Skip to content

Commit 3bfd851

Browse files
committed
Adds python-experimental with dynamic base classes
1 parent 361b593 commit 3bfd851

File tree

549 files changed

+57573
-14
lines changed

Some content is hidden

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

549 files changed

+57573
-14
lines changed

bin/configs/python-experimental.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +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
5+
templatingEngineName: handlebars
6+
additionalProperties:
7+
packageName: petstore_api
8+
recursionLimit: "1234"

docs/generators.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ The following generators are available:
5454
* [php-dt (beta)](generators/php-dt.md)
5555
* [powershell (beta)](generators/powershell.md)
5656
* [python (experimental)](generators/python.md)
57+
* [python-experimental (experimental)](generators/python-experimental.md)
5758
* [python-legacy](generators/python-legacy.md)
5859
* [r](generators/r.md)
5960
* [ruby](generators/ruby.md)
Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
---
2+
title: Config Options for python-experimental
3+
sidebar_label: python-experimental
4+
---
5+
6+
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.
7+
8+
| Option | Description | Values | Default |
9+
| ------ | ----------- | ------ | ------- |
10+
|generateSourceCodeOnly|Specifies that only a library source code is to be generated.| |false|
11+
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
12+
|library|library template (sub-template) to use: asyncio, tornado, urllib3| |urllib3|
13+
|packageName|python package name (convention: snake_case).| |openapi_client|
14+
|packageUrl|python package URL.| |null|
15+
|packageVersion|python package version.| |1.0.0|
16+
|projectName|python project name in setup.py (e.g. petstore-api).| |null|
17+
|recursionLimit|Set the recursion limit. If not set, use the system default value.| |null|
18+
|useNose|use the nose test framework| |false|
19+
20+
## IMPORT MAPPING
21+
22+
| Type/Alias | Imports |
23+
| ---------- | ------- |
24+
25+
26+
## INSTANTIATION TYPES
27+
28+
| Type/Alias | Instantiated By |
29+
| ---------- | --------------- |
30+
|map|dict|
31+
32+
33+
## LANGUAGE PRIMITIVES
34+
35+
<ul class="column-ul">
36+
<li>bool</li>
37+
<li>bytes</li>
38+
<li>date</li>
39+
<li>datetime</li>
40+
<li>dict</li>
41+
<li>file</li>
42+
<li>file_type</li>
43+
<li>float</li>
44+
<li>int</li>
45+
<li>list</li>
46+
<li>none_type</li>
47+
<li>object</li>
48+
<li>str</li>
49+
</ul>
50+
51+
## RESERVED WORDS
52+
53+
<ul class="column-ul">
54+
<li>all_params</li>
55+
<li>and</li>
56+
<li>as</li>
57+
<li>assert</li>
58+
<li>async</li>
59+
<li>auth_settings</li>
60+
<li>await</li>
61+
<li>body_params</li>
62+
<li>bool</li>
63+
<li>break</li>
64+
<li>class</li>
65+
<li>continue</li>
66+
<li>def</li>
67+
<li>del</li>
68+
<li>dict</li>
69+
<li>elif</li>
70+
<li>else</li>
71+
<li>except</li>
72+
<li>exec</li>
73+
<li>false</li>
74+
<li>file_type</li>
75+
<li>finally</li>
76+
<li>float</li>
77+
<li>for</li>
78+
<li>form_params</li>
79+
<li>from</li>
80+
<li>frozendict</li>
81+
<li>global</li>
82+
<li>header_params</li>
83+
<li>if</li>
84+
<li>import</li>
85+
<li>in</li>
86+
<li>int</li>
87+
<li>is</li>
88+
<li>lambda</li>
89+
<li>list</li>
90+
<li>local_var_files</li>
91+
<li>none</li>
92+
<li>none_type</li>
93+
<li>nonlocal</li>
94+
<li>not</li>
95+
<li>or</li>
96+
<li>pass</li>
97+
<li>path_params</li>
98+
<li>print</li>
99+
<li>property</li>
100+
<li>query_params</li>
101+
<li>raise</li>
102+
<li>resource_path</li>
103+
<li>return</li>
104+
<li>self</li>
105+
<li>str</li>
106+
<li>true</li>
107+
<li>try</li>
108+
<li>tuple</li>
109+
<li>while</li>
110+
<li>with</li>
111+
<li>yield</li>
112+
</ul>
113+
114+
## FEATURE SET
115+
116+
117+
### Client Modification Feature
118+
| Name | Supported | Defined By |
119+
| ---- | --------- | ---------- |
120+
|BasePath|✗|ToolingExtension
121+
|Authorizations|✗|ToolingExtension
122+
|UserAgent|✗|ToolingExtension
123+
|MockServer|✗|ToolingExtension
124+
125+
### Data Type Feature
126+
| Name | Supported | Defined By |
127+
| ---- | --------- | ---------- |
128+
|Custom|✗|OAS2,OAS3
129+
|Int32|✓|OAS2,OAS3
130+
|Int64|✓|OAS2,OAS3
131+
|Float|✓|OAS2,OAS3
132+
|Double|✓|OAS2,OAS3
133+
|Decimal|✓|ToolingExtension
134+
|String|✓|OAS2,OAS3
135+
|Byte|✓|OAS2,OAS3
136+
|Binary|✓|OAS2,OAS3
137+
|Boolean|✓|OAS2,OAS3
138+
|Date|✓|OAS2,OAS3
139+
|DateTime|✓|OAS2,OAS3
140+
|Password|✓|OAS2,OAS3
141+
|File|✓|OAS2
142+
|Array|✓|OAS2,OAS3
143+
|Maps|✓|ToolingExtension
144+
|CollectionFormat|✓|OAS2
145+
|CollectionFormatMulti|✓|OAS2
146+
|Enum|✓|OAS2,OAS3
147+
|ArrayOfEnum|✓|ToolingExtension
148+
|ArrayOfModel|✓|ToolingExtension
149+
|ArrayOfCollectionOfPrimitives|✓|ToolingExtension
150+
|ArrayOfCollectionOfModel|✓|ToolingExtension
151+
|ArrayOfCollectionOfEnum|✓|ToolingExtension
152+
|MapOfEnum|✓|ToolingExtension
153+
|MapOfModel|✓|ToolingExtension
154+
|MapOfCollectionOfPrimitives|✓|ToolingExtension
155+
|MapOfCollectionOfModel|✓|ToolingExtension
156+
|MapOfCollectionOfEnum|✓|ToolingExtension
157+
158+
### Documentation Feature
159+
| Name | Supported | Defined By |
160+
| ---- | --------- | ---------- |
161+
|Readme|✓|ToolingExtension
162+
|Model|✓|ToolingExtension
163+
|Api|✓|ToolingExtension
164+
165+
### Global Feature
166+
| Name | Supported | Defined By |
167+
| ---- | --------- | ---------- |
168+
|Host|✓|OAS2,OAS3
169+
|BasePath|✓|OAS2,OAS3
170+
|Info|✓|OAS2,OAS3
171+
|Schemes|✗|OAS2,OAS3
172+
|PartialSchemes|✓|OAS2,OAS3
173+
|Consumes|✓|OAS2
174+
|Produces|✓|OAS2
175+
|ExternalDocumentation|✓|OAS2,OAS3
176+
|Examples|✓|OAS2,OAS3
177+
|XMLStructureDefinitions|✗|OAS2,OAS3
178+
|MultiServer|✗|OAS3
179+
|ParameterizedServer|✓|OAS3
180+
|ParameterStyling|✓|OAS3
181+
|Callbacks|✗|OAS3
182+
|LinkObjects|✗|OAS3
183+
184+
### Parameter Feature
185+
| Name | Supported | Defined By |
186+
| ---- | --------- | ---------- |
187+
|Path|✓|OAS2,OAS3
188+
|Query|✓|OAS2,OAS3
189+
|Header|✓|OAS2,OAS3
190+
|Body|✓|OAS2
191+
|FormUnencoded|✓|OAS2
192+
|FormMultipart|✓|OAS2
193+
|Cookie|✗|OAS3
194+
195+
### Schema Support Feature
196+
| Name | Supported | Defined By |
197+
| ---- | --------- | ---------- |
198+
|Simple|✓|OAS2,OAS3
199+
|Composite|✓|OAS2,OAS3
200+
|Polymorphism|✓|OAS2,OAS3
201+
|Union|✓|OAS3
202+
203+
### Security Feature
204+
| Name | Supported | Defined By |
205+
| ---- | --------- | ---------- |
206+
|BasicAuth|✓|OAS2,OAS3
207+
|ApiKey|✓|OAS2,OAS3
208+
|OpenIDConnect|✗|OAS3
209+
|BearerToken|✓|OAS3
210+
|OAuth2_Implicit|✓|OAS2,OAS3
211+
|OAuth2_Password|✗|OAS2,OAS3
212+
|OAuth2_ClientCredentials|✗|OAS2,OAS3
213+
|OAuth2_AuthorizationCode|✗|OAS2,OAS3
214+
215+
### Wire Format Feature
216+
| Name | Supported | Defined By |
217+
| ---- | --------- | ---------- |
218+
|JSON|✓|OAS2,OAS3
219+
|XML|✗|OAS2,OAS3
220+
|PROTOBUF|✗|ToolingExtension
221+
|Custom|✓|OAS2,OAS3

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,9 @@ public void setEmptyVars(boolean emptyVars) {
10511051
this.emptyVars = emptyVars;
10521052
}
10531053

