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

Commit a4aaf4b

Browse files
committed
Removes oneOf/anyOf/allOf nesting
1 parent e2da9aa commit a4aaf4b

40 files changed

Lines changed: 43 additions & 1672 deletions

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

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
{{#if allOf}}
22

33
class AllOf:
4-
{{#each allOf}}
5-
{{#if refInfo.refClass}}
6-
7-
{{> components/schemas/_helper_refclass_staticmethod }}
8-
{{else}}
9-
{{> components/schemas/_helper_schema_switch_case identifierPieces=(append identifierPieces "AllOf" jsonPathPiece) }}
10-
{{/if}}
11-
{{/each}}
124
classes = [
135
{{#each allOf}}
146
{{#if refInfo.refClass}}
15-
{{jsonPathPiece.snakeCase}},
7+
{{#if refInfo.refModule}}{{refInfo.refModule}}.{{/if}}{{refInfo.refClass}},
168
{{else}}
179
{{jsonPathPiece.camelCase}},
1810
{{/if}}
@@ -22,18 +14,10 @@ class AllOf:
2214
{{#if oneOf}}
2315

2416
class OneOf:
25-
{{#each oneOf}}
26-
{{#if refInfo.refClass}}
27-
28-
{{> components/schemas/_helper_refclass_staticmethod }}
29-
{{else}}
30-
{{> components/schemas/_helper_schema_switch_case identifierPieces=(append identifierPieces "OneOf" jsonPathPiece) }}
31-
{{/if}}
32-
{{/each}}
3317
classes = [
3418
{{#each oneOf}}
3519
{{#if refInfo.refClass}}
36-
{{jsonPathPiece.snakeCase}},
20+
{{#if refInfo.refModule}}{{refInfo.refModule}}.{{/if}}{{refInfo.refClass}},
3721
{{else}}
3822
{{jsonPathPiece.camelCase}},
3923
{{/if}}
@@ -43,18 +27,10 @@ class OneOf:
4327
{{#if anyOf}}
4428

4529
class AnyOf:
46-
{{#each anyOf}}
47-
{{#if refInfo.refClass}}
48-
49-
{{> components/schemas/_helper_refclass_staticmethod }}
50-
{{else}}
51-
{{> components/schemas/_helper_schema_switch_case identifierPieces=(append identifierPieces "AnyOf" jsonPathPiece) }}
52-
{{/if}}
53-
{{/each}}
5430
classes = [
5531
{{#each anyOf}}
5632
{{#if refInfo.refClass}}
57-
{{jsonPathPiece.snakeCase}},
33+
{{#if refInfo.refModule}}{{refInfo.refModule}}.{{/if}}{{refInfo.refClass}},
5834
{{else}}
5935
{{jsonPathPiece.camelCase}},
6036
{{/if}}

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,8 @@ class Properties:
5151
}
5252

5353
class AnyOf:
54-
55-
@staticmethod
56-
def _0() -> typing.Type[AbstractStepMessage]:
57-
return AbstractStepMessage
5854
classes = [
59-
_0,
55+
AbstractStepMessage,
6056
]
6157

6258

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

Lines changed: 0 additions & 207 deletions
Original file line numberDiff line numberDiff line change
@@ -410,213 +410,6 @@ class Schema_:
410410
}
411411

412412
class AllOf:
413-
414-
415-
class _0(
416-
schemas.DictSchema[schemas.T]
417-
):
418-
419-
420-
class Schema_:
421-
types = {frozendict.frozendict}
422-
AdditionalProperties: typing_extensions.TypeAlias = AdditionalProperties[U]
423-
424-
def __getitem__(self, name: str) -> Schema_.AdditionalProperties[typing.Union[
425-
frozendict.frozendict,
426-
str,
427-
decimal.Decimal,
428-
schemas.BoolClass,
429-
schemas.NoneClass,
430-
tuple,
431-
bytes,
432-
schemas.FileIO
433-
]]:
434-
# dict_instance[name] accessor
435-
return super().__getitem__(name)
436-
437-
def __new__(
438-
cls,
439-
*args_: typing.Union[dict, frozendict.frozendict],
440-
configuration_: typing.Optional[schemas.schema_configuration.SchemaConfiguration] = None,
441-
**kwargs: typing.Union[
442-
Schema_.AdditionalProperties[typing.Union[
443-
frozendict.frozendict,
444-
str,
445-
decimal.Decimal,
446-
schemas.BoolClass,
447-
schemas.NoneClass,
448-
tuple,
449-
bytes,
450-
schemas.FileIO
451-
]],
452-
dict,
453-
frozendict.frozendict,
454-
str,
455-
datetime.date,
456-
datetime.datetime,
457-
uuid.UUID,
458-
int,
459-
float,
460-
decimal.Decimal,
461-
bool,
462-
None,
463-
list,
464-
tuple,
465-
bytes,
466-
io.FileIO,
467-
io.BufferedReader
468-
],
469-
) -> AdditionalPropertiesValidator.Schema_.AllOf._0[frozendict.frozendict]:
470-
inst = super().__new__(
471-
cls,
472-
*args_,
473-
configuration_=configuration_,
474-
**kwargs,
475-
)
476-
inst = typing.cast(
477-
AdditionalPropertiesValidator.Schema_.AllOf._0[frozendict.frozendict],
478-
inst
479-
)
480-
return inst
481-
482-
483-
484-
class _1(
485-
schemas.DictSchema[schemas.T]
486-
):
487-
488-
489-
class Schema_:
490-
types = {frozendict.frozendict}
491-
AdditionalProperties: typing_extensions.TypeAlias = AdditionalProperties[U]
492-
493-
def __getitem__(self, name: str) -> Schema_.AdditionalProperties[typing.Union[
494-
frozendict.frozendict,
495-
str,
496-
decimal.Decimal,
497-
schemas.BoolClass,
498-
schemas.NoneClass,
499-
tuple,
500-
bytes,
501-
schemas.FileIO
502-
]]:
503-
# dict_instance[name] accessor
504-
return super().__getitem__(name)
505-
506-
def __new__(
507-
cls,
508-
*args_: typing.Union[dict, frozendict.frozendict],
509-
configuration_: typing.Optional[schemas.schema_configuration.SchemaConfiguration] = None,
510-
**kwargs: typing.Union[
511-
Schema_.AdditionalProperties[typing.Union[
512-
frozendict.frozendict,
513-
str,
514-
decimal.Decimal,
515-
schemas.BoolClass,
516-
schemas.NoneClass,
517-
tuple,
518-
bytes,
519-
schemas.FileIO
520-
]],
521-
dict,
522-
frozendict.frozendict,
523-
str,
524-
datetime.date,
525-
datetime.datetime,
526-
uuid.UUID,
527-
int,
528-
float,
529-
decimal.Decimal,
530-
bool,
531-
None,
532-
list,
533-
tuple,
534-
bytes,
535-
io.FileIO,
536-
io.BufferedReader
537-
],
538-
) -> AdditionalPropertiesValidator.Schema_.AllOf._1[frozendict.frozendict]:
539-
inst = super().__new__(
540-
cls,
541-
*args_,
542-
configuration_=configuration_,
543-
**kwargs,
544-
)
545-
inst = typing.cast(
546-
AdditionalPropertiesValidator.Schema_.AllOf._1[frozendict.frozendict],
547-
inst
548-
)
549-
return inst
550-
551-
552-
553-
class _2(
554-
schemas.DictSchema[schemas.T]
555-
):
556-
557-
558-
class Schema_:
559-
types = {frozendict.frozendict}
560-
AdditionalProperties: typing_extensions.TypeAlias = AdditionalProperties[U]
561-
562-
def __getitem__(self, name: str) -> Schema_.AdditionalProperties[typing.Union[
563-
frozendict.frozendict,
564-
str,
565-
decimal.Decimal,
566-
schemas.BoolClass,
567-
schemas.NoneClass,
568-
tuple,
569-
bytes,
570-
schemas.FileIO
571-
]]:
572-
# dict_instance[name] accessor
573-
return super().__getitem__(name)
574-
575-
def __new__(
576-
cls,
577-
*args_: typing.Union[dict, frozendict.frozendict],
578-
configuration_: typing.Optional[schemas.schema_configuration.SchemaConfiguration] = None,
579-
**kwargs: typing.Union[
580-
Schema_.AdditionalProperties[typing.Union[
581-
frozendict.frozendict,
582-
str,
583-
decimal.Decimal,
584-
schemas.BoolClass,
585-
schemas.NoneClass,
586-
tuple,
587-
bytes,
588-
schemas.FileIO
589-
]],
590-
dict,
591-
frozendict.frozendict,
592-
str,
593-
datetime.date,
594-
datetime.datetime,
595-
uuid.UUID,
596-
int,
597-
float,
598-
decimal.Decimal,
599-
bool,
600-
None,
601-
list,
602-
tuple,
603-
bytes,
604-
io.FileIO,
605-
io.BufferedReader
606-
],
607-
) -> AdditionalPropertiesValidator.Schema_.AllOf._2[frozendict.frozendict]:
608-
inst = super().__new__(
609-
cls,
610-
*args_,
611-
configuration_=configuration_,
612-
**kwargs,
613-
)
614-
inst = typing.cast(
615-
AdditionalPropertiesValidator.Schema_.AllOf._2[frozendict.frozendict],
616-
inst
617-
)
618-
return inst
619-
620413
classes = [
621414
_0,
622415
_1,

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

Lines changed: 1 addition & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -111,95 +111,8 @@ class Schema_:
111111
# any type
112112

113113
class AllOf:
114-
115-
@staticmethod
116-
def _0() -> typing.Type[animal.Animal]:
117-
return animal.Animal
118-
119-
120-
class _1(
121-
schemas.DictSchema[schemas.T]
122-
):
123-
124-
125-
class Schema_:
126-
types = {frozendict.frozendict}
127-
128-
class Properties:
129-
Declawed: typing_extensions.TypeAlias = schemas.BoolSchema[U]
130-
__annotations__ = {
131-
"declawed": Declawed,
132-
}
133-
134-
@typing.overload
135-
def __getitem__(self, name: typing_extensions.Literal["declawed"]) -> Schema_.Properties.Declawed[schemas.BoolClass]: ...
136-
137-
@typing.overload
138-
def __getitem__(self, name: str) -> schemas.AnyTypeSchema[typing.Union[
139-
frozendict.frozendict,
140-
str,
141-
decimal.Decimal,
142-
schemas.BoolClass,
143-
schemas.NoneClass,
144-
tuple,
145-
bytes,
146-
schemas.FileIO
147-
]]: ...
148-
149-
def __getitem__(
150-
self,
151-
name: typing.Union[
152-
typing_extensions.Literal["declawed"],
153-
str
154-
]
155-
):
156-
# dict_instance[name] accessor
157-
return super().__getitem__(name)
158-
159-
def __new__(
160-
cls,
161-
*args_: typing.Union[dict, frozendict.frozendict],
162-
declawed: typing.Union[
163-
Schema_.Properties.Declawed[schemas.BoolClass],
164-
schemas.Unset,
165-
bool
166-
] = schemas.unset,
167-
configuration_: typing.Optional[schemas.schema_configuration.SchemaConfiguration] = None,
168-
**kwargs: typing.Union[
169-
dict,
170-
frozendict.frozendict,
171-
list,
172-
tuple,
173-
decimal.Decimal,
174-
float,
175-
int,
176-
str,
177-
datetime.date,
178-
datetime.datetime,
179-
uuid.UUID,
180-
bool,
181-
None,
182-
bytes,
183-
io.FileIO,
184-
io.BufferedReader,
185-
schemas.Schema
186-
],
187-
) -> Cat.Schema_.AllOf._1[frozendict.frozendict]:
188-
inst = super().__new__(
189-
cls,
190-
*args_,
191-
declawed=declawed,
192-
configuration_=configuration_,
193-
**kwargs,
194-
)
195-
inst = typing.cast(
196-
Cat.Schema_.AllOf._1[frozendict.frozendict],
197-
inst
198-
)
199-
return inst
200-
201114
classes = [
202-
_0,
115+
animal.Animal,
203116
_1,
204117
]
205118

0 commit comments

Comments
 (0)