mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
openapi: Remove unused to_python_type function.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
aa0768a1a4
commit
89277e84df
@@ -476,22 +476,6 @@ def validate_schema(schema: Dict[str, Any]) -> None:
|
|||||||
validate_schema(schema["additionalProperties"])
|
validate_schema(schema["additionalProperties"])
|
||||||
|
|
||||||
|
|
||||||
def to_python_type(py_type: str) -> type:
|
|
||||||
"""Transform an OpenAPI-like type to a Python one.
|
|
||||||
https://swagger.io/docs/specification/data-models/data-types
|
|
||||||
"""
|
|
||||||
TYPES = {
|
|
||||||
"string": str,
|
|
||||||
"number": float,
|
|
||||||
"integer": int,
|
|
||||||
"boolean": bool,
|
|
||||||
"array": list,
|
|
||||||
"object": dict,
|
|
||||||
}
|
|
||||||
|
|
||||||
return TYPES[py_type]
|
|
||||||
|
|
||||||
|
|
||||||
def likely_deprecated_parameter(parameter_description: str) -> bool:
|
def likely_deprecated_parameter(parameter_description: str) -> bool:
|
||||||
if "**Changes**: Deprecated" in parameter_description:
|
if "**Changes**: Deprecated" in parameter_description:
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ from zerver.openapi.openapi import (
|
|||||||
get_openapi_parameters,
|
get_openapi_parameters,
|
||||||
get_openapi_paths,
|
get_openapi_paths,
|
||||||
openapi_spec,
|
openapi_spec,
|
||||||
to_python_type,
|
|
||||||
validate_against_openapi_schema,
|
validate_against_openapi_schema,
|
||||||
validate_request,
|
validate_request,
|
||||||
validate_schema,
|
validate_schema,
|
||||||
@@ -167,19 +166,6 @@ class OpenAPIToolsTest(ZulipTestCase):
|
|||||||
finally:
|
finally:
|
||||||
openapi_spec.openapi()["paths"].pop("testing", None)
|
openapi_spec.openapi()["paths"].pop("testing", None)
|
||||||
|
|
||||||
def test_to_python_type(self) -> None:
|
|
||||||
TYPES = {
|
|
||||||
"string": str,
|
|
||||||
"number": float,
|
|
||||||
"integer": int,
|
|
||||||
"boolean": bool,
|
|
||||||
"array": list,
|
|
||||||
"object": dict,
|
|
||||||
}
|
|
||||||
|
|
||||||
for oa_type, py_type in TYPES.items():
|
|
||||||
self.assertEqual(to_python_type(oa_type), py_type)
|
|
||||||
|
|
||||||
def test_live_reload(self) -> None:
|
def test_live_reload(self) -> None:
|
||||||
# Force the reload by making the last update date < the file's last
|
# Force the reload by making the last update date < the file's last
|
||||||
# modified date
|
# modified date
|
||||||
|
|||||||
Reference in New Issue
Block a user