diff --git a/README.md b/README.md index 87e864be5b32..ce239e316726 100644 --- a/README.md +++ b/README.md @@ -586,6 +586,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in - 2019-04-18 - [How to use OpenAPI3 for API developer (RubyKaigi 2019)](https://speakerdeck.com/ota42y/how-to-use-openapi3-for-api-developer) by [@ota42y](https://twitter.com/ota42y) at [RubyKaigi 2019](https://rubykaigi.org/2019) - 2019-04-29 - [A Beginner's Guide to Code Generation for REST APIs (OpenAPI Generator)](https://gum.co/openapi_generator_ebook) by [William Cheng](https://twitter.com/wing328) - 2019-05-01 - [Design and generate a REST API from Swagger / OpenAPI in Java, Python, C# and more](https://simply-how.com/design-and-generate-api-code-from-openapi) by [Simply How](https://simply-how.com/) +- 2019-05-17 - [Generate Spring Boot REST API using Swagger/OpenAPI](https://www.47northlabs.com/knowledge-base/generate-spring-boot-rest-api-using-swagger-openapi/) by [Antonie Zafirov](https://www.47northlabs.com/author/antonie-zafirov/) ## [6 - About Us](#table-of-contents) @@ -750,7 +751,7 @@ If you want to join the committee, please kindly apply by sending an email to te | Apex | | | Bash | @frol (2017/07) @bkryza (2017/08) @kenjones-cisco (2017/09) | | C | @zhemant (2018/11) | -| C++ | @ravinikam (2017/07) @stkrwork (2017/07) @fvarose (2017/11) @etherealjoy (2018/02) @martindelille (2018/03) | +| C++ | @ravinikam (2017/07) @stkrwork (2017/07) @etherealjoy (2018/02) @martindelille (2018/03) | | C# | @mandrean (2017/08), @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert) | | Clojure | | | Dart | @ircecho (2017/07) @swipesight (2018/09) @jaumard (2018/09) | diff --git a/docs/generators/groovy.md b/docs/generators/groovy.md index 16d4e284a1ea..e5ac52bafbab 100644 --- a/docs/generators/groovy.md +++ b/docs/generators/groovy.md @@ -17,8 +17,6 @@ sidebar_label: groovy |groupId|groupId in generated pom.xml| |org.openapitools| |artifactId|artifactId in generated pom.xml. This also becomes part of the generated library's filename| |openapi-groovy| |artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0| -|artifactUrl|artifact URL in generated pom.xml| |https://github.com/openapitools/openapi-generator| -|artifactDescription|artifact description in generated pom.xml| |OpenAPI Java| |scmConnection|SCM connection in generated pom.xml| |scm:git:git@github.com:openapitools/openapi-generator.git| |scmDeveloperConnection|SCM developer connection in generated pom.xml| |scm:git:git@github.com:openapitools/openapi-generator.git| |scmUrl|SCM URL in generated pom.xml| |https://github.com/openapitools/openapi-generator| diff --git a/docs/generators/javascript-flowtyped.md b/docs/generators/javascript-flowtyped.md index 831f5c1586bd..18c53c560d3b 100644 --- a/docs/generators/javascript-flowtyped.md +++ b/docs/generators/javascript-flowtyped.md @@ -13,7 +13,7 @@ sidebar_label: javascript-flowtyped |prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false| |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase| |supportsES6|Generate code that conforms to ES6.| |false| -|npmName|The name under which you want to publish generated npm package| |null| -|npmVersion|The version of your npm package| |null| +|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| +|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false| |npmRepository|Use this property to set an url your private npmRepo in the package.json| |null| -|snapshot|When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false| diff --git a/docs/generators/typescript-angular.md b/docs/generators/typescript-angular.md index 36e331ad84a0..0090d5472bca 100644 --- a/docs/generators/typescript-angular.md +++ b/docs/generators/typescript-angular.md @@ -13,10 +13,10 @@ sidebar_label: typescript-angular |prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false| |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase| |supportsES6|Generate code that conforms to ES6.| |false| -|npmName|The name under which you want to publish generated npm package. Required to generate a full angular package| |null| +|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| +|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false| |npmRepository|Use this property to set an url your private npmRepo in the package.json| |null| -|snapshot|When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false| |withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false| |taggedUnions|Use discriminators to create tagged unions instead of extending interfaces.| |false| |providedInRoot|Use this property to provide Injectables in root (it is only valid in angular version greater or equal to 6.0.0).| |false| diff --git a/docs/generators/typescript-aurelia.md b/docs/generators/typescript-aurelia.md index 1313df5d5eef..49e909d194f8 100644 --- a/docs/generators/typescript-aurelia.md +++ b/docs/generators/typescript-aurelia.md @@ -13,5 +13,6 @@ sidebar_label: typescript-aurelia |prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false| |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase| |supportsES6|Generate code that conforms to ES6.| |false| -|npmName|The name under which you want to publish generated npm package| |null| -|npmVersion|The version of your npm package| |null| +|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| +|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false| diff --git a/docs/generators/typescript-axios.md b/docs/generators/typescript-axios.md index 1623947770b8..efd9e5b4b559 100644 --- a/docs/generators/typescript-axios.md +++ b/docs/generators/typescript-axios.md @@ -13,10 +13,10 @@ sidebar_label: typescript-axios |prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false| |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase| |supportsES6|Generate code that conforms to ES6.| |false| -|npmName|The name under which you want to publish generated npm package| |null| -|npmVersion|The version of your npm package| |null| +|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| +|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false| |npmRepository|Use this property to set an url of your private npmRepo in the package.json| |null| -|snapshot|When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false| |withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false| |withSeparateModelsAndApi|Put the model and api in separate folders and in separate classes| |false| |withoutPrefixEnums|Don't prefix enum names with class names| |false| diff --git a/docs/generators/typescript-fetch.md b/docs/generators/typescript-fetch.md index 71742b582f98..1ccb820eeeae 100644 --- a/docs/generators/typescript-fetch.md +++ b/docs/generators/typescript-fetch.md @@ -13,8 +13,8 @@ sidebar_label: typescript-fetch |prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false| |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase| |supportsES6|Generate code that conforms to ES6.| |false| -|npmName|The name under which you want to publish generated npm package| |null| -|npmVersion|The version of your npm package| |null| +|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| +|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false| |npmRepository|Use this property to set an url your private npmRepo in the package.json| |null| -|snapshot|When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false| |withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false| diff --git a/docs/generators/typescript-inversify.md b/docs/generators/typescript-inversify.md index c521c73f4b79..4a7cbc73c4c2 100644 --- a/docs/generators/typescript-inversify.md +++ b/docs/generators/typescript-inversify.md @@ -13,10 +13,10 @@ sidebar_label: typescript-inversify |prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false| |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase| |supportsES6|Generate code that conforms to ES6.| |false| -|npmName|The name under which you want to publish generated npm package| |null| -|npmVersion|The version of your npm package| |null| +|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| +|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false| |npmRepository|Use this property to set an url your private npmRepo in the package.json| |null| -|snapshot|When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false| |withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false| |usePromise|Setting this property to use promise instead of observable inside every service.| |false| |taggedUnions|Use discriminators to create tagged unions instead of extending interfaces.| |false| diff --git a/docs/generators/typescript-jquery.md b/docs/generators/typescript-jquery.md index b40fd66c3b26..dd635959395d 100644 --- a/docs/generators/typescript-jquery.md +++ b/docs/generators/typescript-jquery.md @@ -13,8 +13,8 @@ sidebar_label: typescript-jquery |prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false| |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase| |supportsES6|Generate code that conforms to ES6.| |false| -|npmName|The name under which you want to publish generated npm package| |null| -|npmVersion|The version of your npm package| |null| +|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| +|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false| |npmRepository|Use this property to set an url your private npmRepo in the package.json| |null| -|snapshot|When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false| |jqueryAlreadyImported|When using this in legacy app using mix of typescript and javascript, this will only declare jquery and not import it| |false| diff --git a/docs/generators/typescript-node.md b/docs/generators/typescript-node.md index 76fb2925277e..60dd406eb308 100644 --- a/docs/generators/typescript-node.md +++ b/docs/generators/typescript-node.md @@ -13,7 +13,7 @@ sidebar_label: typescript-node |prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false| |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase| |supportsES6|Generate code that conforms to ES6.| |false| -|npmName|The name under which you want to publish generated npm package| |null| -|npmVersion|The version of your npm package| |null| +|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| +|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false| |npmRepository|Use this property to set an url your private npmRepo in the package.json| |null| -|snapshot|When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false| diff --git a/docs/generators/typescript-rxjs.md b/docs/generators/typescript-rxjs.md index 2fd435e3122b..b2db2dc057bd 100644 --- a/docs/generators/typescript-rxjs.md +++ b/docs/generators/typescript-rxjs.md @@ -13,8 +13,8 @@ sidebar_label: typescript-rxjs |prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false| |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase| |supportsES6|Generate code that conforms to ES6.| |false| -|npmName|The name under which you want to publish generated npm package| |null| -|npmVersion|The version of your npm package| |null| +|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| +|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false| |npmRepository|Use this property to set an url your private npmRepo in the package.json| |null| -|snapshot|When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false| |withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false| diff --git a/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Meta.java b/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Meta.java index 8cee440fc3b7..4ec67be8914d 100644 --- a/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Meta.java +++ b/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Meta.java @@ -83,7 +83,7 @@ public class Meta implements Runnable { ImmutableList.of( new SupportingFile("pom.mustache", "", "pom.xml"), new SupportingFile("generatorClass.mustache", on(File.separator).join("src/main/java", asPath(targetPackage)), mainClass.concat(".java")), - new SupportingFile("debugGeneratorTest.mustache", on(File.separator).join("src/test/java", asPath("org.openapitools.codegen.debug")), "DebugCodegenLauncher.java"), + new SupportingFile("generatorClassTest.mustache", on(File.separator).join("src/test/java", asPath(targetPackage)), mainClass.concat("Test.java")), new SupportingFile("README.mustache", "", "README.md"), new SupportingFile("api.template", "src/main/resources" + File.separator + name,"api.mustache"), new SupportingFile("model.template", "src/main/resources" + File.separator + name,"model.mustache"), diff --git a/modules/openapi-generator-gradle-plugin/gradle.properties b/modules/openapi-generator-gradle-plugin/gradle.properties index 7b4544abd1a9..bf2d204d4d1a 100644 --- a/modules/openapi-generator-gradle-plugin/gradle.properties +++ b/modules/openapi-generator-gradle-plugin/gradle.properties @@ -1,4 +1,4 @@ -openApiGeneratorVersion=4.0.0 +openApiGeneratorVersion=5.0.0-SNAPSHOT # BEGIN placeholders # these are just placeholders to allow contributors to build directly diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index e24ac5194912..7c928dee6cea 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -4833,10 +4833,19 @@ public class DefaultCodegen implements CodegenConfig { } protected void updateOption(String key, String defaultValue) { + for (CliOption cliOption : cliOptions) { + if (cliOption.getOpt().equals(key)) { + cliOption.setDefault(defaultValue); + break; + } + } + } + + protected void removeOption(String key) { for(int i = 0; i < cliOptions.size(); i++) { - if(cliOptions.get(i).getOpt().equals(key)) { - cliOptions.get(i).setDefault(defaultValue); - return; + if (key.equals(cliOptions.get(i).getOpt())) { + cliOptions.remove(i); + break; } } } @@ -4853,7 +4862,7 @@ public class DefaultCodegen implements CodegenConfig { * * @param objs map of object */ - public void generateJSONSpecFile(Map objs) { + protected void generateJSONSpecFile(Map objs) { OpenAPI openAPI = (OpenAPI) objs.get("openAPI"); if (openAPI != null) { try { diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java index 4f4e60730d67..d2a20593f52e 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java @@ -652,19 +652,6 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code return escapeText(pattern); } - public boolean convertPropertyToBoolean(String propertyKey) { - boolean booleanValue = false; - if (additionalProperties.containsKey(propertyKey)) { - booleanValue = Boolean.valueOf(additionalProperties.get(propertyKey).toString()); - } - - return booleanValue; - } - - public void writePropertyBack(String propertyKey, boolean value) { - additionalProperties.put(propertyKey, value); - } - @Override public String sanitizeTag(String tag) { return camelize(sanitizeName(tag)); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java index 3c4ec0102c8f..0ef33cf0480f 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java @@ -266,14 +266,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId); } - if (additionalProperties.containsKey(CodegenConstants.SNAPSHOT_VERSION)) { - Boolean useSnapshotVersion = Boolean.valueOf((String) additionalProperties.get(CodegenConstants.SNAPSHOT_VERSION)); - - if (useSnapshotVersion) { - this.setArtifactVersion(this.buildSnapshotVersion(this.artifactVersion)); - } - } - if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_URL)) { this.setArtifactUrl((String) additionalProperties.get(CodegenConstants.ARTIFACT_URL)); } else { @@ -1047,12 +1039,16 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code this.setArtifactVersion((String) additionalProperties.get(CodegenConstants.ARTIFACT_VERSION)); } else if (openAPI.getInfo() != null && openAPI.getInfo().getVersion() != null) { this.setArtifactVersion(openAPI.getInfo().getVersion()); - additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); - } else { - //not set, use to be passed to template - additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); } + if (additionalProperties.containsKey(CodegenConstants.SNAPSHOT_VERSION)) { + Boolean useSnapshotVersion = Boolean.valueOf((String) additionalProperties.get(CodegenConstants.SNAPSHOT_VERSION)); + if (useSnapshotVersion) { + this.setArtifactVersion(this.buildSnapshotVersion(this.getArtifactVersion())); + } + } + additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); + } private static String getAccept(OpenAPI openAPI, Operation operation) { @@ -1060,7 +1056,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code String defaultContentType = "application/json"; Set producesInfo = getProducesInfo(openAPI, operation); if (producesInfo != null && !producesInfo.isEmpty()) { - ArrayList produces = new ArrayList(producesInfo); + ArrayList produces = new ArrayList<>(producesInfo); StringBuilder sb = new StringBuilder(); for (String produce : produces) { if (defaultContentType.equalsIgnoreCase(produce)) { @@ -1085,7 +1081,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code @Override protected boolean needToImport(String type) { - return super.needToImport(type) && type.indexOf(".") < 0; + return super.needToImport(type) && !type.contains("."); } @Override @@ -1183,10 +1179,11 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code if (removedChildEnum) { // If we removed an entry from this model's vars, we need to ensure hasMore is updated - int count = 0, numVars = codegenProperties.size(); + int count = 0; + int numVars = codegenProperties.size(); for (CodegenProperty codegenProperty : codegenProperties) { count += 1; - codegenProperty.hasMore = (count < numVars) ? true : false; + codegenProperty.hasMore = count < numVars; } codegenModel.vars = codegenProperties; } @@ -1444,27 +1441,13 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code return escapeText(pattern); } - @Override - public boolean convertPropertyToBoolean(String propertyKey) { - boolean booleanValue = false; - if (additionalProperties.containsKey(propertyKey)) { - booleanValue = Boolean.valueOf(additionalProperties.get(propertyKey).toString()); - } - - return booleanValue; - } - - @Override - public void writePropertyBack(String propertyKey, boolean value) { - additionalProperties.put(propertyKey, value); - } - /** * Output the Getter name for boolean property, e.g. isActive * * @param name the name of the property * @return getter name based on naming convention */ + @Override public String toBooleanGetter(String name) { return booleanGetterPrefix + getterAndSetterCapitalize(name); } @@ -1505,7 +1488,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code return camelize(name, lowercaseFirstLetter); } - @Override public void postProcessFile(File file, String fileType) { if (file == 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 68c1046af656..ab230e20be29 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 @@ -17,6 +17,7 @@ package org.openapitools.codegen.languages; +import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.parameters.Parameter; @@ -39,14 +40,19 @@ import static org.openapitools.codegen.utils.StringUtils.underscore; public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen implements CodegenConfig { private static final Logger LOGGER = LoggerFactory.getLogger(AbstractTypeScriptClientCodegen.class); - protected static final SimpleDateFormat SNAPSHOT_SUFFIX_FORMAT = new SimpleDateFormat("yyyyMMddHHmm", Locale.ROOT); - private static final String X_DISCRIMINATOR_TYPE = "x-discriminator-value"; private static final String UNDEFINED_VALUE = "undefined"; + public static final String NPM_NAME = "npmName"; + public static final String NPM_VERSION = "npmVersion"; + public static final String SNAPSHOT = "snapshot"; + + protected static final SimpleDateFormat SNAPSHOT_SUFFIX_FORMAT = new SimpleDateFormat("yyyyMMddHHmm", Locale.ROOT); protected String modelPropertyNaming = "camelCase"; protected Boolean supportsES6 = false; protected HashSet languageGenericTypes; + protected String npmName = null; + protected String npmVersion = "1.0.0"; public AbstractTypeScriptClientCodegen() { super(); @@ -119,8 +125,14 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp typeMapping.put("UUID", "string"); typeMapping.put("Error", "Error"); - cliOptions.add(new CliOption(CodegenConstants.MODEL_PROPERTY_NAMING, CodegenConstants.MODEL_PROPERTY_NAMING_DESC).defaultValue("camelCase")); + cliOptions.add(new CliOption(CodegenConstants.MODEL_PROPERTY_NAMING, CodegenConstants.MODEL_PROPERTY_NAMING_DESC).defaultValue(this.modelPropertyNaming)); cliOptions.add(new CliOption(CodegenConstants.SUPPORTS_ES6, CodegenConstants.SUPPORTS_ES6_DESC).defaultValue(String.valueOf(this.getSupportsES6()))); + this.cliOptions.add(new CliOption(NPM_NAME, "The name under which you want to publish generated npm package." + + " Required to generate a full package")); + this.cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package. If not provided, using the version from the OpenAPI specification file.").defaultValue(this.getNpmVersion())); + this.cliOptions.add(CliOption.newBoolean(SNAPSHOT, + "When setting this property to true, the version will be suffixed with -SNAPSHOT." + this.SNAPSHOT_SUFFIX_FORMAT.toPattern(), + false)); } @@ -144,6 +156,37 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp setSupportsES6(Boolean.valueOf(additionalProperties.get(CodegenConstants.SUPPORTS_ES6).toString())); additionalProperties.put("supportsES6", getSupportsES6()); } + + if (additionalProperties.containsKey(NPM_NAME)) { + this.setNpmName(additionalProperties.get(NPM_NAME).toString()); + } + + } + + @Override + public void preprocessOpenAPI(OpenAPI openAPI) { + + if (additionalProperties.containsKey(NPM_NAME)) { + + // If no npmVersion is provided in additional properties, version from API specification is used. + // If none of them is provided then fallbacks to default version + if (additionalProperties.containsKey(NPM_VERSION)) { + this.setNpmVersion(additionalProperties.get(NPM_VERSION).toString()); + } else if (openAPI.getInfo() != null && openAPI.getInfo().getVersion() != null) { + this.setNpmVersion(openAPI.getInfo().getVersion()); + } + + if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) { + if (npmVersion.toUpperCase(Locale.ROOT).matches("^.*-SNAPSHOT$")) { + this.setNpmVersion(npmVersion + "." + SNAPSHOT_SUFFIX_FORMAT.format(new Date())); + } else { + this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date())); + } + } + additionalProperties.put(NPM_VERSION, npmVersion); + + } + } @Override @@ -197,7 +240,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp public String toVarName(String name) { name = this.toParamName(name); - // if the proprty name has any breaking characters such as :, ;, . etc. + // if the property name has any breaking characters such as :, ;, . etc. // then wrap the name within single quotes. // my:interface:property: string; => 'my:interface:property': string; if (propertyHasBreakingCharacters(name)) { @@ -568,6 +611,22 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp return supportsES6; } + public String getNpmName() { + return npmName; + } + + public void setNpmName(String npmName) { + this.npmName = npmName; + } + + public String getNpmVersion() { + return npmVersion; + } + + public void setNpmVersion(String npmVersion) { + this.npmVersion = npmVersion; + } + private void setDiscriminatorValue(CodegenModel model, String baseName, String value) { for (CodegenProperty prop : model.allVars) { if (prop.baseName.equals(baseName)) { diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/FsharpGiraffeServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/FsharpGiraffeServerCodegen.java index 1b3fc948d0db..5a84940292c5 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/FsharpGiraffeServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/FsharpGiraffeServerCodegen.java @@ -18,7 +18,6 @@ package org.openapitools.codegen.languages; import com.samskivert.mustache.Mustache; import io.swagger.v3.oas.models.OpenAPI; -import sun.reflect.generics.reflectiveObjects.NotImplementedException; import org.openapitools.codegen.CodegenConstants; import org.openapitools.codegen.CodegenOperation; diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GroovyClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GroovyClientCodegen.java index 94332fed9d83..ecae95083c90 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GroovyClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GroovyClientCodegen.java @@ -56,13 +56,15 @@ public class GroovyClientCodegen extends AbstractJavaCodegen { artifactId = "openapi-groovy"; dateLibrary = "legacy"; //TODO: add joda support to groovy - // clioOptions default redefinition need to be updated + // cliOptions default redefinition need to be updated updateOption(CodegenConstants.SOURCE_FOLDER, this.getSourceFolder()); updateOption(CodegenConstants.INVOKER_PACKAGE, this.getInvokerPackage()); updateOption(CodegenConstants.ARTIFACT_ID, this.getArtifactId()); updateOption(CodegenConstants.API_PACKAGE, apiPackage); updateOption(CodegenConstants.MODEL_PACKAGE, modelPackage); updateOption(DATE_LIBRARY, this.getDateLibrary()); + removeOption(CodegenConstants.ARTIFACT_URL); + removeOption(CodegenConstants.ARTIFACT_DESCRIPTION); } @@ -95,7 +97,6 @@ public class GroovyClientCodegen extends AbstractJavaCodegen { @Override public Map postProcessOperationsWithModels(Map operations, List allModels) { Map objs = (Map) operations.get("operations"); - List ops = (List) objs.get("operation"); for (CodegenOperation op : ops) { // Overwrite path to map variable with path parameters diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaJAXRSSpecServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaJAXRSSpecServerCodegen.java index 67a8f39b0834..776915734a33 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaJAXRSSpecServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaJAXRSSpecServerCodegen.java @@ -54,7 +54,7 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen { apiPackage = "org.openapitools.api"; modelPackage = "org.openapitools.model"; - // clioOptions default redifinition need to be updated + // cliOptions default redefinition need to be updated updateOption(CodegenConstants.INVOKER_PACKAGE, this.getInvokerPackage()); updateOption(CodegenConstants.ARTIFACT_ID, this.getArtifactId()); updateOption(CodegenConstants.API_PACKAGE, apiPackage); @@ -80,13 +80,7 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen { super.embeddedTemplateDir = templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME + File.separator + "spec"; - for (int i = 0; i < cliOptions.size(); i++) { - if (CodegenConstants.LIBRARY.equals(cliOptions.get(i).getOpt())) { - cliOptions.remove(i); - break; - } - } - + removeOption(CodegenConstants.LIBRARY); CliOption library = new CliOption(CodegenConstants.LIBRARY, CodegenConstants.LIBRARY_DESC).defaultValue(DEFAULT_LIBRARY); Map supportedLibraries = new LinkedHashMap<>(); supportedLibraries.put(DEFAULT_LIBRARY, "JAXRS"); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptFlowtypedClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptFlowtypedClientCodegen.java index f073bed32fb0..e213cd923556 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptFlowtypedClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptFlowtypedClientCodegen.java @@ -32,13 +32,8 @@ import java.util.*; import static org.openapitools.codegen.utils.StringUtils.dashize; public class JavascriptFlowtypedClientCodegen extends AbstractTypeScriptClientCodegen { - public static final String NPM_NAME = "npmName"; - public static final String NPM_VERSION = "npmVersion"; public static final String NPM_REPOSITORY = "npmRepository"; - public static final String SNAPSHOT = "snapshot"; - protected String npmName = null; - protected String npmVersion = "1.0.0"; protected String npmRepository = null; public JavascriptFlowtypedClientCodegen() { @@ -105,10 +100,7 @@ public class JavascriptFlowtypedClientCodegen extends AbstractTypeScriptClientCo outputFolder = "generated-code/javascript-flowtyped"; embeddedTemplateDir = templateDir = "Javascript-Flowtyped"; - this.cliOptions.add(new CliOption(NPM_NAME, "The name under which you want to publish generated npm package")); - this.cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package")); this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json")); - this.cliOptions.add(new CliOption(SNAPSHOT, "When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); } @@ -130,23 +122,6 @@ public class JavascriptFlowtypedClientCodegen extends AbstractTypeScriptClientCo } private void addNpmPackageGeneration() { - if (additionalProperties.containsKey(NPM_NAME)) { - this.setNpmName(additionalProperties.get(NPM_NAME).toString()); - } - - if (additionalProperties.containsKey(NPM_VERSION)) { - this.setNpmVersion(additionalProperties.get(NPM_VERSION).toString()); - } - - if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) { - if (npmVersion.toUpperCase(Locale.ROOT).matches("^.*-SNAPSHOT$")) { - this.setNpmVersion(npmVersion + "." + SNAPSHOT_SUFFIX_FORMAT.format(new Date())); - } - else { - this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date())); - } - } - additionalProperties.put(NPM_VERSION, npmVersion); if (additionalProperties.containsKey(NPM_REPOSITORY)) { this.setNpmRepository(additionalProperties.get(NPM_REPOSITORY).toString()); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java index 8d315b1c2c48..fdaa2bce4e5b 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java @@ -21,6 +21,7 @@ import com.samskivert.mustache.Mustache; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.PathItem; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; import org.openapitools.codegen.*; import org.openapitools.codegen.languages.features.BeanValidationFeatures; @@ -36,6 +37,7 @@ import java.util.*; import java.util.regex.Matcher; import java.util.stream.Collectors; +import static org.apache.commons.lang3.StringUtils.isNotEmpty; import static org.openapitools.codegen.utils.StringUtils.camelize; public class SpringCodegen extends AbstractJavaCodegen @@ -377,7 +379,7 @@ public class SpringCodegen extends AbstractJavaCodegen if (this.java8) { additionalProperties.put("javaVersion", "1.8"); if (!SPRING_CLOUD_LIBRARY.equals(library)) { - additionalProperties.put("jdk8", "true"); + additionalProperties.put("jdk8", true); } if (this.async) { additionalProperties.put(RESPONSE_WRAPPER, "CompletableFuture"); @@ -395,29 +397,32 @@ public class SpringCodegen extends AbstractJavaCodegen // Some well-known Spring or Spring-Cloud response wrappers - switch (this.responseWrapper) { - case "Future": - case "Callable": - case "CompletableFuture": - additionalProperties.put(RESPONSE_WRAPPER, "java.util.concurrent." + this.responseWrapper); - break; - case "ListenableFuture": - additionalProperties.put(RESPONSE_WRAPPER, "org.springframework.util.concurrent.ListenableFuture"); - break; - case "DeferredResult": - additionalProperties.put(RESPONSE_WRAPPER, "org.springframework.web.context.request.async.DeferredResult"); - break; - case "HystrixCommand": - additionalProperties.put(RESPONSE_WRAPPER, "com.netflix.hystrix.HystrixCommand"); - break; - case "RxObservable": - additionalProperties.put(RESPONSE_WRAPPER, "rx.Observable"); - break; - case "RxSingle": - additionalProperties.put(RESPONSE_WRAPPER, "rx.Single"); - break; - default: - break; + if (isNotEmpty(this.responseWrapper)) { + additionalProperties.put("jdk8", false); + switch (this.responseWrapper) { + case "Future": + case "Callable": + case "CompletableFuture": + additionalProperties.put(RESPONSE_WRAPPER, "java.util.concurrent." + this.responseWrapper); + break; + case "ListenableFuture": + additionalProperties.put(RESPONSE_WRAPPER, "org.springframework.util.concurrent.ListenableFuture"); + break; + case "DeferredResult": + additionalProperties.put(RESPONSE_WRAPPER, "org.springframework.web.context.request.async.DeferredResult"); + break; + case "HystrixCommand": + additionalProperties.put(RESPONSE_WRAPPER, "com.netflix.hystrix.HystrixCommand"); + break; + case "RxObservable": + additionalProperties.put(RESPONSE_WRAPPER, "rx.Observable"); + break; + case "RxSingle": + additionalProperties.put(RESPONSE_WRAPPER, "rx.Single"); + break; + default: + break; + } } // add lambda for mustache templates diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java index e5c8f1d00281..745e9747b2c9 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java @@ -38,10 +38,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode private static String CLASS_NAME_SUFFIX_PATTERN = "^[a-zA-Z0-9]*$"; private static String FILE_NAME_SUFFIX_PATTERN = "^[a-zA-Z0-9.-]*$"; - public static final String NPM_NAME = "npmName"; - public static final String NPM_VERSION = "npmVersion"; public static final String NPM_REPOSITORY = "npmRepository"; - public static final String SNAPSHOT = "snapshot"; public static final String WITH_INTERFACES = "withInterfaces"; public static final String TAGGED_UNIONS = "taggedUnions"; public static final String NG_VERSION = "ngVersion"; @@ -52,8 +49,6 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode public static final String MODEL_FILE_SUFFIX = "modelFileSuffix"; public static final String FILE_NAMING = "fileNaming"; - protected String npmName = null; - protected String npmVersion = "1.0.0"; protected String ngVersion = "7.0.0"; protected String npmRepository = null; protected String serviceSuffix = "Service"; @@ -76,14 +71,8 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode apiPackage = "api"; modelPackage = "model"; - this.cliOptions.add(new CliOption(NPM_NAME, "The name under which you want to publish generated npm package." + - " Required to generate a full angular package")); - this.cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package. If not provided, using the version from the OpenAPI specification file.").defaultValue(this.getNpmVersion())); this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json")); - this.cliOptions.add(CliOption.newBoolean(SNAPSHOT, - "When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm", - false)); this.cliOptions.add(CliOption.newBoolean(WITH_INTERFACES, "Setting this property to true will generate interfaces next to the default class implementations.", false)); @@ -200,10 +189,6 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode private void addNpmPackageGeneration(SemVer ngVersion) { - if (additionalProperties.containsKey(NPM_NAME)) { - this.setNpmName(additionalProperties.get(NPM_NAME).toString()); - } - if (additionalProperties.containsKey(NPM_REPOSITORY)) { this.setNpmRepository(additionalProperties.get(NPM_REPOSITORY).toString()); } @@ -278,36 +263,9 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode //Files for building our lib supportingFiles.add(new SupportingFile("package.mustache", getIndexDirectory(), "package.json")); - supportingFiles.add(new SupportingFile("typings.mustache", getIndexDirectory(), "typings.json")); supportingFiles.add(new SupportingFile("tsconfig.mustache", getIndexDirectory(), "tsconfig.json")); } - @Override - public void preprocessOpenAPI(OpenAPI openAPI) { - - if (additionalProperties.containsKey(NPM_NAME)) { - - // If no npmVersion is provided in additional properties, version from API specification is used. - // If none of them is provided then fallbacks to default version - if (additionalProperties.containsKey(NPM_VERSION)) { - this.setNpmVersion(additionalProperties.get(NPM_VERSION).toString()); - } else if (openAPI.getInfo() != null && openAPI.getInfo().getVersion() != null) { - this.setNpmVersion(openAPI.getInfo().getVersion()); - } - - if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) { - if (npmVersion.toUpperCase(Locale.ROOT).matches("^.*-SNAPSHOT$")) { - this.setNpmVersion(npmVersion + "." + SNAPSHOT_SUFFIX_FORMAT.format(new Date())); - } else { - this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date())); - } - } - additionalProperties.put(NPM_VERSION, npmVersion); - - } - - } - private String getIndexDirectory() { String indexPackage = modelPackage.substring(0, Math.max(0, modelPackage.lastIndexOf('.'))); return indexPackage.replace('.', File.separatorChar); @@ -551,22 +509,6 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode return modelPackage() + "/" + toModelFilename(name); } - public String getNpmName() { - return npmName; - } - - public void setNpmName(String npmName) { - this.npmName = npmName; - } - - public String getNpmVersion() { - return npmVersion; - } - - public void setNpmVersion(String npmVersion) { - this.npmVersion = npmVersion; - } - public String getNpmRepository() { return npmRepository; } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularJsClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularJsClientCodegen.java index 7621cbe370aa..dc68aace1e03 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularJsClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularJsClientCodegen.java @@ -33,6 +33,11 @@ public class TypeScriptAngularJsClientCodegen extends AbstractTypeScriptClientCo embeddedTemplateDir = templateDir = "typescript-angularjs"; apiPackage = "api"; modelPackage = "model"; + + removeOption(NPM_NAME); + removeOption(NPM_VERSION); + removeOption(SNAPSHOT); + } @Override @@ -48,6 +53,7 @@ public class TypeScriptAngularJsClientCodegen extends AbstractTypeScriptClientCo @Override public void processOpts() { super.processOpts(); + supportingFiles.add(new SupportingFile("models.mustache", modelPackage().replace('.', File.separatorChar), "models.ts")); supportingFiles.add(new SupportingFile("apis.mustache", apiPackage().replace('.', File.separatorChar), "api.ts")); supportingFiles.add(new SupportingFile("index.mustache", getIndexDirectory(), "index.ts")); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAureliaClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAureliaClientCodegen.java index 2a9d2123ce26..3ed6203c2a6a 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAureliaClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAureliaClientCodegen.java @@ -18,7 +18,6 @@ package org.openapitools.codegen.languages; import org.openapitools.codegen.*; -import org.openapitools.codegen.utils.StringUtils; import java.util.*; @@ -26,12 +25,6 @@ import static org.openapitools.codegen.utils.StringUtils.*; public class TypeScriptAureliaClientCodegen extends AbstractTypeScriptClientCodegen { - public static final String NPM_NAME = "npmName"; - public static final String NPM_VERSION = "npmVersion"; - - protected String npmName = null; - protected String npmVersion = "1.0.0"; - public TypeScriptAureliaClientCodegen() { super(); @@ -43,8 +36,7 @@ public class TypeScriptAureliaClientCodegen extends AbstractTypeScriptClientCode outputFolder = "generated-code/typescript-aurelia"; embeddedTemplateDir = templateDir = "typescript-aurelia"; - this.cliOptions.add(new CliOption(NPM_NAME, "The name under which you want to publish generated npm package")); - this.cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package")); + } @Override @@ -77,14 +69,6 @@ public class TypeScriptAureliaClientCodegen extends AbstractTypeScriptClientCode public void processOpts() { super.processOpts(); - if (additionalProperties.containsKey(NPM_NAME)) { - this.setNpmName(additionalProperties.get(NPM_NAME).toString()); - } - - if (additionalProperties.containsKey(NPM_VERSION)) { - this.setNpmVersion(additionalProperties.get(NPM_VERSION).toString()); - } - // Set supporting files supportingFiles.add(new SupportingFile("models.mustache", "", "models.ts")); supportingFiles.add(new SupportingFile("index.ts.mustache", "", "index.ts")); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAxiosClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAxiosClientCodegen.java index 2360aab7d16d..fff5afb332f7 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAxiosClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAxiosClientCodegen.java @@ -33,16 +33,11 @@ import java.util.*; public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodegen { - public static final String NPM_NAME = "npmName"; - public static final String NPM_VERSION = "npmVersion"; public static final String NPM_REPOSITORY = "npmRepository"; - public static final String SNAPSHOT = "snapshot"; public static final String WITH_INTERFACES = "withInterfaces"; public static final String SEPARATE_MODELS_AND_API = "withSeparateModelsAndApi"; public static final String WITHOUT_PREFIX_ENUMS = "withoutPrefixEnums"; - protected String npmName = null; - protected String npmVersion = "1.0.0"; protected String npmRepository = null; private String tsModelPackage = ""; @@ -57,10 +52,7 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege outputFolder = "generated-code/typescript-axios"; embeddedTemplateDir = templateDir = "typescript-axios"; - this.cliOptions.add(new CliOption(NPM_NAME, "The name under which you want to publish generated npm package")); - this.cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package")); this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url of your private npmRepo in the package.json")); - this.cliOptions.add(new CliOption(SNAPSHOT, "When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); this.cliOptions.add(new CliOption(WITH_INTERFACES, "Setting this property to true will generate interfaces next to the default class implementations.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); this.cliOptions.add(new CliOption(SEPARATE_MODELS_AND_API, "Put the model and api in separate folders and in separate classes", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); this.cliOptions.add(new CliOption(WITHOUT_PREFIX_ENUMS, "Don't prefix enum names with class names", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); @@ -76,22 +68,6 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege return "Generates a TypeScript client library using axios."; } - public String getNpmName() { - return npmName; - } - - public void setNpmName(String npmName) { - this.npmName = npmName; - } - - public String getNpmVersion() { - return npmVersion; - } - - public void setNpmVersion(String npmVersion) { - this.npmVersion = npmVersion; - } - public String getNpmRepository() { return npmRepository; } @@ -235,23 +211,6 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege } private void addNpmPackageGeneration() { - if (additionalProperties.containsKey(NPM_NAME)) { - this.setNpmName(additionalProperties.get(NPM_NAME).toString()); - } - - if (additionalProperties.containsKey(NPM_VERSION)) { - this.setNpmVersion(additionalProperties.get(NPM_VERSION).toString()); - } - - if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) { - if (npmVersion.toUpperCase(Locale.ROOT).matches("^.*-SNAPSHOT$")) { - this.setNpmVersion(npmVersion + "." + SNAPSHOT_SUFFIX_FORMAT.format(new Date())); - } - else { - this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date())); - } - } - additionalProperties.put(NPM_VERSION, npmVersion); if (additionalProperties.containsKey(NPM_REPOSITORY)) { this.setNpmRepository(additionalProperties.get(NPM_REPOSITORY).toString()); 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 5dc9706feea1..4d80efd6a703 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 @@ -33,14 +33,9 @@ import java.util.Map; public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodegen { - public static final String NPM_NAME = "npmName"; - public static final String NPM_VERSION = "npmVersion"; public static final String NPM_REPOSITORY = "npmRepository"; - public static final String SNAPSHOT = "snapshot"; public static final String WITH_INTERFACES = "withInterfaces"; - protected String npmName = null; - protected String npmVersion = "1.0.0"; protected String npmRepository = null; public TypeScriptFetchClientCodegen() { @@ -59,10 +54,7 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege this.modelTemplateFiles.put("models.mustache", ".ts"); this.addExtraReservedWords(); - this.cliOptions.add(new CliOption(NPM_NAME, "The name under which you want to publish generated npm package")); - this.cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package")); this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json")); - this.cliOptions.add(new CliOption(SNAPSHOT, "When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); this.cliOptions.add(new CliOption(WITH_INTERFACES, "Setting this property to true will generate interfaces next to the default class implementations.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); } @@ -76,22 +68,6 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege return "Generates a TypeScript client library using Fetch API (beta)."; } - public String getNpmName() { - return npmName; - } - - public void setNpmName(String npmName) { - this.npmName = npmName; - } - - public String getNpmVersion() { - return npmVersion; - } - - public void setNpmVersion(String npmVersion) { - this.npmVersion = npmVersion; - } - public String getNpmRepository() { return npmRepository; } @@ -196,23 +172,6 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege } private void addNpmPackageGeneration() { - if (additionalProperties.containsKey(NPM_NAME)) { - this.setNpmName(additionalProperties.get(NPM_NAME).toString()); - } - - if (additionalProperties.containsKey(NPM_VERSION)) { - this.setNpmVersion(additionalProperties.get(NPM_VERSION).toString()); - } - - if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) { - if (npmVersion.toUpperCase(Locale.ROOT).matches("^.*-SNAPSHOT$")) { - this.setNpmVersion(npmVersion + "." + SNAPSHOT_SUFFIX_FORMAT.format(new Date())); - } - else { - this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date())); - } - } - additionalProperties.put(NPM_VERSION, npmVersion); if (additionalProperties.containsKey(NPM_REPOSITORY)) { this.setNpmRepository(additionalProperties.get(NPM_REPOSITORY).toString()); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptInversifyClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptInversifyClientCodegen.java index 05464d1a1fa4..7714265d1e0d 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptInversifyClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptInversifyClientCodegen.java @@ -33,16 +33,11 @@ import static org.openapitools.codegen.utils.StringUtils.camelize; public class TypeScriptInversifyClientCodegen extends AbstractTypeScriptClientCodegen { - public static final String NPM_NAME = "npmName"; - public static final String NPM_VERSION = "npmVersion"; public static final String NPM_REPOSITORY = "npmRepository"; - public static final String SNAPSHOT = "snapshot"; public static final String WITH_INTERFACES = "withInterfaces"; public static final String USE_PROMISE = "usePromise"; public static final String TAGGED_UNIONS = "taggedUnions"; - protected String npmVersion = null; - protected String npmName = null; protected String npmRepository = null; private boolean taggedUnions = false; @@ -58,13 +53,8 @@ public class TypeScriptInversifyClientCodegen extends AbstractTypeScriptClientCo apiPackage = "api"; modelPackage = "model"; - this.cliOptions.add(new CliOption(NPM_NAME, "The name under which you want to publish generated npm package")); - this.cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package")); this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json")); - this.cliOptions.add(new CliOption(SNAPSHOT, - "When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm", - SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); this.cliOptions.add(new CliOption(WITH_INTERFACES, "Setting this property to true will generate interfaces next to the default class implementations.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); @@ -122,23 +112,6 @@ public class TypeScriptInversifyClientCodegen extends AbstractTypeScriptClientCo } private void addNpmPackageGeneration() { - if (additionalProperties.containsKey(NPM_NAME)) { - this.setNpmName(additionalProperties.get(NPM_NAME).toString()); - } - - if (additionalProperties.containsKey(NPM_VERSION)) { - this.setNpmVersion(additionalProperties.get(NPM_VERSION).toString()); - } - - if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) { - if (npmVersion.toUpperCase(Locale.ROOT).matches("^.*-SNAPSHOT$")) { - this.setNpmVersion(npmVersion + "." + SNAPSHOT_SUFFIX_FORMAT.format(new Date())); - } - else { - this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date())); - } - } - additionalProperties.put(NPM_VERSION, npmVersion); if (additionalProperties.containsKey(NPM_REPOSITORY)) { this.setNpmRepository(additionalProperties.get(NPM_REPOSITORY).toString()); @@ -348,22 +321,6 @@ public class TypeScriptInversifyClientCodegen extends AbstractTypeScriptClientCo return modelPackage() + "/" + toModelFilename(name); } - public String getNpmName() { - return npmName; - } - - public void setNpmName(String npmName) { - this.npmName = npmName; - } - - public String getNpmVersion() { - return npmVersion; - } - - public void setNpmVersion(String npmVersion) { - this.npmVersion = npmVersion; - } - public String getNpmRepository() { return npmRepository; } 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 379b2a0ee7e4..0be86b0de782 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 @@ -34,14 +34,10 @@ import java.util.Locale; public class TypeScriptJqueryClientCodegen extends AbstractTypeScriptClientCodegen { private static final Logger LOGGER = LoggerFactory.getLogger(TypeScriptJqueryClientCodegen.class); - public static final String NPM_NAME = "npmName"; - public static final String NPM_VERSION = "npmVersion"; public static final String NPM_REPOSITORY = "npmRepository"; public static final String SNAPSHOT = "snapshot"; public static final String JQUERY_ALREADY_IMPORTED = "jqueryAlreadyImported"; - protected String npmName = null; - protected String npmVersion = "1.0.0"; protected String npmRepository = null; public TypeScriptJqueryClientCodegen() { @@ -56,12 +52,7 @@ public class TypeScriptJqueryClientCodegen extends AbstractTypeScriptClientCodeg outputFolder = "generated-code/typescript-jquery"; embeddedTemplateDir = templateDir = "typescript-jquery"; - this.cliOptions.add(new CliOption(NPM_NAME, "The name under which you want to publish generated npm package")); - this.cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package")); this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json")); - this.cliOptions.add(new CliOption(SNAPSHOT, - "When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm", - SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); this.cliOptions.add(new CliOption(JQUERY_ALREADY_IMPORTED, "When using this in legacy app using mix of typescript and javascript, this will only declare jquery and not import it", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); @@ -77,18 +68,6 @@ public class TypeScriptJqueryClientCodegen extends AbstractTypeScriptClientCodeg return "Generates a TypeScript jquery client library."; } - public void setNpmName(String npmName) { - this.npmName = npmName; - } - - public void setNpmVersion(String npmVersion) { - this.npmVersion = npmVersion; - } - - public String getNpmVersion() { - return npmVersion; - } - public String getNpmRepository() { return npmRepository; } @@ -108,7 +87,6 @@ public class TypeScriptJqueryClientCodegen extends AbstractTypeScriptClientCodeg supportingFiles.add(new SupportingFile("index.mustache", getIndexDirectory(), "index.ts")); supportingFiles.add(new SupportingFile("variables.mustache", getIndexDirectory(), "variables.ts")); - //LOGGER.warn("check additionals: " + additionalProperties.get(NPM_NAME)); if (additionalProperties.containsKey(NPM_NAME)) { addNpmPackageGeneration(); } @@ -172,23 +150,6 @@ public class TypeScriptJqueryClientCodegen extends AbstractTypeScriptClientCodeg } private void addNpmPackageGeneration() { - if (additionalProperties.containsKey(NPM_NAME)) { - this.setNpmName(additionalProperties.get(NPM_NAME).toString()); - } - - if (additionalProperties.containsKey(NPM_VERSION)) { - this.setNpmVersion(additionalProperties.get(NPM_VERSION).toString()); - } - - if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) { - if (npmVersion.toUpperCase(Locale.ROOT).matches("^.*-SNAPSHOT$")) { - this.setNpmVersion(npmVersion + "." + SNAPSHOT_SUFFIX_FORMAT.format(new Date())); - } - else { - this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date())); - } - } - additionalProperties.put(NPM_VERSION, npmVersion); if (additionalProperties.containsKey(NPM_REPOSITORY)) { this.setNpmRepository(additionalProperties.get(NPM_REPOSITORY).toString()); @@ -197,7 +158,6 @@ public class TypeScriptJqueryClientCodegen extends AbstractTypeScriptClientCodeg //Files for building our lib supportingFiles.add(new SupportingFile("README.mustache", getPackageRootDirectory(), "README.md")); supportingFiles.add(new SupportingFile("package.mustache", getPackageRootDirectory(), "package.json")); - supportingFiles.add(new SupportingFile("typings.mustache", getPackageRootDirectory(), "typings.json")); supportingFiles.add(new SupportingFile("tsconfig.mustache", getPackageRootDirectory(), "tsconfig.json")); } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNodeClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNodeClientCodegen.java index 3bffc213e4cb..bcad8aa989c0 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNodeClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNodeClientCodegen.java @@ -21,12 +21,10 @@ import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.parser.util.SchemaTypeUtil; import org.openapitools.codegen.*; import org.openapitools.codegen.utils.ModelUtils; -import org.openapitools.codegen.utils.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; -import java.text.SimpleDateFormat; import java.util.*; import static org.openapitools.codegen.utils.StringUtils.camelize; @@ -34,13 +32,8 @@ import static org.openapitools.codegen.utils.StringUtils.camelize; public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen { private static final Logger LOGGER = LoggerFactory.getLogger(TypeScriptNodeClientCodegen.class); - public static final String NPM_NAME = "npmName"; - public static final String NPM_VERSION = "npmVersion"; public static final String NPM_REPOSITORY = "npmRepository"; - public static final String SNAPSHOT = "snapshot"; - protected String npmName = null; - protected String npmVersion = "1.0.0"; protected String npmRepository = null; protected String apiSuffix = "Api"; @@ -61,12 +54,8 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen modelPackage = "model"; apiPackage = "api"; - this.cliOptions.add(new CliOption(NPM_NAME, "The name under which you want to publish generated npm package")); - this.cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package")); this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json")); - this.cliOptions.add(new CliOption(SNAPSHOT, - "When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm", - SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); + } @Override @@ -189,18 +178,6 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen return operations; } - public void setNpmName(String npmName) { - this.npmName = npmName; - } - - public void setNpmVersion(String npmVersion) { - this.npmVersion = npmVersion; - } - - public String getNpmVersion() { - return npmVersion; - } - public String getNpmRepository() { return npmRepository; } @@ -224,23 +201,6 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen } private void addNpmPackageGeneration() { - if (additionalProperties.containsKey(NPM_NAME)) { - this.setNpmName(additionalProperties.get(NPM_NAME).toString()); - } - - if (additionalProperties.containsKey(NPM_VERSION)) { - this.setNpmVersion(additionalProperties.get(NPM_VERSION).toString()); - } - - if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) { - if (npmVersion.toUpperCase(Locale.ROOT).matches("^.*-SNAPSHOT$")) { - this.setNpmVersion(npmVersion + "." + SNAPSHOT_SUFFIX_FORMAT.format(new Date())); - } - else { - this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date())); - } - } - additionalProperties.put(NPM_VERSION, npmVersion); if (additionalProperties.containsKey(NPM_REPOSITORY)) { this.setNpmRepository(additionalProperties.get(NPM_REPOSITORY).toString()); 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 fef59ec90af8..f7f96501ddb0 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 @@ -33,14 +33,9 @@ import java.util.Map; public class TypeScriptRxjsClientCodegen extends AbstractTypeScriptClientCodegen { - public static final String NPM_NAME = "npmName"; - public static final String NPM_VERSION = "npmVersion"; public static final String NPM_REPOSITORY = "npmRepository"; - public static final String SNAPSHOT = "snapshot"; public static final String WITH_INTERFACES = "withInterfaces"; - protected String npmName = null; - protected String npmVersion = "1.0.0"; protected String npmRepository = null; public TypeScriptRxjsClientCodegen() { @@ -59,10 +54,7 @@ public class TypeScriptRxjsClientCodegen extends AbstractTypeScriptClientCodegen this.modelTemplateFiles.put("models.mustache", ".ts"); this.addExtraReservedWords(); - this.cliOptions.add(new CliOption(NPM_NAME, "The name under which you want to publish generated npm package")); - this.cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package")); this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json")); - this.cliOptions.add(new CliOption(SNAPSHOT, "When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); this.cliOptions.add(new CliOption(WITH_INTERFACES, "Setting this property to true will generate interfaces next to the default class implementations.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); } @@ -76,22 +68,6 @@ public class TypeScriptRxjsClientCodegen extends AbstractTypeScriptClientCodegen return "Generates a TypeScript client library using Rxjs API."; } - public String getNpmName() { - return npmName; - } - - public void setNpmName(String npmName) { - this.npmName = npmName; - } - - public String getNpmVersion() { - return npmVersion; - } - - public void setNpmVersion(String npmVersion) { - this.npmVersion = npmVersion; - } - public String getNpmRepository() { return npmRepository; } @@ -186,23 +162,6 @@ public class TypeScriptRxjsClientCodegen extends AbstractTypeScriptClientCodegen } private void addNpmPackageGeneration() { - if (additionalProperties.containsKey(NPM_NAME)) { - this.setNpmName(additionalProperties.get(NPM_NAME).toString()); - } - - if (additionalProperties.containsKey(NPM_VERSION)) { - this.setNpmVersion(additionalProperties.get(NPM_VERSION).toString()); - } - - if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) { - if (npmVersion.toUpperCase(Locale.ROOT).matches("^.*-SNAPSHOT$")) { - this.setNpmVersion(npmVersion + "." + SNAPSHOT_SUFFIX_FORMAT.format(new Date())); - } - else { - this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date())); - } - } - additionalProperties.put(NPM_VERSION, npmVersion); if (additionalProperties.containsKey(NPM_REPOSITORY)) { this.setNpmRepository(additionalProperties.get(NPM_REPOSITORY).toString()); diff --git a/modules/openapi-generator/src/main/resources/Groovy/api.mustache b/modules/openapi-generator/src/main/resources/Groovy/api.mustache index 20fe23f96237..daa1351ff744 100644 --- a/modules/openapi-generator/src/main/resources/Groovy/api.mustache +++ b/modules/openapi-generator/src/main/resources/Groovy/api.mustache @@ -20,12 +20,14 @@ class {{classname}} { def bodyParams def contentType - {{#allParams}}{{#required}} + {{#allParams}} + {{#required}} // verify required params are set if ({{paramName}} == null) { throw new RuntimeException("missing required params {{paramName}}") } - {{/required}}{{/allParams}} + {{/required}} + {{/allParams}} {{#queryParams}} if ({{paramName}} != null) { @@ -47,15 +49,19 @@ class {{classname}} { contentType = '{{{mediaType}}}'; {{/consumes.0}} {{/bodyParam}} + {{#bodyParams.0}} + {{^hasMore}} + bodyParams = {{paramName}} + {{/hasMore}} + {{#hasMore}} + bodyParams = [:] + bodyParams.put("{{baseName}}", {{paramName}}) + {{/hasMore}} + {{/bodyParams.0}} {{#bodyParams}} - // only one body parameter - if (1 == {{bodyParams.size}}) { - bodyParams = {{paramName}} - } - // array of body parameters - else { - bodyParams.put("{{baseName}}", {{paramName}}) - } + {{#secondaryParam}} + bodyParams.put("{{baseName}}", {{paramName}}) + {{/secondaryParam}} {{/bodyParams}} {{#hasFormParams}} @@ -63,20 +69,18 @@ class {{classname}} { contentType = '{{{mediaType}}}'; {{/consumes.0}} {{#formParams.0}} - // only one form parameter - if (1 == {{formParams.size}}) { - bodyParams = {{paramName}} - } - // array of form parameters - else { - bodyParams = [:] - } + {{^hasMore}} + bodyParams = {{paramName}} + {{/hasMore}} + {{#hasMore}} + bodyParams = [:] + bodyParams.put("{{baseName}}", {{paramName}}) + {{/hasMore}} {{/formParams.0}} {{#formParams}} - // array of form parameters - if (1 < {{formParams.size}}) { - bodyParams.put("{{baseName}}", {{paramName}}) - } + {{#secondaryParam}} + bodyParams.put("{{baseName}}", {{paramName}}) + {{/secondaryParam}} {{/formParams}} {{/hasFormParams}} diff --git a/modules/openapi-generator/src/main/resources/apex/licenseInfo.mustache b/modules/openapi-generator/src/main/resources/apex/licenseInfo.mustache index 3b4ccbef537b..3f52a36757f1 100644 --- a/modules/openapi-generator/src/main/resources/apex/licenseInfo.mustache +++ b/modules/openapi-generator/src/main/resources/apex/licenseInfo.mustache @@ -6,6 +6,6 @@ * {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} * * NOTE: This class is auto generated by the OAS code generator program. - * https://github.com/OAS-api/OAS-codegen.git + * https://github.com/OpenAPITools/openapi-generator * Do not edit the class manually. */ diff --git a/modules/openapi-generator/src/main/resources/codegen/debugGeneratorTest.mustache b/modules/openapi-generator/src/main/resources/codegen/debugGeneratorTest.mustache deleted file mode 100644 index 9a9836c1143b..000000000000 --- a/modules/openapi-generator/src/main/resources/codegen/debugGeneratorTest.mustache +++ /dev/null @@ -1,40 +0,0 @@ -package org.openapitools.codegen.debug; - -import org.junit.Test; -import org.openapitools.codegen.OpenAPIGenerator; - -/*** - * This test allows you to easily launch your code generation software under a debugger. - * Then run this test under debug mode. You will be able to step through your java code - * and then see the results in the out directory. - * - * To experiment with debugging your code generator: - * 1) Set a break point in {{generatorClass}}.java in the postProcessOperationsWithModels() method. - * 2) To launch this test in Eclipse: right-click | Debug As | JUnit Test - * - */ -public class DebugCodegenLauncher -{ - @Test - public void launchCodeGeneratorInDebugMode() - { - // use this test to launch you code generator in the debugger. - // this allows you to easily set break points in {{generatorClass}}. - String commandLineParams = - "generate "+ - "-i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml "+ // sample swagger - "-t ./src/main/resources/{{name}} "+ // template directory - "-o out/{{name}} "+ // output directory - "-g {{name}} "; // use this codegen library - - try{ - OpenAPIGenerator.main( commandLineParams.split(" ") ); - } - catch(Exception ex) { - System.err.println(ex.toString()); - } - catch(Error er) { - System.err.println(er.toString()); - } - } -} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/codegen/generatorClassTest.mustache b/modules/openapi-generator/src/main/resources/codegen/generatorClassTest.mustache new file mode 100644 index 000000000000..4267a928fcf4 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/codegen/generatorClassTest.mustache @@ -0,0 +1,36 @@ +package {{generatorPackage}}; + +import org.junit.Test; +import org.openapitools.codegen.ClientOptInput; +import org.openapitools.codegen.DefaultGenerator; +import org.openapitools.codegen.config.CodegenConfigurator; + +/*** + * This test allows you to easily launch your code generation software under a debugger. + * Then run this test under debug mode. You will be able to step through your java code + * and then see the results in the out directory. + * + * To experiment with debugging your code generator: + * 1) Set a break point in {{generatorClass}}.java in the postProcessOperationsWithModels() method. + * 2) To launch this test in Eclipse: right-click | Debug As | JUnit Test + * + */ +public class {{generatorClass}}Test { + + // use this test to launch you code generator in the debugger. + // this allows you to easily set break points in MyclientcodegenGenerator. + @Test + public void launchCodeGenerator() { + // to understand how the 'openapi-generator-cli' module is using 'CodegenConfigurator', have a look at the 'Generate' class: + // https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Generate.java + final CodegenConfigurator configurator = new CodegenConfigurator() + .setGeneratorName("{{name}}") // use this codegen library + .setInputSpec("../../../modules/openapi-generator/src/test/resources/2_0/petstore.yaml") // sample OpenAPI file + // .setInputSpec("https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml") // or from the server + .setOutputDir("out/{{name}}"); // output directory + + final ClientOptInput clientOptInput = configurator.toClientOptInput(); + DefaultGenerator generator = new DefaultGenerator(); + generator.opts(clientOptInput).generate(); + } +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/codegen/pom.mustache b/modules/openapi-generator/src/main/resources/codegen/pom.mustache index 8f9aa292252f..628dd6552f75 100644 --- a/modules/openapi-generator/src/main/resources/codegen/pom.mustache +++ b/modules/openapi-generator/src/main/resources/codegen/pom.mustache @@ -113,11 +113,6 @@ ${openapi-generator-version} provided - - org.openapitools - openapi-generator-cli - ${openapi-generator-version} - junit junit diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-source.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-source.mustache index c529fbea5799..3f7f4e0b7402 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-source.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-source.mustache @@ -79,10 +79,14 @@ void {{classname}}::{{operationIdSnakeCase}}_handler(const Pistache::Rest::Reque try { this->{{operationIdSnakeCase}}(request, response); {{/vendorExtensions.x-codegen-pistache-isParsingSupported}} - } catch (std::runtime_error & e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + } catch (nlohmann::detail::exception &e) { + //send a 400 error + response.send(Pistache::Http::Code::Bad_Request, e.what()); + return; + } catch (std::runtime_error &e) { + //send a 500 error + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + return; } } diff --git a/modules/openapi-generator/src/main/resources/dart/pubspec.mustache b/modules/openapi-generator/src/main/resources/dart/pubspec.mustache index a338854b7485..ef8fab4bb2a5 100644 --- a/modules/openapi-generator/src/main/resources/dart/pubspec.mustache +++ b/modules/openapi-generator/src/main/resources/dart/pubspec.mustache @@ -2,4 +2,4 @@ name: {{pubName}} version: {{pubVersion}} description: {{pubDescription}} dependencies: - http: '>=0.11.1 <0.12.0' + http: '>=0.11.1 <0.13.0' diff --git a/modules/openapi-generator/src/main/resources/dart2/pubspec.mustache b/modules/openapi-generator/src/main/resources/dart2/pubspec.mustache index 388572afe624..008cee0b2412 100644 --- a/modules/openapi-generator/src/main/resources/dart2/pubspec.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/pubspec.mustache @@ -4,4 +4,4 @@ description: {{pubDescription}} environment: sdk: '>=2.0.0 <3.0.0' dependencies: - http: '>=0.11.1 <0.12.0' + http: '>=0.11.1 <0.13.0' diff --git a/modules/openapi-generator/src/main/resources/ruby-client/README.mustache b/modules/openapi-generator/src/main/resources/ruby-client/README.mustache index 00f50d813403..182bb34f4f50 100644 --- a/modules/openapi-generator/src/main/resources/ruby-client/README.mustache +++ b/modules/openapi-generator/src/main/resources/ruby-client/README.mustache @@ -65,10 +65,12 @@ Please follow the [installation](#installation) procedure and then run the follo require '{{{gemName}}}' {{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}{{#hasAuthMethods}} # Setup authorization -{{{moduleName}}}.configure do |config|{{#authMethods}}{{#isBasic}} +{{{moduleName}}}.configure do |config|{{#authMethods}}{{#isBasic}}{{^isBasicBearer}} # Configure HTTP basic authorization: {{{name}}} - config.username = 'YOUR USERNAME' - config.password = 'YOUR PASSWORD'{{/isBasic}}{{#isApiKey}} + config.username = 'YOUR_USERNAME' + config.password = 'YOUR_PASSWORD'{{/isBasicBearer}}{{#isBasicBearer}} + # Configure Bearer authorization{{#bearerFormat}} ({{{.}}}){{/bearerFormat}}: {{{name}}} + config.access_token = 'YOUR_BEARER_TOKEN'{{/isBasicBearer}}{{/isBasic}}{{#isApiKey}} # Configure API key authorization: {{{name}}} config.api_key['{{{keyParamName}}}'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) @@ -128,7 +130,10 @@ Class | Method | HTTP request | Description - **API key parameter name**: {{keyParamName}} - **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} {{/isApiKey}} -{{#isBasic}}- **Type**: HTTP basic authentication +{{#isBasic}} +{{^isBasicBearer}}- **Type**: HTTP basic authentication +{{/isBasicBearer}}{{#isBasicBearer}}- **Type**: Bearer authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} +{{/isBasicBearer}} {{/isBasic}} {{#isOAuth}} diff --git a/modules/openapi-generator/src/main/resources/ruby-client/api_doc.mustache b/modules/openapi-generator/src/main/resources/ruby-client/api_doc.mustache index 960c0552dcf8..dc163725e163 100644 --- a/modules/openapi-generator/src/main/resources/ruby-client/api_doc.mustache +++ b/modules/openapi-generator/src/main/resources/ruby-client/api_doc.mustache @@ -27,10 +27,12 @@ Method | HTTP request | Description require '{{{gemName}}}' {{#hasAuthMethods}} # setup authorization -{{{moduleName}}}.configure do |config|{{#authMethods}}{{#isBasic}} +{{{moduleName}}}.configure do |config|{{#authMethods}}{{#isBasic}}{{^isBasicBearer}} # Configure HTTP basic authorization: {{{name}}} config.username = 'YOUR USERNAME' - config.password = 'YOUR PASSWORD'{{/isBasic}}{{#isApiKey}} + config.password = 'YOUR PASSWORD'{{/isBasicBearer}}{{#isBasicBearer}} + # Configure Bearer authorization{{#bearerFormat}} ({{{.}}}){{/bearerFormat}}: {{{name}}} + config.access_token = 'YOUR_BEARER_TOKEN'{{/isBasicBearer}}{{/isBasic}}{{#isApiKey}} # Configure API key authorization: {{{name}}} config.api_key['{{{keyParamName}}}'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) diff --git a/modules/openapi-generator/src/main/resources/ruby-client/configuration.mustache b/modules/openapi-generator/src/main/resources/ruby-client/configuration.mustache index d0d190ff2f5b..2f43306a3b9f 100644 --- a/modules/openapi-generator/src/main/resources/ruby-client/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/ruby-client/configuration.mustache @@ -199,6 +199,7 @@ module {{moduleName}} }, {{/isApiKey}} {{#isBasic}} +{{^isBasicBearer}} '{{name}}' => { type: 'basic', @@ -206,6 +207,19 @@ module {{moduleName}} key: 'Authorization', value: basic_auth_token }, +{{/isBasicBearer}} +{{#isBasicBearer}} + '{{name}}' => + { + type: 'bearer', + in: 'header', + {{#bearerFormat}} + format: '{{{.}}}', + {{/bearerFormat}} + key: 'Authorization', + value: "Bearer #{access_token}" + }, +{{/isBasicBearer}} {{/isBasic}} {{#isOAuth}} '{{name}}' => diff --git a/modules/openapi-generator/src/main/resources/typescript-angular/typings.mustache b/modules/openapi-generator/src/main/resources/typescript-angular/typings.mustache deleted file mode 100644 index 507c40e5cbed..000000000000 --- a/modules/openapi-generator/src/main/resources/typescript-angular/typings.mustache +++ /dev/null @@ -1,5 +0,0 @@ -{ - "globalDependencies": { - "core-js": "registry:dt/core-js#0.0.0+20160725163759" - } -} diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache index 0ce4291e5da6..6a1967c7c868 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache @@ -94,7 +94,7 @@ export class {{classname}} extends runtime.BaseAPI { {{#headerParams}} {{#isListContainer}} if (requestParameters.{{paramName}}) { - headerParameters['{{baseName}}'] = requestParameters.{{paramName}}.join(runtime.COLLECTION_FORMATS["{{collectionFormat}}"])); + headerParameters['{{baseName}}'] = requestParameters.{{paramName}}.join(runtime.COLLECTION_FORMATS["{{collectionFormat}}"]); } {{/isListContainer}} diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache index 476e984fadc7..fc160bb14b92 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache @@ -1,4 +1,4 @@ -import { exists } from '../runtime'; +import { exists, mapValues } from '../runtime'; {{#hasImports}} import { {{#imports}} @@ -46,17 +46,22 @@ export function {{classname}}FromJSON(json: any): {{classname}} { {{/isDate}} {{/isPrimitiveType}} {{^isPrimitiveType}} - {{#isContainer}} + {{#isListContainer}} '{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}(json['{{baseName}}'] as Array).map({{#items}}{{datatype}}{{/items}}FromJSON), - {{/isContainer}} - {{^isContainer}} + {{/isListContainer}} + {{#isMapContainer}} + '{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}mapValues(json['{{baseName}}'], {{#items}}{{datatype}}{{/items}}FromJSON), + {{/isMapContainer}} + {{^isListContainer}} + {{^isMapContainer}} {{^isFreeFormObject}} '{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}{{datatype}}FromJSON(json['{{baseName}}']), {{/isFreeFormObject}} {{#isFreeFormObject}} '{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}json['{{baseName}}'], {{/isFreeFormObject}} - {{/isContainer}} + {{/isMapContainer}} + {{/isListContainer}} {{/isPrimitiveType}} {{/allVars}} }; @@ -78,17 +83,22 @@ export function {{classname}}ToJSON(value?: {{classname}}): any { '{{baseName}}': {{#isDate}}{{^required}}value.{{name}} === undefined ? undefined : {{/required}}value.{{name}}.toISOString().substr(0,10){{/isDate}}{{#isDateTime}}{{^required}}value.{{name}} === undefined ? undefined : {{/required}}value.{{name}}.toISOString(){{/isDateTime}}{{^isDate}}{{^isDateTime}}value.{{name}}{{/isDateTime}}{{/isDate}}, {{/isPrimitiveType}} {{^isPrimitiveType}} - {{#isContainer}} + {{#isListContainer}} '{{baseName}}': {{^required}}value.{{name}} === undefined ? undefined : {{/required}}(value.{{name}} as Array).map({{#items}}{{datatype}}{{/items}}ToJSON), - {{/isContainer}} - {{^isContainer}} + {{/isListContainer}} + {{#isMapContainer}} + '{{baseName}}': {{^required}}value.{{name}} === undefined ? undefined : {{/required}}mapValues(value.{{name}}, {{#items}}{{datatype}}{{/items}}ToJSON), + {{/isMapContainer}} + {{^isListContainer}} + {{^isMapContainer}} {{^isFreeFormObject}} '{{baseName}}': {{datatype}}ToJSON(value.{{name}}), {{/isFreeFormObject}} {{#isFreeFormObject}} '{{baseName}}': value.{{name}}, {{/isFreeFormObject}} - {{/isContainer}} + {{/isMapContainer}} + {{/isListContainer}} {{/isPrimitiveType}} {{/isReadOnly}} {{/allVars}} diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache index 624feac809f8..6f8038f5bdf2 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache @@ -202,6 +202,13 @@ export function querystring(params: HTTPQuery, prefix: string = ''): string { .join('&'); } +export function mapValues(data: any, fn: (item: any) => any) { + return Object.keys(data).reduce( + (acc, key) => ({ ...acc, [key]: fn(data[key]) }), + {} + ); +} + export interface RequestContext { fetch: FetchAPI; url: string; diff --git a/modules/openapi-generator/src/main/resources/typescript-jquery/README.mustache b/modules/openapi-generator/src/main/resources/typescript-jquery/README.mustache index ef14fdbbf334..ec079198a7c2 100644 --- a/modules/openapi-generator/src/main/resources/typescript-jquery/README.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-jquery/README.mustache @@ -15,7 +15,7 @@ Module system * CommonJS * ES6 module system -It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html)) +It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html)) ### Building diff --git a/modules/openapi-generator/src/main/resources/typescript-jquery/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/typescript-jquery/git_push.sh.mustache index 8a32e53995d6..b2cb1cdd4e8c 100755 --- a/modules/openapi-generator/src/main/resources/typescript-jquery/git_push.sh.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-jquery/git_push.sh.mustache @@ -1,7 +1,7 @@ #!/bin/sh # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ # -# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-typescript-jquery "minor update" git_user_id=$1 git_repo_id=$2 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 46ba3da15d8a..cba64d11771c 100644 --- a/modules/openapi-generator/src/main/resources/typescript-jquery/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-jquery/package.mustache @@ -11,13 +11,13 @@ "dependencies": { "bluebird": "^3.3.5", "request": "^2.72.0", - "jquery": "^3.1.1" + "jquery": "^3.1" }, "devDependencies": { - "typescript": "2.2.2", - "typings": "^1.3.0" + "@types/jquery": "^3.1", + "typescript": "^2.4" }{{#npmRepository}}, - "publishConfig":{ - "registry":"{{npmRepository}}" + "publishConfig": { + "registry": "{{npmRepository}}" }{{/npmRepository}} } diff --git a/modules/openapi-generator/src/main/resources/typescript-jquery/tsconfig.mustache b/modules/openapi-generator/src/main/resources/typescript-jquery/tsconfig.mustache index 39415409ce65..ff5c84462d02 100644 --- a/modules/openapi-generator/src/main/resources/typescript-jquery/tsconfig.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-jquery/tsconfig.mustache @@ -14,8 +14,7 @@ ] }, "files": [ - "index.ts", - "typings/index.d.ts" + "index.ts" ] } diff --git a/modules/openapi-generator/src/main/resources/typescript-jquery/typings.mustache b/modules/openapi-generator/src/main/resources/typescript-jquery/typings.mustache deleted file mode 100644 index 306cf301b884..000000000000 --- a/modules/openapi-generator/src/main/resources/typescript-jquery/typings.mustache +++ /dev/null @@ -1,10 +0,0 @@ -{ - "ambientDependencies": { - "bluebird": "registry:dt/bluebird#2.0.0+20160319051630", - "core-js": "registry:dt/core-js#0.0.0+20160317120654", - "node": "registry:dt/node#4.0.0+20160423143914" - }, - "globalDependencies": { - "jquery": "registry:dt/jquery#1.10.0+20170310222111" - } -} \ No newline at end of file diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/AbstractJavaCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/AbstractJavaCodegenTest.java index 014d6278afef..3db02060a1b7 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/AbstractJavaCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/AbstractJavaCodegenTest.java @@ -225,6 +225,19 @@ public class AbstractJavaCodegenTest { Assert.assertEquals(codegen.getArtifactVersion(), "1.0.7"); } + @Test(description = "tests if API version specification is used if no version is provided in additional properties with snapshot version") + public void openApiSnapShotVersionTest() { + final P_AbstractJavaCodegen codegen = new P_AbstractJavaCodegen(); + + codegen.additionalProperties().put("snapshotVersion", "true"); + + OpenAPI api = TestUtils.createOpenAPI(); + codegen.processOpts(); + codegen.preprocessOpenAPI(api); + + Assert.assertEquals(codegen.getArtifactVersion(), "1.0.7-SNAPSHOT"); + } + @Test(description = "tests if artifactVersion additional property is used") public void additionalPropertyArtifactVersionTest() { final P_AbstractJavaCodegen codegen = new P_AbstractJavaCodegen(); @@ -238,22 +251,42 @@ public class AbstractJavaCodegenTest { Assert.assertEquals(codegen.getArtifactVersion(), "1.1.1"); } + @Test(description = "tests if artifactVersion additional property is used with snapshot parameter") + public void additionalPropertyArtifactSnapShotVersionTest() { + final P_AbstractJavaCodegen codegen = new P_AbstractJavaCodegen(); + + codegen.additionalProperties().put("artifactVersion", "1.1.1"); + codegen.additionalProperties().put("snapshotVersion", "true"); + + OpenAPI api = TestUtils.createOpenAPI(); + codegen.processOpts(); + codegen.preprocessOpenAPI(api); + + Assert.assertEquals(codegen.getArtifactVersion(), "1.1.1-SNAPSHOT"); + } + @Test(description = "tests if default version is used when neither OpenAPI version nor artifactVersion additional property has been provided") public void defaultVersionTest() { final P_AbstractJavaCodegen codegen = new P_AbstractJavaCodegen(); + OpenAPI api = TestUtils.createOpenAPI(); + api.getInfo().setVersion(null); codegen.processOpts(); + codegen.preprocessOpenAPI(api); Assert.assertEquals(codegen.getArtifactVersion(), "1.0.0"); } - @Test(description = "tests if default version is used when neither OpenAPI version nor artifactVersion additional property has been provided") + @Test(description = "tests if default version with snapshot is used when neither OpenAPI version nor artifactVersion additional property has been provided") public void snapshotVersionTest() { final P_AbstractJavaCodegen codegen = new P_AbstractJavaCodegen(); codegen.additionalProperties().put("snapshotVersion", "true"); + OpenAPI api = TestUtils.createOpenAPI(); + api.getInfo().setVersion(null); codegen.processOpts(); + codegen.preprocessOpenAPI(api); Assert.assertEquals(codegen.getArtifactVersion(), "1.0.0-SNAPSHOT"); } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/jaxrs/JavaJaxrsBaseTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/jaxrs/JavaJaxrsBaseTest.java index d9ffb021b0b3..e76f0bf6fe91 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/jaxrs/JavaJaxrsBaseTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/jaxrs/JavaJaxrsBaseTest.java @@ -54,10 +54,14 @@ public abstract class JavaJaxrsBaseTest { } private void checkFileContains(MockDefaultGenerator generator, String path, String... lines) { - String file = generator.getFiles().get(path); + String file = linearize(generator.getFiles().get(path)); assertNotNull(file); for (String line : lines) - assertTrue(file.contains(line)); + assertTrue(file.contains(linearize(line))); + } + + private String linearize(String target) { + return target.replaceAll("\r?\n", "").replaceAll("\\s+", "\\s"); } @Test @@ -92,10 +96,10 @@ public abstract class JavaJaxrsBaseTest { } private void checkFileNotContains(MockDefaultGenerator generator, String path, String... lines) { - String file = generator.getFiles().get(path); + String file = linearize(generator.getFiles().get(path)); assertNotNull(file); for (String line : lines) - assertFalse(file.contains(line)); + assertFalse(file.contains(linearize(line))); } @Test diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java index 43bf0e830b1f..8059873a4533 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java @@ -25,6 +25,8 @@ import org.openapitools.codegen.languages.SpringCodegen; import org.testng.Assert; import org.testng.annotations.Test; +import static org.openapitools.codegen.languages.SpringCodegen.RESPONSE_WRAPPER; + public class SpringCodegenTest { @Test @@ -110,4 +112,14 @@ public class SpringCodegenTest { Assert.assertEquals(codegen.additionalProperties().get(SpringCodegen.TITLE), "someTest"); Assert.assertEquals(codegen.additionalProperties().get(SpringCodegen.SERVER_PORT), "8088"); } + + @Test + public void interfaceDefaultImplDisableWithReponseWrapper() { + final SpringCodegen codegen = new SpringCodegen(); + codegen.additionalProperties().put(SpringCodegen.JAVA_8, true); + codegen.additionalProperties().put(RESPONSE_WRAPPER, "aWrapper"); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get("jdk8"), 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 79818aee9767..a35a49c73882 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 @@ -28,8 +28,8 @@ public class TypeScriptAureliaClientOptionsProvider implements OptionsProvider { public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true"; public static final Boolean SUPPORTS_ES6_VALUE = false; public static final String MODEL_PROPERTY_NAMING_VALUE = "camelCase"; - private static final String NMP_NAME = "npmName"; - private static final String NMP_VERSION = "1.0.0"; + 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"; @@ -45,8 +45,9 @@ public class TypeScriptAureliaClientOptionsProvider implements OptionsProvider { .put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE) .put(CodegenConstants.MODEL_PROPERTY_NAMING, MODEL_PROPERTY_NAMING_VALUE) .put(CodegenConstants.SUPPORTS_ES6, String.valueOf(SUPPORTS_ES6_VALUE)) - .put(TypeScriptAureliaClientCodegen.NPM_NAME, NMP_NAME) - .put(TypeScriptAureliaClientCodegen.NPM_VERSION, NMP_VERSION) + .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) .build(); diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchClientCodegenTest.java index 80e21806a34e..2e18afea218f 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchClientCodegenTest.java @@ -1,5 +1,7 @@ package org.openapitools.codegen.typescript.fetch; +import io.swagger.v3.oas.models.OpenAPI; +import org.openapitools.codegen.TestUtils; import org.openapitools.codegen.languages.TypeScriptFetchClientCodegen; import org.testng.Assert; import org.testng.annotations.Test; @@ -8,11 +10,14 @@ import org.testng.annotations.Test; public class TypeScriptFetchClientCodegenTest { @Test public void testSnapshotVersion() { + OpenAPI api = TestUtils.createOpenAPI(); TypeScriptFetchClientCodegen codegen = new TypeScriptFetchClientCodegen(); + codegen.additionalProperties().put("npmName", "@openapi/typescript-fetch-petstore"); codegen.additionalProperties().put("snapshot", true); codegen.additionalProperties().put("npmVersion", "1.0.0-SNAPSHOT"); codegen.processOpts(); + codegen.preprocessOpenAPI(api); Assert.assertTrue(codegen.getNpmVersion().matches("^1.0.0-SNAPSHOT.[0-9]{12}$")); @@ -21,6 +26,7 @@ public class TypeScriptFetchClientCodegenTest { codegen.additionalProperties().put("snapshot", true); codegen.additionalProperties().put("npmVersion", "3.0.0-M1"); codegen.processOpts(); + codegen.preprocessOpenAPI(api); Assert.assertTrue(codegen.getNpmVersion().matches("^3.0.0-M1-SNAPSHOT.[0-9]{12}$")); @@ -28,11 +34,14 @@ public class TypeScriptFetchClientCodegenTest { @Test public void testWithoutSnapshotVersion() { + OpenAPI api = TestUtils.createOpenAPI(); TypeScriptFetchClientCodegen codegen = new TypeScriptFetchClientCodegen(); + codegen.additionalProperties().put("npmName", "@openapi/typescript-fetch-petstore"); codegen.additionalProperties().put("snapshot", false); codegen.additionalProperties().put("npmVersion", "1.0.0-SNAPSHOT"); codegen.processOpts(); + codegen.preprocessOpenAPI(api); Assert.assertTrue(codegen.getNpmVersion().matches("^1.0.0-SNAPSHOT$")); @@ -41,6 +50,7 @@ public class TypeScriptFetchClientCodegenTest { codegen.additionalProperties().put("snapshot", false); codegen.additionalProperties().put("npmVersion", "3.0.0-M1"); codegen.processOpts(); + codegen.preprocessOpenAPI(api); Assert.assertTrue(codegen.getNpmVersion().matches("^3.0.0-M1$")); diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptnode/TypeScriptNodeClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptnode/TypeScriptNodeClientCodegenTest.java index 50c16244cab5..93fb08719d7e 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptnode/TypeScriptNodeClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptnode/TypeScriptNodeClientCodegenTest.java @@ -1,5 +1,7 @@ package org.openapitools.codegen.typescript.typescriptnode; +import io.swagger.v3.oas.models.OpenAPI; +import org.openapitools.codegen.TestUtils; import org.openapitools.codegen.languages.TypeScriptNodeClientCodegen; import org.testng.Assert; import org.testng.annotations.Test; @@ -20,11 +22,14 @@ public class TypeScriptNodeClientCodegenTest { @Test public void testSnapshotVersion() { + OpenAPI api = TestUtils.createOpenAPI(); TypeScriptNodeClientCodegen codegen = new TypeScriptNodeClientCodegen(); + codegen.additionalProperties().put("npmName", "@openapi/typescript-angular-petstore"); codegen.additionalProperties().put("snapshot", true); codegen.additionalProperties().put("npmVersion", "1.0.0-SNAPSHOT"); codegen.processOpts(); + codegen.preprocessOpenAPI(api); Assert.assertTrue(codegen.getNpmVersion().matches("^1.0.0-SNAPSHOT.[0-9]{12}$")); @@ -33,6 +38,7 @@ public class TypeScriptNodeClientCodegenTest { codegen.additionalProperties().put("snapshot", true); codegen.additionalProperties().put("npmVersion", "3.0.0-M1"); codegen.processOpts(); + codegen.preprocessOpenAPI(api); Assert.assertTrue(codegen.getNpmVersion().matches("^3.0.0-M1-SNAPSHOT.[0-9]{12}$")); @@ -40,11 +46,14 @@ public class TypeScriptNodeClientCodegenTest { @Test public void testWithoutSnapshotVersion() { + OpenAPI api = TestUtils.createOpenAPI(); TypeScriptNodeClientCodegen codegen = new TypeScriptNodeClientCodegen(); + codegen.additionalProperties().put("npmName", "@openapi/typescript-angular-petstore"); codegen.additionalProperties().put("snapshot", false); codegen.additionalProperties().put("npmVersion", "1.0.0-SNAPSHOT"); codegen.processOpts(); + codegen.preprocessOpenAPI(api); Assert.assertTrue(codegen.getNpmVersion().matches("^1.0.0-SNAPSHOT$")); @@ -53,6 +62,7 @@ public class TypeScriptNodeClientCodegenTest { codegen.additionalProperties().put("snapshot", false); codegen.additionalProperties().put("npmVersion", "3.0.0-M1"); codegen.processOpts(); + codegen.preprocessOpenAPI(api); Assert.assertTrue(codegen.getNpmVersion().matches("^3.0.0-M1$")); diff --git a/pom.xml b/pom.xml index 57092603e6aa..f36c1ee758cd 100644 --- a/pom.xml +++ b/pom.xml @@ -1050,6 +1050,7 @@ samples/client/petstore/typescript-angular-v4/npm samples/client/petstore/typescript-angular-v4.3/npm samples/client/petstore/typescript-angular-v6-provided-in-root + samples/client/petstore/typescript-angular-v7-provided-in-root samples/server/petstore/rust-server samples/server/petstore/python-aiohttp @@ -1070,7 +1071,6 @@ samples/client/petstore/go - samples/client/petstore/typescript-angular-v6-provided-in-root samples/client/petstore/scala-httpclient diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/pubspec.yaml b/samples/client/petstore/dart/flutter_petstore/openapi/pubspec.yaml index d54efb46a2e4..79e5223fcd03 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/pubspec.yaml +++ b/samples/client/petstore/dart/flutter_petstore/openapi/pubspec.yaml @@ -2,4 +2,4 @@ name: openapi version: 1.0.0 description: OpenAPI API client dependencies: - http: '>=0.11.1 <0.12.0' + http: '>=0.11.1 <0.13.0' diff --git a/samples/client/petstore/dart/openapi-browser-client/pubspec.yaml b/samples/client/petstore/dart/openapi-browser-client/pubspec.yaml index d54efb46a2e4..79e5223fcd03 100644 --- a/samples/client/petstore/dart/openapi-browser-client/pubspec.yaml +++ b/samples/client/petstore/dart/openapi-browser-client/pubspec.yaml @@ -2,4 +2,4 @@ name: openapi version: 1.0.0 description: OpenAPI API client dependencies: - http: '>=0.11.1 <0.12.0' + http: '>=0.11.1 <0.13.0' diff --git a/samples/client/petstore/dart/openapi/pubspec.yaml b/samples/client/petstore/dart/openapi/pubspec.yaml index d54efb46a2e4..79e5223fcd03 100644 --- a/samples/client/petstore/dart/openapi/pubspec.yaml +++ b/samples/client/petstore/dart/openapi/pubspec.yaml @@ -2,4 +2,4 @@ name: openapi version: 1.0.0 description: OpenAPI API client dependencies: - http: '>=0.11.1 <0.12.0' + http: '>=0.11.1 <0.13.0' diff --git a/samples/client/petstore/groovy/src/main/groovy/org/openapitools/api/PetApi.groovy b/samples/client/petstore/groovy/src/main/groovy/org/openapitools/api/PetApi.groovy index c022982020af..60f3f7d45da1 100644 --- a/samples/client/petstore/groovy/src/main/groovy/org/openapitools/api/PetApi.groovy +++ b/samples/client/petstore/groovy/src/main/groovy/org/openapitools/api/PetApi.groovy @@ -18,24 +18,15 @@ class PetApi { def bodyParams def contentType - // verify required params are set if (body == null) { throw new RuntimeException("missing required params body") } - contentType = 'application/json'; - // only one body parameter - if (1 == 1) { - bodyParams = body - } - // array of body parameters - else { - bodyParams.put("body", body) - } + bodyParams = body apiUtils.invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, bodyParams, contentType, @@ -53,12 +44,10 @@ class PetApi { def bodyParams def contentType - // verify required params are set if (petId == null) { throw new RuntimeException("missing required params petId") } - if (apiKey != null) { @@ -82,12 +71,10 @@ class PetApi { def bodyParams def contentType - // verify required params are set if (status == null) { throw new RuntimeException("missing required params status") } - if (status != null) { queryParams.put("status", status) @@ -111,12 +98,10 @@ class PetApi { def bodyParams def contentType - // verify required params are set if (tags == null) { throw new RuntimeException("missing required params tags") } - if (tags != null) { queryParams.put("tags", tags) @@ -140,12 +125,10 @@ class PetApi { def bodyParams def contentType - // verify required params are set if (petId == null) { throw new RuntimeException("missing required params petId") } - @@ -166,24 +149,15 @@ class PetApi { def bodyParams def contentType - // verify required params are set if (body == null) { throw new RuntimeException("missing required params body") } - contentType = 'application/json'; - // only one body parameter - if (1 == 1) { - bodyParams = body - } - // array of body parameters - else { - bodyParams.put("body", body) - } + bodyParams = body apiUtils.invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, bodyParams, contentType, @@ -201,33 +175,18 @@ class PetApi { def bodyParams def contentType - // verify required params are set if (petId == null) { throw new RuntimeException("missing required params petId") } - contentType = 'application/x-www-form-urlencoded'; - // only one form parameter - if (1 == 2) { - bodyParams = name - } - // array of form parameters - else { - bodyParams = [:] - } - // array of form parameters - if (1 < 2) { - bodyParams.put("name", name) - } - // array of form parameters - if (1 < 2) { - bodyParams.put("status", status) - } + bodyParams = [:] + bodyParams.put("name", name) + bodyParams.put("status", status) apiUtils.invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, bodyParams, contentType, "POST", "", @@ -244,33 +203,18 @@ class PetApi { def bodyParams def contentType - // verify required params are set if (petId == null) { throw new RuntimeException("missing required params petId") } - contentType = 'multipart/form-data'; - // only one form parameter - if (1 == 2) { - bodyParams = additionalMetadata - } - // array of form parameters - else { - bodyParams = [:] - } - // array of form parameters - if (1 < 2) { - bodyParams.put("additionalMetadata", additionalMetadata) - } - // array of form parameters - if (1 < 2) { - bodyParams.put("file", file) - } + bodyParams = [:] + bodyParams.put("additionalMetadata", additionalMetadata) + bodyParams.put("file", file) apiUtils.invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, bodyParams, contentType, "POST", "", diff --git a/samples/client/petstore/groovy/src/main/groovy/org/openapitools/api/StoreApi.groovy b/samples/client/petstore/groovy/src/main/groovy/org/openapitools/api/StoreApi.groovy index 154551d18805..8e7a0ee9d279 100644 --- a/samples/client/petstore/groovy/src/main/groovy/org/openapitools/api/StoreApi.groovy +++ b/samples/client/petstore/groovy/src/main/groovy/org/openapitools/api/StoreApi.groovy @@ -17,12 +17,10 @@ class StoreApi { def bodyParams def contentType - // verify required params are set if (orderId == null) { throw new RuntimeException("missing required params orderId") } - @@ -43,7 +41,6 @@ class StoreApi { def bodyParams def contentType - @@ -64,12 +61,10 @@ class StoreApi { def bodyParams def contentType - // verify required params are set if (orderId == null) { throw new RuntimeException("missing required params orderId") } - @@ -90,24 +85,15 @@ class StoreApi { def bodyParams def contentType - // verify required params are set if (body == null) { throw new RuntimeException("missing required params body") } - contentType = 'application/json'; - // only one body parameter - if (1 == 1) { - bodyParams = body - } - // array of body parameters - else { - bodyParams.put("body", body) - } + bodyParams = body apiUtils.invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, bodyParams, contentType, diff --git a/samples/client/petstore/groovy/src/main/groovy/org/openapitools/api/UserApi.groovy b/samples/client/petstore/groovy/src/main/groovy/org/openapitools/api/UserApi.groovy index 2d0ec2ab73c3..8cc839868089 100644 --- a/samples/client/petstore/groovy/src/main/groovy/org/openapitools/api/UserApi.groovy +++ b/samples/client/petstore/groovy/src/main/groovy/org/openapitools/api/UserApi.groovy @@ -18,24 +18,15 @@ class UserApi { def bodyParams def contentType - // verify required params are set if (body == null) { throw new RuntimeException("missing required params body") } - contentType = 'application/json'; - // only one body parameter - if (1 == 1) { - bodyParams = body - } - // array of body parameters - else { - bodyParams.put("body", body) - } + bodyParams = body apiUtils.invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, bodyParams, contentType, @@ -53,24 +44,15 @@ class UserApi { def bodyParams def contentType - // verify required params are set if (body == null) { throw new RuntimeException("missing required params body") } - contentType = 'application/json'; - // only one body parameter - if (1 == 1) { - bodyParams = body - } - // array of body parameters - else { - bodyParams.put("body", body) - } + bodyParams = body apiUtils.invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, bodyParams, contentType, @@ -88,24 +70,15 @@ class UserApi { def bodyParams def contentType - // verify required params are set if (body == null) { throw new RuntimeException("missing required params body") } - contentType = 'application/json'; - // only one body parameter - if (1 == 1) { - bodyParams = body - } - // array of body parameters - else { - bodyParams.put("body", body) - } + bodyParams = body apiUtils.invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, bodyParams, contentType, @@ -123,12 +96,10 @@ class UserApi { def bodyParams def contentType - // verify required params are set if (username == null) { throw new RuntimeException("missing required params username") } - @@ -149,12 +120,10 @@ class UserApi { def bodyParams def contentType - // verify required params are set if (username == null) { throw new RuntimeException("missing required params username") } - @@ -175,17 +144,14 @@ class UserApi { def bodyParams def contentType - // verify required params are set if (username == null) { throw new RuntimeException("missing required params username") } - // verify required params are set if (password == null) { throw new RuntimeException("missing required params password") } - if (username != null) { queryParams.put("username", username) @@ -212,7 +178,6 @@ class UserApi { def bodyParams def contentType - @@ -233,29 +198,19 @@ class UserApi { def bodyParams def contentType - // verify required params are set if (username == null) { throw new RuntimeException("missing required params username") } - // verify required params are set if (body == null) { throw new RuntimeException("missing required params body") } - contentType = 'application/json'; - // only one body parameter - if (1 == 1) { - bodyParams = body - } - // array of body parameters - else { - bodyParams.put("body", body) - } + bodyParams = body apiUtils.invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, bodyParams, contentType, diff --git a/samples/client/petstore/typescript-angular-v2/npm/typings.json b/samples/client/petstore/typescript-angular-v2/npm/typings.json deleted file mode 100644 index 507c40e5cbed..000000000000 --- a/samples/client/petstore/typescript-angular-v2/npm/typings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "globalDependencies": { - "core-js": "registry:dt/core-js#0.0.0+20160725163759" - } -} diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/typings.json b/samples/client/petstore/typescript-angular-v2/with-interfaces/typings.json deleted file mode 100644 index 507c40e5cbed..000000000000 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/typings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "globalDependencies": { - "core-js": "registry:dt/core-js#0.0.0+20160725163759" - } -} diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/typings.json b/samples/client/petstore/typescript-angular-v4.3/npm/typings.json deleted file mode 100644 index 507c40e5cbed..000000000000 --- a/samples/client/petstore/typescript-angular-v4.3/npm/typings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "globalDependencies": { - "core-js": "registry:dt/core-js#0.0.0+20160725163759" - } -} diff --git a/samples/client/petstore/typescript-angular-v4/npm/typings.json b/samples/client/petstore/typescript-angular-v4/npm/typings.json deleted file mode 100644 index 507c40e5cbed..000000000000 --- a/samples/client/petstore/typescript-angular-v4/npm/typings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "globalDependencies": { - "core-js": "registry:dt/core-js#0.0.0+20160725163759" - } -} diff --git a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/typings.json b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/typings.json deleted file mode 100644 index 507c40e5cbed..000000000000 --- a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/typings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "globalDependencies": { - "core-js": "registry:dt/core-js#0.0.0+20160725163759" - } -} diff --git a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/typings.json b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/typings.json deleted file mode 100644 index 507c40e5cbed..000000000000 --- a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/typings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "globalDependencies": { - "core-js": "registry:dt/core-js#0.0.0+20160725163759" - } -} diff --git a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/typings.json b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/typings.json deleted file mode 100644 index 507c40e5cbed..000000000000 --- a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/typings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "globalDependencies": { - "core-js": "registry:dt/core-js#0.0.0+20160725163759" - } -} diff --git a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/typings.json b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/typings.json deleted file mode 100644 index 507c40e5cbed..000000000000 --- a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/typings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "globalDependencies": { - "core-js": "registry:dt/core-js#0.0.0+20160725163759" - } -} diff --git a/samples/client/petstore/typescript-angular-v7-provided-in-root/tests/default/src/app/app.component.spec.ts b/samples/client/petstore/typescript-angular-v7-provided-in-root/tests/default/src/app/app.component.spec.ts index e82f9f0c32d3..fd77f0b021c5 100644 --- a/samples/client/petstore/typescript-angular-v7-provided-in-root/tests/default/src/app/app.component.spec.ts +++ b/samples/client/petstore/typescript-angular-v7-provided-in-root/tests/default/src/app/app.component.spec.ts @@ -14,7 +14,7 @@ describe('AppComponent', () => { const apiConfigurationParams: ConfigurationParameters = { // add configuration params here - apiKeys: { api_key: "foobar" }, + apiKeys: { api_key: 'foobar' }, }; const apiConfig = new Configuration(apiConfigurationParams); @@ -47,17 +47,17 @@ describe('AppComponent', () => { expect(app).toBeTruthy(); })); - it(`should have as title 'Typescript Angular v6 (provided in root)'`, async(() => { + it(`should have as title 'Typescript Angular v7 (provided in root)'`, async(() => { const fixture = TestBed.createComponent(AppComponent); const app = fixture.debugElement.componentInstance; - expect(app.title).toEqual('Typescript Angular v6 (provided in root)'); + expect(app.title).toEqual('Typescript Angular v7 (provided in root)'); })); it('should render title in a h1 tag', async(() => { const fixture = TestBed.createComponent(AppComponent); fixture.detectChanges(); const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain('Welcome to Typescript Angular v6 (provided in root)!'); + expect(compiled.querySelector('h1').textContent).toContain('Welcome to Typescript Angular v7 (provided in root)!'); })); describe(`constructor()`, () => { diff --git a/samples/client/petstore/typescript-angular-v7-provided-in-root/tests/default/src/app/app.component.ts b/samples/client/petstore/typescript-angular-v7-provided-in-root/tests/default/src/app/app.component.ts index 01b6bcb3860e..0259ba12434a 100644 --- a/samples/client/petstore/typescript-angular-v7-provided-in-root/tests/default/src/app/app.component.ts +++ b/samples/client/petstore/typescript-angular-v7-provided-in-root/tests/default/src/app/app.component.ts @@ -12,7 +12,7 @@ import { styleUrls: ['./app.component.css'] }) export class AppComponent { - title = 'Typescript Angular v6 (provided in root)'; + title = 'Typescript Angular v7 (provided in root)'; pet: Pet; store: { key: string, number: number }[]; diff --git a/samples/client/petstore/typescript-angular-v7-provided-in-root/tests/default/src/test/api.spec.ts b/samples/client/petstore/typescript-angular-v7-provided-in-root/tests/default/src/test/api.spec.ts index 5607deb8a058..257819350720 100644 --- a/samples/client/petstore/typescript-angular-v7-provided-in-root/tests/default/src/test/api.spec.ts +++ b/samples/client/petstore/typescript-angular-v7-provided-in-root/tests/default/src/test/api.spec.ts @@ -36,7 +36,7 @@ describe(`API (functionality)`, () => { const apiConfigurationParams: ConfigurationParameters = { // add configuration params here - apiKeys: { api_key: "foobar" } + apiKeys: { api_key: 'foobar' } }; const apiConfig = new Configuration(apiConfigurationParams); @@ -109,6 +109,23 @@ describe(`API (functionality)`, () => { ); })); + it(`should update the pet name by form`, async(() => { + const petService = TestBed.get(PetService); + const newName = `pet-${Date.now()}`; + createdPet.name = newName; + + petService.updatePetWithForm(createdPet.id, createdPet.name).subscribe( + result => expect(result).toBeFalsy(), + error => fail(`expected a result, not the error: ${error.message}`), + ); + + return petService.getPetById(createdPet.id).subscribe( + result => expect(result.name).toEqual(createdPet.name), + error => fail(`expected a result, not the error: ${error.message}`), + ); + + })); + it(`should delete the pet`, async(() => { const petService = TestBed.get(PetService); diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/default/models/Category.ts index 99df10e5f1a8..f8809dccbea3 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/Category.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/Category.ts @@ -11,7 +11,7 @@ * Do not edit the class manually. */ -import { exists } from '../runtime'; +import { exists, mapValues } from '../runtime'; /** * A category for a pet * @export diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/ModelApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/default/models/ModelApiResponse.ts index 369973446b9a..8b8e2c45fecd 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/ModelApiResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/ModelApiResponse.ts @@ -11,7 +11,7 @@ * Do not edit the class manually. */ -import { exists } from '../runtime'; +import { exists, mapValues } from '../runtime'; /** * Describes the result of uploading an image resource * @export diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/default/models/Order.ts index ef002a60fc9c..6ce0496794f6 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/Order.ts @@ -11,7 +11,7 @@ * Do not edit the class manually. */ -import { exists } from '../runtime'; +import { exists, mapValues } from '../runtime'; /** * An order for a pets from the pet store * @export diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/default/models/Pet.ts index 27de4cee46bf..770f991b89d9 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/Pet.ts @@ -11,7 +11,7 @@ * Do not edit the class manually. */ -import { exists } from '../runtime'; +import { exists, mapValues } from '../runtime'; import { Category, CategoryFromJSON, diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/default/models/Tag.ts index a7dd45562096..7c8098f6dc01 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/Tag.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/Tag.ts @@ -11,7 +11,7 @@ * Do not edit the class manually. */ -import { exists } from '../runtime'; +import { exists, mapValues } from '../runtime'; /** * A tag for a pet * @export diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/User.ts b/samples/client/petstore/typescript-fetch/builds/default/models/User.ts index f42cf94d748d..fd7430063f1c 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/User.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/User.ts @@ -11,7 +11,7 @@ * Do not edit the class manually. */ -import { exists } from '../runtime'; +import { exists, mapValues } from '../runtime'; /** * A User who is purchasing from the pet store * @export diff --git a/samples/client/petstore/typescript-fetch/builds/default/runtime.ts b/samples/client/petstore/typescript-fetch/builds/default/runtime.ts index 3af222044b24..67a45b169fde 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/runtime.ts @@ -213,6 +213,13 @@ export function querystring(params: HTTPQuery, prefix: string = ''): string { .join('&'); } +export function mapValues(data: any, fn: (item: any) => any) { + return Object.keys(data).reduce( + (acc, key) => ({ ...acc, [key]: fn(data[key]) }), + {} + ); +} + export interface RequestContext { fetch: FetchAPI; url: string; diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Category.ts index 99df10e5f1a8..f8809dccbea3 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Category.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Category.ts @@ -11,7 +11,7 @@ * Do not edit the class manually. */ -import { exists } from '../runtime'; +import { exists, mapValues } from '../runtime'; /** * A category for a pet * @export diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/ModelApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/ModelApiResponse.ts index 369973446b9a..8b8e2c45fecd 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/models/ModelApiResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/ModelApiResponse.ts @@ -11,7 +11,7 @@ * Do not edit the class manually. */ -import { exists } from '../runtime'; +import { exists, mapValues } from '../runtime'; /** * Describes the result of uploading an image resource * @export diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Order.ts index ef002a60fc9c..6ce0496794f6 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Order.ts @@ -11,7 +11,7 @@ * Do not edit the class manually. */ -import { exists } from '../runtime'; +import { exists, mapValues } from '../runtime'; /** * An order for a pets from the pet store * @export diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Pet.ts index 27de4cee46bf..770f991b89d9 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Pet.ts @@ -11,7 +11,7 @@ * Do not edit the class manually. */ -import { exists } from '../runtime'; +import { exists, mapValues } from '../runtime'; import { Category, CategoryFromJSON, diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Tag.ts index a7dd45562096..7c8098f6dc01 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/models/Tag.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/Tag.ts @@ -11,7 +11,7 @@ * Do not edit the class manually. */ -import { exists } from '../runtime'; +import { exists, mapValues } from '../runtime'; /** * A tag for a pet * @export diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/models/User.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/models/User.ts index f42cf94d748d..fd7430063f1c 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/models/User.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/models/User.ts @@ -11,7 +11,7 @@ * Do not edit the class manually. */ -import { exists } from '../runtime'; +import { exists, mapValues } from '../runtime'; /** * A User who is purchasing from the pet store * @export diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts index 3af222044b24..67a45b169fde 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts @@ -213,6 +213,13 @@ export function querystring(params: HTTPQuery, prefix: string = ''): string { .join('&'); } +export function mapValues(data: any, fn: (item: any) => any) { + return Object.keys(data).reduce( + (acc, key) => ({ ...acc, [key]: fn(data[key]) }), + {} + ); +} + export interface RequestContext { fetch: FetchAPI; url: string; diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Category.ts index 99df10e5f1a8..f8809dccbea3 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Category.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Category.ts @@ -11,7 +11,7 @@ * Do not edit the class manually. */ -import { exists } from '../runtime'; +import { exists, mapValues } from '../runtime'; /** * A category for a pet * @export diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/ModelApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/ModelApiResponse.ts index 369973446b9a..8b8e2c45fecd 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/ModelApiResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/ModelApiResponse.ts @@ -11,7 +11,7 @@ * Do not edit the class manually. */ -import { exists } from '../runtime'; +import { exists, mapValues } from '../runtime'; /** * Describes the result of uploading an image resource * @export diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Order.ts index ef002a60fc9c..6ce0496794f6 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Order.ts @@ -11,7 +11,7 @@ * Do not edit the class manually. */ -import { exists } from '../runtime'; +import { exists, mapValues } from '../runtime'; /** * An order for a pets from the pet store * @export diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Pet.ts index 27de4cee46bf..770f991b89d9 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Pet.ts @@ -11,7 +11,7 @@ * Do not edit the class manually. */ -import { exists } from '../runtime'; +import { exists, mapValues } from '../runtime'; import { Category, CategoryFromJSON, diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Tag.ts index a7dd45562096..7c8098f6dc01 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Tag.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Tag.ts @@ -11,7 +11,7 @@ * Do not edit the class manually. */ -import { exists } from '../runtime'; +import { exists, mapValues } from '../runtime'; /** * A tag for a pet * @export diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/User.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/User.ts index f42cf94d748d..fd7430063f1c 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/User.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/User.ts @@ -11,7 +11,7 @@ * Do not edit the class manually. */ -import { exists } from '../runtime'; +import { exists, mapValues } from '../runtime'; /** * A User who is purchasing from the pet store * @export diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts index 3af222044b24..67a45b169fde 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts @@ -213,6 +213,13 @@ export function querystring(params: HTTPQuery, prefix: string = ''): string { .join('&'); } +export function mapValues(data: any, fn: (item: any) => any) { + return Object.keys(data).reduce( + (acc, key) => ({ ...acc, [key]: fn(data[key]) }), + {} + ); +} + export interface RequestContext { fetch: FetchAPI; url: string; diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Category.ts index 99df10e5f1a8..f8809dccbea3 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Category.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Category.ts @@ -11,7 +11,7 @@ * Do not edit the class manually. */ -import { exists } from '../runtime'; +import { exists, mapValues } from '../runtime'; /** * A category for a pet * @export diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/ModelApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/ModelApiResponse.ts index 369973446b9a..8b8e2c45fecd 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/ModelApiResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/ModelApiResponse.ts @@ -11,7 +11,7 @@ * Do not edit the class manually. */ -import { exists } from '../runtime'; +import { exists, mapValues } from '../runtime'; /** * Describes the result of uploading an image resource * @export diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Order.ts index ef002a60fc9c..6ce0496794f6 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Order.ts @@ -11,7 +11,7 @@ * Do not edit the class manually. */ -import { exists } from '../runtime'; +import { exists, mapValues } from '../runtime'; /** * An order for a pets from the pet store * @export diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Pet.ts index 27de4cee46bf..770f991b89d9 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Pet.ts @@ -11,7 +11,7 @@ * Do not edit the class manually. */ -import { exists } from '../runtime'; +import { exists, mapValues } from '../runtime'; import { Category, CategoryFromJSON, diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Tag.ts index a7dd45562096..7c8098f6dc01 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Tag.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/Tag.ts @@ -11,7 +11,7 @@ * Do not edit the class manually. */ -import { exists } from '../runtime'; +import { exists, mapValues } from '../runtime'; /** * A tag for a pet * @export diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/User.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/User.ts index f42cf94d748d..fd7430063f1c 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/User.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/models/User.ts @@ -11,7 +11,7 @@ * Do not edit the class manually. */ -import { exists } from '../runtime'; +import { exists, mapValues } from '../runtime'; /** * A User who is purchasing from the pet store * @export diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/runtime.ts index 3af222044b24..67a45b169fde 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/runtime.ts @@ -213,6 +213,13 @@ export function querystring(params: HTTPQuery, prefix: string = ''): string { .join('&'); } +export function mapValues(data: any, fn: (item: any) => any) { + return Object.keys(data).reduce( + (acc, key) => ({ ...acc, [key]: fn(data[key]) }), + {} + ); +} + export interface RequestContext { fetch: FetchAPI; url: string; diff --git a/samples/client/petstore/typescript-jquery/default/git_push.sh b/samples/client/petstore/typescript-jquery/default/git_push.sh index 8442b80bb445..d90bf7f1e1e0 100644 --- a/samples/client/petstore/typescript-jquery/default/git_push.sh +++ b/samples/client/petstore/typescript-jquery/default/git_push.sh @@ -1,7 +1,7 @@ #!/bin/sh # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ # -# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-typescript-jquery "minor update" git_user_id=$1 git_repo_id=$2 diff --git a/samples/client/petstore/typescript-jquery/npm/README.md b/samples/client/petstore/typescript-jquery/npm/README.md index cfd8c761a440..c5d3edc9b4b6 100644 --- a/samples/client/petstore/typescript-jquery/npm/README.md +++ b/samples/client/petstore/typescript-jquery/npm/README.md @@ -15,7 +15,7 @@ Module system * CommonJS * ES6 module system -It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html)) +It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html)) ### Building diff --git a/samples/client/petstore/typescript-jquery/npm/git_push.sh b/samples/client/petstore/typescript-jquery/npm/git_push.sh index 8442b80bb445..d90bf7f1e1e0 100644 --- a/samples/client/petstore/typescript-jquery/npm/git_push.sh +++ b/samples/client/petstore/typescript-jquery/npm/git_push.sh @@ -1,7 +1,7 @@ #!/bin/sh # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ # -# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-typescript-jquery "minor update" git_user_id=$1 git_repo_id=$2 diff --git a/samples/client/petstore/typescript-jquery/npm/package.json b/samples/client/petstore/typescript-jquery/npm/package.json index 0ab26b0f31fb..7fb297b8633b 100644 --- a/samples/client/petstore/typescript-jquery/npm/package.json +++ b/samples/client/petstore/typescript-jquery/npm/package.json @@ -11,13 +11,13 @@ "dependencies": { "bluebird": "^3.3.5", "request": "^2.72.0", - "jquery": "^3.1.1" + "jquery": "^3.1" }, "devDependencies": { - "typescript": "2.2.2", - "typings": "^1.3.0" + "@types/jquery": "^3.1", + "typescript": "^2.4" }, - "publishConfig":{ - "registry":"https://skimdb.npmjs.com/registry" + "publishConfig": { + "registry": "https://skimdb.npmjs.com/registry" } } diff --git a/samples/client/petstore/typescript-jquery/npm/tsconfig.json b/samples/client/petstore/typescript-jquery/npm/tsconfig.json index c11ec54d7ca9..8df90ec7395e 100644 --- a/samples/client/petstore/typescript-jquery/npm/tsconfig.json +++ b/samples/client/petstore/typescript-jquery/npm/tsconfig.json @@ -14,8 +14,7 @@ ] }, "files": [ - "index.ts", - "typings/index.d.ts" + "index.ts" ] } diff --git a/samples/client/petstore/typescript-jquery/npm/typings.json b/samples/client/petstore/typescript-jquery/npm/typings.json deleted file mode 100644 index 306cf301b884..000000000000 --- a/samples/client/petstore/typescript-jquery/npm/typings.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "ambientDependencies": { - "bluebird": "registry:dt/bluebird#2.0.0+20160319051630", - "core-js": "registry:dt/core-js#0.0.0+20160317120654", - "node": "registry:dt/node#4.0.0+20160423143914" - }, - "globalDependencies": { - "jquery": "registry:dt/jquery#1.10.0+20170310222111" - } -} \ No newline at end of file diff --git a/samples/meta-codegen/lib/pom.xml b/samples/meta-codegen/lib/pom.xml index 2e9dd45df1d6..f4411133f5fd 100644 --- a/samples/meta-codegen/lib/pom.xml +++ b/samples/meta-codegen/lib/pom.xml @@ -113,11 +113,6 @@ ${openapi-generator-version} provided - - org.openapitools - openapi-generator-cli - ${openapi-generator-version} - junit junit diff --git a/samples/meta-codegen/lib/src/test/java/com/my/company/codegen/MyclientcodegenGeneratorTest.java b/samples/meta-codegen/lib/src/test/java/com/my/company/codegen/MyclientcodegenGeneratorTest.java new file mode 100644 index 000000000000..cc5c81030107 --- /dev/null +++ b/samples/meta-codegen/lib/src/test/java/com/my/company/codegen/MyclientcodegenGeneratorTest.java @@ -0,0 +1,36 @@ +package com.my.company.codegen; + +import org.junit.Test; +import org.openapitools.codegen.ClientOptInput; +import org.openapitools.codegen.DefaultGenerator; +import org.openapitools.codegen.config.CodegenConfigurator; + +/*** + * This test allows you to easily launch your code generation software under a debugger. + * Then run this test under debug mode. You will be able to step through your java code + * and then see the results in the out directory. + * + * To experiment with debugging your code generator: + * 1) Set a break point in MyclientcodegenGenerator.java in the postProcessOperationsWithModels() method. + * 2) To launch this test in Eclipse: right-click | Debug As | JUnit Test + * + */ +public class MyclientcodegenGeneratorTest { + + // use this test to launch you code generator in the debugger. + // this allows you to easily set break points in MyclientcodegenGenerator. + @Test + public void launchCodeGenerator() { + // to understand how the 'openapi-generator-cli' module is using 'CodegenConfigurator', have a look at the 'Generate' class: + // https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Generate.java + final CodegenConfigurator configurator = new CodegenConfigurator() + .setGeneratorName("myClientCodegen") // use this codegen library + .setInputSpec("../../../modules/openapi-generator/src/test/resources/2_0/petstore.yaml") // sample OpenAPI file + // .setInputSpec("https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml") // or from the server + .setOutputDir("out/myClientCodegen"); // output directory + + final ClientOptInput clientOptInput = configurator.toClientOptInput(); + DefaultGenerator generator = new DefaultGenerator(); + generator.opts(clientOptInput).generate(); + } +} \ No newline at end of file diff --git a/samples/meta-codegen/lib/src/test/java/org/openapitools/codegen/debug/DebugCodegenLauncher.java b/samples/meta-codegen/lib/src/test/java/org/openapitools/codegen/debug/DebugCodegenLauncher.java deleted file mode 100644 index 46f2e3e314e7..000000000000 --- a/samples/meta-codegen/lib/src/test/java/org/openapitools/codegen/debug/DebugCodegenLauncher.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.openapitools.codegen.debug; - -import org.junit.Test; -import org.openapitools.codegen.OpenAPIGenerator; - -/*** - * This test allows you to easily launch your code generation software under a debugger. - * Then run this test under debug mode. You will be able to step through your java code - * and then see the results in the out directory. - * - * To experiment with debugging your code generator: - * 1) Set a break point in MyclientcodegenGenerator.java in the postProcessOperationsWithModels() method. - * 2) To launch this test in Eclipse: right-click | Debug As | JUnit Test - * - */ -public class DebugCodegenLauncher -{ - @Test - public void launchCodeGeneratorInDebugMode() - { - // use this test to launch you code generator in the debugger. - // this allows you to easily set break points in MyclientcodegenGenerator. - String commandLineParams = - "generate "+ - "-i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml "+ // sample swagger - "-t ./src/main/resources/myClientCodegen "+ // template directory - "-o out/myClientCodegen "+ // output directory - "-g myClientCodegen "; // use this codegen library - - try{ - OpenAPIGenerator.main( commandLineParams.split(" ") ); - } - catch(Exception ex) { - System.err.println(ex.toString()); - } - catch(Error er) { - System.err.println(er.toString()); - } - } -} \ No newline at end of file diff --git a/samples/meta-codegen/pom.xml b/samples/meta-codegen/pom.xml index fc3ad25673e3..530637969a71 100644 --- a/samples/meta-codegen/pom.xml +++ b/samples/meta-codegen/pom.xml @@ -8,5 +8,6 @@ lib/ ../../modules/openapi-generator + ../../modules/openapi-generator-core diff --git a/samples/openapi3/client/petstore/ruby/README.md b/samples/openapi3/client/petstore/ruby/README.md index 80fd4176e9a9..6fb930ed9a88 100644 --- a/samples/openapi3/client/petstore/ruby/README.md +++ b/samples/openapi3/client/petstore/ruby/README.md @@ -180,7 +180,7 @@ Class | Method | HTTP request | Description ### bearer_test -- **Type**: HTTP basic authentication +- **Type**: Bearer authentication (JWT) ### http_basic_test diff --git a/samples/openapi3/client/petstore/ruby/docs/FakeApi.md b/samples/openapi3/client/petstore/ruby/docs/FakeApi.md index b1168cc938c3..ab79170143b9 100644 --- a/samples/openapi3/client/petstore/ruby/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/ruby/docs/FakeApi.md @@ -547,9 +547,8 @@ Fake endpoint to test group parameters (optional) require 'petstore' # setup authorization Petstore.configure do |config| - # Configure HTTP basic authorization: bearer_test - config.username = 'YOUR USERNAME' - config.password = 'YOUR PASSWORD' + # Configure Bearer authorization (JWT): bearer_test + config.access_token = 'YOUR_BEARER_TOKEN' end api_instance = Petstore::FakeApi.new diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/configuration.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/configuration.rb index af5b62e60036..845abb090c59 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/configuration.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/configuration.rb @@ -212,10 +212,11 @@ module Petstore }, 'bearer_test' => { - type: 'basic', + type: 'bearer', in: 'header', + format: 'JWT', key: 'Authorization', - value: basic_auth_token + value: "Bearer #{access_token}" }, 'http_basic_test' => { diff --git a/samples/server/petstore/cpp-pistache/api/PetApi.cpp b/samples/server/petstore/cpp-pistache/api/PetApi.cpp index 5ffab955c55c..5ef93e9f73e2 100644 --- a/samples/server/petstore/cpp-pistache/api/PetApi.cpp +++ b/samples/server/petstore/cpp-pistache/api/PetApi.cpp @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -54,10 +54,14 @@ void PetApi::add_pet_handler(const Pistache::Rest::Request &request, Pistache::H try { nlohmann::json::parse(request.body()).get_to(body); this->add_pet(body, response); - } catch (std::runtime_error & e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + } catch (nlohmann::detail::exception &e) { + //send a 400 error + response.send(Pistache::Http::Code::Bad_Request, e.what()); + return; + } catch (std::runtime_error &e) { + //send a 500 error + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + return; } } @@ -70,10 +74,14 @@ void PetApi::delete_pet_handler(const Pistache::Rest::Request &request, Pistache try { this->delete_pet(petId, apiKey, response); - } catch (std::runtime_error & e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + } catch (nlohmann::detail::exception &e) { + //send a 400 error + response.send(Pistache::Http::Code::Bad_Request, e.what()); + return; + } catch (std::runtime_error &e) { + //send a 500 error + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + return; } } @@ -91,10 +99,14 @@ void PetApi::find_pets_by_status_handler(const Pistache::Rest::Request &request, try { this->find_pets_by_status(status, response); - } catch (std::runtime_error & e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + } catch (nlohmann::detail::exception &e) { + //send a 400 error + response.send(Pistache::Http::Code::Bad_Request, e.what()); + return; + } catch (std::runtime_error &e) { + //send a 500 error + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + return; } } @@ -112,10 +124,14 @@ void PetApi::find_pets_by_tags_handler(const Pistache::Rest::Request &request, P try { this->find_pets_by_tags(tags, response); - } catch (std::runtime_error & e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + } catch (nlohmann::detail::exception &e) { + //send a 400 error + response.send(Pistache::Http::Code::Bad_Request, e.what()); + return; + } catch (std::runtime_error &e) { + //send a 500 error + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + return; } } @@ -125,10 +141,14 @@ void PetApi::get_pet_by_id_handler(const Pistache::Rest::Request &request, Pista try { this->get_pet_by_id(petId, response); - } catch (std::runtime_error & e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + } catch (nlohmann::detail::exception &e) { + //send a 400 error + response.send(Pistache::Http::Code::Bad_Request, e.what()); + return; + } catch (std::runtime_error &e) { + //send a 500 error + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + return; } } @@ -141,30 +161,42 @@ void PetApi::update_pet_handler(const Pistache::Rest::Request &request, Pistache try { nlohmann::json::parse(request.body()).get_to(body); this->update_pet(body, response); - } catch (std::runtime_error & e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + } catch (nlohmann::detail::exception &e) { + //send a 400 error + response.send(Pistache::Http::Code::Bad_Request, e.what()); + return; + } catch (std::runtime_error &e) { + //send a 500 error + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + return; } } void PetApi::update_pet_with_form_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { try { this->update_pet_with_form(request, response); - } catch (std::runtime_error & e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + } catch (nlohmann::detail::exception &e) { + //send a 400 error + response.send(Pistache::Http::Code::Bad_Request, e.what()); + return; + } catch (std::runtime_error &e) { + //send a 500 error + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + return; } } void PetApi::upload_file_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { try { this->upload_file(request, response); - } catch (std::runtime_error & e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + } catch (nlohmann::detail::exception &e) { + //send a 400 error + response.send(Pistache::Http::Code::Bad_Request, e.what()); + return; + } catch (std::runtime_error &e) { + //send a 500 error + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + return; } } diff --git a/samples/server/petstore/cpp-pistache/api/PetApi.h b/samples/server/petstore/cpp-pistache/api/PetApi.h index c84ca384279e..d991d13abaed 100644 --- a/samples/server/petstore/cpp-pistache/api/PetApi.h +++ b/samples/server/petstore/cpp-pistache/api/PetApi.h @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/samples/server/petstore/cpp-pistache/api/StoreApi.cpp b/samples/server/petstore/cpp-pistache/api/StoreApi.cpp index 98e4d387a190..6987e9cc8538 100644 --- a/samples/server/petstore/cpp-pistache/api/StoreApi.cpp +++ b/samples/server/petstore/cpp-pistache/api/StoreApi.cpp @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -47,10 +47,14 @@ void StoreApi::delete_order_handler(const Pistache::Rest::Request &request, Pist try { this->delete_order(orderId, response); - } catch (std::runtime_error & e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + } catch (nlohmann::detail::exception &e) { + //send a 400 error + response.send(Pistache::Http::Code::Bad_Request, e.what()); + return; + } catch (std::runtime_error &e) { + //send a 500 error + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + return; } } @@ -58,10 +62,14 @@ void StoreApi::get_inventory_handler(const Pistache::Rest::Request &request, Pis try { this->get_inventory(response); - } catch (std::runtime_error & e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + } catch (nlohmann::detail::exception &e) { + //send a 400 error + response.send(Pistache::Http::Code::Bad_Request, e.what()); + return; + } catch (std::runtime_error &e) { + //send a 500 error + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + return; } } @@ -71,10 +79,14 @@ void StoreApi::get_order_by_id_handler(const Pistache::Rest::Request &request, P try { this->get_order_by_id(orderId, response); - } catch (std::runtime_error & e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + } catch (nlohmann::detail::exception &e) { + //send a 400 error + response.send(Pistache::Http::Code::Bad_Request, e.what()); + return; + } catch (std::runtime_error &e) { + //send a 500 error + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + return; } } @@ -87,10 +99,14 @@ void StoreApi::place_order_handler(const Pistache::Rest::Request &request, Pista try { nlohmann::json::parse(request.body()).get_to(body); this->place_order(body, response); - } catch (std::runtime_error & e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + } catch (nlohmann::detail::exception &e) { + //send a 400 error + response.send(Pistache::Http::Code::Bad_Request, e.what()); + return; + } catch (std::runtime_error &e) { + //send a 500 error + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + return; } } diff --git a/samples/server/petstore/cpp-pistache/api/StoreApi.h b/samples/server/petstore/cpp-pistache/api/StoreApi.h index cde0755f1383..f69875c4678d 100644 --- a/samples/server/petstore/cpp-pistache/api/StoreApi.h +++ b/samples/server/petstore/cpp-pistache/api/StoreApi.h @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/samples/server/petstore/cpp-pistache/api/UserApi.cpp b/samples/server/petstore/cpp-pistache/api/UserApi.cpp index f539a61c7e96..f64232454a2c 100644 --- a/samples/server/petstore/cpp-pistache/api/UserApi.cpp +++ b/samples/server/petstore/cpp-pistache/api/UserApi.cpp @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -54,10 +54,14 @@ void UserApi::create_user_handler(const Pistache::Rest::Request &request, Pistac try { nlohmann::json::parse(request.body()).get_to(body); this->create_user(body, response); - } catch (std::runtime_error & e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + } catch (nlohmann::detail::exception &e) { + //send a 400 error + response.send(Pistache::Http::Code::Bad_Request, e.what()); + return; + } catch (std::runtime_error &e) { + //send a 500 error + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + return; } } @@ -69,10 +73,14 @@ void UserApi::create_users_with_array_input_handler(const Pistache::Rest::Reques try { nlohmann::json::parse(request.body()).get_to(body); this->create_users_with_array_input(body, response); - } catch (std::runtime_error & e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + } catch (nlohmann::detail::exception &e) { + //send a 400 error + response.send(Pistache::Http::Code::Bad_Request, e.what()); + return; + } catch (std::runtime_error &e) { + //send a 500 error + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + return; } } @@ -84,10 +92,14 @@ void UserApi::create_users_with_list_input_handler(const Pistache::Rest::Request try { nlohmann::json::parse(request.body()).get_to(body); this->create_users_with_list_input(body, response); - } catch (std::runtime_error & e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + } catch (nlohmann::detail::exception &e) { + //send a 400 error + response.send(Pistache::Http::Code::Bad_Request, e.what()); + return; + } catch (std::runtime_error &e) { + //send a 500 error + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + return; } } @@ -97,10 +109,14 @@ void UserApi::delete_user_handler(const Pistache::Rest::Request &request, Pistac try { this->delete_user(username, response); - } catch (std::runtime_error & e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + } catch (nlohmann::detail::exception &e) { + //send a 400 error + response.send(Pistache::Http::Code::Bad_Request, e.what()); + return; + } catch (std::runtime_error &e) { + //send a 500 error + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + return; } } @@ -110,10 +126,14 @@ void UserApi::get_user_by_name_handler(const Pistache::Rest::Request &request, P try { this->get_user_by_name(username, response); - } catch (std::runtime_error & e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + } catch (nlohmann::detail::exception &e) { + //send a 400 error + response.send(Pistache::Http::Code::Bad_Request, e.what()); + return; + } catch (std::runtime_error &e) { + //send a 500 error + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + return; } } @@ -139,10 +159,14 @@ void UserApi::login_user_handler(const Pistache::Rest::Request &request, Pistach try { this->login_user(username, password, response); - } catch (std::runtime_error & e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + } catch (nlohmann::detail::exception &e) { + //send a 400 error + response.send(Pistache::Http::Code::Bad_Request, e.what()); + return; + } catch (std::runtime_error &e) { + //send a 500 error + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + return; } } @@ -150,10 +174,14 @@ void UserApi::logout_user_handler(const Pistache::Rest::Request &request, Pistac try { this->logout_user(response); - } catch (std::runtime_error & e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + } catch (nlohmann::detail::exception &e) { + //send a 400 error + response.send(Pistache::Http::Code::Bad_Request, e.what()); + return; + } catch (std::runtime_error &e) { + //send a 500 error + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + return; } } @@ -168,10 +196,14 @@ void UserApi::update_user_handler(const Pistache::Rest::Request &request, Pistac try { nlohmann::json::parse(request.body()).get_to(body); this->update_user(username, body, response); - } catch (std::runtime_error & e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + } catch (nlohmann::detail::exception &e) { + //send a 400 error + response.send(Pistache::Http::Code::Bad_Request, e.what()); + return; + } catch (std::runtime_error &e) { + //send a 500 error + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + return; } } diff --git a/samples/server/petstore/cpp-pistache/api/UserApi.h b/samples/server/petstore/cpp-pistache/api/UserApi.h index 7083c7643070..6c589979dbc9 100644 --- a/samples/server/petstore/cpp-pistache/api/UserApi.h +++ b/samples/server/petstore/cpp-pistache/api/UserApi.h @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/samples/server/petstore/cpp-pistache/impl/PetApiImpl.cpp b/samples/server/petstore/cpp-pistache/impl/PetApiImpl.cpp index b35b40899b01..778117a18bbe 100644 --- a/samples/server/petstore/cpp-pistache/impl/PetApiImpl.cpp +++ b/samples/server/petstore/cpp-pistache/impl/PetApiImpl.cpp @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/samples/server/petstore/cpp-pistache/impl/PetApiImpl.h b/samples/server/petstore/cpp-pistache/impl/PetApiImpl.h index 7b4f3d324050..9e9f3d145baf 100644 --- a/samples/server/petstore/cpp-pistache/impl/PetApiImpl.h +++ b/samples/server/petstore/cpp-pistache/impl/PetApiImpl.h @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/samples/server/petstore/cpp-pistache/impl/StoreApiImpl.cpp b/samples/server/petstore/cpp-pistache/impl/StoreApiImpl.cpp index 63030737b61e..ef164eb0543e 100644 --- a/samples/server/petstore/cpp-pistache/impl/StoreApiImpl.cpp +++ b/samples/server/petstore/cpp-pistache/impl/StoreApiImpl.cpp @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/samples/server/petstore/cpp-pistache/impl/StoreApiImpl.h b/samples/server/petstore/cpp-pistache/impl/StoreApiImpl.h index 71689ae18b1d..c99372463184 100644 --- a/samples/server/petstore/cpp-pistache/impl/StoreApiImpl.h +++ b/samples/server/petstore/cpp-pistache/impl/StoreApiImpl.h @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/samples/server/petstore/cpp-pistache/impl/UserApiImpl.cpp b/samples/server/petstore/cpp-pistache/impl/UserApiImpl.cpp index 2e7b06d956d8..7163a560bd77 100644 --- a/samples/server/petstore/cpp-pistache/impl/UserApiImpl.cpp +++ b/samples/server/petstore/cpp-pistache/impl/UserApiImpl.cpp @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/samples/server/petstore/cpp-pistache/impl/UserApiImpl.h b/samples/server/petstore/cpp-pistache/impl/UserApiImpl.h index 9bde4fc572a2..8f22c4998894 100644 --- a/samples/server/petstore/cpp-pistache/impl/UserApiImpl.h +++ b/samples/server/petstore/cpp-pistache/impl/UserApiImpl.h @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/samples/server/petstore/cpp-pistache/main-api-server.cpp b/samples/server/petstore/cpp-pistache/main-api-server.cpp index 053fd0dbce08..191b60b7712f 100644 --- a/samples/server/petstore/cpp-pistache/main-api-server.cpp +++ b/samples/server/petstore/cpp-pistache/main-api-server.cpp @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/samples/server/petstore/cpp-pistache/model/ApiResponse.cpp b/samples/server/petstore/cpp-pistache/model/ApiResponse.cpp index 93b2961d0321..a78fb1cc7f97 100644 --- a/samples/server/petstore/cpp-pistache/model/ApiResponse.cpp +++ b/samples/server/petstore/cpp-pistache/model/ApiResponse.cpp @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/samples/server/petstore/cpp-pistache/model/ApiResponse.h b/samples/server/petstore/cpp-pistache/model/ApiResponse.h index 3291251d8cb5..7ecb6c9a82ec 100644 --- a/samples/server/petstore/cpp-pistache/model/ApiResponse.h +++ b/samples/server/petstore/cpp-pistache/model/ApiResponse.h @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/samples/server/petstore/cpp-pistache/model/Category.cpp b/samples/server/petstore/cpp-pistache/model/Category.cpp index 80112511b825..2abb0c3c5e2a 100644 --- a/samples/server/petstore/cpp-pistache/model/Category.cpp +++ b/samples/server/petstore/cpp-pistache/model/Category.cpp @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/samples/server/petstore/cpp-pistache/model/Category.h b/samples/server/petstore/cpp-pistache/model/Category.h index 4018607b4350..fa12fdc0de8d 100644 --- a/samples/server/petstore/cpp-pistache/model/Category.h +++ b/samples/server/petstore/cpp-pistache/model/Category.h @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/samples/server/petstore/cpp-pistache/model/Helpers.cpp b/samples/server/petstore/cpp-pistache/model/Helpers.cpp index 8c0e859b6421..b518f8106d77 100644 --- a/samples/server/petstore/cpp-pistache/model/Helpers.cpp +++ b/samples/server/petstore/cpp-pistache/model/Helpers.cpp @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/samples/server/petstore/cpp-pistache/model/Helpers.h b/samples/server/petstore/cpp-pistache/model/Helpers.h index 8c62ecda5a0a..9c8c02c4ae61 100644 --- a/samples/server/petstore/cpp-pistache/model/Helpers.h +++ b/samples/server/petstore/cpp-pistache/model/Helpers.h @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/samples/server/petstore/cpp-pistache/model/Order.cpp b/samples/server/petstore/cpp-pistache/model/Order.cpp index a0bda775a56e..b24cc0fce92e 100644 --- a/samples/server/petstore/cpp-pistache/model/Order.cpp +++ b/samples/server/petstore/cpp-pistache/model/Order.cpp @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/samples/server/petstore/cpp-pistache/model/Order.h b/samples/server/petstore/cpp-pistache/model/Order.h index b4d4598b749a..d900b633f32c 100644 --- a/samples/server/petstore/cpp-pistache/model/Order.h +++ b/samples/server/petstore/cpp-pistache/model/Order.h @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/samples/server/petstore/cpp-pistache/model/Pet.cpp b/samples/server/petstore/cpp-pistache/model/Pet.cpp index 40699f133340..7781e283cebc 100644 --- a/samples/server/petstore/cpp-pistache/model/Pet.cpp +++ b/samples/server/petstore/cpp-pistache/model/Pet.cpp @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/samples/server/petstore/cpp-pistache/model/Pet.h b/samples/server/petstore/cpp-pistache/model/Pet.h index 22eeb9570f48..f23ef47832d2 100644 --- a/samples/server/petstore/cpp-pistache/model/Pet.h +++ b/samples/server/petstore/cpp-pistache/model/Pet.h @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/samples/server/petstore/cpp-pistache/model/Tag.cpp b/samples/server/petstore/cpp-pistache/model/Tag.cpp index 4a1349f0e944..b81cb825724b 100644 --- a/samples/server/petstore/cpp-pistache/model/Tag.cpp +++ b/samples/server/petstore/cpp-pistache/model/Tag.cpp @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/samples/server/petstore/cpp-pistache/model/Tag.h b/samples/server/petstore/cpp-pistache/model/Tag.h index bb5dff9f922b..4b422931d771 100644 --- a/samples/server/petstore/cpp-pistache/model/Tag.h +++ b/samples/server/petstore/cpp-pistache/model/Tag.h @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/samples/server/petstore/cpp-pistache/model/User.cpp b/samples/server/petstore/cpp-pistache/model/User.cpp index 9c467a10d86f..66a026e9c78f 100644 --- a/samples/server/petstore/cpp-pistache/model/User.cpp +++ b/samples/server/petstore/cpp-pistache/model/User.cpp @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/samples/server/petstore/cpp-pistache/model/User.h b/samples/server/petstore/cpp-pistache/model/User.h index 4b8cd2b19626..1f4c17ce6a81 100644 --- a/samples/server/petstore/cpp-pistache/model/User.h +++ b/samples/server/petstore/cpp-pistache/model/User.h @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/website/dynamic/users.yml b/website/dynamic/users.yml index a6a621097643..d32144a8f8b0 100644 --- a/website/dynamic/users.yml +++ b/website/dynamic/users.yml @@ -23,6 +23,11 @@ image: "img/companies/boxever.svg" infoLink: "https://www.boxever.com/" pinned: false +- + caption: CAM + image: "img/companies/cam.png" + infoLink: "https://www.cam-inc.co.jp" + pinned: false - caption: FiNC Technologies image: "img/companies/finc-technologies.png" diff --git a/website/static/img/companies/cam.png b/website/static/img/companies/cam.png new file mode 100644 index 000000000000..58aaec918f02 Binary files /dev/null and b/website/static/img/companies/cam.png differ