diff --git a/docs/generators/javascript-flowtyped.md b/docs/generators/javascript-flowtyped.md index b0c81d51a4f..80c2ba07d75 100644 --- a/docs/generators/javascript-flowtyped.md +++ b/docs/generators/javascript-flowtyped.md @@ -26,6 +26,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |enumPropertyNamingReplaceSpecialChar|Set to true to replace '-' and '+' symbols with 'minus_' and 'plus_' in enum of type string| |false| |enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|
**false**
No changes to the enum's are made, this is the default option.
**true**
With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.
|false| |legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|
**true**
The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.
**false**
The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.
|true| +|licenseName|The name of the license| |Unlicense| |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name. Only change it if you provide your own run-time code for (de-)serialization of models| |original| |npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null| |npmRepository|Use this property to set an url your private npmRepo in the package.json| |null| diff --git a/docs/generators/typescript-angular.md b/docs/generators/typescript-angular.md index 16542b6a36d..999539372dd 100644 --- a/docs/generators/typescript-angular.md +++ b/docs/generators/typescript-angular.md @@ -29,6 +29,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|
**false**
No changes to the enum's are made, this is the default option.
**true**
With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.
|false| |fileNaming|Naming convention for the output files: 'camelCase', 'kebab-case'.| |camelCase| |legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|
**true**
The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.
**false**
The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.
|true| +|licenseName|The name of the license| |Unlicense| |modelFileSuffix|The suffix of the file of the generated model (model<suffix>.ts).| |null| |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name. Only change it if you provide your own run-time code for (de-)serialization of models| |original| |modelSuffix|The suffix of the generated model.| |null| diff --git a/docs/generators/typescript-aurelia.md b/docs/generators/typescript-aurelia.md index a4c3819c4dd..d5bf4e06d98 100644 --- a/docs/generators/typescript-aurelia.md +++ b/docs/generators/typescript-aurelia.md @@ -26,6 +26,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |enumPropertyNamingReplaceSpecialChar|Set to true to replace '-' and '+' symbols with 'minus_' and 'plus_' in enum of type string| |false| |enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|
**false**
No changes to the enum's are made, this is the default option.
**true**
With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.
|false| |legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|
**true**
The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.
**false**
The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.
|true| +|licenseName|The name of the license| |Unlicense| |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name. Only change it if you provide your own run-time code for (de-)serialization of models| |original| |npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null| |npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0| diff --git a/docs/generators/typescript-axios.md b/docs/generators/typescript-axios.md index f4a70222200..bc8f8fe0427 100644 --- a/docs/generators/typescript-axios.md +++ b/docs/generators/typescript-axios.md @@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |enumPropertyNamingReplaceSpecialChar|Set to true to replace '-' and '+' symbols with 'minus_' and 'plus_' in enum of type string| |false| |enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|
**false**
No changes to the enum's are made, this is the default option.
**true**
With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.
|false| |legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|
**true**
The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.
**false**
The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.
|true| +|licenseName|The name of the license| |Unlicense| |modelPackage|package for generated models| |null| |npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null| |npmRepository|Use this property to set an url of your private npmRepo in the package.json| |null| diff --git a/docs/generators/typescript-fetch.md b/docs/generators/typescript-fetch.md index 549bdac995f..c2fc7b0bec4 100644 --- a/docs/generators/typescript-fetch.md +++ b/docs/generators/typescript-fetch.md @@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |fileNaming|Naming convention for the output files: 'PascalCase', 'camelCase', 'kebab-case'.| |PascalCase| |importFileExtension|File extension to use with relative imports. Set it to '.js' or '.mjs' when using [ESM](https://nodejs.org/api/esm.html).| || |legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|
**true**
The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.
**false**
The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.
|true| +|licenseName|The name of the license| |null| |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase| |npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null| |npmRepository|Use this property to set an url your private npmRepo in the package.json| |null| diff --git a/docs/generators/typescript-inversify.md b/docs/generators/typescript-inversify.md index b38c0ff9afb..9daedb0707a 100644 --- a/docs/generators/typescript-inversify.md +++ b/docs/generators/typescript-inversify.md @@ -26,6 +26,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |enumPropertyNamingReplaceSpecialChar|Set to true to replace '-' and '+' symbols with 'minus_' and 'plus_' in enum of type string| |false| |enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|
**false**
No changes to the enum's are made, this is the default option.
**true**
With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.
|false| |legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|
**true**
The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.
**false**
The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.
|true| +|licenseName|The name of the license| |Unlicense| |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name. Only change it if you provide your own run-time code for (de-)serialization of models| |original| |npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null| |npmRepository|Use this property to set an url your private npmRepo in the package.json| |null| diff --git a/docs/generators/typescript-jquery.md b/docs/generators/typescript-jquery.md index 626ac5a920f..148d28e5f60 100644 --- a/docs/generators/typescript-jquery.md +++ b/docs/generators/typescript-jquery.md @@ -27,6 +27,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|
**false**
No changes to the enum's are made, this is the default option.
**true**
With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.
|false| |jqueryAlreadyImported|When using this in legacy app using mix of typescript and javascript, this will only declare jquery and not import it| |false| |legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|
**true**
The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.
**false**
The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.
|true| +|licenseName|The name of the license| |MIT| |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name. Only change it if you provide your own run-time code for (de-)serialization of models| |original| |npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null| |npmRepository|Use this property to set an url your private npmRepo in the package.json| |null| diff --git a/docs/generators/typescript-nestjs.md b/docs/generators/typescript-nestjs.md index 11748efb4ec..2055133b6b8 100644 --- a/docs/generators/typescript-nestjs.md +++ b/docs/generators/typescript-nestjs.md @@ -27,6 +27,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|
**false**
No changes to the enum's are made, this is the default option.
**true**
With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.
|false| |fileNaming|Naming convention for the output files: 'camelCase', 'kebab-case'.| |camelCase| |legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|
**true**
The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.
**false**
The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.
|true| +|licenseName|The name of the license| |Unlicense| |modelFileSuffix|The suffix of the file of the generated model (model<suffix>.ts).| |null| |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name. Only change it if you provide your own run-time code for (de-)serialization of models| |original| |modelSuffix|The suffix of the generated model.| |null| diff --git a/docs/generators/typescript-node.md b/docs/generators/typescript-node.md index f19a9f34e5a..00faa993cbe 100644 --- a/docs/generators/typescript-node.md +++ b/docs/generators/typescript-node.md @@ -26,6 +26,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |enumPropertyNamingReplaceSpecialChar|Set to true to replace '-' and '+' symbols with 'minus_' and 'plus_' in enum of type string| |false| |enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|
**false**
No changes to the enum's are made, this is the default option.
**true**
With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.
|false| |legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|
**true**
The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.
**false**
The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.
|true| +|licenseName|The name of the license| |Unlicense| |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase| |npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null| |npmRepository|Use this property to set an url your private npmRepo in the package.json| |null| diff --git a/docs/generators/typescript-redux-query.md b/docs/generators/typescript-redux-query.md index 0e0aa2ec3ce..9b7a130dc81 100644 --- a/docs/generators/typescript-redux-query.md +++ b/docs/generators/typescript-redux-query.md @@ -26,6 +26,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |enumPropertyNamingReplaceSpecialChar|Set to true to replace '-' and '+' symbols with 'minus_' and 'plus_' in enum of type string| |false| |enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|
**false**
No changes to the enum's are made, this is the default option.
**true**
With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.
|false| |legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|
**true**
The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.
**false**
The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.
|true| +|licenseName|The name of the license| |null| |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase| |npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null| |npmRepository|Use this property to set an url your private npmRepo in the package.json| |null| diff --git a/docs/generators/typescript-rxjs.md b/docs/generators/typescript-rxjs.md index b5cdf9fe8a7..61c23805c8c 100644 --- a/docs/generators/typescript-rxjs.md +++ b/docs/generators/typescript-rxjs.md @@ -26,6 +26,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |enumPropertyNamingReplaceSpecialChar|Set to true to replace '-' and '+' symbols with 'minus_' and 'plus_' in enum of type string| |false| |enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|
**false**
No changes to the enum's are made, this is the default option.
**true**
With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.
|false| |legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|
**true**
The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.
**false**
The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.
|true| +|licenseName|The name of the license| |null| |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name. Only change it if you provide your own run-time code for (de-)serialization of models| |original| |npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null| |npmRepository|Use this property to set an url your private npmRepo in the package.json| |null| diff --git a/docs/generators/typescript.md b/docs/generators/typescript.md index ed7612a0cea..d53ba13a6b8 100644 --- a/docs/generators/typescript.md +++ b/docs/generators/typescript.md @@ -29,6 +29,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |framework|Specify the framework which should be used in the client code.|
**fetch-api**
fetch-api
**jquery**
jquery
|fetch-api| |importFileExtension|File extension to use with relative imports. Set it to '.js' or '.mjs' when using [ESM](https://nodejs.org/api/esm.html). Defaults to '.ts' when 'platform' is set to 'deno'.| |null| |legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|
**true**
The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.
**false**
The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.
|true| +|licenseName|The name of the license| |Unlicense| |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase| |npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null| |npmRepository|Use this property to set an url your private npmRepo in the package.json| |null| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java index 753cd1b4110..c5c55fb357f 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java @@ -37,7 +37,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; -import java.io.IOException; import java.text.SimpleDateFormat; import java.util.*; import java.util.function.BiPredicate; @@ -236,6 +235,8 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp public static final String NULL_SAFE_ADDITIONAL_PROPS = "nullSafeAdditionalProps"; public static final String NULL_SAFE_ADDITIONAL_PROPS_DESC = "Set to make additional properties types declare that their indexer may return undefined"; + public static final String LICENSE_NAME_DEFAULT_VALUE = "Unlicense"; + // NOTE: SimpleDateFormat is not thread-safe and may not be static unless it is thread-local @SuppressWarnings("squid:S5164") protected static final ThreadLocal SNAPSHOT_SUFFIX_FORMAT = ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyyMMddHHmm", Locale.ROOT)); @@ -258,6 +259,9 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp protected String classEnumSeparator = "."; + @Getter() @Setter + protected String licenseName = getLicenseNameDefaultValue(); + public AbstractTypeScriptClientCodegen() { super(); @@ -370,6 +374,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp false)); this.cliOptions.add(new CliOption(NULL_SAFE_ADDITIONAL_PROPS, NULL_SAFE_ADDITIONAL_PROPS_DESC).defaultValue(String.valueOf(this.getNullSafeAdditionalProps()))); this.cliOptions.add(CliOption.newBoolean(ENUM_PROPERTY_NAMING_REPLACE_SPECIAL_CHAR, ENUM_PROPERTY_NAMING_REPLACE_SPECIAL_CHAR_DESC, false)); + cliOptions.add(new CliOption(CodegenConstants.LICENSE_NAME, CodegenConstants.LICENSE_NAME_DESC).defaultValue(this.licenseName)); } protected void supportModelPropertyNaming(MODEL_PROPERTY_NAMING_TYPE defaultModelPropertyNaming) { @@ -416,6 +421,10 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp if (additionalProperties.containsKey(NPM_NAME)) { this.setNpmName(additionalProperties.get(NPM_NAME).toString()); } + + if (additionalProperties.containsKey(CodegenConstants.LICENSE_NAME)) { + this.setLicenseName(additionalProperties.get(CodegenConstants.LICENSE_NAME).toString()); + } } @Override @@ -489,6 +498,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp } + additionalProperties.put(CodegenConstants.LICENSE_NAME, licenseName); } @Override @@ -1143,4 +1153,8 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.TYPESCRIPT; } + + protected String getLicenseNameDefaultValue() { + return LICENSE_NAME_DEFAULT_VALUE; + } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java index e299264517a..875c881a397 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java @@ -1605,4 +1605,9 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege return sb.toString(); } } + + @Override + protected String getLicenseNameDefaultValue() { + return null; + } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptJqueryClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptJqueryClientCodegen.java index b2ec4d7a542..03544af573e 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptJqueryClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptJqueryClientCodegen.java @@ -36,6 +36,7 @@ public class TypeScriptJqueryClientCodegen extends AbstractTypeScriptClientCodeg public static final String NPM_REPOSITORY = "npmRepository"; public static final String JQUERY_ALREADY_IMPORTED = "jqueryAlreadyImported"; + public static final String LICENSE_NAME_DEFAULT_VALUE = "MIT"; @Getter @Setter protected String npmRepository = null; @@ -159,4 +160,9 @@ public class TypeScriptJqueryClientCodegen extends AbstractTypeScriptClientCodeg String indexPackage = modelPackage.substring(0, Math.max(0, modelPackage.lastIndexOf('.'))); return indexPackage.replace('.', File.separatorChar); } + + @Override + protected String getLicenseNameDefaultValue() { + return LICENSE_NAME_DEFAULT_VALUE; + } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptReduxQueryClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptReduxQueryClientCodegen.java index 81ac377f9b1..1b78a1cc4eb 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptReduxQueryClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptReduxQueryClientCodegen.java @@ -45,7 +45,6 @@ public class TypeScriptReduxQueryClientCodegen extends AbstractTypeScriptClientC protected boolean addedApiIndex = false; protected boolean addedModelIndex = false; - public TypeScriptReduxQueryClientCodegen() { super(); @@ -283,4 +282,9 @@ public class TypeScriptReduxQueryClientCodegen extends AbstractTypeScriptClientC private void setUseSingleRequestParameter(boolean useSingleRequestParameter) { this.useSingleRequestParameter = useSingleRequestParameter; } + + @Override + protected String getLicenseNameDefaultValue() { + return null; + } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptRxjsClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptRxjsClientCodegen.java index fb51165d000..b06ca5e10ca 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptRxjsClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptRxjsClientCodegen.java @@ -421,4 +421,9 @@ public class TypeScriptRxjsClientCodegen extends AbstractTypeScriptClientCodegen // import everything (including child schema of a composed schema) addImport(model, modelName); } + + @Override + protected String getLicenseNameDefaultValue() { + return null; + } } diff --git a/modules/openapi-generator/src/main/resources/typescript-angular/package.mustache b/modules/openapi-generator/src/main/resources/typescript-angular/package.mustache index af4bf5fdfba..a55fa3c3f5d 100644 --- a/modules/openapi-generator/src/main/resources/typescript-angular/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-angular/package.mustache @@ -11,7 +11,7 @@ "openapi-client", "openapi-generator" ], - "license": "Unlicense", + "license": "{{licenseName}}", "scripts": { "build": "ng-packagr -p ng-package.json" }, diff --git a/modules/openapi-generator/src/main/resources/typescript-aurelia/package.json.mustache b/modules/openapi-generator/src/main/resources/typescript-aurelia/package.json.mustache index c6c12b4bf20..21e05072946 100644 --- a/modules/openapi-generator/src/main/resources/typescript-aurelia/package.json.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-aurelia/package.json.mustache @@ -5,7 +5,7 @@ "type": "git", "url": "https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}.git" }, - "license": "Unlicense", + "license": "{{licenseName}}", "main": "./dist/Api.js", "browser": "./dist/Api.js", "typings": "./dist/Api.d.ts", diff --git a/modules/openapi-generator/src/main/resources/typescript-axios/package.mustache b/modules/openapi-generator/src/main/resources/typescript-axios/package.mustache index 57504af7415..f05b33ed1ee 100644 --- a/modules/openapi-generator/src/main/resources/typescript-axios/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-axios/package.mustache @@ -14,7 +14,7 @@ "openapi-generator", "{{npmName}}" ], - "license": "Unlicense", + "license": "{{licenseName}}", "main": "./dist/index.js", "typings": "./dist/index.d.ts", {{#supportsES6}} diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/package.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/package.mustache index ebb742fdb78..17092240239 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/package.mustache @@ -7,6 +7,9 @@ "type": "git", "url": "https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}.git" }, +{{#licenseName}} + "license": "{{licenseName}}", +{{/licenseName}} {{#packageAsSourceOnlyLibrary}} "main": "./index.ts", {{/packageAsSourceOnlyLibrary}} diff --git a/modules/openapi-generator/src/main/resources/typescript-inversify/package.mustache b/modules/openapi-generator/src/main/resources/typescript-inversify/package.mustache index 18ee1a7e8a2..df736bea934 100644 --- a/modules/openapi-generator/src/main/resources/typescript-inversify/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-inversify/package.mustache @@ -11,7 +11,7 @@ "openapi-client", "openapi-generator" ], - "license": "Unlicense", + "license": "{{licenseName}}", "main": "dist/index.js", "typings": "dist/index.d.ts", "scripts": { diff --git a/modules/openapi-generator/src/main/resources/typescript-jquery/package.mustache b/modules/openapi-generator/src/main/resources/typescript-jquery/package.mustache index b9b1a8b6d58..03802261030 100644 --- a/modules/openapi-generator/src/main/resources/typescript-jquery/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-jquery/package.mustache @@ -11,7 +11,7 @@ "build": "tsc" }, "author": "OpenAPI-Generator Contributors", - "license": "MIT", + "license": "{{licenseName}}", "dependencies": { "bluebird": "^3.3.5", "request": "^2.72.0", diff --git a/modules/openapi-generator/src/main/resources/typescript-nestjs/package.mustache b/modules/openapi-generator/src/main/resources/typescript-nestjs/package.mustache index 58209fba34d..0bf9b9bbbf4 100644 --- a/modules/openapi-generator/src/main/resources/typescript-nestjs/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-nestjs/package.mustache @@ -10,7 +10,7 @@ "keywords": [ "swagger-client" ], - "license": "Unlicense", + "license": "{{licenseName}}", "scripts": { "build": "tsc -p tsconfig.build.json", "build:clean": "rm -rf dist/ 2> /dev/null && tsc -p tsconfig.build.json", diff --git a/modules/openapi-generator/src/main/resources/typescript-node/package.mustache b/modules/openapi-generator/src/main/resources/typescript-node/package.mustache index f8d6788d5bf..58a3067980d 100644 --- a/modules/openapi-generator/src/main/resources/typescript-node/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-node/package.mustache @@ -14,7 +14,7 @@ "test": "npm run build && node dist/client.js" }, "author": "OpenAPI-Generator Contributors", - "license": "Unlicense", + "license": "{{licenseName}}", "dependencies": { "bluebird": "^3.7.2", "request": "^2.88.2" diff --git a/modules/openapi-generator/src/main/resources/typescript-redux-query/package.mustache b/modules/openapi-generator/src/main/resources/typescript-redux-query/package.mustache index d1f90533fcb..bf40b5f2773 100644 --- a/modules/openapi-generator/src/main/resources/typescript-redux-query/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-redux-query/package.mustache @@ -7,6 +7,9 @@ "type": "git", "url": "https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}.git" }, +{{#licenseName}} + "license": "{{licenseName}}", +{{/licenseName}} "main": "./dist/index.js", "typings": "./dist/index.d.ts", "scripts" : { diff --git a/modules/openapi-generator/src/main/resources/typescript-rxjs/package.mustache b/modules/openapi-generator/src/main/resources/typescript-rxjs/package.mustache index 34b64585a01..4ba3284e8c7 100644 --- a/modules/openapi-generator/src/main/resources/typescript-rxjs/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-rxjs/package.mustache @@ -7,6 +7,9 @@ "type": "git", "url": "https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}.git" }, +{{#licenseName}} + "license": "{{licenseName}}", +{{/licenseName}} "main": "./dist/index.js", "typings": "./dist/index.d.ts", "scripts" : { diff --git a/modules/openapi-generator/src/main/resources/typescript/package.mustache b/modules/openapi-generator/src/main/resources/typescript/package.mustache index 12e08d180d2..6391897ca60 100644 --- a/modules/openapi-generator/src/main/resources/typescript/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/package.mustache @@ -13,7 +13,7 @@ "openapi-client", "openapi-generator" ], - "license": "Unlicense", + "license": "{{licenseName}}", "main": "./dist/index.js", {{#supportsES6}} "type": "module", diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAngularClientOptionsProvider.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAngularClientOptionsProvider.java index 2ffc324fc83..c5ca1add41b 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAngularClientOptionsProvider.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAngularClientOptionsProvider.java @@ -18,40 +18,23 @@ package org.openapitools.codegen.options; import com.google.common.collect.ImmutableMap; -import org.openapitools.codegen.CodegenConstants; -import org.openapitools.codegen.languages.AbstractTypeScriptClientCodegen; 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 class TypeScriptAngularClientOptionsProvider implements TypeScriptSharedClientOptionsProvider { public static final String STRING_ENUMS_VALUE = "false"; - 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 String ENUM_PROPERTY_NAMING_VALUE = "PascalCase"; - public static final String MODEL_PROPERTY_NAMING_VALUE = "camelCase"; - public static final String PARAM_NAMING_VALUE = "camelCase"; - private static final String NPM_NAME = "npmName"; - private static final String NPM_VERSION = "1.1.2"; private static final String NPM_REPOSITORY = "https://registry.npmjs.org"; - public static final String ALLOW_UNICODE_IDENTIFIERS_VALUE = "false"; public static final String NG_VERSION = "12"; - public static final String PREPEND_FORM_OR_BODY_PARAMETERS_VALUE = "true"; public static final String FILE_NAMING_VALUE = "camelCase"; public static final String API_MODULE_PREFIX = ""; public static final String CONFIGURATION_PREFIX = ""; public static final String QUERY_PARAM_OBJECT_FORMAT_VALUE = "dot"; public static final String PROVIDED_IN_LEVEL = "root"; - public static String SERVICE_SUFFIX = "Service"; - public static String SERVICE_FILE_SUFFIX = ".service"; - public static String MODEL_SUFFIX = ""; - public static String MODEL_FILE_SUFFIX = ""; - public static final String ENUM_UNKNOWN_DEFAULT_CASE_VALUE = "false"; - public static final String ENUM_PROPERTY_NAMING_REPLACE_SPECIAL_CHAR_VALUE = "false"; + public static final String SERVICE_SUFFIX = "Service"; + public static final String SERVICE_FILE_SUFFIX = ".service"; + public static final String MODEL_SUFFIX = ""; + public static final String MODEL_FILE_SUFFIX = ""; @Override public String getLanguage() { @@ -60,21 +43,9 @@ public class TypeScriptAngularClientOptionsProvider implements OptionsProvider { @Override public Map createOptions() { - ImmutableMap.Builder builder = new ImmutableMap.Builder(); - 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.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE) - .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) + return ImmutableMap.builder() + .putAll(TypeScriptSharedClientOptionsProvider.super.createOptions()) .put(TypeScriptAngularClientCodegen.STRING_ENUMS, STRING_ENUMS_VALUE) - .put(TypeScriptAngularClientCodegen.NPM_NAME, NPM_NAME) - .put(TypeScriptAngularClientCodegen.NPM_VERSION, NPM_VERSION) - .put(TypeScriptAngularClientCodegen.SNAPSHOT, Boolean.FALSE.toString()) .put(TypeScriptAngularClientCodegen.WITH_INTERFACES, Boolean.FALSE.toString()) .put(TypeScriptAngularClientCodegen.USE_SINGLE_REQUEST_PARAMETER, Boolean.FALSE.toString()) .put(TypeScriptAngularClientCodegen.PROVIDED_IN, PROVIDED_IN_LEVEL) @@ -87,19 +58,9 @@ public class TypeScriptAngularClientOptionsProvider implements OptionsProvider { .put(TypeScriptAngularClientCodegen.SERVICE_FILE_SUFFIX, SERVICE_FILE_SUFFIX) .put(TypeScriptAngularClientCodegen.MODEL_SUFFIX, MODEL_SUFFIX) .put(TypeScriptAngularClientCodegen.MODEL_FILE_SUFFIX, MODEL_FILE_SUFFIX) - .put(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS, ALLOW_UNICODE_IDENTIFIERS_VALUE) - .put(CodegenConstants.PREPEND_FORM_OR_BODY_PARAMETERS, PREPEND_FORM_OR_BODY_PARAMETERS_VALUE) .put(TypeScriptAngularClientCodegen.FILE_NAMING, FILE_NAMING_VALUE) - .put(CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR, "true") - .put(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT, "true") .put(TypeScriptAngularClientCodegen.QUERY_PARAM_OBJECT_FORMAT, QUERY_PARAM_OBJECT_FORMAT_VALUE) - .put(CodegenConstants.ENUM_UNKNOWN_DEFAULT_CASE, ENUM_UNKNOWN_DEFAULT_CASE_VALUE) .put(TypeScriptAngularClientCodegen.USE_SQUARE_BRACKETS_IN_ARRAY_NAMES, Boolean.FALSE.toString()) .build(); } - - @Override - public boolean isServer() { - return false; - } } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAngularJsClientOptionsProvider.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAngularJsClientOptionsProvider.java deleted file mode 100644 index fd62de4e03b..00000000000 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAngularJsClientOptionsProvider.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) - * Copyright 2018 SmartBear Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openapitools.codegen.options; - -import com.google.common.collect.ImmutableMap; -import org.openapitools.codegen.CodegenConstants; -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"; - public static final String SORT_MODEL_PROPERTIES_VALUE = "false"; - public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true"; - public static final String MODEL_PROPERTY_NAMING_VALUE = "camelCase"; - public static final String PARAM_NAMING_VALUE = "camelCase"; - public static final String ENUM_PROPERTY_NAMING_VALUE = "PascalCase"; - public static final String ALLOW_UNICODE_IDENTIFIERS_VALUE = "false"; - public static final String PREPEND_FORM_OR_BODY_PARAMETERS_VALUE = "true"; - public static final String ENUM_UNKNOWN_DEFAULT_CASE_VALUE = "false"; - - @Override - public String getLanguage() { - return "typescript-angularjs"; - } - - @Override - public Map createOptions() { - ImmutableMap.Builder builder = new ImmutableMap.Builder(); - 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) - .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.ALLOW_UNICODE_IDENTIFIERS, ALLOW_UNICODE_IDENTIFIERS_VALUE) - .put(CodegenConstants.PREPEND_FORM_OR_BODY_PARAMETERS, PREPEND_FORM_OR_BODY_PARAMETERS_VALUE) - .put(CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR, "true") - .put(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT, "true") - .put(CodegenConstants.ENUM_UNKNOWN_DEFAULT_CASE, ENUM_UNKNOWN_DEFAULT_CASE_VALUE) - .build(); - } - - @Override - public boolean isServer() { - return false; - } -} diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAureliaClientOptionsProvider.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAureliaClientOptionsProvider.java index e975525974a..2c003e8ad38 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAureliaClientOptionsProvider.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAureliaClientOptionsProvider.java @@ -18,28 +18,10 @@ package org.openapitools.codegen.options; import com.google.common.collect.ImmutableMap; -import org.openapitools.codegen.CodegenConstants; -import org.openapitools.codegen.languages.TypeScriptAureliaClientCodegen; -import org.openapitools.codegen.languages.AbstractTypeScriptClientCodegen; import java.util.Map; -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"; - public static final String MODEL_PROPERTY_NAMING_VALUE = "camelCase"; - public static final String PARAM_NAMING_VALUE = "camelCase"; - private static final String NPM_NAME = "npmName"; - private static final String NPM_VERSION = "1.0.0"; - public static final String ALLOW_UNICODE_IDENTIFIERS_VALUE = "false"; - public static final String PREPEND_FORM_OR_BODY_PARAMETERS_VALUE = "true"; - public static final String ENUM_UNKNOWN_DEFAULT_CASE_VALUE = "false"; - public static final String ENUM_PROPERTY_NAMING_REPLACE_SPECIAL_CHAR_VALUE = "false"; +public class TypeScriptAureliaClientOptionsProvider implements TypeScriptSharedClientOptionsProvider { @Override public String getLanguage() { @@ -48,30 +30,8 @@ public class TypeScriptAureliaClientOptionsProvider implements OptionsProvider { @Override public Map createOptions() { - ImmutableMap.Builder builder = new ImmutableMap.Builder(); - 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.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE) - .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) - .put(TypeScriptAureliaClientCodegen.NPM_NAME, NPM_NAME) - .put(TypeScriptAureliaClientCodegen.NPM_VERSION, NPM_VERSION) - .put(TypeScriptAureliaClientCodegen.SNAPSHOT, Boolean.FALSE.toString()) - .put(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS, ALLOW_UNICODE_IDENTIFIERS_VALUE) - .put(CodegenConstants.PREPEND_FORM_OR_BODY_PARAMETERS, PREPEND_FORM_OR_BODY_PARAMETERS_VALUE) - .put(CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR, "true") - .put(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT, "true") - .put(CodegenConstants.ENUM_UNKNOWN_DEFAULT_CASE, ENUM_UNKNOWN_DEFAULT_CASE_VALUE) + return ImmutableMap.builder() + .putAll(TypeScriptSharedClientOptionsProvider.super.createOptions()) .build(); } - - @Override - public boolean isServer() { - return false; - } } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptFetchClientOptionsProvider.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptFetchClientOptionsProvider.java index cfd5f97e9aa..146b5a69293 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptFetchClientOptionsProvider.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptFetchClientOptionsProvider.java @@ -18,37 +18,20 @@ package org.openapitools.codegen.options; import com.google.common.collect.ImmutableMap; -import org.openapitools.codegen.CodegenConstants; import org.openapitools.codegen.languages.TypeScriptFetchClientCodegen; -import org.openapitools.codegen.languages.AbstractTypeScriptClientCodegen; import java.util.Map; -import static org.openapitools.codegen.languages.TypeScriptFetchClientCodegen.CAMEL_CASE; import static org.openapitools.codegen.languages.TypeScriptFetchClientCodegen.PASCAL_CASE; -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 class TypeScriptFetchClientOptionsProvider implements TypeScriptSharedClientOptionsProvider { 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"; - public static final String MODEL_PROPERTY_NAMING_VALUE = CAMEL_CASE; - public static final String PARAM_NAMING_VALUE = CAMEL_CASE; - public static final String ENUM_PROPERTY_NAMING_VALUE = PASCAL_CASE; - private static final String NMP_NAME = "npmName"; - private static final String NMP_VERSION = "1.0.0"; - private static final String NPM_REPOSITORY = "https://registry.npmjs.org"; - public static final String ALLOW_UNICODE_IDENTIFIERS_VALUE = "false"; - public static final String PREPEND_FORM_OR_BODY_PARAMETERS_VALUE = "true"; public static final String WITHOUT_RUNTIME_CHECKS = "true"; + private static final String NPM_REPOSITORY = "https://registry.npmjs.org"; public static final String SAGAS_AND_RECORDS = "false"; - public static final String ENUM_UNKNOWN_DEFAULT_CASE_VALUE = "false"; public static final String STRING_ENUMS = "false"; public static final String FILE_NAMING_VALUE = PASCAL_CASE; - public static final String ENUM_PROPERTY_NAMING_REPLACE_SPECIAL_CHAR_VALUE = "false"; + @Override public String getLanguage() { @@ -57,21 +40,9 @@ public class TypeScriptFetchClientOptionsProvider implements OptionsProvider { @Override public Map createOptions() { - ImmutableMap.Builder builder = new ImmutableMap.Builder(); - 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.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE) - .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) - .put(TypeScriptFetchClientCodegen.NPM_NAME, NMP_NAME) - .put(TypeScriptFetchClientCodegen.NPM_VERSION, NMP_VERSION) + return ImmutableMap.builder() + .putAll(TypeScriptSharedClientOptionsProvider.super.createOptions()) .put(TypeScriptFetchClientCodegen.NPM_REPOSITORY, NPM_REPOSITORY) - .put(TypeScriptFetchClientCodegen.SNAPSHOT, Boolean.FALSE.toString()) .put(TypeScriptFetchClientCodegen.WITH_INTERFACES, Boolean.FALSE.toString()) .put(TypeScriptFetchClientCodegen.USE_SINGLE_REQUEST_PARAMETER, Boolean.FALSE.toString()) .put(TypeScriptFetchClientCodegen.PREFIX_PARAMETER_INTERFACES, Boolean.FALSE.toString()) @@ -79,19 +50,9 @@ public class TypeScriptFetchClientOptionsProvider implements OptionsProvider { .put(TypeScriptFetchClientCodegen.SAGAS_AND_RECORDS, SAGAS_AND_RECORDS) .put(TypeScriptFetchClientCodegen.IMPORT_FILE_EXTENSION_SWITCH, IMPORT_FILE_EXTENSION_VALUE) .put(TypeScriptFetchClientCodegen.FILE_NAMING, FILE_NAMING_VALUE) - .put(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS, ALLOW_UNICODE_IDENTIFIERS_VALUE) - .put(CodegenConstants.PREPEND_FORM_OR_BODY_PARAMETERS, PREPEND_FORM_OR_BODY_PARAMETERS_VALUE) - .put(CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR, "true") - .put(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT, "true") - .put(CodegenConstants.ENUM_UNKNOWN_DEFAULT_CASE, ENUM_UNKNOWN_DEFAULT_CASE_VALUE) .put(TypeScriptFetchClientCodegen.STRING_ENUMS, STRING_ENUMS) .put(TypeScriptFetchClientCodegen.USE_SQUARE_BRACKETS_IN_ARRAY_NAMES, Boolean.FALSE.toString()) .put(TypeScriptFetchClientCodegen.VALIDATION_ATTRIBUTES, Boolean.FALSE.toString()) .build(); } - - @Override - public boolean isServer() { - return false; - } } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptNestjsClientOptionsProvider.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptNestjsClientOptionsProvider.java index 8c89e824f24..7a2f1bb458d 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptNestjsClientOptionsProvider.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptNestjsClientOptionsProvider.java @@ -18,36 +18,19 @@ package org.openapitools.codegen.options; import com.google.common.collect.ImmutableMap; import org.openapitools.codegen.CodegenConstants; -import org.openapitools.codegen.languages.AbstractTypeScriptClientCodegen; 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 class TypeScriptNestjsClientOptionsProvider implements TypeScriptSharedClientOptionsProvider { public static final String STRING_ENUMS_VALUE = "false"; - 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 String ENUM_PROPERTY_NAMING_VALUE = "PascalCase"; - public static final String MODEL_PROPERTY_NAMING_VALUE = "camelCase"; - public static final String PARAM_NAMING_VALUE = "camelCase"; - private static final String NMP_NAME = "npmName"; - private static final String NMP_VERSION = "1.1.2"; private static final String NPM_REPOSITORY = "https://registry.npmjs.org"; - public static final String ALLOW_UNICODE_IDENTIFIERS_VALUE = "false"; public static final String NEST_VERSION = "6"; - public static final String PREPEND_FORM_OR_BODY_PARAMETERS_VALUE = "true"; public static final String FILE_NAMING_VALUE = "camelCase"; - public static final String API_MODULE_PREFIX = ""; - public static String SERVICE_SUFFIX = "Service"; - public static String SERVICE_FILE_SUFFIX = ".service"; - public static String MODEL_SUFFIX = ""; - public static String MODEL_FILE_SUFFIX = ""; - public static final String ENUM_UNKNOWN_DEFAULT_CASE_VALUE = "false"; - public static final String ENUM_PROPERTY_NAMING_REPLACE_SPECIAL_CHAR_VALUE = "false"; + public static final String SERVICE_SUFFIX = "Service"; + public static final String SERVICE_FILE_SUFFIX = ".service"; + public static final String MODEL_SUFFIX = ""; + public static final String MODEL_FILE_SUFFIX = ""; public static final String USE_SINGLE_REQUEST_PARAMETER = "false"; @Override @@ -57,44 +40,19 @@ public class TypeScriptNestjsClientOptionsProvider implements OptionsProvider { @Override public Map createOptions() { - ImmutableMap.Builder builder = new ImmutableMap.Builder(); - 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.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE) - .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) + return ImmutableMap.builder() + .putAll(TypeScriptSharedClientOptionsProvider.super.createOptions()) .put(TypeScriptNestjsClientCodegen.STRING_ENUMS, STRING_ENUMS_VALUE) - .put(TypeScriptNestjsClientCodegen.NPM_NAME, NMP_NAME) - .put(TypeScriptNestjsClientCodegen.NPM_VERSION, NMP_VERSION) - .put(TypeScriptNestjsClientCodegen.SNAPSHOT, Boolean.FALSE.toString()) .put(TypeScriptNestjsClientCodegen.WITH_INTERFACES, Boolean.FALSE.toString()) - //.put(TypeScriptNestjsClientCodegen.USE_SINGLE_REQUEST_PARAMETER, Boolean.FALSE.toString()) - //.put(TypeScriptNestjsClientCodegen.PROVIDED_IN_ROOT, Boolean.FALSE.toString()) .put(TypeScriptNestjsClientCodegen.TAGGED_UNIONS, Boolean.FALSE.toString()) .put(TypeScriptNestjsClientCodegen.NPM_REPOSITORY, NPM_REPOSITORY) .put(TypeScriptNestjsClientCodegen.NEST_VERSION, NEST_VERSION) - //.put(TypeScriptNestjsClientCodegen.API_MODULE_PREFIX, API_MODULE_PREFIX) .put(TypeScriptNestjsClientCodegen.SERVICE_SUFFIX, SERVICE_SUFFIX) .put(TypeScriptNestjsClientCodegen.SERVICE_FILE_SUFFIX, SERVICE_FILE_SUFFIX) .put(TypeScriptNestjsClientCodegen.MODEL_SUFFIX, MODEL_SUFFIX) .put(TypeScriptNestjsClientCodegen.MODEL_FILE_SUFFIX, MODEL_FILE_SUFFIX) - .put(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS, ALLOW_UNICODE_IDENTIFIERS_VALUE) - .put(CodegenConstants.PREPEND_FORM_OR_BODY_PARAMETERS, PREPEND_FORM_OR_BODY_PARAMETERS_VALUE) - .put(CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR, "true") - .put(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT, "true") .put(TypeScriptNestjsClientCodegen.FILE_NAMING, FILE_NAMING_VALUE) - .put(CodegenConstants.ENUM_UNKNOWN_DEFAULT_CASE, ENUM_UNKNOWN_DEFAULT_CASE_VALUE) .put(CodegenConstants.USE_SINGLE_REQUEST_PARAMETER, USE_SINGLE_REQUEST_PARAMETER) .build(); } - - @Override - public boolean isServer() { - return false; - } } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptNodeClientOptionsProvider.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptNodeClientOptionsProvider.java index fca76c379ae..b7a7ee46410 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptNodeClientOptionsProvider.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptNodeClientOptionsProvider.java @@ -18,31 +18,13 @@ package org.openapitools.codegen.options; import com.google.common.collect.ImmutableMap; -import org.openapitools.codegen.CodegenConstants; -import org.openapitools.codegen.languages.AbstractTypeScriptClientCodegen; -import org.openapitools.codegen.languages.TypeScriptAngularClientCodegen; +import org.openapitools.codegen.languages.TypeScriptNodeClientCodegen; 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"; - public static final String SORT_MODEL_PROPERTIES_VALUE = "false"; - public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true"; - public static final String MODEL_PROPERTY_NAMING_VALUE = "camelCase"; - public static final String PARAM_NAMING_VALUE = "camelCase"; - public static final String ENUM_PROPERTY_NAMING_VALUE = "PascalCase"; - public static final String NMP_NAME = "npmName"; - public static final String NMP_VERSION = "1.1.2"; - public static final String NPM_REPOSITORY = "https://registry.npmjs.org"; - public static final String API_SUFFIX = "Api"; - public static final String ALLOW_UNICODE_IDENTIFIERS_VALUE = "false"; - public static final String PREPEND_FORM_OR_BODY_PARAMETERS_VALUE = "true"; - public static final String ENUM_UNKNOWN_DEFAULT_CASE_VALUE = "false"; - public static final String ENUM_PROPERTY_NAMING_REPLACE_SPECIAL_CHAR_VALUE = "false"; +public class TypeScriptNodeClientOptionsProvider implements TypeScriptSharedClientOptionsProvider { + private static final String NPM_REPOSITORY = "https://registry.npmjs.org"; @Override public String getLanguage() { @@ -51,31 +33,9 @@ public class TypeScriptNodeClientOptionsProvider implements OptionsProvider { @Override public Map createOptions() { - ImmutableMap.Builder builder = new ImmutableMap.Builder(); - 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) - .put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE) - .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(TypeScriptAngularClientCodegen.NPM_NAME, NMP_NAME) - .put(TypeScriptAngularClientCodegen.NPM_VERSION, NMP_VERSION) - .put(TypeScriptAngularClientCodegen.SNAPSHOT, Boolean.FALSE.toString()) - .put(TypeScriptAngularClientCodegen.NPM_REPOSITORY, NPM_REPOSITORY) - .put(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS, ALLOW_UNICODE_IDENTIFIERS_VALUE) - .put(CodegenConstants.PREPEND_FORM_OR_BODY_PARAMETERS, PREPEND_FORM_OR_BODY_PARAMETERS_VALUE) - .put(CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR, "true") - .put(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT, "true") - .put(CodegenConstants.ENUM_UNKNOWN_DEFAULT_CASE, ENUM_UNKNOWN_DEFAULT_CASE_VALUE) + return ImmutableMap.builder() + .putAll(TypeScriptSharedClientOptionsProvider.super.createOptions()) + .put(TypeScriptNodeClientCodegen.NPM_REPOSITORY, NPM_REPOSITORY) .build(); } - - @Override - public boolean isServer() { - return false; - } } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptSharedClientOptionsProvider.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptSharedClientOptionsProvider.java new file mode 100644 index 00000000000..be020be5a7b --- /dev/null +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptSharedClientOptionsProvider.java @@ -0,0 +1,60 @@ +package org.openapitools.codegen.options; + +import org.openapitools.codegen.CodegenConstants; +import org.openapitools.codegen.languages.AbstractTypeScriptClientCodegen; + +import java.util.Map; + +import static java.util.Map.entry; + +public interface TypeScriptSharedClientOptionsProvider extends OptionsProvider { + String NPM_NAME_VALUE = "npmName"; + String NPM_VERSION_VALUE = "1.1.2"; + String SUPPORTS_ES6_VALUE = "false"; + String NULL_SAFE_ADDITIONAL_PROPS_VALUE = "false"; + String ENUM_NAME_SUFFIX_VALUE = "Enum"; + String ENUM_PROPERTY_NAMING_VALUE = "PascalCase"; + String MODEL_PROPERTY_NAMING_VALUE = "camelCase"; + String PARAM_NAMING_VALUE = "camelCase"; + String ALLOW_UNICODE_IDENTIFIERS_VALUE = "false"; + String PREPEND_FORM_OR_BODY_PARAMETERS_VALUE = "true"; + String ENUM_UNKNOWN_DEFAULT_CASE_VALUE = "false"; + String ENUM_PROPERTY_NAMING_REPLACE_SPECIAL_CHAR_VALUE = "false"; + String SORT_PARAMS_VALUE = "false"; + String SORT_MODEL_PROPERTIES_VALUE = "false"; + String ENSURE_UNIQUE_PARAMS_VALUE = "true"; + String LEGACY_DISCRIMINATOR_BEHAVIOUR_VALUE = "true"; + String DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT_VALUE = "true"; + String SNAPSHOT_VALUE = Boolean.FALSE.toString(); + String LICENCE_NAME_VALUE = "Unlicense"; + + @Override + default boolean isServer() { + return false; + } + + @Override + default Map createOptions() { + return Map.ofEntries( + entry(AbstractTypeScriptClientCodegen.NPM_NAME, NPM_NAME_VALUE), + entry(AbstractTypeScriptClientCodegen.NPM_VERSION, NPM_VERSION_VALUE), + entry(CodegenConstants.SUPPORTS_ES6, SUPPORTS_ES6_VALUE), + entry(AbstractTypeScriptClientCodegen.NULL_SAFE_ADDITIONAL_PROPS, NULL_SAFE_ADDITIONAL_PROPS_VALUE), + entry(CodegenConstants.ENUM_NAME_SUFFIX, ENUM_NAME_SUFFIX_VALUE), + entry(CodegenConstants.ENUM_PROPERTY_NAMING, ENUM_PROPERTY_NAMING_VALUE), + entry(CodegenConstants.MODEL_PROPERTY_NAMING, MODEL_PROPERTY_NAMING_VALUE), + entry(CodegenConstants.PARAM_NAMING, PARAM_NAMING_VALUE), + entry(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS, ALLOW_UNICODE_IDENTIFIERS_VALUE), + entry(CodegenConstants.PREPEND_FORM_OR_BODY_PARAMETERS, PREPEND_FORM_OR_BODY_PARAMETERS_VALUE), + entry(CodegenConstants.ENUM_UNKNOWN_DEFAULT_CASE, ENUM_UNKNOWN_DEFAULT_CASE_VALUE), + entry(AbstractTypeScriptClientCodegen.ENUM_PROPERTY_NAMING_REPLACE_SPECIAL_CHAR, ENUM_PROPERTY_NAMING_REPLACE_SPECIAL_CHAR_VALUE), + entry(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE), + entry(CodegenConstants.SORT_MODEL_PROPERTIES_BY_REQUIRED_FLAG, SORT_MODEL_PROPERTIES_VALUE), + entry(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE), + entry(CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR, LEGACY_DISCRIMINATOR_BEHAVIOUR_VALUE), + entry(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT, DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT_VALUE), + entry(AbstractTypeScriptClientCodegen.SNAPSHOT, SNAPSHOT_VALUE), + entry(CodegenConstants.LICENSE_NAME, LICENCE_NAME_VALUE) + ); + } +} diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/TypeScriptClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/TypeScriptClientCodegenTest.java index 0c1cd296d18..574aa043446 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/TypeScriptClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/TypeScriptClientCodegenTest.java @@ -4,10 +4,7 @@ import com.google.common.collect.Sets; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.PathItem; import io.swagger.v3.oas.models.media.*; -import org.openapitools.codegen.CodegenModel; -import org.openapitools.codegen.CodegenOperation; -import org.openapitools.codegen.DefaultCodegen; -import org.openapitools.codegen.TestUtils; +import org.openapitools.codegen.*; import org.openapitools.codegen.languages.TypeScriptClientCodegen; import org.openapitools.codegen.model.ModelMap; import org.openapitools.codegen.model.ModelsMap; @@ -168,4 +165,18 @@ public class TypeScriptClientCodegenTest { .get("foo"); Assert.assertEquals(codegen.getTypeDeclaration(schema), "Array"); } + + @Test + public void testAdditionalPropertiesPutForConfigValues() throws Exception { + String licenseName = "Apache 2.0"; + + TypeScriptClientCodegen codegen = new TypeScriptClientCodegen(); + codegen.additionalProperties().put(CodegenConstants.LICENSE_NAME, licenseName); + codegen.processOpts(); + + OpenAPI openAPI = TestUtils.createOpenAPI(); + codegen.preprocessOpenAPI(openAPI); + + Assert.assertEquals(codegen.getLicenseName(), licenseName); + } } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/aurelia/TypeScriptAureliaClientOptionsTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/aurelia/TypeScriptAureliaClientOptionsTest.java index 8da6662021f..94d93636dda 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/aurelia/TypeScriptAureliaClientOptionsTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/aurelia/TypeScriptAureliaClientOptionsTest.java @@ -46,7 +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).setSupportsES6(Boolean.valueOf(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)); } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchClientOptionsTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchClientOptionsTest.java index 26c9796291d..c44b33dbd4c 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchClientOptionsTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchClientOptionsTest.java @@ -47,7 +47,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).setSupportsES6(Boolean.valueOf(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));