Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use 'in' operator to search for '**' in undefined #2152

Closed
DymitrStinski opened this issue May 6, 2022 · 4 comments · Fixed by #2157
Closed

Cannot use 'in' operator to search for '**' in undefined #2152

DymitrStinski opened this issue May 6, 2022 · 4 comments · Fixed by #2157
Assignees
Labels
released t/bug Something isn't working

Comments

@DymitrStinski
Copy link

Describe the bug
One of valid JSONPath stopped working after update to spectral 6.x.

To Reproduce

  1. Given this OpenAPI/AsyncAPI document '...'
---
swagger: '2.0'
x-samples-languages:
  - java
x-project-id: apiv1
host: myhost.com
info:
  title: 'Order Management API'
  description: The Order Management API.
  version: '1.2'
schemes:
  - http
  - https
basePath: /v1
consumes:
  - application/json
produces:
  - application/json
tags:
  - name: Order
    description: 'Order description.'
paths:
  /orders/getOrder:
    post:
      description: Creates a request.
      operationId: getOrder
      tags:
        - Order
      parameters:
        - in: body
          name: 'getOrderRequest'
          description: Contains both required and optional elements to make a order request.
          required: true
          schema:
            $ref: '#/definitions/GetOrderRequest'
      responses:
        '200':
          description: 'Successful response.'
          schema:
            $ref: '#/definitions/GetOrderResponse'
definitions:
  GetOrderResponse:
    type: object
    description: Contains service response object with order information.
    allOf:
      - $ref: "#/definitions/Order"
      - type: object
        properties:
          Request:
            $ref: '#/definitions/GetOrderRequest'
            description: Copy of the service request object.
          errors:
            type: array
            description: Lists detailed error information. For a successful response, this element will not exist in the response.
            items:
              type: object
              required:
                - category
                - type
              properties:
                category:
                  type: string
                  example: 'BAD_REQUEST'
                  description: The category of the error.
                type:
                  type: string
                  example: 'REQUIRED_FIELD_MISSING'
                  description: The type of the error.
                description:
                  type: string
                  example: 'may not be null'
                  description: The detailed description of the error.

  GetOrderRequest:
    type: object
    description: Contains both required and optional elements to make a request.
    required:
      - confirmationId
    properties:
      confirmationId:
        type: string
        pattern: '^[A-Z0-9]{6,}$'
        example: 'ABCDEF'
        description: The order reference ID.
      givenName:
        type: string
        example: 'John'
        description: The first name.
      middleName:
        type: string
        example: 'W'
        description: The middle name or the initial of the middle name.
      surname:
        type: string
        example: 'Smith'
        description: The last name.

  Order:
    type: object
    description: Contains order information.
    properties:
      contactInfo:
        type: string
        description: Contains contact information for the order.

and rule:

camel-case-property-name:
  description: "Name of property must be provided in camelCase notation."
  severity: error
  type: style
  resolved: false
  given:
    - "$.definitions.*.properties"
    - "$.definitions.*.allOf.*.properties"
  then:
    field: "@key"
    function: casing
    functionOptions:
      type: camel
  1. Run this CLI command:
    npx spectral lint -r rules.yaml spec.yaml

  2. See error

Error running Spectral!
Use --verbose flag to print the error stack.
Error #1: Cannot use 'in' operator to search for '**' in undefined

Expected behavior
49:19 error camel-case-property-name Name of property must be provided in camelCase notation. definitions.GetOrderResponse.allOf[1].properties.Request

Environment:

  • Library version: 6.3.0
  • OS: Windows 10
@P0lip P0lip added the t/bug Something isn't working label May 6, 2022
@P0lip
Copy link
Contributor

P0lip commented May 6, 2022

Fixed in P0lip/nimma@d8ef191.
Going to bump that dep next week :)

@P0lip P0lip self-assigned this May 6, 2022
@CornerTakenQuickly
Copy link

We are also experiencing this issue. It would help us a lot if you could post here when a fix is published to npm.

@P0lip
Copy link
Contributor

P0lip commented May 16, 2022

The PR is up

@stoplight-bot
Copy link
Collaborator

🎉 This issue has been resolved in version @stoplight/spectral-core-v1.12.2 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

@P0lip P0lip reopened this May 19, 2022
@P0lip P0lip closed this as completed May 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants