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

Request validation does not work properly in case request schema is an object "derived" from other object using allOf #116

Open
vyakoviv-vs opened this issue Mar 7, 2019 · 1 comment

Comments

@vyakoviv-vs
Copy link

Hi. I am trying to validate a request which is an object "derived" from other object using allOf

components:
  schemas:
    Base:
      type: object
      properties:
        ctime:
          type: integer

    ExtendedResource:
      allOf:
        - $ref: '#/components/schemas/Base'
        - type: object
          properties:
            name:
              type: string
            options:
              type: object
              properties:
                option_1:
                  type: string
                option_2:
                  type: string
            capabilities:
              type: object
              properties:
                capability_1:
                  type: string
                capability_2:
                  type: string

Currently validator does not raise any exceptions in case of the following request body:

{'name': 'ext_res', 
 'options': {'option_1': 'a', 'option_3': 'b'}, 
 'capabilities': {'capability_1': 'c', 'capability_3': '3'}}

Expecting that options.option_3 or capabilities.capability_3 are rejected.

Many Thanks!

@stojan-jovic
Copy link

I experienced this also for the simple object validation (not only "derived").
Probably you are right that this is bug in the lib, at least according to the official page, but workaround would be to explicitly use additionalProperties: false, for example for capabilities object:

capabilities:
  type: object
  properties:
    capability_1:
      type: string
    capability_2:
      type: string
  additionalProperties: false

And fix in the lib should be very simple, I would say.

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