swagger-api / swagger-api/swagger-ui

Example items for prefixItems are null

Open
#10,400 1 comment 4 reactions 1 assignee View on GitHub

@Divyanshu-Mishra9620 is already working on this.

Since Oct 9, 2025.

P2 type: bug type: enhancement
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: Ubunut
  • Browser: Firefox
  • Version: 136.0.3 (64-bit)
  • Method of installation: fastapi
  • Swagger-UI version: 5.20.1 [edit: was able to reproduce this also with version: 5.20.4]
  • Swagger/OpenAPI version: OpenAPI 3.1.0
Content & configuration

Example Swagger/OpenAPI definition:

{
  "openapi": "3.1.0",
  "info": {
    "title": "FastAPI",
    "version": "0.1.0"
  },
  "paths": {
    "/test_model": {
      "post": {
        "summary": "Test Model",
        "operationId": "test_model_test_model_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TestModel"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TestModel"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ChildModel1": {
        "properties": {
          "c1": {
            "type": "string",
            "title": "C1"
          }
        },
        "type": "object",
        "required": [
          "c1"
        ],
        "title": "ChildModel1"
      },
      "ChildModel3": {
        "properties": {
          "c3": {
            "type": "string",
            "title": "C3"
          }
        },
        "type": "object",
        "required": [
          "c3"
        ],
        "title": "ChildModel3"
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "TestModel": {
        "properties": {
          "tuple_field1": {
            "prefixItems": [
              {
                "type": "integer"
              },
              {
                "type": "string"
              }
            ],
            "type": "array",
            "maxItems": 2,
            "minItems": 2,
            "title": "Tuple Field1"
          },
          "tuple_field2": {
            "prefixItems": [
              {
                "$ref": "#/components/schemas/ChildModel1"
              },
              {
                "$ref": "#/components/schemas/ChildModel3"
              }
            ],
            "type": "array",
            "maxItems": 2,
            "minItems": 2,
            "title": "Tuple Field2"
          }
        },
        "type": "object",
        "required": [
          "tuple_field1",
          "tuple_field2"
        ],
        "title": "TestModel"
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      }
    }
  }
}
Expected behavior

Get a valid example for try out with prefixItems.

Screenshots

example in swagger ui:
Image

schema in swagger ui (lftm):
Image

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.