Skip to content

Prefer property name instead of title for class name #300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions openapi_python_client/parser/properties/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def build_model_property(
name=name,
additional_properties=additional_properties,
)
schemas = attr.evolve(schemas, models={**schemas.models, prop.reference.class_name: prop})
schemas = attr.evolve(schemas, models={**schemas.models, prop.name: prop})
return prop, schemas


Expand Down Expand Up @@ -374,7 +374,7 @@ def build_enum_property(
values=values,
value_type=value_type,
)
schemas = attr.evolve(schemas, enums={**schemas.enums, prop.reference.class_name: prop})
schemas = attr.evolve(schemas, enums={**schemas.enums, prop.name: prop})
return prop, schemas


Expand Down
6 changes: 3 additions & 3 deletions tests/test_parser/test_properties/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def test_property_from_data_str_enum(self, mocker):
assert schemas != new_schemas, "Provided Schemas was mutated"
assert new_schemas.enums == {
"AnEnum": schemas.enums["AnEnum"],
"ParentAnEnum": prop,
"my_enum": prop,
}

def test_property_from_data_int_enum(self, mocker):
Expand Down Expand Up @@ -541,7 +541,7 @@ def test_property_from_data_int_enum(self, mocker):
assert schemas != new_schemas, "Provided Schemas was mutated"
assert new_schemas.enums == {
"AnEnum": schemas.enums["AnEnum"],
"ParentAnEnum": prop,
"my_enum": prop,
}

def test_property_from_data_ref_enum(self):
Expand Down Expand Up @@ -1083,7 +1083,7 @@ def test_build_model_property(additional_properties_schema, expected_additional_
assert new_schemas != schemas
assert new_schemas.models == {
"OtherModel": None,
"ParentMyModel": model,
"prop": model,
}
assert model == ModelProperty(
name="prop",
Expand Down