1+ """
2+ Generate an OpenAPI specification from a Python class definition
3+
4+ Copyright 2022-2025, Levente Hunyadi
5+
6+ :see: https://github.com/hunyadi/pyopenapi
7+ """
8+
19import dataclasses
210import hashlib
311import ipaddress
614from http import HTTPStatus
715from typing import Any , Callable , Optional , Union
816
9- from strong_typing .core import JsonType
17+ from strong_typing .core import JsonType , Schema
1018from strong_typing .docstring import Docstring , parse_type
1119from strong_typing .inspection import is_generic_list , is_type_optional , is_type_union , unwrap_generic_list , unwrap_optional_type , unwrap_union_types
1220from strong_typing .name import python_type_to_name
13- from strong_typing .schema import JsonSchemaGenerator , Schema , SchemaOptions , get_schema_identifier , register_schema
21+ from strong_typing .schema import JsonSchemaGenerator , SchemaOptions , get_schema_identifier , register_schema
1422from strong_typing .serialization import json_dump_string , object_to_json
1523
1624from .operations import EndpointOperation , HTTPMethod , get_endpoint_events , get_endpoint_operations
@@ -208,7 +216,7 @@ def __init__(
208216 if sample_transformer :
209217 self .sample_transformer = sample_transformer
210218 else :
211- self .sample_transformer = lambda sample : sample # noqa: E731
219+ self .sample_transformer = lambda sample : sample
212220
213221 def _get_value (self , example : Any ) -> JsonType :
214222 return self .sample_transformer (object_to_json (example ))
@@ -221,7 +229,7 @@ def get_named(self, example: Any) -> tuple[str, JsonType]:
221229
222230 name : Optional [str ] = None
223231
224- if type (example ).__str__ is not object .__str__ :
232+ if type (example ).__str__ is not object .__str__ : # type: ignore[comparison-overlap]
225233 friendly_name = str (example )
226234 if friendly_name .isprintable ():
227235 name = friendly_name
@@ -315,7 +323,7 @@ def build_response(self, options: ResponseOptions) -> dict[str, Union[Response,
315323
316324 def _build_response (
317325 self ,
318- response_type : type ,
326+ response_type : Optional [ type ] ,
319327 description : str ,
320328 examples : Optional [list [Any ]] = None ,
321329 ) -> Response :
0 commit comments