flask-ast-openapi 0.2.1__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {flask_ast_openapi-0.2.1/src/flask_ast_openapi.egg-info → flask_ast_openapi-0.2.2}/PKG-INFO +1 -1
- {flask_ast_openapi-0.2.1 → flask_ast_openapi-0.2.2}/pyproject.toml +1 -1
- {flask_ast_openapi-0.2.1 → flask_ast_openapi-0.2.2}/src/flask_ast_openapi/generator.py +33 -19
- {flask_ast_openapi-0.2.1 → flask_ast_openapi-0.2.2/src/flask_ast_openapi.egg-info}/PKG-INFO +1 -1
- {flask_ast_openapi-0.2.1 → flask_ast_openapi-0.2.2}/tests/test_generator.py +43 -6
- {flask_ast_openapi-0.2.1 → flask_ast_openapi-0.2.2}/LICENSE +0 -0
- {flask_ast_openapi-0.2.1 → flask_ast_openapi-0.2.2}/README.md +0 -0
- {flask_ast_openapi-0.2.1 → flask_ast_openapi-0.2.2}/setup.cfg +0 -0
- {flask_ast_openapi-0.2.1 → flask_ast_openapi-0.2.2}/src/flask_ast_openapi/__init__.py +0 -0
- {flask_ast_openapi-0.2.1 → flask_ast_openapi-0.2.2}/src/flask_ast_openapi/cli.py +0 -0
- {flask_ast_openapi-0.2.1 → flask_ast_openapi-0.2.2}/src/flask_ast_openapi/swagger.py +0 -0
- {flask_ast_openapi-0.2.1 → flask_ast_openapi-0.2.2}/src/flask_ast_openapi.egg-info/SOURCES.txt +0 -0
- {flask_ast_openapi-0.2.1 → flask_ast_openapi-0.2.2}/src/flask_ast_openapi.egg-info/dependency_links.txt +0 -0
- {flask_ast_openapi-0.2.1 → flask_ast_openapi-0.2.2}/src/flask_ast_openapi.egg-info/entry_points.txt +0 -0
- {flask_ast_openapi-0.2.1 → flask_ast_openapi-0.2.2}/src/flask_ast_openapi.egg-info/requires.txt +0 -0
- {flask_ast_openapi-0.2.1 → flask_ast_openapi-0.2.2}/src/flask_ast_openapi.egg-info/top_level.txt +0 -0
- {flask_ast_openapi-0.2.1 → flask_ast_openapi-0.2.2}/tests/test_cli.py +0 -0
- {flask_ast_openapi-0.2.1 → flask_ast_openapi-0.2.2}/tests/test_package.py +0 -0
- {flask_ast_openapi-0.2.1 → flask_ast_openapi-0.2.2}/tests/test_swagger.py +0 -0
|
@@ -430,11 +430,12 @@ class FlaskASTOpenAPI:
|
|
|
430
430
|
route.path
|
|
431
431
|
)
|
|
432
432
|
|
|
433
|
-
parameters.extend(
|
|
434
|
-
self.build_query_parameters_from_names(
|
|
435
|
-
route.query_parameter_names
|
|
436
|
-
|
|
437
|
-
|
|
433
|
+
parameters.extend(
|
|
434
|
+
self.build_query_parameters_from_names(
|
|
435
|
+
route.query_parameter_names,
|
|
436
|
+
route.request_schema,
|
|
437
|
+
)
|
|
438
|
+
)
|
|
438
439
|
response_status_codes = list(
|
|
439
440
|
route.response_status_codes
|
|
440
441
|
)
|
|
@@ -793,20 +794,33 @@ class FlaskASTOpenAPI:
|
|
|
793
794
|
)
|
|
794
795
|
|
|
795
796
|
return parameters
|
|
796
|
-
def build_query_parameters_from_names(
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
797
|
+
def build_query_parameters_from_names(
|
|
798
|
+
self,
|
|
799
|
+
names: list[str],
|
|
800
|
+
request_schema: dict[str, Any] | None = None,
|
|
801
|
+
) -> list[dict[str, Any]]:
|
|
802
|
+
"""Build OpenAPI query parameters from their names."""
|
|
803
|
+
|
|
804
|
+
schema_properties = (
|
|
805
|
+
request_schema.get("properties", {})
|
|
806
|
+
if request_schema
|
|
807
|
+
else {}
|
|
808
|
+
)
|
|
809
|
+
required_names = set(
|
|
810
|
+
request_schema.get("required", [])
|
|
811
|
+
if request_schema
|
|
812
|
+
else []
|
|
813
|
+
)
|
|
814
|
+
|
|
815
|
+
return [
|
|
816
|
+
{
|
|
817
|
+
"name": name,
|
|
818
|
+
"in": "query",
|
|
819
|
+
"required": name in required_names,
|
|
820
|
+
"schema": schema_properties.get(name, {"type": "string"}),
|
|
821
|
+
}
|
|
822
|
+
for name in names
|
|
823
|
+
]
|
|
810
824
|
def function_uses_json_body(self,function: ast.FunctionDef | ast.AsyncFunctionDef,) -> bool:
|
|
811
825
|
"""Check whether a route function reads a JSON request body."""
|
|
812
826
|
|
|
@@ -908,7 +908,7 @@ def get_users():
|
|
|
908
908
|
]
|
|
909
909
|
|
|
910
910
|
|
|
911
|
-
def test_build_openapi_operation_includes_query_parameters(tmp_path):
|
|
911
|
+
def test_build_openapi_operation_includes_query_parameters(tmp_path):
|
|
912
912
|
generator = FlaskASTOpenAPI(tmp_path)
|
|
913
913
|
|
|
914
914
|
route = RouteDefinition(
|
|
@@ -920,7 +920,7 @@ def test_build_openapi_operation_includes_query_parameters(tmp_path):
|
|
|
920
920
|
|
|
921
921
|
operation = generator.build_openapi_operation(route)
|
|
922
922
|
|
|
923
|
-
assert operation["parameters"] == [
|
|
923
|
+
assert operation["parameters"] == [
|
|
924
924
|
{
|
|
925
925
|
"name": "page",
|
|
926
926
|
"in": "query",
|
|
@@ -937,10 +937,47 @@ def test_build_openapi_operation_includes_query_parameters(tmp_path):
|
|
|
937
937
|
"type": "string",
|
|
938
938
|
},
|
|
939
939
|
},
|
|
940
|
-
]
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
def
|
|
940
|
+
]
|
|
941
|
+
|
|
942
|
+
|
|
943
|
+
def test_build_openapi_operation_uses_request_schema_for_query_parameters(
|
|
944
|
+
tmp_path,
|
|
945
|
+
):
|
|
946
|
+
generator = FlaskASTOpenAPI(tmp_path)
|
|
947
|
+
|
|
948
|
+
route = RouteDefinition(
|
|
949
|
+
function_name="get_users",
|
|
950
|
+
path="/users",
|
|
951
|
+
methods=["GET"],
|
|
952
|
+
query_parameter_names=["page", "page_size"],
|
|
953
|
+
request_schema={
|
|
954
|
+
"type": "object",
|
|
955
|
+
"properties": {
|
|
956
|
+
"page": {"type": "integer"},
|
|
957
|
+
"page_size": {"type": "integer"},
|
|
958
|
+
},
|
|
959
|
+
},
|
|
960
|
+
)
|
|
961
|
+
|
|
962
|
+
operation = generator.build_openapi_operation(route)
|
|
963
|
+
|
|
964
|
+
assert operation["parameters"] == [
|
|
965
|
+
{
|
|
966
|
+
"name": "page",
|
|
967
|
+
"in": "query",
|
|
968
|
+
"required": False,
|
|
969
|
+
"schema": {"type": "integer"},
|
|
970
|
+
},
|
|
971
|
+
{
|
|
972
|
+
"name": "page_size",
|
|
973
|
+
"in": "query",
|
|
974
|
+
"required": False,
|
|
975
|
+
"schema": {"type": "integer"},
|
|
976
|
+
},
|
|
977
|
+
]
|
|
978
|
+
|
|
979
|
+
|
|
980
|
+
def test_build_openapi_operation_combines_path_and_query_parameters(
|
|
944
981
|
tmp_path,
|
|
945
982
|
):
|
|
946
983
|
generator = FlaskASTOpenAPI(tmp_path)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flask_ast_openapi-0.2.1 → flask_ast_openapi-0.2.2}/src/flask_ast_openapi.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{flask_ast_openapi-0.2.1 → flask_ast_openapi-0.2.2}/src/flask_ast_openapi.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{flask_ast_openapi-0.2.1 → flask_ast_openapi-0.2.2}/src/flask_ast_openapi.egg-info/requires.txt
RENAMED
|
File without changes
|
{flask_ast_openapi-0.2.1 → flask_ast_openapi-0.2.2}/src/flask_ast_openapi.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|