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

Improper validation when additionalProperties are set to false #958

Open
shubhamkr-cohesity opened this issue Jun 3, 2024 · 0 comments
Open

Comments

@shubhamkr-cohesity
Copy link

I have been doing some tests with this library and came across a situation where the library is unable to validate the request payload properly if some extra fields are present.

Expectation: This should pass.
{ "category": "test" }

Result:
request body has an error: doesn't match schema #/components/schemas/PetWithCategory: property "category" is unsupported

openapi: 3.0.0
info:
  version: 1.0.0
  title: Swagger Petstore
  license:
    name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
  "/pets":
    post:
      summary: Create a pet
      operationId: createPets
      tags:
      - pets
      requestBody:
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/PetWithCategory"
        required: true
      responses:
        '201':
          description: Null response
components:
  schemas:
    PetCategory:
      type: object
      properties:
        category:
          type: string
    PetWithCategory:
      allOf:
      - "$ref": "#/components/schemas/PetCategory"
      - type: object
        properties:
          pet:
            "$ref": "#/components/schemas/Pet"
      additionalProperties: false
    Pet:
      type: object
      required:
      - id
      - name
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
        tag:
          type: string
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

1 participant