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

Required parameter in body not validated without $ref #138

Open
danopz opened this issue Feb 9, 2017 · 0 comments · May be fixed by #185
Open

Required parameter in body not validated without $ref #138

danopz opened this issue Feb 9, 2017 · 0 comments · May be fixed by #185

Comments

@danopz
Copy link
Contributor

danopz commented Feb 9, 2017

Required Body parameters are not validated for their existence if they are not defined by $ref.
Given the following swagger.yml file:

swagger: '2.0'
info:
  title: foobar
  version: 0.0.1
schemes:
  - https
  - http
produces:
  - application/json
paths:
  /foo:
    post:
      consumes:
        - application/json
      parameters:
        - in: body
          name: body
          required: true
          schema:
            type: object
            required:
              - foo
            properties:
              foo:
                type: string
              bar:
                type: string
      responses:
        default:
          description: response
          schema:
            type: object
            properties:
              foo:
                type: string

If I POST an empty String with Content-Type: application/json it correctly validates as "Got value '' of type string. Value must be of type(s): ('object',)".
But now when I POST an empty JSON object it will validate as true.
Validation works if I POST an Integer for the foo param: "Got value 1 of type integer. Value must be of type(s): ('string',)"

If one define the body schema via $ref in definitions everything works fine, missing parameters are validated.

For validation I am using a populated Flex Request and flex.core.validate_api_request.

danopz added a commit to danopz/flex that referenced this issue Nov 21, 2017
@danopz danopz linked a pull request Nov 22, 2017 that will close this issue
danopz added a commit to danopz/flex that referenced this issue Dec 6, 2017
danopz added a commit to danopz/flex that referenced this issue Feb 22, 2018
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

Successfully merging a pull request may close this issue.

1 participant