[TypeScript Client] fix npm version when snapshot is true and npmversion is snapshot too (#2401)

This commit is contained in:
Vincent Devos
2019-03-26 17:03:24 +01:00
committed by William Cheng
parent 01e8c67da9
commit d795c4e9d0
11 changed files with 188 additions and 18 deletions

View File

@@ -164,7 +164,12 @@ public class JavascriptFlowtypedClientCodegen extends AbstractTypeScriptClientCo
}
if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) {
this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
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);

View File

@@ -26,7 +26,6 @@ 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.*;
@@ -208,9 +207,13 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
this.setNpmVersion(this.getVersionFromApi());
}
if (additionalProperties.containsKey(SNAPSHOT)
&& Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) {
this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
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);
@@ -445,9 +448,9 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
/**
* Finds and returns a path parameter of an operation by its name
*
* @param operation
* @param parameterName
* @return
* @param operation the operation
* @param parameterName the name of the parameter
* @return param
*/
private CodegenParameter findPathParameterByName(CodegenOperation operation, String parameterName) {
for (CodegenParameter param : operation.pathParams) {
@@ -564,6 +567,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
return toApiFilename(name);
}
/*
private String getModelnameFromModelFilename(String filename) {
String name = filename.substring((modelPackage() + "/").length());
// Remove the file suffix and add the class suffix.
@@ -574,6 +578,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
}
return camelize(name) + modelSuffix;
}
*/
@Override
public String toModelName(String name) {
@@ -654,7 +659,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
/**
* Returns version from OpenAPI info.
*
* @return
* @return version
*/
private String getVersionFromApi() {
if (this.openAPI != null && this.openAPI.getInfo() != null) {

View File

@@ -231,7 +231,12 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege
}
if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) {
this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
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);

View File

@@ -194,7 +194,12 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
}
if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) {
this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
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);

View File

@@ -129,9 +129,13 @@ public class TypeScriptInversifyClientCodegen extends AbstractTypeScriptClientCo
this.setNpmVersion(additionalProperties.get(NPM_VERSION).toString());
}
if (additionalProperties.containsKey(SNAPSHOT)
&& Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) {
this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
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);

View File

@@ -181,7 +181,12 @@ public class TypeScriptJqueryClientCodegen extends AbstractTypeScriptClientCodeg
}
if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) {
this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
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);

View File

@@ -232,7 +232,12 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
}
if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) {
this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
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);

View File

@@ -194,7 +194,12 @@ public class TypeScriptRxjsClientCodegen extends AbstractTypeScriptClientCodegen
}
if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) {
this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
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);