Skip to content

Content-Type is not validated #229

@julrich1

Description

@julrich1

It looks like openapi-backend isn't validating the Content-Type defined in the OpenAPI specification, and worse it will happily pass along payloads that aren't valid. For a quick example, if I have an endpoint defined as such:

     requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                messages:
                  type: array
                  minItems: 1
                  maxItems: 100
                  items:
                    $ref: '#/components/schemas/MessageID'

The validation works great when I pass a Content-Type: application/json header, but if I set the header value to text/plain, the endpoint is called with no validation and the payload is empty. Is there perhaps an easy way to verify the content is as expected?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions