Merge remote-tracking branch 'origin/master' into HEAD

This commit is contained in:
Jeremie Bresson 2019-05-20 13:06:34 +02:00
commit 98348a9ee6
145 changed files with 712 additions and 968 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
openApiGeneratorVersion=4.0.0
openApiGeneratorVersion=4.1.0-SNAPSHOT
# BEGIN placeholders
# these are just placeholders to allow contributors to build directly

View File

@ -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<String, Object> objs) {
protected void generateJSONSpecFile(Map<String, Object> objs) {
OpenAPI openAPI = (OpenAPI) objs.get("openAPI");
if (openAPI != null) {
try {

View File

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

View File

@ -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<String> producesInfo = getProducesInfo(openAPI, operation);
if (producesInfo != null && !producesInfo.isEmpty()) {
ArrayList<String> produces = new ArrayList<String>(producesInfo);
ArrayList<String> 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) {

View File

@ -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<String> 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)) {

View File

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

View File

@ -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<String, Object> postProcessOperationsWithModels(Map<String, Object> operations, List<Object> allModels) {
Map<String, Object> objs = (Map<String, Object>) operations.get("operations");
List<CodegenOperation> ops = (List<CodegenOperation>) objs.get("operation");
for (CodegenOperation op : ops) {
// Overwrite path to map variable with path parameters

View File

@ -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<String, String> supportedLibraries = new LinkedHashMap<>();
supportedLibraries.put(DEFAULT_LIBRARY, "JAXRS");

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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.
*/

View File

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

View File

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

View File

@ -113,11 +113,6 @@
<version>${openapi-generator-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-cli</artifactId>
<version>${openapi-generator-version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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}}' =>

View File

@ -1,5 +0,0 @@
{
"globalDependencies": {
"core-js": "registry:dt/core-js#0.0.0+20160725163759"
}
}

View File

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

View File

@ -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<any>).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<any>).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}}

View File

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

View File

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

View File

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

View File

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

View File

@ -14,8 +14,7 @@
]
},
"files": [
"index.ts",
"typings/index.d.ts"
"index.ts"
]
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1050,6 +1050,7 @@
<module>samples/client/petstore/typescript-angular-v4/npm</module>
<module>samples/client/petstore/typescript-angular-v4.3/npm</module>
<module>samples/client/petstore/typescript-angular-v6-provided-in-root</module>
<module>samples/client/petstore/typescript-angular-v7-provided-in-root</module>
<!--<module>samples/client/petstore/bash</module>-->
<module>samples/server/petstore/rust-server</module>
<module>samples/server/petstore/python-aiohttp</module>
@ -1070,7 +1071,6 @@
<!-- clients -->
<!-- test non-java projects -->
<module>samples/client/petstore/go</module>
<module>samples/client/petstore/typescript-angular-v6-provided-in-root</module>
<!-- test java-related projects -->
<!--<module>samples/client/petstore/scala-akka</module>-->
<module>samples/client/petstore/scala-httpclient</module>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +0,0 @@
{
"globalDependencies": {
"core-js": "registry:dt/core-js#0.0.0+20160725163759"
}
}

View File

@ -1,5 +0,0 @@
{
"globalDependencies": {
"core-js": "registry:dt/core-js#0.0.0+20160725163759"
}
}

View File

@ -1,5 +0,0 @@
{
"globalDependencies": {
"core-js": "registry:dt/core-js#0.0.0+20160725163759"
}
}

View File

@ -1,5 +0,0 @@
{
"globalDependencies": {
"core-js": "registry:dt/core-js#0.0.0+20160725163759"
}
}

View File

@ -1,5 +0,0 @@
{
"globalDependencies": {
"core-js": "registry:dt/core-js#0.0.0+20160725163759"
}
}

View File

@ -1,5 +0,0 @@
{
"globalDependencies": {
"core-js": "registry:dt/core-js#0.0.0+20160725163759"
}
}

View File

@ -1,5 +0,0 @@
{
"globalDependencies": {
"core-js": "registry:dt/core-js#0.0.0+20160725163759"
}
}

View File

@ -1,5 +0,0 @@
{
"globalDependencies": {
"core-js": "registry:dt/core-js#0.0.0+20160725163759"
}
}

View File

@ -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()`, () => {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,7 +11,7 @@
* Do not edit the class manually.
*/
import { exists } from '../runtime';
import { exists, mapValues } from '../runtime';
import {
Category,
CategoryFromJSON,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,7 +11,7 @@
* Do not edit the class manually.
*/
import { exists } from '../runtime';
import { exists, mapValues } from '../runtime';
import {
Category,
CategoryFromJSON,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,7 +11,7 @@
* Do not edit the class manually.
*/
import { exists } from '../runtime';
import { exists, mapValues } from '../runtime';
import {
Category,
CategoryFromJSON,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,7 +11,7 @@
* Do not edit the class manually.
*/
import { exists } from '../runtime';
import { exists, mapValues } from '../runtime';
import {
Category,
CategoryFromJSON,

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