def test_get_openapi_types(): type_converter = OpenApiTypeConverter() openapi_type = type_converter.get_openapi_type_of_parameter( inspect.Parameter("param", kind=inspect.Parameter.POSITIONAL_OR_KEYWORD, annotation=UUID) ) assert openapi_type == Schema(type="string", format="uuid") openapi_type = type_converter.get_openapi_type_of_parameter( inspect.Parameter("param", kind=inspect.Parameter.POSITIONAL_OR_KEYWORD, annotation=int) ) assert openapi_type == Schema(type="integer")
def test_openapi_types_base_model(): type_converter = OpenApiTypeConverter() openapi_type = type_converter.get_openapi_type_of_parameter( inspect.Parameter("param", kind=inspect.Parameter.POSITIONAL_OR_KEYWORD, annotation=model.Environment) ) assert openapi_type.ref == type_converter.ref_prefix + "Environment" environment_type = type_converter.resolve_reference(openapi_type.ref) assert environment_type.required == ["id", "name", "project_id", "repo_url", "repo_branch", "settings", "halted"]