Skip to content

Commit 7e73645

Browse files
authored
Switches python-experimental in as the primary python client (#13501)
* Changes python to python-prior * python -> python-prior, python-experimental->python * Renames sample spec directories * Samples regnerated * Regenerates docs * Fixes test * Samples regenerated * Updates renerators list * Fixes made to python paths in pom.xml * Fixes node4 sh file paths
1 parent 9d62134 commit 7e73645

File tree

3,628 files changed

+49293
-45280
lines changed

Some content is hidden

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

3,628 files changed

+49293
-45280
lines changed

CI/circle_parallel.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ elif [ "$NODE_INDEX" = "4" ]; then
7979

8080
#mvn --no-snapshot-updates --quiet verify -Psamples.circleci.node4 -Dorg.slf4j.simpleLogger.defaultLogLevel=error
8181
(cd samples/openapi3/client/petstore/python && make test)
82-
(cd samples/openapi3/client/petstore/python-experimental && make test)
83-
(cd samples/openapi3/client/3_0_3_unit_test/python-experimental && make test)
82+
(cd samples/openapi3/client/petstore/python-prior && make test)
83+
(cd samples/openapi3/client/3_0_3_unit_test/python && make test)
8484

8585
else
8686
echo "Running node $NODE_INDEX to test 'samples.circleci.others' defined in pom.xml ..."

bin/configs/python-extensions-x-auth-id-alias.yaml renamed to bin/configs/python-prior-extensions-x-auth-id-alias.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
generatorName: python
2-
outputDir: samples/openapi3/client/extensions/x-auth-id-alias/python/
1+
generatorName: python-prior
2+
outputDir: samples/openapi3/client/extensions/x-auth-id-alias/python-prior/
33
inputSpec: modules/openapi-generator/src/test/resources/3_0/extensions/x-auth-id-alias.yaml
44
templateDir: modules/openapi-generator/src/main/resources/python
55
additionalProperties:

bin/configs/python-oas2.yaml renamed to bin/configs/python-prior-oas2.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# which makes it default to false
33
# that false setting is needed for composed schemas to work
44
# Composed schemas are schemas that contain the allOf/oneOf/anyOf keywords. v2 specs only support the allOf keyword.
5-
generatorName: python
6-
outputDir: samples/client/petstore/python
7-
inputSpec: modules/openapi-generator/src/test/resources/2_0/python-client-experimental/petstore-with-fake-endpoints-models-for-testing.yaml
8-
templateDir: modules/openapi-generator/src/main/resources/python
5+
generatorName: python-prior
6+
outputDir: samples/client/petstore/python-prior
7+
inputSpec: modules/openapi-generator/src/test/resources/2_0/python-prior/petstore-with-fake-endpoints-models-for-testing.yaml
8+
templateDir: modules/openapi-generator/src/main/resources/python-prior
99
additionalProperties:
1010
packageName: petstore_api
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
generatorName: python
2-
outputDir: samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent
3-
inputSpec: modules/openapi-generator/src/test/resources/2_0/python-client-experimental/petstore-with-fake-endpoints-models-for-testing.yaml
4-
templateDir: modules/openapi-generator/src/main/resources/python
1+
generatorName: python-prior
2+
outputDir: samples/client/petstore/python-prior_disallowAdditionalPropertiesIfNotPresent
3+
inputSpec: modules/openapi-generator/src/test/resources/2_0/python-prior/petstore-with-fake-endpoints-models-for-testing.yaml
4+
templateDir: modules/openapi-generator/src/main/resources/python-prior
55
additionalProperties:
66
disallowAdditionalPropertiesIfNotPresent: "true"
77
packageName: petstore_api
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
generatorName: python-experimental
2-
outputDir: samples/openapi3/client/petstore/python-experimental
3-
inputSpec: modules/openapi-generator/src/test/resources/3_0/python-experimental/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
4-
templateDir: modules/openapi-generator/src/main/resources/python-experimental
1+
generatorName: python-prior
2+
outputDir: samples/openapi3/client/petstore/python-prior
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/python-prior/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
4+
templateDir: modules/openapi-generator/src/main/resources/python-prior
55
additionalProperties:
66
packageName: petstore_api
77
recursionLimit: "1234"
8+
initRequiredVars: false

bin/configs/python.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ templateDir: modules/openapi-generator/src/main/resources/python
55
additionalProperties:
66
packageName: petstore_api
77
recursionLimit: "1234"
8-
initRequiredVars: false
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
generatorName: python-experimental
2-
outputDir: samples/openapi3/client/3_0_3_unit_test/python-experimental
1+
generatorName: python
2+
outputDir: samples/openapi3/client/3_0_3_unit_test/python
33
inputSpec: modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml
4-
templateDir: modules/openapi-generator/src/main/resources/python-experimental
4+
templateDir: modules/openapi-generator/src/main/resources/python
55
additionalProperties:
66
packageName: unit_test_api

docs/generators.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ The following generators are available:
5050
* [php-dt (beta)](generators/php-dt.md)
5151
* [powershell (beta)](generators/powershell.md)
5252
* [python](generators/python.md)
53-
* [python-experimental (experimental)](generators/python-experimental.md)
5453
* [python-legacy](generators/python-legacy.md)
54+
* [python-prior](generators/python-prior.md)
5555
* [r](generators/r.md)
5656
* [ruby](generators/ruby.md)
5757
* [rust](generators/rust.md)

docs/generators/python-experimental.md renamed to docs/generators/python-prior.md

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,35 @@
11
---
2-
title: Documentation for the python-experimental Generator
2+
title: Documentation for the python-prior Generator
33
---
44

55
## METADATA
66

77
| Property | Value | Notes |
88
| -------- | ----- | ----- |
9-
| generator name | python-experimental | pass this to the generate command after -g |
10-
| generator stability | EXPERIMENTAL | |
9+
| generator name | python-prior | pass this to the generate command after -g |
10+
| generator stability | STABLE | |
1111
| generator type | CLIENT | |
1212
| generator language | Python | |
13-
| generator language version | >=3.7 | |
14-
| generator default templating engine | handlebars | |
15-
| helpTxt | Generates a Python client library<br /><br />Features in this generator:<br />- type hints on endpoints and model creation<br />- model parameter names use the spec defined keys and cases<br />- robust composition (oneOf/anyOf/allOf/not) where payload data is stored in one instance only<br />- endpoint parameter names use the spec defined keys and cases<br />- inline schemas are supported at any location including composition<br />- multiple content types supported in request body and response bodies<br />- run time type checking<br />- Sending/receiving decimals as strings supported with type:string format: number -> DecimalSchema<br />- Sending/receiving uuids as strings supported with type:string format: uuid -> UUIDSchema<br />- quicker load time for python modules (a single endpoint can be imported and used without loading others)<br />- all instances of schemas dynamically inherit from all matching schemas so one can use isinstance to check if validation passed<br />- composed schemas with type constraints supported (type:object + oneOf/anyOf/allOf)<br />- schemas are not coerced/cast. For example string + date are both stored as string, and there is a date accessor<br /> - Exceptions: int/float is stored as Decimal, When receiving data from headers it will start as str and may need to be cast for example to int | |
13+
| generator language version | >=3.6 | |
14+
| generator default templating engine | mustache | |
15+
| helpTxt | Generates a Python client library. | |
1616

1717
## CONFIG OPTIONS
1818
These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details.
1919

2020
| Option | Description | Values | Default |
2121
| ------ | ----------- | ------ | ------- |
22+
|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default. NOTE: this option breaks composition and will be removed in 6.0.0</dd></dl>|false|
2223
|generateSourceCodeOnly|Specifies that only a library source code is to be generated.| |false|
2324
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
24-
|library|library template (sub-template) to use: urllib3| |urllib3|
25+
|initRequiredVars|If set to true then the required variables are included as positional arguments in __init__ and _from_openapi_data methods. Note: this can break some composition use cases. To learn more read PR #8802.| |false|
26+
|library|library template (sub-template) to use: asyncio, tornado, urllib3| |urllib3|
2527
|packageName|python package name (convention: snake_case).| |openapi_client|
2628
|packageUrl|python package URL.| |null|
2729
|packageVersion|python package version.| |1.0.0|
2830
|projectName|python project name in setup.py (e.g. petstore-api).| |null|
31+
|pythonAttrNoneIfUnset|when accessing unset attribute, return `None` instead of raising `ApiAttributeError`| |false|
2932
|recursionLimit|Set the recursion limit. If not set, use the system default value.| |null|
30-
|useInlineModelResolver|use the inline model resolver, if true inline complex models will be extracted into components and $refs to them will be used| |false|
3133
|useNose|use the nose test framework| |false|
3234

3335
## IMPORT MAPPING
@@ -40,7 +42,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
4042

4143
| Type/Alias | Instantiated By |
4244
| ---------- | --------------- |
43-
|map|dict|
4445

4546

4647
## LANGUAGE PRIMITIVES
@@ -72,37 +73,29 @@ These options may be applied as additional-properties (cli) or configOptions (pl
7273
<li>auth_settings</li>
7374
<li>await</li>
7475
<li>body_params</li>
75-
<li>bool</li>
7676
<li>break</li>
7777
<li>class</li>
7878
<li>continue</li>
7979
<li>def</li>
8080
<li>del</li>
81-
<li>dict</li>
8281
<li>elif</li>
8382
<li>else</li>
8483
<li>except</li>
8584
<li>exec</li>
8685
<li>false</li>
87-
<li>file_type</li>
8886
<li>finally</li>
89-
<li>float</li>
9087
<li>for</li>
9188
<li>form_params</li>
9289
<li>from</li>
93-
<li>frozendict</li>
9490
<li>global</li>
9591
<li>header_params</li>
9692
<li>if</li>
9793
<li>import</li>
9894
<li>in</li>
99-
<li>int</li>
10095
<li>is</li>
10196
<li>lambda</li>
102-
<li>list</li>
10397
<li>local_var_files</li>
10498
<li>none</li>
105-
<li>none_type</li>
10699
<li>nonlocal</li>
107100
<li>not</li>
108101
<li>or</li>
@@ -115,10 +108,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
115108
<li>resource_path</li>
116109
<li>return</li>
117110
<li>self</li>
118-
<li>str</li>
119111
<li>true</li>
120112
<li>try</li>
121-
<li>tuple</li>
122113
<li>while</li>
123114
<li>with</li>
124115
<li>yield</li>
@@ -152,10 +143,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl
152143
|DateTime|✓|OAS2,OAS3
153144
|Password|✓|OAS2,OAS3
154145
|File|✓|OAS2
155-
|Uuid||
146+
|Uuid||
156147
|Array|✓|OAS2,OAS3
157-
|Null||OAS3
158-
|AnyType||OAS2,OAS3
148+
|Null||OAS3
149+
|AnyType||OAS2,OAS3
159150
|Object|✓|OAS2,OAS3
160151
|Maps|✓|ToolingExtension
161152
|CollectionFormat|✓|OAS2
@@ -194,7 +185,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
194185
|XMLStructureDefinitions|✗|OAS2,OAS3
195186
|MultiServer|✗|OAS3
196187
|ParameterizedServer|✓|OAS3
197-
|ParameterStyling||OAS3
188+
|ParameterStyling||OAS3
198189
|Callbacks|✗|OAS3
199190
|LinkObjects|✗|OAS3
200191

@@ -214,12 +205,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl
214205
| ---- | --------- | ---------- |
215206
|Simple|✓|OAS2,OAS3
216207
|Composite|✓|OAS2,OAS3
217-
|Polymorphism||OAS2,OAS3
218-
|Union||OAS3
219-
|allOf||OAS2,OAS3
220-
|anyOf||OAS3
221-
|oneOf||OAS3
222-
|not||OAS3
208+
|Polymorphism||OAS2,OAS3
209+
|Union||OAS3
210+
|allOf||OAS2,OAS3
211+
|anyOf||OAS3
212+
|oneOf||OAS3
213+
|not||OAS3
223214

224215
### Security Feature
225216
| Name | Supported | Defined By |
@@ -237,6 +228,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
237228
| Name | Supported | Defined By |
238229
| ---- | --------- | ---------- |
239230
|JSON|✓|OAS2,OAS3
240-
|XML||OAS2,OAS3
231+
|XML||OAS2,OAS3
241232
|PROTOBUF|✗|ToolingExtension
242233
|Custom|✓|OAS2,OAS3

docs/generators/python.md

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,24 @@ title: Documentation for the python Generator
1010
| generator stability | STABLE | |
1111
| generator type | CLIENT | |
1212
| generator language | Python | |
13-
| generator language version | >=3.6 | |
14-
| generator default templating engine | mustache | |
15-
| helpTxt | Generates a Python client library. | |
13+
| generator language version | >=3.7 | |
14+
| generator default templating engine | handlebars | |
15+
| helpTxt | Generates a Python client library<br /><br />Features in this generator:<br />- type hints on endpoints and model creation<br />- model parameter names use the spec defined keys and cases<br />- robust composition (oneOf/anyOf/allOf/not) where payload data is stored in one instance only<br />- endpoint parameter names use the spec defined keys and cases<br />- inline schemas are supported at any location including composition<br />- multiple content types supported in request body and response bodies<br />- run time type checking<br />- Sending/receiving decimals as strings supported with type:string format: number -> DecimalSchema<br />- Sending/receiving uuids as strings supported with type:string format: uuid -> UUIDSchema<br />- quicker load time for python modules (a single endpoint can be imported and used without loading others)<br />- all instances of schemas dynamically inherit from all matching schemas so one can use isinstance to check if validation passed<br />- composed schemas with type constraints supported (type:object + oneOf/anyOf/allOf)<br />- schemas are not coerced/cast. For example string + date are both stored as string, and there is a date accessor<br /> - Exceptions: int/float is stored as Decimal, When receiving data from headers it will start as str and may need to be cast for example to int | |
1616

1717
## CONFIG OPTIONS
1818
These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details.
1919

2020
| Option | Description | Values | Default |
2121
| ------ | ----------- | ------ | ------- |
22-
|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default. NOTE: this option breaks composition and will be removed in 6.0.0</dd></dl>|false|
2322
|generateSourceCodeOnly|Specifies that only a library source code is to be generated.| |false|
2423
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
25-
|initRequiredVars|If set to true then the required variables are included as positional arguments in __init__ and _from_openapi_data methods. Note: this can break some composition use cases. To learn more read PR #8802.| |false|
26-
|library|library template (sub-template) to use: asyncio, tornado, urllib3| |urllib3|
24+
|library|library template (sub-template) to use: urllib3| |urllib3|
2725
|packageName|python package name (convention: snake_case).| |openapi_client|
2826
|packageUrl|python package URL.| |null|
2927
|packageVersion|python package version.| |1.0.0|
3028
|projectName|python project name in setup.py (e.g. petstore-api).| |null|
31-
|pythonAttrNoneIfUnset|when accessing unset attribute, return `None` instead of raising `ApiAttributeError`| |false|
3229
|recursionLimit|Set the recursion limit. If not set, use the system default value.| |null|
30+
|useInlineModelResolver|use the inline model resolver, if true inline complex models will be extracted into components and $refs to them will be used| |false|
3331
|useNose|use the nose test framework| |false|
3432

3533
## IMPORT MAPPING
@@ -42,6 +40,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
4240

4341
| Type/Alias | Instantiated By |
4442
| ---------- | --------------- |
43+
|map|dict|
4544

4645

4746
## LANGUAGE PRIMITIVES
@@ -73,29 +72,37 @@ These options may be applied as additional-properties (cli) or configOptions (pl
7372
<li>auth_settings</li>
7473
<li>await</li>
7574
<li>body_params</li>
75+
<li>bool</li>
7676
<li>break</li>
7777
<li>class</li>
7878
<li>continue</li>
7979
<li>def</li>
8080
<li>del</li>
81+
<li>dict</li>
8182
<li>elif</li>
8283
<li>else</li>
8384
<li>except</li>
8485
<li>exec</li>
8586
<li>false</li>
87+
<li>file_type</li>
8688
<li>finally</li>
89+
<li>float</li>
8790
<li>for</li>
8891
<li>form_params</li>
8992
<li>from</li>
93+
<li>frozendict</li>
9094
<li>global</li>
9195
<li>header_params</li>
9296
<li>if</li>
9397
<li>import</li>
9498
<li>in</li>
99+
<li>int</li>
95100
<li>is</li>
96101
<li>lambda</li>
102+
<li>list</li>
97103
<li>local_var_files</li>
98104
<li>none</li>
105+
<li>none_type</li>
99106
<li>nonlocal</li>
100107
<li>not</li>
101108
<li>or</li>
@@ -108,8 +115,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl
108115
<li>resource_path</li>
109116
<li>return</li>
110117
<li>self</li>
118+
<li>str</li>
111119
<li>true</li>
112120
<li>try</li>
121+
<li>tuple</li>
113122
<li>while</li>
114123
<li>with</li>
115124
<li>yield</li>
@@ -143,10 +152,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl
143152
|DateTime|✓|OAS2,OAS3
144153
|Password|✓|OAS2,OAS3
145154
|File|✓|OAS2
146-
|Uuid||
155+
|Uuid||
147156
|Array|✓|OAS2,OAS3
148-
|Null||OAS3
149-
|AnyType||OAS2,OAS3
157+
|Null||OAS3
158+
|AnyType||OAS2,OAS3
150159
|Object|✓|OAS2,OAS3
151160
|Maps|✓|ToolingExtension
152161
|CollectionFormat|✓|OAS2
@@ -185,7 +194,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
185194
|XMLStructureDefinitions|✗|OAS2,OAS3
186195
|MultiServer|✗|OAS3
187196
|ParameterizedServer|✓|OAS3
188-
|ParameterStyling||OAS3
197+
|ParameterStyling||OAS3
189198
|Callbacks|✗|OAS3
190199
|LinkObjects|✗|OAS3
191200

@@ -205,12 +214,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl
205214
| ---- | --------- | ---------- |
206215
|Simple|✓|OAS2,OAS3
207216
|Composite|✓|OAS2,OAS3
208-
|Polymorphism||OAS2,OAS3
209-
|Union||OAS3
210-
|allOf||OAS2,OAS3
211-
|anyOf||OAS3
212-
|oneOf||OAS3
213-
|not||OAS3
217+
|Polymorphism||OAS2,OAS3
218+
|Union||OAS3
219+
|allOf||OAS2,OAS3
220+
|anyOf||OAS3
221+
|oneOf||OAS3
222+
|not||OAS3
214223

215224
### Security Feature
216225
| Name | Supported | Defined By |
@@ -228,6 +237,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
228237
| Name | Supported | Defined By |
229238
| ---- | --------- | ---------- |
230239
|JSON|✓|OAS2,OAS3
231-
|XML||OAS2,OAS3
240+
|XML||OAS2,OAS3
232241
|PROTOBUF|✗|ToolingExtension
233242
|Custom|✓|OAS2,OAS3

modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
import org.openapitools.codegen.api.TemplatingEngineAdapter;
4141
import org.openapitools.codegen.api.TemplateFileType;
4242
import org.openapitools.codegen.ignore.CodegenIgnoreProcessor;
43+
import org.openapitools.codegen.languages.PythonPriorClientCodegen;
4344
import org.openapitools.codegen.languages.PythonClientCodegen;
44-
import org.openapitools.codegen.languages.PythonExperimentalClientCodegen;
4545
import org.openapitools.codegen.meta.GeneratorMetadata;
4646
import org.openapitools.codegen.meta.Stability;
4747
import org.openapitools.codegen.model.ApiInfoMap;
@@ -541,7 +541,7 @@ void generateModels(List<File> files, List<ModelMap> allModels, List<String> unu
541541
ModelMap modelTemplate = modelList.get(0);
542542
if (modelTemplate != null && modelTemplate.getModel() != null) {
543543
CodegenModel m = modelTemplate.getModel();
544-
if (m.isAlias && !((config instanceof PythonClientCodegen) || (config instanceof PythonExperimentalClientCodegen))) {
544+
if (m.isAlias && !((config instanceof PythonPriorClientCodegen) || (config instanceof PythonClientCodegen))) {
545545
// alias to number, string, enum, etc, which should not be generated as model
546546
// for PythonClientCodegen, all aliases are generated as models
547547
continue; // Don't create user-defined classes for aliases

0 commit comments

Comments
 (0)