1054+
public boolean getHasItems() {
1055+
return this.items != null;
1056+
}
10541057
/**
10551058
* Remove duplicated properties in all variable list
10561059
*/

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,10 @@ public void setHasDiscriminatorWithNonEmptyMapping(boolean hasDiscriminatorWithN
778778
this.hasDiscriminatorWithNonEmptyMapping = hasDiscriminatorWithNonEmptyMapping;
779779
}
780780

781+
public boolean getHasItems() {
782+
return this.items != null;
783+
}
784+
781785
@Override
782786
public boolean getIsString() { return isString; }
783787

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

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2731,7 +2731,6 @@ public CodegenModel fromModel(String name, Schema schema) {
27312731
addParentContainer(m, name, schema);
27322732
} else if (ModelUtils.isIntegerSchema(schema)) { // integer type
27332733
// NOTE: Integral schemas as CodegenModel is a rare use case and may be removed at a later date.
2734-
27352734
m.isNumeric = Boolean.TRUE;
27362735
if (ModelUtils.isLongSchema(schema)) { // int64/long format
27372736
m.isLong = Boolean.TRUE;
@@ -2823,6 +2822,7 @@ public int compare(CodegenProperty one, CodegenProperty another) {
28232822
postProcessModelProperty(m, prop);
28242823
}
28252824
}
2825+
28262826
return m;
28272827
}
28282828

