Merge remote-tracking branch 'origin/master' into 5.2.x

This commit is contained in:
William Cheng 2021-03-26 10:20:36 +08:00
commit 16b141e402
669 changed files with 1327 additions and 41749 deletions

View File

@ -81,8 +81,6 @@ else
export PATH="/usr/local/go1.14/go/bin:$PATH"
go version
installDart
mvn --no-snapshot-updates --quiet verify -Psamples.circleci.others -Dorg.slf4j.simpleLogger.defaultLogLevel=error
mvn --no-snapshot-updates --quiet javadoc:javadoc -Psamples.circleci -Dorg.slf4j.simpleLogger.defaultLogLevel=error
fi

View File

@ -120,8 +120,8 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
| OpenAPI Generator Version | Release Date | Notes |
| --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ------------------------------------------------- |
| 6.0.0 (upcoming major release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/6.0.0-SNAPSHOT/) | Nov/Dec 2021 | Minor release with breaking changes (no fallback) |
| 5.1.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/5.2.0-SNAPSHOT/) | May/Jun 2021 | Minor release with breaking changes (with fallback) |
| 5.1.0 (upcoming patch release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/5.1.1-SNAPSHOT/) | Apr/May 2021 | Patch release (enhancements, bug fixes, etc) |
| 5.2.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/5.2.0-SNAPSHOT/) | May/Jun 2021 | Minor release with breaking changes (with fallback) |
| 5.1.1 (upcoming patch release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/5.1.1-SNAPSHOT/) | Apr/May 2021 | Patch release (enhancements, bug fixes, etc) |
| [5.1.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v5.1.0) (latest stable release) | 20.03.2021 | Minor release with breaking changes (with fallback) |
| [4.3.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.3.1) | 06.05.2020 | Patch release (enhancements, bug fixes, etc) |

View File

@ -32,7 +32,7 @@ install:
- git clone https://github.com/wing328/swagger-samples
- ps: Start-Process -FilePath 'C:\maven\apache-maven-3.2.5\bin\mvn' -ArgumentList 'jetty:run' -WorkingDirectory "$env:appveyor_build_folder\swagger-samples\java\java-jersey-jaxrs-ci"
- ps: $PSVersionTable.PSVersion
- ps: Install-Module Pester -Force -Scope CurrentUser
- ps: Install-Module -Name Pester -Force -Scope CurrentUser
build_script:
- dotnet --info
# build C# aspnetcore 5.0 server

View File

@ -9,4 +9,4 @@ additionalProperties:
useCompareNetObjects: true
disallowAdditionalPropertiesIfNotPresent: false
useOneOfDiscriminatorLookup: true
targetFramework: netstandard2.1
targetFramework: netstandard2.0

View File

@ -1,7 +0,0 @@
generatorName: dart-jaguar
outputDir: samples/client/petstore/dart-jaguar/flutter_petstore/openapi
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/dart-jaguar
additionalProperties:
pubName: openapi
hideGenerationTimestamp: "true"

View File

@ -1,8 +0,0 @@
generatorName: dart-jaguar
outputDir: samples/client/petstore/dart-jaguar/flutter_proto_petstore/openapi
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-proto.yaml
templateDir: modules/openapi-generator/src/main/resources/dart-jaguar
additionalProperties:
serialization: proto
pubName: openapi
hideGenerationTimestamp: "true"

View File

@ -1,7 +0,0 @@
generatorName: dart-jaguar
outputDir: samples/client/petstore/dart-jaguar/openapi
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/dart-jaguar
additionalProperties:
hideGenerationTimestamp: "true"
pubName: openapi

View File

@ -1,8 +0,0 @@
generatorName: dart-jaguar
outputDir: samples/client/petstore/dart-jaguar/openapi_proto
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-proto.yaml
templateDir: modules/openapi-generator/src/main/resources/dart-jaguar
additionalProperties:
serialization: proto
pubName: openapi
hideGenerationTimestamp: "true"

View File

@ -1,5 +1,7 @@
---
# csharp-netcore test files and image for upload
- filename: "samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools.Test/JSONComposedSchemaTests.cs"
sha256: ec34838fbbb1abb9f762949d510503b6237b607400a85c848c234c39d013a776
- filename: "samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools.Test/Api/PetApiTests.cs"
sha256: dae985015ba461297927d544a78267f2def35e07c3f14ca66468fd61e1fd1c26
- filename: "samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools.Test/linux-logo.png"

View File

@ -12,6 +12,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|apiPackage|package for generated api classes| |null|
|artifactId|artifactId| |openapi-scala-akka-http-server|
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|asManagedSources|Resulting files cab be used as managed resources. No build files or default controllers will be generated| |false|
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (prefered for JDK 1.8+)</dd></dl>|java8|
|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|true|
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|

View File

