Skip to content

Request validation incorrectly treats optional requestBody as required when only one content type is defined #817

@dgmora

Description

@dgmora

The request body validator schema ignores the requestBody.required field from the OpenAPI spec. Instead, it treats the request body as required whenever there is exactly one content type defined:

if (_.keys(requestBody.content).length === 1) {
// if application/json is the only specified format, it's required
requestBodySchema.required.push('requestBody');
}

Per the https://swagger.io/docs/specification/v3_0/describing-request-body/describing-request-body/, requestBody.required defaults to false. The number of content types should not determine whether the body is required. Is there a reason for this difference? Thanks!

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