Skip to content

Commit 56d645d

Browse files
authored
Merge branch 'main' into allow-type-and-id-as-attributes
2 parents 2bc51ef + 5805c03 commit 56d645d

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

end_to_end_tests/openapi.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,6 @@
10631063
"type": "object"
10641064
},
10651065
"ModelWithAdditionalPropertiesInlined": {
1066-
"title": "ModelWithAdditionalPropertiesInlined",
10671066
"type": "object",
10681067
"properties": {
10691068
"a_number": {

openapi_python_client/parser/properties/model_property.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,18 +180,18 @@ def build_model_property(
180180
parent_name: The name of the property that this property is inside of (affects class naming)
181181
config: Config data for this run of the generator, used to modifying names
182182
"""
183-
class_name = data.title or name
183+
class_string = data.title or name
184184
if parent_name:
185-
class_name = f"{utils.pascal_case(parent_name)}{utils.pascal_case(class_name)}"
186-
class_info = Class.from_string(string=class_name, config=config)
185+
class_string = f"{utils.pascal_case(parent_name)}{utils.pascal_case(class_string)}"
186+
class_info = Class.from_string(string=class_string, config=config)
187187

188-
property_data = _process_properties(data=data, schemas=schemas, class_name=class_name, config=config)
188+
property_data = _process_properties(data=data, schemas=schemas, class_name=class_info.name, config=config)
189189
if isinstance(property_data, PropertyError):
190190
return property_data, schemas
191191
schemas = property_data.schemas
192192

193193
additional_properties, schemas = _get_additional_properties(
194-
schema_additional=data.additionalProperties, schemas=schemas, class_name=class_name, config=config
194+
schema_additional=data.additionalProperties, schemas=schemas, class_name=class_info.name, config=config
195195
)
196196
if isinstance(additional_properties, Property):
197197
property_data.relative_imports.update(additional_properties.get_imports(prefix=".."))

tests/test_parser/test_properties/test_model_property.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def test_bad_props_return_error(self):
178178
assert err == PropertyError(detail="unknown type not_real", data=oai.Schema(type="not_real"))
179179

180180
def test_bad_additional_props_return_error(self):
181-
from openapi_python_client.parser.properties import Schemas, build_model_property
181+
from openapi_python_client.parser.properties import Config, Schemas, build_model_property
182182

183183
additional_properties = oai.Schema(
184184
type="object",
@@ -190,7 +190,7 @@ def test_bad_additional_props_return_error(self):
190190
schemas = Schemas()
191191

192192
err, new_schemas = build_model_property(
193-
data=data, name="prop", schemas=schemas, required=True, parent_name=None, config=MagicMock()
193+
data=data, name="prop", schemas=schemas, required=True, parent_name=None, config=Config()
194194
)
195195

196196
assert new_schemas == schemas

0 commit comments

Comments
 (0)