Skip to content

Example items for prefixItems are null #10400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
maksim-pinguin opened this issue Apr 3, 2025 · 0 comments
Open

Example items for prefixItems are null #10400

maksim-pinguin opened this issue Apr 3, 2025 · 0 comments

Comments

@maksim-pinguin
Copy link

maksim-pinguin commented Apr 3, 2025

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

@maksim-pinguin maksim-pinguin changed the title Expample items for prefixItems are null Example items for prefixItems are null Apr 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants