Skip to content

OpenAPI 3.1.0 support: OpenAPI 3.1 type: […, "null"] incomplete support in parameters #9056

@commonism

Description

@commonism

Q&A (please complete the following information)

Content & configuration

Example Swagger/OpenAPI definition:
https://gist.github.com/commonism/7adcb666278f4070b8f7aabd456faa43

openapi: 3.1.0
info:
  title: ''
  version: 0.0.0
servers:
  - url: http://127.0.0.1/api

security:
  - {}

paths:
  /{path}:
    parameters:
      - $ref: "#/components/parameters/path"
      - $ref: '#/components/parameters/cookie'

    post:
      operationId: post
      requestBody:
        description: "!"
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Any'

      responses:
        '200':
          description: "!"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Any"

      callbacks:
        onData:
          '{$request.query.callbackUrl}/data':
            post:
              requestBody:
                description: "!"
                content:
                  application/json:
                    schema:
                      $ref: "#/components/schemas/Any"
              responses:
                '200':
                  description: "!"
                  content:
                    application/json:
                      schema:
                        $ref: "#/components/schemas/Any"



    get:
      operationId: get
      parameters:
      - $ref: "#/components/parameters/query"
      - $ref: "#/components/parameters/header"

      responses: &resp
        '200':
          description: "!"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Any'
          headers:
            head:
              $ref: "#/components/headers/header"



components:
  schemas:
    Any:
      type: [integer, string, object, array, boolean, "null"]
      items:
        $ref: "#/components/schemas/Any"
      properties:
        next:
          $ref: "#/components/schemas/Any"

  headers:
    header:
      schema:
          $ref: "#/components/schemas/Any"
      style: simple
      explode: false

  parameters:

    query:
      in: query
      name: query
      style: deepObject
      explode: true
      required: true
      schema:
        $ref: "#/components/schemas/Any"

    path:
      in: path
      name: path
      required: true
      schema:
        type: [string, "null"]

    header:
      in: header
      name: header
      required: true
      schema:
        type: [string, "null"]

    cookie:
      in: cookie
      name: cookie
      required: true
      schema:
        type: [string, "null"]

Describe the bug you're encountering

The rendering of the parameters does not reflect the use of OpenAPI 3.1 type as a list.
The use of "null" as list element to indicate "nullable" is not reflected as well.

To reproduce...

Steps to reproduce the behavior:
Paste the yaml to swagger editor.

Expected behavior

Screenshots

Bad types for Response & header
image

all Parameters
image

Callback Response
image

but works for a RequestBody
image

Additional context or thoughts

type: […, "null"] is the preferable way to define nullable in v3.1, using the alternative anyOf: […,{type: "null"}] instead results in a additional/unnecessary level of indirection in models generated from description documents.

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