@ -28,7 +28,6 @@ import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicLong;
import java.util.regex.Pattern;
/**

View File

@ -16,9 +16,6 @@
package org.openapitools.codegen.meta;
import org.openapitools.codegen.meta.features.*;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

View File

@ -16,7 +16,6 @@
package org.openapitools.codegen.plugin;
import org.junit.Test;
import org.openapitools.codegen.plugin.stubs.StubUtility;
import java.io.File;

View File

@ -31,8 +31,6 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Properties;

View File

@ -19,7 +19,6 @@ package org.openapitools.codegen.online.service;
import com.fasterxml.jackson.databind.JsonNode;
import io.swagger.parser.OpenAPIParser;
import io.swagger.v3.core.util.Json;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.parser.core.models.AuthorizationValue;
import io.swagger.v3.parser.core.models.ParseOptions;

View File

@ -30,7 +30,7 @@ import java.util.zip.ZipOutputStream;
/**
* This utility compresses a list of files to standard ZIP format file. It is able to compresses all
* sub files and sub directories, recursively.
*
*
* @author Ha Minh Nam
*
*/
@ -42,7 +42,7 @@ public class ZipUtil {
/**
* Compresses a collection of files to a destination zip file.
*
*
* @param listFiles A collection of files and directories
* @param destZipFile The path of the destination zip file
* @throws FileNotFoundException if file not found
@ -67,7 +67,7 @@ public class ZipUtil {
/**
* Adds a directory to the current zip output stream.
*
*
* @param folder the directory to be added
* @param parentFolder the path of parent directory
* @param zos the current zip output stream
@ -99,7 +99,7 @@ public class ZipUtil {
/**
* Adds a file to the current zip output stream.
*
*
* @param file the file to be added
* @param zos the current zip output stream
* @throws FileNotFoundException if file not found

View File

@ -77,7 +77,7 @@ public class CliOption {
public String getOptValue() {
return this.optValue;
}
public void setOptValue(String optValue) {
if (this.enumValues!=null && this.enumValues.containsKey(optValue)) {
this.optValue = optValue;
@ -106,7 +106,7 @@ public class CliOption {
/**
* Create new boolean command line option with a default of false
*
*
* @param opt Option name
* @param description Option description
* @return the CliOption created
@ -117,7 +117,7 @@ public class CliOption {
/**
* Create new boolean command line option with the provided value as default
*
*
* @param opt Option name
* @param description Option description
* @param defaultValue the default value to use if option not specified

View File

@ -123,9 +123,9 @@ public interface CodegenConfig {
List<CodegenSecurity> fromSecurity(Map<String, SecurityScheme> schemas);
List<CodegenServer> fromServers(List<Server> servers);
List<CodegenServerVariable> fromServerVariables(Map<String, ServerVariable> variables);
Set<String> defaultIncludes();
Map<String, String> typeMapping();

View File

@ -1,7 +1,5 @@
package org.openapitools.codegen;
import org.apache.commons.lang3.builder.ToStringBuilder;
import java.util.TreeSet;
import java.util.Map;
import java.util.Objects;

View File

@ -53,7 +53,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
public String name;
// The language-specific name of the class that implements this schema.
// The name of the class is derived from the OpenAPI schema name with formatting rules applied.
// The classname is derived from the OpenAPI schema name, with sanitization and escaping rules applied.
// The classname is derived from the OpenAPI schema name, with sanitization and escaping rules applied.
public String classname;
// The value of the 'title' attribute in the OpenAPI document.
public String title;
@ -109,7 +109,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
/**
* The type of the value for the additionalProperties keyword in the OAS document.
* Used in map like objects, including composed schemas.
*
*
* In most programming languages, the additional (undeclared) properties are stored
* in a map data structure, such as HashMap in Java, map in golang, or a dict in Python.
* There are multiple ways to implement the additionalProperties keyword, depending
@ -122,7 +122,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
*
* For example, in the OAS schema below, the schema has a declared 'id' property
* and additional, undeclared properties of type 'integer' are allowed.
*
*
* type: object
* properties:
* id:
@ -232,7 +232,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
* Return true if the classname property is sanitized, false if it is the same as the OpenAPI schema name.
* The OpenAPI schema name may be any valid JSON schema name, including non-ASCII characters.
* The name of the class may have to be sanitized with character escaping.
*
*
* @return true if the classname property is sanitized
*/
public boolean getIsClassnameSanitized() {
@ -273,7 +273,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
/**
* Returns the discriminator for this schema object, or null if no discriminator has been specified.
*
*
* The list of all possible schema discriminator mapping values is obtained
* from explicit discriminator mapping values in the OpenAPI document, and from
* inherited discriminators through oneOf, allOf, anyOf.
@ -283,7 +283,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
* 'objectType' properties are 'Dog' and 'Cat'.
* The allowed discriminator mapping value for the Dog schema is 'Dog'.
* The allowed discriminator mapping value for the Cat schema is 'Dog'.
*
*
* Pet:
* type: object
* discriminator:
@ -307,7 +307,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
* properties:
* p2:
* type: string
*
*
* @return the discriminator.
*/
public CodegenDiscriminator getDiscriminator() {
@ -323,7 +323,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
* In the OpenAPI document, the discriminator may be specified in the local schema or
* it may be inherited, such as through a 'allOf' schema which references another schema
* that has a discriminator, recursively.
*
*
* @return the name of the discriminator property.
*/
public String getDiscriminatorName() {

View File

@ -31,7 +31,7 @@ public class CodegenOperation {
isRestfulIndex, isRestfulShow, isRestfulCreate, isRestfulUpdate, isRestfulDestroy,
isRestful, isDeprecated, isCallbackRequest, uniqueItems;
public String path, operationId, returnType, returnFormat, httpMethod, returnBaseType,
returnContainer, summary, unescapedNotes, notes, baseName, defaultResponse;
returnContainer, summary, unescapedNotes, notes, baseName, defaultResponse;
public CodegenDiscriminator discriminator;
public List<Map<String, String>> consumes, produces, prioritizedContentTypes;
public List<CodegenServer> servers = new ArrayList<CodegenServer>();

View File

@ -157,7 +157,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
public Map<String, Object> allowableValues;
// If 'additionalProperties' is not set, items is null.
// If 'additionalProperties' is set to a type or refers to a type, 'items' provides the type information for
// the undeclared properties.
// the undeclared properties.
public CodegenProperty items;
public CodegenProperty additionalProperties;
public List<CodegenProperty> vars = new ArrayList<CodegenProperty>(); // all properties (without parent's properties)

View File

@ -20,7 +20,6 @@ package org.openapitools.codegen;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;

View File

@ -461,7 +461,7 @@ public class DefaultCodegen implements CodegenConfig {
/**
* Return a map from model name to Schema for efficient lookup.
*
*
* @return map from model name to Schema.
*/
protected Map<String, Schema> getModelNameToSchemaCache() {
@ -2615,35 +2615,47 @@ public class DefaultCodegen implements CodegenConfig {
}
private void setAddProps(Schema schema, IJsonSchemaValidationProperties property){
if (schema.equals(new Schema())) {
// if we are trying to set additionalProperties on an empty schema stop recursing
return;
}
boolean additionalPropertiesIsAnyType = false;
CodegenModel m = null;
if (property instanceof CodegenModel) {
m = (CodegenModel) property;
}
CodegenProperty addPropProp = null;
boolean isAdditionalPropertiesTrue = false;
if (schema.getAdditionalProperties() == null) {
if (!disallowAdditionalPropertiesIfNotPresent) {
isAdditionalPropertiesTrue = true;
CodegenProperty cp = fromProperty("", new Schema());
property.setAdditionalProperties(cp);
property.setAdditionalPropertiesIsAnyType(true);
addPropProp = fromProperty("", new Schema());
additionalPropertiesIsAnyType = true;
}
} else if (schema.getAdditionalProperties() instanceof Boolean) {
if (Boolean.TRUE.equals(schema.getAdditionalProperties())) {
isAdditionalPropertiesTrue = true;
CodegenProperty cp = fromProperty("", new Schema());
property.setAdditionalProperties(cp);
property.setAdditionalPropertiesIsAnyType(true);
addPropProp = fromProperty("", new Schema());
additionalPropertiesIsAnyType = true;
}
} else {
CodegenProperty cp = fromProperty("", (Schema) schema.getAdditionalProperties());
property.setAdditionalProperties(cp);
addPropProp = fromProperty("", (Schema) schema.getAdditionalProperties());
if (isAnyTypeSchema((Schema) schema.getAdditionalProperties())) {
property.setAdditionalPropertiesIsAnyType(true);
additionalPropertiesIsAnyType = true;
}
}
if (additionalPropertiesIsAnyType) {
property.setAdditionalPropertiesIsAnyType(true);
}
if (m != null && isAdditionalPropertiesTrue) {
m.isAdditionalPropertiesTrue = true;
}
if (ModelUtils.isComposedSchema(schema) && !supportsAdditionalPropertiesWithComposedSchema) {
return;
}
if (addPropProp != null) {
property.setAdditionalProperties(addPropProp);
}
}
@ -3078,7 +3090,7 @@ public class DefaultCodegen implements CodegenConfig {
/**
* Convert OAS Property object to Codegen Property object.
*
*
* The return value is cached. An internal cache is looked up to determine
* if the CodegenProperty return value has already been instantiated for
* the (String name, Schema p) arguments.
@ -4711,13 +4723,13 @@ public class DefaultCodegen implements CodegenConfig {
* of the 'additionalProperties' keyword. Some language generator use class inheritance
* to implement additional properties. For example, in Java the generated model class
* has 'extends HashMap' to represent the additional properties.
*
*
* TODO: it's not a good idea to use single class inheritance to implement
* additionalProperties. That may work for non-composed schemas, but that does not
* work for composed 'allOf' schemas. For example, in Java, if additionalProperties
* is set to true (which it should be by default, per OAS spec), then the generated
* code has extends HashMap. That wouldn't work for composed 'allOf' schemas.
*
*
* @param model the codegen representation of the OAS schema.
* @param name the name of the model.
* @param schema the input OAS schema.
@ -6157,6 +6169,7 @@ public class DefaultCodegen implements CodegenConfig {
}
private void addVarsRequiredVarsAdditionalProps(Schema schema, IJsonSchemaValidationProperties property){
setAddProps(schema, property);
if (!"object".equals(schema.getType())) {
return;
}
@ -6178,7 +6191,6 @@ public class DefaultCodegen implements CodegenConfig {
property.setHasRequired(true);
}
}
setAddProps(schema, property);
}
private void addJsonSchemaForBodyRequestInCaseItsNotPresent(CodegenParameter codegenParameter, RequestBody body) {
@ -6600,7 +6612,7 @@ public class DefaultCodegen implements CodegenConfig {
/**
* Returns the additionalProperties Schema for the specified input schema.
*
*
* The additionalProperties keyword is used to control the handling of additional, undeclared
* properties, that is, properties whose names are not listed in the properties keyword.
* The additionalProperties keyword may be either a boolean or an object.
@ -6608,7 +6620,7 @@ public class DefaultCodegen implements CodegenConfig {
* By default when the additionalProperties keyword is not specified in the input schema,
* any additional properties are allowed. This is equivalent to setting additionalProperties
* to the boolean value True or setting additionalProperties: {}
*
*
* @param schema the input schema that may or may not have the additionalProperties keyword.
* @return the Schema of the additionalProperties. The null value is returned if no additional
* properties are allowed.

View File

@ -29,7 +29,6 @@ import io.swagger.v3.oas.models.parameters.Parameter;
import io.swagger.v3.oas.models.parameters.RequestBody;
import io.swagger.v3.oas.models.responses.ApiResponse;
import io.swagger.v3.oas.models.responses.ApiResponses;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -38,7 +38,7 @@ import java.util.*;
* </ul>
* <p>
* The corresponding {@code add...} method on the passed configurator is called for each key-value pair (or value).
* </p>
* </p>
*/
public final class CodegenConfiguratorUtils {
@ -60,7 +60,7 @@ public final class CodegenConfiguratorUtils {
applyInstantiationTypesKvp(propString, configurator);
}
}
public static void applyInstantiationTypesKvp(String instantiationTypes, CodegenConfigurator configurator) {
final Map<String, String> map = createMapFromKeyValuePairs(instantiationTypes);
for (Map.Entry<String, String> entry : map.entrySet()) {
@ -143,9 +143,9 @@ public final class CodegenConfiguratorUtils {
final Map<String, String> map = createMapFromKeyValuePairs(reservedWordMappings);
for (Map.Entry<String, String> entry : map.entrySet()) {
configurator.addAdditionalReservedWordMapping(entry.getKey(), entry.getValue());
}
}
}
private static Set<String> createSetFromCsvList(String csvProperty) {
final List<String> values = OptionUtils.splitCommaSeparatedList(csvProperty);
return new HashSet<String>(values);

View File

@ -25,7 +25,7 @@ import java.util.Properties;
*
* This provides a set of properties specific to the executing thread, such that the generator may not modify system properties
* consumed by other threads.
*
*
* @author gndrm
* @since 2018
*/

View File

@ -32,7 +32,6 @@ import org.slf4j.LoggerFactory;
import java.util.*;
import static org.openapitools.codegen.utils.OnceLogger.once;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public abstract class AbstractApexCodegen extends DefaultCodegen implements CodegenConfig {

View File

@ -32,9 +32,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.util.*;
import static org.openapitools.codegen.utils.OnceLogger.once;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public abstract class AbstractCSharpCodegen extends DefaultCodegen implements CodegenConfig {
@ -399,7 +399,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
// check to see if model name is same as the property name
// which will result in compilation error
// if found, prepend with _ to workaround the limitation
if (var.name.equalsIgnoreCase(cm.name)) {
if (var.name.equalsIgnoreCase(cm.classname)) {
var.name = "_" + var.name;
}
}
@ -500,6 +500,12 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
}
}
/* Comment out the following as model.dataType is always the model name, eg. OuterIntegerEnum,
* and this will fix the integer enum via #9035.
* Only x-enum-byte is used in the template but it won't work due to the bug mentioned above.
* A better solution is to introduce isLong, isInteger, etc in the DefaultCodegen
* so that there is no need for each generator to post-process model enums.
*
// We're looping all models here.
if (model.isEnum) {
// We now need to make allowableValues.enumVars look like the context of CodegenProperty
@ -543,7 +549,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
if (!newEnumVars.isEmpty()) {
model.allowableValues.put("enumVars", newEnumVars);
}
}
} */
} else {
LOGGER.warn("Expected to retrieve model %s by name, but no model was found. Check your -Dmodels inclusions.", openAPIName);
}
@ -1263,8 +1269,10 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
} else {
LOGGER.info("Successfully executed: " + command);
}
} catch (Exception e) {
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
// Restore interrupted state
Thread.currentThread().interrupt();
}
}
}

View File

@ -40,6 +40,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
@ -330,8 +331,10 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg
} else {
LOGGER.info("Successfully executed: " + command);
}
} catch (Exception e) {
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
// Restore interrupted state
Thread.currentThread().interrupt();
}
}
}

View File

@ -17,6 +17,7 @@ import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;
@ -709,8 +710,10 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
} else {
LOGGER.info("Successfully executed: {}", command);
}
} catch (Exception e) {
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
// Restore interrupted state
Thread.currentThread().interrupt();
}
}
}

View File

@ -31,7 +31,6 @@ import org.slf4j.LoggerFactory;
import java.util.*;
import static com.google.common.base.Strings.isNullOrEmpty;
import static org.openapitools.codegen.utils.OnceLogger.once;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@ -91,7 +90,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
instantiationTypes.put("array", "ARRAYED_LIST");
instantiationTypes.put("list", "ARRAYED_LIST");
instantiationTypes.put("map", "STRING_TABLE");
importMapping.put("List", "LIST");
importMapping.put("Set", "SET");
importMapping.put("file", "FILE");
@ -153,7 +152,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
name = escapeReservedWord(name);
}
// for reserved word or word starting with number, append
// for reserved word or word starting with number, append
if (name.matches("^\\d.*")) {
name = escapeReservedWord(name);
}
@ -349,7 +348,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
+ camelize("call_" + operationId));
sanitizedOperationId = "call_" + sanitizedOperationId;
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
LOGGER.warn(operationId + " (starting with a number) cannot be used as method sname. Renamed to " + camelize("call_" + operationId), true);

View File

@ -30,9 +30,8 @@ import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.Exception;
import java.io.File;
import java.io.IOException;
import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.camelize;
@ -1124,8 +1123,10 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
} else {
LOGGER.info("Successfully executed: " + command);
}
} catch (Exception e) {
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
// Restore interrupted state
Thread.currentThread().interrupt();
}
}
}

View File

@ -27,6 +27,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.camelize;
@ -594,7 +595,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
// The 'go-experimental/model.mustache' template conditionally generates accessor methods.
// For primitive types and custom types (e.g. interface{}, map[string]interface{}...),
// the generated code has a wrapper type and a Get() function to access the underlying type.
// For containers (e.g. Array, Map), the generated code returns the type directly.
// For containers (e.g. Array, Map), the generated code returns the type directly.
if (property.isContainer || property.isFreeFormObject || property.isAnyType) {
property.vendorExtensions.put("x-golang-is-container", true);
}
@ -830,8 +831,10 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
} else {
LOGGER.info("Successfully executed: " + command);
}
} catch (Exception e) {
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
// Restore interrupted state
Thread.currentThread().interrupt();
}
}
}

View File