@@ -2870,16 +2870,15 @@ protected void setAddProps(Schema schema, IJsonSchemaValidationProperties proper
28702870
}
28712871
}
28722872

2873-
2874-
/**
2875-
* Recursively look in Schema sc for the discriminator discPropName
2876-
* and return a CodegenProperty with the dataType and required params set
2877-
* the returned CodegenProperty may not be required and it may not be of type string
2878-
*
2879-
* @param composedSchemaName The name of the sc Schema
2880-
* @param sc The Schema that may contain the discriminator
2881-
* @param discPropName The String that is the discriminator propertyName in the schema
2882-
*/
2873+
/**
2874+
* Recursively look in Schema sc for the discriminator discPropName
2875+
* and return a CodegenProperty with the dataType and required params set
2876+
* the returned CodegenProperty may not be required and it may not be of type string
2877+
*
2878+
* @param composedSchemaName The name of the sc Schema
2879+
* @param sc The Schema that may contain the discriminator
2880+
* @param discPropName The String that is the discriminator propertyName in the schema
2881+
*/
28832882
private CodegenProperty discriminatorFound(String composedSchemaName, Schema sc, String discPropName, OpenAPI openAPI) {
28842883
Schema refSchema = ModelUtils.getReferencedSchema(openAPI, sc);
28852884
if (refSchema.getProperties() != null && refSchema.getProperties().get(discPropName) != null) {
@@ -5199,7 +5198,7 @@ protected void addVars(CodegenModel m, Map<String, Schema> properties, List<Stri
51995198
* @param properties a map of properties (schema)
52005199
* @param mandatory a set of required properties' name
52015200
*/
5202-
private void addVars(IJsonSchemaValidationProperties m, List<CodegenProperty> vars, Map<String, Schema> properties, Set<String> mandatory) {
5201+
protected void addVars(IJsonSchemaValidationProperties m, List<CodegenProperty> vars, Map<String, Schema> properties, Set<String> mandatory) {
52035202
if (properties == null) {
52045203
return;
52055204
}
@@ -6826,7 +6825,7 @@ public CodegenParameter fromRequestBody(RequestBody body, Set<String> imports, S
68266825
return codegenParameter;
68276826
}
68286827

6829-
private void addVarsRequiredVarsAdditionalProps(Schema schema, IJsonSchemaValidationProperties property){
6828+
protected void addVarsRequiredVarsAdditionalProps(Schema schema, IJsonSchemaValidationProperties property){
68306829
setAddProps(schema, property);
68316830
if (!"object".equals(schema.getType())) {
68326831
return;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.openapitools.codegen.api.TemplateFileType;
4242
import org.openapitools.codegen.ignore.CodegenIgnoreProcessor;
4343
import org.openapitools.codegen.languages.PythonClientCodegen;
44+
import org.openapitools.codegen.languages.PythonExperimentalClientCodegen;
4445
import org.openapitools.codegen.meta.GeneratorMetadata;
4546
import org.openapitools.codegen.meta.Stability;
4647
import org.openapitools.codegen.serializer.SerializerUtils;
@@ -527,7 +528,7 @@ void generateModels(List<File> files, List<Object> allModels, List<String> unuse
527528
Map<String, Object> modelTemplate = (Map<String, Object>) modelList.get(0);
528529
if (modelTemplate != null && modelTemplate.containsKey("model")) {
529530
CodegenModel m = (CodegenModel) modelTemplate.get("model");
530-
if (m.isAlias && !(config instanceof PythonClientCodegen)) {
531+
if (m.isAlias && !((config instanceof PythonClientCodegen) || (config instanceof PythonExperimentalClientCodegen))) {
531532
// alias to number, string, enum, etc, which should not be generated as model
532533
// for PythonClientCodegen, all aliases are generated as models
533534
continue; // Don't create user-defined classes for aliases

0 commit comments

Comments
 (0)