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

Semantic error (path parameter not present in the path) detected in Swagger 2.X but not in OpenAPI 3.X #154

Open
DCollart opened this issue Oct 1, 2020 · 1 comment

Comments

@DCollart
Copy link

DCollart commented Oct 1, 2020

In short, this file contains a semantic error :

openapi: 3.0.1
info:
  title: Sample API
  version: v1
servers:
  - url: 'api.example.com'
paths:
  '/test/{foo}':
    get:
      parameters:
        - name: foo
          in: path
          required: true
          schema:
            type: string
        - name: bar
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Ok
          content:
            application/json:
              schema:
                type: string

You can find this semantic error by posting it into the swagger editor

Semantic error at paths./test/{foo}.get.parameters.1.name
Path parameter "bar" must have the corresponding {bar} segment in the "/test/{foo}" path
Jump to line 16

But I was not able to find this semantic error. Neither in the swagger-cli or the online tool. According to both the file is valid.

I think it's a regression because the same error in version swagger 2.0 was detected as well :

swagger: "2.0"
info:
  title: Sample API
  version: v1
host: api.example.com
basePath: /v1
schemes:
  - https
paths:
  /test/{foo}:
    get:
      summary: Returns a user by ID.
      parameters:
        - in: path
          name: foo
          required: true
          type: string
        - in: path
          name: bar
          required: true
          type: string
      responses:
        200:
          description: OK

Thank you :-)

@jaishirole
Copy link
Contributor

@DCollart I see the reason as: This is so due to no validations applied for OpenAPI v3.

if (api.openapi) {

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

No branches or pull requests

2 participants