@ -42,6 +42,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*;
@ -941,6 +942,11 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
return super.toDefaultValue(schema);
}
return null;
} else if (ModelUtils.isComposedSchema(schema)) {
if (schema.getDefault() != null) {
return super.toDefaultValue(schema);
}
return null;
}
return super.toDefaultValue(schema);
@ -1430,6 +1436,27 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
return op;
}
@Override
public void postProcessParameter(CodegenParameter p) {
// we use a custom version of this function to remove the l, d, and f suffixes from Long/Double/Float
// defaultValues
// remove the l because our users will use Long.parseLong(String defaultValue)
// remove the d because our users will use Double.parseDouble(String defaultValue)
// remove the f because our users will use Float.parseFloat(String defaultValue)
// NOTE: for CodegenParameters we DO need these suffixes because those defaultValues are used as java value
// literals assigned to Long/Double/Float
if (p.defaultValue == null) {
return;
}
Boolean fixLong = (p.isLong && "l".equals(p.defaultValue.substring(p.defaultValue.length()-1)));
Boolean fixDouble = (p.isDouble && "d".equals(p.defaultValue.substring(p.defaultValue.length()-1)));
Boolean fixFloat = (p.isFloat && "f".equals(p.defaultValue.substring(p.defaultValue.length()-1)));
if (fixLong || fixDouble || fixFloat) {
p.defaultValue = p.defaultValue.substring(0, p.defaultValue.length()-1);
}
}
private static CodegenModel reconcileInlineEnums(CodegenModel codegenModel, CodegenModel parentCodegenModel) {
// This generator uses inline classes to define enums, which breaks when
// dealing with models that have subTypes. To clean this up, we will analyze
@ -1813,8 +1840,10 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
} else {
LOGGER.info("Successfully executed: " + command);
}
} catch (Exception e) {
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
// Restore interrupted state
Thread.currentThread().interrupt();
}
}
}
@ -1847,7 +1876,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
protected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, Schema schema) {
if (!supportsAdditionalPropertiesWithComposedSchema) {
// The additional (undeclared) propertiees are modeled in Java as a HashMap.
//
//
// 1. supportsAdditionalPropertiesWithComposedSchema is set to false:
// The generated model class extends from the HashMap. That does not work
// with composed schemas that also use a discriminator because the model class

View File

@ -33,6 +33,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -891,8 +892,10 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
} else {
LOGGER.info("Successfully executed: " + command);
}
} catch (Exception e) {
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
// Restore interrupted state
Thread.currentThread().interrupt();
}
}
}

View File

@ -27,11 +27,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.openapitools.codegen.utils.OnceLogger.once;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@ -751,8 +749,10 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
} else {
LOGGER.info("Successfully executed: " + command);
}
} catch (Exception e) {
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
// Restore interrupted state
Thread.currentThread().interrupt();
}
}
}

View File

@ -28,12 +28,8 @@ import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.time.ZoneId;
import java.io.IOException;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -281,8 +277,10 @@ abstract public class AbstractPythonCodegen extends DefaultCodegen implements Co
} else {
LOGGER.info("Successfully executed: " + command);
}
} catch (Exception e) {
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
// Restore interrupted state
Thread.currentThread().interrupt();
}
}
}

View File

@ -29,7 +29,6 @@ import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.parameters.Parameter;
import io.swagger.v3.oas.models.parameters.RequestBody;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.features.DocumentationFeature;

View File

@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.time.ZoneId;
@ -250,8 +251,10 @@ abstract public class AbstractRubyCodegen extends DefaultCodegen implements Code
} else {
LOGGER.info("Successfully executed: `{}`", command);
}
} catch (Exception e) {
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
// Restore interrupted state
Thread.currentThread().interrupt();
}
}
}

View File

@ -29,6 +29,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.util.*;
import static org.openapitools.codegen.languages.AbstractJavaCodegen.DATE_LIBRARY;
@ -532,8 +533,10 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
} else {
LOGGER.info("Successfully executed: " + command);
}
} catch (Exception e) {
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
// Restore interrupted state
Thread.currentThread().interrupt();
}
}
}

View File

@ -17,7 +17,6 @@
package org.openapitools.codegen.languages;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.media.ArraySchema;
@ -35,9 +34,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -857,8 +856,10 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
} else {
LOGGER.info("Successfully executed: " + command);
}
} catch (Exception e) {
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
// Restore interrupted state
Thread.currentThread().interrupt();
}
}
}

View File

@ -24,8 +24,6 @@ import org.slf4j.LoggerFactory;
import java.util.*;
import static org.openapitools.codegen.utils.OnceLogger.once;
public class Apache2ConfigCodegen extends DefaultCodegen implements CodegenConfig {
public static final String USER_INFO_PATH = "userInfoPath";

View File

@ -106,8 +106,8 @@ public class ApexClientCodegen extends AbstractApexCodegen {
"hint", "if", "implements", "import", "in", "inner", "insert", "instanceof", "int", "integer",
"interface", "into", "join", "like", "limit", "list", "long", "loop", "map", "merge", "new",
"not", "null", "nulls", "number", "object", "of", "on", "or", "outer", "override", "package", "parallel",
"pragma", "private", "protected", "public", "retrieve", "return",
"rollback", "select", "set", "short", "sObject", "sort", "static", "string",
"pragma", "private", "protected", "public", "retrieve", "return",
"rollback", "select", "set", "short", "sObject", "sort", "static", "string",
"super", "switch", "synchronized", "system", "testmethod", "then", "this",
"throw", "time", "transaction", "trigger", "true", "try", "undelete", "update", "upsert", "using",
"virtual", "void", "webservice", "when", "where", "while"

View File

@ -31,6 +31,7 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@ -402,6 +403,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
}
supportingFiles.add(new SupportingFile("Authentication" + File.separator + "ApiAuthentication.mustache", packageFolder + File.separator + "Authentication", "ApiAuthentication.cs"));
supportingFiles.add(new SupportingFile("Formatters" + File.separator + "InputFormatterStream.mustache", packageFolder + File.separator + "Formatters", "InputFormatterStream.cs"));
}
public void setPackageGuid(String packageGuid) {
@ -441,6 +443,68 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
operation.httpMethod = "Http" + operation.httpMethod.substring(0, 1) + operation.httpMethod.substring(1).toLowerCase(Locale.ROOT);
}
@Override
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
super.postProcessOperationsWithModels(objs, allModels);
// We need to postprocess the operations to add proper consumes tags and fix form file handling
if (objs != null) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
if (operations != null) {
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
for (CodegenOperation operation : ops) {
if (operation.consumes == null) {
continue;
}
if (operation.consumes.size() == 0) {
continue;
}
// Build a consumes string for the operation we cannot iterate in the template as we need a ','
// after each entry but the last
StringBuilder consumesString = new StringBuilder();
for (Map<String, String> consume : operation.consumes) {
if (!consume.containsKey("mediaType")) {
continue;
}
if(consumesString.toString().equals("")) {
consumesString = new StringBuilder("\"" + consume.get("mediaType") + "\"");
}
else {
consumesString.append(", \"").append(consume.get("mediaType")).append("\"");
}
// In a multipart/form-data consuming context binary data is best handled by an IFormFile
if (!consume.get("mediaType").equals("multipart/form-data")) {
continue;
}
// Change dataType of binary parameters to IFormFile for formParams in multipart/form-data
for (CodegenParameter param : operation.formParams) {
if (param.isBinary) {
param.dataType = "IFormFile";
param.baseType = "IFormFile";
}
}
for (CodegenParameter param : operation.allParams) {
if (param.isBinary && param.isFormParam) {
param.dataType = "IFormFile";
param.baseType = "IFormFile";
}
}
}
if(!consumesString.toString().equals("")) {
operation.vendorExtensions.put("x-aspnetcore-consumes", consumesString.toString());
}
}
}
}
return objs;
}
@Override
public Mustache.Compiler processCompiler(Mustache.Compiler compiler) {
// To avoid unexpected behaviors when options are passed programmatically such as { "useCollection": "" }

View File

@ -21,9 +21,6 @@ import org.openapitools.codegen.meta.GeneratorMetadata;
import org.openapitools.codegen.meta.Stability;
import org.openapitools.codegen.meta.features.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.Arrays;
import java.util.EnumSet;

View File

@ -28,6 +28,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.camelize;
@ -890,8 +891,10 @@ public class CLibcurlClientCodegen extends DefaultCodegen implements CodegenConf
} else {
LOGGER.info("Successfully executed: " + command);
}
} catch (Exception e) {
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
// Restore interrupted state
Thread.currentThread().interrupt();
}
}
}

View File

@ -651,7 +651,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
postProcessPattern(parameter.pattern, parameter.vendorExtensions);
postProcessEmitDefaultValue(parameter.vendorExtensions);
super.postProcessParameter(parameter);
if (nullableType.contains(parameter.dataType)) {
if (!parameter.required) { //optional
parameter.dataType = parameter.dataType + "?";
@ -666,7 +666,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
postProcessPattern(property.pattern, property.vendorExtensions);
postProcessEmitDefaultValue(property.vendorExtensions);
super.postProcessModelProperty(model, property);
if (!property.isContainer && (nullableType.contains(property.dataType) || property.isEnum)) {
property.vendorExtensions.put("x-csharp-value-type", true);
}

View File

@ -20,7 +20,6 @@ import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.features.*;
import org.openapitools.codegen.utils.ModelUtils;

View File

@ -33,7 +33,6 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
import static org.openapitools.codegen.utils.OnceLogger.once;
import static org.openapitools.codegen.utils.StringUtils.dashize;
import static org.openapitools.codegen.utils.StringUtils.underscore;

View File

@ -128,7 +128,7 @@ public class ConfluenceWikiCodegen extends DefaultCodegen implements CodegenConf
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
return postProcessModelsEnum(objs);
}
@Override
public String escapeQuotationMark(String input) {
// just return the original string
@ -140,13 +140,13 @@ public class ConfluenceWikiCodegen extends DefaultCodegen implements CodegenConf
// just return the original string
return input;
}
@Override
public String escapeText(String input) {
if (input == null) {
return input;
}
// chomp tailing newline because it breaks the tables and keep all other sign to show documentation properly
return StringUtils.chomp(input);
}

View File

@ -32,7 +32,6 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
import static org.openapitools.codegen.utils.OnceLogger.once;
import static org.openapitools.codegen.utils.StringUtils.underscore;
public class CppPistacheServerCodegen extends AbstractCppCodegen {

View File

@ -13,8 +13,6 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
import static org.openapitools.codegen.utils.OnceLogger.once;
public class CppQt5AbstractCodegen extends AbstractCppCodegen implements CodegenConfig {
private final Logger LOGGER = LoggerFactory.getLogger(CppQt5AbstractCodegen.class);
protected final String PREFIX = "OAI";

View File

@ -97,7 +97,7 @@ public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements Codege
supportingFiles.add(new SupportingFile("ServerConfiguration.mustache", sourceFolder, PREFIX +"ServerConfiguration.h"));
supportingFiles.add(new SupportingFile("ServerVariable.mustache", sourceFolder, PREFIX +"ServerVariable.h"));
supportingFiles.add(new SupportingFile("README.mustache", "","README.md"));
supportingFiles.add(new SupportingFile("CMakeLists.txt.mustache", sourceFolder, "CMakeLists.txt"));
supportingFiles.add(new SupportingFile("CMakeLists.txt.mustache", sourceFolder, "CMakeLists.txt"));
if (optionalProjectFileFlag) {
supportingFiles.add(new SupportingFile("Project.mustache", sourceFolder, "client.pri"));
}
@ -122,14 +122,14 @@ public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements Codege
supportingFiles.add(new SupportingFile("HttpRequest.h.mustache", sourceFolder, modelNamePrefix + "HttpRequest.h"));
supportingFiles.add(new SupportingFile("HttpRequest.cpp.mustache", sourceFolder, modelNamePrefix + "HttpRequest.cpp"));
supportingFiles.add(new SupportingFile("HttpFileElement.h.mustache", sourceFolder, modelNamePrefix + "HttpFileElement.h"));
supportingFiles.add(new SupportingFile("HttpFileElement.cpp.mustache", sourceFolder, modelNamePrefix + "HttpFileElement.cpp"));
supportingFiles.add(new SupportingFile("HttpFileElement.cpp.mustache", sourceFolder, modelNamePrefix + "HttpFileElement.cpp"));
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder, modelNamePrefix + "Object.h"));
supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder, modelNamePrefix + "Enum.h"));
supportingFiles.add(new SupportingFile("ServerConfiguration.mustache", sourceFolder, modelNamePrefix + "ServerConfiguration.h"));
supportingFiles.add(new SupportingFile("ServerVariable.mustache", sourceFolder, modelNamePrefix + "ServerVariable.h"));
supportingFiles.add(new SupportingFile("README.mustache", "","README.md"));
supportingFiles.add(new SupportingFile("CMakeLists.txt.mustache", sourceFolder, "CMakeLists.txt"));
typeMapping.put("file", modelNamePrefix + "HttpFileElement");
importMapping.put(modelNamePrefix + "HttpFileElement", "#include \"" + modelNamePrefix + "HttpFileElement.h\"");

View File

@ -29,7 +29,6 @@ import java.io.File;
import java.util.*;
import java.util.Map.Entry;
import static org.openapitools.codegen.utils.OnceLogger.once;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class CppRestbedServerCodegen extends AbstractCppCodegen {

View File

@ -509,7 +509,7 @@ public class CppUE4ClientCodegen extends AbstractCppCodegen {
if (isReservedWord(name) || name.matches("^\\d.*")) {
name = escapeReservedWord(name);
}
return name;
}

View File

@ -25,13 +25,13 @@ import org.openapitools.codegen.meta.GeneratorMetadata;
import org.openapitools.codegen.meta.Stability;
import org.openapitools.codegen.meta.features.*;
import org.openapitools.codegen.templating.mustache.PrefixWithHashLambda;
import org.openapitools.codegen.templating.mustache.TrimWhitespaceLambda;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
@ -883,8 +883,10 @@ public class CrystalClientCodegen extends DefaultCodegen {
} else {
LOGGER.info("Successfully executed: " + command);
}
} catch (Exception e) {
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
// Restore interrupted state
Thread.currentThread().interrupt();
}
}
}

View File

@ -17,8 +17,6 @@
package org.openapitools.codegen.languages;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.GeneratorMetadata;
import org.openapitools.codegen.meta.Stability;
import org.openapitools.codegen.meta.features.*;
import org.openapitools.codegen.utils.ModelUtils;

View File

@ -391,7 +391,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
}
static class ParameterSorter implements Comparator<CodegenParameter> {
public int compare(final CodegenParameter p1, final CodegenParameter p2) {
public int compare(final CodegenParameter p1, final CodegenParameter p2) {
return index(p1) - index(p2);
}
@ -410,8 +410,8 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
}
return 5;
}
}
}
@Override
public String toDefaultValue(Schema p) {
if (ModelUtils.isStringSchema(p)) {

View File

@ -19,16 +19,9 @@ package org.openapitools.codegen.languages;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.GeneratorMetadata;
import org.openapitools.codegen.meta.Stability;
import io.swagger.models.properties.ArrayProperty;
import io.swagger.models.properties.MapProperty;
import io.swagger.models.properties.Property;
import io.swagger.models.parameters.Parameter;
import java.io.File;
import java.util.*;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.meta.features.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -33,6 +33,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -1456,8 +1457,10 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
} else {
LOGGER.info("Successfully executed: " + command);
}
} catch (Exception e) {
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
// Restore interrupted state
Thread.currentThread().interrupt();
}
}
}

View File

@ -31,10 +31,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.regex.Pattern;
import static org.openapitools.codegen.utils.OnceLogger.once;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class HaskellServantCodegen extends DefaultCodegen implements CodegenConfig {
@ -450,7 +450,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
for (CodegenParameter param : pathParams) {
captureTypes.put(param.baseName, param.dataType);
}
// Properly handle root-only routes (#3256)
if (path.contentEquals("/")) {
return new ArrayList<>();
@ -694,8 +694,10 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
} else {
LOGGER.info("Successfully executed: " + command);
}
} catch (Exception e) {
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
// Restore interrupted state
Thread.currentThread().interrupt();
}
}
}

View File

@ -17,7 +17,6 @@
package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.Operation;
import org.openapitools.codegen.*;
import org.openapitools.codegen.languages.features.CXFServerFeatures;
import org.openapitools.codegen.languages.features.GzipTestFeatures;
@ -27,8 +26,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.List;
import java.util.Map;
public class JavaCXFServerCodegen extends AbstractJavaJAXRSServerCodegen
implements CXFServerFeatures, GzipTestFeatures, LoggingTestFeatures, UseGenericResponseFeatures {

View File

@ -17,13 +17,11 @@
package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.Operation;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.features.DocumentationFeature;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

View File

@ -31,7 +31,6 @@ import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.openapitools.codegen.utils.OnceLogger.once;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class JavaPlayFrameworkCodegen extends AbstractJavaCodegen implements BeanValidationFeatures {

View File

@ -17,9 +17,7 @@
package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.Operation;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.languages.features.BeanValidationFeatures;
import org.openapitools.codegen.languages.features.JbossFeature;
@ -27,7 +25,6 @@ import org.openapitools.codegen.languages.features.SwaggerFeatures;
import org.openapitools.codegen.meta.features.DocumentationFeature;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

View File

@ -17,15 +17,12 @@
package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.Operation;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.languages.features.JbossFeature;
import org.openapitools.codegen.meta.features.DocumentationFeature;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

View File

@ -32,9 +32,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.util.*;
import static org.openapitools.codegen.utils.OnceLogger.once;
import static org.openapitools.codegen.utils.StringUtils.*;
public class JavascriptApolloClientCodegen extends DefaultCodegen implements CodegenConfig {
@ -1135,8 +1135,10 @@ public class JavascriptApolloClientCodegen extends DefaultCodegen implements Cod
LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue);
}
LOGGER.info("Successfully executed: " + command);
} catch (Exception e) {
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
// Restore interrupted state
Thread.currentThread().interrupt();
}
}
}

View File

@ -31,9 +31,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.util.*;
import static org.openapitools.codegen.utils.OnceLogger.once;
import static org.openapitools.codegen.utils.StringUtils.*;
public class JavascriptClientCodegen extends DefaultCodegen implements CodegenConfig {
@ -1220,8 +1220,10 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue);
}
LOGGER.info("Successfully executed: " + command);
} catch (Exception e) {
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
// Restore interrupted state
Thread.currentThread().interrupt();
}
}
}

View File

@ -23,8 +23,6 @@ import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.features.DocumentationFeature;
import org.openapitools.codegen.utils.ModelUtils;
import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.dashize;

View File

@ -31,8 +31,6 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
final Logger LOGGER = LoggerFactory.getLogger(NimClientCodegen.class);

View File

@ -36,6 +36,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.*;
import java.util.Map.Entry;
@ -445,8 +446,10 @@ public class NodeJSExpressServerCodegen extends DefaultCodegen implements Codege
LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue);
}
LOGGER.info("Successfully executed: " + command);
} catch (Exception e) {
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
// Restore interrupted state
Thread.currentThread().interrupt();
}
}
}

View File

@ -31,12 +31,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
import static org.apache.commons.lang3.StringUtils.capitalize;
import static org.openapitools.codegen.utils.OnceLogger.once;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.escape;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@ -817,8 +816,10 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
} else {
LOGGER.info("Successfully executed: " + command);
}
} catch (Exception e) {
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
// Restore interrupted state
Thread.currentThread().interrupt();
}
}
}

View File

@ -29,7 +29,6 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
import static org.openapitools.codegen.utils.OnceLogger.once;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {

View File

@ -28,6 +28,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.regex.Matcher;
@ -621,8 +622,10 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
} else {
LOGGER.info("Successfully executed: " + command);
}
} catch (Exception e) {
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
// Restore interrupted state
Thread.currentThread().interrupt();
}
}
}

View File

@ -175,7 +175,7 @@ public class PhpLumenServerCodegen extends AbstractPhpCodegen {
op.httpMethod = op.httpMethod.toLowerCase(Locale.ROOT);
}
// sort the endpoints in ascending to avoid the route priority issure.
// sort the endpoints in ascending to avoid the route priority issure.
Collections.sort(operations, new Comparator<CodegenOperation>() {
@Override
public int compare(CodegenOperation lhs, CodegenOperation rhs) {

View File

@ -29,7 +29,6 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
import static org.openapitools.codegen.utils.OnceLogger.once;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements CodegenConfig {

View File

@ -31,6 +31,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.util.*;
import static java.util.UUID.randomUUID;
@ -1311,8 +1312,10 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
} else {
LOGGER.info("Successfully executed: " + command);
}
} catch (Exception e) {
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
// Restore interrupted state
Thread.currentThread().interrupt();
}
}

View File

@ -17,25 +17,14 @@
package org.openapitools.codegen.languages;
import com.github.curiousoddman.rgxgen.RgxGen;
import io.swagger.v3.oas.models.examples.Example;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.parameters.Parameter;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.features.*;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
public class PythonLegacyClientCodegen extends AbstractPythonCodegen implements CodegenConfig {

View File

@ -199,7 +199,7 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
additionalProperties.put(CodegenConstants.EXCEPTION_ON_FAILURE, returnExceptionOnFailure);
additionalProperties.put(USE_DEFAULT_EXCEPTION, this.useDefaultExceptionHandling);
additionalProperties.put(USE_RLANG_EXCEPTION, this.useRlangExceptionHandling);
@ -358,7 +358,7 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
return getSchemaType(p) + "[" + getTypeDeclaration(inner)+ "]";
return getSchemaType(p) + "[" + getTypeDeclaration(inner)+ "]";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = getAdditionalProperties(p);
return getSchemaType(p) + "(" + getTypeDeclaration(inner) + ")";

View File

@ -27,9 +27,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.EnumSet;
import java.util.Locale;
import java.util.Map;
import static org.openapitools.codegen.utils.StringUtils.camelize;

View File

@ -224,7 +224,7 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
Map<String, Object> mas = new HashMap<>();
mas.put("modelName", camelize(mappedModel.getModelName()));
mas.put("mappingName", mappedModel.getMappingName());
// TODO: deleting the variable from the array was
// problematic; I don't know what this is supposed to do
// so I'm just cloning it for the moment

View File

@ -39,6 +39,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.*;
import java.util.Map.Entry;
@ -1670,8 +1671,10 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
} else {
LOGGER.info("Successfully executed: {} {}", commandPrefix, file.toString());
}
} catch (Exception e) {
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({} ()). Exception: {}", commandPrefix, file.toString(), e.getMessage());
// Restore interrupted state
Thread.currentThread().interrupt();
}
}
}

View File

