Skip to content

Fails to validate schema type: file on responses #192

@kirpit

Description

@kirpit

Hi,

Spec validation doesn't support a file type as a schema on responses and simply fails to validate:

swagger: "2.0"
info:
  version: "1.0.0"
  title: "Download app"
paths:
  /download:
    get:
      summary: "Download a file"
      produces:
      - "application/pdf"
      responses:
        200:
          description: OK
          schema:
            type: file

which is perfectly valid spec definition that you can confirm on https://editor.swagger.io/.

>>> from flex import load
>>> load('test.yml')
ValidationError                           Traceback (most recent call last)
<ipython-input-2-ba70e59f9805> in <module>()
----> 1 load('test.yml')
... // snip snip
ValidationError: 'paths':
    - '/download':
        - 'get':
            - 'responses':
                - 200:
                    - 'referenceObject':
                        - 'additionalProperties':
                            - "When `additionalProperties` is False, no unspecified properties are allowed. The following unspecified properties were found:\n\t`{'schema', 'description'}`"
                        - 'required':
                            - '$ref':
                                - 'This value is required'
                    - 'responseObject':
                        - 'schema':
                            - 'type':
                                - 'type':
                                    - 'enum':
                                        - "Invalid value. file is not one of the available options (['null', 'boolean', 'integer', 'number', 'string', 'array', 'object'])"

We can validate the same definition with no issues just by changing the type: file to type: string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions