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

Commit bb3a4ae

Browse files
committed
v2 module import cleanup (#111)
* Uses datetime import, adds types templates * Template and petstore update * petstore regenerated * Python tests fixed, samples regen * FIxes java test
1 parent 0aa6c5a commit bb3a4ae

File tree

1,520 files changed

+4113
-4082
lines changed

Some content is hidden

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

1,520 files changed

+4113
-4082
lines changed

modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonCodegen.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ public AbstractPythonCodegen() {
6161
"assert", "else", "if", "pass", "yield", "break", "except", "import",
6262
"print", "class", "exec", "in", "raise", "continue", "finally", "is",
6363
"return", "def", "for", "lambda", "try", "self", "nonlocal", "None", "True",
64-
"False", "async", "await"));
64+
"False", "async", "await",
65+
// imports, imports_schema_types.handlebars, include these to prevent name collision
66+
"datetime", "decimal", "functools", "io", "re",
67+
"typing", "typing_extensions", "uuid", "frozendict", "schemas"
68+
));
6569

6670
languageSpecificPrimitives.clear();
6771
languageSpecificPrimitives.add("int");

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

Lines changed: 82 additions & 95 deletions
Large diffs are not rendered by default.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from datetime import date, datetime # noqa: F401
1+
import datetime # noqa: F401
22
import decimal # noqa: F401
33
import functools # noqa: F401
44
import io # noqa: F401

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __new__(
4141
{{/if}}
4242
{{/if}}
4343
{{/each}}
44-
_configuration: typing.Optional[schemas.Configuration] = None,
44+
_configuration: typing.Optional[schemas.configuration_module.Configuration] = None,
4545
{{#with additionalProperties}}
4646
{{#unless getIsBooleanSchemaFalse}}
4747
{{#if refClass}}
@@ -52,7 +52,7 @@ def __new__(
5252
{{/unless}}
5353
{{else}}
5454
{{#or isMap isAnyType}}
55-
**kwargs: typing.Union[schemas.AnyTypeSchema, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes],
55+
**kwargs: typing.Union[{{> types_all_incl_schema_oneline }}],
5656
{{/or}}
5757
{{/with}}
5858
) -> '{{name.getCamelCaseName}}':
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{#if isAnyType}}dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, {{/if}}{{#if isArray}}list, tuple, {{/if}}{{#if isMap}}dict, frozendict.frozendict, {{/if}}{{#if isNull}}None, {{/if}}{{#if isString }}{{#neq format "binary"}}str, {{/neq}}{{#eq format "date"}}date, {{/eq}}{{#eq format "date-time"}}datetime, {{/eq}}{{#eq format "uuid"}}uuid.UUID, {{/eq}}{{#eq format "binary"}}bytes, io.FileIO, io.BufferedReader, {{/eq}}{{/if}}{{#if isInteger}}decimal.Decimal, int, {{/if}}{{#if isNumber}}decimal.Decimal, int, float, {{/if}}{{#if isBoolean}}bool, {{/if}}
1+
{{#if isAnyType}}dict, frozendict.frozendict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, {{/if}}{{#if isArray}}list, tuple, {{/if}}{{#if isMap}}dict, frozendict.frozendict, {{/if}}{{#if isNull}}None, {{/if}}{{#if isString }}{{#neq format "binary"}}str, {{/neq}}{{#eq format "date"}}datetime.date, {{/eq}}{{#eq format "date-time"}}datetime.datetime, {{/eq}}{{#eq format "uuid"}}uuid.UUID, {{/eq}}{{#eq format "binary"}}bytes, io.FileIO, io.BufferedReader, {{/eq}}{{/if}}{{#if isInteger}}decimal.Decimal, int, {{/if}}{{#if isNumber}}decimal.Decimal, int, float, {{/if}}{{#if isBoolean}}bool, {{/if}}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import dataclasses
2-
from datetime import date, datetime
2+
import datetime
33
import decimal
44
import io
55
import typing

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Key | Input Type | Accessed Type | Description | Notes
2727
{{/if}}
2828
{{/unless}}
2929
{{else}}
30-
**any_string_name** | dict, frozendict.frozendict, str, date, datetime, int, float, bool, decimal.Decimal, None, list, tuple, bytes, io.FileIO, io.BufferedReader | frozendict.frozendict, str, BoolClass, decimal.Decimal, NoneClass, tuple, bytes, FileIO | any string name can be used but the value must be the correct type | [optional]
30+
**any_string_name** | {{> types_all_incl_schema_oneline }} | {{> types_all_accessed_oneline }} | any string name can be used but the value must be the correct type | [optional]
3131
{{/with}}
3232
{{/or}}
3333
{{#each requiredProperties}}

0 commit comments

Comments
 (0)