@ -40,11 +40,16 @@ public class ScalaAkkaHttpServerCodegen extends AbstractScalaCodegen implements
protected String invokerPackage;
protected String akkaHttpVersion;
protected boolean generateAsManagedSources;
public static final String AKKA_HTTP_VERSION = "akkaHttpVersion";
public static final String AKKA_HTTP_VERSION_DESC = "The version of akka-http";
public static final String DEFAULT_AKKA_HTTP_VERSION = "10.1.10";
public static final String GENERATE_AS_MANAGED_SOURCES = "asManagedSources";
public static final String GENERATE_AS_MANAGED_SOURCES_DESC = "Resulting files cab be used as managed resources. No build files or default controllers will be generated";
public static final boolean DEFAULT_GENERATE_AS_MANAGED_SOURCES = false;
static final Logger LOGGER = LoggerFactory.getLogger(ScalaAkkaHttpServerCodegen.class);
public CodegenType getTag() {
@ -99,6 +104,7 @@ public class ScalaAkkaHttpServerCodegen extends AbstractScalaCodegen implements
modelPackage = "org.openapitools.server.model";
invokerPackage = "org.openapitools.server";
akkaHttpVersion = DEFAULT_AKKA_HTTP_VERSION;
generateAsManagedSources = DEFAULT_GENERATE_AS_MANAGED_SOURCES;
setReservedWordsLowerCase(
Arrays.asList(
@ -114,6 +120,7 @@ public class ScalaAkkaHttpServerCodegen extends AbstractScalaCodegen implements
cliOptions.add(CliOption.newString(CodegenConstants.ARTIFACT_ID, CodegenConstants.ARTIFACT_ID).defaultValue(artifactId));
cliOptions.add(CliOption.newString(CodegenConstants.ARTIFACT_VERSION, CodegenConstants.ARTIFACT_VERSION_DESC).defaultValue(artifactVersion));
cliOptions.add(CliOption.newString(AKKA_HTTP_VERSION, AKKA_HTTP_VERSION_DESC).defaultValue(akkaHttpVersion));
cliOptions.add(CliOption.newBoolean(GENERATE_AS_MANAGED_SOURCES, GENERATE_AS_MANAGED_SOURCES_DESC).defaultValue(Boolean.valueOf(DEFAULT_GENERATE_AS_MANAGED_SOURCES).toString()));
importMapping.remove("Seq");
importMapping.remove("List");
@ -141,8 +148,6 @@ public class ScalaAkkaHttpServerCodegen extends AbstractScalaCodegen implements
instantiationTypes.put("array", "ListBuffer");
instantiationTypes.put("map", "Map");
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
}
@Override
@ -181,9 +186,19 @@ public class ScalaAkkaHttpServerCodegen extends AbstractScalaCodegen implements
parseAkkaHttpVersion();
supportingFiles.add(new SupportingFile("build.sbt.mustache", "", "build.sbt"));
supportingFiles.add(new SupportingFile("controller.mustache",
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "Controller.scala"));
if (additionalProperties.containsKey(GENERATE_AS_MANAGED_SOURCES)) {
generateAsManagedSources = Boolean.parseBoolean(additionalProperties.get(GENERATE_AS_MANAGED_SOURCES).toString());
} else {
additionalProperties.put(GENERATE_AS_MANAGED_SOURCES, Boolean.valueOf(generateAsManagedSources).toString());
}
if (!generateAsManagedSources) {
supportingFiles.add(new SupportingFile("build.sbt.mustache", "", "build.sbt"));
supportingFiles.add(new SupportingFile("controller.mustache",
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "Controller.scala"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
}
supportingFiles.add(new SupportingFile("helper.mustache",
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "AkkaHttpHelper.scala"));
supportingFiles.add(new SupportingFile("stringDirectives.mustache",

View File

@ -28,8 +28,6 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
import static org.openapitools.codegen.utils.OnceLogger.once;
public class ScalaFinchServerCodegen extends DefaultCodegen implements CodegenConfig {
private final Logger LOGGER = LoggerFactory.getLogger(ScalaFinchServerCodegen.class);
protected String invokerPackage = "org.openapitools.client";

View File

@ -31,7 +31,6 @@ import java.util.EnumSet;
import java.util.HashMap;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
/*
* This generator has been deprecated. Please use scala-akka instead.

View File

@ -26,7 +26,6 @@ import org.slf4j.LoggerFactory;
import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
public class ScalaLagomServerCodegen extends AbstractScalaCodegen implements CodegenConfig {
private final Logger LOGGER = LoggerFactory.getLogger(ScalaLagomServerCodegen.class);

View File

@ -36,7 +36,6 @@ import java.util.stream.Collectors;
import static org.apache.commons.lang3.StringUtils.rightPad;
import static org.openapitools.codegen.languages.AbstractJavaCodegen.DATE_LIBRARY;
import static org.openapitools.codegen.utils.OnceLogger.once;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class ScalaPlayFrameworkServerCodegen extends AbstractScalaCodegen implements CodegenConfig {

View File

@ -874,25 +874,4 @@ public class SpringCodegen extends AbstractJavaCodegen
public void setUseOptional(boolean useOptional) {
this.useOptional = useOptional;
}
@Override
public void postProcessParameter(CodegenParameter p) {
// we use a custom version of this function to remove the l, d, and f suffixes from Long/Double/Float
// defaultValues
// remove the l because our users will use Long.parseLong(String defaultValue)
// remove the d because our users will use Double.parseDouble(String defaultValue)
// remove the f because our users will use Float.parseFloat(String defaultValue)
// NOTE: for CodegenParameters we DO need these suffixes because those defaultValues are used as java value
// literals assigned to Long/Double/Float
if (p.defaultValue == null) {
return;
}
Boolean fixLong = (p.isLong && "l".equals(p.defaultValue.substring(p.defaultValue.length()-1)));
Boolean fixDouble = (p.isDouble && "d".equals(p.defaultValue.substring(p.defaultValue.length()-1)));
Boolean fixFloat = (p.isFloat && "f".equals(p.defaultValue.substring(p.defaultValue.length()-1)));
if (fixLong || fixDouble || fixFloat) {
p.defaultValue = p.defaultValue.substring(0, p.defaultValue.length()-1);
}
}
}

View File

@ -35,7 +35,6 @@ import org.slf4j.LoggerFactory;
import java.util.*;
import static org.openapitools.codegen.utils.OnceLogger.once;
import static org.openapitools.codegen.utils.StringUtils.*;
public class StaticHtml2Generator extends DefaultCodegen implements CodegenConfig {

View File

@ -32,6 +32,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -243,7 +244,7 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
+ StringUtils.join(RESPONSE_LIBRARIES, ", ")
+ " are available."));
cliOptions.add(new CliOption(CodegenConstants.NON_PUBLIC_API,
CodegenConstants.NON_PUBLIC_API_DESC
CodegenConstants.NON_PUBLIC_API_DESC
+ "(default: false)"));
cliOptions.add(new CliOption(UNWRAP_REQUIRED,
"Treat 'required' properties in response as non-optional "
@ -428,8 +429,8 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
supportingFiles.add(new SupportingFile("Cartfile.mustache",
"",
"Cartfile"));
supportingFiles.add(new SupportingFile("Package.swift.mustache",
"",
supportingFiles.add(new SupportingFile("Package.swift.mustache",
"",
"Package.swift"));
supportingFiles.add(new SupportingFile("APIHelper.mustache",
sourceFolder,
@ -459,8 +460,8 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
sourceFolder,
"JSONEncodingHelper.swift"));
if (ArrayUtils.contains(responseAs, LIBRARY_RESULT)) {
supportingFiles.add(new SupportingFile("Result.mustache",
sourceFolder,
supportingFiles.add(new SupportingFile("Result.mustache",
sourceFolder,
"Result.swift"));
}
supportingFiles.add(new SupportingFile("git_push.sh.mustache",
@ -974,8 +975,10 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
} else {
LOGGER.info("Successfully executed: " + command);
}
} catch (Exception e) {
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
// Restore interrupted state
Thread.currentThread().interrupt();
}
}
}

View File

@ -31,6 +31,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -41,7 +42,6 @@ import java.util.concurrent.TimeUnit;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig {
private final Logger LOGGER = LoggerFactory.getLogger(Swift5ClientCodegen.class);
@ -979,8 +979,10 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
} else {
LOGGER.info("Successfully executed: " + command);
}
} catch (Exception e) {
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
// Restore interrupted state
Thread.currentThread().interrupt();
}
}
}

View File

@ -41,7 +41,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
private static String FILE_NAME_SUFFIX_PATTERN = "^[a-zA-Z0-9.-]*$";
public static enum QUERY_PARAM_OBJECT_FORMAT_TYPE {dot, json, key}
public static enum PROVIDED_IN_LEVEL {none, root, any, platform}
public static enum PROVIDED_IN_LEVEL {none, root, any, platform}
private static final String DEFAULT_IMPORT_PREFIX = "./";
@ -190,7 +190,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
apiTemplateFiles.put("apiInterface.mustache", "Interface.ts");
}
}
if (additionalProperties.containsKey(USE_SINGLE_REQUEST_PARAMETER)) {
this.setUseSingleRequestParameter(convertPropertyToBoolean(USE_SINGLE_REQUEST_PARAMETER));
}
@ -223,7 +223,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
additionalProperties.put("providedIn", providedIn);
additionalProperties.put("isProvidedInNone", getIsProvidedInNone());
if (ngVersion.atLeast("9.0.0")) {
if (ngVersion.atLeast("9.0.0")) {
additionalProperties.put(ENFORCE_GENERIC_MODULE_WITH_PROVIDERS, true);
} else {
additionalProperties.put(ENFORCE_GENERIC_MODULE_WITH_PROVIDERS, false);
@ -386,7 +386,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
public boolean isDataTypeFile(final String dataType) {
return dataType != null && dataType.equals("Blob");
}
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isFileSchema(p)) {
@ -739,10 +739,10 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
}
return name;
}
/**
* Set the Injectable level
*
*
* @param level the wanted level
*/
public void setProvidedIn (String level) {
@ -757,9 +757,9 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
throw new IllegalArgumentException(msg);
}
}
/**
*
*
*/
private boolean getIsProvidedInNone() {
return PROVIDED_IN_LEVEL.none.equals(providedIn);

View File

@ -22,8 +22,6 @@ import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.features.DocumentationFeature;
import org.openapitools.codegen.utils.ModelUtils;
import java.util.*;
public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodegen {

View File

@ -19,11 +19,8 @@ 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.NumberSchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.parameters.Parameter;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.GeneratorMetadata;
@ -35,7 +32,6 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Map.Entry;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@ -62,9 +58,9 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
private static final String USE_OBJECT_PARAMS_SWITCH = "useObjectParameters";
private static final String USE_OBJECT_PARAMS_DESC = "Use aggregate parameter objects as function arguments for api operations instead of passing each parameter as a separate function argument.";
private final Map<String, String> frameworkToHttpLibMap;
// NPM Options
private static final String SNAPSHOT = "snapshot";
@SuppressWarnings("squid:S5164")
@ -83,14 +79,14 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
public TypeScriptClientCodegen() {
super();
this.frameworkToHttpLibMap = new HashMap<>();
this.frameworkToHttpLibMap.put("fetch-api", "isomorphic-fetch");
this.frameworkToHttpLibMap.put("jquery", "jquery");
this.generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata).stability(Stability.EXPERIMENTAL).build();
// clear import mapping (from default generator) as TS does not use it
// at the moment
importMapping.clear();
@ -98,7 +94,7 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
embeddedTemplateDir = templateDir = "typescript";
supportsInheritance = true;
// NOTE: TypeScript uses camel cased reserved words, while models are title cased. We don't want lowercase comparisons.
reservedWords.addAll(Arrays.asList(
// local variable names used in API methods (endpoints)
@ -155,7 +151,7 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
typeMapping.put("ByteArray", "string");
typeMapping.put("UUID", "string");
typeMapping.put("Error", "Error");
cliOptions.add(new CliOption(NPM_NAME, "The name under which you want to publish generated npm package." +
" Required to generate a full package"));
@ -186,11 +182,11 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
platformOption.defaultValue(PLATFORMS[0]);
cliOptions.add(platformOption);
// Git
supportingFiles.add(new SupportingFile(".gitignore.mustache", "", ".gitignore"));
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
// Util
supportingFiles.add(new SupportingFile("util.mustache", "", "util.ts"));
supportingFiles.add(new SupportingFile("api" + File.separator + "exception.mustache", "apis", "exception.ts"));
@ -200,7 +196,7 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
supportingFiles.add(new SupportingFile("configuration.mustache", "", "configuration.ts"));
supportingFiles.add(new SupportingFile("auth" + File.separator + "auth.mustache", "auth", "auth.ts"));
supportingFiles.add(new SupportingFile("model" + File.separator + "models_all.mustache", "models", "all.ts"));
supportingFiles.add(new SupportingFile("types" + File.separator + "PromiseAPI.mustache", "types", "PromiseAPI.ts"));
@ -242,12 +238,12 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
public void setNpmVersion(String npmVersion) {
this.npmVersion = npmVersion;
}
@Override
public CodegenType getTag() {
return CodegenType.CLIENT;
}
@Override
public void preprocessOpenAPI(OpenAPI openAPI) {
@ -272,9 +268,9 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
}
}
@Override
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
final Object propFramework = additionalProperties.get(FRAMEWORK_SWITCH);
Map<String, Boolean> frameworks = new HashMap<>();
@ -288,27 +284,27 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
return objs;
}
@Override
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> operations, List<Object> models) {
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> operations, List<Object> models) {
// Add additional filename information for model imports in the apis
List<Map<String, Object>> imports = (List<Map<String, Object>>) operations.get("imports");
for (Map<String, Object> im : imports) {
im.put("filename", ((String) im.get("import")).replace(".", "/"));
im.put("classname", getModelnameFromModelFilename(im.get("import").toString()));
}
@SuppressWarnings("unchecked")
Map<String, Object> operationsMap = (Map<String, Object>) operations.get("operations");
List<CodegenOperation> operationList = (List<CodegenOperation>) operationsMap.get("operation");
for (CodegenOperation operation: operationList) {
List<CodegenResponse> responses = operation.responses;
operation.returnType = this.getReturnType(responses);
operation.returnType = this.getReturnType(responses);
}
return operations;
}
/**
* Returns the correct return type based on all 2xx HTTP responses defined for an operation.
* @param responses all CodegenResponses defined for one operation
@ -325,19 +321,19 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
}
}
}
if (returnTypes.size() == 0) {
return null;
}
}
return String.join(" | ", returnTypes);
}
private String getModelnameFromModelFilename(String filename) {
String name = filename.substring((modelPackage() + File.separator).length());
return camelize(name);
}
@Override
public String escapeReservedWord(String name) {
if (this.reservedWordsMappings().containsKey(name)) {
@ -514,7 +510,7 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
}
}
@Override
protected boolean isReservedWord(String word) {
// NOTE: This differs from super's implementation in that TypeScript does _not_ want case insensitive matching.
@ -739,7 +735,7 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
public String escapeUnsafeCharacters(String input) {
return input.replace("*/", "*_/").replace("/*", "/_*");
}
@Override
public String getName() {
return "typescript";

View File

@ -19,7 +19,6 @@ package org.openapitools.codegen.languages;
import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.openapitools.codegen.*;

View File

@ -23,8 +23,6 @@ import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.features.DocumentationFeature;
import org.openapitools.codegen.utils.ModelUtils;
import java.io.File;
import java.util.*;

View File

@ -20,7 +20,6 @@ import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.GeneratorMetadata;
import org.openapitools.codegen.meta.Stability;
import org.openapitools.codegen.meta.features.*;
import org.openapitools.codegen.utils.ModelUtils;
import org.openapitools.codegen.utils.SemVer;
import org.slf4j.Logger;

View File

@ -17,7 +17,6 @@
package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.openapitools.codegen.*;

View File

@ -17,12 +17,9 @@
package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.FeatureSet;
import org.openapitools.codegen.meta.GeneratorMetadata;
import org.openapitools.codegen.meta.features.DocumentationFeature;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
@ -31,8 +28,6 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
import static org.openapitools.codegen.utils.OnceLogger.once;
public class TypeScriptRxjsClientCodegen extends AbstractTypeScriptClientCodegen {
private final Logger LOGGER = LoggerFactory.getLogger(AbstractTypeScriptClientCodegen.class);
@ -259,7 +254,7 @@ public class TypeScriptRxjsClientCodegen extends AbstractTypeScriptClientCodegen
// This method will determine if there are required parameters and if there are list containers
Map<String, Object> _operations = (Map<String, Object>) operations.get("operations");
List<ExtendedCodegenOperation> operationList = (List<ExtendedCodegenOperation>) _operations.get("operation");
boolean hasRequiredParams = false;
boolean hasListContainers = false;
boolean hasHttpHeaders = false;

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