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

128 files changed

Lines changed: 301 additions & 585 deletions

File tree

Some content is hidden

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

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")

0 commit comments

Comments
 (0)