swagger-api / swagger-api/swagger-ui

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

Open
#10,747 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

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 https://github.com/swagger-api/swagger-ui/blob/cc408812fc927e265da158bf68239530740ab4cc/src/core/plugins/samples/fn.js#L6-L19

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/core/plugins/samples/fn.js at the referenced sample-generation code and inspect how default values are selected for the OAS 3.1 example. Reproduce the supplied boolean property case, then verify that a configured null default renders as null even when null is not included in the type.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.