Skip to content

Commit

Permalink
Merge branch 'OpenAPITools:master' into generate_enums
Browse files Browse the repository at this point in the history
  • Loading branch information
chaayac committed Sep 16, 2022
2 parents cbaa34b + 048af8e commit d224fe6
Show file tree
Hide file tree
Showing 246 changed files with 1,263 additions and 599 deletions.
2 changes: 1 addition & 1 deletion docs/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ java -cp "out/generators/my-codegen/target/my-codegen-openapi-generator-1.0.0.ja
Note the `my-codegen` is an option for `-g` now, and you can use the usual arguments for generating your code:

```sh
java -cp out/codegens/customCodegen/target/my-codegen-openapi-generator-1.0.0.jar:modules/openapi-generator-cli/target/openapi-generator-cli.jar \
java -cp out/generators/my-codegen/target/my-codegen-openapi-generator-1.0.0.jar:modules/openapi-generator-cli/target/openapi-generator-cli.jar \
org.openapitools.codegen.OpenAPIGenerator generate -g my-codegen \
-i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml \
-o ./out/myClient
Expand Down
1 change: 0 additions & 1 deletion docs/generators/php-dt.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>bool</li>
<li>boolean</li>
<li>byte</li>
<li>double</li>
<li>float</li>
<li>int</li>
<li>integer</li>
Expand Down
1 change: 0 additions & 1 deletion docs/generators/php-laravel.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>bool</li>
<li>boolean</li>
<li>byte</li>
<li>double</li>
<li>float</li>
<li>int</li>
<li>integer</li>
Expand Down
1 change: 0 additions & 1 deletion docs/generators/php-lumen.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>bool</li>
<li>boolean</li>
<li>byte</li>
<li>double</li>
<li>float</li>
<li>int</li>
<li>integer</li>
Expand Down
1 change: 0 additions & 1 deletion docs/generators/php-mezzio-ph.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>bool</li>
<li>boolean</li>
<li>byte</li>
<li>double</li>
<li>float</li>
<li>int</li>
<li>integer</li>
Expand Down
1 change: 0 additions & 1 deletion docs/generators/php-slim-deprecated.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>bool</li>
<li>boolean</li>
<li>byte</li>
<li>double</li>
<li>float</li>
<li>int</li>
<li>integer</li>
Expand Down
1 change: 0 additions & 1 deletion docs/generators/php-slim4.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>bool</li>
<li>boolean</li>
<li>byte</li>
<li>double</li>
<li>float</li>
<li>int</li>
<li>integer</li>
Expand Down
1 change: 0 additions & 1 deletion docs/generators/php-symfony.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>array</li>
<li>bool</li>
<li>byte</li>
<li>double</li>
<li>float</li>
<li>int</li>
<li>mixed</li>
Expand Down
1 change: 0 additions & 1 deletion docs/generators/php.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>bool</li>
<li>boolean</li>
<li>byte</li>
<li>double</li>
<li>float</li>
<li>int</li>
<li>integer</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ public AbstractPhpCodegen() {
"boolean",
"int",
"integer",
"double",
"float",
"string",
"object",
Expand Down Expand Up @@ -119,7 +118,7 @@ public AbstractPhpCodegen() {
typeMapping.put("number", "float");
typeMapping.put("float", "float");
typeMapping.put("decimal", "float");
typeMapping.put("double", "double");
typeMapping.put("double", "float");
typeMapping.put("string", "string");
typeMapping.put("byte", "int");
typeMapping.put("boolean", "bool");
Expand Down Expand Up @@ -656,7 +655,7 @@ public void setParameterExampleValue(CodegenParameter p) {

@Override
public String toEnumValue(String value, String datatype) {
if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
if ("int".equals(datatype) || "float".equals(datatype)) {
return value;
} else {
return "\'" + escapeText(value) + "\'";
Expand Down Expand Up @@ -684,7 +683,7 @@ public String toEnumVarName(String name, String datatype) {
}

// number
if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
if ("int".equals(datatype) || "float".equals(datatype)) {
String varName = name;
varName = varName.replaceAll("-", "MINUS_");
varName = varName.replaceAll("\\+", "PLUS_");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ public PhpDataTransferClientCodegen() {
.stability(Stability.BETA)
.build();

//no point to use double - http://php.net/manual/en/language.types.float.php , especially because of PHP 7+ float type declaration
typeMapping.put("double", "float");

// remove these from primitive types to make the output works
languageSpecificPrimitives.remove("\\DateTime");
languageSpecificPrimitives.remove("\\SplFileObject");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ public String toEnumVarName(String value, String datatype) {
}

// number
if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
if ("int".equals(datatype) || "float".equals(datatype)) {
String varName = "NUMBER_" + value;
varName = varName.replaceAll("-", "MINUS_");
varName = varName.replaceAll("\\+", "PLUS_");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ public PhpMezzioPathHandlerServerCodegen() {
)
);

//no point to use double - http://php.net/manual/en/language.types.float.php , especially because of PHP 7+ float type declaration
typeMapping.put("double", "float");

// remove these from primitive types to make the output works
languageSpecificPrimitives.remove("\\DateTime");
languageSpecificPrimitives.remove("\\SplFileObject");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ public PhpSilexServerCodegen() {
"boolean",
"int",
"integer",
"double",
"float",
"string",
"object",
Expand All @@ -115,7 +114,7 @@ public PhpSilexServerCodegen() {
typeMapping.put("integer", "int");
typeMapping.put("long", "int");
typeMapping.put("float", "float");
typeMapping.put("double", "double");
typeMapping.put("double", "float");
typeMapping.put("string", "string");
typeMapping.put("byte", "int");
typeMapping.put("boolean", "boolean");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ public PhpSymfonyServerCodegen() {
Arrays.asList(
"bool",
"int",
"double",
"float",
"string",
"object",
Expand Down Expand Up @@ -183,7 +182,7 @@ public PhpSymfonyServerCodegen() {
typeMapping.put("decimal", "float");
typeMapping.put("number", "float");
typeMapping.put("float", "float");
typeMapping.put("double", "double");
typeMapping.put("double", "float");
typeMapping.put("string", "string");
typeMapping.put("byte", "int");
typeMapping.put("boolean", "bool");
Expand Down Expand Up @@ -588,7 +587,7 @@ public String toModelImport(String name) {

@Override
public String toEnumValue(String value, String datatype) {
if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
if ("int".equals(datatype) || "float".equals(datatype)) {
return value;
} else {
return "\"" + escapeText(value) + "\"";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def discriminator(cls):
{{/with}}
{{/if}}
{{#if vars}}

class properties:
{{#each vars}}
{{#if complexType}}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{#with items}}
{{#if complexType}}

@classmethod
@property
def {{baseName}}(cls) -> typing.Type['{{complexType}}']:
return {{complexType}}
{{else}}
{{> model_templates/schema }}
{{/if}}
{{/with}}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ class {{#if this.classname}}{{classname}}{{else}}{{#if nameInSnakeCase}}{{name}}
schemas.AnyTypeSchema,
{{/if}}
{{else}}
{{#if getHasMultipleTypes}}
schemas.SchemaTypeCheckerClsFactory(typing.Union[{{#if isNull}}schemas.NoneClass, {{/if}}{{#if isMap}}frozendict.frozendict, {{/if}}{{#if isArray}}tuple, {{/if}}{{#if isString }}str, {{/if}}{{#or isInteger isNumber}}decimal.Decimal, {{/or}}{{#if isBoolean}}schemas.BoolClass, {{/if}}]),
{{/if}}
{{#if composedSchemas}}
schemas.ComposedBase,
{{/if}}
Expand Down Expand Up @@ -41,17 +38,9 @@ class {{#if this.classname}}{{classname}}{{else}}{{#if nameInSnakeCase}}{{name}}
{{#if getFormat}}
format = '{{getFormat}}'
{{/if}}
{{#with items}}
{{#if complexType}}

@classmethod
@property
def {{baseName}}(cls) -> typing.Type['{{complexType}}']:
return {{complexType}}
{{else}}
{{> model_templates/schema }}
{{#if getItems}}
{{> model_templates/list_partial }}
{{/if}}
{{/with}}
{{#or additionalProperties getRequiredVarsMap getHasDiscriminatorWithNonEmptyMapping vars}}
{{> model_templates/dict_partial }}
{{/or}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,22 @@ class {{> model_templates/classname }}(
{{/if}}
"""
{{/if}}
{{#if isStub}}
{{#or additionalProperties getRequiredVarsMap getHasDiscriminatorWithNonEmptyMapping vars}}


class MetaOapg:
{{> model_templates/dict_partial }}
{{/or}}
{{else}}
{{#or additionalProperties getRequiredVarsMap getHasDiscriminatorWithNonEmptyMapping vars hasValidation}}


class MetaOapg:
{{> model_templates/dict_partial }}
{{#unless isStub}}
{{> model_templates/validations }}
{{/unless}}
{{/or}}
{{/if}}
{{> model_templates/property_type_hints }}

{{> model_templates/new }}
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,24 @@ class {{> model_templates/classname }}(
{{/if}}
"""
{{/if}}
{{#if isStub}}
{{#if items}}


class MetaOapg:
{{#unless isStub}}
{{> model_templates/validations }}
{{/unless}}
{{#with items}}
{{#if complexType}}

@classmethod
@property
def {{baseName}}(cls) -> typing.Type['{{complexType}}']:
return {{complexType}}
{{> model_templates/list_partial }}
{{/if}}
{{else}}
{{> model_templates/schema }}
{{#or getItems hasValidation}}


class MetaOapg:
{{#if hasValidation}}
{{> model_templates/validations }}
{{/if}}
{{> model_templates/list_partial }}
{{/or}}
{{/if}}
{{/with}}

{{> model_templates/new }}

Expand Down
Loading

0 comments on commit d224fe6

Please sign in to comment.