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

Schema Validation not working when Path Templating and Fixed Paths overlap #9396

Closed
darrencapner opened this issue Jan 4, 2021 · 4 comments

Comments

@darrencapner
Copy link

darrencapner commented Jan 4, 2021

Describe the Issue

I am trying to define an Openapi spec where I have the following paths:

/{id}
/lookups
When I perform a validation on the collection within the API Designer the API Designer Collection validator does not understand a fixed path where there exists a path with a wildcard. The merge window evaluates both paths as one and the suggested merge is nonsensical.

Steps to Reproduce

Definition used below that is causing issues:

/lookups:
    get:
      summary: Lookup Job Values
      description: Lookup values for job fields
      operationId: lookupJobValues
      security:
        - authorizer: []
      parameters:
        - in: path
          name: include
          schema:
            type: string
          required: true
          description: Unique value to return list of possible job field values.
          example: "cancellationReasons"
/{jobid}:
    get:
      summary: Get Job by ID
      description: |
        Retrieve a job by the identifier provided.
        Query Parameters supported are:
        * 'include' will return related entities to a Job. Can ask for 'quote' at this time.
      operationId: getJobById
      security:
        - authorizer: []
      parameters:
        - in: path
          name: jobid
          schema:
            type: string
          required: true
          description: Unique identifier for a job to retrieve.
          example: "{{jobid}}"
        - in: query
          name: include
          schema:
            type: string
            example: quote
          required: false
          description: Include related entities to a Job to be returned in request. Can ask for 'quote' at this time.

Screenshots or Videos
Postman_conflict_merge_screen

Environment Information

  • Platform Type: [e.g. Postman On The Web]
  • Postman Version: December 28th, 2020
  • Operating System: Windows / Chrome Browser

Additional Context

Postman Community Post

@abhinaba-ghosh
Copy link

Hi @darrencapner, this is fixed in current postman version. Feel free to re-open the ticket if you face any diffuculties.

@darrencapner
Copy link
Author

darrencapner commented Mar 19, 2021

I still see the error. I have created an API Spec to verify this scenario using the pre-generated one in the API Designer.

I am using the Web Version of Postman.

openapi: 3.0.0
info:
  version: 0.0.1
  title: test
servers:
  - url: 'http://localhost:3000'
paths:
  /{userid}:
    get:
      summary: 'Sample endpoint: Returns details about a particular user'
      operationId: getUserid
      parameters:
        - name: id
          in: query
          description: ID of the user
          required: true
          schema:
            type: integer
            format: int32
      responses:
        '200':
          description: 'Sample response: Details about a user by ID'
          headers:
            x-next:
              description: A link to the next page of responses
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        default:
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /user:
    get:
      summary: 'Sample endpoint: get details about a particular user'
      operationId: listUser
      tags:
        - user
      parameters:
        - name: id
          in: query
          description: ID of the user
          required: true
          schema:
            type: integer
            format: int32
      responses:
        '200':
          description: 'Sample response: Details about a user by ID'
          headers:
            x-next:
              description: A link to the next page of responses
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        default:
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    User:
      type: object
      required:
        - id
        - name
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
        tag:
          type: string
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: integer
          format: int32
        message:
          type: string
  1. I generate a collection using spec.
  2. Then go to the 'test' tab of the API Designer, and click the 'Validate Again' button of the collection listed (attached).
  3. I click the 'Review Issues' button

I see the following comparison that doesn't look to work as it says can't find path variables in schema.

image

@VShingala
Copy link
Member

@darrencapner Given specification doesn't adhere to OpenAPI specification as it's required to define al path parameters defined in path under parameters of that operation. Here for operation GET /{userid}, no definition of userid is present under parameters so the validator is suggesting mismatch for it.

@darrencapner
Copy link
Author

Yes sorry, my mistake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants