Skip to content

Example items for prefixItems are null #10400

Open
@maksim-pinguin

Description

@maksim-pinguin

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions