Compare commits

..

19 Commits

Author SHA1 Message Date
William Cheng
8ecf9e352d fix additional properties any type 2023-07-30 16:25:18 +08:00
William Cheng
07d4f7d534 update template and samples 2023-07-30 16:20:45 +08:00
William Cheng
659885f509 better additional properties support 2023-07-30 16:15:07 +08:00
William Cheng
526ca78e79 add tests for #16199 (python client) (#16220) 2023-07-30 01:19:11 +08:00
ふぁ
48ff57b4f6 [python-nextgen] fix #16010 circular refs lead to no imports (#16199)
* [python-nextgen] fix #16010 circular refs lead to no imports

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python-nextgen] update samples

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python-nextgen] remove unnecessary Postponed annotations

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python-nextgen] update samples

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python-nextgen] remove unnecessary Postponed annotations

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python-nextgen] update samples

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python-nextgen] update samples

Signed-off-by: ふぁ <yuki@yuki0311.com>

---------

Signed-off-by: ふぁ <yuki@yuki0311.com>
2023-07-30 00:42:46 +08:00
William Cheng
d41fe12c1f [python] Add tests for simple object with additional properties (#16218)
* add tests for simple object without additional properties

* update logic
2023-07-29 11:43:37 +08:00
ふぁ
d9fc039dcf [python-nextgen] fix #16151 Disallow additional properties if not present - missing Any and Dict import (#16208)
* [python-nextgen] fix #16151 Disallow additional properties if not present - missing Any and Dict import

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python-nextgen] update samples

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python-nextgen] remove unwanted imports

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python-nextgen] update samples

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python-nextgen] remove unwanted imports

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python-nextgen] update samples

Signed-off-by: ふぁ <yuki@yuki0311.com>

---------

Signed-off-by: ふぁ <yuki@yuki0311.com>
2023-07-29 10:51:28 +08:00
ふぁ
e411b2ac0a [python-nextgen] Add type to actual instance (#16204)
* [python-nextgen] add type to actual_instance

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python-nextgen] update samples

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python-nextgen] fixed unnecessary type conversions

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python-nextgen] update samples

Signed-off-by: ふぁ <yuki@yuki0311.com>

---------

Signed-off-by: ふぁ <yuki@yuki0311.com>
2023-07-29 10:08:06 +08:00
Marc Miltenberger
adac3b127f Support for multipart/form-data; charset="utf-8" in Java GSON Generator (#16211)
* Support for multipart/form-data; charset="utf-8"

Previously, it was only checked for an exact equal string, which failed when there were additional options such as charset.

* Update samples
2023-07-29 00:22:19 +08:00
William Cheng
7ca84e5c88 Add name, parameter name mapping to abstract go codegen (#16171)
* add name, parameter name mapping to abstract go codegen

* better code format
2023-07-28 09:57:23 +08:00
William Cheng
5d2e80977b add name, parameter mapping to scala generators (#16194) 2023-07-28 09:51:50 +08:00
William Cheng
954d41b9aa [C#] Add property, parameter naming support (#16196)
* add property, parameter naming support to c# generators

* update

* fix workflow

* update test

* update
2023-07-28 09:51:33 +08:00
William Cheng
184dfd2edd [Kotlin] Add name, parameter mapping support (#16193)
* add name, parameter mapping support to abstract kotlin

* remove files
2023-07-28 09:42:08 +08:00
William Cheng
86cf4f1eb1 add mapping option to ada codegen (#16190) 2023-07-28 09:41:43 +08:00
Masahiro Sakai
f6a819686d [haskell][haskell-yesod] Fix special char replacements (#16197)
* [haskell][haskell-yesod] remove fixOperatorChars()

fixOperatorChars() does not change input strings since special
characters have already been replaced in DefaultCodegen.fromModel().

* [haskell][haskell-yesod] do not prefix with quote ("'") when generating removeFieldLabelPrefix table

We switched from the conversion done by fixOperatorChars() to the
conversion done by DefaultCodegen.fromModel() and the latter does not
insert quote characters. So We modify the removeFieldLabelPrefix table
to conform the new mapping.

* [haskell][haskell-yesod] remove forParsing parameter from removeFieldLabelPrefix function

Aeson's fieldLabelModifier always convert Haskell field names to JSON
field names, whether at parse time or not. (Note that stripPrefix and
uncapitalize do not take such parameter)

* [haskell][haskell-yesod] perform replaceSpecialChars after stripping prefix

Because replaceSpecialChars can corrupt prefix if the prefix contains
a replacement string of a specfial character as a substring.

* [haskell][haskell-yesod] regenerate samples
2023-07-28 09:35:46 +08:00
William Cheng
d7311cd5cd [Ruby] add property, parameter name mapping (#16191)
* add property, parameter name mapping support to ruby generators

* update samples
2023-07-27 09:48:53 +08:00
Adam Shannon
90eacb685c fix(golang): make sure xml.Encoder is closed (#16141) 2023-07-26 15:48:46 +08:00
William Cheng
30c38ed7ad fix potential npe in ada codegen (#16188) 2023-07-26 14:12:45 +08:00
William Cheng
596487aa6c update doc, customization.md (#16189) 2023-07-26 14:11:36 +08:00
438 changed files with 12257 additions and 709 deletions

View File

@@ -20,6 +20,8 @@ on:
- samples/client/petstore/csharp/OpenAPIClient-net5.0/**
# build C# API client (.net 5.0 with ConditionalSerialization)
- samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/**
# build C# API client (property, parameter name mappings)
- samples/client/petstore/csharp-restsharp-name-parameter-mappings/**
pull_request:
paths:
# build C# API client (multiple frameworks)
@@ -39,6 +41,8 @@ on:
- samples/client/petstore/csharp/OpenAPIClient-net5.0/**
# build C# API client (.net 5.0 with ConditionalSerialization)
- samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/**
# build C# API client (property, parameter name mappings)
- samples/client/petstore/csharp-restsharp-name-parameter-mappings/**
jobs:
build:
name: Build .Net clients
@@ -65,6 +69,8 @@ jobs:
- samples/client/petstore/csharp/OpenAPIClient-net5.0/
# build C# API client (.net 5.0 with ConditionalSerialization)
- samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/
# build C# API client (property, parameter name mappings)
- samples/client/petstore/csharp-restsharp-name-parameter-mappings
steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v3.2.0

View File

@@ -59,6 +59,7 @@ jobs:
- samples/client/petstore/kotlin-jvm-spring-2-webclient
- samples/client/petstore/kotlin-jvm-spring-3-webclient
- samples/client/petstore/kotlin-spring-cloud
- samples/client/petstore/kotlin-name-parameter-mappings
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3

View File

@@ -115,13 +115,15 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
| OpenAPI Generator Version | Release Date | Notes |
| --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ------------------------------------------------- |
| 7.0.0 (upcoming major release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/7.0.0-SNAPSHOT/) | May/Jun 2023 | Major release with breaking changes (no fallback) |
| 7.0.0 (upcoming major release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/7.0.0-SNAPSHOT/) | Jul/Aug 2023 | Major release with breaking changes (no fallback) |
| [6.6.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v6.6.0) (latest stable release) | 11.05.2023 | Minor release with breaking changes (with fallback) |
| [5.4.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v5.4.0) | 31.01.2022 | Minor release with breaking changes (with fallback) |
| [4.3.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.3.1) | 06.05.2020 | Patch release (enhancements, bug fixes, etc) |
OpenAPI Spec compatibility: 1.0, 1.1, 1.2, 2.0, 3.0
(We do not publish daily/nightly build. Please use SNAPSHOT instead)
For old releases, please refer to the [**Release**](https://github.com/OpenAPITools/openapi-generator/releases) page.
For decomissioned generators/libraries/frameworks, please refer to [the "Decommission" label](https://github.com/OpenAPITools/openapi-generator/issues?q=label%3ADecommission+is%3Amerged+) in the pull request page.
@@ -906,6 +908,8 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- 2023-04-27 - [Create an Angular Client using OpenAPI Specifications](Create an Angular Client using OpenAPI Specifications) by [Patric](https://pguso.medium.com/)
- 2023-05-16 - [Adyen for Java developers](https://www.adyen.com/blog/adyen-java-library) by [Beppe Catanese, Developer Advocate, Adyen](https://github.com/gcatanese)
- 2023-05-18 - [如何基于 Swagger 使用 OpenAPI Generator 生成 JMeter 脚本?](https://blog.51cto.com/u_15181572/6294974) by [高楼Zee)](https://blog.51cto.com/u_15181572)
- 2023-06-28 - [Generate API contract using OpenAPI Generator Maven plugin](https://huongdanjava.com/generate-api-contract-using-openapi-generator-maven-plugin.html) by [Khanh Nguyen](https://huongdanjava.com/)
- 2023-06-30 - [Generate Client SDKs with OpenApi Generator in Springboot](https://medium.com/@ramavathvinayak/generate-client-sdks-with-openapi-generator-in-springboot-f9f012e73c0b) by [Vinayak Ramavath](https://medium.com/@ramavathvinayak)
## [6 - About Us](#table-of-contents)

15
bin/configs/ada.yaml Normal file
View File

@@ -0,0 +1,15 @@
generatorName: ada
outputDir: samples/client/petstore/ada
inputSpec: modules/openapi-generator/src/test/resources/3_0/ada/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/Ada
nameMappings:
_type: P_UnderscoreType
type_: P_TypeWithUnderscore
http_debug_operation: P_HTTPDebugOperation
parameterNameMappings:
_type: UnderscoreType
type_: TypeWithUnderscore
http_debug_operation: HttpDebugOperation
additionalProperties:
modelPackage: Samples.Petstore
projectName: Petstore

View File

@@ -0,0 +1,15 @@
generatorName: csharp
outputDir: samples/client/petstore/csharp-restsharp-name-parameter-mappings
inputSpec: modules/openapi-generator/src/test/resources/3_0/name-parameter-mappings.yaml
templateDir: modules/openapi-generator/src/main/resources/csharp
nameMappings:
_type: UnderscoreType
type_: TypeWithUnderscore
http_debug_operation: HttpDebugOperation
parameterNameMappings:
_type: UnderscoreType
type_: TypeWithUnderscore
http_debug_operation: HttpDebugOperation
additionalProperties:
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
hideGenerationTimestamp: "true"

View File

@@ -2,8 +2,17 @@ generatorName: go
outputDir: samples/openapi3/client/petstore/go/go-petstore
inputSpec: modules/openapi-generator/src/test/resources/3_0/go/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
templateDir: modules/openapi-generator/src/main/resources/go
nameMappings:
_type: UnderscoreType
type_: TypeWithUnderscore
http_debug_operation: HTTPDebugOperation
parameterNameMappings:
_type: underscoreType
type_: typeWithUnderscore
http_debug_operation: httpDebugOperation
additionalProperties:
enumClassPrefix: "true"
packageName: petstore
disallowAdditionalPropertiesIfNotPresent: false
generateInterfaces: true

View File

@@ -0,0 +1,14 @@
generatorName: kotlin
outputDir: samples/client/petstore/kotlin-name-parameter-mappings
inputSpec: modules/openapi-generator/src/test/resources/3_0/name-parameter-mappings.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
nameMappings:
_type: underscoreType
type_: typeWithUnderscore
http_debug_operation: httpDebugOperation
parameterNameMappings:
_type: underscoreType
type_: typeWithUnderscore
http_debug_operation: httpDebugOperation
additionalProperties:
artifactId: kotlin-petstore-client

View File

@@ -9,3 +9,9 @@ additionalProperties:
gemName: petstore
skipFormModel: "true"
strictSpecBehavior: false
nameMappings:
_type: underscore_type
type_: type_with_underscore
parameterNameMappings:
_type: underscore_type
type_: type_with_underscore

View File

@@ -2,5 +2,13 @@ generatorName: scala-sttp
outputDir: samples/client/petstore/scala-sttp
inputSpec: modules/openapi-generator/src/test/resources/3_0/scala/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/scala-sttp
nameMappings:
_type: "`underscoreType`"
type_: "`typeWithUnderscore`"
http_debug_operation: "`httpDebugOperation`"
parameterNameMappings:
_type: underscoreType
type_: typeWithUnderscore
http_debug_operation: httpDebugOperation
additionalProperties:
artifactId: scala-sttp-petstore

View File

@@ -1,7 +0,0 @@
generatorName: ada
outputDir: samples/client/petstore/ada
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/Ada
additionalProperties:
modelPackage: Samples.Petstore
projectName: Petstore

View File

@@ -536,7 +536,7 @@ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generat
Example:
```
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -i modules/openapi-generator/src/test/resources/3_0/enableKeepOnlyFirstTagInOperation_test.yaml -o /tmp/java-okhttp/ --openapi-normalizer SET_TAGS_FOR_ALL_OPERATIONS=true
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -i modules/openapi-generator/src/test/resources/3_0/enableKeepOnlyFirstTagInOperation_test.yaml -o /tmp/java-okhttp/ --openapi-normalizer SET_TAGS_FOR_ALL_OPERATIONS=another_tag_name
```
- `ADD_UNSIGNED_TO_INTEGER_WITH_INVALID_MAX_VALUE`: when set to true, auto fix integer with maximum value 4294967295 (2^32-1) or long with 18446744073709551615 (2^64-1) by adding x-unsigned to the schema

View File

@@ -36,6 +36,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|supportsES6|Generate code that conforms to ES6.| |false|
## IMPORT MAPPING

View File

@@ -47,6 +47,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|stringEnums|Generate string enums instead of objects for enum values.| |false|
|supportsES6|Generate code that conforms to ES6.| |false|
|taggedUnions|Use discriminators to create tagged unions instead of extending interfaces.| |false|
|useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.| |false|
|withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false|

View File

@@ -35,6 +35,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|supportsES6|Generate code that conforms to ES6.| |false|
## IMPORT MAPPING

View File

@@ -38,6 +38,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|stringEnums|Generate string enums instead of objects for enum values.| |false|
|supportsES6|Generate code that conforms to ES6.| |false|
|useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.| |false|
|withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false|
|withNodeImports|Setting this property to true adds imports for NodeJS| |false|

View File

@@ -40,6 +40,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|stringEnums|Generate string enums instead of objects for enum values.| |false|
|supportsES6|Generate code that conforms to ES6.| |false|
|useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.| |true|
|withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false|
|withoutRuntimeChecks|Setting this property to true will remove any runtime checks on the request and response payloads. Payloads will be casted to their expected types.| |false|

View File

@@ -36,6 +36,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|supportsES6|Generate code that conforms to ES6.| |false|
|taggedUnions|Use discriminators to create tagged unions instead of extending interfaces.| |false|
|usePromise|Setting this property to use promise instead of observable inside every service.| |false|
|useRxJS6|Setting this property to use rxjs 6 instead of rxjs 5.| |false|

View File

@@ -37,6 +37,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|supportsES6|Generate code that conforms to ES6.| |false|
## IMPORT MAPPING

View File

@@ -43,6 +43,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|stringEnums|Generate string enums instead of objects for enum values.| |false|
|supportsES6|Generate code that conforms to ES6.| |false|
|taggedUnions|Use discriminators to create tagged unions instead of extending interfaces.| |false|
|withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false|

View File

@@ -36,6 +36,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|supportsES6|Generate code that conforms to ES6.| |false|
## IMPORT MAPPING

View File

@@ -36,6 +36,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|supportsES6|Generate code that conforms to ES6.| |false|
|useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.| |true|
|withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false|

View File

@@ -36,6 +36,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|supportsES6|Generate code that conforms to ES6.| |false|
|withProgressSubscriber|Setting this property to true will generate API controller methods with support for subscribing to request progress.| |false|
## IMPORT MAPPING

View File

@@ -40,6 +40,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|supportsES6|Generate code that conforms to ES6.| |false|
|useInversify|Enable this to generate decorators and service identifiers for the InversifyJS inversion of control container. If you set 'deno' as 'platform', the generator will process this value as 'disable'.| |false|
|useObjectParameters|Use aggregate parameter objects as function arguments for api operations instead of passing each parameter as a separate function argument.| |false|
|useRxJS|Enable this to internally use rxjs observables. If disabled, a stub is used instead. This is required for the 'angular' framework.| |false|

View File

@@ -272,6 +272,9 @@ public class CodegenConstants {
public static final String HTTP_USER_AGENT = "httpUserAgent";
public static final String HTTP_USER_AGENT_DESC = "HTTP user agent, e.g. codegen_csharp_api_client, default to 'OpenAPI-Generator/{packageVersion}/{language}'";
public static final String SUPPORTS_ES6 = "supportsES6";
public static final String SUPPORTS_ES6_DESC = "Generate code that conforms to ES6.";
public static final String SUPPORTS_ASYNC = "supportsAsync";
public static final String SUPPORTS_ASYNC_DESC = "Generate code that supports async operations.";

View File

@@ -153,6 +153,23 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
*/
public boolean isAdditionalPropertiesTrue;
/**
* True if additional properties is set to any type
*/
public boolean isAdditionalPropertiesAnyType;
/**
* True if additional properties is set to free form object
*/
public boolean isAdditionalPropertiesFreeFormObject;
/**
* True if additional properties is enabled (boolean or any type)
*/
public boolean isAdditionalPropertiesEnabled() {
return isAdditionalPropertiesTrue || isAdditionalPropertiesAnyType || isAdditionalPropertiesFreeFormObject;
}
private Integer maxProperties;
private Integer minProperties;
private boolean uniqueItems;
@@ -1088,6 +1105,9 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
Objects.equals(externalDocumentation, that.externalDocumentation) &&
Objects.equals(vendorExtensions, that.vendorExtensions) &&
Objects.equals(additionalPropertiesType, that.additionalPropertiesType) &&
Objects.equals(isAdditionalPropertiesAnyType, that.isAdditionalPropertiesAnyType) &&
Objects.equals(isAdditionalPropertiesFreeFormObject, that.isAdditionalPropertiesFreeFormObject) &&
Objects.equals(isAdditionalPropertiesTrue, that.isAdditionalPropertiesTrue) &&
Objects.equals(getMaxProperties(), that.getMaxProperties()) &&
Objects.equals(getMinProperties(), that.getMinProperties()) &&
Objects.equals(getMaxItems(), that.getMaxItems()) &&
@@ -1121,7 +1141,8 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
getAdditionalPropertiesIsAnyType(), hasDiscriminatorWithNonEmptyMapping,
isAnyType, getComposedSchemas(), hasMultipleTypes, isDecimal, isUuid, requiredVarsMap, ref,
uniqueItemsBoolean, schemaIsFromAdditionalProperties, isBooleanSchemaTrue, isBooleanSchemaFalse,
format, dependentRequired, contains);
format, dependentRequired, contains, isAdditionalPropertiesTrue, isAdditionalPropertiesFreeFormObject,
isAdditionalPropertiesFreeFormObject);
}
@Override
@@ -1227,6 +1248,9 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
sb.append(", format=").append(format);
sb.append(", dependentRequired=").append(dependentRequired);
sb.append(", contains=").append(contains);
sb.append(", isAdditionalPropertiesAnyType=").append(isAdditionalPropertiesAnyType);
sb.append(", isAdditionalPropertiesFreeFormObject=").append(isAdditionalPropertiesFreeFormObject);
sb.append(", isAdditionalPropertiesTrue=").append(isAdditionalPropertiesTrue);
sb.append('}');
return sb.toString();
}

View File

@@ -1617,6 +1617,11 @@ public class DefaultCodegen implements CodegenConfig {
* @return the sanitized variable name
*/
public String toVarName(final String name) {
// obtain the name from nameMapping directly if provided
if (nameMapping.containsKey(name)) {
return nameMapping.get(name);
}
if (reservedWords.contains(name)) {
return escapeReservedWord(name);
} else if (name.chars().anyMatch(character -> specialCharReplacements.containsKey(String.valueOf((char) character)))) {
@@ -1634,6 +1639,11 @@ public class DefaultCodegen implements CodegenConfig {
*/
@Override
public String toParamName(String name) {
// obtain the name from parameterNameMapping directly if provided
if (parameterNameMapping.containsKey(name)) {
return parameterNameMapping.get(name);
}
name = removeNonNameElementToCamelCase(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
if (reservedWords.contains(name)) {
return escapeReservedWord(name);
@@ -3157,13 +3167,16 @@ public class DefaultCodegen implements CodegenConfig {
// if we are trying to set additionalProperties on an empty schema stop recursing
return;
}
boolean additionalPropertiesIsAnyType = false;
boolean isAdditionalPropertiesTrue = false;
boolean isAdditionalPropertiesFreeFormObject = false;
CodegenModel m = null;
if (property instanceof CodegenModel) {
m = (CodegenModel) property;
}
CodegenProperty addPropProp = null;
boolean isAdditionalPropertiesTrue = false;
if (schema.getAdditionalProperties() == null) {
if (!disallowAdditionalPropertiesIfNotPresent) {
isAdditionalPropertiesTrue = true;
@@ -3173,20 +3186,25 @@ public class DefaultCodegen implements CodegenConfig {
} else if (schema.getAdditionalProperties() instanceof Boolean) {
if (Boolean.TRUE.equals(schema.getAdditionalProperties())) {
isAdditionalPropertiesTrue = true;
addPropProp = fromProperty(getAdditionalPropertiesName(), new Schema(), false);
additionalPropertiesIsAnyType = true;
}
} else {
addPropProp = fromProperty(getAdditionalPropertiesName(), (Schema) schema.getAdditionalProperties(), false);
if (ModelUtils.isAnyType((Schema) schema.getAdditionalProperties())) {
isAdditionalPropertiesTrue = true;
additionalPropertiesIsAnyType = true;
}
if (ModelUtils.isFreeFormObject((Schema) schema.getAdditionalProperties())) {
isAdditionalPropertiesFreeFormObject = true;
}
}
if (additionalPropertiesIsAnyType) {
property.setAdditionalPropertiesIsAnyType(true);
}
if (m != null && isAdditionalPropertiesTrue) {
m.isAdditionalPropertiesTrue = true;
if (m != null) {
m.isAdditionalPropertiesTrue = isAdditionalPropertiesTrue;
m.isAdditionalPropertiesAnyType = additionalPropertiesIsAnyType;
m.isAdditionalPropertiesFreeFormObject = isAdditionalPropertiesFreeFormObject;
}
if (ModelUtils.isComposedSchema(schema) && !supportsAdditionalPropertiesWithComposedSchema) {
return;

View File

@@ -364,11 +364,21 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
@Override
public String toVarName(String name) {
// obtain the name from nameMapping directly if provided
if (nameMapping.containsKey(name)) {
return nameMapping.get(name);
}
return toAdaIdentifier(sanitizeName(name), "P_");
}
@Override
public String toParamName(String name) {
// obtain the name from parameterNameMapping directly if provided
if (parameterNameMapping.containsKey(name)) {
return parameterNameMapping.get(name);
}
return toAdaIdentifier(super.toParamName(name), "P_");
}
@@ -821,7 +831,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
//LOGGER.debug("Compare " + name + " with " + second.name + "=-1");
return -1;
}
if ((depend == null ? 0 : depend.size()) != (second.depend == null ? 0 : second.depend.size())) {
if (depend != null && (depend == null ? 0 : depend.size()) != (second.depend == null ? 0 : second.depend.size())) {
//LOGGER.debug("Compare " + name + " with " + second.name + "=D"
// + (depend.size() - second.depend.size()));
return depend.size() - second.depend.size();
@@ -833,7 +843,6 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
@Override
public ModelsMap postProcessModels(ModelsMap objs) {
// This is run first, before the operations.
// remove model imports to avoid error
List<Map<String, String>> imports = objs.getImports();

View File

@@ -963,6 +963,11 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
@Override
public String toVarName(String name) {
// obtain the name from nameMapping directly if provided
if (nameMapping.containsKey(name)) {
return nameMapping.get(name);
}
// sanitize name
name = sanitizeName(name);
@@ -989,6 +994,11 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
@Override
public String toParamName(String name) {
// obtain the name from parameterNameMapping directly if provided
if (parameterNameMapping.containsKey(name)) {
return parameterNameMapping.get(name);
}
// sanitize name
name = sanitizeName(name);

View File

@@ -191,6 +191,10 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
@Override
public String toVarName(String name) {
// obtain the name from nameMapping directly if provided
if (nameMapping.containsKey(name)) {
return nameMapping.get(name);
}
// replace - with _ e.g. created-at => created_at
name = sanitizeName(name);
@@ -228,6 +232,11 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
@Override
public String toParamName(String name) {
// obtain the name from parameterNameMapping directly if provided
if (parameterNameMapping.containsKey(name)) {
return parameterNameMapping.get(name);
}
// params should be lowerCamelCase. E.g. "person Person", instead of
// "Person Person".
//
@@ -364,7 +373,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
return "[]" + typDecl;
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);
return getSchemaType(p) + "[string]" + getTypeDeclaration(unaliasSchema(inner));
return getSchemaType(p) + "[string]" + getTypeDeclaration(unaliasSchema(inner));
}
//return super.getTypeDeclaration(p);
@@ -621,7 +630,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
}
List<CodegenProperty> codegenProperties = new ArrayList<>();
if(model.getComposedSchemas() == null || (model.getComposedSchemas() != null && model.getComposedSchemas().getAllOf() != null)) {
if (model.getComposedSchemas() == null || (model.getComposedSchemas() != null && model.getComposedSchemas().getAllOf() != null)) {
// If the model is an allOf or does not have any composed schemas, then we can use the model's properties.
codegenProperties.addAll(model.vars);
} else {

View File

@@ -937,6 +937,11 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
@Override
public String toParamName(String name) {
// obtain the name from parameterNameMapping directly if provided
if (parameterNameMapping.containsKey(name)) {
return parameterNameMapping.get(name);
}
// to avoid conflicts with 'callback' parameter for async call
if ("callback".equals(name)) {
return "paramCallback";
@@ -948,6 +953,11 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
@Override
public String toVarName(String name) {
// obtain the name from nameMapping directly if provided
if (nameMapping.containsKey(name)) {
return nameMapping.get(name);
}
name = toVariableName(name);
if (propertyAdditionalKeywords.contains(name)) {
return camelize("property_" + name, LOWERCASE_FIRST_LETTER);

View File

@@ -176,6 +176,11 @@ abstract public class AbstractRubyCodegen extends DefaultCodegen implements Code
@Override
public String toVarName(final String name) {
// obtain the name from nameMapping directly if provided
if (nameMapping.containsKey(name)) {
return nameMapping.get(name);
}
String varName = sanitizeName(name);
// if it's all upper case, convert to lower case
if (name.matches("^[A-Z_]*$")) {
@@ -201,6 +206,11 @@ abstract public class AbstractRubyCodegen extends DefaultCodegen implements Code
@Override
public String toParamName(String name) {
// obtain the name from parameterNameMapping directly if provided
if (parameterNameMapping.containsKey(name)) {
return parameterNameMapping.get(name);
}
// should be the same as variable name
return toVarName(name);
}
@@ -265,5 +275,7 @@ abstract public class AbstractRubyCodegen extends DefaultCodegen implements Code
}
@Override
public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.RUBY; }
public GeneratorLanguage generatorLanguage() {
return GeneratorLanguage.RUBY;
}
}

View File

@@ -276,6 +276,11 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
@Override
public String toVarName(String name) {
// obtain the name from nameMapping directly if provided
if (nameMapping.containsKey(name)) {
return nameMapping.get(name);
}
String varName = sanitizeName(name);
if ("_".equals(varName)) {

View File

@@ -244,6 +244,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
protected ENUM_PROPERTY_NAMING_TYPE enumPropertyNaming = ENUM_PROPERTY_NAMING_TYPE.PascalCase;
protected PARAM_NAMING_TYPE paramNaming = PARAM_NAMING_TYPE.camelCase;
protected boolean enumPropertyNamingReplaceSpecialChar = false;
protected Boolean supportsES6 = false;
protected Boolean nullSafeAdditionalProps = false;
protected HashSet<String> languageGenericTypes;
protected String npmName = null;
@@ -355,6 +356,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
cliOptions.add(new CliOption(CodegenConstants.ENUM_NAME_SUFFIX, CodegenConstants.ENUM_NAME_SUFFIX_DESC).defaultValue(this.enumSuffix));
cliOptions.add(new CliOption(CodegenConstants.ENUM_PROPERTY_NAMING, CodegenConstants.ENUM_PROPERTY_NAMING_DESC).defaultValue(this.enumPropertyNaming.name()));
cliOptions.add(new CliOption(CodegenConstants.MODEL_PROPERTY_NAMING, MODEL_PROPERTY_NAMING_DESC_WITH_WARNING).defaultValue(this.modelPropertyNaming.name()));
cliOptions.add(new CliOption(CodegenConstants.SUPPORTS_ES6, CodegenConstants.SUPPORTS_ES6_DESC).defaultValue(String.valueOf(this.getSupportsES6())));
cliOptions.add(new CliOption(CodegenConstants.PARAM_NAMING, CodegenConstants.PARAM_NAMING_DESC).defaultValue(this.paramNaming.name()));
this.cliOptions.add(new CliOption(NPM_NAME, "The name under which you want to publish generated npm package." +
" Required to generate a full package"));
@@ -401,6 +403,8 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
setParamNaming((String) additionalProperties.get(CodegenConstants.PARAM_NAMING));
}
setSupportsES6(convertPropertyToBooleanAndWriteBack(CodegenConstants.SUPPORTS_ES6));
if (additionalProperties.containsKey(NULL_SAFE_ADDITIONAL_PROPS)) {
setNullSafeAdditionalProps(Boolean.valueOf(additionalProperties.get(NULL_SAFE_ADDITIONAL_PROPS).toString()));
}
@@ -508,9 +512,9 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
@Override
public String toParamName(String name) {
// obtain the name from parameterNameMapping directly if provided
if (parameterNameMapping.containsKey(name)) {
return parameterNameMapping.get(name);
// obtain the name from nameMapping directly if provided
if (nameMapping.containsKey(name)) {
return nameMapping.get(name);
}
name = sanitizeName(name, "[^\\w$]");
@@ -1010,6 +1014,14 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
return result;
}
public void setSupportsES6(Boolean value) {
supportsES6 = value;
}
public Boolean getSupportsES6() {
return supportsES6;
}
public Boolean getNullSafeAdditionalProps() {
return nullSafeAdditionalProps;
}

View File

@@ -1259,6 +1259,11 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
@Override
public String toVarName(String name) {
// obtain the name from nameMapping directly if provided
if (nameMapping.containsKey(name)) {
return nameMapping.get(name);
}
// sanitize name
name = sanitizeName(name);

View File

@@ -928,6 +928,11 @@ public class CSharpReducedClientCodegen extends AbstractCSharpCodegen {
@Override
public String toVarName(String name) {
// obtain the name from nameMapping directly if provided
if (nameMapping.containsKey(name)) {
return nameMapping.get(name);
}
// sanitize name
name = sanitizeName(name);

View File

@@ -326,7 +326,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
String c = (String) replacementChar;
Map<String, Object> o = new HashMap<>();
o.put("char", c);
o.put("replacement", "'" + specialCharReplacements.get(c));
o.put("replacement", specialCharReplacements.get(c));
replacements.add(o);
}
additionalProperties.put("specialCharReplacements", replacements);
@@ -636,29 +636,6 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
}
}
private String fixOperatorChars(String string) {
StringBuilder sb = new StringBuilder();
String name = string;
//Check if it is a reserved word, in which case the underscore is added when property name is generated.
if (string.startsWith("_")) {
if (reservedWords.contains(string.substring(1))) {
name = string.substring(1);
} else if (reservedWordsMappings.containsValue(string)) {
name = LEADING_UNDERSCORE.matcher(string).replaceFirst("");
}
}
for (char c : name.toCharArray()) {
String cString = String.valueOf(c);
if (specialCharReplacements.containsKey(cString)) {
sb.append("'");
sb.append(specialCharReplacements.get(cString));
} else {
sb.append(c);
}
}
return sb.toString();
}
// Remove characters from a string that do not belong in a model classname
private String fixModelChars(String string) {
return string.replace(".", "").replace("-", "");
@@ -680,7 +657,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
// From the model name, compute the prefix for the fields.
String prefix = camelize(model.classname, LOWERCASE_FIRST_LETTER);
for (CodegenProperty prop : model.vars) {
prop.name = toVarName(prefix + camelize(fixOperatorChars(prop.name)));
prop.name = toVarName(prefix + camelize(prop.name));
}
// Create newtypes for things with non-object types

View File

@@ -286,7 +286,7 @@ public class HaskellYesodServerCodegen extends DefaultCodegen implements Codegen
String c = (String) replacementChar;
Map<String, Object> o = new HashMap<>();
o.put("char", c);
o.put("replacement", "'" + specialCharReplacements.get(c));
o.put("replacement", specialCharReplacements.get(c));
replacements.add(o);
}
additionalProperties.put("specialCharReplacements", replacements);
@@ -530,29 +530,6 @@ public class HaskellYesodServerCodegen extends DefaultCodegen implements Codegen
}
}
private String fixOperatorChars(String string) {
StringBuilder sb = new StringBuilder();
String name = string;
//Check if it is a reserved word, in which case the underscore is added when property name is generated.
if (string.startsWith("_")) {
if (reservedWords.contains(string.substring(1))) {
name = string.substring(1);
} else if (reservedWordsMappings.containsValue(string)) {
name = LEADING_UNDERSCORE.matcher(string).replaceFirst("");
}
}
for (char c : name.toCharArray()) {
String cString = String.valueOf(c);
if (specialCharReplacements.containsKey(cString)) {
sb.append("'");
sb.append(specialCharReplacements.get(cString));
} else {
sb.append(c);
}
}
return sb.toString();
}
// Remove characters from a string that do not belong in a model classname
private String fixModelChars(String string) {
return string.replace(".", "").replace("-", "");
@@ -574,7 +551,7 @@ public class HaskellYesodServerCodegen extends DefaultCodegen implements Codegen
// From the model name, compute the prefix for the fields.
String prefix = camelize(model.classname, LOWERCASE_FIRST_LETTER);
for (CodegenProperty prop : model.vars) {
prop.name = toVarName(prefix + camelize(fixOperatorChars(prop.name)));
prop.name = toVarName(prefix + camelize(prop.name));
}
// Create newtypes for things with non-object types

View File

@@ -413,6 +413,8 @@ public class PythonClientCodegen extends AbstractPythonCodegen implements Codege
* @param datetimeImports datetime imports
* @param modelImports model imports
* @param exampleImports example imports
* @param postponedModelImports postponed model imports
* @param postponedExampleImports postponed example imports
* @param classname class name
* @return pydantic type
*
@@ -423,6 +425,8 @@ public class PythonClientCodegen extends AbstractPythonCodegen implements Codege
Set<String> datetimeImports,
Set<String> modelImports,
Set<String> exampleImports,
Set<String> postponedModelImports,
Set<String> postponedExampleImports,
String classname) {
if (cp == null) {
// if codegen parameter (e.g. map/dict of undefined type) is null, default to string
@@ -444,12 +448,12 @@ public class PythonClientCodegen extends AbstractPythonCodegen implements Codege
}
pydanticImports.add("conlist");
return String.format(Locale.ROOT, "conlist(%s%s)",
getPydanticType(cp.items, typingImports, pydanticImports, datetimeImports, modelImports, exampleImports, classname),
getPydanticType(cp.items, typingImports, pydanticImports, datetimeImports, modelImports, exampleImports, postponedModelImports, postponedExampleImports, classname),
constraints);
} else if (cp.isMap) {
typingImports.add("Dict");
return String.format(Locale.ROOT, "Dict[str, %s]",
getPydanticType(cp.items, typingImports, pydanticImports, datetimeImports, modelImports, exampleImports, classname));
getPydanticType(cp.items, typingImports, pydanticImports, datetimeImports, modelImports, exampleImports, postponedModelImports, postponedExampleImports, classname));
} else if (cp.isString) {
if (cp.hasValidation) {
List<String> fieldCustomization = new ArrayList<>();
@@ -658,7 +662,7 @@ public class PythonClientCodegen extends AbstractPythonCodegen implements Codege
CodegenMediaType cmt = contents.get(key);
// TODO process the first one only at the moment
if (cmt != null)
return getPydanticType(cmt.getSchema(), typingImports, pydanticImports, datetimeImports, modelImports, exampleImports, classname);
return getPydanticType(cmt.getSchema(), typingImports, pydanticImports, datetimeImports, modelImports, exampleImports, postponedModelImports, postponedExampleImports, classname);
}
throw new RuntimeException("Error! Failed to process getPydanticType when getting the content: " + cp);
} else {
@@ -675,6 +679,8 @@ public class PythonClientCodegen extends AbstractPythonCodegen implements Codege
* @param datetimeImports datetime imports
* @param modelImports model imports
* @param exampleImports example imports
* @param postponedModelImports postponed model imports
* @param postponedExampleImports postponed example imports
* @param classname class name
* @return pydantic type
*
@@ -685,6 +691,8 @@ public class PythonClientCodegen extends AbstractPythonCodegen implements Codege
Set<String> datetimeImports,
Set<String> modelImports,
Set<String> exampleImports,
Set<String> postponedModelImports,
Set<String> postponedExampleImports,
String classname) {
if (cp == null) {
// if codegen property (e.g. map/dict of undefined type) is null, default to string
@@ -725,11 +733,11 @@ public class PythonClientCodegen extends AbstractPythonCodegen implements Codege
pydanticImports.add("conlist");
typingImports.add("List"); // for return type
return String.format(Locale.ROOT, "conlist(%s%s)",
getPydanticType(cp.items, typingImports, pydanticImports, datetimeImports, modelImports, exampleImports, classname),
getPydanticType(cp.items, typingImports, pydanticImports, datetimeImports, modelImports, exampleImports, postponedModelImports, postponedExampleImports, classname),
constraints);
} else if (cp.isMap) {
typingImports.add("Dict");
return String.format(Locale.ROOT, "Dict[str, %s]", getPydanticType(cp.items, typingImports, pydanticImports, datetimeImports, modelImports, exampleImports, classname));
return String.format(Locale.ROOT, "Dict[str, %s]", getPydanticType(cp.items, typingImports, pydanticImports, datetimeImports, modelImports, exampleImports, postponedModelImports, postponedExampleImports, classname));
} else if (cp.isString) {
if (cp.hasValidation) {
List<String> fieldCustomization = new ArrayList<>();
@@ -935,6 +943,9 @@ public class PythonClientCodegen extends AbstractPythonCodegen implements Codege
} else {
if (circularImports.containsKey(cp.dataType)) {
if (circularImports.get(cp.dataType).contains(classname)) {
hasModelsToImport = true;
postponedModelImports.add(cp.dataType);
postponedExampleImports.add(cp.dataType);
// cp.dataType import map of set contains this model (classname), don't import
LOGGER.debug("Skipped importing {} in {} due to circular import.", cp.dataType, classname);
} else {
@@ -960,15 +971,17 @@ public class PythonClientCodegen extends AbstractPythonCodegen implements Codege
TreeSet<String> pydanticImports = new TreeSet<>();
TreeSet<String> datetimeImports = new TreeSet<>();
TreeSet<String> modelImports = new TreeSet<>();
TreeSet<String> postponedModelImports = new TreeSet<>();
OperationMap objectMap = objs.getOperations();
List<CodegenOperation> operations = objectMap.getOperation();
for (CodegenOperation operation : operations) {
TreeSet<String> exampleImports = new TreeSet<>(); // import for each operation to be show in sample code
TreeSet<String> postponedExampleImports = new TreeSet<>(); // import for each operation to be show in sample code
List<CodegenParameter> params = operation.allParams;
for (CodegenParameter param : params) {
String typing = getPydanticType(param, typingImports, pydanticImports, datetimeImports, modelImports, exampleImports, null);
String typing = getPydanticType(param, typingImports, pydanticImports, datetimeImports, modelImports, exampleImports, postponedModelImports, postponedExampleImports, null);
List<String> fields = new ArrayList<>();
String firstField = "";
@@ -1020,7 +1033,7 @@ public class PythonClientCodegen extends AbstractPythonCodegen implements Codege
// update typing import for operation return type
if (!StringUtils.isEmpty(operation.returnType)) {
String typing = getPydanticType(operation.returnProperty, typingImports,
new TreeSet<>() /* skip pydantic import for return type */, datetimeImports, modelImports, exampleImports, null);
new TreeSet<>() /* skip pydantic import for return type */, datetimeImports, modelImports, exampleImports, postponedModelImports, postponedExampleImports, null);
}
// add import for code samples
@@ -1032,6 +1045,15 @@ public class PythonClientCodegen extends AbstractPythonCodegen implements Codege
}
operation.vendorExtensions.put("x-py-example-import", imports);
}
if (!postponedExampleImports.isEmpty()) {
List<String> imports = new ArrayList<>();
for (String exampleImport : postponedExampleImports) {
imports.add("from " + packageName + ".models." + underscore(exampleImport) + " import "
+ exampleImport);
}
operation.vendorExtensions.put("x-py-example-import", imports);
}
}
List<Map<String, String>> newImports = new ArrayList<>();
@@ -1066,6 +1088,14 @@ public class PythonClientCodegen extends AbstractPythonCodegen implements Codege
}
}
if (!postponedModelImports.isEmpty()) {
for (String modelImport : postponedModelImports) {
Map<String, String> item = new HashMap<>();
item.put("import", "from " + packageName + ".models." + underscore(modelImport) + " import " + modelImport);
newImports.add(item);
}
}
// reset imports with newImports
objs.setImports(newImports);
return objs;
@@ -1194,9 +1224,11 @@ public class PythonClientCodegen extends AbstractPythonCodegen implements Codege
TreeSet<String> pydanticImports = new TreeSet<>();
TreeSet<String> datetimeImports = new TreeSet<>();
TreeSet<String> modelImports = new TreeSet<>();
TreeSet<String> postponedModelImports = new TreeSet<>();
for (ModelMap m : objs.getModels()) {
TreeSet<String> exampleImports = new TreeSet<>();
TreeSet<String> postponedExampleImports = new TreeSet<>();
List<String> readOnlyFields = new ArrayList<>();
hasModelsToImport = false;
int property_count = 1;
@@ -1239,9 +1271,17 @@ public class PythonClientCodegen extends AbstractPythonCodegen implements Codege
codegenProperties = model.vars;
}
// if model_generic.mustache is used and support additionalProperties
if (model.oneOf.isEmpty() && model.anyOf.isEmpty()
&& !model.isEnum
&& !this.disallowAdditionalPropertiesIfNotPresent) {
typingImports.add("Dict");
typingImports.add("Any");
}
//loop through properties/schemas to set up typing, pydantic
for (CodegenProperty cp : codegenProperties) {
String typing = getPydanticType(cp, typingImports, pydanticImports, datetimeImports, modelImports, exampleImports, model.classname);
String typing = getPydanticType(cp, typingImports, pydanticImports, datetimeImports, modelImports, exampleImports, postponedModelImports, postponedExampleImports, model.classname);
List<String> fields = new ArrayList<>();
String firstField = "";
@@ -1314,13 +1354,11 @@ public class PythonClientCodegen extends AbstractPythonCodegen implements Codege
}
}
if (!model.isEnum) {
pydanticImports.add("BaseModel");
}
// add parent model to import
if (!StringUtils.isEmpty(model.parent)) {
modelImports.add(model.parent);
} else if (!model.isEnum) {
pydanticImports.add("BaseModel");
}
// set enum type in extensions and update `name` in enumVars
@@ -1356,6 +1394,20 @@ public class PythonClientCodegen extends AbstractPythonCodegen implements Codege
model.getVendorExtensions().putIfAbsent("x-py-model-imports", modelsToImport);
}
if (!postponedModelImports.isEmpty()) {
Set<String> modelsToImport = new TreeSet<>();
for (String modelImport : postponedModelImports) {
if (modelImport.equals(model.classname)) {
// skip self import
continue;
}
modelsToImport.add("from " + packageName + ".models." + underscore(modelImport) + " import " + modelImport);
}
model.getVendorExtensions().putIfAbsent("x-py-postponed-model-imports", modelsToImport);
}
}
return objs;

View File

@@ -159,15 +159,15 @@ public class ScalaAkkaClientCodegen extends AbstractScalaCodegen implements Code
if (additionalProperties.containsKey("mainPackage")) {
setMainPackage((String) additionalProperties.get("mainPackage"));
additionalProperties.replace("configKeyPath", this.configKeyPath);
if (!additionalProperties.containsKey(CodegenConstants.API_PACKAGE)){
if (!additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) {
apiPackage = mainPackage + ".api";
additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage);
}
if (!additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)){
if (!additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) {
modelPackage = mainPackage + ".model";
additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage);
}
if (!additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)){
if (!additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) {
invokerPackage = mainPackage + ".core";
}
}
@@ -262,6 +262,11 @@ public class ScalaAkkaClientCodegen extends AbstractScalaCodegen implements Code
@Override
public String toParamName(String name) {
// obtain the name from parameterNameMapping directly if provided
if (parameterNameMapping.containsKey(name)) {
return parameterNameMapping.get(name);
}
return formatIdentifier(name, false);
}

View File

@@ -133,6 +133,11 @@ public class ScalaLagomServerCodegen extends AbstractScalaCodegen implements Cod
@Override
public String toParamName(String name) {
// obtain the name from parameterNameMapping directly if provided
if (parameterNameMapping.containsKey(name)) {
return parameterNameMapping.get(name);
}
// should be the same as variable name
return toVarName(name);
}

View File

@@ -380,6 +380,11 @@ public class ScalaSttp4ClientCodegen extends AbstractScalaCodegen implements Cod
@Override
public String toParamName(String name) {
// obtain the name from parameterNameMapping directly if provided
if (parameterNameMapping.containsKey(name)) {
return parameterNameMapping.get(name);
}
return formatIdentifier(name, false);
}

View File

@@ -398,6 +398,11 @@ public class ScalaSttpClientCodegen extends AbstractScalaCodegen implements Code
@Override
public String toParamName(String name) {
// obtain the name from parameterNameMapping directly if provided
if (parameterNameMapping.containsKey(name)) {
return parameterNameMapping.get(name);
}
return formatIdentifier(name, false);
}

View File

@@ -139,6 +139,11 @@ public class ScalazClientCodegen extends AbstractScalaCodegen implements Codegen
@Override
public String toParamName(String name) {
// obtain the name from parameterNameMapping directly if provided
if (parameterNameMapping.containsKey(name)) {
return parameterNameMapping.get(name);
}
// should be the same as variable name
return toVarName(name);
}

View File

@@ -290,7 +290,10 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("package.mustache", "", "package.json"));
supportingFiles.add(new SupportingFile("tsconfig.mustache", "", "tsconfig.json"));
supportingFiles.add(new SupportingFile("tsconfig.esm.mustache", "", "tsconfig.esm.json"));
// in case ECMAScript 6 is supported add another tsconfig for an ESM (ECMAScript Module)
if (supportsES6) {
supportingFiles.add(new SupportingFile("tsconfig.esm.mustache", "", "tsconfig.esm.json"));
}
}
@Override

View File

@@ -427,7 +427,9 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
supportingFiles.add(new SupportingFile("package.mustache", "", "package.json"));
supportingFiles.add(new SupportingFile("tsconfig.mustache", "", "tsconfig.json"));
// in case ECMAScript 6 is supported add another tsconfig for an ESM (ECMAScript Module)
supportingFiles.add(new SupportingFile("tsconfig.esm.mustache", "", "tsconfig.esm.json"));
if (supportsES6) {
supportingFiles.add(new SupportingFile("tsconfig.esm.mustache", "", "tsconfig.esm.json"));
}
supportingFiles.add(new SupportingFile("npmignore.mustache", "", ".npmignore"));
supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore"));
}

View File

@@ -1426,12 +1426,15 @@ public class ApiClient {
// prepare HTTP request body
RequestBody reqBody;
String contentType = headerParams.get("Content-Type");
String contentTypePure = contentType;
if (contentTypePure != null && contentTypePure.contains(";")) {
contentTypePure = contentType.substring(0, contentType.indexOf(";"));
}
if (!HttpMethod.permitsRequestBody(method)) {
reqBody = null;
} else if ("application/x-www-form-urlencoded".equals(contentType)) {
} else if ("application/x-www-form-urlencoded".equals(contentTypePure)) {
reqBody = buildRequestBodyFormEncoding(formParams);
} else if ("multipart/form-data".equals(contentType)) {
} else if ("multipart/form-data".equals(contentTypePure)) {
reqBody = buildRequestBodyMultipart(formParams);
} else if (body == null) {
if ("DELETE".equals(method)) {

View File

@@ -1,4 +1,4 @@
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
/**
* A container for additional, undeclared properties.
* This is a holder for any undeclared properties as specified with
@@ -43,4 +43,4 @@
}
return this.additionalProperties.get(key);
}
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}

View File

@@ -314,8 +314,8 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
}{{#hasVars}}
{{classname}} {{classVarName}} = ({{classname}}) o;
return {{#vars}}{{#vendorExtensions.x-is-jackson-optional-nullable}}equalsNullable(this.{{name}}, {{classVarName}}.{{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{#isByteArray}}Arrays{{/isByteArray}}{{^isByteArray}}Objects{{/isByteArray}}.equals(this.{{name}}, {{classVarName}}.{{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^-last}} &&
{{/-last}}{{/vars}}{{#isAdditionalPropertiesTrue}}&&
Objects.equals(this.additionalProperties, {{classVarName}}.additionalProperties){{/isAdditionalPropertiesTrue}}{{#parent}} &&
{{/-last}}{{/vars}}{{#isAdditionalPropertiesEnabled}}&&
Objects.equals(this.additionalProperties, {{classVarName}}.additionalProperties){{/isAdditionalPropertiesEnabled}}{{#parent}} &&
super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}}
return {{#parent}}super.equals(o){{/parent}}{{^parent}}true{{/parent}};{{/hasVars}}
{{/useReflectionEqualsHashCode}}
@@ -331,7 +331,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
return HashCodeBuilder.reflectionHashCode(this);
{{/useReflectionEqualsHashCode}}
{{^useReflectionEqualsHashCode}}
return Objects.hash({{#vars}}{{#vendorExtensions.x-is-jackson-optional-nullable}}hashCodeNullable({{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{^isByteArray}}{{name}}{{/isByteArray}}{{#isByteArray}}Arrays.hashCode({{name}}){{/isByteArray}}{{/vendorExtensions.x-is-jackson-optional-nullable}}{{^-last}}, {{/-last}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}}{{#isAdditionalPropertiesTrue}}{{#hasVars}}, {{/hasVars}}{{^hasVars}}{{#parent}}, {{/parent}}{{/hasVars}}additionalProperties{{/isAdditionalPropertiesTrue}});
return Objects.hash({{#vars}}{{#vendorExtensions.x-is-jackson-optional-nullable}}hashCodeNullable({{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{^isByteArray}}{{name}}{{/isByteArray}}{{#isByteArray}}Arrays.hashCode({{name}}){{/isByteArray}}{{/vendorExtensions.x-is-jackson-optional-nullable}}{{^-last}}, {{/-last}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}}{{#isAdditionalPropertiesEnabled}}{{#hasVars}}, {{/hasVars}}{{^hasVars}}{{#parent}}, {{/parent}}{{/hasVars}}additionalProperties{{/isAdditionalPropertiesEnabled}});
{{/useReflectionEqualsHashCode}}
}{{#vendorExtensions.x-jackson-optional-nullable-helpers}}
@@ -352,9 +352,9 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{#vars}}
sb.append(" {{name}}: ").append(toIndentedString({{name}})).append("\n");
{{/vars}}
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
sb.append("}");
return sb.toString();
}
@@ -460,7 +460,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
}
}
{{^hasChildren}}
{{^isAdditionalPropertiesTrue}}
{{^isAdditionalPropertiesEnabled}}
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
@@ -469,7 +469,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `{{classname}}` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
{{#requiredVars}}
{{#-first}}
@@ -589,7 +589,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
@Override
public void write(JsonWriter out, {{classname}} value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
obj.remove("additionalProperties");
// serialize additional properties
if (value.getAdditionalProperties() != null) {
@@ -607,7 +607,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
}
}
}
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
elementAdapter.write(out, obj);
}
@@ -615,7 +615,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
public {{classname}} read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
JsonObject jsonObj = jsonElement.getAsJsonObject();
// store additional fields in the deserialized instance
{{classname}} instance = thisAdapter.fromJsonTree(jsonObj);
@@ -638,10 +638,10 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
}
}
return instance;
{{/isAdditionalPropertiesTrue}}
{{^isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
{{^isAdditionalPropertiesEnabled}}
return thisAdapter.fromJsonTree(jsonElement);
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
}
}.nullSafe();

View File

@@ -97,15 +97,15 @@
/// Initializes a new instance of the <see cref="{{classname}}" /> class.
/// </summary>
[JsonConstructorAttribute]
{{^isAdditionalPropertiesTrue}}
{{^isAdditionalPropertiesEnabled}}
protected {{classname}}() { }
{{/isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
{{#isAdditionalPropertiesEnabled}}
protected {{classname}}()
{
this.AdditionalProperties = new Dictionary<string, object>();
}
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
{{/hasOnlyReadOnly}}
{{/hasRequired}}
/// <summary>
@@ -170,9 +170,9 @@
{{/isReadOnly}}
{{/isInherited}}
{{/vars}}
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
this.AdditionalProperties = new Dictionary<string, object>();
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
}
{{#vars}}
@@ -250,14 +250,14 @@
{{/isEnum}}
{{/isInherited}}
{{/vars}}
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public IDictionary<string, object> AdditionalProperties { get; set; }
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
/// <summary>
/// Returns the string presentation of the object
/// </summary>
@@ -272,9 +272,9 @@
{{#vars}}
sb.Append(" {{name}}: ").Append({{name}}).Append("\n");
{{/vars}}
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
sb.Append("}\n");
return sb.ToString();
}
@@ -333,10 +333,10 @@
{{^vendorExtensions.x-is-value-type}}this.{{name}} != null &&
input.{{name}} != null &&
{{/vendorExtensions.x-is-value-type}}this.{{name}}.SequenceEqual(input.{{name}})
){{^-last}} && {{/-last}}{{/isContainer}}{{/vars}}{{^vars}}{{#parent}}base.Equals(input){{/parent}}{{^parent}}false{{/parent}}{{/vars}}{{^isAdditionalPropertiesTrue}};{{/isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesTrue}}
){{^-last}} && {{/-last}}{{/isContainer}}{{/vars}}{{^vars}}{{#parent}}base.Equals(input){{/parent}}{{^parent}}false{{/parent}}{{/vars}}{{^isAdditionalPropertiesEnabled}};{{/isAdditionalPropertiesEnabled}}
{{#isAdditionalPropertiesEnabled}}
&& (this.AdditionalProperties.Count == input.AdditionalProperties.Count && !this.AdditionalProperties.Except(input.AdditionalProperties).Any());
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
{{/useCompareNetObjects}}
}
@@ -363,10 +363,10 @@
hashCode = hashCode * 59 + this.{{name}}.GetHashCode();
{{/vendorExtensions.x-is-value-type}}
{{/vars}}
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
if (this.AdditionalProperties != null)
hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode();
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
return hashCode;
}
}

View File

@@ -168,7 +168,7 @@
{{/isInherited}}
{{/isEnum}}
{{/allVars}}
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
{{^parentModel}}
/// <summary>
/// Gets or Sets additional properties
@@ -177,7 +177,7 @@
public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>();
{{/parentModel}}
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
/// <summary>
/// Returns the string presentation of the object
/// </summary>
@@ -192,11 +192,11 @@
{{#vars}}
sb.Append(" {{name}}: ").Append({{name}}).Append("\n");
{{/vars}}
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
{{^parentModel}}
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
{{/parentModel}}
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
sb.Append("}\n");
return sb.ToString();
}
@@ -249,12 +249,12 @@
{{^vendorExtensions.x-is-value-type}}{{name}} != null &&
input.{{name}} != null &&
{{/vendorExtensions.x-is-value-type}}{{name}}.SequenceEqual(input.{{name}})
){{^-last}} && {{/-last}}{{/isContainer}}{{/isInherited}}{{/readOnlyVars}}{{^readOnlyVars}}{{#parent}}base.Equals(input){{/parent}}{{^parent}}false{{/parent}}{{/readOnlyVars}}{{^isAdditionalPropertiesTrue}};{{/isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesTrue}}
){{^-last}} && {{/-last}}{{/isContainer}}{{/isInherited}}{{/readOnlyVars}}{{^readOnlyVars}}{{#parent}}base.Equals(input){{/parent}}{{^parent}}false{{/parent}}{{/readOnlyVars}}{{^isAdditionalPropertiesEnabled}};{{/isAdditionalPropertiesEnabled}}
{{#isAdditionalPropertiesEnabled}}
{{^parentModel}}
&& (AdditionalProperties.Count == input.AdditionalProperties.Count && !AdditionalProperties.Except(input.AdditionalProperties).Any());
{{/parentModel}}
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
{{/useCompareNetObjects}}
}
@@ -284,11 +284,11 @@
hashCode = (hashCode * 59) + {{name}}.GetHashCode();
{{/isNullable}}
{{/readOnlyVars}}
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
{{^parentModel}}
hashCode = (hashCode * 59) + AdditionalProperties.GetHashCode();
{{/parentModel}}
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
return hashCode;
}

View File

@@ -114,15 +114,15 @@
/// Initializes a new instance of the <see cref="{{classname}}" /> class.
/// </summary>
[JsonConstructorAttribute]
{{^isAdditionalPropertiesTrue}}
{{^isAdditionalPropertiesEnabled}}
protected {{classname}}() { }
{{/isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
{{#isAdditionalPropertiesEnabled}}
protected {{classname}}()
{
this.AdditionalProperties = new Dictionary<string, object>();
}
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
{{/hasOnlyReadOnly}}
{{/hasRequired}}
/// <summary>
@@ -201,9 +201,9 @@
{{/isReadOnly}}
{{/isInherited}}
{{/vars}}
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
this.AdditionalProperties = new Dictionary<string, object>();
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
}
{{#vars}}
@@ -290,14 +290,14 @@
{{/isEnum}}
{{/isInherited}}
{{/vars}}
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public IDictionary<string, object> AdditionalProperties { get; set; }
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
/// <summary>
/// Returns the string presentation of the object
/// </summary>
@@ -312,9 +312,9 @@
{{#vars}}
sb.Append(" {{name}}: ").Append({{name}}).Append("\n");
{{/vars}}
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
sb.Append("}\n");
return sb.ToString();
}
@@ -375,10 +375,10 @@
{{^vendorExtensions.x-is-value-type}}this.{{name}} != null &&
input.{{name}} != null &&
{{/vendorExtensions.x-is-value-type}}this.{{name}}.SequenceEqual(input.{{name}})
){{^-last}} && {{/-last}}{{/isContainer}}{{/vars}}{{^vars}}{{#parent}}base.Equals(input){{/parent}}{{^parent}}false{{/parent}}{{/vars}}{{^isAdditionalPropertiesTrue}};{{/isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesTrue}}
){{^-last}} && {{/-last}}{{/isContainer}}{{/vars}}{{^vars}}{{#parent}}base.Equals(input){{/parent}}{{^parent}}false{{/parent}}{{/vars}}{{^isAdditionalPropertiesEnabled}};{{/isAdditionalPropertiesEnabled}}
{{#isAdditionalPropertiesEnabled}}
&& (this.AdditionalProperties.Count == input.AdditionalProperties.Count && !this.AdditionalProperties.Except(input.AdditionalProperties).Any());
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
{{/useCompareNetObjects}}
}
@@ -407,12 +407,12 @@
hashCode = (hashCode * 59) + this.{{name}}.GetHashCode();
{{/vendorExtensions.x-is-value-type}}
{{/vars}}
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
if (this.AdditionalProperties != null)
{
hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode();
}
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
return hashCode;
}
}

View File

@@ -400,9 +400,9 @@ func (c *{{classname}}Controller) {{nickname}}(w http.ResponseWriter, r *http.Re
{{#isBodyParam}}
{{paramName}}Param := {{dataType}}{}
d := json.NewDecoder(r.Body)
{{^isAdditionalPropertiesTrue}}
{{^isAdditionalPropertiesEnabled}}
d.DisallowUnknownFields()
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
if err := d.Decode(&{{paramName}}Param); err != nil {
c.errorHandler(w, r, &ParsingError{Err: err}, nil)
return

View File

@@ -609,7 +609,11 @@ func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err e
} else if jsonCheck.MatchString(contentType) {
err = json.NewEncoder(bodyBuf).Encode(body)
} else if xmlCheck.MatchString(contentType) {
err = xml.NewEncoder(bodyBuf).Encode(body)
var bs []byte
bs, err = xml.Marshal(body)
if err == nil {
bodyBuf.Write(bs)
}
}
if err != nil {

View File

@@ -24,15 +24,15 @@ type {{classname}} struct {
{{/deprecated}}
{{name}} {{^required}}{{^isNullable}}{{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{/isNullable}}{{/required}}{{{dataType}}} `json:"{{baseName}}{{^required}},omitempty{{/required}}"{{#withXml}} xml:"{{baseName}}{{#isXmlAttribute}},attr{{/isXmlAttribute}}"{{/withXml}}{{#vendorExtensions.x-go-custom-tag}} {{{.}}}{{/vendorExtensions.x-go-custom-tag}}`
{{/vars}}
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
AdditionalProperties map[string]interface{}
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
}
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
type _{{{classname}}} {{{classname}}}
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
// New{{classname}} instantiates a new {{classname}} object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
@@ -321,17 +321,17 @@ func (o {{classname}}) ToMap() (map[string]interface{}, error) {
{{/required}}
{{/isNullable}}
{{/vars}}
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
for key, value := range o.AdditionalProperties {
toSerialize[key] = value
}
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
return toSerialize, nil
}
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
func (o *{{{classname}}}) UnmarshalJSON(bytes []byte) (err error) {
{{#parent}}
{{^isMap}}
@@ -440,7 +440,7 @@ func (o *{{{classname}}}) UnmarshalJSON(bytes []byte) (err error) {
{{/parent}}
}
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
{{#isArray}}
func (o *{{{classname}}}) UnmarshalJSON(bytes []byte) (err error) {
return json.Unmarshal(bytes, &o.Items)

View File

@@ -42,14 +42,14 @@ import Data.Function ((&))
} deriving (Show, Eq, Generic, Data)
instance FromJSON {{classname}} where
parseJSON = genericParseJSON (removeFieldLabelPrefix True "{{vendorExtensions.x-prefix}}")
parseJSON = genericParseJSON (removeFieldLabelPrefix "{{vendorExtensions.x-prefix}}")
instance ToJSON {{classname}} where
toJSON = genericToJSON (removeFieldLabelPrefix False "{{vendorExtensions.x-prefix}}")
toJSON = genericToJSON (removeFieldLabelPrefix "{{vendorExtensions.x-prefix}}")
{{#generateToSchema}}
instance ToSchema {{classname}} where
declareNamedSchema = Swagger.genericDeclareNamedSchema
$ Swagger.fromAesonOptions
$ removeFieldLabelPrefix False "{{vendorExtensions.x-prefix}}"
$ removeFieldLabelPrefix "{{vendorExtensions.x-prefix}}"
{{/generateToSchema}}
{{/parent}}
@@ -70,15 +70,11 @@ uncapitalize [] = []
-- | Remove a field label prefix during JSON parsing.
-- Also perform any replacements for special characters.
-- The @forParsing@ parameter is to distinguish between the cases in which we're using this
-- to power a @FromJSON@ or a @ToJSON@ instance. In the first case we're parsing, and we want
-- to replace special characters with their quoted equivalents (because we cannot have special
-- chars in identifier names), while we want to do vice versa when sending data instead.
removeFieldLabelPrefix :: Bool -> String -> Options
removeFieldLabelPrefix forParsing prefix =
removeFieldLabelPrefix :: String -> Options
removeFieldLabelPrefix prefix =
defaultOptions
{ omitNothingFields = True
, fieldLabelModifier = uncapitalize . fromMaybe (error ("did not find prefix " ++ prefix)) . stripPrefix prefix . replaceSpecialChars
, fieldLabelModifier = uncapitalize . replaceSpecialChars . fromMaybe (error ("did not find prefix " ++ prefix)) . stripPrefix prefix
}
where
replaceSpecialChars field = foldl (&) field (map mkCharReplacement specialChars)
@@ -86,8 +82,4 @@ removeFieldLabelPrefix forParsing prefix =
[ {{#specialCharReplacements}}("{{&char}}", "{{&replacement}}"){{^-last}}
, {{/-last}}{{/specialCharReplacements}}
]
mkCharReplacement (replaceStr, searchStr) = T.unpack . replacer (T.pack searchStr) (T.pack replaceStr) . T.pack
replacer =
if forParsing
then flip T.replace
else T.replace
mkCharReplacement (replaceStr, searchStr) = T.unpack . T.replace (T.pack searchStr) (T.pack replaceStr) . T.pack

View File

@@ -36,9 +36,9 @@ import Data.Function ((&))
} deriving (Show, Eq, Generic)
instance FromJSON {{classname}} where
parseJSON = genericParseJSON (removeFieldLabelPrefix True "{{vendorExtensions.x-prefix}}")
parseJSON = genericParseJSON (removeFieldLabelPrefix "{{vendorExtensions.x-prefix}}")
instance ToJSON {{classname}} where
toJSON = genericToJSON (removeFieldLabelPrefix False "{{vendorExtensions.x-prefix}}")
toJSON = genericToJSON (removeFieldLabelPrefix "{{vendorExtensions.x-prefix}}")
{{/parent}}
{{#parent}}
@@ -58,15 +58,11 @@ uncapitalize [] = []
-- | Remove a field label prefix during JSON parsing.
-- Also perform any replacements for special characters.
-- The @forParsing@ parameter is to distinguish between the cases in which we're using this
-- to power a @FromJSON@ or a @ToJSON@ instance. In the first case we're parsing, and we want
-- to replace special characters with their quoted equivalents (because we cannot have special
-- chars in identifier names), while we want to do vice versa when sending data instead.
removeFieldLabelPrefix :: Bool -> String -> Options
removeFieldLabelPrefix forParsing prefix =
removeFieldLabelPrefix :: String -> Options
removeFieldLabelPrefix prefix =
defaultOptions
{ omitNothingFields = True
, fieldLabelModifier = uncapitalize . fromMaybe (error ("did not find prefix " ++ prefix)) . stripPrefix prefix . replaceSpecialChars
, fieldLabelModifier = uncapitalize . replaceSpecialChars . fromMaybe (error ("did not find prefix " ++ prefix)) . stripPrefix prefix
}
where
replaceSpecialChars field = foldl (&) field (map mkCharReplacement specialChars)
@@ -74,8 +70,4 @@ removeFieldLabelPrefix forParsing prefix =
[ {{#specialCharReplacements}}("{{&char}}", "{{&replacement}}"){{^-last}}
, {{/-last}}{{/specialCharReplacements}}
]
mkCharReplacement (replaceStr, searchStr) = T.unpack . replacer (T.pack searchStr) (T.pack replaceStr) . T.pack
replacer =
if forParsing
then flip T.replace
else T.replace
mkCharReplacement (replaceStr, searchStr) = T.unpack . T.replace (T.pack searchStr) (T.pack replaceStr) . T.pack

View File

@@ -223,24 +223,24 @@ function ConvertFrom-{{{apiNamePrefix}}}JsonTo{{{classname}}} {
$PSBoundParameters | Out-DebugParameter | Write-Debug
$JsonParameters = ConvertFrom-Json -InputObject $Json
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
${{{apiNamePrefix}}}{{{classname}}}AdditionalProperties = @{}
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
# check if Json contains properties not defined in {{{apiNamePrefix}}}{{{classname}}}
$AllProperties = ({{#allVars}}"{{{baseName}}}"{{^-last}}, {{/-last}}{{/allVars}})
foreach ($name in $JsonParameters.PsObject.Properties.Name) {
{{^isAdditionalPropertiesTrue}}
{{^isAdditionalPropertiesEnabled}}
if (!($AllProperties.Contains($name))) {
throw "Error! JSON key '$name' not found in the properties: $($AllProperties)"
}
{{/isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
{{#isAdditionalPropertiesEnabled}}
# store undefined properties in additionalProperties
if (!($AllProperties.Contains($name))) {
${{{apiNamePrefix}}}{{{classname}}}AdditionalProperties[$name] = $JsonParameters.PSobject.Properties[$name].value
}
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
}
{{#requiredVars}}
@@ -271,9 +271,9 @@ function ConvertFrom-{{{apiNamePrefix}}}JsonTo{{{classname}}} {
"<<baseName>>" = ${<<name>>}
<</allVars>>
<<={{ }}=>>
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
"AdditionalProperties" = ${{{apiNamePrefix}}}{{{classname}}}AdditionalProperties
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
}
return $PSO

View File

@@ -29,3 +29,10 @@ from pprint import pprint
except Exception as e:
print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e)
```
{{#vendorExtensions.x-py-postponed-example-imports.size}}
{{#vendorExtensions.x-py-postponed-example-imports}}
{{{.}}}
{{/vendorExtensions.x-py-postponed-example-imports}}
{{classname}}.update_forward_refs()
{{/vendorExtensions.x-py-postponed-example-imports.size}}

View File

@@ -9,7 +9,7 @@ import re # noqa: F401
{{#vendorExtensions.x-py-model-imports}}
{{{.}}}
{{/vendorExtensions.x-py-model-imports}}
from typing import Any, List
from typing import Union, Any, List, TYPE_CHECKING
from pydantic import StrictStr, Field
{{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ANY_OF_SCHEMAS = [{{#anyOf}}"{{.}}"{{^-last}}, {{/-last}}{{/anyOf}}]
@@ -23,7 +23,10 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
# data type: {{{dataType}}}
{{vendorExtensions.x-py-name}}: {{{vendorExtensions.x-py-typing}}}
{{/composedSchemas.anyOf}}
actual_instance: Any
if TYPE_CHECKING:
actual_instance: Union[{{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}}]
else:
actual_instance: Any
any_of_schemas: List[str] = Field({{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ANY_OF_SCHEMAS, const=True)
class Config:
@@ -168,3 +171,10 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
def to_str(self) -> str:
"""Returns the string representation of the actual instance"""
return pprint.pformat(self.dict())
{{#vendorExtensions.x-py-postponed-model-imports.size}}
{{#vendorExtensions.x-py-postponed-model-imports}}
{{{.}}}
{{/vendorExtensions.x-py-postponed-model-imports}}
{{classname}}.update_forward_refs()
{{/vendorExtensions.x-py-postponed-model-imports.size}}

View File

@@ -22,9 +22,9 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
{{#vars}}
{{name}}: {{{vendorExtensions.x-py-typing}}}
{{/vars}}
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
additional_properties: Dict[str, Any] = {}
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
__properties = [{{#allVars}}"{{baseName}}"{{^-last}}, {{/-last}}{{/allVars}}]
{{#vars}}
{{#vendorExtensions.x-regex}}
@@ -130,9 +130,9 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
{{#vendorExtensions.x-py-readonly}}
"{{{.}}}",
{{/vendorExtensions.x-py-readonly}}
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
"additional_properties"
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
},
exclude_none=True)
{{#allVars}}
@@ -202,13 +202,13 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
{{/isPrimitiveType}}
{{/isContainer}}
{{/allVars}}
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
# puts key-value pairs in additional_properties in the top level
if self.additional_properties is not None:
for _key, _value in self.additional_properties.items():
_dict[_key] = _value
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
{{#allVars}}
{{#isNullable}}
# set to None if {{{name}}} (nullable) is None
@@ -244,13 +244,13 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
return {{{classname}}}.parse_obj(obj)
{{#disallowAdditionalPropertiesIfNotPresent}}
{{^isAdditionalPropertiesTrue}}
{{^isAdditionalPropertiesEnabled}}
# raise errors for additional fields in the input
for _key in obj.keys():
if _key not in cls.__properties:
raise ValueError("Error due to additional fields (not defined in {{classname}}) in the input: " + obj)
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
{{/disallowAdditionalPropertiesIfNotPresent}}
_obj = {{{classname}}}.parse_obj({
{{#allVars}}
@@ -348,12 +348,19 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
{{/isContainer}}
{{/allVars}}
})
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
# store additional fields in additional_properties
for _key in obj.keys():
if _key not in cls.__properties:
_obj.additional_properties[_key] = obj.get(_key)
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
return _obj
{{/hasChildren}}
{{#vendorExtensions.x-py-postponed-model-imports.size}}
{{#vendorExtensions.x-py-postponed-model-imports}}
{{{.}}}
{{/vendorExtensions.x-py-postponed-model-imports}}
{{classname}}.update_forward_refs()
{{/vendorExtensions.x-py-postponed-model-imports.size}}

View File

@@ -9,7 +9,7 @@ import re # noqa: F401
{{#vendorExtensions.x-py-model-imports}}
{{{.}}}
{{/vendorExtensions.x-py-model-imports}}
from typing import Any, List
from typing import Union, Any, List, TYPE_CHECKING
from pydantic import StrictStr, Field
{{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ONE_OF_SCHEMAS = [{{#oneOf}}"{{.}}"{{^-last}}, {{/-last}}{{/oneOf}}]
@@ -22,7 +22,10 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
# data type: {{{dataType}}}
{{vendorExtensions.x-py-name}}: {{{vendorExtensions.x-py-typing}}}
{{/composedSchemas.oneOf}}
actual_instance: Any
if TYPE_CHECKING:
actual_instance: Union[{{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}]
else:
actual_instance: Any
one_of_schemas: List[str] = Field({{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ONE_OF_SCHEMAS, const=True)
class Config:
@@ -194,3 +197,10 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
def to_str(self) -> str:
"""Returns the string representation of the actual instance"""
return pprint.pformat(self.dict())
{{#vendorExtensions.x-py-postponed-model-imports.size}}
{{#vendorExtensions.x-py-postponed-model-imports}}
{{{.}}}
{{/vendorExtensions.x-py-postponed-model-imports}}
{{classname}}.update_forward_refs()
{{/vendorExtensions.x-py-postponed-model-imports.size}}

View File

@@ -10,10 +10,10 @@
{{#vars}}
#' @field {{name}} {{#lambdaRdocEscape}}{{{description}}}{{/lambdaRdocEscape}} {{{vendorExtensions.x-r-doc-type}}}{{^required}} [optional]{{/required}}
{{/vars}}
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
#' @field _field_list a list of fields list(character)
#' @field additional_properties additional properties list(character) [optional]
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
@@ -26,10 +26,10 @@
{{#vars}}
`{{{name}}}` = NULL,
{{/vars}}
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
`_field_list` = c({{#vars}}"{{{name}}}"{{^-last}}, {{/-last}}{{/vars}}),
`additional_properties` = list(),
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
{{#discriminator}}
`_discriminator_property_name` = '{{discriminator.propertyName}}',
{{#discriminator.mappedModels}}{{#-first}}`_discriminator_mapping_name` = c({{/-first}}'{{mappingName}}' = '{{modelName}}'{{^-last}}, {{/-last}}{{#-last}}),{{/-last}}{{/discriminator.mappedModels}}
@@ -45,12 +45,12 @@
{{#optionalVars}}
#' @param {{name}} {{#lambdaRdocEscape}}{{{description}}}{{/lambdaRdocEscape}}{{^description}}{{{name}}}{{/description}}{{#defaultValue}}. Default to {{{.}}}.{{/defaultValue}}
{{/optionalVars}}
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
#' @param additional_properties additional properties (optional)
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
#' @param ... Other optional arguments.
#' @export
initialize = function({{#requiredVars}}`{{name}}`, {{/requiredVars}}{{#optionalVars}}`{{name}}` = {{{defaultValue}}}{{^defaultValue}}NULL{{/defaultValue}}, {{/optionalVars}}{{#isAdditionalPropertiesTrue}}additional_properties = NULL, {{/isAdditionalPropertiesTrue}}...) {
initialize = function({{#requiredVars}}`{{name}}`, {{/requiredVars}}{{#optionalVars}}`{{name}}` = {{{defaultValue}}}{{^defaultValue}}NULL{{/defaultValue}}, {{/optionalVars}}{{#isAdditionalPropertiesEnabled}}additional_properties = NULL, {{/isAdditionalPropertiesEnabled}}...) {
{{#requiredVars}}
if (!missing(`{{name}}`)) {
{{^isContainer}}
@@ -195,13 +195,13 @@
self$`{{name}}` <- `{{name}}`
}
{{/optionalVars}}
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
if (!is.null(additional_properties)) {
for (key in names(additional_properties)) {
self$additional_properties[[key]] <- additional_properties[[key]]
}
}
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
},
#' To JSON string
#'
@@ -243,12 +243,12 @@
{{/isContainer}}
}
{{/vars}}
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
for (key in names(self$additional_properties)) {
{{classname}}Object[[key]] <- self$additional_properties[[key]]
}
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
{{classname}}Object
},
#' Deserialize JSON string into an instance of {{{classname}}}
@@ -296,7 +296,7 @@
{{/isContainer}}
}
{{/vars}}
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
# process additional properties/fields in the payload
for (key in names(this_object)) {
if (!(key %in% self$`_field_list`)) { # json key not in list of fields
@@ -304,7 +304,7 @@
}
}
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
self
},
#' To JSON string
@@ -375,13 +375,13 @@
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]]
}
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA)))
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
},
#' Deserialize JSON string into an instance of {{{classname}}}
#'
@@ -425,7 +425,7 @@
{{/isPrimitiveType}}
{{/isContainer}}
{{/vars}}
{{#isAdditionalPropertiesTrue}}
{{#isAdditionalPropertiesEnabled}}
# process additional properties/fields in the payload
for (key in names(this_object)) {
if (!(key %in% self$`_field_list`)) { # json key not in list of fields
@@ -433,7 +433,7 @@
}
}
{{/isAdditionalPropertiesTrue}}
{{/isAdditionalPropertiesEnabled}}
self
},
#' Validate JSON input with respect to {{classname}}

View File

@@ -4,8 +4,8 @@
"experimentalDecorators": true,
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true,
"target": "es6",
"module": "es6",
"target": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}es5{{/supportsES6}}",
"module": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}commonjs{{/supportsES6}}",
"moduleResolution": "node",
"removeComments": true,
"sourceMap": true,

View File

@@ -10,7 +10,8 @@
"browser": "./dist/Api.js",
"typings": "./dist/Api.d.ts",
"dependencies": {
"isomorphic-fetch": "^2.2.1",
{{^supportsES6}}"core-js": "^2.4.0",
{{/supportsES6}}"isomorphic-fetch": "^2.2.1",
"aurelia-framework": "^1.3.1",
"aurelia-http-client": "^1.3.0"
},

View File

@@ -17,10 +17,12 @@
"license": "Unlicense",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
{{#supportsES6}}
"module": "./dist/esm/index.js",
"sideEffects": false,
{{/supportsES6}}
"scripts": {
"build": "tsc && tsc -p tsconfig.esm.json",
"build": "tsc {{#supportsES6}}&& tsc -p tsconfig.esm.json{{/supportsES6}}",
"prepare": "npm run build"
},
"dependencies": {

View File

@@ -1,7 +1,7 @@
{
"compilerOptions": {
"declaration": true,
"target": "ES6",
"target": "{{#supportsES6}}ES6{{/supportsES6}}{{^supportsES6}}ES5{{/supportsES6}}",
"module": "commonjs",
"noImplicitAny": true,
"outDir": "dist",

View File

@@ -13,10 +13,12 @@
{{^packageAsSourceOnlyLibrary}}
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
{{#supportsES6}}
"module": "./dist/esm/index.js",
"sideEffects": false,
{{/supportsES6}}
"scripts": {
"build": "tsc && tsc -p tsconfig.esm.json"{{^sagasAndRecords}},
"build": "tsc{{#supportsES6}} && tsc -p tsconfig.esm.json{{/supportsES6}}"{{^sagasAndRecords}},
"prepare": "npm run build"{{/sagasAndRecords}}
},
{{/packageAsSourceOnlyLibrary}}

View File

@@ -1,7 +1,7 @@
{
"compilerOptions": {
"declaration": true,
"target": "es6",
"target": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}es5{{/supportsES6}}",
{{#sagasAndRecords}}
"strict": true,
{{/sagasAndRecords}}

View File

@@ -4,8 +4,8 @@
"experimentalDecorators": true,
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true,
"target": "es6",
"module": "es6",
"target": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}es5{{/supportsES6}}",
"module": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}commonjs{{/supportsES6}}",
"moduleResolution": "node",
"removeComments": true,
"sourceMap": true,

View File

@@ -3,7 +3,7 @@
"module": "commonjs",
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true,
"target": "ES6",
"target": "{{#supportsES6}}ES6{{/supportsES6}}{{^supportsES6}}ES5{{/supportsES6}}",
"moduleResolution": "node",
"removeComments": true,
"sourceMap": true,

View File

@@ -5,7 +5,7 @@
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"target": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}es5{{/supportsES6}}",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",

View File

@@ -3,7 +3,7 @@
"module": "commonjs",
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true,
"target": "ES6",
"target": "{{#supportsES6}}ES6{{/supportsES6}}{{^supportsES6}}ES5{{/supportsES6}}",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"strict": true,

View File

@@ -1,7 +1,7 @@
{
"compilerOptions": {
"declaration": true,
"target": "es6",
"target": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}es5{{/supportsES6}}",
"module": "commonjs",
"moduleResolution": "node",
"outDir": "dist",

View File

@@ -1,7 +1,7 @@
{
"compilerOptions": {
"declaration": true,
"target": "es6",
"target": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}es5{{/supportsES6}}",
"module": "commonjs",
"moduleResolution": "node",
"outDir": "dist",

View File

@@ -25,6 +25,7 @@ import org.openapitools.codegen.languages.TypeScriptAngularClientCodegen;
import java.util.Map;
public class TypeScriptAngularClientOptionsProvider implements OptionsProvider {
public static final String SUPPORTS_ES6_VALUE = "false";
public static final String NULL_SAFE_ADDITIONAL_PROPS_VALUE = "false";
public static final String ENUM_NAME_SUFFIX = "Enum";
public static final String STRING_ENUMS_VALUE = "false";
@@ -66,6 +67,7 @@ public class TypeScriptAngularClientOptionsProvider implements OptionsProvider {
.put(CodegenConstants.ENUM_PROPERTY_NAMING, ENUM_PROPERTY_NAMING_VALUE)
.put(CodegenConstants.MODEL_PROPERTY_NAMING, MODEL_PROPERTY_NAMING_VALUE)
.put(CodegenConstants.PARAM_NAMING, PARAM_NAMING_VALUE)
.put(CodegenConstants.SUPPORTS_ES6, SUPPORTS_ES6_VALUE)
.put(AbstractTypeScriptClientCodegen.NULL_SAFE_ADDITIONAL_PROPS, NULL_SAFE_ADDITIONAL_PROPS_VALUE)
.put(AbstractTypeScriptClientCodegen.ENUM_PROPERTY_NAMING_REPLACE_SPECIAL_CHAR, ENUM_PROPERTY_NAMING_REPLACE_SPECIAL_CHAR_VALUE)
.put(CodegenConstants.ENUM_NAME_SUFFIX, ENUM_NAME_SUFFIX)

View File

@@ -24,6 +24,7 @@ import org.openapitools.codegen.languages.AbstractTypeScriptClientCodegen;
import java.util.Map;
public class TypeScriptAngularJsClientOptionsProvider implements OptionsProvider {
public static final String SUPPORTS_ES6_VALUE = "false";
public static final String NULL_SAFE_ADDITIONAL_PROPS_VALUE = "false";
public static final String ENUM_NAME_SUFFIX = "Enum";
public static final String SORT_PARAMS_VALUE = "false";
@@ -46,6 +47,7 @@ public class TypeScriptAngularJsClientOptionsProvider implements OptionsProvider
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>();
return builder.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE)
.put(CodegenConstants.SORT_MODEL_PROPERTIES_BY_REQUIRED_FLAG, SORT_MODEL_PROPERTIES_VALUE)
.put(CodegenConstants.SUPPORTS_ES6, SUPPORTS_ES6_VALUE)
.put(AbstractTypeScriptClientCodegen.NULL_SAFE_ADDITIONAL_PROPS, NULL_SAFE_ADDITIONAL_PROPS_VALUE)
.put(CodegenConstants.ENUM_NAME_SUFFIX, ENUM_NAME_SUFFIX)
.put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE)

View File

@@ -28,6 +28,7 @@ public class TypeScriptAureliaClientOptionsProvider implements OptionsProvider {
public static final String SORT_PARAMS_VALUE = "false";
public static final String SORT_MODEL_PROPERTIES_VALUE = "false";
public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true";
public static final Boolean SUPPORTS_ES6_VALUE = false;
public static final Boolean NULL_SAFE_ADDITIONAL_PROPS_VALUE = false;
public static final String ENUM_NAME_SUFFIX = "Enum";
public static final String ENUM_PROPERTY_NAMING_VALUE = "PascalCase";
@@ -54,6 +55,7 @@ public class TypeScriptAureliaClientOptionsProvider implements OptionsProvider {
.put(CodegenConstants.ENUM_PROPERTY_NAMING, ENUM_PROPERTY_NAMING_VALUE)
.put(CodegenConstants.MODEL_PROPERTY_NAMING, MODEL_PROPERTY_NAMING_VALUE)
.put(CodegenConstants.PARAM_NAMING, PARAM_NAMING_VALUE)
.put(CodegenConstants.SUPPORTS_ES6, String.valueOf(SUPPORTS_ES6_VALUE))
.put(AbstractTypeScriptClientCodegen.NULL_SAFE_ADDITIONAL_PROPS, String.valueOf(NULL_SAFE_ADDITIONAL_PROPS_VALUE))
.put(AbstractTypeScriptClientCodegen.ENUM_PROPERTY_NAMING_REPLACE_SPECIAL_CHAR, ENUM_PROPERTY_NAMING_REPLACE_SPECIAL_CHAR_VALUE)
.put(CodegenConstants.ENUM_NAME_SUFFIX, ENUM_NAME_SUFFIX)

View File

@@ -28,6 +28,7 @@ public class TypeScriptFetchClientOptionsProvider implements OptionsProvider {
public static final String SORT_PARAMS_VALUE = "false";
public static final String SORT_MODEL_PROPERTIES_VALUE = "false";
public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true";
public static final Boolean SUPPORTS_ES6_VALUE = false;
public static final String IMPORT_FILE_EXTENSION_VALUE = "";
public static final Boolean NULL_SAFE_ADDITIONAL_PROPS_VALUE = false;
public static final String ENUM_NAME_SUFFIX = "Enum";
@@ -59,6 +60,7 @@ public class TypeScriptFetchClientOptionsProvider implements OptionsProvider {
.put(CodegenConstants.ENUM_PROPERTY_NAMING, ENUM_PROPERTY_NAMING_VALUE)
.put(CodegenConstants.MODEL_PROPERTY_NAMING, MODEL_PROPERTY_NAMING_VALUE)
.put(CodegenConstants.PARAM_NAMING, PARAM_NAMING_VALUE)
.put(CodegenConstants.SUPPORTS_ES6, String.valueOf(SUPPORTS_ES6_VALUE))
.put(AbstractTypeScriptClientCodegen.NULL_SAFE_ADDITIONAL_PROPS, String.valueOf(NULL_SAFE_ADDITIONAL_PROPS_VALUE))
.put(AbstractTypeScriptClientCodegen.ENUM_PROPERTY_NAMING_REPLACE_SPECIAL_CHAR, ENUM_PROPERTY_NAMING_REPLACE_SPECIAL_CHAR_VALUE)
.put(CodegenConstants.ENUM_NAME_SUFFIX, ENUM_NAME_SUFFIX)

View File

@@ -24,6 +24,7 @@ import org.openapitools.codegen.languages.TypeScriptNestjsClientCodegen;
import java.util.Map;
public class TypeScriptNestjsClientOptionsProvider implements OptionsProvider {
public static final String SUPPORTS_ES6_VALUE = "false";
public static final String NULL_SAFE_ADDITIONAL_PROPS_VALUE = "false";
public static final String ENUM_NAME_SUFFIX = "Enum";
public static final String STRING_ENUMS_VALUE = "false";
@@ -62,6 +63,7 @@ public class TypeScriptNestjsClientOptionsProvider implements OptionsProvider {
.put(CodegenConstants.ENUM_PROPERTY_NAMING, ENUM_PROPERTY_NAMING_VALUE)
.put(CodegenConstants.MODEL_PROPERTY_NAMING, MODEL_PROPERTY_NAMING_VALUE)
.put(CodegenConstants.PARAM_NAMING, PARAM_NAMING_VALUE)
.put(CodegenConstants.SUPPORTS_ES6, SUPPORTS_ES6_VALUE)
.put(AbstractTypeScriptClientCodegen.NULL_SAFE_ADDITIONAL_PROPS, NULL_SAFE_ADDITIONAL_PROPS_VALUE)
.put(AbstractTypeScriptClientCodegen.ENUM_PROPERTY_NAMING_REPLACE_SPECIAL_CHAR, ENUM_PROPERTY_NAMING_REPLACE_SPECIAL_CHAR_VALUE)
.put(CodegenConstants.ENUM_NAME_SUFFIX, ENUM_NAME_SUFFIX)

View File

@@ -26,6 +26,7 @@ import java.util.Map;
public class TypeScriptNodeClientOptionsProvider implements OptionsProvider {
public static final String SUPPORTS_ES6_VALUE = "false";
public static final String NULL_SAFE_ADDITIONAL_PROPS_VALUE = "false";
public static final String ENUM_NAME_SUFFIX = "Enum";
public static final String SORT_PARAMS_VALUE = "false";
@@ -53,6 +54,7 @@ public class TypeScriptNodeClientOptionsProvider implements OptionsProvider {
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>();
return builder.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE)
.put(CodegenConstants.SORT_MODEL_PROPERTIES_BY_REQUIRED_FLAG, SORT_MODEL_PROPERTIES_VALUE)
.put(CodegenConstants.SUPPORTS_ES6, SUPPORTS_ES6_VALUE)
.put(AbstractTypeScriptClientCodegen.NULL_SAFE_ADDITIONAL_PROPS, NULL_SAFE_ADDITIONAL_PROPS_VALUE)
.put(AbstractTypeScriptClientCodegen.ENUM_PROPERTY_NAMING_REPLACE_SPECIAL_CHAR, ENUM_PROPERTY_NAMING_REPLACE_SPECIAL_CHAR_VALUE)
.put(CodegenConstants.ENUM_NAME_SUFFIX, ENUM_NAME_SUFFIX)

View File

@@ -46,6 +46,7 @@ public class TypeScriptAureliaClientOptionsTest extends AbstractOptionsTest {
verify(clientCodegen).setSortParamsByRequiredFlag(Boolean.valueOf(TypeScriptAureliaClientOptionsProvider.SORT_PARAMS_VALUE));
verify(clientCodegen).setModelPropertyNaming(TypeScriptAureliaClientOptionsProvider.MODEL_PROPERTY_NAMING_VALUE);
verify(clientCodegen).setParamNaming(TypeScriptAureliaClientOptionsProvider.PARAM_NAMING_VALUE);
verify(clientCodegen).setSupportsES6(TypeScriptAureliaClientOptionsProvider.SUPPORTS_ES6_VALUE);
verify(clientCodegen).setPrependFormOrBodyParameters(Boolean.valueOf(TypeScriptAureliaClientOptionsProvider.PREPEND_FORM_OR_BODY_PARAMETERS_VALUE));
verify(clientCodegen).setEnumUnknownDefaultCase(Boolean.parseBoolean(TypeScriptAureliaClientOptionsProvider.ENUM_UNKNOWN_DEFAULT_CASE_VALUE));
}

View File

@@ -89,6 +89,7 @@ public class TypeScriptAxiosClientCodegenTest {
codegen.additionalProperties().put("npmName", "@openapi/typescript-axios-petstore");
codegen.additionalProperties().put("snapshot", false);
codegen.additionalProperties().put("npmVersion", "1.0.0-SNAPSHOT");
codegen.additionalProperties().put("supportsES6", true);
codegen.processOpts();
@@ -96,4 +97,18 @@ public class TypeScriptAxiosClientCodegenTest {
assertThat(codegen.supportingFiles()).contains(new SupportingFile("tsconfig.esm.mustache", "", "tsconfig.esm.json"));
}
@Test
public void doesNotContainESMTSConfigFileInCaseOfES5AndNPM() {
TypeScriptAxiosClientCodegen codegen = new TypeScriptAxiosClientCodegen();
codegen.additionalProperties().put("npmName", "@openapi/typescript-axios-petstore");
codegen.additionalProperties().put("snapshot", false);
codegen.additionalProperties().put("npmVersion", "1.0.0-SNAPSHOT");
codegen.additionalProperties().put("supportsES6", false);
codegen.processOpts();
assertThat(codegen.supportingFiles()).contains(new SupportingFile("tsconfig.mustache", "", "tsconfig.json"));
assertThat(codegen.supportingFiles()).doesNotContain(new SupportingFile("tsconfig.esm.mustache", "", "tsconfig.esm.json"));
}
}

View File

@@ -149,10 +149,26 @@ public class TypeScriptFetchClientCodegenTest {
codegen.additionalProperties().put("npmName", "@openapi/typescript-fetch-petstore");
codegen.additionalProperties().put("snapshot", false);
codegen.additionalProperties().put("npmVersion", "1.0.0-SNAPSHOT");
codegen.additionalProperties().put("supportsES6", true);
codegen.processOpts();
assertThat(codegen.supportingFiles()).contains(new SupportingFile("tsconfig.mustache", "", "tsconfig.json"));
assertThat(codegen.supportingFiles()).contains(new SupportingFile("tsconfig.esm.mustache", "", "tsconfig.esm.json"));
}
@Test
public void doesNotContainESMTSConfigFileInCaseOfES5AndNPM() {
TypeScriptFetchClientCodegen codegen = new TypeScriptFetchClientCodegen();
codegen.additionalProperties().put("npmName", "@openapi/typescript-fetch-petstore");
codegen.additionalProperties().put("snapshot", false);
codegen.additionalProperties().put("npmVersion", "1.0.0-SNAPSHOT");
codegen.additionalProperties().put("supportsES6", false);
codegen.processOpts();
assertThat(codegen.supportingFiles()).contains(new SupportingFile("tsconfig.mustache", "", "tsconfig.json"));
assertThat(codegen.supportingFiles()).doesNotContain(new SupportingFile("tsconfig.esm.mustache", "", "tsconfig.esm.json"));
}
}

View File

@@ -46,6 +46,7 @@ public class TypeScriptFetchClientOptionsTest extends AbstractOptionsTest {
verify(clientCodegen).setSortParamsByRequiredFlag(Boolean.valueOf(TypeScriptFetchClientOptionsProvider.SORT_PARAMS_VALUE));
verify(clientCodegen).setModelPropertyNaming(TypeScriptFetchClientOptionsProvider.MODEL_PROPERTY_NAMING_VALUE);
verify(clientCodegen).setParamNaming(TypeScriptFetchClientOptionsProvider.PARAM_NAMING_VALUE);
verify(clientCodegen).setSupportsES6(TypeScriptFetchClientOptionsProvider.SUPPORTS_ES6_VALUE);
verify(clientCodegen).setImportFileExtension(TypeScriptFetchClientOptionsProvider.IMPORT_FILE_EXTENSION_VALUE);
verify(clientCodegen).setPrependFormOrBodyParameters(Boolean.valueOf(TypeScriptFetchClientOptionsProvider.PREPEND_FORM_OR_BODY_PARAMETERS_VALUE));
verify(clientCodegen).setWithoutRuntimeChecks(Boolean.valueOf(TypeScriptFetchClientOptionsProvider.WITHOUT_RUNTIME_CHECKS));

View File

@@ -45,6 +45,7 @@ public class TypeScriptAngularClientOptionsTest extends AbstractOptionsTest {
protected void verifyOptions() {
verify(clientCodegen).setSortParamsByRequiredFlag(Boolean.valueOf(TypeScriptAngularClientOptionsProvider.SORT_PARAMS_VALUE));
verify(clientCodegen).setModelPropertyNaming(TypeScriptAngularClientOptionsProvider.MODEL_PROPERTY_NAMING_VALUE);
verify(clientCodegen).setSupportsES6(Boolean.valueOf(TypeScriptAngularClientOptionsProvider.SUPPORTS_ES6_VALUE));
verify(clientCodegen).setStringEnums(Boolean.parseBoolean(TypeScriptAngularClientOptionsProvider.STRING_ENUMS_VALUE));
verify(clientCodegen).setPrependFormOrBodyParameters(Boolean.valueOf(TypeScriptAngularClientOptionsProvider.PREPEND_FORM_OR_BODY_PARAMETERS_VALUE));
verify(clientCodegen).setQueryParamObjectFormat(TypeScriptAngularClientOptionsProvider.QUERY_PARAM_OBJECT_FORMAT_VALUE);

View File

@@ -46,6 +46,7 @@ public class TypeScriptNestjsClientOptionsTest extends AbstractOptionsTest {
verify(clientCodegen).setSortParamsByRequiredFlag(Boolean.valueOf(TypeScriptNestjsClientOptionsProvider.SORT_PARAMS_VALUE));
verify(clientCodegen).setModelPropertyNaming(TypeScriptNestjsClientOptionsProvider.MODEL_PROPERTY_NAMING_VALUE);
verify(clientCodegen).setParamNaming(TypeScriptNestjsClientOptionsProvider.PARAM_NAMING_VALUE);
verify(clientCodegen).setSupportsES6(Boolean.valueOf(TypeScriptNestjsClientOptionsProvider.SUPPORTS_ES6_VALUE));
verify(clientCodegen).setStringEnums(Boolean.parseBoolean(TypeScriptNestjsClientOptionsProvider.STRING_ENUMS_VALUE));
verify(clientCodegen).setPrependFormOrBodyParameters(Boolean.valueOf(TypeScriptNestjsClientOptionsProvider.PREPEND_FORM_OR_BODY_PARAMETERS_VALUE));
verify(clientCodegen).setEnumUnknownDefaultCase(Boolean.parseBoolean(TypeScriptNestjsClientOptionsProvider.ENUM_UNKNOWN_DEFAULT_CASE_VALUE));

View File

@@ -46,6 +46,7 @@ public class TypeScriptNodeClientOptionsTest extends AbstractOptionsTest {
verify(clientCodegen).setSortParamsByRequiredFlag(Boolean.valueOf(TypeScriptNodeClientOptionsProvider.SORT_PARAMS_VALUE));
verify(clientCodegen).setModelPropertyNaming(TypeScriptNodeClientOptionsProvider.MODEL_PROPERTY_NAMING_VALUE);
verify(clientCodegen).setParamNaming(TypeScriptNodeClientOptionsProvider.PARAM_NAMING_VALUE);
verify(clientCodegen).setSupportsES6(Boolean.valueOf(TypeScriptNodeClientOptionsProvider.SUPPORTS_ES6_VALUE));
verify(clientCodegen).setPrependFormOrBodyParameters(Boolean.valueOf(TypeScriptNodeClientOptionsProvider.PREPEND_FORM_OR_BODY_PARAMETERS_VALUE));
verify(clientCodegen).setEnumUnknownDefaultCase(Boolean.parseBoolean(TypeScriptNodeClientOptionsProvider.ENUM_UNKNOWN_DEFAULT_CASE_VALUE));
}

View File

@@ -41,6 +41,7 @@ public class TypescriptNodeES5IntegrationTest extends AbstractIntegrationTest {
properties.put("npmName", "node-es6-test");
properties.put("npmVersion", "1.0.3");
properties.put("snapshot", "false");
properties.put("supportsES6", "false");
return properties;
}

View File

@@ -40,6 +40,7 @@ public class TypescriptNodeEnumIntegrationTest extends AbstractIntegrationTest {
properties.put("npmName", "node-es6-test");
properties.put("npmVersion", "1.0.3");
properties.put("snapshot", "false");
properties.put("supportsES6", "false");
return properties;
}

View File

@@ -0,0 +1,786 @@
openapi: 3.0.0
servers:
- url: 'http://petstore.swagger.io/v2'
info:
description: >-
This is a sample server Petstore server. For this sample, you can use the api key
`special-key` to test the authorization filters.
version: 1.0.0
title: OpenAPI Petstore
license:
name: Apache-2.0
url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
tags:
- name: pet
description: Everything about your Pets
- name: store
description: Access to Petstore orders
- name: user
description: Operations about user
paths:
/pet:
post:
tags:
- pet
summary: Add a new pet to the store
description: ''
operationId: addPet
responses:
'200':
description: successful operation
content:
application/xml:
schema:
$ref: '#/components/schemas/Pet'
application/json:
schema:
$ref: '#/components/schemas/Pet'
'405':
description: Invalid input
security:
- petstore_auth:
- 'write:pets'
- 'read:pets'
requestBody:
$ref: '#/components/requestBodies/Pet'
put:
tags:
- pet
summary: Update an existing pet
description: ''
operationId: updatePet
externalDocs:
url: "http://petstore.swagger.io/v2/doc/updatePet"
description: "API documentation for the updatePet operation"
responses:
'200':
description: successful operation
content:
application/xml:
schema:
$ref: '#/components/schemas/Pet'
application/json:
schema:
$ref: '#/components/schemas/Pet'
'400':
description: Invalid ID supplied
'404':
description: Pet not found
'405':
description: Validation exception
security:
- petstore_auth:
- 'write:pets'
- 'read:pets'
requestBody:
$ref: '#/components/requestBodies/Pet'
/pet/findByStatus:
get:
tags:
- pet
summary: Finds Pets by status
description: Multiple status values can be provided with comma separated strings
operationId: findPetsByStatus
parameters:
- name: status
in: query
description: Status values that need to be considered for filter
required: true
style: form
explode: false
deprecated: true
schema:
type: array
items:
type: string
enum:
- available
- pending
- sold
default: available
responses:
'200':
description: successful operation
content:
application/xml:
schema:
type: array
items:
$ref: '#/components/schemas/Pet'
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Pet'
'400':
description: Invalid status value
security:
- petstore_auth:
- 'read:pets'
/pet/findByTags:
get:
tags:
- pet
summary: Finds Pets by tags
description: >-
Multiple tags can be provided with comma separated strings. Use tag1,
tag2, tag3 for testing.
operationId: findPetsByTags
parameters:
- name: tags
in: query
description: Tags to filter by
required: true
style: form
explode: false
schema:
type: array
items:
type: string
responses:
'200':
description: successful operation
content:
application/xml:
schema:
type: array
items:
$ref: '#/components/schemas/Pet'
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Pet'
'400':
description: Invalid tag value
security:
- petstore_auth:
- 'read:pets'
deprecated: true
'/pet/{petId}':
get:
tags:
- pet
summary: Find pet by ID
description: Returns a single pet
operationId: getPetById
parameters:
- name: petId
in: path
description: ID of pet to return
required: true
schema:
type: integer
format: int64
responses:
'200':
description: successful operation
content:
application/xml:
schema:
$ref: '#/components/schemas/Pet'
application/json:
schema:
$ref: '#/components/schemas/Pet'
'400':
description: Invalid ID supplied
'404':
description: Pet not found
security:
- api_key: []
post:
tags:
- pet
summary: Updates a pet in the store with form data
description: ''
operationId: updatePetWithForm
parameters:
- name: petId
in: path
description: ID of pet that needs to be updated
required: true
schema:
type: integer
format: int64
responses:
'405':
description: Invalid input
security:
- petstore_auth:
- 'write:pets'
- 'read:pets'
requestBody:
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
name:
description: Updated name of the pet
type: string
status:
description: Updated status of the pet
type: string
delete:
tags:
- pet
summary: Deletes a pet
description: ''
operationId: deletePet
parameters:
- name: api_key
in: header
required: false
schema:
type: string
- name: petId
in: path
description: Pet id to delete
required: true
schema:
type: integer
format: int64
responses:
'400':
description: Invalid pet value
security:
- petstore_auth:
- 'write:pets'
- 'read:pets'
'/pet/{petId}/uploadImage':
post:
tags:
- pet
summary: uploads an image
description: ''
operationId: uploadFile
parameters:
- name: petId
in: path
description: ID of pet to update
required: true
schema:
type: integer
format: int64
responses:
'200':
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
security:
- petstore_auth:
- 'write:pets'
- 'read:pets'
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
additionalMetadata:
description: Additional data to pass to server
type: string
file:
description: file to upload
type: string
format: binary
/store/inventory:
get:
tags:
- store
summary: Returns pet inventories by status
description: Returns a map of status codes to quantities
operationId: getInventory
responses:
'200':
description: successful operation
content:
application/json:
schema:
type: object
additionalProperties:
type: integer
format: int32
security:
- api_key: []
/store/order:
post:
tags:
- store
summary: Place an order for a pet
description: ''
operationId: placeOrder
responses:
'200':
description: successful operation
content:
application/xml:
schema:
$ref: '#/components/schemas/Order'
application/json:
schema:
$ref: '#/components/schemas/Order'
'400':
description: Invalid Order
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Order'
description: order placed for purchasing the pet
required: true
'/store/order/{orderId}':
get:
tags:
- store
summary: Find purchase order by ID
description: >-
For valid response try integer IDs with value <= 5 or > 10. Other values
will generate exceptions
operationId: getOrderById
parameters:
- name: orderId
in: path
description: ID of pet that needs to be fetched
required: true
schema:
type: integer
format: int64
minimum: 1
maximum: 5
responses:
'200':
description: successful operation
content:
application/xml:
schema:
$ref: '#/components/schemas/Order'
application/json:
schema:
$ref: '#/components/schemas/Order'
'400':
description: Invalid ID supplied
'404':
description: Order not found
delete:
tags:
- store
summary: Delete purchase order by ID
description: >-
For valid response try integer IDs with value < 1000. Anything above
1000 or nonintegers will generate API errors
operationId: deleteOrder
parameters:
- name: orderId
in: path
description: ID of the order that needs to be deleted
required: true
schema:
type: string
responses:
'400':
description: Invalid ID supplied
'404':
description: Order not found
/user:
post:
tags:
- user
summary: Create user
description: This can only be done by the logged in user.
operationId: createUser
responses:
default:
description: successful operation
security:
- api_key: []
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/User'
description: Created user object
required: true
/user/createWithArray:
post:
tags:
- user
summary: Creates list of users with given input array
description: ''
operationId: createUsersWithArrayInput
responses:
default:
description: successful operation
security:
- api_key: []
requestBody:
$ref: '#/components/requestBodies/UserArray'
/user/createWithList:
post:
tags:
- user
summary: Creates list of users with given input array
description: ''
operationId: createUsersWithListInput
responses:
default:
description: successful operation
security:
- api_key: []
requestBody:
$ref: '#/components/requestBodies/UserArray'
/user/login:
get:
tags:
- user
summary: Logs user into the system
description: ''
operationId: loginUser
parameters:
- name: username
in: query
description: The user name for login
required: true
schema:
type: string
pattern: '^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$'
- name: password
in: query
description: The password for login in clear text
required: true
schema:
type: string
responses:
'200':
description: successful operation
headers:
Set-Cookie:
description: >-
Cookie authentication key for use with the `api_key`
apiKey authentication.
schema:
type: string
example: AUTH_KEY=abcde12345; Path=/; HttpOnly
X-Rate-Limit:
description: calls per hour allowed by the user
schema:
type: integer
format: int32
X-Expires-After:
description: date in UTC when token expires
schema:
type: string
format: date-time
content:
application/xml:
schema:
type: string
application/json:
schema:
type: string
'400':
description: Invalid username/password supplied
/user/logout:
get:
tags:
- user
summary: Logs out current logged in user session
description: ''
operationId: logoutUser
responses:
default:
description: successful operation
security:
- api_key: []
'/user/{username}':
get:
tags:
- user
summary: Get user by user name
description: ''
operationId: getUserByName
parameters:
- name: username
in: path
description: The name that needs to be fetched. Use user1 for testing.
required: true
schema:
type: string
responses:
'200':
description: successful operation
content:
application/xml:
schema:
$ref: '#/components/schemas/User'
application/json:
schema:
$ref: '#/components/schemas/User'
'400':
description: Invalid username supplied
'404':
description: User not found
put:
tags:
- user
summary: Updated user
description: This can only be done by the logged in user.
operationId: updateUser
parameters:
- name: username
in: path
description: name that need to be deleted
required: true
schema:
type: string
responses:
'400':
description: Invalid user supplied
'404':
description: User not found
security:
- api_key: []
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/User'
description: Updated user object
required: true
delete:
tags:
- user
summary: Delete user
description: This can only be done by the logged in user.
operationId: deleteUser
parameters:
- name: username
in: path
description: The name that needs to be deleted
required: true
schema:
type: string
responses:
'400':
description: Invalid username supplied
'404':
description: User not found
security:
- api_key: []
/fake/parameter-name-mapping:
get:
tags:
- fake
summary: parameter name mapping test
operationId: getParameterNameMapping
parameters:
- name: _type
in: header
description: _type
required: true
schema:
type: integer
format: int64
- name: type
in: query
description: type
required: true
schema:
type: string
- name: type_
in: header
description: type_
required: true
schema:
type: string
- name: http_debug_option
in: query
description: http debug option (to test parameter naming option)
required: true
schema:
type: string
responses:
200:
description: OK
externalDocs:
description: Find out more about Swagger
url: 'http://swagger.io'
components:
requestBodies:
UserArray:
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/User'
description: List of user object
required: true
Pet:
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
application/xml:
schema:
$ref: '#/components/schemas/Pet'
description: Pet object that needs to be added to the store
required: true
securitySchemes:
petstore_auth:
type: oauth2
flows:
implicit:
authorizationUrl: 'http://petstore.swagger.io/api/oauth/dialog'
scopes:
'write:pets': modify pets in your account
'read:pets': read your pets
api_key:
type: apiKey
name: api_key
in: header
schemas:
Order:
title: Pet Order
description: An order for a pets from the pet store
type: object
properties:
id:
type: integer
format: int64
petId:
type: integer
format: int64
quantity:
type: integer
format: int32
shipDate:
type: string
format: date-time
status:
type: string
description: Order Status
enum:
- placed
- approved
- delivered
complete:
type: boolean
default: false
xml:
name: Order
Category:
title: Pet category
description: A category for a pet
type: object
properties:
id:
type: integer
format: int64
name:
type: string
pattern: '^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$'
xml:
name: Category
User:
title: a User
description: A User who is purchasing from the pet store
type: object
properties:
id:
type: integer
format: int64
username:
type: string
firstName:
type: string
lastName:
type: string
email:
type: string
password:
type: string
phone:
type: string
userStatus:
type: integer
format: int32
description: User Status
xml:
name: User
Tag:
title: Pet Tag
description: A tag for a pet
type: object
properties:
id:
type: integer
format: int64
name:
type: string
xml:
name: Tag
Pet:
title: a Pet
description: A pet for sale in the pet store
type: object
required:
- name
- photoUrls
properties:
id:
type: integer
format: int64
category:
$ref: '#/components/schemas/Category'
name:
type: string
example: doggie
photoUrls:
type: array
xml:
name: photoUrl
wrapped: true
items:
type: string
tags:
type: array
xml:
name: tag
wrapped: true
items:
$ref: '#/components/schemas/Tag'
status:
type: string
description: pet status in the store
deprecated: true
enum:
- available
- pending
- sold
xml:
name: Pet
ApiResponse:
title: An uploaded response
description: Describes the result of uploading an image resource
type: object
properties:
code:
type: integer
format: int32
type:
type: string
message:
type: string
PropertyNameMapping:
properties:
http_debug_operation:
type: string
_type:
type: string
type:
type: string
type_:
type: string

View File

@@ -1178,6 +1178,41 @@ paths:
responses:
'200':
description: OK
/fake/parameter-name-mapping:
get:
tags:
- fake
summary: parameter name mapping test
operationId: getParameterNameMapping
parameters:
- name: _type
in: header
description: _type
required: true
schema:
type: integer
format: int64
- name: type
in: query
description: type
required: true
schema:
type: string
- name: type_
in: header
description: type_
required: true
schema:
type: string
- name: http_debug_option
in: query
description: http debug option (to test parameter naming option)
required: true
schema:
type: string
responses:
200:
description: OK
servers:
- url: 'http://{server}.swagger.io:{port}/v2'
description: petstore server
@@ -2058,3 +2093,13 @@ components:
test:
type: string
format: date-time
PropertyNameMapping:
properties:
http_debug_operation:
type: string
_type:
type: string
type:
type: string
type_:
type: string

View File

@@ -0,0 +1,56 @@
openapi: 3.0.0
info:
description: To test name, parameter mapping options
version: 1.0.0
title: Dummy
license:
name: Apache-2.0
url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
paths:
/fake/parameter-name-mapping:
get:
tags:
- fake
summary: parameter name mapping test
operationId: getParameterNameMapping
parameters:
- name: _type
in: header
description: _type
required: true
schema:
type: integer
format: int64
- name: type
in: query
description: type
required: true
schema:
type: string
- name: type_
in: header
description: type_
required: true
schema:
type: string
- name: http_debug_option
in: query
description: http debug option (to test parameter naming option)
required: true
schema:
type: string
responses:
200:
description: OK
components:
schemas:
PropertyNameMapping:
properties:
http_debug_operation:
type: string
_type:
type: string
type:
type: string
type_:
type: string

View File

@@ -2238,3 +2238,24 @@ components:
type_:
type: string
type: object
ObjectToTestAdditionalProperties:
description: Minimal object
type: object
properties:
property:
description: Property
type: boolean
default: false
AdditionalPropertieObject:
type: object
properties:
name:
type: string
additionalProperties:
type: object
AdditionalPropertieAnyType:
type: object
properties:
name:
type: string
additionalProperties: {}

View File

@@ -1267,6 +1267,41 @@ paths:
responses:
200:
description: The instance started successfully
/fake/parameter-name-mapping:
get:
tags:
- fake
summary: parameter name mapping test
operationId: getParameterNameMapping
parameters:
- name: _type
in: header
description: _type
required: true
schema:
type: integer
format: int64
- name: type
in: query
description: type
required: true
schema:
type: string
- name: type_
in: header
description: type_
required: true
schema:
type: string
- name: http_debug_option
in: query
description: http debug option (to test parameter naming option)
required: true
schema:
type: string
responses:
200:
description: OK
servers:
- url: 'http://{server}.swagger.io:{port}/v2'
description: petstore server
@@ -2045,3 +2080,13 @@ components:
required:
- classname
additionalProperties: true
PropertyNameMapping:
properties:
http_debug_operation:
type: string
_type:
type: string
type:
type: string
type_:
type: string

View File

@@ -566,6 +566,41 @@ paths:
description: User not found
security:
- api_key: []
/fake/parameter-name-mapping:
get:
tags:
- fake
summary: parameter name mapping test
operationId: getParameterNameMapping
parameters:
- name: _type
in: header
description: _type
required: true
schema:
type: integer
format: int64
- name: type
in: query
description: type
required: true
schema:
type: string
- name: type_
in: header
description: type_
required: true
schema:
type: string
- name: http_debug_option
in: query
description: http debug option (to test parameter naming option)
required: true
schema:
type: string
responses:
200:
description: OK
externalDocs:
description: Find out more about Swagger
url: 'http://swagger.io'
@@ -758,3 +793,13 @@ components:
type: string
type: array
type: object
PropertyNameMapping:
properties:
http_debug_operation:
type: string
_type:
type: string
type:
type: string
type_:
type: string

View File

@@ -1166,12 +1166,15 @@ public class ApiClient {
// prepare HTTP request body
RequestBody reqBody;
String contentType = headerParams.get("Content-Type");
String contentTypePure = contentType;
if (contentTypePure != null && contentTypePure.contains(";")) {
contentTypePure = contentType.substring(0, contentType.indexOf(";"));
}
if (!HttpMethod.permitsRequestBody(method)) {
reqBody = null;
} else if ("application/x-www-form-urlencoded".equals(contentType)) {
} else if ("application/x-www-form-urlencoded".equals(contentTypePure)) {
reqBody = buildRequestBodyFormEncoding(formParams);
} else if ("multipart/form-data".equals(contentType)) {
} else if ("multipart/form-data".equals(contentTypePure)) {
reqBody = buildRequestBodyMultipart(formParams);
} else if (body == null) {
if ("DELETE".equals(method)) {

View File

@@ -51,6 +51,7 @@ with openapi_client.ApiClient(configuration) as api_client:
```
### Parameters
This endpoint does not need any parameter.
@@ -113,6 +114,7 @@ with openapi_client.ApiClient(configuration) as api_client:
```
### Parameters
Name | Type | Description | Notes
@@ -178,6 +180,7 @@ with openapi_client.ApiClient(configuration) as api_client:
```
### Parameters
Name | Type | Description | Notes
@@ -243,6 +246,7 @@ with openapi_client.ApiClient(configuration) as api_client:
```
### Parameters
Name | Type | Description | Notes
@@ -309,6 +313,7 @@ with openapi_client.ApiClient(configuration) as api_client:
```
### Parameters
Name | Type | Description | Notes
@@ -375,6 +380,7 @@ with openapi_client.ApiClient(configuration) as api_client:
```
### Parameters
Name | Type | Description | Notes
@@ -441,6 +447,7 @@ with openapi_client.ApiClient(configuration) as api_client:
```
### Parameters
Name | Type | Description | Notes

View File

@@ -48,6 +48,7 @@ with openapi_client.ApiClient(configuration) as api_client:
```
### Parameters
Name | Type | Description | Notes

View File

@@ -48,6 +48,7 @@ with openapi_client.ApiClient(configuration) as api_client:
```
### Parameters
Name | Type | Description | Notes

View File

@@ -47,6 +47,7 @@ with openapi_client.ApiClient(configuration) as api_client:
```
### Parameters
Name | Type | Description | Notes

Some files were not shown because too many files have changed in this diff Show More