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

Vaildation error for tuple since version 8.0.0 #122

Closed
ikokostya opened this issue Jul 10, 2019 · 2 comments
Closed

Vaildation error for tuple since version 8.0.0 #122

ikokostya opened this issue Jul 10, 2019 · 2 comments

Comments

@ikokostya
Copy link

ikokostya commented Jul 10, 2019

Versions

  • swagger-parser: 8.0.0
  • node.js v10.16.0

Description

swagger-parser in version 8.0.0 stops validate tuples in response schema.

Code example

# api.yaml
openapi: '3.0.1'
info:
  version: v1
  title: test
paths:
  /:
    get:
      responses:
        200:
          description: Success
          content:
            application/json:
              schema:
                type: array
                items:
                  - type: number
                  - type: number
// t.js
const SwaggerParser = require('swagger-parser');

SwaggerParser.validate('api.yml')
  .then((api) => console.log('done'))
  .catch((err) => console.error(err.message));

Actual behavior

Validation error:

$ node t.js 
Swagger schema validation failed. 
  Data does not match any schemas from 'oneOf' at #/paths///post/requestBody
    Data does not match any schemas from 'oneOf' at #/paths///post/requestBody/content/application/json/schema
      Data does not match any schemas from 'oneOf' at #/content/application/json/schema/items
        Expected type object but found type array at #/items
        Expected type object but found type array at #/items
      Missing required property: $ref at #/content/application/json/schema
    Missing required property: $ref at #/paths///post/requestBody
 
JSON_OBJECT_VALIDATION_FAILED

Expected behavior

No errors.

Additional information

There are no errors in previous version 7.x:

$ npm i swagger-parser@7
+ swagger-parser@7.0.1
removed 1 package, updated 1 package and audited 128 packages in 1.37s
found 0 vulnerabilities

$ node t.js
done
@ikokostya ikokostya changed the title Vaildation error for tuple Vaildation error for tuple since version 8.0.0 Jul 10, 2019
@ikokostya
Copy link
Author

ikokostya commented Jul 10, 2019

Looks like this behavior follows to current state of specification OAI/OpenAPI-Specification#1026

@JamesMessinger
Copy link
Member

Looks like this behavior follows to current state of specification OAI/OpenAPI-Specification#1026

Correct. This isn't a bug in Swagger Parser. It's a design limitation of the OpenAPI and/or JSON Schema specifications.

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

2 participants