Skip to content

Commit

Permalink
Switches python-experimental in as the primary python client (#13501)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
spacether authored Sep 24, 2022
1 parent 9d62134 commit 7e73645
Show file tree
Hide file tree
Showing 3,628 changed files with 49,293 additions and 45,280 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 2 additions & 2 deletions CI/circle_parallel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ elif [ "$NODE_INDEX" = "4" ]; then

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

else
echo "Running node $NODE_INDEX to test 'samples.circleci.others' defined in pom.xml ..."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
generatorName: python
outputDir: samples/openapi3/client/extensions/x-auth-id-alias/python/
generatorName: python-prior
outputDir: samples/openapi3/client/extensions/x-auth-id-alias/python-prior/
inputSpec: modules/openapi-generator/src/test/resources/3_0/extensions/x-auth-id-alias.yaml
templateDir: modules/openapi-generator/src/main/resources/python
additionalProperties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# which makes it default to false
# that false setting is needed for composed schemas to work
# Composed schemas are schemas that contain the allOf/oneOf/anyOf keywords. v2 specs only support the allOf keyword.
generatorName: python
outputDir: samples/client/petstore/python
inputSpec: modules/openapi-generator/src/test/resources/2_0/python-client-experimental/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/python
generatorName: python-prior
outputDir: samples/client/petstore/python-prior
inputSpec: modules/openapi-generator/src/test/resources/2_0/python-prior/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/python-prior
additionalProperties:
packageName: petstore_api
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
generatorName: python
outputDir: samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent
inputSpec: modules/openapi-generator/src/test/resources/2_0/python-client-experimental/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/python
generatorName: python-prior
outputDir: samples/client/petstore/python-prior_disallowAdditionalPropertiesIfNotPresent
inputSpec: modules/openapi-generator/src/test/resources/2_0/python-prior/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/python-prior
additionalProperties:
disallowAdditionalPropertiesIfNotPresent: "true"
packageName: petstore_api
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
generatorName: python-experimental
outputDir: samples/openapi3/client/petstore/python-experimental
inputSpec: modules/openapi-generator/src/test/resources/3_0/python-experimental/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
templateDir: modules/openapi-generator/src/main/resources/python-experimental
generatorName: python-prior
outputDir: samples/openapi3/client/petstore/python-prior
inputSpec: modules/openapi-generator/src/test/resources/3_0/python-prior/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
templateDir: modules/openapi-generator/src/main/resources/python-prior
additionalProperties:
packageName: petstore_api
recursionLimit: "1234"
initRequiredVars: false
1 change: 0 additions & 1 deletion bin/configs/python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ templateDir: modules/openapi-generator/src/main/resources/python
additionalProperties:
packageName: petstore_api
recursionLimit: "1234"
initRequiredVars: false
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
generatorName: python-experimental
outputDir: samples/openapi3/client/3_0_3_unit_test/python-experimental
generatorName: python
outputDir: samples/openapi3/client/3_0_3_unit_test/python
inputSpec: modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml
templateDir: modules/openapi-generator/src/main/resources/python-experimental
templateDir: modules/openapi-generator/src/main/resources/python
additionalProperties:
packageName: unit_test_api
2 changes: 1 addition & 1 deletion docs/generators.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ The following generators are available:
* [php-dt (beta)](generators/php-dt.md)
* [powershell (beta)](generators/powershell.md)
* [python](generators/python.md)
* [python-experimental (experimental)](generators/python-experimental.md)
* [python-legacy](generators/python-legacy.md)
* [python-prior](generators/python-prior.md)
* [r](generators/r.md)
* [ruby](generators/ruby.md)
* [rust](generators/rust.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
---
title: Documentation for the python-experimental Generator
title: Documentation for the python-prior Generator
---

## METADATA

| Property | Value | Notes |
| -------- | ----- | ----- |
| generator name | python-experimental | pass this to the generate command after -g |
| generator stability | EXPERIMENTAL | |
| generator name | python-prior | pass this to the generate command after -g |
| generator stability | STABLE | |
| generator type | CLIENT | |
| generator language | Python | |
| generator language version | >=3.7 | |
| generator default templating engine | handlebars | |
| 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 | |
| generator language version | >=3.6 | |
| generator default templating engine | mustache | |
| helpTxt | Generates a Python client library. | |

## CONFIG OPTIONS
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.

| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|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|
|generateSourceCodeOnly|Specifies that only a library source code is to be generated.| |false|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|library|library template (sub-template) to use: urllib3| |urllib3|
|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|
|library|library template (sub-template) to use: asyncio, tornado, urllib3| |urllib3|
|packageName|python package name (convention: snake_case).| |openapi_client|
|packageUrl|python package URL.| |null|
|packageVersion|python package version.| |1.0.0|
|projectName|python project name in setup.py (e.g. petstore-api).| |null|
|pythonAttrNoneIfUnset|when accessing unset attribute, return `None` instead of raising `ApiAttributeError`| |false|
|recursionLimit|Set the recursion limit. If not set, use the system default value.| |null|
|useInlineModelResolver|use the inline model resolver, if true inline complex models will be extracted into components and $refs to them will be used| |false|
|useNose|use the nose test framework| |false|

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

| Type/Alias | Instantiated By |
| ---------- | --------------- |
|map|dict|


## LANGUAGE PRIMITIVES
Expand Down Expand Up @@ -72,37 +73,29 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>auth_settings</li>
<li>await</li>
<li>body_params</li>
<li>bool</li>
<li>break</li>
<li>class</li>
<li>continue</li>
<li>def</li>
<li>del</li>
<li>dict</li>
<li>elif</li>
<li>else</li>
<li>except</li>
<li>exec</li>
<li>false</li>
<li>file_type</li>
<li>finally</li>
<li>float</li>
<li>for</li>
<li>form_params</li>
<li>from</li>
<li>frozendict</li>
<li>global</li>
<li>header_params</li>
<li>if</li>
<li>import</li>
<li>in</li>
<li>int</li>
<li>is</li>
<li>lambda</li>
<li>list</li>
<li>local_var_files</li>
<li>none</li>
<li>none_type</li>
<li>nonlocal</li>
<li>not</li>
<li>or</li>
Expand All @@ -115,10 +108,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>resource_path</li>
<li>return</li>
<li>self</li>
<li>str</li>
<li>true</li>
<li>try</li>
<li>tuple</li>
<li>while</li>
<li>with</li>
<li>yield</li>
Expand Down Expand Up @@ -152,10 +143,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|DateTime|✓|OAS2,OAS3
|Password|✓|OAS2,OAS3
|File|✓|OAS2
|Uuid||
|Uuid||
|Array|✓|OAS2,OAS3
|Null||OAS3
|AnyType||OAS2,OAS3
|Null||OAS3
|AnyType||OAS2,OAS3
|Object|✓|OAS2,OAS3
|Maps|✓|ToolingExtension
|CollectionFormat|✓|OAS2
Expand Down Expand Up @@ -194,7 +185,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|XMLStructureDefinitions|✗|OAS2,OAS3
|MultiServer|✗|OAS3
|ParameterizedServer|✓|OAS3
|ParameterStyling||OAS3
|ParameterStyling||OAS3
|Callbacks|✗|OAS3
|LinkObjects|✗|OAS3

Expand All @@ -214,12 +205,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| ---- | --------- | ---------- |
|Simple|✓|OAS2,OAS3
|Composite|✓|OAS2,OAS3
|Polymorphism||OAS2,OAS3
|Union||OAS3
|allOf||OAS2,OAS3
|anyOf||OAS3
|oneOf||OAS3
|not||OAS3
|Polymorphism||OAS2,OAS3
|Union||OAS3
|allOf||OAS2,OAS3
|anyOf||OAS3
|oneOf||OAS3
|not||OAS3

### Security Feature
| Name | Supported | Defined By |
Expand All @@ -237,6 +228,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|JSON|✓|OAS2,OAS3
|XML||OAS2,OAS3
|XML||OAS2,OAS3
|PROTOBUF|✗|ToolingExtension
|Custom|✓|OAS2,OAS3
45 changes: 27 additions & 18 deletions docs/generators/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,24 @@ title: Documentation for the python Generator
| generator stability | STABLE | |
| generator type | CLIENT | |
| generator language | Python | |
| generator language version | >=3.6 | |
| generator default templating engine | mustache | |
| helpTxt | Generates a Python client library. | |
| generator language version | >=3.7 | |
| generator default templating engine | handlebars | |
| 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 | |

## CONFIG OPTIONS
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.

| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|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|
|generateSourceCodeOnly|Specifies that only a library source code is to be generated.| |false|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|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|
|library|library template (sub-template) to use: asyncio, tornado, urllib3| |urllib3|
|library|library template (sub-template) to use: urllib3| |urllib3|
|packageName|python package name (convention: snake_case).| |openapi_client|
|packageUrl|python package URL.| |null|
|packageVersion|python package version.| |1.0.0|
|projectName|python project name in setup.py (e.g. petstore-api).| |null|
|pythonAttrNoneIfUnset|when accessing unset attribute, return `None` instead of raising `ApiAttributeError`| |false|
|recursionLimit|Set the recursion limit. If not set, use the system default value.| |null|
|useInlineModelResolver|use the inline model resolver, if true inline complex models will be extracted into components and $refs to them will be used| |false|
|useNose|use the nose test framework| |false|

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

| Type/Alias | Instantiated By |
| ---------- | --------------- |
|map|dict|


## LANGUAGE PRIMITIVES
Expand Down Expand Up @@ -73,29 +72,37 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>auth_settings</li>
<li>await</li>
<li>body_params</li>
<li>bool</li>
<li>break</li>
<li>class</li>
<li>continue</li>
<li>def</li>
<li>del</li>
<li>dict</li>
<li>elif</li>
<li>else</li>
<li>except</li>
<li>exec</li>
<li>false</li>
<li>file_type</li>
<li>finally</li>
<li>float</li>
<li>for</li>
<li>form_params</li>
<li>from</li>
<li>frozendict</li>
<li>global</li>
<li>header_params</li>
<li>if</li>
<li>import</li>
<li>in</li>
<li>int</li>
<li>is</li>
<li>lambda</li>
<li>list</li>
<li>local_var_files</li>
<li>none</li>
<li>none_type</li>
<li>nonlocal</li>
<li>not</li>
<li>or</li>
Expand All @@ -108,8 +115,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>resource_path</li>
<li>return</li>
<li>self</li>
<li>str</li>
<li>true</li>
<li>try</li>
<li>tuple</li>
<li>while</li>
<li>with</li>
<li>yield</li>
Expand Down Expand Up @@ -143,10 +152,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|DateTime|✓|OAS2,OAS3
|Password|✓|OAS2,OAS3
|File|✓|OAS2
|Uuid||
|Uuid||
|Array|✓|OAS2,OAS3
|Null||OAS3
|AnyType||OAS2,OAS3
|Null||OAS3
|AnyType||OAS2,OAS3
|Object|✓|OAS2,OAS3
|Maps|✓|ToolingExtension
|CollectionFormat|✓|OAS2
Expand Down Expand Up @@ -185,7 +194,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|XMLStructureDefinitions|✗|OAS2,OAS3
|MultiServer|✗|OAS3
|ParameterizedServer|✓|OAS3
|ParameterStyling||OAS3
|ParameterStyling||OAS3
|Callbacks|✗|OAS3
|LinkObjects|✗|OAS3

Expand All @@ -205,12 +214,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| ---- | --------- | ---------- |
|Simple|✓|OAS2,OAS3
|Composite|✓|OAS2,OAS3
|Polymorphism||OAS2,OAS3
|Union||OAS3
|allOf||OAS2,OAS3
|anyOf||OAS3
|oneOf||OAS3
|not||OAS3
|Polymorphism||OAS2,OAS3
|Union||OAS3
|allOf||OAS2,OAS3
|anyOf||OAS3
|oneOf||OAS3
|not||OAS3

### Security Feature
| Name | Supported | Defined By |
Expand All @@ -228,6 +237,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|JSON|✓|OAS2,OAS3
|XML||OAS2,OAS3
|XML||OAS2,OAS3
|PROTOBUF|✗|ToolingExtension
|Custom|✓|OAS2,OAS3
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
import org.openapitools.codegen.api.TemplatingEngineAdapter;
import org.openapitools.codegen.api.TemplateFileType;
import org.openapitools.codegen.ignore.CodegenIgnoreProcessor;
import org.openapitools.codegen.languages.PythonPriorClientCodegen;
import org.openapitools.codegen.languages.PythonClientCodegen;
import org.openapitools.codegen.languages.PythonExperimentalClientCodegen;
import org.openapitools.codegen.meta.GeneratorMetadata;
import org.openapitools.codegen.meta.Stability;
import org.openapitools.codegen.model.ApiInfoMap;
Expand Down Expand Up @@ -541,7 +541,7 @@ void generateModels(List<File> files, List<ModelMap> allModels, List<String> unu
ModelMap modelTemplate = modelList.get(0);
if (modelTemplate != null && modelTemplate.getModel() != null) {
CodegenModel m = modelTemplate.getModel();
if (m.isAlias && !((config instanceof PythonClientCodegen) || (config instanceof PythonExperimentalClientCodegen))) {
if (m.isAlias && !((config instanceof PythonPriorClientCodegen) || (config instanceof PythonClientCodegen))) {
// alias to number, string, enum, etc, which should not be generated as model
// for PythonClientCodegen, all aliases are generated as models
continue; // Don't create user-defined classes for aliases
Expand Down
Loading

0 comments on commit 7e73645

Please sign in to comment.