Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Commit 4554ac2

Browse files
committed
Writes properties with unmodifed names, only writes them if they are valid
1 parent cc81d59 commit 4554ac2

File tree

128 files changed

+301
-585
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+301
-585
lines changed

modules/openapi-json-schema-generator/src/main/resources/python/components/schemas/_helper_object_output_properties.hbs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{{#if requiredProperties}}
22
{{#each requiredProperties}}
3+
{{#if @key.isValid}}
34
{{#with this}}
45
{{#if refInfo.refClass}}
56

@@ -16,15 +17,17 @@
1617
{{! for when additionalProperties is unset, use OUTPUT_BASE_TYPES }}
1718

1819
@property
19-
def get_{{@key.snakeCase}}(self) -> schemas.OUTPUT_BASE_TYPES:
20+
def {{@key.original}}(self) -> schemas.OUTPUT_BASE_TYPES:
2021
{{> components/schemas/_helper_object_get_property required=true }}
2122
{{/if}}
2223
{{/if}}
2324
{{/with}}
25+
{{/if}}
2426
{{/each}}
2527
{{/if}}
2628
{{#if optionalProperties}}
2729
{{#each optionalProperties}}
30+
{{#if @key.isValid}}
2831
{{#with this}}
2932
{{#if refInfo.refClass}}
3033

@@ -38,6 +41,7 @@ def get_{{@key.snakeCase}}(self) -> schemas.OUTPUT_BASE_TYPES:
3841
{{> components/schemas/_helper_object_get_property required=false }}
3942
{{/if}}
4043
{{/with}}
44+
{{/if}}
4145
{{/each}}
4246
{{/if}}
4347
{{#eq additionalProperties null }}
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{#eq mode "get_additional_property_"}}def get_additional_property_(self, name: str) -> {{else}}{{#eq mode "get_property"}}def get_{{@key.snakeCase}}(self) -> {{else}}{{#eq mode "typehint"}}{{key}}: {{#eq key "schema"}}typing_extensions.TypeAlias = {{/eq}}{{/eq}}{{/eq}}{{/eq}}{{> components/schemas/_helper_schema_output_type_base }}
1+
{{#eq mode "get_additional_property_"}}def get_additional_property_(self, name: str) -> {{else}}{{#eq mode "get_property"}}def {{@key.original}}(self) -> {{else}}{{#eq mode "typehint"}}{{key}}: {{#eq key "schema"}}typing_extensions.TypeAlias = {{/eq}}{{/eq}}{{/eq}}{{/eq}}{{> components/schemas/_helper_schema_output_type_base }}

modules/openapi-json-schema-generator/src/main/resources/python/components/schemas/_helper_schema_output_ref_type.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
{{#eq types.size 1}}
2828
{{> components/schemas/_helper_schema_output_ref_single }}
2929
{{else}}
30-
{{#eq mode "get_additional_property_"}}def get_additional_property_(self, name: str) -> {{else}}{{#eq mode "get_property"}}def get_{{@key.snakeCase}}(self) -> {{else}}{{#eq mode "typehint"}}{{key}}: {{#eq key "schema"}}typing_extensions.TypeAlias = {{/eq}}{{/eq}}{{/eq}}{{/eq}}typing.Union[
30+
{{#eq mode "get_additional_property_"}}def get_additional_property_(self, name: str) -> {{else}}{{#eq mode "get_property"}}def {{@key.original}}(self) -> {{else}}{{#eq mode "typehint"}}{{key}}: {{#eq key "schema"}}typing_extensions.TypeAlias = {{/eq}}{{/eq}}{{/eq}}{{/eq}}typing.Union[
3131
{{> components/schemas/_helper_schema_output_type_base endChar="," }}
3232
]{{endChar}}
3333
{{/eq}}

modules/openapi-json-schema-generator/src/main/resources/python/components/schemas/_helper_schema_output_type.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{{#eq types.size 1}}
33
{{> components/schemas/_helper_schema_output_type_single }}
44
{{else}}
5-
{{#eq mode "get_additional_property_"}}def get_additional_property_(self, name: str) -> {{else}}{{#eq mode "get_property"}}def get_{{@key.snakeCase}}y(self) -> {{else}}{{#eq mode "typehint"}}{{key}}: {{#eq key "schema"}}typing_extensions.TypeAlias = {{/eq}}{{/eq}}{{/eq}}{{/eq}}typing.Union[
5+
{{#eq mode "get_additional_property_"}}def get_additional_property_(self, name: str) -> {{else}}{{#eq mode "get_property"}}def {{@key.original}}(self) -> {{else}}{{#eq mode "typehint"}}{{key}}: {{#eq key "schema"}}typing_extensions.TypeAlias = {{/eq}}{{/eq}}{{/eq}}{{/eq}}typing.Union[
66
{{> components/schemas/_helper_schema_output_type_base endChar="," }}
77
]{{endChar}}
88
{{/eq}}
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{#eq mode "get_additional_property_"}}def get_additional_property_(self, name: str) -> {{else}}{{#eq mode "get_property"}}def get_{{@key.snakeCase}}(self) -> {{else}}{{#eq mode "typehint"}}{{key}}: {{#eq key "schema"}}typing_extensions.TypeAlias = {{/eq}}{{/eq}}{{/eq}}{{/eq}}{{> components/schemas/_helper_schema_output_type_base }}
1+
{{#eq mode "get_additional_property_"}}def get_additional_property_(self, name: str) -> {{else}}{{#eq mode "get_property"}}def {{@key.original}}(self) -> {{else}}{{#eq mode "typehint"}}{{key}}: {{#eq key "schema"}}typing_extensions.TypeAlias = {{/eq}}{{/eq}}{{/eq}}{{/eq}}{{> components/schemas/_helper_schema_output_type_base }}

samples/openapi3/client/petstore/python/src/petstore_api/components/responses/response_success_inline_content_and_header/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class HeadersDict(schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]):
3333
})
3434

3535
@property
36-
def get_some_header(self) -> typing.Union[str, schemas.Unset]:
36+
def someHeader(self) -> typing.Union[str, schemas.Unset]:
3737
val = self.get("someHeader", schemas.unset)
3838
if val is schemas.unset:
3939
return val

samples/openapi3/client/petstore/python/src/petstore_api/components/responses/response_success_with_json_api_response/__init__.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,35 +70,21 @@ class HeadersDict(schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]):
7070
})
7171

7272
@property
73-
def get_int32(self) -> int:
73+
def int32(self) -> int:
7474
return typing.cast(
7575
int,
7676
self.__getitem__("int32")
7777
)
7878

7979
@property
80-
def get_ref_content_schema_header(self) -> str:
81-
return typing.cast(
82-
str,
83-
self.__getitem__("ref-content-schema-header")
84-
)
85-
86-
@property
87-
def get_ref_schema_header(self) -> str:
88-
return typing.cast(
89-
str,
90-
self.__getitem__("ref-schema-header")
91-
)
92-
93-
@property
94-
def get_string_header(self) -> str:
80+
def stringHeader(self) -> str:
9581
return typing.cast(
9682
str,
9783
self.__getitem__("stringHeader")
9884
)
9985

10086
@property
101-
def get_number_header(self) -> typing.Union[str, schemas.Unset]:
87+
def numberHeader(self) -> typing.Union[str, schemas.Unset]:
10288
val = self.get("numberHeader", schemas.unset)
10389
if val is schemas.unset:
10490
return val

samples/openapi3/client/petstore/python/src/petstore_api/components/schema/_200_response.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class _200ResponseDict(schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]):
3030
})
3131

3232
@property
33-
def get_name(self) -> typing.Union[int, schemas.Unset]:
33+
def name(self) -> typing.Union[int, schemas.Unset]:
3434
val = self.get("name", schemas.unset)
3535
if val is schemas.unset:
3636
return val
@@ -39,16 +39,6 @@ def get_name(self) -> typing.Union[int, schemas.Unset]:
3939
val
4040
)
4141

42-
@property
43-
def get__class(self) -> typing.Union[str, schemas.Unset]:
44-
val = self.get("class", schemas.unset)
45-
if val is schemas.unset:
46-
return val
47-
return typing.cast(
48-
str,
49-
val
50-
)
51-
5242
def get_additional_property_(self, name: str) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
5343
schemas.raise_if_key_known(name, self.__required_keys__, self.__optional_keys__)
5444
return self.get(name, schemas.unset)

samples/openapi3/client/petstore/python/src/petstore_api/components/schema/_return.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,6 @@ class ReturnDict(schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]):
2626
"return",
2727
})
2828

29-
@property
30-
def get__return(self) -> typing.Union[int, schemas.Unset]:
31-
val = self.get("return", schemas.unset)
32-
if val is schemas.unset:
33-
return val
34-
return typing.cast(
35-
int,
36-
val
37-
)
38-
3929
def get_additional_property_(self, name: str) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
4030
schemas.raise_if_key_known(name, self.__required_keys__, self.__optional_keys__)
4131
return self.get(name, schemas.unset)

samples/openapi3/client/petstore/python/src/petstore_api/components/schema/abstract_step_message.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@ class AbstractStepMessageDict(schemas.immutabledict[str, schemas.OUTPUT_BASE_TYP
2929
})
3030

3131
@property
32-
def get_description(self) -> schemas.OUTPUT_BASE_TYPES:
32+
def description(self) -> schemas.OUTPUT_BASE_TYPES:
3333
return typing.cast(
3434
schemas.OUTPUT_BASE_TYPES,
3535
self.__getitem__("description")
3636
)
3737

3838
@property
39-
def get_discriminator(self) -> str:
39+
def discriminator(self) -> str:
4040
return typing.cast(
4141
str,
4242
self.__getitem__("discriminator")
4343
)
4444

4545
@property
46-
def get_sequence_number(self) -> schemas.OUTPUT_BASE_TYPES:
46+
def sequenceNumber(self) -> schemas.OUTPUT_BASE_TYPES:
4747
return typing.cast(
4848
schemas.OUTPUT_BASE_TYPES,
4949
self.__getitem__("sequenceNumber")

samples/openapi3/client/petstore/python/src/petstore_api/components/schema/additional_properties_class.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ class AdditionalPropertiesClassDict(schemas.immutabledict[str, schemas.OUTPUT_BA
368368
})
369369

370370
@property
371-
def get_map_property(self) -> typing.Union[MapPropertyDict, schemas.Unset]:
371+
def map_property(self) -> typing.Union[MapPropertyDict, schemas.Unset]:
372372
val = self.get("map_property", schemas.unset)
373373
if val is schemas.unset:
374374
return val
@@ -378,7 +378,7 @@ def get_map_property(self) -> typing.Union[MapPropertyDict, schemas.Unset]:
378378
)
379379

380380
@property
381-
def get_map_of_map_property(self) -> typing.Union[MapOfMapPropertyDict, schemas.Unset]:
381+
def map_of_map_property(self) -> typing.Union[MapOfMapPropertyDict, schemas.Unset]:
382382
val = self.get("map_of_map_property", schemas.unset)
383383
if val is schemas.unset:
384384
return val
@@ -388,7 +388,7 @@ def get_map_of_map_property(self) -> typing.Union[MapOfMapPropertyDict, schemas.
388388
)
389389

390390
@property
391-
def get_anytype1(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
391+
def anytype_1(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
392392
val = self.get("anytype_1", schemas.unset)
393393
if val is schemas.unset:
394394
return val
@@ -398,7 +398,7 @@ def get_anytype1(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]
398398
)
399399

400400
@property
401-
def get_map_with_undeclared_properties_anytype1(self) -> typing.Union[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], schemas.Unset]:
401+
def map_with_undeclared_properties_anytype_1(self) -> typing.Union[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], schemas.Unset]:
402402
val = self.get("map_with_undeclared_properties_anytype_1", schemas.unset)
403403
if val is schemas.unset:
404404
return val
@@ -408,7 +408,7 @@ def get_map_with_undeclared_properties_anytype1(self) -> typing.Union[schemas.im
408408
)
409409

410410
@property
411-
def get_map_with_undeclared_properties_anytype2(self) -> typing.Union[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], schemas.Unset]:
411+
def map_with_undeclared_properties_anytype_2(self) -> typing.Union[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], schemas.Unset]:
412412
val = self.get("map_with_undeclared_properties_anytype_2", schemas.unset)
413413
if val is schemas.unset:
414414
return val
@@ -418,7 +418,7 @@ def get_map_with_undeclared_properties_anytype2(self) -> typing.Union[schemas.im
418418
)
419419

420420
@property
421-
def get_map_with_undeclared_properties_anytype3(self) -> typing.Union[MapWithUndeclaredPropertiesAnytype3Dict, schemas.Unset]:
421+
def map_with_undeclared_properties_anytype_3(self) -> typing.Union[MapWithUndeclaredPropertiesAnytype3Dict, schemas.Unset]:
422422
val = self.get("map_with_undeclared_properties_anytype_3", schemas.unset)
423423
if val is schemas.unset:
424424
return val
@@ -428,7 +428,7 @@ def get_map_with_undeclared_properties_anytype3(self) -> typing.Union[MapWithUnd
428428
)
429429

430430
@property
431-
def get_empty_map(self) -> typing.Union[EmptyMapDict, schemas.Unset]:
431+
def empty_map(self) -> typing.Union[EmptyMapDict, schemas.Unset]:
432432
val = self.get("empty_map", schemas.unset)
433433
if val is schemas.unset:
434434
return val
@@ -438,7 +438,7 @@ def get_empty_map(self) -> typing.Union[EmptyMapDict, schemas.Unset]:
438438
)
439439

440440
@property
441-
def get_map_with_undeclared_properties_string(self) -> typing.Union[MapWithUndeclaredPropertiesStringDict, schemas.Unset]:
441+
def map_with_undeclared_properties_string(self) -> typing.Union[MapWithUndeclaredPropertiesStringDict, schemas.Unset]:
442442
val = self.get("map_with_undeclared_properties_string", schemas.unset)
443443
if val is schemas.unset:
444444
return val

samples/openapi3/client/petstore/python/src/petstore_api/components/schema/animal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ class AnimalDict(schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]):
3939
})
4040

4141
@property
42-
def get_class_name(self) -> str:
42+
def className(self) -> str:
4343
return typing.cast(
4444
str,
4545
self.__getitem__("className")
4646
)
4747

4848
@property
49-
def get_color(self) -> typing.Union[str, schemas.Unset]:
49+
def color(self) -> typing.Union[str, schemas.Unset]:
5050
val = self.get("color", schemas.unset)
5151
if val is schemas.unset:
5252
return val

samples/openapi3/client/petstore/python/src/petstore_api/components/schema/any_type_and_format.py

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class AnyTypeAndFormatDict(schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]
123123
})
124124

125125
@property
126-
def get_uuid(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
126+
def uuid(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
127127
val = self.get("uuid", schemas.unset)
128128
if val is schemas.unset:
129129
return val
@@ -133,7 +133,7 @@ def get_uuid(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
133133
)
134134

135135
@property
136-
def get_date(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
136+
def date(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
137137
val = self.get("date", schemas.unset)
138138
if val is schemas.unset:
139139
return val
@@ -143,17 +143,7 @@ def get_date(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
143143
)
144144

145145
@property
146-
def get_date_time(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
147-
val = self.get("date-time", schemas.unset)
148-
if val is schemas.unset:
149-
return val
150-
return typing.cast(
151-
schemas.OUTPUT_BASE_TYPES,
152-
val
153-
)
154-
155-
@property
156-
def get_number(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
146+
def number(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
157147
val = self.get("number", schemas.unset)
158148
if val is schemas.unset:
159149
return val
@@ -163,7 +153,7 @@ def get_number(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
163153
)
164154

165155
@property
166-
def get_binary(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
156+
def binary(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
167157
val = self.get("binary", schemas.unset)
168158
if val is schemas.unset:
169159
return val
@@ -173,7 +163,7 @@ def get_binary(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
173163
)
174164

175165
@property
176-
def get_int32(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
166+
def int32(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
177167
val = self.get("int32", schemas.unset)
178168
if val is schemas.unset:
179169
return val
@@ -183,7 +173,7 @@ def get_int32(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
183173
)
184174

185175
@property
186-
def get_int64(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
176+
def int64(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
187177
val = self.get("int64", schemas.unset)
188178
if val is schemas.unset:
189179
return val
@@ -193,7 +183,7 @@ def get_int64(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
193183
)
194184

195185
@property
196-
def get_double(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
186+
def double(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
197187
val = self.get("double", schemas.unset)
198188
if val is schemas.unset:
199189
return val
@@ -202,16 +192,6 @@ def get_double(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
202192
val
203193
)
204194

205-
@property
206-
def get__float(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
207-
val = self.get("float", schemas.unset)
208-
if val is schemas.unset:
209-
return val
210-
return typing.cast(
211-
schemas.OUTPUT_BASE_TYPES,
212-
val
213-
)
214-
215195
def get_additional_property_(self, name: str) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
216196
schemas.raise_if_key_known(name, self.__required_keys__, self.__optional_keys__)
217197
return self.get(name, schemas.unset)

samples/openapi3/client/petstore/python/src/petstore_api/components/schema/api_response.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ApiResponseDict(schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]):
3333
})
3434

3535
@property
36-
def get_code(self) -> typing.Union[int, schemas.Unset]:
36+
def code(self) -> typing.Union[int, schemas.Unset]:
3737
val = self.get("code", schemas.unset)
3838
if val is schemas.unset:
3939
return val
@@ -43,7 +43,7 @@ def get_code(self) -> typing.Union[int, schemas.Unset]:
4343
)
4444

4545
@property
46-
def get_type(self) -> typing.Union[str, schemas.Unset]:
46+
def type(self) -> typing.Union[str, schemas.Unset]:
4747
val = self.get("type", schemas.unset)
4848
if val is schemas.unset:
4949
return val
@@ -53,7 +53,7 @@ def get_type(self) -> typing.Union[str, schemas.Unset]:
5353
)
5454

5555
@property
56-
def get_message(self) -> typing.Union[str, schemas.Unset]:
56+
def message(self) -> typing.Union[str, schemas.Unset]:
5757
val = self.get("message", schemas.unset)
5858
if val is schemas.unset:
5959
return val

0 commit comments

Comments
 (0)