Skip to content

Swagger UI: Allow setting an example with the null value (even if it is not part of the type) #10747

@stdedos

Description

@stdedos

Q&A (please complete the following information)

  • OS: [e.g. macOS]
  • Browser: [e.g. chrome, safari]
  • Version: [e.g. 22]
  • Method of installation: [e.g. npm, dist assets]
  • Swagger-UI version: [e.g. 3.10.0]
  • Swagger/OpenAPI version: [e.g. Swagger 2.0, OpenAPI 3.0]

OAS 3.1, Swagger UI 5.31.2

Content & configuration

Swagger/OpenAPI definition:

# your YAML here

Swagger-UI configuration options:

SwaggerUI({
  // your config options here
})

What FastAPI+Pydantic provides, but with vendored assets

?yourQueryStringConfig

Screenshots

How can we help?

I have

          "success": {
            "type": "boolean",
            "title": "Success",
            "default": false
          },

But I would like the rendered default to be null - even if the type of the argument is success: bool (or, at least with success: bool | None = None (PS: Python)

IIUC, partially of the code responsible is here

const primitives = {
"string": () => "string",
"string_email": () => "user@example.com",
"string_date-time": () => new Date().toISOString(),
"string_date": () => new Date().toISOString().substring(0, 10),
"string_uuid": () => "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"string_hostname": () => "example.com",
"string_ipv4": () => "198.51.100.42",
"string_ipv6": () => "2001:0db8:5b96:0000:0000:426f:8e17:642a",
"number": () => 0,
"number_float": () => 0.0,
"integer": () => 0,
"boolean": (schema) => typeof schema.default === "boolean" ? schema.default : true
}

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