Skip to content

Commit 5a34387

Browse files
committed
Полные ссылки на refы из других файлов и корректировка генерации моделей
1 parent a7195bb commit 5a34387

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

openapi_python_client/parser/properties/remote_model_property.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def self_import(self) -> str:
5656
return f".{self.module_path}.models.{self.class_info.module_name} import {self.class_info.name}"
5757

5858
def get_lazy_imports(self, *, prefix: str) -> set[str]:
59-
return {f"from {prefix}{self.self_import}"}
59+
return {f"from data_structures.{self.module_path}.models.{self.class_info.module_name} import {self.class_info.name}"}
6060

6161
def get_base_type_string(self, *, quoted: bool = False) -> str:
6262
return f'"{self.class_info.name}"' if quoted else self.class_info.name
@@ -70,6 +70,8 @@ def _get_module_path(path: str) -> str:
7070
creditRegistry.ds.json ->
7171
creditRegistry
7272
"""
73-
73+
# Специфика СПР
74+
# Удаляем расширение ds.json
7475
ref = urlparse(path)
75-
return ref.path.split("/")[-1].split(".")[0]
76+
path = f"{ref.path.replace('.ds.json','').replace('/', '.')}"
77+
return path.lstrip('.') if path.startswith('.') else path

openapi_python_client/parser/properties/union.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ def build(
5656

5757
for i, sub_prop_data in enumerate(chain(data.anyOf, data.oneOf, type_list_data)):
5858
sub_prop, schemas = property_from_data(
59-
name=f"{name}_type_{i}",
59+
# Убрал генерацию числового имени свойства
60+
# Приводило к багу в СПР, когда структура данных вся по себе имела свойство nullable
61+
# В названии получалось {Model}_type_0
62+
# name=f"{name}_type_{i}",
63+
name=name,
6064
required=True,
6165
data=sub_prop_data,
6266
schemas=schemas,

0 commit comments

Comments
 (0)