redocly-cli icon indicating copy to clipboard operation
redocly-cli copied to clipboard

"Parameter must contain 'schema' or 'content'" is not validated against openAPI 3.0.0 spec

Open azimbelm opened this issue 1 year ago • 1 comments

Describe the bug No validation rule applies that a parameter must contain a 'schema' or a 'content' field. Defined in: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md

A parameter MUST contain either a schema property, or a content property, but not both.

To Reproduce

 responses:
        '200':
          description: My description
        default:
          description: >-
            My description
          headers:
            Content-Type:
              description: ThisHeaderNeedsASchemaOrElseItsNotValid
          content:
            application/json:
              schema:
                format: binary
                title: File download
                type: string

Expected behavior An error should be shown, that the 'A parameter MUST contain either a schema property, or a content property'

Logs

OpenAPI definition 3.0.0/3.1.0

Redocly Version 1.0.0-beta.105

Node.js Version(s) v16.12.0

Additional context https://apitools.dev/swagger-parser/online/ and https://editor.swagger.io/ deliver the error: Swagger schema validation failed. #/paths/.../responses/default/headers/Content-Type must have required property 'schema'

azimbelm avatar Aug 09 '22 11:08 azimbelm

Hi @azimbelm, Thanks for reporting this issue. Looks like the Header type is missing this section from the Parameter type: https://github.com/Redocly/redocly-cli/blob/master/packages/core/src/types/oas3.ts#L139 Another way might be to avoid duplicating the properties and use omitObjectProps.

AntonKozachuk avatar Aug 11 '22 09:08 AntonKozachuk

@AntonKozachuk what do you mean about the Header type missing? Header is not part of Parameters -- they are related to the response, right? https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#headerObject

adamaltman avatar Aug 24 '22 12:08 adamaltman

Ahh, you mean that link is missing that appears in the definition of Parameter type. You are right!

adamaltman avatar Aug 24 '22 12:08 adamaltman