diff --git a/end_to_end_tests/openapi.json b/end_to_end_tests/openapi.json index f384dbbdd..4af206d39 100644 --- a/end_to_end_tests/openapi.json +++ b/end_to_end_tests/openapi.json @@ -1063,7 +1063,6 @@ "type": "object" }, "ModelWithAdditionalPropertiesInlined": { - "title": "ModelWithAdditionalPropertiesInlined", "type": "object", "properties": { "a_number": { diff --git a/openapi_python_client/parser/properties/model_property.py b/openapi_python_client/parser/properties/model_property.py index 0af0b1cea..a40460886 100644 --- a/openapi_python_client/parser/properties/model_property.py +++ b/openapi_python_client/parser/properties/model_property.py @@ -180,18 +180,18 @@ def build_model_property( parent_name: The name of the property that this property is inside of (affects class naming) config: Config data for this run of the generator, used to modifying names """ - class_name = data.title or name + class_string = data.title or name if parent_name: - class_name = f"{utils.pascal_case(parent_name)}{utils.pascal_case(class_name)}" - class_info = Class.from_string(string=class_name, config=config) + class_string = f"{utils.pascal_case(parent_name)}{utils.pascal_case(class_string)}" + class_info = Class.from_string(string=class_string, config=config) - property_data = _process_properties(data=data, schemas=schemas, class_name=class_name, config=config) + property_data = _process_properties(data=data, schemas=schemas, class_name=class_info.name, config=config) if isinstance(property_data, PropertyError): return property_data, schemas schemas = property_data.schemas additional_properties, schemas = _get_additional_properties( - schema_additional=data.additionalProperties, schemas=schemas, class_name=class_name, config=config + schema_additional=data.additionalProperties, schemas=schemas, class_name=class_info.name, config=config ) if isinstance(additional_properties, Property): property_data.relative_imports.update(additional_properties.get_imports(prefix="..")) diff --git a/tests/test_parser/test_properties/test_model_property.py b/tests/test_parser/test_properties/test_model_property.py index b366c2333..abe0e5323 100644 --- a/tests/test_parser/test_properties/test_model_property.py +++ b/tests/test_parser/test_properties/test_model_property.py @@ -178,7 +178,7 @@ def test_bad_props_return_error(self): assert err == PropertyError(detail="unknown type not_real", data=oai.Schema(type="not_real")) def test_bad_additional_props_return_error(self): - from openapi_python_client.parser.properties import Schemas, build_model_property + from openapi_python_client.parser.properties import Config, Schemas, build_model_property additional_properties = oai.Schema( type="object", @@ -190,7 +190,7 @@ def test_bad_additional_props_return_error(self): schemas = Schemas() err, new_schemas = build_model_property( - data=data, name="prop", schemas=schemas, required=True, parent_name=None, config=MagicMock() + data=data, name="prop", schemas=schemas, required=True, parent_name=None, config=Config() ) assert new_schemas == schemas