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

Commit 42bc8bc

Browse files
committed
v2 ensure that cls.MetaOapg will always exist, type check improvement (#84)
* Updates templates so MetaOapg will always be present * Samples regenerated * Fixes two tests * Adds type info to MetaOapg, fixes test * Adds types info to all classes * Uses cls.MetaOapg.types for type checking * Fixes 10 tests in TestAnyTypeSchema * Fixes 5 remaining tests * Removes _types * Samples regenerated * Fixes java test * Fixes test_pet
1 parent 206fdf1 commit 42bc8bc

File tree

380 files changed

+1577
-367
lines changed

Some content is hidden

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

380 files changed

+1577
-367
lines changed

modules/openapi-json-schema-generator/src/main/resources/python/model_templates/schema_composed_or_anytype.handlebars

+1-2
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ class {{#if this.classname}}{{classname}}{{else}}{{#if nameInSnakeCase}}{{name}}
3131
{{/if}}
3232
"""
3333
{{/if}}
34-
{{#or hasValidation composedSchemas getItems additionalProperties getRequiredVarsMap getHasDiscriminatorWithNonEmptyMapping vars getFormat isEnum}}
3534

3635

3736
class MetaOapg:
37+
{{> model_templates/types }}
3838
{{#if getFormat}}
3939
format = '{{getFormat}}'
4040
{{/if}}
@@ -61,7 +61,6 @@ class {{#if this.classname}}{{classname}}{{else}}{{#if nameInSnakeCase}}{{name}}
6161
{{#if composedSchemas}}
6262
{{> model_templates/composed_schemas }}
6363
{{/if}}
64-
{{/or}}
6564
{{#if isEnum}}
6665
{{> model_templates/enums }}
6766
{{/if}}

modules/openapi-json-schema-generator/src/main/resources/python/model_templates/schema_dict.handlebars

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class {{> model_templates/classname }}(
2626

2727

2828
class MetaOapg:
29+
types = {frozendict.frozendict}
2930
{{> model_templates/dict_partial }}
3031
{{> model_templates/validations }}
3132
{{/or}}

modules/openapi-json-schema-generator/src/main/resources/python/model_templates/schema_list.handlebars

+1-9
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,16 @@ class {{> model_templates/classname }}(
1414
{{/if}}
1515
"""
1616
{{/if}}
17-
{{#if isStub}}
18-
{{#if items}}
19-
20-
21-
class MetaOapg:
22-
{{> model_templates/list_partial }}
23-
{{/if}}
24-
{{else}}
2517
{{#or getItems hasValidation}}
2618

2719

2820
class MetaOapg:
21+
types = {tuple}
2922
{{#if hasValidation}}
3023
{{> model_templates/validations }}
3124
{{/if}}
3225
{{> model_templates/list_partial }}
3326
{{/or}}
34-
{{/if}}
3527

3628
{{> model_templates/new }}
3729

modules/openapi-json-schema-generator/src/main/resources/python/model_templates/schema_simple.handlebars

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class {{#if this.classname}}{{classname}}{{else}}{{#if nameInSnakeCase}}{{name}}
2222

2323

2424
class MetaOapg:
25+
{{> model_templates/types }}
2526
{{#if getFormat}}
2627
format = '{{getFormat}}'
2728
{{/if}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{{#if isAnyType}}
2+
types = None
3+
{{else}}
4+
types = {
5+
{{/if}}
6+
{{#if isNull}}
7+
schemas.NoneClass,
8+
{{/if}}
9+
{{#if isMap}}
10+
frozendict.frozendict,
11+
{{/if}}
12+
{{#if isArray}}
13+
tuple,
14+
{{/if}}
15+
{{#if isString }}
16+
{{#eq format "binary"}}
17+
FileIO,
18+
bytes,
19+
{{else}}
20+
str,
21+
{{/eq}}
22+
{{/if}}
23+
{{#or isInteger isNumber}}
24+
decimal.Decimal,
25+
{{/or}}
26+
{{#if isBoolean}}
27+
schemas.BoolClass,
28+
{{/if}}
29+
{{#unless isAnyType}}
30+
}
31+
{{/unless}}

0 commit comments

Comments
 (0)