[typescript] feat: Add typescript licenseName option (#19888)

* Add licenseName option to typescript

* Update documentation

* Fix import in test

* Consolidate typescript test OptionsProviders

* Rename Typescript to TypeScript
This commit is contained in:
David Riddervold Marconis 2024-10-17 15:48:38 +02:00 committed by GitHub
parent 23bd50fea0
commit ce09134b48
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
38 changed files with 170 additions and 313 deletions

View File

@ -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.|<dl><dt>**false**</dt><dd>No changes to the enum's are made, this is the default option.</dd><dt>**true**</dt><dd>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.</dd></dl>|false|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>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.</dd></dl>|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|

View File

@ -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.|<dl><dt>**false**</dt><dd>No changes to the enum's are made, this is the default option.</dd><dt>**true**</dt><dd>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.</dd></dl>|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).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>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.</dd></dl>|true|
|licenseName|The name of the license| |Unlicense|
|modelFileSuffix|The suffix of the file of the generated model (model&lt;suffix&gt;.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|

View File

@ -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.|<dl><dt>**false**</dt><dd>No changes to the enum's are made, this is the default option.</dd><dt>**true**</dt><dd>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.</dd></dl>|false|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>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.</dd></dl>|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|

View File

@ -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.|<dl><dt>**false**</dt><dd>No changes to the enum's are made, this is the default option.</dd><dt>**true**</dt><dd>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.</dd></dl>|false|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>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.</dd></dl>|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|

View File

@ -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).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>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.</dd></dl>|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|

View File

@ -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.|<dl><dt>**false**</dt><dd>No changes to the enum's are made, this is the default option.</dd><dt>**true**</dt><dd>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.</dd></dl>|false|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>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.</dd></dl>|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|

View File

@ -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.|<dl><dt>**false**</dt><dd>No changes to the enum's are made, this is the default option.</dd><dt>**true**</dt><dd>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.</dd></dl>|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).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>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.</dd></dl>|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|

View File

@ -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.|<dl><dt>**false**</dt><dd>No changes to the enum's are made, this is the default option.</dd><dt>**true**</dt><dd>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.</dd></dl>|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).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>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.</dd></dl>|true|
|licenseName|The name of the license| |Unlicense|
|modelFileSuffix|The suffix of the file of the generated model (model&lt;suffix&gt;.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|

View File

@ -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.|<dl><dt>**false**</dt><dd>No changes to the enum's are made, this is the default option.</dd><dt>**true**</dt><dd>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.</dd></dl>|false|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>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.</dd></dl>|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|

View File

@ -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.|<dl><dt>**false**</dt><dd>No changes to the enum's are made, this is the default option.</dd><dt>**true**</dt><dd>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.</dd></dl>|false|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>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.</dd></dl>|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|

View File

@ -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.|<dl><dt>**false**</dt><dd>No changes to the enum's are made, this is the default option.</dd><dt>**true**</dt><dd>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.</dd></dl>|false|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>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.</dd></dl>|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|

View File

@ -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.|<dl><dt>**fetch-api**</dt><dd>fetch-api</dd><dt>**jquery**</dt><dd>jquery</dd></dl>|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).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>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.</dd></dl>|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|

View File

@ -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<SimpleDateFormat> 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;
}
}

View File

@ -1605,4 +1605,9 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
return sb.toString();
}
}
@Override
protected String getLicenseNameDefaultValue() {
return null;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -11,7 +11,7 @@
"openapi-client",
"openapi-generator"
],
"license": "Unlicense",
"license": "{{licenseName}}",
"scripts": {
"build": "ng-packagr -p ng-package.json"
},

View File

@ -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",

View File

@ -14,7 +14,7 @@
"openapi-generator",
"{{npmName}}"
],
"license": "Unlicense",
"license": "{{licenseName}}",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
{{#supportsES6}}

View File

@ -7,6 +7,9 @@
"type": "git",
"url": "https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}.git"
},
{{#licenseName}}
"license": "{{licenseName}}",
{{/licenseName}}
{{#packageAsSourceOnlyLibrary}}
"main": "./index.ts",
{{/packageAsSourceOnlyLibrary}}

View File

@ -11,7 +11,7 @@
"openapi-client",
"openapi-generator"
],
"license": "Unlicense",
"license": "{{licenseName}}",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {

View File

@ -11,7 +11,7 @@
"build": "tsc"
},
"author": "OpenAPI-Generator Contributors",
"license": "MIT",
"license": "{{licenseName}}",
"dependencies": {
"bluebird": "^3.3.5",
"request": "^2.72.0",

View File

@ -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",

View File

@ -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"

View File

@ -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" : {

View File

@ -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" : {

View File

@ -13,7 +13,7 @@
"openapi-client",
"openapi-generator"
],
"license": "Unlicense",
"license": "{{licenseName}}",
"main": "./dist/index.js",
{{#supportsES6}}
"type": "module",

View File

@ -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<String, String> createOptions() {
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.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.<String, String>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;
}
}

View File

@ -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<String, String> createOptions() {
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)
.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;
}
}

View File

@ -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<String, String> createOptions() {
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.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.<String, String>builder()
.putAll(TypeScriptSharedClientOptionsProvider.super.createOptions())
.build();
}
@Override
public boolean isServer() {
return false;
}
}

View File

@ -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<String, String> createOptions() {
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.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.<String, String>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;
}
}

View File

@ -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<String, String> createOptions() {
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.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.<String, String>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;
}
}

View File

@ -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<String, String> createOptions() {
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)
.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.<String, String>builder()
.putAll(TypeScriptSharedClientOptionsProvider.super.createOptions())
.put(TypeScriptNodeClientCodegen.NPM_REPOSITORY, NPM_REPOSITORY)
.build();
}
@Override
public boolean isServer() {
return false;
}
}

View File

@ -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<String, String> 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)
);
}
}

View File

@ -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<string | null>");
}
@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);
}
}

View File

@ -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));
}

View File

@ -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));