Skip to content

Don't allow specify undefined property as required in schema #106

Description

@ikokostya

Versions

  • Node.js: 8.12.0
  • swagger-parser: 6.0.2

Code example

API specification:

openapi: '3.0.2'
info:
  version: v1
  title: test
paths:
  /:
    post:
      requestBody:
        required: true
        content:
          'application/json':
            schema:
              type: object
              properties:
                foo:
                  type: string
              required:
                - foo
                - bar # This property is not defined!
              additionalProperties: false
      responses:
        200:
          description: Success
const SwaggerParser = require('swagger-parser');

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

Expected behavior

Validation error: property bar is required, but it's not defined.

Actual behavior

No errors.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions