Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new Python client generator - python-nextgen #14157

Merged
merged 100 commits into from
Dec 17, 2022
Merged
Show file tree
Hide file tree
Changes from 98 commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
c28f22e
add python-nextgen generator
wing328 Oct 3, 2022
798d8d0
remove client_side_validation from model
wing328 Oct 4, 2022
fffde02
remove configuraiton import from models
wing328 Oct 4, 2022
a880fe7
add inheritance support
wing328 Oct 5, 2022
ea77c84
update test requirements, tox
wing328 Oct 5, 2022
c0af85f
add typings, pydanic to models
wing328 Oct 8, 2022
26b1065
add test model
wing328 Oct 8, 2022
96cdee0
minor improvements
wing328 Oct 8, 2022
04a20a9
add enum support
wing328 Oct 10, 2022
9a16295
add typing for parameters, remove validations
wing328 Oct 10, 2022
9eb82ef
add oneof, anyof support
wing328 Oct 24, 2022
80c3910
fix default value
wing328 Oct 25, 2022
1e708e0
fix deserialization, api tests passed
wing328 Oct 25, 2022
74cf063
private variable naming, update tests, all tests passed
wing328 Oct 25, 2022
42664e9
remove six
wing328 Oct 25, 2022
401c3e8
remove nose
wing328 Oct 25, 2022
b3eb052
update doc
wing328 Oct 25, 2022
59f490d
remove sortParamsByRequiredFlag option
wing328 Oct 25, 2022
decf09c
add parameter validation
wing328 Oct 25, 2022
f6ae1e8
add validation tests
wing328 Oct 25, 2022
f7a1b5a
simplify Field()
wing328 Oct 26, 2022
056f837
remove previous required parameter validation
wing328 Oct 26, 2022
37e6d50
improve parameter handling
wing328 Oct 26, 2022
fe402ba
support discriminator mapping
wing328 Oct 26, 2022
bef92fe
better typing discriminator mapping
wing328 Oct 26, 2022
8634b8e
format test code
wing328 Oct 26, 2022
80c3029
fix tests
wing328 Oct 26, 2022
b954552
fix oneOf from_dict, add test
wing328 Oct 26, 2022
226b195
add set validation test
wing328 Oct 27, 2022
d428523
fix nested oneof serialization, add tests
wing328 Oct 27, 2022
04b253e
add model import
wing328 Oct 27, 2022
27ed235
remove models. prefix
wing328 Oct 27, 2022
1c61628
remove import models
wing328 Oct 27, 2022
e57bab5
remove model import from api
wing328 Oct 27, 2022
b6b743d
simplify from_dict
wing328 Oct 27, 2022
8513bc5
add typing for return
wing328 Oct 29, 2022
39b9a2b
skip pydantic import in return type
wing328 Oct 29, 2022
2468575
fix tests, fix enum
wing328 Oct 29, 2022
44c0207
restore more enum schema tests
wing328 Oct 29, 2022
90259a3
uncomment enum integer test
wing328 Oct 29, 2022
a32f957
clean up getfullargspec import in model
wing328 Oct 29, 2022
e9f4881
clean up getfullargspec import
wing328 Oct 29, 2022
9d9ecda
fix deserilizatoin for nested oneof
wing328 Oct 29, 2022
c21a210
minor fixes, add tests
wing328 Oct 29, 2022
3e0eb25
fix regular expression
wing328 Oct 29, 2022
ee69292
add aiohttp samples, add tests
wing328 Oct 30, 2022
d38d7b6
remove default content type to json
wing328 Oct 30, 2022
0251a88
update template
wing328 Oct 30, 2022
d5851a8
fix select accept, content-type
wing328 Oct 30, 2022
4126791
move tests
wing328 Oct 30, 2022
a2e0378
move tests
wing328 Oct 30, 2022
cc395f9
fix url query parameters
wing328 Oct 30, 2022
ec95f13
fix list
wing328 Nov 5, 2022
57e4971
fix samples
wing328 Nov 5, 2022
93b53da
fix param pydantic, add list as reserved word
wing328 Nov 5, 2022
fa144ca
fix auto-generated doc
wing328 Nov 5, 2022
4c71d9e
fix readme
wing328 Nov 5, 2022
f67b4e3
fix list, fix special variable name with var_
wing328 Nov 5, 2022
4d61687
fix Literal in python 3.7
wing328 Nov 6, 2022
aa3b27c
fix default configuration
wing328 Nov 9, 2022
40e63a3
fix aiohttp tests
wing328 Nov 9, 2022
a3e00b6
set default api client instance
wing328 Nov 9, 2022
36d5aaa
deprecate get_default_copy method
wing328 Nov 9, 2022
f2c0416
Merge remote-tracking branch 'origin/master' into python-nextgen
wing328 Nov 9, 2022
9b571f5
fix enum model
wing328 Nov 9, 2022
28b3076
fix enum serializatio/deserialization
wing328 Nov 9, 2022
3bfba2b
add github workflow support
wing328 Nov 9, 2022
745f189
add regular expression validator
wing328 Nov 9, 2022
e84a18b
add enum validator
wing328 Nov 9, 2022
1f794dd
better model import
wing328 Nov 11, 2022
cbd7f35
fix file, remove x-py-import-models
wing328 Nov 11, 2022
0fbe4d8
rename local var
wing328 Nov 12, 2022
627b837
better model example
wing328 Nov 12, 2022
860b52d
fix regular expression warning, add special_name test, whitelist schema
wing328 Nov 12, 2022
e4aac8e
skip self import
wing328 Nov 12, 2022
0668001
update samples
wing328 Nov 12, 2022
a1e66e5
various fixes
wing328 Nov 13, 2022
32f82bc
add base64, json as reserved word
wing328 Nov 13, 2022
b137c21
add http signature support
wing328 Nov 14, 2022
ebe6e14
add http signature test
wing328 Nov 14, 2022
65f3b07
add additioanl properties support in python client
wing328 Nov 16, 2022
02a2f62
add decimal support
wing328 Nov 16, 2022
aa3bd77
use strictstr instead of constr
wing328 Nov 16, 2022
4b3d796
fix test with virtualenv
wing328 Nov 16, 2022
f34eaf9
add nullable support
wing328 Nov 17, 2022
5c586a9
add readonly support
wing328 Nov 17, 2022
5dfc2d1
add model name caching
wing328 Nov 18, 2022
2389d18
fix circular reference import
wing328 Nov 21, 2022
23de505
add onelook discriminator lookup
wing328 Nov 21, 2022
1a9057f
add tests
wing328 Nov 22, 2022
b79bf08
Merge remote-tracking branch 'origin/master' into python-nextgen
wing328 Dec 1, 2022
60bb863
update samples
wing328 Dec 1, 2022
aff491f
fix locale
wing328 Dec 1, 2022
f6aceeb
Fix client legacy generator asyncio README code example
wing328 Dec 1, 2022
f543fae
test python-nextgen in circleci
wing328 Dec 1, 2022
d5dbee9
fix pom.xml
wing328 Dec 3, 2022
161d6b3
update python to 3.7.15
wing328 Dec 3, 2022
d91ff55
test with python 3.7.12
wing328 Dec 3, 2022
2f64f1d
various updates
wing328 Dec 16, 2022
f4aab76
fix python legacy
wing328 Dec 16, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions CI/circle_parallel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ elif [ "$NODE_INDEX" = "3" ]; then
#./configure --enable-optimizations
#sudo make altinstall
pyenv install --list
pyenv install 3.6.3
pyenv install 3.7.12
pyenv install 2.7.14
pyenv global 3.6.3
pyenv global 3.7.12

# Install node@stable (for angular 6)
set +e
Expand Down
7 changes: 7 additions & 0 deletions bin/configs/python-nextgen-aiohttp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
generatorName: python-nextgen
outputDir: samples/openapi3/client/petstore/python-nextgen-aiohttp
inputSpec: modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/python-nextgen
library: asyncio
additionalProperties:
packageName: petstore_api
8 changes: 8 additions & 0 deletions bin/configs/python-nextgen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
generatorName: python-nextgen
outputDir: samples/openapi3/client/petstore/python-nextgen
inputSpec: modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/python-nextgen
additionalProperties:
packageName: petstore_api
useOneOfDiscriminatorLookup: "true"
disallowAdditionalPropertiesIfNotPresent: false
1 change: 1 addition & 0 deletions docs/generators.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ The following generators are available:
* [powershell (beta)](generators/powershell.md)
* [python](generators/python.md)
* [python-legacy](generators/python-legacy.md)
* [python-nextgen (beta)](generators/python-nextgen.md)
* [python-prior](generators/python-prior.md)
* [r](generators/r.md)
* [ruby](generators/ruby.md)
Expand Down
2 changes: 2 additions & 0 deletions docs/generators/python-legacy.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## LANGUAGE PRIMITIVES

<ul class="column-ul">
<li>Dict</li>
<li>List</li>
<li>bool</li>
<li>bytes</li>
<li>date</li>
Expand Down
225 changes: 225 additions & 0 deletions docs/generators/python-nextgen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
---
title: Documentation for the python-nextgen Generator
---

## METADATA

| Property | Value | Notes |
| -------- | ----- | ----- |
| generator name | python-nextgen | pass this to the generate command after -g |
| generator stability | BETA | |
| generator type | CLIENT | |
| generator language | Python | |
| generator language version | 3.7+ | |
| 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.</dd></dl>|true|
|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: asyncio, tornado (deprecated), 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|
|recursionLimit|Set the recursion limit. If not set, use the system default value.| |null|

## IMPORT MAPPING

| Type/Alias | Imports |
| ---------- | ------- |


## INSTANTIATION TYPES

| Type/Alias | Instantiated By |
| ---------- | --------------- |


## LANGUAGE PRIMITIVES

<ul class="column-ul">
<li>Dict</li>
<li>List</li>
<li>bool</li>
<li>bytes</li>
<li>date</li>
<li>datetime</li>
<li>decimal.Decimal</li>
<li>dict</li>
<li>float</li>
<li>int</li>
<li>list</li>
<li>object</li>
<li>str</li>
</ul>

## RESERVED WORDS

<ul class="column-ul">
<li>and</li>
<li>as</li>
<li>assert</li>
<li>async</li>
<li>await</li>
<li>base64</li>
<li>break</li>
<li>class</li>
<li>continue</li>
<li>date</li>
<li>def</li>
<li>del</li>
<li>elif</li>
<li>else</li>
<li>except</li>
<li>exec</li>
<li>false</li>
<li>finally</li>
<li>for</li>
<li>from</li>
<li>global</li>
<li>if</li>
<li>import</li>
<li>in</li>
<li>is</li>
<li>json</li>
<li>lambda</li>
<li>none</li>
<li>nonlocal</li>
<li>not</li>
<li>or</li>
<li>pass</li>
<li>print</li>
<li>property</li>
<li>raise</li>
<li>return</li>
<li>schema</li>
<li>self</li>
<li>true</li>
<li>try</li>
<li>while</li>
<li>with</li>
<li>yield</li>
</ul>

## FEATURE SET


### Client Modification Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|BasePath|✗|ToolingExtension
|Authorizations|✗|ToolingExtension
|UserAgent|✗|ToolingExtension
|MockServer|✗|ToolingExtension

### Data Type Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Custom|✗|OAS2,OAS3
|Int32|✓|OAS2,OAS3
|Int64|✓|OAS2,OAS3
|Float|✓|OAS2,OAS3
|Double|✓|OAS2,OAS3
|Decimal|✓|ToolingExtension
|String|✓|OAS2,OAS3
|Byte|✓|OAS2,OAS3
|Binary|✓|OAS2,OAS3
|Boolean|✓|OAS2,OAS3
|Date|✓|OAS2,OAS3
|DateTime|✓|OAS2,OAS3
|Password|✓|OAS2,OAS3
|File|✓|OAS2
|Uuid|✗|
|Array|✓|OAS2,OAS3
|Null|✗|OAS3
|AnyType|✗|OAS2,OAS3
|Object|✓|OAS2,OAS3
|Maps|✓|ToolingExtension
|CollectionFormat|✓|OAS2
|CollectionFormatMulti|✓|OAS2
|Enum|✓|OAS2,OAS3
|ArrayOfEnum|✓|ToolingExtension
|ArrayOfModel|✓|ToolingExtension
|ArrayOfCollectionOfPrimitives|✓|ToolingExtension
|ArrayOfCollectionOfModel|✓|ToolingExtension
|ArrayOfCollectionOfEnum|✓|ToolingExtension
|MapOfEnum|✓|ToolingExtension
|MapOfModel|✓|ToolingExtension
|MapOfCollectionOfPrimitives|✓|ToolingExtension
|MapOfCollectionOfModel|✓|ToolingExtension
|MapOfCollectionOfEnum|✓|ToolingExtension

### Documentation Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Readme|✓|ToolingExtension
|Model|✓|ToolingExtension
|Api|✓|ToolingExtension

### Global Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Host|✓|OAS2,OAS3
|BasePath|✓|OAS2,OAS3
|Info|✓|OAS2,OAS3
|Schemes|✗|OAS2,OAS3
|PartialSchemes|✓|OAS2,OAS3
|Consumes|✓|OAS2
|Produces|✓|OAS2
|ExternalDocumentation|✓|OAS2,OAS3
|Examples|✓|OAS2,OAS3
|XMLStructureDefinitions|✗|OAS2,OAS3
|MultiServer|✗|OAS3
|ParameterizedServer|✗|OAS3
|ParameterStyling|✗|OAS3
|Callbacks|✗|OAS3
|LinkObjects|✗|OAS3

### Parameter Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Path|✓|OAS2,OAS3
|Query|✓|OAS2,OAS3
|Header|✓|OAS2,OAS3
|Body|✓|OAS2
|FormUnencoded|✓|OAS2
|FormMultipart|✓|OAS2
|Cookie|✗|OAS3

### Schema Support Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Simple|✓|OAS2,OAS3
|Composite|✓|OAS2,OAS3
|Polymorphism|✓|OAS2,OAS3
|Union|✗|OAS3
|allOf|✓|OAS2,OAS3
|anyOf|✓|OAS3
|oneOf|✓|OAS3
|not|✗|OAS3

### Security Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|BasicAuth|✓|OAS2,OAS3
|ApiKey|✓|OAS2,OAS3
|OpenIDConnect|✗|OAS3
|BearerToken|✓|OAS3
|OAuth2_Implicit|✓|OAS2,OAS3
|OAuth2_Password|✗|OAS2,OAS3
|OAuth2_ClientCredentials|✗|OAS2,OAS3
|OAuth2_AuthorizationCode|✗|OAS2,OAS3

### Wire Format Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|JSON|✓|OAS2,OAS3
|XML|✓|OAS2,OAS3
|PROTOBUF|✗|ToolingExtension
|Custom|✓|OAS2,OAS3
2 changes: 2 additions & 0 deletions docs/generators/python-prior.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## LANGUAGE PRIMITIVES

<ul class="column-ul">
<li>Dict</li>
<li>List</li>
<li>bool</li>
<li>bytes</li>
<li>date</li>
Expand Down
2 changes: 2 additions & 0 deletions docs/generators/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## LANGUAGE PRIMITIVES

<ul class="column-ul">
<li>Dict</li>
<li>List</li>
<li>bool</li>
<li>bytes</li>
<li>date</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -637,14 +637,29 @@ protected void removeSelfReferenceImports(CodegenModel model) {
}

public void setCircularReferences(Map<String, CodegenModel> models) {
final Map<String, List<CodegenProperty>> dependencyMap = models.entrySet().stream()
.collect(Collectors.toMap(Entry::getKey, entry -> getModelDependencies(entry.getValue())));
// for allVars
final Map<String, List<CodegenProperty>> allVarsDependencyMap = models.entrySet().stream()
.collect(Collectors.toMap(Entry::getKey, entry -> getModelDependencies(entry.getValue().getAllVars())));

models.keySet().forEach(name -> setCircularReferencesOnProperties(name, dependencyMap));
models.keySet().forEach(name -> setCircularReferencesOnProperties(name, allVarsDependencyMap));

// for vars
final Map<String, List<CodegenProperty>> varsDependencyMap = models.entrySet().stream()
.collect(Collectors.toMap(Entry::getKey, entry -> getModelDependencies(entry.getValue().getVars())));

models.keySet().forEach(name -> setCircularReferencesOnProperties(name, varsDependencyMap));

// for oneOf
final Map<String, List<CodegenProperty>> oneOfDependencyMap = models.entrySet().stream()
.collect(Collectors.toMap(Entry::getKey, entry -> getModelDependencies(
(entry.getValue().getComposedSchemas() != null && entry.getValue().getComposedSchemas().getOneOf() != null)
? entry.getValue().getComposedSchemas().getOneOf() : new ArrayList<CodegenProperty>())));

models.keySet().forEach(name -> setCircularReferencesOnProperties(name, oneOfDependencyMap));
}

private List<CodegenProperty> getModelDependencies(CodegenModel model) {
return model.getAllVars().stream()
private List<CodegenProperty> getModelDependencies( List<CodegenProperty> vars) {
return vars.stream()
.map(prop -> {
if (prop.isContainer) {
return prop.items.dataType == null ? null : prop;
Expand Down
Loading