from pydantic.error_wrappers import ErrorWrapper
from pydantic.errors import MissingError
from pydantic.fields import (
+ SHAPE_FROZENSET,
SHAPE_LIST,
SHAPE_SEQUENCE,
SHAPE_SET,
sequence_shapes = {
SHAPE_LIST,
SHAPE_SET,
+ SHAPE_FROZENSET,
SHAPE_TUPLE,
SHAPE_SEQUENCE,
SHAPE_TUPLE_ELLIPSIS,
import http
-from typing import Optional
+from typing import FrozenSet, Optional
from fastapi import FastAPI, Path, Query
@app.get("/enum-status-code", status_code=http.HTTPStatus.CREATED)
def get_enum_status_code():
return "foo bar"
+
+
+@app.get("/query/frozenset")
+def get_query_type_frozenset(query: FrozenSet[int] = Query(...)):
+ return ",".join(map(str, sorted(query)))
"operationId": "get_enum_status_code_enum_status_code_get",
}
},
+ "/query/frozenset": {
+ "get": {
+ "summary": "Get Query Type Frozenset",
+ "operationId": "get_query_type_frozenset_query_frozenset_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "Query",
+ "uniqueItems": True,
+ "type": "array",
+ "items": {"type": "integer"},
+ },
+ "name": "query",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
+ }
+ },
},
"components": {
"schemas": {
("/query/param-required/int", 422, response_missing),
("/query/param-required/int?query=50", 200, "foo bar 50"),
("/query/param-required/int?query=foo", 422, response_not_valid_int),
+ ("/query/frozenset/?query=1&query=1&query=2", 200, "1,2"),
],
)
def test_get_path(path, expected_status, expected_response):