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 at paths is not detected by validator #176

Open
lenchvolodymyr opened this issue Jul 1, 2021 · 6 comments
Open

Semantic error at paths is not detected by validator #176

lenchvolodymyr opened this issue Jul 1, 2021 · 6 comments

Comments

@lenchvolodymyr
Copy link

The swagger-parser doesn't validate semantic error when path parameter has invalid type.

This schema is invalid according to swagger-editor

openapi: 3.0.3
info:
  title: ''
  version: '1.0'
paths:
  '/items/{id}':
    get:
      parameters:
        - name: id
          in: query
          required: true
          schema:
            type: object
            nullable: false
      responses:
        '200':
          description: ''
components: {}

It shows the following error:

Semantic error at paths./items/{id}
Declared path parameter "id" needs to be defined as a path parameter at either the path or operation level

But swagger-parser doesn't throw any errors when validating the schema.

const SwaggerParser = require('swagger-parser');

SwaggerParser.validate(script, {}, (err, api) => {...});
@jaishirole
Copy link
Contributor

@lenchvolodymyr
This is so due to no validations applied for OpenAPI v3.

if (api.openapi) {

@lenchvolodymyr
Copy link
Author

@jaishirole thanks for the response, I see now. I would keep the issue open until it's implemented for OpenAPI

@jaishirole
Copy link
Contributor

@lenchvolodymyr Sure.

@jaishirole
Copy link
Contributor

@lenchvolodymyr This PR hopefully shall address this issue for OpenAPI v3:
https://github.com/APIDevTools/swagger-parser/pull/179/files

@lenchvolodymyr
Copy link
Author

@jaishirole nice, hope it will be merged soon. Thank you!

@jurgen-kammcs
Copy link

Any news on this?

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

3 participants