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

This commit is contained in:
William Cheng
2021-03-30 13:18:35 +08:00
1103 changed files with 7928 additions and 9209 deletions

View File

@@ -28,14 +28,14 @@ jobs:
with:
java-version: ${{ matrix.java }}
- uses: actions/cache@v1
- uses: actions/cache@v2.1.4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('pom.xml', 'modules/**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- uses: actions/cache@v2
- uses: actions/cache@v2.1.4
with:
path: |
~/.gradle/caches
@@ -49,7 +49,7 @@ jobs:
run: mvn -nsu -B --quiet -Djacoco.skip=true -Dorg.slf4j.simpleLogger.defaultLogLevel=error --no-transfer-progress clean install --file pom.xml ${{ matrix.flags }}
- name: Upload Maven build artifact
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v2.2.2
if: matrix.java == '8' && matrix.os == 'ubuntu-latest'
with:
name: artifact
@@ -80,7 +80,7 @@ jobs:
- name: Check out code
uses: actions/checkout@v2
- name: Download build artifact
uses: actions/download-artifact@v1
uses: actions/download-artifact@v2.0.8
with:
name: artifact
- name: Run Ensures Script

View File

@@ -7,6 +7,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|enumNameSuffix|Suffix that will be appended to all enum names.| ||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|library|library template (sub-template) to use.|<dl><dt>**hyper**</dt><dd>HTTP client: Hyper.</dd><dt>**reqwest**</dt><dd>HTTP client: Reqwest.</dd></dl>|reqwest|
|packageName|Rust package name (convention: lowercase).| |openapi|

View File

@@ -26,9 +26,11 @@ import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
* Represents those settings applied to a generation workflow.
@@ -66,7 +68,7 @@ public class WorkflowSettings {
private String templateDir;
private String templatingEngineName = DEFAULT_TEMPLATING_ENGINE_NAME;
private String ignoreFileOverride;
private ImmutableMap<String, String> globalProperties = DEFAULT_GLOBAL_PROPERTIES;
private ImmutableMap<String, ?> globalProperties = DEFAULT_GLOBAL_PROPERTIES;
private WorkflowSettings(Builder builder) {
this.inputSpec = builder.inputSpec;
@@ -282,7 +284,15 @@ public class WorkflowSettings {
* @return the system properties
*/
public Map<String, String> getGlobalProperties() {
return globalProperties;
return globalProperties.entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getKey, e -> {
if (e.getValue() instanceof List) {
return ((List<?>) e.getValue()).stream()
.map(Object::toString)
.collect(Collectors.joining(","));
}
return String.valueOf(e.getValue());
}));
}
/**

View File

@@ -21,7 +21,7 @@ import org.testng.annotations.Test;
import static org.testng.Assert.*;
public class ValidationRuleTest {
class Sample {
static class Sample {
private String name;
public Sample(String name) {

View File

@@ -42,7 +42,7 @@ public class OpenAPI2SpringBoot implements CommandLineRunner {
new SpringApplication(OpenAPI2SpringBoot.class).run(args);
}
class ExitException extends RuntimeException implements ExitCodeGenerator {
static class ExitException extends RuntimeException implements ExitCodeGenerator {
private static final long serialVersionUID = 1L;
@Override

View File

@@ -813,11 +813,13 @@ public class DefaultCodegen implements CodegenConfig {
schemas.put(opId, requestSchema);
}
// process all response bodies
for (Map.Entry<String, ApiResponse> ar : op.getValue().getResponses().entrySet()) {
ApiResponse a = ModelUtils.getReferencedApiResponse(openAPI, ar.getValue());
Schema responseSchema = ModelUtils.getSchemaFromResponse(a);
if (responseSchema != null) {
schemas.put(opId + ar.getKey(), responseSchema);
if (op.getValue().getResponses() != null) {
for (Map.Entry<String, ApiResponse> ar : op.getValue().getResponses().entrySet()) {
ApiResponse a = ModelUtils.getReferencedApiResponse(openAPI, ar.getValue());
Schema responseSchema = ModelUtils.getSchemaFromResponse(a);
if (responseSchema != null) {
schemas.put(opId + ar.getKey(), responseSchema);
}
}
}
}

View File

@@ -385,14 +385,14 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(camelizedName)) {
final String modelName = "Model" + camelizedName;
LOGGER.warn(camelizedName + " (reserved word) cannot be used as model name. Renamed to " + modelName);
LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", camelizedName, modelName);
return modelName;
}
// model name starts with number
if (camelizedName.matches("^\\d.*")) {
final String modelName = "Model" + camelizedName; // e.g. 200Response => Model200Response (after camelize)
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + modelName);
LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", name, modelName);
return modelName;
}
@@ -471,7 +471,7 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
public String getSchemaType(Schema p) {
String openAPIType = super.getSchemaType(p);
if (openAPIType == null) {
LOGGER.error("No Type defined for Schema " + p);
LOGGER.error("No Type defined for Schema {}", p);
}
if (typeMapping.containsKey(openAPIType)) {
return typeMapping.get(openAPIType);
@@ -601,13 +601,13 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
String newOperationId = camelize("call_" + operationId, true);
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + camelize("call_" + operationId), true);
LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, camelize("call_" + operationId), true);
operationId = camelize("call_" + operationId, true);
}
@@ -685,8 +685,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

@@ -788,6 +788,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
@Override
public String toDefaultValue(Schema schema) {
schema = ModelUtils.unaliasSchema(this.openAPI, schema);
if (schema.getDefault() != null) {
return schema.getDefault().toString();
} else {

View File

@@ -275,12 +275,12 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
}
if (additionalProperties.containsKey(SUPPORT_JAVA6)) {
this.setSupportJava6(Boolean.valueOf(additionalProperties.get(SUPPORT_JAVA6).toString()));
this.setSupportJava6(Boolean.parseBoolean(additionalProperties.get(SUPPORT_JAVA6).toString()));
}
additionalProperties.put(SUPPORT_JAVA6, supportJava6);
if (additionalProperties.containsKey(DISABLE_HTML_ESCAPING)) {
this.setDisableHtmlEscaping(Boolean.valueOf(additionalProperties.get(DISABLE_HTML_ESCAPING).toString()));
this.setDisableHtmlEscaping(Boolean.parseBoolean(additionalProperties.get(DISABLE_HTML_ESCAPING).toString()));
}
additionalProperties.put(DISABLE_HTML_ESCAPING, disableHtmlEscaping);
@@ -290,7 +290,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
additionalProperties.put(BOOLEAN_GETTER_PREFIX, booleanGetterPrefix);
if (additionalProperties.containsKey(IGNORE_ANYOF_IN_ENUM)) {
this.setIgnoreAnyOfInEnum(Boolean.valueOf(additionalProperties.get(IGNORE_ANYOF_IN_ENUM).toString()));
this.setIgnoreAnyOfInEnum(Boolean.parseBoolean(additionalProperties.get(IGNORE_ANYOF_IN_ENUM).toString()));
}
additionalProperties.put(IGNORE_ANYOF_IN_ENUM, ignoreAnyOfInEnum);
@@ -427,17 +427,17 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
}
if (additionalProperties.containsKey(CodegenConstants.SERIALIZE_BIG_DECIMAL_AS_STRING)) {
this.setSerializeBigDecimalAsString(Boolean.valueOf(additionalProperties.get(CodegenConstants.SERIALIZE_BIG_DECIMAL_AS_STRING).toString()));
this.setSerializeBigDecimalAsString(Boolean.parseBoolean(additionalProperties.get(CodegenConstants.SERIALIZE_BIG_DECIMAL_AS_STRING).toString()));
}
// need to put back serializableModel (boolean) into additionalProperties as value in additionalProperties is string
additionalProperties.put(CodegenConstants.SERIALIZABLE_MODEL, serializableModel);
if (additionalProperties.containsKey(FULL_JAVA_UTIL)) {
this.setFullJavaUtil(Boolean.valueOf(additionalProperties.get(FULL_JAVA_UTIL).toString()));
this.setFullJavaUtil(Boolean.parseBoolean(additionalProperties.get(FULL_JAVA_UTIL).toString()));
}
if (additionalProperties.containsKey(DISCRIMINATOR_CASE_SENSITIVE)) {
this.setDiscriminatorCaseSensitive(Boolean.valueOf(additionalProperties.get(DISCRIMINATOR_CASE_SENSITIVE).toString()));
this.setDiscriminatorCaseSensitive(Boolean.parseBoolean(additionalProperties.get(DISCRIMINATOR_CASE_SENSITIVE).toString()));
} else {
// By default, the discriminator lookup should be case sensitive. There is nothing in the OpenAPI specification
// that indicates the lookup should be case insensitive. However, some implementations perform
@@ -453,12 +453,12 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
additionalProperties.put("javaUtilPrefix", javaUtilPrefix);
if (additionalProperties.containsKey(WITH_XML)) {
this.setWithXml(Boolean.valueOf(additionalProperties.get(WITH_XML).toString()));
this.setWithXml(Boolean.parseBoolean(additionalProperties.get(WITH_XML).toString()));
}
additionalProperties.put(WITH_XML, withXml);
if (additionalProperties.containsKey(OPENAPI_NULLABLE)) {
this.setOpenApiNullable(Boolean.valueOf(additionalProperties.get(OPENAPI_NULLABLE).toString()));
this.setOpenApiNullable(Boolean.parseBoolean(additionalProperties.get(OPENAPI_NULLABLE).toString()));
}
additionalProperties.put(OPENAPI_NULLABLE, openApiNullable);

View File

@@ -37,7 +37,7 @@ import java.util.regex.Pattern;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
abstract public class AbstractPythonCodegen extends DefaultCodegen implements CodegenConfig {
public abstract class AbstractPythonCodegen extends DefaultCodegen implements CodegenConfig {
private final Logger LOGGER = LoggerFactory.getLogger(AbstractPythonCodegen.class);
protected String packageName = "openapi_client";
@@ -144,7 +144,7 @@ abstract public class AbstractPythonCodegen extends DefaultCodegen implements Co
public String toDefaultValue(Schema p) {
if (ModelUtils.isBooleanSchema(p)) {
if (p.getDefault() != null) {
if (Boolean.valueOf(p.getDefault().toString()) == false)
if (!Boolean.valueOf(p.getDefault().toString()))
return "False";
else
return "True";
@@ -166,11 +166,13 @@ abstract public class AbstractPythonCodegen extends DefaultCodegen implements Co
if (Pattern.compile("\r\n|\r|\n").matcher((String) p.getDefault()).find())
return "'''" + p.getDefault() + "'''";
else
return "'" + ((String) p.getDefault()).replaceAll("'", "\'") + "'";
return "'" + ((String) p.getDefault()).replace("'", "\'") + "'";
}
} else if (ModelUtils.isArraySchema(p)) {
if (p.getDefault() != null) {
return p.getDefault().toString();
} else {
return null;
}
}
@@ -231,13 +233,13 @@ abstract public class AbstractPythonCodegen extends DefaultCodegen implements Co
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + underscore(sanitizeName("call_" + operationId)));
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, underscore(sanitizeName("call_" + operationId)));
operationId = "call_" + operationId;
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + underscore(sanitizeName("call_" + operationId)));
LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, underscore(sanitizeName("call_" + operationId)));
operationId = "call_" + operationId;
}
@@ -275,7 +277,7 @@ abstract public class AbstractPythonCodegen extends DefaultCodegen implements Co
if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue);
} else {
LOGGER.info("Successfully executed: " + command);
LOGGER.info("Successfully executed: {}", command);
}
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
@@ -287,12 +289,12 @@ abstract public class AbstractPythonCodegen extends DefaultCodegen implements Co
@Override
public String toExampleValue(Schema schema) {
return toExampleValueRecursive(schema, new ArrayList<String>(), 5);
return toExampleValueRecursive(schema, new ArrayList<>(), 5);
}
private String toExampleValueRecursive(Schema schema, List<String> included_schemas, int indentation) {
String indentation_string = "";
for (int i = 0; i < indentation; i++) indentation_string += " ";
private String toExampleValueRecursive(Schema schema, List<String> includedSchemas, int indentation) {
String indentationString = "";
for (int i = 0; i < indentation; i++) indentationString += " ";
String example = null;
if (schema.getExample() != null) {
example = schema.getExample().toString();
@@ -345,9 +347,9 @@ abstract public class AbstractPythonCodegen extends DefaultCodegen implements Co
refSchema.setTitle(ref);
}
if (StringUtils.isNotBlank(schema.getTitle()) && !"null".equals(schema.getTitle())) {
included_schemas.add(schema.getTitle());
includedSchemas.add(schema.getTitle());
}
return toExampleValueRecursive(refSchema, included_schemas, indentation);
return toExampleValueRecursive(refSchema, includedSchemas, indentation);
}
} else {
LOGGER.warn("allDefinitions not defined in toExampleValue!\n");
@@ -410,25 +412,25 @@ abstract public class AbstractPythonCodegen extends DefaultCodegen implements Co
example = "True";
} else if (ModelUtils.isArraySchema(schema)) {
if (StringUtils.isNotBlank(schema.getTitle()) && !"null".equals(schema.getTitle())) {
included_schemas.add(schema.getTitle());
includedSchemas.add(schema.getTitle());
}
ArraySchema arrayschema = (ArraySchema) schema;
example = "[\n" + indentation_string + toExampleValueRecursive(arrayschema.getItems(), included_schemas, indentation + 1) + "\n" + indentation_string + "]";
example = "[\n" + indentationString + toExampleValueRecursive(arrayschema.getItems(), includedSchemas, indentation + 1) + "\n" + indentationString + "]";
} else if (ModelUtils.isMapSchema(schema)) {
if (StringUtils.isNotBlank(schema.getTitle()) && !"null".equals(schema.getTitle())) {
included_schemas.add(schema.getTitle());
includedSchemas.add(schema.getTitle());
}
Object additionalObject = schema.getAdditionalProperties();
if (additionalObject instanceof Schema) {
Schema additional = (Schema) additionalObject;
String the_key = "'key'";
String theKey = "'key'";
if (additional.getEnum() != null && !additional.getEnum().isEmpty()) {
the_key = additional.getEnum().get(0).toString();
theKey = additional.getEnum().get(0).toString();
if (ModelUtils.isStringSchema(additional)) {
the_key = "'" + escapeText(the_key) + "'";
theKey = "'" + escapeText(theKey) + "'";
}
}
example = "{\n" + indentation_string + the_key + " : " + toExampleValueRecursive(additional, included_schemas, indentation + 1) + "\n" + indentation_string + "}";
example = "{\n" + indentationString + theKey + " : " + toExampleValueRecursive(additional, includedSchemas, indentation + 1) + "\n" + indentationString + "}";
} else {
example = "{ }";
}
@@ -462,13 +464,13 @@ abstract public class AbstractPythonCodegen extends DefaultCodegen implements Co
if (toExclude != null && reqs.contains(toExclude)) {
reqs.remove(toExclude);
}
for (String toRemove : included_schemas) {
for (String toRemove : includedSchemas) {
if (reqs.contains(toRemove)) {
reqs.remove(toRemove);
}
}
if (StringUtils.isNotBlank(schema.getTitle()) && !"null".equals(schema.getTitle())) {
included_schemas.add(schema.getTitle());
includedSchemas.add(schema.getTitle());
}
if (null != schema.getRequired()) for (Object toAdd : schema.getRequired()) {
reqs.add((String) toAdd);
@@ -480,14 +482,14 @@ abstract public class AbstractPythonCodegen extends DefaultCodegen implements Co
if (StringUtils.isBlank(refTitle) || "null".equals(refTitle)) {
schema2.setTitle(propname);
}
example += "\n" + indentation_string + underscore(propname) + " = " +
toExampleValueRecursive(schema2, included_schemas, indentation + 1) + ", ";
example += "\n" + indentationString + underscore(propname) + " = " +
toExampleValueRecursive(schema2, includedSchemas, indentation + 1) + ", ";
}
}
}
example += ")";
} else {
LOGGER.warn("Type " + schema.getType() + " not handled properly in toExampleValue");
LOGGER.warn("Type {} not handled properly in toExampleValue", schema.getType());
}
if (ModelUtils.isStringSchema(schema)) {
@@ -549,7 +551,7 @@ abstract public class AbstractPythonCodegen extends DefaultCodegen implements Co
// type is a model class, e.g. User
example = this.packageName + "." + type + "()";
} else {
LOGGER.warn("Type " + type + " not handled properly in setParameterExampleValue");
LOGGER.warn("Type {} not handled properly in setParameterExampleValue", type);
}
if (example == null) {
@@ -632,13 +634,13 @@ abstract public class AbstractPythonCodegen extends DefaultCodegen implements Co
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", name, camelize("model_" + name));
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
}
// model name starts with number
if (name.matches("^\\d.*")) {
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", name, camelize("model_" + name));
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
}

View File

@@ -198,11 +198,11 @@ public abstract class AbstractPythonConnexionServerCodegen extends AbstractPytho
}
public void setFeatureCORS(String val) {
this.featureCORS = Boolean.valueOf(val);
this.featureCORS = Boolean.parseBoolean(val);
}
public void setUseNose(String val) {
this.useNose = Boolean.valueOf(val);
this.useNose = Boolean.parseBoolean(val);
}
public void setPythonSrcRoot(String val) {

View File

@@ -423,7 +423,7 @@ public class CSharpNancyFXServerCodegen extends AbstractCSharpCodegen {
return ImmutableSet.of("LocalTime?", "LocalDate?", "ZonedDateTime?");
}
private class DependencyInfo {
private static class DependencyInfo {
private final String version;
private final String framework;

View File

@@ -556,7 +556,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
*/
if (additionalProperties.containsKey(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT)) {
this.setDisallowAdditionalPropertiesIfNotPresent(Boolean.valueOf(additionalProperties
this.setDisallowAdditionalPropertiesIfNotPresent(Boolean.parseBoolean(additionalProperties
.get(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT).toString()));
}

View File

@@ -420,7 +420,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
}
} else if (ModelUtils.isBooleanSchema(p)) {
if (p.getDefault() != null) {
return Boolean.valueOf(p.getDefault().toString()) ? "True" : "False";
return Boolean.parseBoolean(p.getDefault().toString()) ? "True" : "False";
}
} else if (ModelUtils.isNumberSchema(p)) {
if (p.getDefault() != null) {

View File

@@ -238,7 +238,7 @@ public class GoClientCodegen extends AbstractGoCodegen {
}
if (additionalProperties.containsKey(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT)) {
this.setDisallowAdditionalPropertiesIfNotPresent(Boolean.valueOf(additionalProperties
this.setDisallowAdditionalPropertiesIfNotPresent(Boolean.parseBoolean(additionalProperties
.get(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT).toString()));
}

View File

@@ -313,8 +313,8 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
List<Map<String, Object>> replacements = new ArrayList<>();
Object[] replacementChars = specialCharReplacements.keySet().toArray();
for (int i = 0; i < replacementChars.length; i++) {
String c = (String) replacementChars[i];
for (Object replacementChar : replacementChars) {
String c = (String) replacementChar;
Map<String, Object> o = new HashMap<>();
o.put("char", c);
o.put("replacement", "'" + specialCharReplacements.get(c));

View File

@@ -226,26 +226,26 @@ public class JavaClientCodegen extends AbstractJavaCodegen
// RxJava
if (additionalProperties.containsKey(USE_RX_JAVA) && additionalProperties.containsKey(USE_RX_JAVA2) && additionalProperties.containsKey(USE_RX_JAVA3)) {
LOGGER.warn("You specified all RxJava versions 1, 2 and 3 but they are mutually exclusive. Defaulting to v3.");
this.setUseRxJava3(Boolean.valueOf(additionalProperties.get(USE_RX_JAVA3).toString()));
this.setUseRxJava3(Boolean.parseBoolean(additionalProperties.get(USE_RX_JAVA3).toString()));
} else {
if (additionalProperties.containsKey(USE_RX_JAVA) && additionalProperties.containsKey(USE_RX_JAVA2)) {
LOGGER.warn("You specified both RxJava versions 1 and 2 but they are mutually exclusive. Defaulting to v2.");
this.setUseRxJava2(Boolean.valueOf(additionalProperties.get(USE_RX_JAVA2).toString()));
this.setUseRxJava2(Boolean.parseBoolean(additionalProperties.get(USE_RX_JAVA2).toString()));
} else if (additionalProperties.containsKey(USE_RX_JAVA) && additionalProperties.containsKey(USE_RX_JAVA3)) {
LOGGER.warn("You specified both RxJava versions 1 and 3 but they are mutually exclusive. Defaulting to v3.");
this.setUseRxJava3(Boolean.valueOf(additionalProperties.get(USE_RX_JAVA3).toString()));
this.setUseRxJava3(Boolean.parseBoolean(additionalProperties.get(USE_RX_JAVA3).toString()));
} else if (additionalProperties.containsKey(USE_RX_JAVA2) && additionalProperties.containsKey(USE_RX_JAVA3)) {
LOGGER.warn("You specified both RxJava versions 2 and 3 but they are mutually exclusive. Defaulting to v3.");
this.setUseRxJava3(Boolean.valueOf(additionalProperties.get(USE_RX_JAVA3).toString()));
this.setUseRxJava3(Boolean.parseBoolean(additionalProperties.get(USE_RX_JAVA3).toString()));
} else {
if (additionalProperties.containsKey(USE_RX_JAVA)) {
this.setUseRxJava(Boolean.valueOf(additionalProperties.get(USE_RX_JAVA).toString()));
this.setUseRxJava(Boolean.parseBoolean(additionalProperties.get(USE_RX_JAVA).toString()));
}
if (additionalProperties.containsKey(USE_RX_JAVA2)) {
this.setUseRxJava2(Boolean.valueOf(additionalProperties.get(USE_RX_JAVA2).toString()));
this.setUseRxJava2(Boolean.parseBoolean(additionalProperties.get(USE_RX_JAVA2).toString()));
}
if (additionalProperties.containsKey(USE_RX_JAVA3)) {
this.setUseRxJava3(Boolean.valueOf(additionalProperties.get(USE_RX_JAVA3).toString()));
this.setUseRxJava3(Boolean.parseBoolean(additionalProperties.get(USE_RX_JAVA3).toString()));
}
}
}
@@ -256,7 +256,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
// Java Play
if (additionalProperties.containsKey(USE_PLAY_WS)) {
this.setUsePlayWS(Boolean.valueOf(additionalProperties.get(USE_PLAY_WS).toString()));
this.setUsePlayWS(Boolean.parseBoolean(additionalProperties.get(USE_PLAY_WS).toString()));
}
additionalProperties.put(USE_PLAY_WS, usePlayWS);
@@ -279,7 +279,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
}
if (additionalProperties.containsKey(PARCELABLE_MODEL)) {
this.setParcelableModel(Boolean.valueOf(additionalProperties.get(PARCELABLE_MODEL).toString()));
this.setParcelableModel(Boolean.parseBoolean(additionalProperties.get(PARCELABLE_MODEL).toString()));
}
// put the boolean value back to PARCELABLE_MODEL in additionalProperties
additionalProperties.put(PARCELABLE_MODEL, parcelableModel);
@@ -313,7 +313,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
}
if (additionalProperties.containsKey(DYNAMIC_OPERATIONS)) {
this.setDynamicOperations(Boolean.valueOf(additionalProperties.get(DYNAMIC_OPERATIONS).toString()));
this.setDynamicOperations(Boolean.parseBoolean(additionalProperties.get(DYNAMIC_OPERATIONS).toString()));
}
additionalProperties.put(DYNAMIC_OPERATIONS, dynamicOperations);

View File

@@ -108,16 +108,16 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
@Override
public void processOpts() {
if (additionalProperties.containsKey(GENERATE_POM)) {
generatePom = Boolean.valueOf(additionalProperties.get(GENERATE_POM).toString());
generatePom = Boolean.parseBoolean(additionalProperties.get(GENERATE_POM).toString());
}
if (additionalProperties.containsKey(INTERFACE_ONLY)) {
interfaceOnly = Boolean.valueOf(additionalProperties.get(INTERFACE_ONLY).toString());
interfaceOnly = Boolean.parseBoolean(additionalProperties.get(INTERFACE_ONLY).toString());
if (!interfaceOnly) {
additionalProperties.remove(INTERFACE_ONLY);
}
}
if (additionalProperties.containsKey(RETURN_RESPONSE)) {
returnResponse = Boolean.valueOf(additionalProperties.get(RETURN_RESPONSE).toString());
returnResponse = Boolean.parseBoolean(additionalProperties.get(RETURN_RESPONSE).toString());
if (!returnResponse) {
additionalProperties.remove(RETURN_RESPONSE);
}
@@ -126,7 +126,7 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
useSwaggerAnnotations = false;
} else {
if (additionalProperties.containsKey(USE_SWAGGER_ANNOTATIONS)) {
useSwaggerAnnotations = Boolean.valueOf(additionalProperties.get(USE_SWAGGER_ANNOTATIONS).toString());
useSwaggerAnnotations = Boolean.parseBoolean(additionalProperties.get(USE_SWAGGER_ANNOTATIONS).toString());
}
}
if (KUMULUZEE_LIBRARY.equals(library)){
@@ -135,7 +135,7 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
writePropertyBack(USE_SWAGGER_ANNOTATIONS, useSwaggerAnnotations);
if (additionalProperties.containsKey(GENERATE_BUILDERS)) {
generateBuilders = Boolean.valueOf(additionalProperties.get(GENERATE_BUILDERS).toString());
generateBuilders = Boolean.parseBoolean(additionalProperties.get(GENERATE_BUILDERS).toString());
}
additionalProperties.put(GENERATE_BUILDERS, generateBuilders);

View File

@@ -145,7 +145,7 @@ public class JavaPKMSTServerCodegen extends AbstractJavaCodegen {
}
if (this.additionalProperties.containsKey(CodegenConstants.SERIALIZE_BIG_DECIMAL_AS_STRING)) {
this.setSerializeBigDecimalAsString(Boolean.valueOf(
this.setSerializeBigDecimalAsString(Boolean.parseBoolean(
this.additionalProperties.get(CodegenConstants.SERIALIZE_BIG_DECIMAL_AS_STRING).toString()));
}
if (this.additionalProperties.containsKey(CodegenConstants.SERIALIZABLE_MODEL)) {
@@ -157,7 +157,7 @@ public class JavaPKMSTServerCodegen extends AbstractJavaCodegen {
}
this.additionalProperties.put(CodegenConstants.SERIALIZABLE_MODEL, serializableModel);
if (this.additionalProperties.containsKey(FULL_JAVA_UTIL)) {
this.setFullJavaUtil(Boolean.valueOf(this.additionalProperties.get(FULL_JAVA_UTIL).toString()));
this.setFullJavaUtil(Boolean.parseBoolean(this.additionalProperties.get(FULL_JAVA_UTIL).toString()));
}
if (this.additionalProperties.containsKey(EUREKA_URI)) {
@@ -178,7 +178,7 @@ public class JavaPKMSTServerCodegen extends AbstractJavaCodegen {
this.additionalProperties.put("java8", true);
if (this.additionalProperties.containsKey(WITH_XML)) {
this.setWithXml(Boolean.valueOf(additionalProperties.get(WITH_XML).toString()));
this.setWithXml(Boolean.parseBoolean(additionalProperties.get(WITH_XML).toString()));
}
this.additionalProperties.put(WITH_XML, withXml);
@@ -658,7 +658,7 @@ public class JavaPKMSTServerCodegen extends AbstractJavaCodegen {
void setReturnContainer(String returnContainer);
}
private class ResourcePath {
private static class ResourcePath {
private String path;

View File

@@ -311,13 +311,13 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
if (hasConflict) {
LOGGER.warn("You specified RxJava versions 1 and 2 and 3 or Coroutines together, please choose one of them.");
} else if (hasRx) {
this.setUseRxJava(Boolean.valueOf(additionalProperties.get(USE_RX_JAVA).toString()));
this.setUseRxJava(Boolean.parseBoolean(additionalProperties.get(USE_RX_JAVA).toString()));
} else if (hasRx2) {
this.setUseRxJava2(Boolean.valueOf(additionalProperties.get(USE_RX_JAVA2).toString()));
this.setUseRxJava2(Boolean.parseBoolean(additionalProperties.get(USE_RX_JAVA2).toString()));
} else if (hasRx3) {
this.setUseRxJava3(Boolean.valueOf(additionalProperties.get(USE_RX_JAVA3).toString()));
this.setUseRxJava3(Boolean.parseBoolean(additionalProperties.get(USE_RX_JAVA3).toString()));
} else if (hasCoroutines) {
this.setUseCoroutines(Boolean.valueOf(additionalProperties.get(USE_COROUTINES).toString()));
this.setUseCoroutines(Boolean.parseBoolean(additionalProperties.get(USE_COROUTINES).toString()));
}
if (!hasRx && !hasRx2 && !hasRx3 && !hasCoroutines) {

View File

@@ -319,27 +319,27 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
}
if (additionalProperties.containsKey(EXCEPTION_HANDLER)) {
this.setExceptionHandler(Boolean.valueOf(additionalProperties.get(EXCEPTION_HANDLER).toString()));
this.setExceptionHandler(Boolean.parseBoolean(additionalProperties.get(EXCEPTION_HANDLER).toString()));
}
writePropertyBack(EXCEPTION_HANDLER, exceptionHandler);
if (additionalProperties.containsKey(GRADLE_BUILD_FILE)) {
this.setGradleBuildFile(Boolean.valueOf(additionalProperties.get(GRADLE_BUILD_FILE).toString()));
this.setGradleBuildFile(Boolean.parseBoolean(additionalProperties.get(GRADLE_BUILD_FILE).toString()));
}
writePropertyBack(GRADLE_BUILD_FILE, gradleBuildFile);
if (additionalProperties.containsKey(SWAGGER_ANNOTATIONS)) {
this.setSwaggerAnnotations(Boolean.valueOf(additionalProperties.get(SWAGGER_ANNOTATIONS).toString()));
this.setSwaggerAnnotations(Boolean.parseBoolean(additionalProperties.get(SWAGGER_ANNOTATIONS).toString()));
}
writePropertyBack(SWAGGER_ANNOTATIONS, swaggerAnnotations);
if (additionalProperties.containsKey(SERVICE_INTERFACE)) {
this.setServiceInterface(Boolean.valueOf(additionalProperties.get(SERVICE_INTERFACE).toString()));
this.setServiceInterface(Boolean.parseBoolean(additionalProperties.get(SERVICE_INTERFACE).toString()));
}
writePropertyBack(SERVICE_INTERFACE, serviceInterface);
if (additionalProperties.containsKey(SERVICE_IMPLEMENTATION)) {
this.setServiceImplementation(Boolean.valueOf(additionalProperties.get(SERVICE_IMPLEMENTATION).toString()));
this.setServiceImplementation(Boolean.parseBoolean(additionalProperties.get(SERVICE_IMPLEMENTATION).toString()));
}
writePropertyBack(SERVICE_IMPLEMENTATION, serviceImplementation);
@@ -357,11 +357,11 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
writePropertyBack(EXCEPTION_HANDLER, exceptionHandler);
if (additionalProperties.containsKey(INTERFACE_ONLY)) {
this.setInterfaceOnly(Boolean.valueOf(additionalProperties.get(INTERFACE_ONLY).toString()));
this.setInterfaceOnly(Boolean.parseBoolean(additionalProperties.get(INTERFACE_ONLY).toString()));
}
if (additionalProperties.containsKey(DELEGATE_PATTERN)) {
this.setDelegatePattern(Boolean.valueOf(additionalProperties.get(DELEGATE_PATTERN).toString()));
this.setDelegatePattern(Boolean.parseBoolean(additionalProperties.get(DELEGATE_PATTERN).toString()));
if (!this.interfaceOnly) {
this.setSwaggerAnnotations(true);
}

View File

@@ -61,7 +61,7 @@ public class KtormSchemaCodegen extends AbstractKotlinCodegen {
protected Map<String, String> sqlTypeMapping = new HashMap<String, String>();
// https://ktorm.liuwj.me/api-docs/me.liuwj.ktorm.schema/index.html
protected class SqlType {
protected static class SqlType {
protected static final String Blob = "blob";
protected static final String Boolean = "boolean";
protected static final String Bytes = "bytes";
@@ -335,7 +335,7 @@ public class KtormSchemaCodegen extends AbstractKotlinCodegen {
return objs;
}
private class KtormSchema extends HashMap<String, Object> {
private static class KtormSchema extends HashMap<String, Object> {
private static final long serialVersionUID = -9159755928980443880L;
}
@@ -763,7 +763,7 @@ public class KtormSchemaCodegen extends AbstractKotlinCodegen {
return input.substring(0, 1).toLowerCase(Locale.ROOT) + input.substring(1);
}
private class SqlTypeArgs {
private static class SqlTypeArgs {
// type classes
public boolean isPrimitive;
public boolean isNumeric;

View File

@@ -428,16 +428,16 @@ public class LuaClientCodegen extends DefaultCodegen implements CodegenConfig {
String luaPath = "";
int pathParamIndex = 0;
for (int i = 0; i < items.length; ++i) {
if (items[i].matches("^\\{(.*)\\}$")) { // wrap in {}
for (String item : items) {
if (item.matches("^\\{(.*)\\}$")) { // wrap in {}
// find the datatype of the parameter
//final CodegenParameter cp = op.pathParams.get(pathParamIndex);
// TODO: Handle non-primitives…
//luaPath = luaPath + cp.dataType.toLowerCase(Locale.ROOT);
luaPath = luaPath + "/%s";
pathParamIndex++;
} else if (items[i].length() != 0) {
luaPath = luaPath + "/" + items[i];
} else if (item.length() != 0) {
luaPath = luaPath + "/" + item;
} else {
//luaPath = luaPath + "/";
}

View File

@@ -92,7 +92,7 @@ public class PhpSlimServerCodegen extends AbstractPhpCodegen {
// override cliOptions from AbstractPhpCodegen
for (CliOption co : cliOptions) {
if (co.getOpt().equals(AbstractPhpCodegen.VARIABLE_NAMING_CONVENTION)) {
if (AbstractPhpCodegen.VARIABLE_NAMING_CONVENTION.equals(co.getOpt())) {
co.setDescription("naming convention of variable name, e.g. camelCase.");
co.setDefault("camelCase");
break;

View File

@@ -256,7 +256,7 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
@Override
public String apiFilename(String templateName, String tag) {
String suffix = apiTemplateFiles().get(templateName);
if (templateName.equals("api_controller.mustache"))
if ("api_controller.mustache".equals(templateName))
return controllerFileFolder() + File.separator + toControllerName(tag) + suffix;
return apiFileFolder() + File.separator + toApiFilename(tag) + suffix;
@@ -421,7 +421,7 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
// @todo: The default values for headers, forms and query params are handled
// in DefaultCodegen fromParameter with no real possibility to override
// the functionality. Thus we are handling quoting of string values here
if (param.dataType.equals("string") && param.defaultValue != null && !param.defaultValue.isEmpty()) {
if ("string".equals(param.dataType) && param.defaultValue != null && !param.defaultValue.isEmpty()) {
param.defaultValue = "'" + param.defaultValue + "'";
}
}
@@ -429,7 +429,7 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
// Create a variable to display the correct return type in comments for interfaces
if (op.returnType != null) {
op.vendorExtensions.put("x-comment-type", op.returnType);
if (op.returnContainer != null && op.returnContainer.equals("array")) {
if (op.returnContainer != null && "array".equals(op.returnContainer)) {
op.vendorExtensions.put("x-comment-type", op.returnType + "[]");
}
} else {

View File

@@ -750,7 +750,7 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
}
if (additionalProperties.containsKey(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT)) {
this.setDisallowAdditionalPropertiesIfNotPresent(Boolean.valueOf(additionalProperties
this.setDisallowAdditionalPropertiesIfNotPresent(Boolean.parseBoolean(additionalProperties
.get(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT).toString()));
}
@@ -1330,7 +1330,7 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
public String toDefaultValue(Schema p) {
if (p.getDefault() != null) {
if (ModelUtils.isBooleanSchema(p)) {
if (Boolean.valueOf(p.getDefault().toString())) {
if (Boolean.parseBoolean(p.getDefault().toString())) {
return "$true";
} else {
return "$false";

View File

@@ -125,8 +125,16 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
supportingFiles.add(new SupportingFile("model_utils.mustache", packagePath(), "model_utils.py"));
// add the models and apis folders
supportingFiles.add(new SupportingFile("__init__models.mustache", packagePath() + File.separatorChar + "models", "__init__.py"));
SupportingFile originalInitModel = supportingFiles.stream()
.filter(sf -> sf.getTemplateFile().equals("__init__model.mustache"))
.reduce((a, b) -> {
throw new IllegalStateException("Multiple elements: " + a + ", " + b);
})
.get();
supportingFiles.remove(originalInitModel);
supportingFiles.add(new SupportingFile("__init__model.mustache", packagePath() + File.separatorChar + "model", "__init__.py"));
supportingFiles.add(new SupportingFile("__init__apis.mustache", packagePath() + File.separatorChar + "apis", "__init__.py"));
// Generate the 'signing.py' module, but only if the 'HTTP signature' security scheme is specified in the OAS.
@@ -219,11 +227,12 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
// free form object (type: object)
if (ModelUtils.hasValidation(ref)) {
return schema;
} else if (getAllOfDescendants(simpleRef, openAPI).size() > 0) {
} else if (!getAllOfDescendants(simpleRef, openAPI).isEmpty()) {
return schema;
} else {
return unaliasSchema(allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())),
usedImportMappings);
}
return unaliasSchema(allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())),
usedImportMappings);
}
} else if (ModelUtils.hasValidation(ref)) {
// non object non array non map schemas that have validations
@@ -246,7 +255,7 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
try {
date = (OffsetDateTime) dateValue;
} catch (ClassCastException e) {
LOGGER.warn("Invalid `date` format for value {}", dateValue.toString());
LOGGER.warn("Invalid `date` format for value {}", dateValue);
date = ((Date) dateValue).toInstant().atOffset(ZoneOffset.UTC);
}
strValue = date.format(iso8601Date);
@@ -263,7 +272,7 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
try {
dateTime = (OffsetDateTime) dateTimeValue;
} catch (ClassCastException e) {
LOGGER.warn("Invalid `date-time` format for value {}", dateTimeValue.toString());
LOGGER.warn("Invalid `date-time` format for value {}", dateTimeValue);
dateTime = ((Date) dateTimeValue).toInstant().atOffset(ZoneOffset.UTC);
}
strValue = dateTime.format(iso8601DateTime);
@@ -286,10 +295,9 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
// python servers: should only use default values for optional params
// python clients: should only use default values for required params
Object defaultObject = null;
Boolean enumLengthOne = (p.getEnum() != null && p.getEnum().size() == 1);
if (p.getDefault() != null) {
defaultObject = p.getDefault();
} else if (enumLengthOne) {
} else if (p.getEnum() != null && p.getEnum().size() == 1) {
defaultObject = p.getEnum().get(0);
}
@@ -305,7 +313,7 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
} else if (ModelUtils.isStringSchema(p) && !ModelUtils.isByteArraySchema(p) && !ModelUtils.isBinarySchema(p) && !ModelUtils.isFileSchema(p) && !ModelUtils.isUUIDSchema(p) && !ModelUtils.isEmailSchema(p)) {
defaultValue = ensureQuotes(defaultValue);
} else if (ModelUtils.isBooleanSchema(p)) {
if (Boolean.valueOf(defaultValue) == false) {
if (!Boolean.valueOf(defaultValue)) {
defaultValue = "False";
} else {
defaultValue = "True";
@@ -329,9 +337,8 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
HashMap<String, Object> val = (HashMap<String, Object>) objs.get("operations");
ArrayList<CodegenOperation> operations = (ArrayList<CodegenOperation>) val.get("operation");
ArrayList<HashMap<String, String>> imports = (ArrayList<HashMap<String, String>>) objs.get("imports");
for (CodegenOperation operation : operations) {
if (operation.imports.size() == 0) {
if (operation.imports.isEmpty()) {
continue;
}
String[] modelNames = operation.imports.toArray(new String[0]);
@@ -540,7 +547,7 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
* @return the sanitized value for enum
*/
public String toEnumValue(String value, String datatype) {
if (datatype.equals("int") || datatype.equals("float")) {
if ("int".equals(datatype) || "float".equals(datatype)) {
return value;
} else {
return ensureQuotes(value);

View File

@@ -405,7 +405,7 @@ public class PythonLegacyClientCodegen extends AbstractPythonCodegen implements
public void setUseNose(String val) {
this.useNose = Boolean.valueOf(val);
this.useNose = Boolean.parseBoolean(val);
}

View File

@@ -183,7 +183,7 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
}
if (additionalProperties.containsKey(CodegenConstants.EXCEPTION_ON_FAILURE)) {
boolean booleanValue = Boolean.valueOf(additionalProperties.get(CodegenConstants.EXCEPTION_ON_FAILURE).toString());
boolean booleanValue = Boolean.parseBoolean(additionalProperties.get(CodegenConstants.EXCEPTION_ON_FAILURE).toString());
setReturnExceptionOnFailure(booleanValue);
} else {
setReturnExceptionOnFailure(false);

View File

@@ -239,7 +239,6 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
supportingFiles.add(new SupportingFile("gem.mustache", libFolder, gemName + ".rb"));
String gemFolder = libFolder + File.separator + gemName;
supportingFiles.add(new SupportingFile("api_error.mustache", gemFolder, "api_error.rb"));
supportingFiles.add(new SupportingFile("configuration.mustache", gemFolder, "configuration.rb"));
supportingFiles.add(new SupportingFile("version.mustache", gemFolder, "version.rb"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));

View File

@@ -54,6 +54,7 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
protected String modelDocPath = "docs/";
protected String apiFolder = "src/apis";
protected String modelFolder = "src/models";
protected String enumSuffix = ""; // default to empty string for backward compatibility
public CodegenType getTag() {
return CodegenType.CLIENT;
@@ -179,6 +180,7 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
.defaultValue(Boolean.TRUE.toString()));
cliOptions.add(new CliOption(SUPPORT_MULTIPLE_RESPONSES, "If set, return type wraps an enum of all possible 2xx schemas. This option is for 'reqwest' library only", SchemaTypeUtil.BOOLEAN_TYPE)
.defaultValue(Boolean.FALSE.toString()));
cliOptions.add(new CliOption(CodegenConstants.ENUM_NAME_SUFFIX, CodegenConstants.ENUM_NAME_SUFFIX_DESC).defaultValue(this.enumSuffix));
supportedLibraries.put(HYPER_LIBRARY, "HTTP client: Hyper.");
supportedLibraries.put(REQWEST_LIBRARY, "HTTP client: Reqwest.");
@@ -247,6 +249,10 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
public void processOpts() {
super.processOpts();
if (additionalProperties.containsKey(CodegenConstants.ENUM_NAME_SUFFIX)) {
enumSuffix = additionalProperties.get(CodegenConstants.ENUM_NAME_SUFFIX).toString();
}
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
} else {
@@ -650,9 +656,13 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String toEnumName(CodegenProperty property) {
String name = property.name;
if (!org.apache.commons.lang3.StringUtils.isEmpty(enumSuffix)) {
name = name + "_" + enumSuffix;
}
// camelize the enum name
// phone_number => PhoneNumber
String enumName = camelize(toModelName(property.name));
String enumName = camelize(toModelName(name));
// remove [] for array or map of enum
enumName = enumName.replace("[]", "");

View File

@@ -584,7 +584,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
}
private boolean isMimetypeUnknown(String mimetype) {
return mimetype.equals("*/*");
return "*/*".equals(mimetype);
}
/**
@@ -864,7 +864,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
if (producesXml) {
outputMime = xmlMimeType;
} else if (producesPlainText) {
if (rsp.dataType.equals(bytesType)) {
if (bytesType.equals(rsp.dataType)) {
outputMime = octetMimeType;
} else {
outputMime = plainTextMimeType;
@@ -907,7 +907,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
// and string/bytes - that is we don't auto-detect whether
// base64 encoding should be done. They both look like
// 'producesBytes'.
if (rsp.dataType.equals(bytesType)) {
if (bytesType.equals(rsp.dataType)) {
rsp.vendorExtensions.put("x-produces-bytes", true);
} else {
rsp.vendorExtensions.put("x-produces-plain-text", true);
@@ -917,7 +917,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
// If the data type is just "object", then ensure that the
// Rust data type is "serde_json::Value". This allows us
// to define APIs that can return arbitrary JSON bodies.
if (rsp.dataType.equals("object")) {
if ("object".equals(rsp.dataType)) {
rsp.dataType = "serde_json::Value";
}
}
@@ -935,7 +935,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
}
}
for (CodegenProperty header : rsp.headers) {
if (header.dataType.equals(uuidType)) {
if (uuidType.equals(header.dataType)) {
additionalProperties.put("apiUsesUuid", true);
}
header.nameInCamelCase = toModelName(header.baseName);
@@ -948,7 +948,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
}
for (CodegenProperty header : op.responseHeaders) {
if (header.dataType.equals(uuidType)) {
if (uuidType.equals(header.dataType)) {
additionalProperties.put("apiUsesUuid", true);
}
header.nameInCamelCase = toModelName(header.baseName);
@@ -1043,7 +1043,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
}
for (CodegenProperty header : op.responseHeaders) {
if (header.dataType.equals(uuidType)) {
if (uuidType.equals(header.dataType)) {
additionalProperties.put("apiUsesUuid", true);
}
header.nameInCamelCase = toModelName(header.baseName);
@@ -1280,7 +1280,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
}
for (CodegenProperty prop : model.vars) {
if (prop.dataType.equals(uuidType)) {
if (uuidType.equals(prop.dataType)) {
additionalProperties.put("apiUsesUuid", true);
}
@@ -1289,7 +1289,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
prop.vendorExtensions.put("x-item-xml-name", xmlName);
}
if (prop.dataType.equals(uuidType)) {
if (uuidType.equals(prop.dataType)) {
additionalProperties.put("apiUsesUuid", true);
}
}
@@ -1383,11 +1383,11 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String toDefaultValue(Schema p) {
String defaultValue = null;
if ((ModelUtils.isNullable(p)) && (p.getDefault() != null) && (p.getDefault().toString().equalsIgnoreCase("null")))
if ((ModelUtils.isNullable(p)) && (p.getDefault() != null) && ("null".equalsIgnoreCase(p.getDefault().toString())))
return "swagger::Nullable::Null";
else if (ModelUtils.isBooleanSchema(p)) {
if (p.getDefault() != null) {
if (p.getDefault().toString().equalsIgnoreCase("false"))
if ("false".equalsIgnoreCase(p.getDefault().toString()))
defaultValue = "false";
else
defaultValue = "true";
@@ -1560,12 +1560,12 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
LOGGER.trace("Post processing model: {}", cm);
if (cm.dataType != null && cm.dataType.equals("object")) {
if (cm.dataType != null && "object".equals(cm.dataType)) {
// Object isn't a sensible default. Instead, we set it to
// 'null'. This ensures that we treat this model as a struct
// with multiple parameters.
cm.dataType = null;
} else if (cm.dataType != null && cm.dataType.equals("map")) {
} else if (cm.dataType != null && "map".equals(cm.dataType)) {
if (!cm.allVars.isEmpty() || cm.additionalPropertiesType == null) {
// We don't yet support `additionalProperties` that also have
// properties. If we see variables, we ignore the
@@ -1639,7 +1639,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
param.vendorExtensions.put("x-example", "???");
op.vendorExtensions.put("x-no-client-example", Boolean.TRUE);
}
} else if ((param.dataFormat != null) && ((param.dataFormat.equals("date-time")) || (param.dataFormat.equals("date")))) {
} else if ((param.dataFormat != null) && (("date-time".equals(param.dataFormat)) || ("date".equals(param.dataFormat)))) {
param.vendorExtensions.put("x-format-string", "{:?}");
param.vendorExtensions.put("x-example", "None");
} else {

View File

@@ -271,7 +271,7 @@ public class ScalaAkkaHttpServerCodegen extends AbstractScalaCodegen implements
if (!param.required) {
param.vendorExtensions.put("x-has-default-value", param.defaultValue != null);
// Escaping default string values
if (param.defaultValue != null && param.dataType.equals("String")) {
if (param.defaultValue != null && "String".equals(param.dataType)) {
param.defaultValue = String.format(Locale.ROOT, "\"%s\"", param.defaultValue);
}
}
@@ -417,7 +417,7 @@ public class ScalaAkkaHttpServerCodegen extends AbstractScalaCodegen implements
operationSpecificMarshallers.add(marshaller);
}
response.vendorExtensions.put("x-empty-response", response.baseType == null && response.message == null);
response.vendorExtensions.put("x-is-default", response.code.equals("0"));
response.vendorExtensions.put("x-is-default", "0".equals(response.code));
}
op.vendorExtensions.put("x-specific-marshallers", operationSpecificMarshallers);
op.vendorExtensions.put("x-file-params", fileParams);

View File

@@ -316,7 +316,7 @@ public class ScalaFinchServerCodegen extends DefaultCodegen implements CodegenCo
//All path parameters are String initially, for primitives these need to be converted
private String toPathParameter(CodegenParameter p, String paramType, Boolean canBeOptional) {
Boolean isNotAString = !p.dataType.equals("String");
Boolean isNotAString = !"String".equals(p.dataType);
return paramType + (canBeOptional && !p.required ? "Option" : "") + "(\"" + p.baseName + "\")" + (isNotAString ? toPrimitive(p.dataType, p.required, canBeOptional) : "");
}

View File

@@ -279,7 +279,7 @@ public class ScalaGatlingCodegen extends AbstractScalaCodegen implements Codegen
if (operation.getParameters() != null) {
for (Parameter parameter : operation.getParameters()) {
if (parameter.getIn().equalsIgnoreCase("header")) {
if ("header".equalsIgnoreCase(parameter.getIn())) {
headerParameters.add(parameter);
}
/* need to revise below as form parameter is no longer in the parameter list
@@ -287,10 +287,10 @@ public class ScalaGatlingCodegen extends AbstractScalaCodegen implements Codegen
formParameters.add(parameter);
}
*/
if (parameter.getIn().equalsIgnoreCase("query")) {
if ("query".equalsIgnoreCase(parameter.getIn())) {
queryParameters.add(parameter);
}
if (parameter.getIn().equalsIgnoreCase("path")) {
if ("path".equalsIgnoreCase(parameter.getIn())) {
pathParameters.add(parameter);
}
/* TODO need to revise below as body is no longer in the parameter

View File

@@ -380,9 +380,9 @@ public class ScalaSttpClientCodegen extends AbstractScalaCodegen implements Code
@Override
public void updateAdditionalProperties(Map<String, Object> additionalProperties) {
String value = getValue(additionalProperties);
if (value.equals(CIRCE) || value.equals(JSON4S)) {
additionalProperties.put(CIRCE, value.equals(CIRCE));
additionalProperties.put(JSON4S, value.equals(JSON4S));
if (CIRCE.equals(value) || JSON4S.equals(value)) {
additionalProperties.put(CIRCE, CIRCE.equals(value));
additionalProperties.put(JSON4S, JSON4S.equals(value));
} else {
IllegalArgumentException exception =
new IllegalArgumentException("Invalid json library: " + value + ". Must be " + CIRCE + " " +

View File

@@ -217,7 +217,7 @@ public class SpringCodegen extends AbstractJavaCodegen
// Process java8 option before common java ones to change the default dateLibrary to java8.
LOGGER.info("----------------------------------");
if (additionalProperties.containsKey(JAVA_8)) {
this.setJava8(Boolean.valueOf(additionalProperties.get(JAVA_8).toString()));
this.setJava8(Boolean.parseBoolean(additionalProperties.get(JAVA_8).toString()));
additionalProperties.put(JAVA_8, java8);
LOGGER.warn("java8 option has been deprecated as it's set to true by default (JDK7 support has been deprecated)");
}
@@ -257,27 +257,27 @@ public class SpringCodegen extends AbstractJavaCodegen
}
if (additionalProperties.containsKey(VIRTUAL_SERVICE)) {
this.setVirtualService(Boolean.valueOf(additionalProperties.get(VIRTUAL_SERVICE).toString()));
this.setVirtualService(Boolean.parseBoolean(additionalProperties.get(VIRTUAL_SERVICE).toString()));
}
if (additionalProperties.containsKey(INTERFACE_ONLY)) {
this.setInterfaceOnly(Boolean.valueOf(additionalProperties.get(INTERFACE_ONLY).toString()));
this.setInterfaceOnly(Boolean.parseBoolean(additionalProperties.get(INTERFACE_ONLY).toString()));
}
if (additionalProperties.containsKey(DELEGATE_PATTERN)) {
this.setDelegatePattern(Boolean.valueOf(additionalProperties.get(DELEGATE_PATTERN).toString()));
this.setDelegatePattern(Boolean.parseBoolean(additionalProperties.get(DELEGATE_PATTERN).toString()));
}
if (additionalProperties.containsKey(SINGLE_CONTENT_TYPES)) {
this.setSingleContentTypes(Boolean.valueOf(additionalProperties.get(SINGLE_CONTENT_TYPES).toString()));
this.setSingleContentTypes(Boolean.parseBoolean(additionalProperties.get(SINGLE_CONTENT_TYPES).toString()));
}
if (additionalProperties.containsKey(SKIP_DEFAULT_INTERFACE)) {
this.setSkipDefaultInterface(Boolean.valueOf(additionalProperties.get(SKIP_DEFAULT_INTERFACE).toString()));
this.setSkipDefaultInterface(Boolean.parseBoolean(additionalProperties.get(SKIP_DEFAULT_INTERFACE).toString()));
}
if (additionalProperties.containsKey(ASYNC)) {
this.setAsync(Boolean.valueOf(additionalProperties.get(ASYNC).toString()));
this.setAsync(Boolean.parseBoolean(additionalProperties.get(ASYNC).toString()));
//fix for issue/1164
convertPropertyToBooleanAndWriteBack(ASYNC);
}
@@ -286,7 +286,7 @@ public class SpringCodegen extends AbstractJavaCodegen
if (!SPRING_BOOT.equals(library)) {
throw new IllegalArgumentException("Currently, reactive option is only supported with Spring-boot");
}
this.setReactive(Boolean.valueOf(additionalProperties.get(REACTIVE).toString()));
this.setReactive(Boolean.parseBoolean(additionalProperties.get(REACTIVE).toString()));
}
if (additionalProperties.containsKey(RESPONSE_WRAPPER)) {
@@ -294,7 +294,7 @@ public class SpringCodegen extends AbstractJavaCodegen
}
if (additionalProperties.containsKey(USE_TAGS)) {
this.setUseTags(Boolean.valueOf(additionalProperties.get(USE_TAGS).toString()));
this.setUseTags(Boolean.parseBoolean(additionalProperties.get(USE_TAGS).toString()));
}
if (additionalProperties.containsKey(USE_BEANVALIDATION)) {
@@ -312,27 +312,27 @@ public class SpringCodegen extends AbstractJavaCodegen
}
if (additionalProperties.containsKey(IMPLICIT_HEADERS)) {
this.setImplicitHeaders(Boolean.valueOf(additionalProperties.get(IMPLICIT_HEADERS).toString()));
this.setImplicitHeaders(Boolean.parseBoolean(additionalProperties.get(IMPLICIT_HEADERS).toString()));
}
if (additionalProperties.containsKey(OPENAPI_DOCKET_CONFIG)) {
this.setOpenapiDocketConfig(Boolean.valueOf(additionalProperties.get(OPENAPI_DOCKET_CONFIG).toString()));
this.setOpenapiDocketConfig(Boolean.parseBoolean(additionalProperties.get(OPENAPI_DOCKET_CONFIG).toString()));
}
if (additionalProperties.containsKey(API_FIRST)) {
this.setApiFirst(Boolean.valueOf(additionalProperties.get(API_FIRST).toString()));
this.setApiFirst(Boolean.parseBoolean(additionalProperties.get(API_FIRST).toString()));
}
if (additionalProperties.containsKey(HATEOAS)) {
this.setHateoas(Boolean.valueOf(additionalProperties.get(HATEOAS).toString()));
this.setHateoas(Boolean.parseBoolean(additionalProperties.get(HATEOAS).toString()));
}
if (additionalProperties.containsKey(RETURN_SUCCESS_CODE)) {
this.setReturnSuccessCode(Boolean.valueOf(additionalProperties.get(RETURN_SUCCESS_CODE).toString()));
this.setReturnSuccessCode(Boolean.parseBoolean(additionalProperties.get(RETURN_SUCCESS_CODE).toString()));
}
if (additionalProperties.containsKey(UNHANDLED_EXCEPTION_HANDLING)) {
this.setUnhandledException(Boolean.valueOf(additionalProperties.get(UNHANDLED_EXCEPTION_HANDLING).toString()));
this.setUnhandledException(Boolean.parseBoolean(additionalProperties.get(UNHANDLED_EXCEPTION_HANDLING).toString()));
}
additionalProperties.put(UNHANDLED_EXCEPTION_HANDLING, this.isUnhandledException());
@@ -358,13 +358,13 @@ public class SpringCodegen extends AbstractJavaCodegen
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
if (!this.interfaceOnly) {
if (library.equals(SPRING_BOOT)) {
if (SPRING_BOOT.equals(library)) {
supportingFiles.add(new SupportingFile("openapi2SpringBoot.mustache",
(sourceFolder + File.separator + basePackage).replace(".", java.io.File.separator), "OpenAPI2SpringBoot.java"));
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache",
(sourceFolder + File.separator + basePackage).replace(".", java.io.File.separator), "RFC3339DateFormat.java"));
}
if (library.equals(SPRING_MVC_LIBRARY)) {
if (SPRING_MVC_LIBRARY.equals(library)) {
supportingFiles.add(new SupportingFile("webApplication.mustache",
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "WebApplication.java"));
supportingFiles.add(new SupportingFile("webMvcConfiguration.mustache",
@@ -374,7 +374,7 @@ public class SpringCodegen extends AbstractJavaCodegen
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache",
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "RFC3339DateFormat.java"));
}
if (library.equals(SPRING_CLOUD_LIBRARY)) {
if (SPRING_CLOUD_LIBRARY.equals(library)) {
supportingFiles.add(new SupportingFile("apiKeyRequestInterceptor.mustache",
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "ApiKeyRequestInterceptor.java"));
supportingFiles.add(new SupportingFile("clientConfiguration.mustache",
@@ -398,7 +398,7 @@ public class SpringCodegen extends AbstractJavaCodegen
("src/main/resources").replace("/", java.io.File.separator), "openapi.yaml"));
}
}
} else if (this.openapiDocketConfig && !library.equals(SPRING_CLOUD_LIBRARY) && !this.reactive && !this.apiFirst) {
} else if (this.openapiDocketConfig && !SPRING_CLOUD_LIBRARY.equals(library) && !this.reactive && !this.apiFirst) {
supportingFiles.add(new SupportingFile("openapiDocumentationConfig.mustache",
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "OpenAPIDocumentationConfig.java"));
}
@@ -416,7 +416,7 @@ public class SpringCodegen extends AbstractJavaCodegen
if ("threetenbp".equals(dateLibrary)) {
supportingFiles.add(new SupportingFile("customInstantDeserializer.mustache",
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "CustomInstantDeserializer.java"));
if (library.equals(SPRING_BOOT) || library.equals(SPRING_CLOUD_LIBRARY)) {
if (SPRING_BOOT.equals(library) || SPRING_CLOUD_LIBRARY.equals(library)) {
supportingFiles.add(new SupportingFile("jacksonConfiguration.mustache",
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "JacksonConfiguration.java"));
}
@@ -500,7 +500,7 @@ public class SpringCodegen extends AbstractJavaCodegen
@Override
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations) {
if ((library.equals(SPRING_BOOT) || library.equals(SPRING_MVC_LIBRARY)) && !useTags) {
if ((SPRING_BOOT.equals(library) || SPRING_MVC_LIBRARY.equals(library)) && !useTags) {
String basePath = resourcePath;
if (basePath.startsWith("/")) {
basePath = basePath.substring(1);
@@ -510,7 +510,7 @@ public class SpringCodegen extends AbstractJavaCodegen
basePath = basePath.substring(0, pos);
}
if (basePath.equals("")) {
if ("".equals(basePath)) {
basePath = "default";
} else {
co.subresourceOperation = !co.path.isEmpty();
@@ -682,7 +682,7 @@ public class SpringCodegen extends AbstractJavaCodegen
@Override
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
generateYAMLSpecFile(objs);
if (library.equals(SPRING_CLOUD_LIBRARY)) {
if (SPRING_CLOUD_LIBRARY.equals(library)) {
List<CodegenSecurity> authMethods = (List<CodegenSecurity>) objs.get("authMethods");
if (authMethods != null) {
for (CodegenSecurity authMethod : authMethods) {

View File

@@ -534,12 +534,12 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
@Override
public boolean isDataTypeFile(String dataType) {
return dataType != null && dataType.equals("URL");
return dataType != null && "URL".equals(dataType);
}
@Override
public boolean isDataTypeBinary(final String dataType) {
return dataType != null && dataType.equals("Data");
return dataType != null && "Data".equals(dataType);
}
/**

View File

@@ -546,12 +546,12 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
@Override
public boolean isDataTypeFile(String dataType) {
return dataType != null && dataType.equals("URL");
return dataType != null && "URL".equals(dataType);
}
@Override
public boolean isDataTypeBinary(final String dataType) {
return dataType != null && dataType.equals("Data");
return dataType != null && "Data".equals(dataType);
}
/**

View File

@@ -177,7 +177,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
}
if (additionalProperties.containsKey(STRING_ENUMS)) {
setStringEnums(Boolean.valueOf(additionalProperties.get(STRING_ENUMS).toString()));
setStringEnums(Boolean.parseBoolean(additionalProperties.get(STRING_ENUMS).toString()));
additionalProperties.put("stringEnums", getStringEnums());
if (getStringEnums()) {
classEnumSeparator = "";
@@ -384,7 +384,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
@Override
public boolean isDataTypeFile(final String dataType) {
return dataType != null && dataType.equals("Blob");
return dataType != null && "Blob".equals(dataType);
}
@Override

View File

@@ -94,7 +94,7 @@ public class TypeScriptAureliaClientCodegen extends AbstractTypeScriptClientCode
// Collect models to be imported
for (CodegenParameter param : op.allParams) {
if (!param.isPrimitiveType && !param.isArray && !param.dataType.equals("any")) {
if (!param.isPrimitiveType && !param.isArray && !"any".equals(param.dataType)) {
modelImports.add(param.dataType);
}
}

View File

@@ -783,15 +783,15 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
}
additionalProperties.put("platforms", platforms);
additionalProperties.putIfAbsent(FILE_CONTENT_DATA_TYPE, propPlatform.equals("node") ? "Buffer" : "Blob");
additionalProperties.putIfAbsent(FILE_CONTENT_DATA_TYPE, "node".equals(propPlatform) ? "Buffer" : "Blob");
if (!propPlatform.equals("deno")) {
if (!"deno".equals(propPlatform)) {
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("package.mustache", "", "package.json"));
supportingFiles.add(new SupportingFile("tsconfig.mustache", "", "tsconfig.json"));
}
if (propPlatform.equals("deno")) {
if ("deno".equals(propPlatform)) {
additionalProperties.put("extensionForDeno", ".ts");
}

View File

@@ -141,7 +141,7 @@ public class TypeScriptInversifyClientCodegen extends AbstractTypeScriptClientCo
@Override
public boolean isDataTypeFile(final String dataType) {
return dataType != null && dataType.equals("Blob");
return dataType != null && "Blob".equals(dataType);
}
@Override

View File

@@ -143,7 +143,7 @@ public class TypeScriptNestjsClientCodegen extends AbstractTypeScriptClientCodeg
}
if (additionalProperties.containsKey(STRING_ENUMS)) {
setStringEnums(Boolean.valueOf(additionalProperties.get(STRING_ENUMS).toString()));
setStringEnums(Boolean.parseBoolean(additionalProperties.get(STRING_ENUMS).toString()));
additionalProperties.put("stringEnums", getStringEnums());
if (getStringEnums()) {
enumSuffix = "";
@@ -216,7 +216,7 @@ public class TypeScriptNestjsClientCodegen extends AbstractTypeScriptClientCodeg
@Override
public boolean isDataTypeFile(final String dataType) {
return dataType != null && dataType.equals("Blob");
return dataType != null && "Blob".equals(dataType);
}
@Override

View File

@@ -82,7 +82,7 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
@Override
public boolean isDataTypeFile(final String dataType) {
return dataType != null && dataType.equals("RequestFile");
return dataType != null && "RequestFile".equals(dataType);
}
@Override

View File

@@ -98,7 +98,7 @@ public class TypeScriptRxjsClientCodegen extends AbstractTypeScriptClientCodegen
@Override
public boolean isDataTypeFile(final String dataType) {
return dataType != null && dataType.equals("Blob");
return dataType != null && "Blob".equals(dataType);
}
@Override

View File

@@ -58,7 +58,7 @@ public interface JsonCache {
/**
* Exception thrown by cache operations. Not intended to be created by client code.
*/
class CacheException extends Exception {
static class CacheException extends Exception {
private static final long serialVersionUID = -1215367978375557620L;
CacheException(String message) {

View File

@@ -1426,7 +1426,7 @@ public class ModelUtils {
}
if (schema.getExtensions() != null && schema.getExtensions().get("x-nullable") != null) {
return Boolean.valueOf(schema.getExtensions().get("x-nullable").toString());
return Boolean.parseBoolean(schema.getExtensions().get("x-nullable").toString());
}
// In OAS 3.1, the recommended way to define a nullable property or object is to use oneOf.
if (schema instanceof ComposedSchema) {

View File

@@ -34,7 +34,7 @@ class OpenApiParameterValidations extends GenericValidator<ParameterWrapper> {
*/
private static ValidationRule.Result apacheNginxHeaderCheck(ParameterWrapper parameterWrapper) {
Parameter parameter = parameterWrapper.getParameter();
if (parameter == null || !parameter.getIn().equals("header")) return ValidationRule.Pass.empty();
if (parameter == null || !"header".equals(parameter.getIn())) return ValidationRule.Pass.empty();
ValidationRule.Result result = ValidationRule.Pass.empty();
String headerName = parameter.getName();

View File

@@ -1229,10 +1229,8 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
* @return Client
*/
protected Client buildHttpClient() {
// use the default client config if not yet initialized
if (clientConfig == null) {
clientConfig = getDefaultClientConfig();
}
// recreate the client config to pickup changes
clientConfig = getDefaultClientConfig();
ClientBuilder clientBuilder = ClientBuilder.newBuilder();
customizeClientBuilder(clientBuilder);

View File

@@ -233,7 +233,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#vendorE
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^isReadOnly}}
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
{{#jackson}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{> jackson_annotations}}{{/vendorExtensions.x-is-jackson-optional-nullable}}{{/jackson}} public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
{{#vendorExtensions.x-enum-as-string}}
if (!{{{nameInSnakeCase}}}_VALUES.contains({{name}})) {
throw new IllegalArgumentException({{name}} + " is invalid. Possible values for {{name}}: " + String.join(", ", {{{nameInSnakeCase}}}_VALUES));

View File

@@ -236,7 +236,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#vendorE
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^isReadOnly}}
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
{{#jackson}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{> jackson_annotations}}{{/vendorExtensions.x-is-jackson-optional-nullable}}{{/jackson}} public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
{{#vendorExtensions.x-enum-as-string}}
if (!{{{nameInSnakeCase}}}_VALUES.contains({{name}})) {
throw new IllegalArgumentException({{name}} + " is invalid. Possible values for {{name}}: " + String.join(", ", {{{nameInSnakeCase}}}_VALUES));

View File

@@ -219,7 +219,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#vendorE
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^isReadOnly}}
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
{{#jackson}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{> jackson_annotations}}{{/vendorExtensions.x-is-jackson-optional-nullable}}{{/jackson}} public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
{{#vendorExtensions.x-is-jackson-optional-nullable}}
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{name}});
{{/vendorExtensions.x-is-jackson-optional-nullable}}

View File

@@ -49,7 +49,45 @@ import com.fasterxml.jackson.annotation.JsonValue;
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
this.{{name}} = {{name}};
}{{/vars}}
}
{{#isListContainer}}
public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
if (this.{{name}} == null) {
this.{{name}} = {{{defaultValue}}};
}
this.{{name}}.add({{name}}Item);
return this;
}
public {{classname}} remove{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
if ({{name}}Item != null && this.{{name}} != null) {
this.{{name}}.remove({{name}}Item);
}
return this;
}
{{/isListContainer}}
{{#isMapContainer}}
public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) {
if (this.{{name}} == null) {
this.{{name}} = {{{defaultValue}}};
}
this.{{name}}.put(key, {{name}}Item);
return this;
}
public {{classname}} remove{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
if ({{name}}Item != null && this.{{name}} != null) {
this.{{name}}.remove({{name}}Item);
}
return this;
}
{{/isMapContainer}}
{{/vars}}
@Override
public boolean equals(Object o) {

View File

@@ -6,7 +6,7 @@
"main": "dist{{#invokerPackage}}/{{invokerPackage}}{{/invokerPackage}}/index.js",
"scripts": {
"build": "babel src -d dist",
"prepack": "npm run build",
"prepare": "npm run build",
"test": "mocha --require @babel/register --recursive"
},
"browser": {

View File

@@ -5,11 +5,11 @@ using System.ComponentModel.DataAnnotations;
{{#operationResultTask}}
using System.Threading.Tasks;
{{/operationResultTask}}
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Http;
{{#useSwashbuckle}}
using Swashbuckle.AspNetCore.Annotations;
using Microsoft.AspNetCore.Authorization;
using Swashbuckle.AspNetCore.SwaggerGen;
{{/useSwashbuckle}}
{{^isLibrary}}

View File

@@ -245,7 +245,7 @@ url_escape() {
-e 's/(/%28/g' \
-e 's/)/%29/g' \
-e 's/:/%3A/g' \
-e 's/\t/%09/g' \
-e 's/\\t/%09/g' \
-e 's/?/%3F/g' <<<"$raw_url");
echo "$value"

View File

@@ -100,6 +100,29 @@ System.Net.WebProxy webProxy = new System.Net.WebProxy("http://myProxyUrl:80/");
webProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
c.Proxy = webProxy;
```
{{#useHttpClient}}
To use your own HttpClient instances just pass them to the ApiClass constructor.
```csharp
HttpClientHandler yourHandler = new HttpClientHandler();
HttpClient yourHttpClient = new HttpClient(yourHandler);
var api = new YourApiClass(yourHttpClient, yourHandler);
```
If you want to use an HttpClient and don't have access to the handler, for example in a DI context in aspnetcore when
using IHttpClientFactory. You need to disable the features that require handler access:
```csharp
HttpClient yourHttpClient = new HttpClient();
var api = new YourApiClass(yourHttpClient, null, true);
```
The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings.
You need to either manually handle those in your setup of the HttpClient or they won't be available.
{{/useHttpClient}}
<a name="getting-started"></a>
## Getting Started

View File

@@ -161,13 +161,16 @@ namespace {{packageName}}.Client
/// Provides a default implementation of an Api client (both synchronous and asynchronous implementatios),
/// encapsulating general REST accessor use cases.
/// </summary>
{{>visibility}} partial class ApiClient : ISynchronousClient{{#supportsAsync}}, IAsynchronousClient{{/supportsAsync}}
{{>visibility}} partial class ApiClient : IDisposable, ISynchronousClient{{#supportsAsync}}, IAsynchronousClient{{/supportsAsync}}
{
private readonly String _baseUrl;
{{#reUseHttpClient}}
private readonly HttpClientHandler _httpClientHandler;
private readonly bool _disposeHandler;
private readonly HttpClient _httpClient;
{{/reUseHttpClient}}
private readonly bool _disposeClient;
private readonly bool _disableHandlerFeatures;
/// <summary>
/// Specifies the settings on a <see cref="JsonSerializer" /> object.
@@ -189,30 +192,50 @@ namespace {{packageName}}.Client
/// <summary>
/// Initializes a new instance of the <see cref="ApiClient" />, defaulting to the global configurations' base url.
/// </summary>
public ApiClient()
/// <param name="client">An instance of HttpClient</param>
/// <param name="handler">An instance of HttpClientHandler that is used by HttpClient</param>
/// <param name="disableHandlerFeatures">Disable ApiClient features that require access to the HttpClientHandler</param>
public ApiClient(HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) :
this({{packageName}}.Client.GlobalConfiguration.Instance.BasePath, client, handler, disableHandlerFeatures)
{
_baseUrl = {{packageName}}.Client.GlobalConfiguration.Instance.BasePath;
{{#reUseHttpClient}}
_httpClientHandler = new HttpClientHandler();
_httpClient = new HttpClient(_httpClientHandler);
{{/reUseHttpClient}}
}
/// <summary>
/// Initializes a new instance of the <see cref="ApiClient" />
/// </summary>
/// <param name="basePath">The target service's base path in URL format.</param>
/// <param name="client">An instance of HttpClient</param>
/// <param name="handler">An instance of HttpClientHandler that is used by HttpClient</param>
/// <param name="disableHandlerFeatures">Disable ApiClient features that require access to the HttpClientHandler</param>
/// <exception cref="ArgumentException"></exception>
public ApiClient(String basePath)
public ApiClient(String basePath, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false)
{
if (string.IsNullOrEmpty(basePath))
throw new ArgumentException("basePath cannot be empty");
_baseUrl = basePath;
{{#reUseHttpClient}}
_httpClientHandler = new HttpClientHandler();
_httpClient = new HttpClient(_httpClientHandler);
{{/reUseHttpClient}}
if((client != null && handler == null) && !disableHandlerFeatures) {
throw new ArgumentException("If providing HttpClient, you also need to provide its handler or disable features requiring the handler, see README.md");
}
_disableHandlerFeatures = disableHandlerFeatures;
_httpClientHandler = handler ?? new HttpClientHandler();
_disposeHandler = handler == null;
_httpClient = client ?? new HttpClient(_httpClientHandler, false);
_disposeClient = client == null;
}
/// <summary>
/// Disposes resources if they were created by us
/// </summary>
public void Dispose()
{
if(_disposeClient) {
_httpClient.Dispose();
}
if(_disposeHandler) {
_httpClientHandler.Dispose();
}
}
/// Prepares multipart/form-data content
@@ -275,6 +298,11 @@ namespace {{packageName}}.Client
HttpRequestMessage request = new HttpRequestMessage(method, builder.GetFullUri());
if (configuration.UserAgent != null)
{
request.Headers.TryAddWithoutValidation("User-Agent", configuration.UserAgent);
}
if (configuration.DefaultHeaders != null)
{
foreach (var headerParam in configuration.DefaultHeaders)
@@ -377,15 +405,18 @@ namespace {{packageName}}.Client
}
}
if (response != null)
if(!_disableHandlerFeatures)
{
try {
foreach (Cookie cookie in handler.CookieContainer.GetCookies(uri))
{
transformed.Cookies.Add(cookie);
if (response != null)
{
try {
foreach (Cookie cookie in handler.CookieContainer.GetCookies(uri))
{
transformed.Cookies.Add(cookie);
}
}
catch (PlatformNotSupportedException) {}
}
catch (PlatformNotSupportedException) {}
}
return transformed;
@@ -400,14 +431,8 @@ namespace {{packageName}}.Client
IReadableConfiguration configuration,
System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
{{^reUseHttpClient}}
var handler = new HttpClientHandler();
var client = new HttpClient();
{{/reUseHttpClient}}
{{#reUseHttpClient}}
var handler = _httpClientHandler;
var client = _httpClient;
{{/reUseHttpClient}}
var deserializer = new CustomJsonCodec(SerializerSettings, configuration);
var finalToken = cancellationToken;
@@ -417,20 +442,16 @@ namespace {{packageName}}.Client
var tokenSource = new CancellationTokenSource(configuration.Timeout);
finalToken = CancellationTokenSource.CreateLinkedTokenSource(finalToken, tokenSource.Token).Token;
}
if(!_disableHandlerFeatures) {
if (configuration.Proxy != null)
{
handler.Proxy = configuration.Proxy;
}
if (configuration.Proxy != null)
{
handler.Proxy = configuration.Proxy;
}
if (configuration.UserAgent != null)
{
client.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", configuration.UserAgent);
}
if (configuration.ClientCertificates != null)
{
handler.ClientCertificates.AddRange(configuration.ClientCertificates);
if (configuration.ClientCertificates != null)
{
handler.ClientCertificates.AddRange(configuration.ClientCertificates);
}
}
var cookieContainer = req.Properties.ContainsKey("CookieContainer") ? req.Properties["CookieContainer"] as List<Cookie> : null;

View File

@@ -0,0 +1,652 @@
{{>partial_header}}
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Mime;
using {{packageName}}.Client;
{{#hasImport}}using {{packageName}}.{{modelPackage}};
{{/hasImport}}
namespace {{packageName}}.{{apiPackage}}
{
{{#operations}}
/// <summary>
/// Represents a collection of functions to interact with the API endpoints
/// </summary>
{{>visibility}} interface {{interfacePrefix}}{{classname}}Sync : IApiAccessor
{
#region Synchronous Operations
{{#operation}}
/// <summary>
/// {{summary}}
/// </summary>
{{#notes}}
/// <remarks>
/// {{notes}}
/// </remarks>
{{/notes}}
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
{{/allParams}}/// <returns>{{#returnType}}{{returnType}}{{/returnType}}</returns>
{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}});
/// <summary>
/// {{summary}}
/// </summary>
/// <remarks>
/// {{notes}}
/// </remarks>
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
{{/allParams}}/// <returns>ApiResponse of {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Object(void){{/returnType}}</returns>
ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}> {{operationId}}WithHttpInfo({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}});
{{/operation}}
#endregion Synchronous Operations
}
{{#supportsAsync}}
/// <summary>
/// Represents a collection of functions to interact with the API endpoints
/// </summary>
{{>visibility}} interface {{interfacePrefix}}{{classname}}Async : IApiAccessor
{
#region Asynchronous Operations
{{#operation}}
/// <summary>
/// {{summary}}
/// </summary>
/// <remarks>
/// {{notes}}
/// </remarks>
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
{{#allParams}}
/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
{{/allParams}}
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task of {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}void{{/returnType}}</returns>
{{#returnType}}System.Threading.Tasks.Task<{{{returnType}}}>{{/returnType}}{{^returnType}}System.Threading.Tasks.Task{{/returnType}} {{operationId}}Async({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
/// <summary>
/// {{summary}}
/// </summary>
/// <remarks>
/// {{notes}}
/// </remarks>
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
{{#allParams}}
/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
{{/allParams}}
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task of ApiResponse{{#returnType}} ({{returnType}}){{/returnType}}</returns>
System.Threading.Tasks.Task<ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>> {{operationId}}WithHttpInfoAsync({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
{{/operation}}
#endregion Asynchronous Operations
}
{{/supportsAsync}}
/// <summary>
/// Represents a collection of functions to interact with the API endpoints
/// </summary>
{{>visibility}} interface {{interfacePrefix}}{{classname}} : {{interfacePrefix}}{{classname}}Sync{{#supportsAsync}}, {{interfacePrefix}}{{classname}}Async{{/supportsAsync}}
{
}
/// <summary>
/// Represents a collection of functions to interact with the API endpoints
/// </summary>
{{>visibility}} partial class {{classname}} : IDisposable, {{interfacePrefix}}{{classname}}
{
private {{packageName}}.Client.ExceptionFactory _exceptionFactory = (name, response) => null;
/// <summary>
/// Initializes a new instance of the <see cref="{{classname}}"/> class.
/// </summary>
/// <param name="client">An instance of HttpClient</param>
/// <param name="handler">An instance of HttpClientHandler that is used by HttpClient</param>
/// <param name="disableHandlerFeatures">Disable ApiClient features that require access to the HttpClientHandler</param>
/// <returns></returns>
public {{classname}}(HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) : this((string)null, client, handler, disableHandlerFeatures)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="{{classname}}"/> class.
/// </summary>
/// <param name="client">An instance of HttpClient</param>
/// <param name="handler">An instance of HttpClientHandler that is used by HttpClient</param>
/// <param name="disableHandlerFeatures">Disable ApiClient features that require access to the HttpClientHandler</param>
/// <returns></returns>
public {{classname}}(String basePath, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false)
{
this.Configuration = {{packageName}}.Client.Configuration.MergeConfigurations(
{{packageName}}.Client.GlobalConfiguration.Instance,
new {{packageName}}.Client.Configuration { BasePath = basePath }
);
this.ApiClient = new {{packageName}}.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures);
this.Client = this.ApiClient;
{{#supportsAsync}}
this.AsynchronousClient = this.ApiClient;
{{/supportsAsync}}
this.ExceptionFactory = {{packageName}}.Client.Configuration.DefaultExceptionFactory;
}
/// <summary>
/// Initializes a new instance of the <see cref="{{classname}}"/> class
/// using Configuration object
/// </summary>
/// <param name="configuration">An instance of Configuration</param>
/// <param name="client">An instance of HttpClient</param>
/// <param name="handler">An instance of HttpClientHandler that is used by HttpClient</param>
/// <param name="disableHandlerFeatures">Disable ApiClient features that require access to the HttpClientHandler</param>
/// <returns></returns>
public {{classname}}({{packageName}}.Client.Configuration configuration, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false)
{
if (configuration == null) throw new ArgumentNullException("configuration");
this.Configuration = {{packageName}}.Client.Configuration.MergeConfigurations(
{{packageName}}.Client.GlobalConfiguration.Instance,
configuration
);
this.ApiClient = new {{packageName}}.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures);
this.Client = this.ApiClient;
{{#supportsAsync}}
this.AsynchronousClient = this.ApiClient;
{{/supportsAsync}}
ExceptionFactory = {{packageName}}.Client.Configuration.DefaultExceptionFactory;
}
/// <summary>
/// Initializes a new instance of the <see cref="{{classname}}"/> class
/// using a Configuration object and client instance.
/// </summary>
/// <param name="client">The client interface for synchronous API access.</param>{{#supportsAsync}}
/// <param name="asyncClient">The client interface for asynchronous API access.</param>{{/supportsAsync}}
/// <param name="configuration">The configuration object.</param>
public {{classname}}({{packageName}}.Client.ISynchronousClient client, {{#supportsAsync}}{{packageName}}.Client.IAsynchronousClient asyncClient, {{/supportsAsync}}{{packageName}}.Client.IReadableConfiguration configuration)
{
if (client == null) throw new ArgumentNullException("client");
{{#supportsAsync}}
if (asyncClient == null) throw new ArgumentNullException("asyncClient");
{{/supportsAsync}}
if (configuration == null) throw new ArgumentNullException("configuration");
this.Client = client;
{{#supportsAsync}}
this.AsynchronousClient = asyncClient;
{{/supportsAsync}}
this.Configuration = configuration;
this.ExceptionFactory = {{packageName}}.Client.Configuration.DefaultExceptionFactory;
}
/// <summary>
/// Disposes resources if they were created by us
/// </summary>
public void Dispose()
{
this.ApiClient?.Dispose();
}
/// <summary>
/// Holds the ApiClient if created
/// </summary>
public {{packageName}}.Client.ApiClient ApiClient { get; set; } = null;
{{#supportsAsync}}
/// <summary>
/// The client for accessing this underlying API asynchronously.
/// </summary>
public {{packageName}}.Client.IAsynchronousClient AsynchronousClient { get; set; }
{{/supportsAsync}}
/// <summary>
/// The client for accessing this underlying API synchronously.
/// </summary>
public {{packageName}}.Client.ISynchronousClient Client { get; set; }
/// <summary>
/// Gets the base path of the API client.
/// </summary>
/// <value>The base path</value>
public String GetBasePath()
{
return this.Configuration.BasePath;
}
/// <summary>
/// Gets or sets the configuration object
/// </summary>
/// <value>An instance of the Configuration</value>
public {{packageName}}.Client.IReadableConfiguration Configuration { get; set; }
/// <summary>
/// Provides a factory method hook for the creation of exceptions.
/// </summary>
public {{packageName}}.Client.ExceptionFactory ExceptionFactory
{
get
{
if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1)
{
throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported.");
}
return _exceptionFactory;
}
set { _exceptionFactory = value; }
}
{{#operation}}
/// <summary>
/// {{summary}} {{notes}}
/// </summary>
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
{{/allParams}}/// <returns>{{#returnType}}{{returnType}}{{/returnType}}</returns>
public {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}})
{
{{#returnType}}{{packageName}}.Client.ApiResponse<{{{returnType}}}> localVarResponse = {{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
return localVarResponse.Data;{{/returnType}}{{^returnType}}{{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});{{/returnType}}
}
/// <summary>
/// {{summary}} {{notes}}
/// </summary>
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
{{/allParams}}/// <returns>ApiResponse of {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Object(void){{/returnType}}</returns>
public {{packageName}}.Client.ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}> {{operationId}}WithHttpInfo({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}})
{
{{#allParams}}
{{#required}}
{{^vendorExtensions.x-csharp-value-type}}
// verify the required parameter '{{paramName}}' is set
if ({{paramName}} == null)
throw new {{packageName}}.Client.ApiException(400, "Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}");
{{/vendorExtensions.x-csharp-value-type}}
{{/required}}
{{/allParams}}
{{packageName}}.Client.RequestOptions localVarRequestOptions = new {{packageName}}.Client.RequestOptions();
String[] _contentTypes = new String[] {
{{#consumes}}
"{{{mediaType}}}"{{^-last}},{{/-last}}
{{/consumes}}
};
// to determine the Accept header
String[] _accepts = new String[] {
{{#produces}}
"{{{mediaType}}}"{{^-last}},{{/-last}}
{{/produces}}
};
var localVarContentType = {{packageName}}.Client.ClientUtils.SelectHeaderContentType(_contentTypes);
if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType);
var localVarAccept = {{packageName}}.Client.ClientUtils.SelectHeaderAccept(_accepts);
if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept);
{{#pathParams}}
{{#required}}
localVarRequestOptions.PathParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // path parameter
{{/required}}
{{^required}}
if ({{paramName}} != null)
{
localVarRequestOptions.PathParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // path parameter
}
{{/required}}
{{/pathParams}}
{{#queryParams}}
{{#required}}
{{#isDeepObject}}
{{#items.vars}}
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}", "{{baseName}}", {{paramName}}.{{name}}));
{{/items.vars}}
{{^items}}
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("deepObject", "{{baseName}}", {{paramName}}));
{{/items}}
{{/isDeepObject}}
{{^isDeepObject}}
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}", "{{baseName}}", {{paramName}}));
{{/isDeepObject}}
{{/required}}
{{^required}}
if ({{paramName}} != null)
{
{{#isDeepObject}}
{{#items.vars}}
if ({{paramName}}.{{name}} != null)
{
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}", "{{baseName}}", {{paramName}}.{{name}}));
}
{{/items.vars}}
{{^items}}
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("deepObject", "{{baseName}}", {{paramName}}));
{{/items}}
{{/isDeepObject}}
{{^isDeepObject}}
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}", "{{baseName}}", {{paramName}}));
{{/isDeepObject}}
}
{{/required}}
{{/queryParams}}
{{#headerParams}}
{{#required}}
localVarRequestOptions.HeaderParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // header parameter
{{/required}}
{{^required}}
if ({{paramName}} != null)
{
localVarRequestOptions.HeaderParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // header parameter
}
{{/required}}
{{/headerParams}}
{{#formParams}}
{{#required}}
{{#isFile}}
localVarRequestOptions.FileParameters.Add("{{baseName}}", {{paramName}});
{{/isFile}}
{{^isFile}}
localVarRequestOptions.FormParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // form parameter
{{/isFile}}
{{/required}}
{{^required}}
if ({{paramName}} != null)
{
{{#isFile}}
localVarRequestOptions.FileParameters.Add("{{baseName}}", {{paramName}});
{{/isFile}}
{{^isFile}}
localVarRequestOptions.FormParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // form parameter
{{/isFile}}
}
{{/required}}
{{/formParams}}
{{#bodyParam}}
localVarRequestOptions.Data = {{paramName}};
{{/bodyParam}}
{{#authMethods}}
// authentication ({{name}}) required
{{#isApiKey}}
{{#isKeyInCookie}}
// cookie parameter support
if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
{
localVarRequestOptions.Cookies.Add(new Cookie("{{keyParamName}}", this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")));
}
{{/isKeyInCookie}}
{{#isKeyInHeader}}
if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
{
localVarRequestOptions.HeaderParameters.Add("{{keyParamName}}", this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}"));
}
{{/isKeyInHeader}}
{{#isKeyInQuery}}
if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
{
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("", "{{keyParamName}}", this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")));
}
{{/isKeyInQuery}}
{{/isApiKey}}
{{#isBasicBasic}}
// http basic authentication required
if (!String.IsNullOrEmpty(this.Configuration.Username) || !String.IsNullOrEmpty(this.Configuration.Password))
{
localVarRequestOptions.HeaderParameters.Add("Authorization", "Basic " + {{packageName}}.Client.ClientUtils.Base64Encode(this.Configuration.Username + ":" + this.Configuration.Password));
}
{{/isBasicBasic}}
{{#isBasicBearer}}
// bearer authentication required
if (!String.IsNullOrEmpty(this.Configuration.AccessToken))
{
localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken);
}
{{/isBasicBearer}}
{{#isOAuth}}
// oauth required
if (!String.IsNullOrEmpty(this.Configuration.AccessToken))
{
localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken);
}
{{/isOAuth}}
{{#isHttpSignature}}
if (this.Configuration.HttpSigningConfiguration != null)
{
var HttpSigningHeaders = this.Configuration.HttpSigningConfiguration.GetHttpSignedHeader(this.Configuration.BasePath, "{{{httpMethod}}}", "{{{path}}}", localVarRequestOptions);
foreach (var headerItem in HttpSigningHeaders)
{
if (localVarRequestOptions.HeaderParameters.ContainsKey(headerItem.Key))
{
localVarRequestOptions.HeaderParameters[headerItem.Key] = new List<string>() { headerItem.Value };
}
else
{
localVarRequestOptions.HeaderParameters.Add(headerItem.Key, headerItem.Value);
}
}
}
{{/isHttpSignature}}
{{/authMethods}}
// make the HTTP request
var localVarResponse = this.Client.{{#lambda.titlecase}}{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}{{/lambda.titlecase}}<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>("{{{path}}}", localVarRequestOptions, this.Configuration);
if (this.ExceptionFactory != null)
{
Exception _exception = this.ExceptionFactory("{{operationId}}", localVarResponse);
if (_exception != null) throw _exception;
}
return localVarResponse;
}
{{#supportsAsync}}
/// <summary>
/// {{summary}} {{notes}}
/// </summary>
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
{{#allParams}}
/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
{{/allParams}}
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task of {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}void{{/returnType}}</returns>
{{#returnType}}public async System.Threading.Tasks.Task<{{{returnType}}}>{{/returnType}}{{^returnType}}public async System.Threading.Tasks.Task{{/returnType}} {{operationId}}Async({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
{{#returnType}}{{packageName}}.Client.ApiResponse<{{{returnType}}}> localVarResponse = await {{operationId}}WithHttpInfoAsync({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}cancellationToken).ConfigureAwait(false);
return localVarResponse.Data;{{/returnType}}{{^returnType}}await {{operationId}}WithHttpInfoAsync({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}cancellationToken).ConfigureAwait(false);{{/returnType}}
}
/// <summary>
/// {{summary}} {{notes}}
/// </summary>
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
{{#allParams}}
/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
{{/allParams}}
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task of ApiResponse{{#returnType}} ({{returnType}}){{/returnType}}</returns>
public async System.Threading.Tasks.Task<{{packageName}}.Client.ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>> {{operationId}}WithHttpInfoAsync({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
{{#allParams}}
{{#required}}
{{^vendorExtensions.x-csharp-value-type}}
// verify the required parameter '{{paramName}}' is set
if ({{paramName}} == null)
throw new {{packageName}}.Client.ApiException(400, "Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}");
{{/vendorExtensions.x-csharp-value-type}}
{{/required}}
{{/allParams}}
{{packageName}}.Client.RequestOptions localVarRequestOptions = new {{packageName}}.Client.RequestOptions();
String[] _contentTypes = new String[] {
{{#consumes}}
"{{{mediaType}}}"{{^-last}}, {{/-last}}
{{/consumes}}
};
// to determine the Accept header
String[] _accepts = new String[] {
{{#produces}}
"{{{mediaType}}}"{{^-last}},{{/-last}}
{{/produces}}
};
var localVarContentType = {{packageName}}.Client.ClientUtils.SelectHeaderContentType(_contentTypes);
if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType);
var localVarAccept = {{packageName}}.Client.ClientUtils.SelectHeaderAccept(_accepts);
if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept);
{{#pathParams}}
{{#required}}
localVarRequestOptions.PathParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // path parameter
{{/required}}
{{^required}}
if ({{paramName}} != null)
{
localVarRequestOptions.PathParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // path parameter
}
{{/required}}
{{/pathParams}}
{{#queryParams}}
{{#required}}
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}", "{{baseName}}", {{paramName}}));
{{/required}}
{{^required}}
if ({{paramName}} != null)
{
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}", "{{baseName}}", {{paramName}}));
}
{{/required}}
{{/queryParams}}
{{#headerParams}}
{{#required}}
localVarRequestOptions.HeaderParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // header parameter
{{/required}}
{{^required}}
if ({{paramName}} != null)
{
localVarRequestOptions.HeaderParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // header parameter
}
{{/required}}
{{/headerParams}}
{{#formParams}}
{{#required}}
{{#isFile}}
localVarRequestOptions.FileParameters.Add("{{baseName}}", {{paramName}});
{{/isFile}}
{{^isFile}}
localVarRequestOptions.FormParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // form parameter
{{/isFile}}
{{/required}}
{{^required}}
if ({{paramName}} != null)
{
{{#isFile}}
localVarRequestOptions.FileParameters.Add("{{baseName}}", {{paramName}});
{{/isFile}}
{{^isFile}}
localVarRequestOptions.FormParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // form parameter
{{/isFile}}
}
{{/required}}
{{/formParams}}
{{#bodyParam}}
localVarRequestOptions.Data = {{paramName}};
{{/bodyParam}}
{{#authMethods}}
// authentication ({{name}}) required
{{#isApiKey}}
{{#isKeyInCookie}}
// cookie parameter support
if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
{
localVarRequestOptions.Cookies.Add(new Cookie("{{keyParamName}}", this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")));
}
{{/isKeyInCookie}}
{{#isKeyInHeader}}
if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
{
localVarRequestOptions.HeaderParameters.Add("{{keyParamName}}", this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}"));
}
{{/isKeyInHeader}}
{{#isKeyInQuery}}
if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
{
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("", "{{keyParamName}}", this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")));
}
{{/isKeyInQuery}}
{{/isApiKey}}
{{#isBasic}}
{{#isBasicBasic}}
// http basic authentication required
if (!String.IsNullOrEmpty(this.Configuration.Username) || !String.IsNullOrEmpty(this.Configuration.Password))
{
localVarRequestOptions.HeaderParameters.Add("Authorization", "Basic " + {{packageName}}.Client.ClientUtils.Base64Encode(this.Configuration.Username + ":" + this.Configuration.Password));
}
{{/isBasicBasic}}
{{#isBasicBearer}}
// bearer authentication required
if (!String.IsNullOrEmpty(this.Configuration.AccessToken))
{
localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken);
}
{{/isBasicBearer}}
{{/isBasic}}
{{#isOAuth}}
// oauth required
if (!String.IsNullOrEmpty(this.Configuration.AccessToken))
{
localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken);
}
{{/isOAuth}}
{{#isHttpSignature}}
if (this.Configuration.HttpSigningConfiguration != null)
{
var HttpSigningHeaders = this.Configuration.HttpSigningConfiguration.GetHttpSignedHeader(this.Configuration.BasePath, "{{{httpMethod}}}", "{{{path}}}", localVarRequestOptions);
foreach (var headerItem in HttpSigningHeaders)
{
if (localVarRequestOptions.HeaderParameters.ContainsKey(headerItem.Key))
{
localVarRequestOptions.HeaderParameters[headerItem.Key] = new List<string>() { headerItem.Value };
}
else
{
localVarRequestOptions.HeaderParameters.Add(headerItem.Key, headerItem.Value);
}
}
}
{{/isHttpSignature}}
{{/authMethods}}
// make the HTTP request
var localVarResponse = await this.AsynchronousClient.{{#lambda.titlecase}}{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}{{/lambda.titlecase}}Async<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>("{{{path}}}", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false);
if (this.ExceptionFactory != null)
{
Exception _exception = this.ExceptionFactory("{{operationId}}", localVarResponse);
if (_exception != null) throw _exception;
}
return localVarResponse;
}
{{/supportsAsync}}
{{/operation}}
}
{{/operations}}
}

View File

@@ -4,14 +4,13 @@ description: {{pubDescription}}
environment:
sdk: '>=2.7.0 <3.0.0'
dependencies:
dio: ^3.0.9
dio: '^3.0.9'
built_value: '>=7.1.0 <8.0.0'
built_collection: '>=4.3.2 <5.0.0'
{{#timeMachine}}
time_machine: ^0.9.12
time_machine: '^0.9.12'
{{/timeMachine}}
dev_dependencies:
built_value_generator: '>=7.1.0 <8.0.0'
build_runner: ^1.7.1
build_runner: any
test: '>=1.3.0 <1.16.0'

View File

@@ -6,7 +6,7 @@ environment:
sdk: '>=2.12.0 <3.0.0'
dependencies:
dio: '4.0.0-prev2'
dio: '>=4.0.0 <5.0.0'
{{#useBuiltValue}}
built_value: '>=8.0.3 <9.0.0'
built_collection: '>=5.0.0 <6.0.0'

View File

@@ -389,6 +389,13 @@ func (c *APIClient) prepareRequest(
for header, value := range c.cfg.DefaultHeader {
localVarRequest.Header.Add(header, value)
}
{{#withCustomMiddlewareFunction}}
if c.cfg.Middleware != nil {
c.cfg.Middleware(localVarRequest)
}
{{/withCustomMiddlewareFunction}}
{{#hasHttpSignatureMethods}}
if ctx != nil {
// HTTP Signature Authentication. All request headers must be set (including default headers)

View File

@@ -93,6 +93,11 @@ type ServerConfiguration struct {
// ServerConfigurations stores multiple ServerConfiguration items
type ServerConfigurations []ServerConfiguration
{{#withCustomMiddlewareFunction}}
// MiddlewareFunction provides way to implement custom middleware
type MiddlewareFunction func(*http.Request)
{{/withCustomMiddlewareFunction}}
// Configuration stores the configuration of the API client
type Configuration struct {
Host string `json:"host,omitempty"`
@@ -103,6 +108,9 @@ type Configuration struct {
Servers ServerConfigurations
OperationServers map[string]ServerConfigurations
HTTPClient *http.Client
{{#withCustomMiddlewareFunction}}
Middleware MiddlewareFunction
{{/withCustomMiddlewareFunction}}
}
// NewConfiguration returns a new Configuration object

View File

@@ -265,11 +265,11 @@ class ObjectSerializer
if (strcasecmp(substr($class, -2), '[]') === 0) {
$data = is_string($data) ? json_decode($data) : $data;
if (!is_array($data)) {
throw new \InvalidArgumentException("Invalid array '$class'");
}
$subClass = substr($class, 0, -2);
$values = [];
foreach ($data as $key => $value) {

View File

@@ -82,7 +82,7 @@ use {{invokerPackage}}\ObjectSerializer;
*
* @param int $hostIndex Host index (required)
*/
public function setHostIndex($hostIndex)
public function setHostIndex($hostIndex): void
{
$this->hostIndex = $hostIndex;
}
@@ -110,7 +110,7 @@ use {{invokerPackage}}\ObjectSerializer;
* Operation {{{operationId}}}
{{#summary}}
*
* {{{summary}}}
* {{.}}
{{/summary}}
*
{{#description}}
@@ -148,7 +148,7 @@ use {{invokerPackage}}\ObjectSerializer;
* Operation {{{operationId}}}WithHttpInfo
{{#summary}}
*
* {{{summary}}}
* {{.}}
{{/summary}}
*
{{#description}}
@@ -187,7 +187,7 @@ use {{invokerPackage}}\ObjectSerializer;
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
(int) $e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? (string) $e->getResponse()->getBody() : null
);
@@ -200,26 +200,25 @@ use {{invokerPackage}}\ObjectSerializer;
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
(string) $request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
(string) $response->getBody()
);
}
{{#returnType}}
{{#responses}}
{{#responses}}
{{#-first}}
$responseBody = $response->getBody();
switch($statusCode) {
{{/-first}}
{{#dataType}}
{{^isWildcard}}case {{code}}:{{/isWildcard}}{{#isWildcard}}default:{{/isWildcard}}
if ('{{{dataType}}}' === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $responseBody;
$content = (string) $response->getBody();
}
return [
@@ -231,14 +230,13 @@ use {{invokerPackage}}\ObjectSerializer;
{{#-last}}
}
{{/-last}}
{{/responses}}
{{/responses}}
$returnType = '{{{returnType}}}';
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $responseBody;
$content = (string) $response->getBody();
}
return [
@@ -274,8 +272,10 @@ use {{invokerPackage}}\ObjectSerializer;
/**
* Operation {{{operationId}}}Async
*
* {{{summary}}}
{{#summary}}
* {{.}}
*
{{/summary}}
{{#description}}
* {{.}}
*
@@ -313,8 +313,10 @@ use {{invokerPackage}}\ObjectSerializer;
/**
* Operation {{{operationId}}}AsyncWithHttpInfo
*
* {{{summary}}}
{{#summary}}
* {{.}}
*
{{/summary}}
{{#description}}
* {{.}}
*
@@ -349,11 +351,10 @@ use {{invokerPackage}}\ObjectSerializer;
->then(
function ($response) use ($returnType) {
{{#returnType}}
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $responseBody;
$content = (string) $response->getBody();
}
return [
@@ -364,7 +365,7 @@ use {{invokerPackage}}\ObjectSerializer;
{{/returnType}}
{{^returnType}}
return [null, $response->getStatusCode(), $response->getHeaders()];
{{/returnType}}
{{/returnType}}
},
function ($exception) {
$response = $exception->getResponse();
@@ -377,7 +378,7 @@ use {{invokerPackage}}\ObjectSerializer;
),
$statusCode,
$response->getHeaders(),
$response->getBody()
(string) $response->getBody()
);
}
);

View File

@@ -41,7 +41,7 @@ use \{{invokerPackage}}\ObjectSerializer;
{{^isEnum}}
* @implements \ArrayAccess<TKey, TValue>
* @template TKey int|null
* @template TValue mixed|null
* @template TValue mixed|null
{{/isEnum}}
*/
{{#isEnum}}{{>model_enum}}{{/isEnum}}{{^isEnum}}{{>model_generic}}{{/isEnum}}

View File

@@ -1,4 +1,4 @@
class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}{{^parentSchema}}implements ModelInterface, ArrayAccess, \JsonSerializable{{/parentSchema}}
class {{classname}} {{#parentSchema}}extends {{{parent}}}{{/parentSchema}}{{^parentSchema}}implements ModelInterface, ArrayAccess, \JsonSerializable{{/parentSchema}}
{
public const DISCRIMINATOR = {{#discriminator}}'{{discriminatorName}}'{{/discriminator}}{{^discriminator}}null{{/discriminator}};
@@ -123,10 +123,18 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}{{^pa
return self::$openAPIModelName;
}
{{#vars}}{{#isEnum}}{{#allowableValues}}{{#enumVars}}const {{enumName}}_{{{name}}} = {{{value}}};
{{/enumVars}}{{/allowableValues}}{{/isEnum}}{{/vars}}
{{#vars}}
{{#isEnum}}
{{#allowableValues}}
{{#enumVars}}
const {{enumName}}_{{{name}}} = {{{value}}};
{{/enumVars}}
{{/allowableValues}}
{{/isEnum}}
{{/vars}}
{{#vars}}{{#isEnum}}
{{#vars}}
{{#isEnum}}
/**
* Gets allowable values of the enum
*
@@ -139,8 +147,9 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}{{^pa
{{/-last}}{{/enumVars}}{{/allowableValues}}
];
}
{{/isEnum}}{{/vars}}
{{/isEnum}}
{{/vars}}
{{^parentSchema}}
/**
* Associative array for storing property values

View File

@@ -7,8 +7,12 @@
* {{{appDescription}}}
*
{{/appDescription}}
* {{#version}}The version of the OpenAPI document: {{{version}}}{{/version}}
* {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}}
{{#version}}
* The version of the OpenAPI document: {{{version}}}
{{/version}}
{{#infoEmail}}
* Contact: {{{infoEmail}}}
{{/infoEmail}}
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: {{{generatorVersion}}}
*/

View File

@@ -11,7 +11,17 @@ require '{{gemName}}/configuration'
# Models
{{#models}}
{{#model}}
require '{{gemName}}/{{modelPackage}}/{{classFilename}}'{{/model}}
{{^parent}}
require '{{gemName}}/{{modelPackage}}/{{classFilename}}'
{{/parent}}
{{/model}}
{{/models}}
{{#models}}
{{#model}}
{{#parent}}
require '{{gemName}}/{{modelPackage}}/{{classFilename}}'
{{/parent}}
{{/model}}
{{/models}}
# APIs

View File

@@ -270,11 +270,11 @@ public class DefaultCodegenTest {
CodegenProperty map_without_additional_properties_cp = null;
for(CodegenProperty cp: cm.vars) {
if (cp.baseName.equals("map_string")) {
if ("map_string".equals(cp.baseName)) {
map_string_cp = cp;
} else if (cp.baseName.equals("map_with_additional_properties")) {
} else if ("map_with_additional_properties".equals(cp.baseName)) {
map_with_additional_properties_cp = cp;
} else if (cp.baseName.equals("map_without_additional_properties")) {
} else if ("map_without_additional_properties".equals(cp.baseName)) {
map_without_additional_properties_cp = cp;
}
}
@@ -359,11 +359,11 @@ public class DefaultCodegenTest {
CodegenProperty map_without_additional_properties_cp = null;
for(CodegenProperty cp: cm.vars) {
if (cp.baseName.equals("map_string")) {
if ("map_string".equals(cp.baseName)) {
map_string_cp = cp;
} else if (cp.baseName.equals("map_with_additional_properties")) {
} else if ("map_with_additional_properties".equals(cp.baseName)) {
map_with_additional_properties_cp = cp;
} else if (cp.baseName.equals("map_without_additional_properties")) {
} else if ("map_without_additional_properties".equals(cp.baseName)) {
map_without_additional_properties_cp = cp;
}
}
@@ -439,15 +439,15 @@ public class DefaultCodegenTest {
CodegenProperty empty_map_cp = null;
for(CodegenProperty cp: cm.vars) {
if (cp.baseName.equals("map_with_undeclared_properties_string")) {
if ("map_with_undeclared_properties_string".equals(cp.baseName)) {
map_with_undeclared_properties_string_cp = cp;
} else if (cp.baseName.equals("map_with_undeclared_properties_anytype_1")) {
} else if ("map_with_undeclared_properties_anytype_1".equals(cp.baseName)) {
map_with_undeclared_properties_anytype_1_cp = cp;
} else if (cp.baseName.equals("map_with_undeclared_properties_anytype_2")) {
} else if ("map_with_undeclared_properties_anytype_2".equals(cp.baseName)) {
map_with_undeclared_properties_anytype_2_cp = cp;
} else if (cp.baseName.equals("map_with_undeclared_properties_anytype_3")) {
} else if ("map_with_undeclared_properties_anytype_3".equals(cp.baseName)) {
map_with_undeclared_properties_anytype_3_cp = cp;
} else if (cp.baseName.equals("empty_map")) {
} else if ("empty_map".equals(cp.baseName)) {
empty_map_cp = cp;
}
}
@@ -610,7 +610,7 @@ public class DefaultCodegenTest {
// make sure that fruit has the property color
boolean colorSeen = false;
for (CodegenProperty cp : fruit.vars) {
if (cp.name.equals("color")) {
if ("color".equals(cp.name)) {
colorSeen = true;
break;
}
@@ -618,7 +618,7 @@ public class DefaultCodegenTest {
Assert.assertTrue(colorSeen);
colorSeen = false;
for (CodegenProperty cp : fruit.optionalVars) {
if (cp.name.equals("color")) {
if ("color".equals(cp.name)) {
colorSeen = true;
break;
}

View File

@@ -76,7 +76,7 @@ public class AbstractKotlinCodegenTest {
assertEquals(codegen.toEnumValue("data", "Something"), "\"data\"");
}
private class P_AbstractKotlinCodegen extends AbstractKotlinCodegen {
private static class P_AbstractKotlinCodegen extends AbstractKotlinCodegen {
@Override
public CodegenType getTag() {
return null;

View File

@@ -47,6 +47,6 @@ public class Swift5OptionsTest extends AbstractOptionsTest {
verify(clientCodegen).setObjcCompatible(Boolean.parseBoolean(Swift5OptionsProvider.OBJC_COMPATIBLE_VALUE));
verify(clientCodegen).setLenientTypeCast(Boolean.parseBoolean(Swift5OptionsProvider.LENIENT_TYPE_CAST_VALUE));
verify(clientCodegen).setPrependFormOrBodyParameters(Boolean.valueOf(Swift5OptionsProvider.PREPEND_FORM_OR_BODY_PARAMETERS_VALUE));
verify(clientCodegen).setReadonlyProperties(Boolean.valueOf(Swift5OptionsProvider.READONLY_PROPERTIES_VALUE));
verify(clientCodegen).setReadonlyProperties(Boolean.parseBoolean(Swift5OptionsProvider.READONLY_PROPERTIES_VALUE));
}
}

View File

@@ -271,7 +271,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<version>3.2.0</version>
<configuration>
<archive>
<manifestEntries>

View File

@@ -50,6 +50,27 @@ webProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
c.Proxy = webProxy;
```
To use your own HttpClient instances just pass them to the ApiClass constructor.
```csharp
HttpClientHandler yourHandler = new HttpClientHandler();
HttpClient yourHttpClient = new HttpClient(yourHandler);
var api = new YourApiClass(yourHttpClient, yourHandler);
```
If you want to use an HttpClient and don't have access to the handler, for example in a DI context in aspnetcore when
using IHttpClientFactory. You need to disable the features that require handler access:
```csharp
HttpClient yourHttpClient = new HttpClient();
var api = new YourApiClass(yourHttpClient, null, true);
```
The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings.
You need to either manually handle those in your setup of the HttpClient or they won't be available.
<a name="getting-started"></a>
## Getting Started

View File

@@ -13,6 +13,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Mime;
using Org.OpenAPITools.Client;
using Org.OpenAPITools.Model;
@@ -93,30 +94,38 @@ namespace Org.OpenAPITools.Api
/// <summary>
/// Represents a collection of functions to interact with the API endpoints
/// </summary>
public partial class AnotherFakeApi : IAnotherFakeApi
public partial class AnotherFakeApi : IDisposable, IAnotherFakeApi
{
private Org.OpenAPITools.Client.ExceptionFactory _exceptionFactory = (name, response) => null;
/// <summary>
/// Initializes a new instance of the <see cref="AnotherFakeApi"/> class.
/// </summary>
/// <param name="client">An instance of HttpClient</param>
/// <param name="handler">An instance of HttpClientHandler that is used by HttpClient</param>
/// <param name="disableHandlerFeatures">Disable ApiClient features that require access to the HttpClientHandler</param>
/// <returns></returns>
public AnotherFakeApi() : this((string)null)
public AnotherFakeApi(HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) : this((string)null, client, handler, disableHandlerFeatures)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="AnotherFakeApi"/> class.
/// </summary>
/// <param name="client">An instance of HttpClient</param>
/// <param name="handler">An instance of HttpClientHandler that is used by HttpClient</param>
/// <param name="disableHandlerFeatures">Disable ApiClient features that require access to the HttpClientHandler</param>
/// <returns></returns>
public AnotherFakeApi(String basePath)
public AnotherFakeApi(String basePath, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false)
{
this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations(
Org.OpenAPITools.Client.GlobalConfiguration.Instance,
new Org.OpenAPITools.Client.Configuration { BasePath = basePath }
);
this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures);
this.Client = this.ApiClient;
this.AsynchronousClient = this.ApiClient;
this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory;
}
@@ -125,8 +134,11 @@ namespace Org.OpenAPITools.Api
/// using Configuration object
/// </summary>
/// <param name="configuration">An instance of Configuration</param>
/// <param name="client">An instance of HttpClient</param>
/// <param name="handler">An instance of HttpClientHandler that is used by HttpClient</param>
/// <param name="disableHandlerFeatures">Disable ApiClient features that require access to the HttpClientHandler</param>
/// <returns></returns>
public AnotherFakeApi(Org.OpenAPITools.Client.Configuration configuration)
public AnotherFakeApi(Org.OpenAPITools.Client.Configuration configuration, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false)
{
if (configuration == null) throw new ArgumentNullException("configuration");
@@ -134,8 +146,9 @@ namespace Org.OpenAPITools.Api
Org.OpenAPITools.Client.GlobalConfiguration.Instance,
configuration
);
this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures);
this.Client = this.ApiClient;
this.AsynchronousClient = this.ApiClient;
ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory;
}
@@ -158,6 +171,19 @@ namespace Org.OpenAPITools.Api
this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory;
}
/// <summary>
/// Disposes resources if they were created by us
/// </summary>
public void Dispose()
{
this.ApiClient?.Dispose();
}
/// <summary>
/// Holds the ApiClient if created
/// </summary>
public Org.OpenAPITools.Client.ApiClient ApiClient { get; set; } = null;
/// <summary>
/// The client for accessing this underlying API asynchronously.
/// </summary>

View File

@@ -13,6 +13,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Mime;
using Org.OpenAPITools.Client;
using Org.OpenAPITools.Model;
@@ -86,30 +87,38 @@ namespace Org.OpenAPITools.Api
/// <summary>
/// Represents a collection of functions to interact with the API endpoints
/// </summary>
public partial class DefaultApi : IDefaultApi
public partial class DefaultApi : IDisposable, IDefaultApi
{
private Org.OpenAPITools.Client.ExceptionFactory _exceptionFactory = (name, response) => null;
/// <summary>
/// Initializes a new instance of the <see cref="DefaultApi"/> class.
/// </summary>
/// <param name="client">An instance of HttpClient</param>
/// <param name="handler">An instance of HttpClientHandler that is used by HttpClient</param>
/// <param name="disableHandlerFeatures">Disable ApiClient features that require access to the HttpClientHandler</param>
/// <returns></returns>
public DefaultApi() : this((string)null)
public DefaultApi(HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) : this((string)null, client, handler, disableHandlerFeatures)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="DefaultApi"/> class.
/// </summary>
/// <param name="client">An instance of HttpClient</param>
/// <param name="handler">An instance of HttpClientHandler that is used by HttpClient</param>
/// <param name="disableHandlerFeatures">Disable ApiClient features that require access to the HttpClientHandler</param>
/// <returns></returns>
public DefaultApi(String basePath)
public DefaultApi(String basePath, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false)
{
this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations(
Org.OpenAPITools.Client.GlobalConfiguration.Instance,
new Org.OpenAPITools.Client.Configuration { BasePath = basePath }
);
this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures);
this.Client = this.ApiClient;
this.AsynchronousClient = this.ApiClient;
this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory;
}
@@ -118,8 +127,11 @@ namespace Org.OpenAPITools.Api
/// using Configuration object
/// </summary>
/// <param name="configuration">An instance of Configuration</param>
/// <param name="client">An instance of HttpClient</param>
/// <param name="handler">An instance of HttpClientHandler that is used by HttpClient</param>
/// <param name="disableHandlerFeatures">Disable ApiClient features that require access to the HttpClientHandler</param>
/// <returns></returns>
public DefaultApi(Org.OpenAPITools.Client.Configuration configuration)
public DefaultApi(Org.OpenAPITools.Client.Configuration configuration, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false)
{
if (configuration == null) throw new ArgumentNullException("configuration");
@@ -127,8 +139,9 @@ namespace Org.OpenAPITools.Api
Org.OpenAPITools.Client.GlobalConfiguration.Instance,
configuration
);
this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures);
this.Client = this.ApiClient;
this.AsynchronousClient = this.ApiClient;
ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory;
}
@@ -151,6 +164,19 @@ namespace Org.OpenAPITools.Api
this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory;
}
/// <summary>
/// Disposes resources if they were created by us
/// </summary>
public void Dispose()
{
this.ApiClient?.Dispose();
}
/// <summary>
/// Holds the ApiClient if created
/// </summary>
public Org.OpenAPITools.Client.ApiClient ApiClient { get; set; } = null;
/// <summary>
/// The client for accessing this underlying API asynchronously.
/// </summary>

View File

@@ -13,6 +13,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Mime;
using Org.OpenAPITools.Client;
using Org.OpenAPITools.Model;
@@ -810,30 +811,38 @@ namespace Org.OpenAPITools.Api
/// <summary>
/// Represents a collection of functions to interact with the API endpoints
/// </summary>
public partial class FakeApi : IFakeApi
public partial class FakeApi : IDisposable, IFakeApi
{
private Org.OpenAPITools.Client.ExceptionFactory _exceptionFactory = (name, response) => null;
/// <summary>
/// Initializes a new instance of the <see cref="FakeApi"/> class.
/// </summary>
/// <param name="client">An instance of HttpClient</param>
/// <param name="handler">An instance of HttpClientHandler that is used by HttpClient</param>
/// <param name="disableHandlerFeatures">Disable ApiClient features that require access to the HttpClientHandler</param>
/// <returns></returns>
public FakeApi() : this((string)null)
public FakeApi(HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) : this((string)null, client, handler, disableHandlerFeatures)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="FakeApi"/> class.
/// </summary>
/// <param name="client">An instance of HttpClient</param>
/// <param name="handler">An instance of HttpClientHandler that is used by HttpClient</param>
/// <param name="disableHandlerFeatures">Disable ApiClient features that require access to the HttpClientHandler</param>
/// <returns></returns>
public FakeApi(String basePath)
public FakeApi(String basePath, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false)
{
this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations(
Org.OpenAPITools.Client.GlobalConfiguration.Instance,
new Org.OpenAPITools.Client.Configuration { BasePath = basePath }
);
this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures);
this.Client = this.ApiClient;
this.AsynchronousClient = this.ApiClient;
this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory;
}
@@ -842,8 +851,11 @@ namespace Org.OpenAPITools.Api
/// using Configuration object
/// </summary>
/// <param name="configuration">An instance of Configuration</param>
/// <param name="client">An instance of HttpClient</param>
/// <param name="handler">An instance of HttpClientHandler that is used by HttpClient</param>
/// <param name="disableHandlerFeatures">Disable ApiClient features that require access to the HttpClientHandler</param>
/// <returns></returns>
public FakeApi(Org.OpenAPITools.Client.Configuration configuration)
public FakeApi(Org.OpenAPITools.Client.Configuration configuration, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false)
{
if (configuration == null) throw new ArgumentNullException("configuration");
@@ -851,8 +863,9 @@ namespace Org.OpenAPITools.Api
Org.OpenAPITools.Client.GlobalConfiguration.Instance,
configuration
);
this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures);
this.Client = this.ApiClient;
this.AsynchronousClient = this.ApiClient;
ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory;
}
@@ -875,6 +888,19 @@ namespace Org.OpenAPITools.Api
this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory;
}
/// <summary>
/// Disposes resources if they were created by us
/// </summary>
public void Dispose()
{
this.ApiClient?.Dispose();
}
/// <summary>
/// Holds the ApiClient if created
/// </summary>
public Org.OpenAPITools.Client.ApiClient ApiClient { get; set; } = null;
/// <summary>
/// The client for accessing this underlying API asynchronously.
/// </summary>

View File

@@ -13,6 +13,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Mime;
using Org.OpenAPITools.Client;
using Org.OpenAPITools.Model;
@@ -93,30 +94,38 @@ namespace Org.OpenAPITools.Api
/// <summary>
/// Represents a collection of functions to interact with the API endpoints
/// </summary>
public partial class FakeClassnameTags123Api : IFakeClassnameTags123Api
public partial class FakeClassnameTags123Api : IDisposable, IFakeClassnameTags123Api
{
private Org.OpenAPITools.Client.ExceptionFactory _exceptionFactory = (name, response) => null;
/// <summary>
/// Initializes a new instance of the <see cref="FakeClassnameTags123Api"/> class.
/// </summary>
/// <param name="client">An instance of HttpClient</param>
/// <param name="handler">An instance of HttpClientHandler that is used by HttpClient</param>
/// <param name="disableHandlerFeatures">Disable ApiClient features that require access to the HttpClientHandler</param>
/// <returns></returns>
public FakeClassnameTags123Api() : this((string)null)
public FakeClassnameTags123Api(HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) : this((string)null, client, handler, disableHandlerFeatures)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="FakeClassnameTags123Api"/> class.
/// </summary>
/// <param name="client">An instance of HttpClient</param>
/// <param name="handler">An instance of HttpClientHandler that is used by HttpClient</param>
/// <param name="disableHandlerFeatures">Disable ApiClient features that require access to the HttpClientHandler</param>
/// <returns></returns>
public FakeClassnameTags123Api(String basePath)
public FakeClassnameTags123Api(String basePath, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false)
{
this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations(
Org.OpenAPITools.Client.GlobalConfiguration.Instance,
new Org.OpenAPITools.Client.Configuration { BasePath = basePath }
);
this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures);
this.Client = this.ApiClient;
this.AsynchronousClient = this.ApiClient;
this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory;
}
@@ -125,8 +134,11 @@ namespace Org.OpenAPITools.Api
/// using Configuration object
/// </summary>
/// <param name="configuration">An instance of Configuration</param>
/// <param name="client">An instance of HttpClient</param>
/// <param name="handler">An instance of HttpClientHandler that is used by HttpClient</param>
/// <param name="disableHandlerFeatures">Disable ApiClient features that require access to the HttpClientHandler</param>
/// <returns></returns>
public FakeClassnameTags123Api(Org.OpenAPITools.Client.Configuration configuration)
public FakeClassnameTags123Api(Org.OpenAPITools.Client.Configuration configuration, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false)
{
if (configuration == null) throw new ArgumentNullException("configuration");
@@ -134,8 +146,9 @@ namespace Org.OpenAPITools.Api
Org.OpenAPITools.Client.GlobalConfiguration.Instance,
configuration
);
this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures);
this.Client = this.ApiClient;
this.AsynchronousClient = this.ApiClient;
ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory;
}
@@ -158,6 +171,19 @@ namespace Org.OpenAPITools.Api
this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory;
}
/// <summary>
/// Disposes resources if they were created by us
/// </summary>
public void Dispose()
{
this.ApiClient?.Dispose();
}
/// <summary>
/// Holds the ApiClient if created
/// </summary>
public Org.OpenAPITools.Client.ApiClient ApiClient { get; set; } = null;
/// <summary>
/// The client for accessing this underlying API asynchronously.
/// </summary>

View File

@@ -13,6 +13,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Mime;
using Org.OpenAPITools.Client;
using Org.OpenAPITools.Model;
@@ -455,30 +456,38 @@ namespace Org.OpenAPITools.Api
/// <summary>
/// Represents a collection of functions to interact with the API endpoints
/// </summary>
public partial class PetApi : IPetApi
public partial class PetApi : IDisposable, IPetApi
{
private Org.OpenAPITools.Client.ExceptionFactory _exceptionFactory = (name, response) => null;
/// <summary>
/// Initializes a new instance of the <see cref="PetApi"/> class.
/// </summary>
/// <param name="client">An instance of HttpClient</param>
/// <param name="handler">An instance of HttpClientHandler that is used by HttpClient</param>
/// <param name="disableHandlerFeatures">Disable ApiClient features that require access to the HttpClientHandler</param>
/// <returns></returns>
public PetApi() : this((string)null)
public PetApi(HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) : this((string)null, client, handler, disableHandlerFeatures)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="PetApi"/> class.
/// </summary>
/// <param name="client">An instance of HttpClient</param>
/// <param name="handler">An instance of HttpClientHandler that is used by HttpClient</param>
/// <param name="disableHandlerFeatures">Disable ApiClient features that require access to the HttpClientHandler</param>
/// <returns></returns>
public PetApi(String basePath)
public PetApi(String basePath, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false)
{
this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations(
Org.OpenAPITools.Client.GlobalConfiguration.Instance,
new Org.OpenAPITools.Client.Configuration { BasePath = basePath }
);
this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures);
this.Client = this.ApiClient;
this.AsynchronousClient = this.ApiClient;
this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory;
}
@@ -487,8 +496,11 @@ namespace Org.OpenAPITools.Api
/// using Configuration object
/// </summary>
/// <param name="configuration">An instance of Configuration</param>
/// <param name="client">An instance of HttpClient</param>
/// <param name="handler">An instance of HttpClientHandler that is used by HttpClient</param>
/// <param name="disableHandlerFeatures">Disable ApiClient features that require access to the HttpClientHandler</param>
/// <returns></returns>
public PetApi(Org.OpenAPITools.Client.Configuration configuration)
public PetApi(Org.OpenAPITools.Client.Configuration configuration, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false)
{
if (configuration == null) throw new ArgumentNullException("configuration");
@@ -496,8 +508,9 @@ namespace Org.OpenAPITools.Api
Org.OpenAPITools.Client.GlobalConfiguration.Instance,
configuration
);
this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures);
this.Client = this.ApiClient;
this.AsynchronousClient = this.ApiClient;
ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory;
}
@@ -520,6 +533,19 @@ namespace Org.OpenAPITools.Api
this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory;
}
/// <summary>
/// Disposes resources if they were created by us
/// </summary>
public void Dispose()
{
this.ApiClient?.Dispose();
}
/// <summary>
/// Holds the ApiClient if created
/// </summary>
public Org.OpenAPITools.Client.ApiClient ApiClient { get; set; } = null;
/// <summary>
/// The client for accessing this underlying API asynchronously.
/// </summary>

View File

@@ -13,6 +13,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Mime;
using Org.OpenAPITools.Client;
using Org.OpenAPITools.Model;
@@ -218,30 +219,38 @@ namespace Org.OpenAPITools.Api
/// <summary>
/// Represents a collection of functions to interact with the API endpoints
/// </summary>
public partial class StoreApi : IStoreApi
public partial class StoreApi : IDisposable, IStoreApi
{
private Org.OpenAPITools.Client.ExceptionFactory _exceptionFactory = (name, response) => null;
/// <summary>
/// Initializes a new instance of the <see cref="StoreApi"/> class.
/// </summary>
/// <param name="client">An instance of HttpClient</param>
/// <param name="handler">An instance of HttpClientHandler that is used by HttpClient</param>
/// <param name="disableHandlerFeatures">Disable ApiClient features that require access to the HttpClientHandler</param>
/// <returns></returns>
public StoreApi() : this((string)null)
public StoreApi(HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) : this((string)null, client, handler, disableHandlerFeatures)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="StoreApi"/> class.
/// </summary>
/// <param name="client">An instance of HttpClient</param>
/// <param name="handler">An instance of HttpClientHandler that is used by HttpClient</param>
/// <param name="disableHandlerFeatures">Disable ApiClient features that require access to the HttpClientHandler</param>
/// <returns></returns>
public StoreApi(String basePath)
public StoreApi(String basePath, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false)
{
this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations(
Org.OpenAPITools.Client.GlobalConfiguration.Instance,
new Org.OpenAPITools.Client.Configuration { BasePath = basePath }
);
this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures);
this.Client = this.ApiClient;
this.AsynchronousClient = this.ApiClient;
this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory;
}
@@ -250,8 +259,11 @@ namespace Org.OpenAPITools.Api
/// using Configuration object
/// </summary>
/// <param name="configuration">An instance of Configuration</param>
/// <param name="client">An instance of HttpClient</param>
/// <param name="handler">An instance of HttpClientHandler that is used by HttpClient</param>
/// <param name="disableHandlerFeatures">Disable ApiClient features that require access to the HttpClientHandler</param>
/// <returns></returns>
public StoreApi(Org.OpenAPITools.Client.Configuration configuration)
public StoreApi(Org.OpenAPITools.Client.Configuration configuration, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false)
{
if (configuration == null) throw new ArgumentNullException("configuration");
@@ -259,8 +271,9 @@ namespace Org.OpenAPITools.Api
Org.OpenAPITools.Client.GlobalConfiguration.Instance,
configuration
);
this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures);
this.Client = this.ApiClient;
this.AsynchronousClient = this.ApiClient;
ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory;
}
@@ -283,6 +296,19 @@ namespace Org.OpenAPITools.Api
this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory;
}
/// <summary>
/// Disposes resources if they were created by us
/// </summary>
public void Dispose()
{
this.ApiClient?.Dispose();
}
/// <summary>
/// Holds the ApiClient if created
/// </summary>
public Org.OpenAPITools.Client.ApiClient ApiClient { get; set; } = null;
/// <summary>
/// The client for accessing this underlying API asynchronously.
/// </summary>

View File

@@ -13,6 +13,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Mime;
using Org.OpenAPITools.Client;
using Org.OpenAPITools.Model;
@@ -390,30 +391,38 @@ namespace Org.OpenAPITools.Api
/// <summary>
/// Represents a collection of functions to interact with the API endpoints
/// </summary>
public partial class UserApi : IUserApi
public partial class UserApi : IDisposable, IUserApi
{
private Org.OpenAPITools.Client.ExceptionFactory _exceptionFactory = (name, response) => null;
/// <summary>
/// Initializes a new instance of the <see cref="UserApi"/> class.
/// </summary>
/// <param name="client">An instance of HttpClient</param>
/// <param name="handler">An instance of HttpClientHandler that is used by HttpClient</param>
/// <param name="disableHandlerFeatures">Disable ApiClient features that require access to the HttpClientHandler</param>
/// <returns></returns>
public UserApi() : this((string)null)
public UserApi(HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) : this((string)null, client, handler, disableHandlerFeatures)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="UserApi"/> class.
/// </summary>
/// <param name="client">An instance of HttpClient</param>
/// <param name="handler">An instance of HttpClientHandler that is used by HttpClient</param>
/// <param name="disableHandlerFeatures">Disable ApiClient features that require access to the HttpClientHandler</param>
/// <returns></returns>
public UserApi(String basePath)
public UserApi(String basePath, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false)
{
this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations(
Org.OpenAPITools.Client.GlobalConfiguration.Instance,
new Org.OpenAPITools.Client.Configuration { BasePath = basePath }
);
this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures);
this.Client = this.ApiClient;
this.AsynchronousClient = this.ApiClient;
this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory;
}
@@ -422,8 +431,11 @@ namespace Org.OpenAPITools.Api
/// using Configuration object
/// </summary>
/// <param name="configuration">An instance of Configuration</param>
/// <param name="client">An instance of HttpClient</param>
/// <param name="handler">An instance of HttpClientHandler that is used by HttpClient</param>
/// <param name="disableHandlerFeatures">Disable ApiClient features that require access to the HttpClientHandler</param>
/// <returns></returns>
public UserApi(Org.OpenAPITools.Client.Configuration configuration)
public UserApi(Org.OpenAPITools.Client.Configuration configuration, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false)
{
if (configuration == null) throw new ArgumentNullException("configuration");
@@ -431,8 +443,9 @@ namespace Org.OpenAPITools.Api
Org.OpenAPITools.Client.GlobalConfiguration.Instance,
configuration
);
this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
this.ApiClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath, client, handler, disableHandlerFeatures);
this.Client = this.ApiClient;
this.AsynchronousClient = this.ApiClient;
ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory;
}
@@ -455,6 +468,19 @@ namespace Org.OpenAPITools.Api
this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory;
}
/// <summary>
/// Disposes resources if they were created by us
/// </summary>
public void Dispose()
{
this.ApiClient?.Dispose();
}
/// <summary>
/// Holds the ApiClient if created
/// </summary>
public Org.OpenAPITools.Client.ApiClient ApiClient { get; set; } = null;
/// <summary>
/// The client for accessing this underlying API asynchronously.
/// </summary>

View File

@@ -161,10 +161,17 @@ namespace Org.OpenAPITools.Client
/// Provides a default implementation of an Api client (both synchronous and asynchronous implementatios),
/// encapsulating general REST accessor use cases.
/// </summary>
public partial class ApiClient : ISynchronousClient, IAsynchronousClient
public partial class ApiClient : IDisposable, ISynchronousClient, IAsynchronousClient
{
private readonly String _baseUrl;
private readonly HttpClientHandler _httpClientHandler;
private readonly bool _disposeHandler;
private readonly HttpClient _httpClient;
private readonly bool _disposeClient;
private readonly bool _disableHandlerFeatures;
/// <summary>
/// Specifies the settings on a <see cref="JsonSerializer" /> object.
/// These settings can be adjusted to accomodate custom serialization rules.
@@ -185,22 +192,50 @@ namespace Org.OpenAPITools.Client
/// <summary>
/// Initializes a new instance of the <see cref="ApiClient" />, defaulting to the global configurations' base url.
/// </summary>
public ApiClient()
/// <param name="client">An instance of HttpClient</param>
/// <param name="handler">An instance of HttpClientHandler that is used by HttpClient</param>
/// <param name="disableHandlerFeatures">Disable ApiClient features that require access to the HttpClientHandler</param>
public ApiClient(HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false) :
this(Org.OpenAPITools.Client.GlobalConfiguration.Instance.BasePath, client, handler, disableHandlerFeatures)
{
_baseUrl = Org.OpenAPITools.Client.GlobalConfiguration.Instance.BasePath;
}
/// <summary>
/// Initializes a new instance of the <see cref="ApiClient" />
/// </summary>
/// <param name="basePath">The target service's base path in URL format.</param>
/// <param name="client">An instance of HttpClient</param>
/// <param name="handler">An instance of HttpClientHandler that is used by HttpClient</param>
/// <param name="disableHandlerFeatures">Disable ApiClient features that require access to the HttpClientHandler</param>
/// <exception cref="ArgumentException"></exception>
public ApiClient(String basePath)
public ApiClient(String basePath, HttpClient client = null, HttpClientHandler handler = null, bool disableHandlerFeatures = false)
{
if (string.IsNullOrEmpty(basePath))
throw new ArgumentException("basePath cannot be empty");
_baseUrl = basePath;
if((client != null && handler == null) && !disableHandlerFeatures) {
throw new ArgumentException("If providing HttpClient, you also need to provide its handler or disable features requiring the handler, see README.md");
}
_disableHandlerFeatures = disableHandlerFeatures;
_httpClientHandler = handler ?? new HttpClientHandler();
_disposeHandler = handler == null;
_httpClient = client ?? new HttpClient(_httpClientHandler, false);
_disposeClient = client == null;
}
/// <summary>
/// Disposes resources if they were created by us
/// </summary>
public void Dispose()
{
if(_disposeClient) {
_httpClient.Dispose();
}
if(_disposeHandler) {
_httpClientHandler.Dispose();
}
}
/// Prepares multipart/form-data content
@@ -262,6 +297,11 @@ namespace Org.OpenAPITools.Client
HttpRequestMessage request = new HttpRequestMessage(method, builder.GetFullUri());
if (configuration.UserAgent != null)
{
request.Headers.TryAddWithoutValidation("User-Agent", configuration.UserAgent);
}
if (configuration.DefaultHeaders != null)
{
foreach (var headerParam in configuration.DefaultHeaders)
@@ -363,15 +403,18 @@ namespace Org.OpenAPITools.Client
}
}
if (response != null)
if(!_disableHandlerFeatures)
{
try {
foreach (Cookie cookie in handler.CookieContainer.GetCookies(uri))
{
transformed.Cookies.Add(cookie);
if (response != null)
{
try {
foreach (Cookie cookie in handler.CookieContainer.GetCookies(uri))
{
transformed.Cookies.Add(cookie);
}
}
catch (PlatformNotSupportedException) {}
}
catch (PlatformNotSupportedException) {}
}
return transformed;
@@ -386,8 +429,8 @@ namespace Org.OpenAPITools.Client
IReadableConfiguration configuration,
System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
var handler = new HttpClientHandler();
var client = new HttpClient();
var handler = _httpClientHandler;
var client = _httpClient;
var deserializer = new CustomJsonCodec(SerializerSettings, configuration);
var finalToken = cancellationToken;
@@ -397,20 +440,16 @@ namespace Org.OpenAPITools.Client
var tokenSource = new CancellationTokenSource(configuration.Timeout);
finalToken = CancellationTokenSource.CreateLinkedTokenSource(finalToken, tokenSource.Token).Token;
}
if(!_disableHandlerFeatures) {
if (configuration.Proxy != null)
{
handler.Proxy = configuration.Proxy;
}
if (configuration.Proxy != null)
{
handler.Proxy = configuration.Proxy;
}
if (configuration.UserAgent != null)
{
client.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", configuration.UserAgent);
}
if (configuration.ClientCertificates != null)
{
handler.ClientCertificates.AddRange(configuration.ClientCertificates);
if (configuration.ClientCertificates != null)
{
handler.ClientCertificates.AddRange(configuration.ClientCertificates);
}
}
var cookieContainer = req.Properties.ContainsKey("CookieContainer") ? req.Properties["CookieContainer"] as List<Cookie> : null;

View File

@@ -4,11 +4,10 @@ description: OpenAPI API client
environment:
sdk: '>=2.7.0 <3.0.0'
dependencies:
dio: ^3.0.9
dio: '^3.0.9'
built_value: '>=7.1.0 <8.0.0'
built_collection: '>=4.3.2 <5.0.0'
dev_dependencies:
built_value_generator: '>=7.1.0 <8.0.0'
build_runner: ^1.7.1
build_runner: any
test: '>=1.3.0 <1.16.0'

View File

@@ -60,6 +60,8 @@ public class AdditionalPropertiesAnyType extends HashMap<String, Object> {
}
@JsonProperty(JSON_PROPERTY_NAME)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setName(String name) {
this.name = name;
}

View File

@@ -61,6 +61,8 @@ public class AdditionalPropertiesArray extends HashMap<String, List> {
}
@JsonProperty(JSON_PROPERTY_NAME)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setName(String name) {
this.name = name;
}

View File

@@ -60,6 +60,8 @@ public class AdditionalPropertiesBoolean extends HashMap<String, Boolean> {
}
@JsonProperty(JSON_PROPERTY_NAME)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setName(String name) {
this.name = name;
}

View File

@@ -110,6 +110,8 @@ public class AdditionalPropertiesClass {
}
@JsonProperty(JSON_PROPERTY_MAP_STRING)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setMapString(Map<String, String> mapString) {
this.mapString = mapString;
}
@@ -143,6 +145,8 @@ public class AdditionalPropertiesClass {
}
@JsonProperty(JSON_PROPERTY_MAP_NUMBER)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setMapNumber(Map<String, BigDecimal> mapNumber) {
this.mapNumber = mapNumber;
}
@@ -176,6 +180,8 @@ public class AdditionalPropertiesClass {
}
@JsonProperty(JSON_PROPERTY_MAP_INTEGER)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setMapInteger(Map<String, Integer> mapInteger) {
this.mapInteger = mapInteger;
}
@@ -209,6 +215,8 @@ public class AdditionalPropertiesClass {
}
@JsonProperty(JSON_PROPERTY_MAP_BOOLEAN)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setMapBoolean(Map<String, Boolean> mapBoolean) {
this.mapBoolean = mapBoolean;
}
@@ -242,6 +250,8 @@ public class AdditionalPropertiesClass {
}
@JsonProperty(JSON_PROPERTY_MAP_ARRAY_INTEGER)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setMapArrayInteger(Map<String, List<Integer>> mapArrayInteger) {
this.mapArrayInteger = mapArrayInteger;
}
@@ -275,6 +285,8 @@ public class AdditionalPropertiesClass {
}
@JsonProperty(JSON_PROPERTY_MAP_ARRAY_ANYTYPE)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setMapArrayAnytype(Map<String, List<Object>> mapArrayAnytype) {
this.mapArrayAnytype = mapArrayAnytype;
}
@@ -308,6 +320,8 @@ public class AdditionalPropertiesClass {
}
@JsonProperty(JSON_PROPERTY_MAP_MAP_STRING)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setMapMapString(Map<String, Map<String, String>> mapMapString) {
this.mapMapString = mapMapString;
}
@@ -341,6 +355,8 @@ public class AdditionalPropertiesClass {
}
@JsonProperty(JSON_PROPERTY_MAP_MAP_ANYTYPE)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setMapMapAnytype(Map<String, Map<String, Object>> mapMapAnytype) {
this.mapMapAnytype = mapMapAnytype;
}
@@ -366,6 +382,8 @@ public class AdditionalPropertiesClass {
}
@JsonProperty(JSON_PROPERTY_ANYTYPE1)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setAnytype1(Object anytype1) {
this.anytype1 = anytype1;
}
@@ -391,6 +409,8 @@ public class AdditionalPropertiesClass {
}
@JsonProperty(JSON_PROPERTY_ANYTYPE2)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setAnytype2(Object anytype2) {
this.anytype2 = anytype2;
}
@@ -416,6 +436,8 @@ public class AdditionalPropertiesClass {
}
@JsonProperty(JSON_PROPERTY_ANYTYPE3)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setAnytype3(Object anytype3) {
this.anytype3 = anytype3;
}

View File

@@ -60,6 +60,8 @@ public class AdditionalPropertiesInteger extends HashMap<String, Integer> {
}
@JsonProperty(JSON_PROPERTY_NAME)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setName(String name) {
this.name = name;
}

View File

@@ -61,6 +61,8 @@ public class AdditionalPropertiesNumber extends HashMap<String, BigDecimal> {
}
@JsonProperty(JSON_PROPERTY_NAME)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setName(String name) {
this.name = name;
}

View File

@@ -60,6 +60,8 @@ public class AdditionalPropertiesObject extends HashMap<String, Map> {
}
@JsonProperty(JSON_PROPERTY_NAME)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setName(String name) {
this.name = name;
}

View File

@@ -60,6 +60,8 @@ public class AdditionalPropertiesString extends HashMap<String, String> {
}
@JsonProperty(JSON_PROPERTY_NAME)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setName(String name) {
this.name = name;
}

View File

@@ -73,6 +73,8 @@ public class Animal {
}
@JsonProperty(JSON_PROPERTY_CLASS_NAME)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public void setClassName(String className) {
this.className = className;
}
@@ -98,6 +100,8 @@ public class Animal {
}
@JsonProperty(JSON_PROPERTY_COLOR)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setColor(String color) {
this.color = color;
}

View File

@@ -69,6 +69,8 @@ public class ArrayOfArrayOfNumberOnly {
}
@JsonProperty(JSON_PROPERTY_ARRAY_ARRAY_NUMBER)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setArrayArrayNumber(List<List<BigDecimal>> arrayArrayNumber) {
this.arrayArrayNumber = arrayArrayNumber;
}

View File

@@ -69,6 +69,8 @@ public class ArrayOfNumberOnly {
}
@JsonProperty(JSON_PROPERTY_ARRAY_NUMBER)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setArrayNumber(List<BigDecimal> arrayNumber) {
this.arrayNumber = arrayNumber;
}

View File

@@ -77,6 +77,8 @@ public class ArrayTest {
}
@JsonProperty(JSON_PROPERTY_ARRAY_OF_STRING)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setArrayOfString(List<String> arrayOfString) {
this.arrayOfString = arrayOfString;
}
@@ -110,6 +112,8 @@ public class ArrayTest {
}
@JsonProperty(JSON_PROPERTY_ARRAY_ARRAY_OF_INTEGER)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setArrayArrayOfInteger(List<List<Long>> arrayArrayOfInteger) {
this.arrayArrayOfInteger = arrayArrayOfInteger;
}
@@ -143,6 +147,8 @@ public class ArrayTest {
}
@JsonProperty(JSON_PROPERTY_ARRAY_ARRAY_OF_MODEL)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setArrayArrayOfModel(List<List<ReadOnlyFirst>> arrayArrayOfModel) {
this.arrayArrayOfModel = arrayArrayOfModel;
}

View File

@@ -103,6 +103,8 @@ public class BigCat extends Cat {
}
@JsonProperty(JSON_PROPERTY_KIND)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setKind(KindEnum kind) {
this.kind = kind;
}

View File

@@ -97,6 +97,8 @@ public class BigCatAllOf {
}
@JsonProperty(JSON_PROPERTY_KIND)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setKind(KindEnum kind) {
this.kind = kind;
}

View File

@@ -78,6 +78,8 @@ public class Capitalization {
}
@JsonProperty(JSON_PROPERTY_SMALL_CAMEL)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setSmallCamel(String smallCamel) {
this.smallCamel = smallCamel;
}
@@ -103,6 +105,8 @@ public class Capitalization {
}
@JsonProperty(JSON_PROPERTY_CAPITAL_CAMEL)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setCapitalCamel(String capitalCamel) {
this.capitalCamel = capitalCamel;
}
@@ -128,6 +132,8 @@ public class Capitalization {
}
@JsonProperty(JSON_PROPERTY_SMALL_SNAKE)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setSmallSnake(String smallSnake) {
this.smallSnake = smallSnake;
}
@@ -153,6 +159,8 @@ public class Capitalization {
}
@JsonProperty(JSON_PROPERTY_CAPITAL_SNAKE)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setCapitalSnake(String capitalSnake) {
this.capitalSnake = capitalSnake;
}
@@ -178,6 +186,8 @@ public class Capitalization {
}
@JsonProperty(JSON_PROPERTY_SC_A_E_T_H_FLOW_POINTS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setScAETHFlowPoints(String scAETHFlowPoints) {
this.scAETHFlowPoints = scAETHFlowPoints;
}
@@ -203,6 +213,8 @@ public class Capitalization {
}
@JsonProperty(JSON_PROPERTY_A_T_T_N_A_M_E)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setATTNAME(String ATT_NAME) {
this.ATT_NAME = ATT_NAME;
}

View File

@@ -68,6 +68,8 @@ public class Cat extends Animal {
}
@JsonProperty(JSON_PROPERTY_DECLAWED)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setDeclawed(Boolean declawed) {
this.declawed = declawed;
}

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