forked from loafle/openapi-generator-original
Merge remote-tracking branch 'origin/5.3.x' into 6.0.x
This commit is contained in:
commit
b799ca9ee0
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -16,5 +16,5 @@
|
||||
These must match the expectations made by your contribution.
|
||||
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example `./bin/generate-samples.sh bin/configs/java*`.
|
||||
For Windows users, please run the script in [Git BASH](https://gitforwindows.org/).
|
||||
- [ ] File the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master`, `5.1.x`, `6.0.x`
|
||||
- [ ] File the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master`, `5.3.x`, `6.0.x`
|
||||
- [ ] If your PR is targeting a particular programming language, @mention the [technical committee](https://github.com/openapitools/openapi-generator/#62---openapi-generator-technical-committee) members, so they are more likely to review the pull request.
|
||||
|
@ -826,6 +826,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- 2021-04-27 - [From zero to publishing PowerShell API clients in PowerShell Gallery within minutes](https://speakerdeck.com/wing328/from-zero-to-publishing-powershell-api-clients-in-powershell-gallery-within-minutes) by [William Cheng](https://github.com/wing328) at [PowerShell + DevOps Global Summit 2021](https://events.devopscollective.org/event/powershell-devops-global-summit-2021/)
|
||||
- 2021-05-31 - [FlutterでOpen Api Generator(Swagger)を使う](https://aakira.app/blog/2021/05/flutter-open-api/) by [AAkira](https://twitter.com/_a_akira)
|
||||
- 2021-06-22 - [Rest API Documentation and Client Generation With OpenAPI](https://dzone.com/articles/rest-api-documentation-and-client-generation-with) by [Prasanth Gullapalli](https://dzone.com/users/1011797/prasanthnath.g@gmail.com.html)
|
||||
- 2021-07-16 - [銀行事業のサーバーサイド開発について / LINE 京都開発室 エンジニア採用説明会](https://www.youtube.com/watch?v=YrrKQHxLPpQ) by 野田誠人, Robert Mitchell
|
||||
|
||||
## [6 - About Us](#table-of-contents)
|
||||
|
||||
@ -1029,7 +1030,7 @@ If you want to join the committee, please kindly apply by sending an email to te
|
||||
| C++ | @ravinikam (2017/07) @stkrwork (2017/07) @etherealjoy (2018/02) @martindelille (2018/03) @muttleyxd (2019/08) |
|
||||
| C# | @mandrean (2017/08) @frankyjuang (2019/09) @shibayan (2020/02) @Blackclaws (2021/03) @lucamazzanti (2021/05) |
|
||||
| Clojure | |
|
||||
| Dart | @swipesight (2018/09) @jaumard (2018/09) @josh-burton (2019/12) @amondnet (2019/12) @sbu-WBT (2020/12) @kuhnroyal (2020/12) @agilob (2020/12) |
|
||||
| Dart | @jaumard (2018/09) @josh-burton (2019/12) @amondnet (2019/12) @sbu-WBT (2020/12) @kuhnroyal (2020/12) @agilob (2020/12) |
|
||||
| Eiffel | @jvelilla (2017/09) |
|
||||
| Elixir | @mrmstn (2018/12) |
|
||||
| Elm | @eriktim (2018/09) |
|
||||
|
@ -1,7 +1,7 @@
|
||||
generatorName: java
|
||||
outputDir: samples/client/petstore/java/feign
|
||||
library: feign
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/Java
|
||||
additionalProperties:
|
||||
booleanGetterPrefix: is
|
||||
|
@ -1,11 +0,0 @@
|
||||
generatorName: java
|
||||
outputDir: samples/openapi3/client/petstore/java/native
|
||||
library: native
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/Java
|
||||
additionalProperties:
|
||||
artifactId: petstore-openapi3-native
|
||||
hideGenerationTimestamp: true
|
||||
serverPort: "8082"
|
||||
useOneOfDiscriminatorLookup: true
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
@ -3,6 +3,7 @@ outputDir: samples/client/petstore/java/resttemplate-withXml
|
||||
library: resttemplate
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
additionalProperties:
|
||||
java8: true
|
||||
withXml: "true"
|
||||
artifactId: petstore-resttemplate-withxml
|
||||
hideGenerationTimestamp: "true"
|
||||
|
@ -5,3 +5,4 @@ inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-e
|
||||
additionalProperties:
|
||||
artifactId: petstore-resttemplate
|
||||
hideGenerationTimestamp: "true"
|
||||
java8: true
|
||||
|
@ -1,7 +1,7 @@
|
||||
generatorName: java
|
||||
outputDir: samples/client/petstore/java/webclient
|
||||
library: webclient
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
additionalProperties:
|
||||
artifactId: petstore-webclient
|
||||
hideGenerationTimestamp: "true"
|
||||
|
@ -0,0 +1,6 @@
|
||||
generatorName: jaxrs-cxf-client
|
||||
outputDir: samples/openapi3/client/petstore/jaxrs-cxf-client-jackson-nullable
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaJaxRS/cxf
|
||||
additionalProperties:
|
||||
jackson: "true"
|
@ -1,7 +1,7 @@
|
||||
generatorName: rust
|
||||
outputDir: samples/client/petstore/rust/hyper/petstore
|
||||
library: hyper
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/rust
|
||||
additionalProperties:
|
||||
supportAsync: "false"
|
||||
|
@ -1,7 +1,7 @@
|
||||
generatorName: rust
|
||||
outputDir: samples/client/petstore/rust/reqwest/petstore-async
|
||||
library: reqwest
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/rust
|
||||
additionalProperties:
|
||||
supportAsync: true
|
||||
|
@ -1,7 +1,7 @@
|
||||
generatorName: rust
|
||||
outputDir: samples/client/petstore/rust/reqwest/petstore
|
||||
library: reqwest
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/rust
|
||||
additionalProperties:
|
||||
supportAsync: false
|
||||
|
@ -238,7 +238,7 @@
|
||||
<junit-version>4.8.1</junit-version>
|
||||
<kotlin.version>1.5.10</kotlin.version>
|
||||
<kotlinJvmTarget>1.8</kotlinJvmTarget>
|
||||
<moshi-kotlin.version>1.8.0</moshi-kotlin.version>
|
||||
<moshi-kotlin.version>1.12.0</moshi-kotlin.version>
|
||||
<migbase64.version>2.2</migbase64.version>
|
||||
</properties>
|
||||
</project>
|
||||
|
@ -301,7 +301,7 @@ public class CodegenConfigurator {
|
||||
|
||||
public CodegenConfigurator setGitUserId(String gitUserId) {
|
||||
if (StringUtils.isNotEmpty(gitUserId)) {
|
||||
addAdditionalProperty(CodegenConstants.GIT_HOST, gitUserId);
|
||||
addAdditionalProperty(CodegenConstants.GIT_USER_ID, gitUserId);
|
||||
}
|
||||
generatorSettingsBuilder.withGitUserId(gitUserId);
|
||||
return this;
|
||||
|
@ -1263,6 +1263,19 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessParameter(CodegenParameter parameter) {
|
||||
super.postProcessParameter(parameter);
|
||||
|
||||
// ensure a method's parameters are marked as nullable when nullable or when nullReferences are enabled
|
||||
// this is mostly needed for reference types used as a method's parameters
|
||||
if (!parameter.required && (nullReferenceTypesFlag || nullableType.contains(parameter.dataType))) {
|
||||
parameter.dataType = parameter.dataType.endsWith("?")
|
||||
? parameter.dataType
|
||||
: parameter.dataType + "?";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessFile(File file, String fileType) {
|
||||
if (file == null) {
|
||||
|
@ -70,6 +70,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
public static final String ADDITIONAL_ENUM_TYPE_ANNOTATIONS = "additionalEnumTypeAnnotations";
|
||||
public static final String DISCRIMINATOR_CASE_SENSITIVE = "discriminatorCaseSensitive";
|
||||
public static final String OPENAPI_NULLABLE = "openApiNullable";
|
||||
public static final String JACKSON = "jackson";
|
||||
|
||||
protected String dateLibrary = "threetenbp";
|
||||
protected boolean supportAsync = false;
|
||||
@ -525,6 +526,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
importMapping.put("JsonValue", "com.fasterxml.jackson.annotation.JsonValue");
|
||||
importMapping.put("JsonIgnore", "com.fasterxml.jackson.annotation.JsonIgnore");
|
||||
importMapping.put("JsonInclude", "com.fasterxml.jackson.annotation.JsonInclude");
|
||||
importMapping.put("JsonNullable", "org.openapitools.jackson.nullable.JsonNullable");
|
||||
importMapping.put("SerializedName", "com.google.gson.annotations.SerializedName");
|
||||
importMapping.put("TypeAdapter", "com.google.gson.TypeAdapter");
|
||||
importMapping.put("JsonAdapter", "com.google.gson.annotations.JsonAdapter");
|
||||
@ -1174,7 +1176,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
if (codegenModel.description != null) {
|
||||
codegenModel.imports.add("ApiModel");
|
||||
}
|
||||
if (codegenModel.discriminator != null && additionalProperties.containsKey("jackson")) {
|
||||
if (codegenModel.discriminator != null && additionalProperties.containsKey(JACKSON)) {
|
||||
codegenModel.imports.add("JsonSubTypes");
|
||||
codegenModel.imports.add("JsonTypeInfo");
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen
|
||||
|
||||
additionalProperties.put("title", title);
|
||||
// java inflector uses the jackson lib
|
||||
additionalProperties.put("jackson", "true");
|
||||
additionalProperties.put(JACKSON, "true");
|
||||
|
||||
cliOptions.add(new CliOption(CodegenConstants.IMPL_FOLDER, CodegenConstants.IMPL_FOLDER_DESC).defaultValue(implFolder));
|
||||
cliOptions.add(new CliOption("title", "a title describing the application").defaultValue(title));
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.media.StringSchema;
|
||||
@ -928,6 +929,24 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
if (p.getDefault() != null) {
|
||||
return "URI.create('" + p.getDefault() + "')";
|
||||
}
|
||||
} else if (ModelUtils.isArraySchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
String arrInstantiationType = ModelUtils.isSet(p) ? "set" : "arrayList";
|
||||
|
||||
ArrayNode _default = (ArrayNode) p.getDefault();
|
||||
if (_default.isEmpty()) {
|
||||
return arrInstantiationType + "Of()";
|
||||
}
|
||||
|
||||
StringBuilder defaultContent = new StringBuilder();
|
||||
Schema<?> itemsSchema = getSchemaItems((ArraySchema) schema);
|
||||
_default.elements().forEachRemaining((element) -> {
|
||||
itemsSchema.setDefault(element.asText());
|
||||
defaultContent.append(toDefaultValue(itemsSchema)).append(",");
|
||||
});
|
||||
defaultContent.deleteCharAt(defaultContent.length()-1); // remove trailing comma
|
||||
return arrInstantiationType + "Of(" + defaultContent + ")";
|
||||
}
|
||||
} else if (ModelUtils.isStringSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
String _default = (String) p.getDefault();
|
||||
|
@ -29,6 +29,7 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.Matcher;
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
@ -190,6 +191,18 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
this.setParameterNamingConvention((String) additionalProperties.get(VARIABLE_NAMING_CONVENTION));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.GIT_USER_ID)) {
|
||||
this.setGitUserId((String) additionalProperties.get(CodegenConstants.GIT_USER_ID));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.GIT_REPO_ID)) {
|
||||
this.setGitRepoId((String) additionalProperties.get(CodegenConstants.GIT_REPO_ID));
|
||||
}
|
||||
|
||||
if (!this.getComposerPackageName().isEmpty()) {
|
||||
additionalProperties.put("composerPackageName", this.getComposerPackageName());
|
||||
}
|
||||
|
||||
additionalProperties.put("escapedInvokerPackage", invokerPackage.replace("\\", "\\\\"));
|
||||
|
||||
// make api and model src path available in mustache template
|
||||
@ -758,4 +771,22 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Composer package name based on GIT_USER_ID and GIT_REPO_ID.
|
||||
*
|
||||
* @return package name or empty string on fail
|
||||
*/
|
||||
public String getComposerPackageName() {
|
||||
String packageName = this.getGitUserId() + "/" + this.getGitRepoId();
|
||||
if (
|
||||
packageName.contentEquals("/")
|
||||
|| packageName.contentEquals("null/null")
|
||||
|| !Pattern.matches("^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$", packageName)
|
||||
) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return packageName;
|
||||
}
|
||||
}
|
||||
|
@ -536,33 +536,6 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
return this.modelPropertyNaming;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
|
||||
super.postProcessOperationsWithModels(objs, allModels);
|
||||
if (objs != null) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
for (CodegenOperation operation : ops) {
|
||||
if (operation.returnType != null) {
|
||||
operation.returnContainer = operation.returnType;
|
||||
if (this.returnICollection && (
|
||||
operation.returnType.startsWith("List") ||
|
||||
operation.returnType.startsWith("Collection"))) {
|
||||
// NOTE: ICollection works for both List<T> and Collection<T>
|
||||
int genericStart = operation.returnType.indexOf("<");
|
||||
if (genericStart > 0) {
|
||||
operation.returnType = "ICollection" + operation.returnType.substring(genericStart);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
|
@ -468,33 +468,6 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
super.postProcessModelProperty(model, property);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
|
||||
super.postProcessOperationsWithModels(objs, allModels);
|
||||
if (objs != null) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
for (CodegenOperation operation : ops) {
|
||||
if (operation.returnType != null) {
|
||||
operation.returnContainer = operation.returnType;
|
||||
if (this.returnICollection && (
|
||||
operation.returnType.startsWith("List") ||
|
||||
operation.returnType.startsWith("Collection"))) {
|
||||
// NOTE: ICollection works for both List<T> and Collection<T>
|
||||
int genericStart = operation.returnType.indexOf("<");
|
||||
if (genericStart > 0) {
|
||||
operation.returnType = "ICollection" + operation.returnType.substring(genericStart);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessParameter(CodegenParameter parameter) {
|
||||
postProcessPattern(parameter.pattern, parameter.vendorExtensions);
|
||||
|
@ -157,6 +157,7 @@ public class DartDioNextClientCodegen extends AbstractDartCodegen {
|
||||
final String authFolder = srcFolder + File.separator + "auth";
|
||||
supportingFiles.add(new SupportingFile("auth/api_key_auth.mustache", authFolder, "api_key_auth.dart"));
|
||||
supportingFiles.add(new SupportingFile("auth/basic_auth.mustache", authFolder, "basic_auth.dart"));
|
||||
supportingFiles.add(new SupportingFile("auth/bearer_auth.mustache", authFolder, "bearer_auth.dart"));
|
||||
supportingFiles.add(new SupportingFile("auth/oauth.mustache", authFolder, "oauth.dart"));
|
||||
supportingFiles.add(new SupportingFile("auth/auth.mustache", authFolder, "auth.dart"));
|
||||
|
||||
@ -322,6 +323,18 @@ public class DartDioNextClientCodegen extends AbstractDartCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
// the MultipartFile handling above changes the type of some parameters from
|
||||
// `UInt8List`, the default for files, to `MultipartFile`.
|
||||
//
|
||||
// The following block removes the required import for Uint8List if it is no
|
||||
// longer in use.
|
||||
if (op.allParams.stream().noneMatch(param -> param.dataType.equals("Uint8List"))
|
||||
&& op.responses.stream().filter(response -> response.dataType != null)
|
||||
.noneMatch(response -> response.dataType.equals("Uint8List"))) {
|
||||
// Remove unused imports after processing
|
||||
op.imports.remove("Uint8List");
|
||||
}
|
||||
|
||||
for (CodegenParameter param : op.bodyParams) {
|
||||
if (param.isContainer) {
|
||||
final Map<String, Object> serializer = new HashMap<>();
|
||||
@ -333,11 +346,6 @@ public class DartDioNextClientCodegen extends AbstractDartCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
if (op.allParams.stream().noneMatch(param -> param.dataType.equals("Uint8List"))) {
|
||||
// Remove unused imports after processing
|
||||
op.imports.remove("Uint8List");
|
||||
}
|
||||
|
||||
resultImports.addAll(rewriteImports(op.imports, false));
|
||||
if (op.getHasFormParams() || op.getHasQueryParams()) {
|
||||
resultImports.add("package:" + pubName + "/src/api_util.dart");
|
||||
|
@ -879,16 +879,9 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
private void processReturnType(CodegenOperation op) {
|
||||
String returnType = op.returnType;
|
||||
if (returnType == null || returnType.equals("null")) {
|
||||
if (op.hasProduces) {
|
||||
returnType = "res";
|
||||
op.vendorExtensions.put(VENDOR_EXTENSION_X_HAS_UNKNOWN_RETURN, true);
|
||||
} else {
|
||||
returnType = "NoContent";
|
||||
if (!op.vendorExtensions.containsKey(VENDOR_EXTENSION_X_INLINE_ACCEPT)) {
|
||||
SetNoContent(op, VENDOR_EXTENSION_X_INLINE_ACCEPT);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (returnType.contains(" ")) {
|
||||
returnType = "(" + returnType + ")";
|
||||
}
|
||||
|
@ -49,6 +49,8 @@ public class JavaCXFClientCodegen extends AbstractJavaCodegen
|
||||
|
||||
protected boolean useLoggingFeatureForTests = false;
|
||||
|
||||
private boolean useJackson = false;
|
||||
|
||||
public JavaCXFClientCodegen() {
|
||||
super();
|
||||
|
||||
@ -108,6 +110,10 @@ public class JavaCXFClientCodegen extends AbstractJavaCodegen
|
||||
this.setUseLoggingFeatureForTests(convertPropertyToBooleanAndWriteBack(USE_LOGGING_FEATURE_FOR_TESTS));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(JACKSON)) {
|
||||
useJackson = convertPropertyToBooleanAndWriteBack(JACKSON);
|
||||
}
|
||||
|
||||
supportingFiles.clear(); // Don't need extra files provided by AbstractJAX-RS & Java Codegen
|
||||
|
||||
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")
|
||||
@ -139,12 +145,22 @@ public class JavaCXFClientCodegen extends AbstractJavaCodegen
|
||||
model.imports.remove("JsonSerialize");
|
||||
model.imports.remove("ToStringSerializer");
|
||||
|
||||
//Add imports for Jackson when model has inner enum
|
||||
if (additionalProperties.containsKey("jackson")) {
|
||||
|
||||
if (useJackson) {
|
||||
//Add jackson imports when model has inner enum
|
||||
if (Boolean.FALSE.equals(model.isEnum) && Boolean.TRUE.equals(model.hasEnums)) {
|
||||
model.imports.add("JsonCreator");
|
||||
model.imports.add("JsonValue");
|
||||
}
|
||||
|
||||
//Add JsonNullable import and mark property nullable for templating if necessary
|
||||
if (openApiNullable) {
|
||||
if (Boolean.FALSE.equals(property.required) && Boolean.TRUE.equals(property.isNullable)) {
|
||||
property.getVendorExtensions().put("x-is-jackson-optional-nullable", true);
|
||||
model.imports.add("JsonNullable");
|
||||
model.imports.add("JsonIgnore");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -195,4 +211,7 @@ public class JavaCXFClientCodegen extends AbstractJavaCodegen
|
||||
return useGenericResponse;
|
||||
}
|
||||
|
||||
public boolean isUseJackson() {
|
||||
return useJackson;
|
||||
}
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ public class JavaCXFServerCodegen extends AbstractJavaJAXRSServerCodegen
|
||||
model.imports.remove("ToStringSerializer");
|
||||
|
||||
//Add imports for Jackson when model has inner enum
|
||||
if (additionalProperties.containsKey("jackson")) {
|
||||
if (additionalProperties.containsKey(JACKSON)) {
|
||||
if (Boolean.FALSE.equals(model.isEnum) && Boolean.TRUE.equals(model.hasEnums)) {
|
||||
model.imports.add("JsonCreator");
|
||||
model.imports.add("JsonValue");
|
||||
|
@ -69,7 +69,7 @@ public class JavaInflectorServerCodegen extends AbstractJavaCodegen {
|
||||
|
||||
additionalProperties.put("title", title);
|
||||
// java inflector uses the jackson lib
|
||||
additionalProperties.put("jackson", "true");
|
||||
additionalProperties.put(JACKSON, "true");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -31,7 +31,6 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
|
||||
public static final String RETURN_RESPONSE = "returnResponse";
|
||||
public static final String GENERATE_POM = "generatePom";
|
||||
public static final String USE_SWAGGER_ANNOTATIONS = "useSwaggerAnnotations";
|
||||
public static final String JACKSON = "jackson";
|
||||
public static final String OPEN_API_SPEC_FILE_LOCATION = "openApiSpecFileLocation";
|
||||
public static final String GENERATE_BUILDERS = "generateBuilders";
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class JavaPKMSTServerCodegen extends AbstractJavaCodegen {
|
||||
updateOption(CodegenConstants.API_PACKAGE, apiPackage);
|
||||
updateOption(CodegenConstants.MODEL_PACKAGE, modelPackage);
|
||||
|
||||
additionalProperties.put("jackson", "true");
|
||||
additionalProperties.put(JACKSON, "true");
|
||||
|
||||
this.cliOptions.add(new CliOption("basePackage", "base package for java source code"));
|
||||
this.cliOptions.add(new CliOption("serviceName", "Service Name"));
|
||||
@ -422,7 +422,7 @@ public class JavaPKMSTServerCodegen extends AbstractJavaCodegen {
|
||||
}
|
||||
} else { // enum class
|
||||
// Needed imports for Jackson's JsonCreator
|
||||
if (this.additionalProperties.containsKey("jackson")) {
|
||||
if (this.additionalProperties.containsKey(JACKSON)) {
|
||||
model.imports.add("JsonCreator");
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ public class JavaPlayFrameworkCodegen extends AbstractJavaCodegen implements Bea
|
||||
updateOption(CodegenConstants.MODEL_PACKAGE, modelPackage);
|
||||
|
||||
additionalProperties.put("java8", true);
|
||||
additionalProperties.put("jackson", "true");
|
||||
additionalProperties.put(JACKSON, "true");
|
||||
|
||||
cliOptions.add(new CliOption(TITLE, "server title name or client service name").defaultValue(title));
|
||||
cliOptions.add(new CliOption(CONFIG_PACKAGE, "configuration package for generated code").defaultValue(getConfigPackage()));
|
||||
|
@ -574,6 +574,8 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
|
||||
public String toEnumValue(String value, String datatype) {
|
||||
if ("int".equals(datatype) || "float".equals(datatype)) {
|
||||
return value;
|
||||
} else if ("bool".equals(datatype)) {
|
||||
return value.substring(0, 1).toUpperCase(Locale.ROOT) + value.substring(1);
|
||||
} else {
|
||||
return ensureQuotes(value);
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
apiTestTemplateFiles.clear(); // TODO: add test template
|
||||
|
||||
// spring uses the jackson lib
|
||||
additionalProperties.put("jackson", "true");
|
||||
additionalProperties.put(JACKSON, "true");
|
||||
additionalProperties.put("openbrace", OPEN_BRACE);
|
||||
additionalProperties.put("closebrace", CLOSE_BRACE);
|
||||
|
||||
@ -829,7 +829,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
}
|
||||
} else { // enum class
|
||||
//Needed imports for Jackson's JsonCreator
|
||||
if (additionalProperties.containsKey("jackson")) {
|
||||
if (additionalProperties.containsKey(JACKSON)) {
|
||||
model.imports.add("JsonCreator");
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ end:
|
||||
//
|
||||
{{/notes}}
|
||||
{{#returnType}}{{#returnTypeIsPrimitive}}{{#returnSimpleType}}{{{.}}}*{{/returnSimpleType}}{{^returnSimpleType}}{{#isArray}}{{{.}}}_t*{{/isArray}}{{#isMap}}{{{.}}}{{/isMap}}{{/returnSimpleType}}{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}{{{.}}}_t*{{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void{{/returnType}}
|
||||
{{{classname}}}_{{{operationId}}}(apiClient_t *apiClient{{#allParams}}, {{#isPrimitiveType}}{{#isNumber}}{{{dataType}}}{{/isNumber}}{{#isLong}}{{{dataType}}}{{/isLong}}{{#isInteger}}{{{dataType}}}{{/isInteger}}{{#isDouble}}{{{dataType}}}{{/isDouble}}{{#isFloat}}{{{dataType}}}{{/isFloat}}{{#isBoolean}}{{dataType}}{{/isBoolean}}{{#isEnum}}{{#isString}}{{projectName}}_{{operationId}}_{{baseName}}_e{{/isString}}{{/isEnum}}{{^isEnum}}{{#isString}}{{{dataType}}} *{{/isString}}{{/isEnum}}{{#isByteArray}}{{{dataType}}}{{/isByteArray}}{{#isDate}}{{{dataType}}}{{/isDate}}{{#isDateTime}}{{{dataType}}}{{/isDateTime}}{{#isFile}}{{{dataType}}}{{/isFile}}{{#isFreeFormObject}}{{dataType}}_t *{{/isFreeFormObject}}{{/isPrimitiveType}}{{^isArray}}{{^isPrimitiveType}}{{#isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{^isEnum}}{{{dataType}}}_t *{{/isEnum}}{{/isModel}}{{^isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{/isModel}}{{#isUuid}}{{dataType}} *{{/isUuid}}{{#isEmail}}{{dataType}}{{/isEmail}}{{/isPrimitiveType}}{{/isArray}}{{#isContainer}}{{#isArray}}{{dataType}}_t *{{/isArray}}{{#isMap}}{{dataType}}{{/isMap}}{{/isContainer}} {{{paramName}}} {{/allParams}})
|
||||
{{{classname}}}_{{{operationId}}}(apiClient_t *apiClient{{#allParams}}, {{#isPrimitiveType}}{{#isNumber}}{{{dataType}}}{{/isNumber}}{{#isLong}}{{{dataType}}}{{/isLong}}{{#isInteger}}{{{dataType}}}{{/isInteger}}{{#isDouble}}{{{dataType}}}{{/isDouble}}{{#isFloat}}{{{dataType}}}{{/isFloat}}{{#isBoolean}}{{dataType}}{{/isBoolean}}{{#isEnum}}{{#isString}}{{projectName}}_{{operationId}}_{{baseName}}_e{{/isString}}{{/isEnum}}{{^isEnum}}{{#isString}}{{{dataType}}} *{{/isString}}{{/isEnum}}{{#isByteArray}}{{{dataType}}} *{{/isByteArray}}{{#isDate}}{{{dataType}}}{{/isDate}}{{#isDateTime}}{{{dataType}}}{{/isDateTime}}{{#isFile}}{{{dataType}}}{{/isFile}}{{#isFreeFormObject}}{{dataType}}_t *{{/isFreeFormObject}}{{/isPrimitiveType}}{{^isArray}}{{^isPrimitiveType}}{{#isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{^isEnum}}{{{dataType}}}_t *{{/isEnum}}{{/isModel}}{{^isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{/isModel}}{{#isUuid}}{{dataType}} *{{/isUuid}}{{#isEmail}}{{dataType}}{{/isEmail}}{{/isPrimitiveType}}{{/isArray}}{{#isContainer}}{{#isArray}}{{dataType}}_t *{{/isArray}}{{#isMap}}{{dataType}}{{/isMap}}{{/isContainer}} {{{paramName}}} {{/allParams}})
|
||||
{
|
||||
list_t *localVarQueryParameters = {{#hasQueryParams}}list_create();{{/hasQueryParams}}{{^hasQueryParams}}NULL;{{/hasQueryParams}}
|
||||
list_t *localVarHeaderParameters = {{#hasHeaderParams}}list_create();{{/hasHeaderParams}}{{^hasHeaderParams}}NULL;{{/hasHeaderParams}}
|
||||
@ -194,7 +194,7 @@ end:
|
||||
|
||||
// header parameters
|
||||
char *keyHeader_{{{paramName}}} = NULL;
|
||||
{{#isPrimitiveType}}{{#isNumber}}{{{dataType}}}{{/isNumber}}{{#isLong}}{{{dataType}}}{{/isLong}}{{#isInteger}}{{{dataType}}}{{/isInteger}}{{#isDouble}}{{{dataType}}}{{/isDouble}}{{#isFloat}}{{{dataType}}}{{/isFloat}}{{#isBoolean}}{{dataType}}{{/isBoolean}}{{#isEnum}}{{#isString}}{{projectName}}_{{operationId}}_{{baseName}}_e{{/isString}}{{/isEnum}}{{^isEnum}}{{#isString}}{{{dataType}}} *{{/isString}}{{/isEnum}}{{#isByteArray}}{{{dataType}}}{{/isByteArray}}{{#isDate}}{{{dataType}}}{{/isDate}}{{#isDateTime}}{{{dataType}}}{{/isDateTime}}{{#isFile}}{{{dataType}}}{{/isFile}}{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{^isEnum}}{{{dataType}}}_t *{{/isEnum}}{{/isModel}}{{^isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{/isModel}}{{#isUuid}}{{dataType}} *{{/isUuid}}{{#isEmail}}{{dataType}}{{/isEmail}}{{/isPrimitiveType}} valueHeader_{{{paramName}}} = 0;
|
||||
{{#isPrimitiveType}}{{#isNumber}}{{{dataType}}}{{/isNumber}}{{#isLong}}{{{dataType}}}{{/isLong}}{{#isInteger}}{{{dataType}}}{{/isInteger}}{{#isDouble}}{{{dataType}}}{{/isDouble}}{{#isFloat}}{{{dataType}}}{{/isFloat}}{{#isBoolean}}{{dataType}}{{/isBoolean}}{{#isEnum}}{{#isString}}{{projectName}}_{{operationId}}_{{baseName}}_e{{/isString}}{{/isEnum}}{{^isEnum}}{{#isString}}{{{dataType}}} *{{/isString}}{{/isEnum}}{{#isByteArray}}{{{dataType}}} *{{/isByteArray}}{{#isDate}}{{{dataType}}}{{/isDate}}{{#isDateTime}}{{{dataType}}}{{/isDateTime}}{{#isFile}}{{{dataType}}}{{/isFile}}{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{^isEnum}}{{{dataType}}}_t *{{/isEnum}}{{/isModel}}{{^isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{/isModel}}{{#isUuid}}{{dataType}} *{{/isUuid}}{{#isEmail}}{{dataType}}{{/isEmail}}{{/isPrimitiveType}} valueHeader_{{{paramName}}} = 0;
|
||||
keyValuePair_t *keyPairHeader_{{paramName}} = 0;
|
||||
if ({{paramName}}) {
|
||||
keyHeader_{{{paramName}}} = strdup("{{{baseName}}}");
|
||||
@ -209,7 +209,7 @@ end:
|
||||
// query parameters
|
||||
{{^isArray}}
|
||||
char *keyQuery_{{{paramName}}} = NULL;
|
||||
{{#isPrimitiveType}}{{#isNumber}}{{{dataType}}}{{/isNumber}}{{#isLong}}{{{dataType}}}{{/isLong}}{{#isInteger}}char *{{/isInteger}}{{#isDouble}}{{{dataType}}}{{/isDouble}}{{#isFloat}}{{{dataType}}}{{/isFloat}}{{#isBoolean}}char *{{/isBoolean}}{{#isEnum}}{{#isString}}{{projectName}}_{{operationId}}_{{baseName}}_e{{/isString}}{{/isEnum}}{{^isEnum}}{{#isString}}{{{dataType}}} *{{/isString}}{{/isEnum}}{{#isByteArray}}{{{dataType}}}{{/isByteArray}}{{#isDate}}{{{dataType}}}{{/isDate}}{{#isDateTime}}{{{dataType}}}{{/isDateTime}}{{#isFile}}{{{dataType}}}{{/isFile}}{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{^isEnum}}{{{dataType}}}_t *{{/isEnum}}{{/isModel}}{{^isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{/isModel}}{{#isUuid}}{{dataType}} *{{/isUuid}}{{#isEmail}}{{dataType}}{{/isEmail}}{{/isPrimitiveType}} valueQuery_{{{paramName}}} {{#isString}}{{^isEnum}}= NULL{{/isEnum}}{{/isString}}{{#isInteger}}= NULL{{/isInteger}}{{#isBoolean}}= NULL{{/isBoolean}};
|
||||
{{#isPrimitiveType}}{{#isNumber}}{{{dataType}}}{{/isNumber}}{{#isLong}}{{{dataType}}}{{/isLong}}{{#isInteger}}char *{{/isInteger}}{{#isDouble}}{{{dataType}}}{{/isDouble}}{{#isFloat}}{{{dataType}}}{{/isFloat}}{{#isBoolean}}char *{{/isBoolean}}{{#isEnum}}{{#isString}}{{projectName}}_{{operationId}}_{{baseName}}_e{{/isString}}{{/isEnum}}{{^isEnum}}{{#isString}}{{{dataType}}} *{{/isString}}{{/isEnum}}{{#isByteArray}}{{{dataType}}} *{{/isByteArray}}{{#isDate}}{{{dataType}}}{{/isDate}}{{#isDateTime}}{{{dataType}}}{{/isDateTime}}{{#isFile}}{{{dataType}}}{{/isFile}}{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{^isEnum}}{{{dataType}}}_t *{{/isEnum}}{{/isModel}}{{^isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{/isModel}}{{#isUuid}}{{dataType}} *{{/isUuid}}{{#isEmail}}{{dataType}}{{/isEmail}}{{/isPrimitiveType}} valueQuery_{{{paramName}}} {{#isString}}{{^isEnum}}= NULL{{/isEnum}}{{/isString}}{{#isInteger}}= NULL{{/isInteger}}{{#isBoolean}}= NULL{{/isBoolean}};
|
||||
keyValuePair_t *keyPairQuery_{{paramName}} = 0;
|
||||
{{/isArray}}
|
||||
if ({{paramName}})
|
||||
@ -248,7 +248,7 @@ end:
|
||||
{{/isFile}}
|
||||
{{^isFile}}
|
||||
char *keyForm_{{paramName}} = NULL;
|
||||
{{#isPrimitiveType}}{{#isNumber}}{{{dataType}}}{{/isNumber}}{{#isLong}}{{{dataType}}}{{/isLong}}{{#isInteger}}{{{dataType}}}{{/isInteger}}{{#isDouble}}{{{dataType}}}{{/isDouble}}{{#isFloat}}{{{dataType}}}{{/isFloat}}{{#isBoolean}}{{dataType}}{{/isBoolean}}{{#isEnum}}{{#isString}}{{projectName}}_{{operationId}}_{{baseName}}_e{{/isString}}{{/isEnum}}{{^isEnum}}{{#isString}}{{{dataType}}} *{{/isString}}{{/isEnum}}{{#isByteArray}}{{{dataType}}}{{/isByteArray}}{{#isDate}}{{{dataType}}}{{/isDate}}{{#isDateTime}}{{{dataType}}}{{/isDateTime}}{{#isFile}}{{{dataType}}}{{/isFile}}{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{^isEnum}}{{{dataType}}}_t *{{/isEnum}}{{/isModel}}{{^isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{/isModel}}{{#isUuid}}{{dataType}} *{{/isUuid}}{{#isEmail}}{{dataType}}{{/isEmail}}{{/isPrimitiveType}} valueForm_{{paramName}} = 0;
|
||||
{{#isPrimitiveType}}{{#isNumber}}{{{dataType}}}{{/isNumber}}{{#isLong}}{{{dataType}}}{{/isLong}}{{#isInteger}}{{{dataType}}}{{/isInteger}}{{#isDouble}}{{{dataType}}}{{/isDouble}}{{#isFloat}}{{{dataType}}}{{/isFloat}}{{#isBoolean}}{{dataType}}{{/isBoolean}}{{#isEnum}}{{#isString}}{{projectName}}_{{operationId}}_{{baseName}}_e{{/isString}}{{/isEnum}}{{^isEnum}}{{#isString}}{{{dataType}}} *{{/isString}}{{/isEnum}}{{#isByteArray}}{{{dataType}}} *{{/isByteArray}}{{#isDate}}{{{dataType}}}{{/isDate}}{{#isDateTime}}{{{dataType}}}{{/isDateTime}}{{#isFile}}{{{dataType}}}{{/isFile}}{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{^isEnum}}{{{dataType}}}_t *{{/isEnum}}{{/isModel}}{{^isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{/isModel}}{{#isUuid}}{{dataType}} *{{/isUuid}}{{#isEmail}}{{dataType}}{{/isEmail}}{{/isPrimitiveType}} valueForm_{{paramName}} = 0;
|
||||
keyValuePair_t *keyPairForm_{{paramName}} = 0;
|
||||
{{/isFile}}
|
||||
if ({{paramName}} != NULL)
|
||||
|
@ -33,7 +33,7 @@ typedef enum { {{projectName}}_{{operationId}}_{{enumName}}_NULL = 0{{#enumVars
|
||||
//
|
||||
{{/notes}}
|
||||
{{#returnType}}{{#returnTypeIsPrimitive}}{{#returnSimpleType}}{{{.}}}*{{/returnSimpleType}}{{^returnSimpleType}}{{#isArray}}{{{.}}}_t*{{/isArray}}{{#isMap}}{{{.}}}{{/isMap}}{{/returnSimpleType}}{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}{{{.}}}_t*{{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void{{/returnType}}
|
||||
{{{classname}}}_{{{operationId}}}(apiClient_t *apiClient{{#allParams}}, {{#isPrimitiveType}}{{#isNumber}}{{{dataType}}}{{/isNumber}}{{#isLong}}{{{dataType}}}{{/isLong}}{{#isInteger}}{{{dataType}}}{{/isInteger}}{{#isDouble}}{{{dataType}}}{{/isDouble}}{{#isFloat}}{{{dataType}}}{{/isFloat}}{{#isBoolean}}{{dataType}}{{/isBoolean}}{{#isEnum}}{{#isString}}{{projectName}}_{{operationId}}_{{baseName}}_e{{/isString}}{{/isEnum}}{{^isEnum}}{{#isString}}{{{dataType}}} *{{/isString}}{{/isEnum}}{{#isByteArray}}{{{dataType}}}{{/isByteArray}}{{#isDate}}{{{dataType}}}{{/isDate}}{{#isDateTime}}{{{dataType}}}{{/isDateTime}}{{#isFile}}{{{dataType}}}{{/isFile}}{{#isFreeFormObject}}{{dataType}}_t *{{/isFreeFormObject}}{{/isPrimitiveType}}{{^isArray}}{{^isPrimitiveType}}{{#isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{^isEnum}}{{{dataType}}}_t *{{/isEnum}}{{/isModel}}{{^isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{/isModel}}{{#isUuid}}{{dataType}} *{{/isUuid}}{{#isEmail}}{{dataType}}{{/isEmail}}{{/isPrimitiveType}}{{/isArray}}{{#isContainer}}{{#isArray}}{{dataType}}_t *{{/isArray}}{{#isMap}}{{dataType}}{{/isMap}}{{/isContainer}} {{{paramName}}} {{/allParams}});
|
||||
{{{classname}}}_{{{operationId}}}(apiClient_t *apiClient{{#allParams}}, {{#isPrimitiveType}}{{#isNumber}}{{{dataType}}}{{/isNumber}}{{#isLong}}{{{dataType}}}{{/isLong}}{{#isInteger}}{{{dataType}}}{{/isInteger}}{{#isDouble}}{{{dataType}}}{{/isDouble}}{{#isFloat}}{{{dataType}}}{{/isFloat}}{{#isBoolean}}{{dataType}}{{/isBoolean}}{{#isEnum}}{{#isString}}{{projectName}}_{{operationId}}_{{baseName}}_e{{/isString}}{{/isEnum}}{{^isEnum}}{{#isString}}{{{dataType}}} *{{/isString}}{{/isEnum}}{{#isByteArray}}{{{dataType}}} *{{/isByteArray}}{{#isDate}}{{{dataType}}}{{/isDate}}{{#isDateTime}}{{{dataType}}}{{/isDateTime}}{{#isFile}}{{{dataType}}}{{/isFile}}{{#isFreeFormObject}}{{dataType}}_t *{{/isFreeFormObject}}{{/isPrimitiveType}}{{^isArray}}{{^isPrimitiveType}}{{#isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{^isEnum}}{{{dataType}}}_t *{{/isEnum}}{{/isModel}}{{^isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{/isModel}}{{#isUuid}}{{dataType}} *{{/isUuid}}{{#isEmail}}{{dataType}}{{/isEmail}}{{/isPrimitiveType}}{{/isArray}}{{#isContainer}}{{#isArray}}{{dataType}}_t *{{/isArray}}{{#isMap}}{{dataType}}{{/isMap}}{{/isContainer}} {{{paramName}}} {{/allParams}});
|
||||
|
||||
|
||||
{{/operation}}
|
||||
|
@ -20,7 +20,7 @@ Method | HTTP request | Description
|
||||
// {{{notes}}}
|
||||
//
|
||||
{{/notes}}
|
||||
{{#returnType}}{{#returnTypeIsPrimitive}}{{#returnSimpleType}}{{{.}}}*{{/returnSimpleType}}{{^returnSimpleType}}{{#isArray}}{{{.}}}_t*{{/isArray}}{{#isMap}}{{{.}}}{{/isMap}}{{/returnSimpleType}}{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}{{{.}}}_t*{{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void{{/returnType}} {{{classname}}}_{{{operationId}}}(apiClient_t *apiClient{{#allParams}}, {{#isPrimitiveType}}{{#isNumber}}{{{dataType}}}{{/isNumber}}{{#isLong}}{{{dataType}}}{{/isLong}}{{#isInteger}}{{{dataType}}}{{/isInteger}}{{#isDouble}}{{{dataType}}}{{/isDouble}}{{#isFloat}}{{{dataType}}}{{/isFloat}}{{#isBoolean}}{{dataType}}{{/isBoolean}}{{#isEnum}}{{#isString}}{{projectName}}_{{operationId}}_{{baseName}}_e{{/isString}}{{/isEnum}}{{^isEnum}}{{#isString}}{{{dataType}}} *{{/isString}}{{/isEnum}}{{#isByteArray}}{{{dataType}}}{{/isByteArray}}{{#isDate}}{{{dataType}}}{{/isDate}}{{#isDateTime}}{{{dataType}}}{{/isDateTime}}{{#isFile}}{{{dataType}}}{{/isFile}}{{#isFreeFormObject}}{{dataType}}_t *{{/isFreeFormObject}}{{/isPrimitiveType}}{{^isArray}}{{^isPrimitiveType}}{{#isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{^isEnum}}{{{dataType}}}_t *{{/isEnum}}{{/isModel}}{{^isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{/isModel}}{{#isUuid}}{{dataType}} *{{/isUuid}}{{#isEmail}}{{dataType}}{{/isEmail}}{{/isPrimitiveType}}{{/isArray}}{{#isContainer}}{{#isArray}}{{dataType}}_t *{{/isArray}}{{#isMap}}{{dataType}}{{/isMap}}{{/isContainer}} {{{paramName}}}{{/allParams}});
|
||||
{{#returnType}}{{#returnTypeIsPrimitive}}{{#returnSimpleType}}{{{.}}}*{{/returnSimpleType}}{{^returnSimpleType}}{{#isArray}}{{{.}}}_t*{{/isArray}}{{#isMap}}{{{.}}}{{/isMap}}{{/returnSimpleType}}{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}{{{.}}}_t*{{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void{{/returnType}} {{{classname}}}_{{{operationId}}}(apiClient_t *apiClient{{#allParams}}, {{#isPrimitiveType}}{{#isNumber}}{{{dataType}}}{{/isNumber}}{{#isLong}}{{{dataType}}}{{/isLong}}{{#isInteger}}{{{dataType}}}{{/isInteger}}{{#isDouble}}{{{dataType}}}{{/isDouble}}{{#isFloat}}{{{dataType}}}{{/isFloat}}{{#isBoolean}}{{dataType}}{{/isBoolean}}{{#isEnum}}{{#isString}}{{projectName}}_{{operationId}}_{{baseName}}_e{{/isString}}{{/isEnum}}{{^isEnum}}{{#isString}}{{{dataType}}} *{{/isString}}{{/isEnum}}{{#isByteArray}}{{{dataType}}} *{{/isByteArray}}{{#isDate}}{{{dataType}}}{{/isDate}}{{#isDateTime}}{{{dataType}}}{{/isDateTime}}{{#isFile}}{{{dataType}}}{{/isFile}}{{#isFreeFormObject}}{{dataType}}_t *{{/isFreeFormObject}}{{/isPrimitiveType}}{{^isArray}}{{^isPrimitiveType}}{{#isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{^isEnum}}{{{dataType}}}_t *{{/isEnum}}{{/isModel}}{{^isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{/isModel}}{{#isUuid}}{{dataType}} *{{/isUuid}}{{#isEmail}}{{dataType}}{{/isEmail}}{{/isPrimitiveType}}{{/isArray}}{{#isContainer}}{{#isArray}}{{dataType}}_t *{{/isArray}}{{#isMap}}{{dataType}}{{/isMap}}{{/isContainer}} {{{paramName}}}{{/allParams}});
|
||||
```
|
||||
|
||||
### Parameters
|
||||
@ -28,7 +28,7 @@ Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**apiClient** | **apiClient_t \*** | context containing the client configuration |
|
||||
{{#allParams}}
|
||||
**{{paramName}}** | {{#isPrimitiveType}}{{#isNumber}}**{{{dataType}}}**{{/isNumber}}{{#isLong}}**{{{dataType}}}**{{/isLong}}{{#isInteger}}**{{{dataType}}}**{{/isInteger}}{{#isDouble}}**{{{dataType}}}**{{/isDouble}}{{#isFloat}}**{{{dataType}}}**{{/isFloat}}{{#isBoolean}}**{{dataType}}**{{/isBoolean}}{{#isEnum}}{{#isString}}**{{projectName}}_{{operationId}}_{{baseName}}_e**{{/isString}}{{/isEnum}}{{^isEnum}}{{#isString}}**{{{dataType}}} \***{{/isString}}{{/isEnum}}{{#isByteArray}}**{{{dataType}}}**{{/isByteArray}}{{#isDate}}**{{{dataType}}}**{{/isDate}}{{#isDateTime}}**{{{dataType}}}**{{/isDateTime}}{{#isFile}}**{{{dataType}}}**{{/isFile}}{{#isFreeFormObject}}**[{{dataType}}_t]({{baseType}}.md) \***{{/isFreeFormObject}}{{/isPrimitiveType}}{{^isArray}}{{^isPrimitiveType}}{{#isModel}}{{#isEnum}}**{{datatypeWithEnum}}_e**{{/isEnum}}{{^isEnum}}**[{{{dataType}}}_t]({{{baseType}}}.md) \***{{/isEnum}}{{/isModel}}{{^isModel}}{{#isEnum}}**{{datatypeWithEnum}}_e**{{/isEnum}}{{/isModel}}{{#isUuid}}**{{dataType}} \***{{/isUuid}}{{#isEmail}}**{{dataType}}**{{/isEmail}}{{/isPrimitiveType}}{{/isArray}}{{#isContainer}}{{#isArray}}**[{{dataType}}_t]({{baseType}}.md) \***{{/isArray}}{{#isMap}}**{{dataType}}**{{/isMap}}{{/isContainer}} | {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}
|
||||
**{{paramName}}** | {{#isPrimitiveType}}{{#isNumber}}**{{{dataType}}}**{{/isNumber}}{{#isLong}}**{{{dataType}}}**{{/isLong}}{{#isInteger}}**{{{dataType}}}**{{/isInteger}}{{#isDouble}}**{{{dataType}}}**{{/isDouble}}{{#isFloat}}**{{{dataType}}}**{{/isFloat}}{{#isBoolean}}**{{dataType}}**{{/isBoolean}}{{#isEnum}}{{#isString}}**{{projectName}}_{{operationId}}_{{baseName}}_e**{{/isString}}{{/isEnum}}{{^isEnum}}{{#isString}}**{{{dataType}}} \***{{/isString}}{{/isEnum}}{{#isByteArray}}**{{{dataType}}} \***{{/isByteArray}}{{#isDate}}**{{{dataType}}}**{{/isDate}}{{#isDateTime}}**{{{dataType}}}**{{/isDateTime}}{{#isFile}}**{{{dataType}}}**{{/isFile}}{{#isFreeFormObject}}**[{{dataType}}_t]({{baseType}}.md) \***{{/isFreeFormObject}}{{/isPrimitiveType}}{{^isArray}}{{^isPrimitiveType}}{{#isModel}}{{#isEnum}}**{{datatypeWithEnum}}_e**{{/isEnum}}{{^isEnum}}**[{{{dataType}}}_t]({{{baseType}}}.md) \***{{/isEnum}}{{/isModel}}{{^isModel}}{{#isEnum}}**{{datatypeWithEnum}}_e**{{/isEnum}}{{/isModel}}{{#isUuid}}**{{dataType}} \***{{/isUuid}}{{#isEmail}}**{{dataType}}**{{/isEmail}}{{/isPrimitiveType}}{{/isArray}}{{#isContainer}}{{#isArray}}**[{{dataType}}_t]({{baseType}}.md) \***{{/isArray}}{{#isMap}}**{{dataType}}**{{/isMap}}{{/isContainer}} | {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}
|
||||
{{/allParams}}
|
||||
|
||||
### Return type
|
||||
|
@ -164,7 +164,7 @@ char* {{name}}{{classname}}_ToString({{projectName}}_{{classVarName}}_{{enumName
|
||||
{{/isString}}
|
||||
{{/isEnum}}
|
||||
{{#isByteArray}}
|
||||
{{datatype}} {{name}}{{^-last}},{{/-last}}
|
||||
{{datatype}} *{{name}}{{^-last}},{{/-last}}
|
||||
{{/isByteArray}}
|
||||
{{#isBinary}}
|
||||
{{datatype}} {{name}}{{^-last}},{{/-last}}
|
||||
@ -347,8 +347,8 @@ cJSON *{{classname}}_convertToJSON({{classname}}_t *{{classname}}) {
|
||||
{{/isString}}
|
||||
{{/isEnum}}
|
||||
{{#isByteArray}}
|
||||
if(cJSON_AddNumberToObject(item, "{{{baseName}}}", {{{classname}}}->{{{name}}}) == NULL) {
|
||||
goto fail; //Byte
|
||||
if(cJSON_AddStringToObject(item, "{{{baseName}}}", {{{classname}}}->{{{name}}}) == NULL) {
|
||||
goto fail; //ByteArray
|
||||
}
|
||||
{{/isByteArray}}
|
||||
{{#isBinary}}
|
||||
@ -481,6 +481,12 @@ cJSON *{{classname}}_convertToJSON({{classname}}_t *{{classname}}) {
|
||||
goto fail;
|
||||
}
|
||||
{{/isString}}
|
||||
{{#isByteArray}}
|
||||
if(cJSON_AddStringToObject(localMapObject, localKeyValue->key, (char*)localKeyValue->value) == NULL)
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
{{/isByteArray}}
|
||||
{{#isNumeric}}
|
||||
if(cJSON_AddNumberToObject(localMapObject, localKeyValue->key, *(double *)localKeyValue->value) == NULL)
|
||||
{
|
||||
@ -562,9 +568,9 @@ fail:
|
||||
{{/isEnum}}
|
||||
{{#isByteArray}}
|
||||
{{^required}}if ({{{name}}}) { {{/required}}
|
||||
if(!cJSON_IsNumber({{{name}}}))
|
||||
if(!cJSON_IsString({{{name}}}))
|
||||
{
|
||||
goto end; //Byte
|
||||
goto end; //ByteArray
|
||||
}
|
||||
{{/isByteArray}}
|
||||
{{#isBinary}}
|
||||
@ -707,6 +713,13 @@ fail:
|
||||
}
|
||||
localMapKeyPair = keyValuePair_create(strdup(localMapObject->string),strdup(localMapObject->valuestring));
|
||||
{{/isString}}
|
||||
{{#isByteArray}}
|
||||
if(!cJSON_IsString(localMapObject))
|
||||
{
|
||||
goto end;
|
||||
}
|
||||
localMapKeyPair = keyValuePair_create(strdup(localMapObject->string),strdup(localMapObject->valuestring));
|
||||
{{/isByteArray}}
|
||||
{{#isBoolean}}
|
||||
if(!cJSON_IsBool(localMapObject))
|
||||
{
|
||||
@ -772,7 +785,7 @@ fail:
|
||||
{{/isString}}
|
||||
{{/isEnum}}
|
||||
{{#isByteArray}}
|
||||
{{^required}}{{{name}}} ? {{/required}}{{{name}}}->valueint{{^required}} : 0{{/required}}{{^-last}},{{/-last}}
|
||||
{{^required}}{{{name}}} ? {{/required}}strdup({{{name}}}->valuestring){{^required}} : NULL{{/required}}{{^-last}},{{/-last}}
|
||||
{{/isByteArray}}
|
||||
{{#isBinary}}
|
||||
{{^required}}{{{name}}} ? {{/required}}decoded_str_{{{name}}}{{^required}} : NULL{{/required}}{{^-last}},{{/-last}}
|
||||
|
@ -114,7 +114,7 @@ typedef struct {{classname}}_t {
|
||||
{{/isString}}
|
||||
{{/isEnum}}
|
||||
{{#isByteArray}}
|
||||
{{datatype}} {{name}}; //Byte
|
||||
{{datatype}} *{{name}}; //ByteArray
|
||||
{{/isByteArray}}
|
||||
{{#isBinary}}
|
||||
{{datatype}} {{name}}; //binary
|
||||
@ -184,7 +184,7 @@ typedef struct {{classname}}_t {
|
||||
{{/isString}}
|
||||
{{/isEnum}}
|
||||
{{#isByteArray}}
|
||||
{{datatype}} {{name}}{{^-last}},{{/-last}}
|
||||
{{datatype}} *{{name}}{{^-last}},{{/-last}}
|
||||
{{/isByteArray}}
|
||||
{{#isBinary}}
|
||||
{{datatype}} {{name}}{{^-last}},{{/-last}}
|
||||
|
@ -4,7 +4,7 @@
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
{{#vars}}
|
||||
**{{name}}** | {{^isContainer}}{{^isPrimitiveType}}{{#isModel}}{{#isEnum}}**{{projectName}}_{{classVarName}}_{{enumName}}_e**{{/isEnum}}{{^isEnum}}[**{{datatype}}_t**]({{complexType}}.md) \*{{/isEnum}}{{/isModel}}{{#isUuid}}**{{datatype}} \***{{/isUuid}}{{#isEmail}}**{{datatype}} \***{{/isEmail}}{{#isFreeFormObject}}[**{{datatype}}_t**]({{complexType}}.md) \*{{/isFreeFormObject}}{{/isPrimitiveType}}{{#isPrimitiveType}}{{#isNumeric}}**{{datatype}}**{{/isNumeric}}{{#isBoolean}}**{{datatype}}**{{/isBoolean}}{{#isEnum}}{{#isString}}**{{projectName}}_{{classVarName}}_{{enumName}}_e**{{/isString}}{{/isEnum}}{{^isEnum}}{{#isString}}**{{datatype}} \***{{/isString}}{{/isEnum}}{{#isByteArray}}**{{datatype}}**{{/isByteArray}}{{#isBinary}}**{{datatype}}**{{/isBinary}}{{#isDate}}**{{datatype}} \***{{/isDate}}{{#isDateTime}}**{{datatype}} \***{{/isDateTime}}{{/isPrimitiveType}}{{/isContainer}}{{#isContainer}}{{#isArray}}{{#isPrimitiveType}}**{{datatype}}_t \***{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}_t**]({{complexType}}.md) \*{{/isPrimitiveType}}{{/isArray}}{{#isMap}}**{{datatype}}**{{/isMap}}{{/isContainer}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
|
||||
**{{name}}** | {{^isContainer}}{{^isPrimitiveType}}{{#isModel}}{{#isEnum}}**{{projectName}}_{{classVarName}}_{{enumName}}_e**{{/isEnum}}{{^isEnum}}[**{{datatype}}_t**]({{complexType}}.md) \*{{/isEnum}}{{/isModel}}{{#isUuid}}**{{datatype}} \***{{/isUuid}}{{#isEmail}}**{{datatype}} \***{{/isEmail}}{{#isFreeFormObject}}[**{{datatype}}_t**]({{complexType}}.md) \*{{/isFreeFormObject}}{{/isPrimitiveType}}{{#isPrimitiveType}}{{#isNumeric}}**{{datatype}}**{{/isNumeric}}{{#isBoolean}}**{{datatype}}**{{/isBoolean}}{{#isEnum}}{{#isString}}**{{projectName}}_{{classVarName}}_{{enumName}}_e**{{/isString}}{{/isEnum}}{{^isEnum}}{{#isString}}**{{datatype}} \***{{/isString}}{{/isEnum}}{{#isByteArray}}**{{datatype}} \***{{/isByteArray}}{{#isBinary}}**{{datatype}}**{{/isBinary}}{{#isDate}}**{{datatype}} \***{{/isDate}}{{#isDateTime}}**{{datatype}} \***{{/isDateTime}}{{/isPrimitiveType}}{{/isContainer}}{{#isContainer}}{{#isArray}}{{#isPrimitiveType}}**{{datatype}}_t \***{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}_t**]({{complexType}}.md) \*{{/isPrimitiveType}}{{/isArray}}{{#isMap}}**{{datatype}}**{{/isMap}}{{/isContainer}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
|
||||
{{/vars}}
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -34,7 +34,13 @@ public interface {{classname}} extends ApiClient.Api {
|
||||
* {{description}}
|
||||
* @see <a href="{{url}}">{{summary}} Documentation</a>
|
||||
{{/externalDocs}}
|
||||
{{#isDeprecated}}
|
||||
* @deprecated
|
||||
{{/isDeprecated}}
|
||||
*/
|
||||
{{#isDeprecated}}
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
@RequestLine("{{httpMethod}} {{{path}}}{{#hasQueryParams}}?{{/hasQueryParams}}{{#queryParams}}{{baseName}}={{=<% %>=}}{<%paramName%>}<%={{ }}=%>{{^-last}}&{{/-last}}{{/queryParams}}")
|
||||
@Headers({
|
||||
{{#vendorExtensions.x-contentType}} "Content-Type: {{vendorExtensions.x-contentType}}",
|
||||
@ -72,7 +78,13 @@ public interface {{classname}} extends ApiClient.Api {
|
||||
* {{description}}
|
||||
* @see <a href="{{url}}">{{summary}} Documentation</a>
|
||||
{{/externalDocs}}
|
||||
{{#isDeprecated}}
|
||||
* @deprecated
|
||||
{{/isDeprecated}}
|
||||
*/
|
||||
{{#isDeprecated}}
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
@RequestLine("{{httpMethod}} {{{path}}}?{{#queryParams}}{{baseName}}={{=<% %>=}}{<%paramName%>}<%={{ }}=%>{{^-last}}&{{/-last}}{{/queryParams}}")
|
||||
@Headers({
|
||||
{{#vendorExtensions.x-contentType}} "Content-Type: {{vendorExtensions.x-contentType}}",
|
||||
|
@ -53,9 +53,14 @@ public class {{classname}} {
|
||||
* @throws IOException if an error occurs while attempting to invoke the API{{#externalDocs}}
|
||||
* {{description}}
|
||||
* @see <a href="{{url}}">{{summary}} Documentation</a>
|
||||
{{/externalDocs}}
|
||||
{{/externalDocs}}{{#isDeprecated}}
|
||||
* @deprecated
|
||||
{{/isDeprecated}}
|
||||
|
||||
**/
|
||||
{{#isDeprecated}}
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws IOException {
|
||||
{{#returnType}}HttpResponse response = {{/returnType}}{{operationId}}ForHttpResponse({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});{{#returnType}}
|
||||
TypeReference<{{{returnType}}}> typeRef = new TypeReference<{{{returnType}}}>() {};
|
||||
@ -72,15 +77,23 @@ public class {{classname}} {
|
||||
* @throws IOException if an error occurs while attempting to invoke the API{{#externalDocs}}
|
||||
* {{description}}
|
||||
* @see <a href="{{url}}">{{summary}} Documentation</a>
|
||||
{{/externalDocs}}
|
||||
{{/externalDocs}}{{#isDeprecated}}
|
||||
* @deprecated
|
||||
{{/isDeprecated}}
|
||||
|
||||
**/
|
||||
{{#isDeprecated}}
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#bodyParam}}{{^required}}{{{dataType}}} {{paramName}}, {{/required}}{{/bodyParam}}{{#requiredParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#hasRequiredParams}}, {{/hasRequiredParams}}Map<String, Object> params) throws IOException {
|
||||
{{#returnType}}HttpResponse response = {{/returnType}}{{operationId}}ForHttpResponse({{#bodyParam}}{{^required}}{{paramName}}, {{/required}}{{/bodyParam}}{{#requiredParams}}{{paramName}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#hasRequiredParams}}, {{/hasRequiredParams}}params);{{#returnType}}
|
||||
TypeReference<{{{returnType}}}> typeRef = new TypeReference<{{{returnType}}}>() {};
|
||||
return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);{{/returnType}}
|
||||
}
|
||||
|
||||
{{#isDeprecated}}
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
public HttpResponse {{operationId}}ForHttpResponse({{#allParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws IOException {
|
||||
{{#allParams}}{{#required}}// verify the required parameter '{{paramName}}' is set
|
||||
if ({{paramName}} == null) {
|
||||
@ -112,6 +125,9 @@ public class {{classname}} {
|
||||
return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.{{httpMethod}}, genericUrl, content).execute();
|
||||
}{{#bodyParam}}
|
||||
|
||||
{{#isDeprecated}}
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
public HttpResponse {{operationId}}ForHttpResponse({{#allParams}}{{#isBodyParam}}java.io.InputStream {{paramName}}{{/isBodyParam}}{{^isBodyParam}}{{{dataType}}} {{paramName}}{{/isBodyParam}}{{^-last}}, {{/-last}}{{/allParams}}, String mediaType) throws IOException {
|
||||
{{#allParams}}{{#required}}// verify the required parameter '{{paramName}}' is set
|
||||
if ({{paramName}} == null) {
|
||||
@ -145,6 +161,9 @@ public class {{classname}} {
|
||||
return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.{{httpMethod}}, genericUrl, content).execute();
|
||||
}{{/bodyParam}}
|
||||
|
||||
{{#isDeprecated}}
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
public HttpResponse {{operationId}}ForHttpResponse({{#bodyParam}}{{^required}}{{{dataType}}} {{paramName}}, {{/required}}{{/bodyParam}}{{#requiredParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#hasRequiredParams}}, {{/hasRequiredParams}}Map<String, Object> params) throws IOException {
|
||||
{{#allParams}}{{#required}}// verify the required parameter '{{paramName}}' is set
|
||||
if ({{paramName}} == null) {
|
||||
|
@ -1,6 +1,8 @@
|
||||
/**
|
||||
* {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}}
|
||||
*/{{#description}}
|
||||
* {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}}{{#isDeprecated}}
|
||||
* @deprecated{{/isDeprecated}}
|
||||
*/{{#isDeprecated}}
|
||||
@Deprecated{{/isDeprecated}}{{#description}}
|
||||
@ApiModel(description = "{{{description}}}"){{/description}}
|
||||
{{#jackson}}
|
||||
@JsonPropertyOrder({
|
||||
@ -187,11 +189,20 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#vendorE
|
||||
* maximum: {{maximum}}
|
||||
{{/maximum}}
|
||||
* @return {{name}}
|
||||
{{#deprecated}}
|
||||
* @deprecated
|
||||
{{/deprecated}}
|
||||
**/
|
||||
{{#deprecated}}
|
||||
@Deprecated
|
||||
{{/deprecated}}
|
||||
{{#required}}
|
||||
{{#isNullable}}
|
||||
@javax.annotation.Nullable
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
@javax.annotation.Nonnull
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
@javax.annotation.Nullable
|
||||
|
@ -44,8 +44,14 @@ public interface {{classname}} {
|
||||
* {{notes}}
|
||||
*
|
||||
{{/notes}}
|
||||
{{#isDeprecated}}
|
||||
* @deprecated
|
||||
{{/isDeprecated}}
|
||||
*/
|
||||
{{/summary}}
|
||||
{{#isDeprecated}}
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
@{{httpMethod}}
|
||||
{{#subresourceOperation}}@Path("{{{path}}}"){{/subresourceOperation}}
|
||||
{{#hasConsumes}}
|
||||
|
@ -69,7 +69,13 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}}{{#serializ
|
||||
* maximum: {{maximum}}
|
||||
{{/maximum}}
|
||||
* @return {{name}}
|
||||
{{#deprecated}}
|
||||
* @deprecated
|
||||
{{/deprecated}}
|
||||
**/
|
||||
{{#deprecated}}
|
||||
@Deprecated
|
||||
{{/deprecated}}
|
||||
{{^withXml}}
|
||||
@JsonbProperty("{{baseName}}")
|
||||
{{/withXml}}
|
||||
|
@ -2,8 +2,10 @@
|
||||
import {{invokerPackage}}.JSON;
|
||||
{{/discriminator}}
|
||||
/**
|
||||
* {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}}
|
||||
*/{{#description}}
|
||||
* {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}}{{#isDeprecated}}
|
||||
* @deprecated{{/isDeprecated}}
|
||||
*/{{#isDeprecated}}
|
||||
@Deprecated{{/isDeprecated}}{{#description}}
|
||||
@ApiModel(description = "{{{description}}}"){{/description}}
|
||||
{{#jackson}}
|
||||
@JsonPropertyOrder({
|
||||
@ -190,11 +192,20 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#vendorE
|
||||
* maximum: {{maximum}}
|
||||
{{/maximum}}
|
||||
* @return {{name}}
|
||||
{{#deprecated}}
|
||||
* @deprecated
|
||||
{{/deprecated}}
|
||||
**/
|
||||
{{#deprecated}}
|
||||
@Deprecated
|
||||
{{/deprecated}}
|
||||
{{#required}}
|
||||
{{#isNullable}}
|
||||
@javax.annotation.Nullable
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
@javax.annotation.Nonnull
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
@javax.annotation.Nullable
|
||||
|
@ -27,6 +27,7 @@ import org.springframework.http.converter.json.MappingJackson2HttpMessageConvert
|
||||
import org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter;
|
||||
{{/withXml}}
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.StringUtils;
|
||||
@ -92,6 +93,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
CSV(","), TSV("\t"), SSV(" "), PIPES("|"), MULTI(null);
|
||||
|
||||
private final String separator;
|
||||
|
||||
private CollectionFormat(String separator) {
|
||||
this.separator = separator;
|
||||
}
|
||||
@ -148,6 +150,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
|
||||
/**
|
||||
* Get the current base path
|
||||
*
|
||||
* @return String the base path
|
||||
*/
|
||||
public String getBasePath() {
|
||||
@ -156,6 +159,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
|
||||
/**
|
||||
* Set the base path, which should include the host
|
||||
*
|
||||
* @param basePath the base path
|
||||
* @return ApiClient this client
|
||||
*/
|
||||
@ -166,6 +170,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
|
||||
/**
|
||||
* Get authentications (key: authentication name, value: authentication).
|
||||
*
|
||||
* @return Map the currently configured authentication types
|
||||
*/
|
||||
public Map<String, Authentication> getAuthentications() {
|
||||
@ -185,6 +190,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
{{#hasHttpBearerMethods}}
|
||||
/**
|
||||
* Helper method to set token for HTTP bearer authentication.
|
||||
*
|
||||
* @param bearerToken the token
|
||||
*/
|
||||
public void setBearerToken(String bearerToken) {
|
||||
@ -202,6 +208,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
{{#hasHttpBasicMethods}}
|
||||
/**
|
||||
* Helper method to set username for the first HTTP basic authentication.
|
||||
*
|
||||
* @param username Username
|
||||
*/
|
||||
public void setUsername(String username) {
|
||||
@ -233,6 +240,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
{{#hasApiKeyMethods}}
|
||||
/**
|
||||
* Helper method to set API key value for the first API key authentication.
|
||||
*
|
||||
* @param apiKey the API key
|
||||
*/
|
||||
public void setApiKey(String apiKey) {
|
||||
@ -247,6 +255,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
|
||||
/**
|
||||
* Helper method to set API key prefix for the first API key authentication.
|
||||
*
|
||||
* @param apiKeyPrefix API key prefix
|
||||
*/
|
||||
public void setApiKeyPrefix(String apiKeyPrefix) {
|
||||
@ -264,6 +273,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
{{#hasOAuthMethods}}
|
||||
/**
|
||||
* Helper method to set access token for the first OAuth2 authentication.
|
||||
*
|
||||
* @param accessToken Access token
|
||||
*/
|
||||
public void setAccessToken(String accessToken) {
|
||||
@ -280,6 +290,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
|
||||
/**
|
||||
* Set the User-Agent header's value (by adding to the default header map).
|
||||
*
|
||||
* @param userAgent the user agent string
|
||||
* @return ApiClient this client
|
||||
*/
|
||||
@ -378,6 +389,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
|
||||
/**
|
||||
* Parse the given string into Date object.
|
||||
*
|
||||
* @param str the string to parse
|
||||
* @return the Date parsed from the string
|
||||
*/
|
||||
@ -391,6 +403,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
|
||||
/**
|
||||
* Format the given Date object into string.
|
||||
*
|
||||
* @param date the date to format
|
||||
* @return the formatted date as string
|
||||
*/
|
||||
@ -400,6 +413,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
|
||||
/**
|
||||
* Format the given parameter object into string.
|
||||
*
|
||||
* @param param the object to convert
|
||||
* @return String the parameter represented as a String
|
||||
*/
|
||||
@ -448,6 +462,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
|
||||
/**
|
||||
* Converts a parameter to a {@link MultiValueMap} for use in REST requests
|
||||
*
|
||||
* @param collectionFormat The format to convert to
|
||||
* @param name The name of the parameter
|
||||
* @param value The parameter's value
|
||||
@ -494,6 +509,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
|
||||
/**
|
||||
* Check if the given {@code String} is a JSON MIME.
|
||||
*
|
||||
* @param mediaType the input MediaType
|
||||
* @return boolean true if the MediaType represents JSON, false otherwise
|
||||
*/
|
||||
@ -516,6 +532,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
* application/json
|
||||
* application/json; charset=UTF8
|
||||
* APPLICATION/JSON
|
||||
*
|
||||
* @param mediaType the input MediaType
|
||||
* @return boolean true if the MediaType represents JSON, false otherwise
|
||||
*/
|
||||
@ -525,6 +542,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
|
||||
/**
|
||||
* Check if the given {@code String} is a Problem JSON MIME (RFC-7807).
|
||||
*
|
||||
* @param mediaType the input MediaType
|
||||
* @return boolean true if the MediaType represents Problem JSON, false otherwise
|
||||
*/
|
||||
@ -576,6 +594,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
|
||||
/**
|
||||
* Select the body to use for the request
|
||||
*
|
||||
* @param obj the body object
|
||||
* @param formParams the form parameters
|
||||
* @param contentType the content type of the request
|
||||
@ -588,6 +607,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
|
||||
/**
|
||||
* Expand path template with variables
|
||||
*
|
||||
* @param pathTemplate path template with placeholders
|
||||
* @param variables variables to replace
|
||||
* @return path with placeholders replaced by variables
|
||||
@ -596,12 +616,47 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
return restTemplate.getUriTemplateHandler().expand(pathTemplate, variables).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Include queryParams in uriParams taking into account the paramName
|
||||
*
|
||||
* @param queryParam The query parameters
|
||||
* @param uriParams The path parameters
|
||||
* return templatized query string
|
||||
*/
|
||||
private String generateQueryUri(MultiValueMap<String, String> queryParams, Map<String, Object> uriParams) {
|
||||
StringBuilder queryBuilder = new StringBuilder();
|
||||
queryParams.forEach((name, values) -> {
|
||||
if (CollectionUtils.isEmpty(values)) {
|
||||
if (queryBuilder.length() != 0) {
|
||||
queryBuilder.append('&');
|
||||
}
|
||||
queryBuilder.append(name);
|
||||
} else {
|
||||
int valueItemCounter = 0;
|
||||
for (Object value : values) {
|
||||
if (queryBuilder.length() != 0) {
|
||||
queryBuilder.append('&');
|
||||
}
|
||||
queryBuilder.append(name);
|
||||
if (value != null) {
|
||||
String templatizedKey = name + valueItemCounter++;
|
||||
uriParams.put(templatizedKey, value.toString());
|
||||
queryBuilder.append('=').append("{").append(templatizedKey).append("}");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return queryBuilder.toString();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke API by sending HTTP request with the given options.
|
||||
*
|
||||
* @param <T> the return type to use
|
||||
* @param path The sub-path of the HTTP URL
|
||||
* @param method The request method
|
||||
* @param pathParams The path parameters
|
||||
* @param queryParams The query parameters
|
||||
* @param body The request body object
|
||||
* @param headerParams The header parameters
|
||||
@ -613,25 +668,22 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
* @param returnType The return type into which to deserialize the response
|
||||
* @return ResponseEntity<T> The response of the chosen type
|
||||
*/
|
||||
public <T> ResponseEntity<T> invokeAPI(String path, HttpMethod method, MultiValueMap<String, String> queryParams, Object body, HttpHeaders headerParams, MultiValueMap<String, String> cookieParams, MultiValueMap<String, Object> formParams, List<MediaType> accept, MediaType contentType, String[] authNames, ParameterizedTypeReference<T> returnType) throws RestClientException {
|
||||
public <T> ResponseEntity<T> invokeAPI(String path, HttpMethod method, Map<String, Object> pathParams, MultiValueMap<String, String> queryParams, Object body, HttpHeaders headerParams, MultiValueMap<String, String> cookieParams, MultiValueMap<String, Object> formParams, List<MediaType> accept, MediaType contentType, String[] authNames, ParameterizedTypeReference<T> returnType) throws RestClientException {
|
||||
updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);
|
||||
|
||||
final UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(basePath).path(path);
|
||||
if (queryParams != null) {
|
||||
//encode the query parameters in case they contain unsafe characters
|
||||
for (List<String> values : queryParams.values()) {
|
||||
if (values != null) {
|
||||
for (int i = 0; i < values.size(); i++) {
|
||||
try {
|
||||
values.set(i, URLEncoder.encode(values.get(i), "utf8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
Map<String,Object> uriParams = new HashMap();
|
||||
uriParams.putAll(pathParams);
|
||||
|
||||
String finalUri = path;
|
||||
|
||||
if (queryParams != null && !queryParams.isEmpty()) {
|
||||
//Include queryParams in uriParams taking into account the paramName
|
||||
String queryUri = generateQueryUri(queryParams, uriParams);
|
||||
//Append to finalUri the templatized query string like "?param1={param1Value}&.......
|
||||
finalUri += "?" + queryUri;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
builder.queryParams(queryParams);
|
||||
}
|
||||
String expandedPath = this.expandPath(finalUri, uriParams);
|
||||
final UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(basePath).path(expandedPath);
|
||||
|
||||
URI uri;
|
||||
try {
|
||||
@ -683,6 +735,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
|
||||
/**
|
||||
* Add cookies to the request that is being built
|
||||
*
|
||||
* @param cookies The cookies to add
|
||||
* @param requestBuilder The current request
|
||||
*/
|
||||
@ -815,3 +868,4 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,9 @@ public class {{classname}} {
|
||||
* {{description}}
|
||||
* @see <a href="{{url}}">{{summary}} Documentation</a>
|
||||
{{/externalDocs}}
|
||||
{{#isDeprecated}}
|
||||
* @deprecated
|
||||
{{/isDeprecated}}
|
||||
*/
|
||||
{{#isDeprecated}}
|
||||
@Deprecated
|
||||
@ -95,6 +98,9 @@ public class {{classname}} {
|
||||
* {{description}}
|
||||
* @see <a href="{{url}}">{{summary}} Documentation</a>
|
||||
{{/externalDocs}}
|
||||
{{#isDeprecated}}
|
||||
* @deprecated
|
||||
{{/isDeprecated}}
|
||||
*/
|
||||
{{#isDeprecated}}
|
||||
@Deprecated
|
||||
@ -110,7 +116,6 @@ public class {{classname}} {
|
||||
// create path and map variables
|
||||
final Map<String, Object> uriVariables = new HashMap<String, Object>();{{#pathParams}}
|
||||
uriVariables.put("{{baseName}}", {{#collectionFormat}}apiClient.collectionPathParameterToString(ApiClient.CollectionFormat.valueOf("{{{collectionFormat}}}".toUpperCase()), {{{paramName}}}){{/collectionFormat}}{{^collectionFormat}}{{{paramName}}}{{/collectionFormat}});{{/pathParams}}{{/hasPathParams}}
|
||||
String path = apiClient.expandPath("{{{path}}}", {{#hasPathParams}}uriVariables{{/hasPathParams}}{{^hasPathParams}}Collections.<String, Object>emptyMap(){{/hasPathParams}});
|
||||
|
||||
final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
|
||||
final HttpHeaders headerParams = new HttpHeaders();
|
||||
@ -144,7 +149,7 @@ public class {{classname}} {
|
||||
String[] authNames = new String[] { {{#authMethods}}"{{name}}"{{^-last}}, {{/-last}}{{/authMethods}} };
|
||||
|
||||
{{#returnType}}ParameterizedTypeReference<{{{returnType}}}> returnType = new ParameterizedTypeReference<{{{returnType}}}>() {};{{/returnType}}{{^returnType}}ParameterizedTypeReference<Void> returnType = new ParameterizedTypeReference<Void>() {};{{/returnType}}
|
||||
return apiClient.invokeAPI(path, HttpMethod.{{httpMethod}}, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType);
|
||||
return apiClient.invokeAPI("{{{path}}}", HttpMethod.{{httpMethod}}, {{#hasPathParams}}uriVariables{{/hasPathParams}}{{^hasPathParams}}Collections.<String, Object>emptyMap(){{/hasPathParams}}, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType);
|
||||
}
|
||||
{{/operation}}
|
||||
}
|
||||
|
@ -31,7 +31,13 @@ public interface {{classname}} {
|
||||
* {{description}}
|
||||
* @see <a href="{{url}}">{{summary}} Documentation</a>
|
||||
{{/externalDocs}}
|
||||
{{#isDeprecated}}
|
||||
* @deprecated
|
||||
{{/isDeprecated}}
|
||||
*/
|
||||
{{#isDeprecated}}
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
{{#formParams}}{{#-first}}
|
||||
{{#isMultipart}}@retrofit.http.Multipart{{/isMultipart}}{{^isMultipart}}@retrofit.http.FormUrlEncoded{{/isMultipart}}{{/-first}}{{/formParams}}
|
||||
@{{httpMethod}}("{{{path}}}")
|
||||
@ -50,7 +56,13 @@ public interface {{classname}} {
|
||||
* {{description}}
|
||||
* @see <a href="{{url}}">{{summary}} Documentation</a>
|
||||
{{/externalDocs}}
|
||||
{{#isDeprecated}}
|
||||
* @deprecated
|
||||
{{/isDeprecated}}
|
||||
*/
|
||||
{{#isDeprecated}}
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
{{#formParams}}{{#-first}}
|
||||
{{#isMultipart}}@retrofit.http.Multipart{{/isMultipart}}{{^isMultipart}}@retrofit.http.FormUrlEncoded{{/isMultipart}}{{/-first}}{{/formParams}}
|
||||
@{{httpMethod}}("{{{path}}}")
|
||||
|
@ -34,7 +34,13 @@ public interface {{classname}} {
|
||||
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}
|
||||
{{/allParams}}
|
||||
* @return Call<{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Void{{/returnType}}>
|
||||
{{#isDeprecated}}
|
||||
* @deprecated
|
||||
{{/isDeprecated}}
|
||||
*/
|
||||
{{#isDeprecated}}
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
{{#formParams}}
|
||||
{{#-first}}
|
||||
{{#isMultipart}}@retrofit2.http.Multipart{{/isMultipart}}{{^isMultipart}}@retrofit2.http.FormUrlEncoded{{/isMultipart}}
|
||||
|
@ -34,7 +34,13 @@ public interface {{classname}} {
|
||||
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}
|
||||
{{/allParams}}
|
||||
* @return Call<{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Void{{/returnType}}>
|
||||
{{#isDeprecated}}
|
||||
* @deprecated
|
||||
{{/isDeprecated}}
|
||||
*/
|
||||
{{#isDeprecated}}
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
{{#formParams}}
|
||||
{{#-first}}
|
||||
{{#isMultipart}}@retrofit2.http.Multipart{{/isMultipart}}{{^isMultipart}}@retrofit2.http.FormUrlEncoded{{/isMultipart}}
|
||||
|
@ -34,7 +34,13 @@ public interface {{classname}} {
|
||||
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}
|
||||
{{/allParams}}
|
||||
* @return Call<{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Void{{/returnType}}>
|
||||
{{#isDeprecated}}
|
||||
* @deprecated
|
||||
{{/isDeprecated}}
|
||||
*/
|
||||
{{#isDeprecated}}
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
{{#formParams}}
|
||||
{{#-first}}
|
||||
{{#isMultipart}}@retrofit2.http.Multipart{{/isMultipart}}{{^isMultipart}}@retrofit2.http.FormUrlEncoded{{/isMultipart}}
|
||||
|
@ -13,8 +13,14 @@ public interface {{classname}} {
|
||||
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
{{#isDeprecated}}
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
void {{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}Handler<AsyncResult<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}>> handler);
|
||||
|
||||
{{#isDeprecated}}
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
void {{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}ApiClient.AuthInfo authInfo, Handler<AsyncResult<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}>> handler);
|
||||
|
||||
{{/operation}}
|
||||
|
@ -277,7 +277,7 @@
|
||||
<dependency>
|
||||
<groupId>com.github.joschi.jackson</groupId>
|
||||
<artifactId>jackson-datatype-threetenbp</artifactId>
|
||||
<version>${jackson-version}</version>
|
||||
<version>2.9.10</version>
|
||||
</dependency>
|
||||
{{/threetenbp}}
|
||||
<dependency>
|
||||
|
@ -24,6 +24,7 @@ import org.springframework.http.client.ClientHttpRequestInterceptor;
|
||||
import org.springframework.http.client.ClientHttpResponse;
|
||||
import org.springframework.http.codec.json.Jackson2JsonDecoder;
|
||||
import org.springframework.http.codec.json.Jackson2JsonEncoder;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.StringUtils;
|
||||
@ -610,15 +611,59 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
return requestBuilder.retrieve();
|
||||
}
|
||||
|
||||
private WebClient.RequestBodySpec prepareRequest(String path, HttpMethod method, Map<String, Object> pathParams, MultiValueMap<String, String> queryParams, Object body, HttpHeaders headerParams, MultiValueMap<String, String> cookieParams, MultiValueMap<String, Object> formParams, List<MediaType> accept, MediaType contentType, String[] authNames) {
|
||||
/**
|
||||
* Include queryParams in uriParams taking into account the paramName
|
||||
* @param queryParam The query parameters
|
||||
* @param uriParams The path parameters
|
||||
* return templatized query string
|
||||
*/
|
||||
private String generateQueryUri(MultiValueMap<String, String> queryParams, Map<String, Object> uriParams) {
|
||||
StringBuilder queryBuilder = new StringBuilder();
|
||||
queryParams.forEach((name, values) -> {
|
||||
if (CollectionUtils.isEmpty(values)) {
|
||||
if (queryBuilder.length() != 0) {
|
||||
queryBuilder.append('&');
|
||||
}
|
||||
queryBuilder.append(name);
|
||||
} else {
|
||||
int valueItemCounter = 0;
|
||||
for (Object value : values) {
|
||||
if (queryBuilder.length() != 0) {
|
||||
queryBuilder.append('&');
|
||||
}
|
||||
queryBuilder.append(name);
|
||||
if (value != null) {
|
||||
String templatizedKey = name + valueItemCounter++;
|
||||
uriParams.put(templatizedKey, value.toString());
|
||||
queryBuilder.append('=').append("{").append(templatizedKey).append("}");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return queryBuilder.toString();
|
||||
}
|
||||
|
||||
private WebClient.RequestBodySpec prepareRequest(String path, HttpMethod method, Map<String, Object> pathParams,
|
||||
MultiValueMap<String, String> queryParams, Object body, HttpHeaders headerParams,
|
||||
MultiValueMap<String, String> cookieParams, MultiValueMap<String, Object> formParams, List<MediaType> accept,
|
||||
MediaType contentType, String[] authNames) {
|
||||
updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);
|
||||
|
||||
final UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(basePath).path(path);
|
||||
if (queryParams != null) {
|
||||
builder.queryParams(queryParams);
|
||||
|
||||
String finalUri = builder.build(false).toUriString();
|
||||
Map<String, Object> uriParams = new HashMap();
|
||||
uriParams.putAll(pathParams);
|
||||
|
||||
if (queryParams != null && !queryParams.isEmpty()) {
|
||||
//Include queryParams in uriParams taking into account the paramName
|
||||
String queryUri = generateQueryUri(queryParams, uriParams);
|
||||
//Append to finalUri the templatized query string like "?param1={param1Value}&.......
|
||||
finalUri += "?" + queryUri;
|
||||
}
|
||||
|
||||
final WebClient.RequestBodySpec requestBuilder = webClient.method(method).uri(builder.build(false).toUriString(), pathParams);
|
||||
final WebClient.RequestBodySpec requestBuilder = webClient.method(method).uri(finalUri, uriParams);
|
||||
|
||||
if (accept != null) {
|
||||
requestBuilder.accept(accept.toArray(new MediaType[accept.size()]));
|
||||
}
|
||||
|
@ -63,7 +63,13 @@ public class {{classname}} {
|
||||
* {{description}}
|
||||
* @see <a href="{{url}}">{{summary}} Documentation</a>
|
||||
{{/externalDocs}}
|
||||
{{#isDeprecated}}
|
||||
* @deprecated
|
||||
{{/isDeprecated}}
|
||||
*/
|
||||
{{#isDeprecated}}
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
private ResponseSpec {{operationId}}RequestCreation({{#allParams}}{{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection<org.springframework.core.io.AbstractResource>{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.AbstractResource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws WebClientResponseException {
|
||||
Object postBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
|
||||
{{#allParams}}
|
||||
|
@ -12,6 +12,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
{{/fullJavaUtil}}
|
||||
|
||||
/**
|
||||
@ -33,7 +34,7 @@ public class {{classname}}Test {
|
||||
{{#allParams}}
|
||||
{{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection<org.springframework.core.io.AbstractResource>{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.AbstractResource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}} = null;
|
||||
{{/allParams}}
|
||||
{{#returnType}}{{{returnType}}} response = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}){{#isArray}}.collectList().block(){{/isArray}}{{^isArray}}.block(){{/isArray}};
|
||||
{{#returnType}}{{{returnType}}} response = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}){{#isArray}}{{#uniqueItems}}.collect(Collectors.toSet()){{/uniqueItems}}{{^uniqueItems}}.collectList(){{/uniqueItems}}.block(){{/isArray}}{{^isArray}}.block(){{/isArray}};
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
/**
|
||||
* {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}}
|
||||
*/{{#description}}
|
||||
* {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}}{{#isDeprecated}}
|
||||
* @deprecated{{/isDeprecated}}
|
||||
*/{{#isDeprecated}}
|
||||
@Deprecated{{/isDeprecated}}{{#description}}
|
||||
@ApiModel(description = "{{{description}}}"){{/description}}
|
||||
{{#jackson}}
|
||||
@JsonPropertyOrder({
|
||||
@ -170,11 +172,20 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#vendorE
|
||||
* maximum: {{maximum}}
|
||||
{{/maximum}}
|
||||
* @return {{name}}
|
||||
{{#deprecated}}
|
||||
* @deprecated
|
||||
{{/deprecated}}
|
||||
**/
|
||||
{{#deprecated}}
|
||||
@Deprecated
|
||||
{{/deprecated}}
|
||||
{{#required}}
|
||||
{{#isNullable}}
|
||||
@javax.annotation.Nullable
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
@javax.annotation.Nonnull
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
@javax.annotation.Nullable
|
||||
|
@ -28,12 +28,22 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
* {{{description}}}
|
||||
**/
|
||||
{{/description}}
|
||||
{{#vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{#isContainer}}
|
||||
private JsonNullable<{{{datatypeWithEnum}}}> {{name}} = JsonNullable.<{{{datatypeWithEnum}}}>undefined();
|
||||
{{/isContainer}}
|
||||
{{^isContainer}}
|
||||
private JsonNullable<{{{datatypeWithEnum}}}> {{name}} = JsonNullable.<{{{datatypeWithEnum}}}>{{#defaultValue}}of({{{.}}}){{/defaultValue}}{{^defaultValue}}undefined(){{/defaultValue}};
|
||||
{{/isContainer}}
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{^vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{#isContainer}}
|
||||
private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}};
|
||||
{{/isContainer}}
|
||||
{{^isContainer}}
|
||||
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
|
||||
{{/isContainer}}
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{/vars}}
|
||||
{{#vars}}
|
||||
/**
|
||||
@ -51,44 +61,115 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
{{/maximum}}
|
||||
* @return {{name}}
|
||||
**/
|
||||
@JsonProperty("{{baseName}}")
|
||||
{{#vendorExtensions.x-extra-annotation}}
|
||||
{{{vendorExtensions.x-extra-annotation}}}
|
||||
{{/vendorExtensions.x-extra-annotation}}
|
||||
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} {{#isEnum}}{{^isArray}}{{^isMap}}public {{dataType}} {{getter}}() {
|
||||
{{#vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{!unannotated, Jackson would pick this up automatically and add it *in addition* to the _JsonNullable getter field}}
|
||||
@JsonIgnore
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{^vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
@JsonProperty("{{baseName}}")
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} {{#isEnum}}{{^isContainer}}public {{dataType}} {{getter}}() {
|
||||
{{#vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
if ({{name}} == null || !{{name}}.isPresent() || {{name}}.get() == null) {
|
||||
return null;
|
||||
}
|
||||
return {{name}}.get().value();
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{^vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
if ({{name}} == null) {
|
||||
return null;
|
||||
}
|
||||
return {{name}}.value();
|
||||
}{{/isMap}}{{/isArray}}{{/isEnum}}{{#isEnum}}{{#isArray}}public {{{datatypeWithEnum}}} {{getter}}() {
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
}{{/isContainer}}{{#isContainer}}public {{{datatypeWithEnum}}} {{getter}}() {
|
||||
{{#vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
if ({{name}} == null) {
|
||||
return null;
|
||||
}
|
||||
return {{name}}.orElse(null);
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{^vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
return {{name}};
|
||||
}{{/isArray}}{{/isEnum}}{{#isEnum}}{{#isMap}}public {{{datatypeWithEnum}}} {{getter}}() {
|
||||
return {{name}};
|
||||
}{{/isMap}}{{/isEnum}}{{^isEnum}}public {{{datatypeWithEnum}}} {{getter}}() {
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
}{{/isContainer}}{{/isEnum}}{{^isEnum}}public {{{datatypeWithEnum}}} {{getter}}() {
|
||||
{{#vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
if ({{name}} == null) {
|
||||
return null;
|
||||
}
|
||||
return {{name}}.orElse(null);
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{^vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
return {{name}};
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
}{{/isEnum}}
|
||||
{{#vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
|
||||
@JsonProperty("{{baseName}}")
|
||||
public JsonNullable<{{{datatypeWithEnum}}}> {{getter}}_JsonNullable() {
|
||||
return {{name}};
|
||||
}
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
|
||||
{{^isReadOnly}}
|
||||
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
|
||||
{{#vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{name}});
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{^vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
this.{{name}} = {{name}};
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
}
|
||||
{{#vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
|
||||
@JsonProperty("{{baseName}}")
|
||||
public void {{setter}}_JsonNullable(JsonNullable<{{{datatypeWithEnum}}}> {{name}}) {
|
||||
{{! For getters/setters that have name differing from attribute name, we must include setter (albeit private) for jackson to be able to set the attribute}}
|
||||
this.{{name}} = {{name}};
|
||||
}
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
|
||||
public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) {
|
||||
{{#vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{name}});
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{^vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
this.{{name}} = {{name}};
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
return this;
|
||||
}
|
||||
{{#isArray}}
|
||||
|
||||
public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
|
||||
{{#vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
if (this.{{name}} == null || !this.{{name}}.isPresent()) {
|
||||
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}});
|
||||
}
|
||||
this.{{name}}.get().add({{name}}Item);
|
||||
return this;
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{^vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
this.{{name}}.add({{name}}Item);
|
||||
return this;
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
}
|
||||
{{/isArray}}
|
||||
{{#isMap}}
|
||||
|
||||
public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) {
|
||||
{{#vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
if (this.{{name}} == null || !this.{{name}}.isPresent()) {
|
||||
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}});
|
||||
}
|
||||
this.{{name}}.get().put(key, {{name}}Item);
|
||||
return this;
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{^vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
this.{{name}}.put(key, {{name}}Item);
|
||||
return this;
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
}
|
||||
{{/isMap}}
|
||||
{{/isReadOnly}}
|
||||
|
@ -126,6 +126,16 @@ inline FString ToString(const FString& Value)
|
||||
return Value;
|
||||
}
|
||||
|
||||
inline FString ToString(bool Value)
|
||||
{
|
||||
return Value ? TEXT("true") : TEXT("false");
|
||||
}
|
||||
|
||||
inline FStringFormatArg ToStringFormatArg(bool Value)
|
||||
{
|
||||
return FStringFormatArg(ToString(Value));
|
||||
}
|
||||
|
||||
inline FString ToString(const TArray<uint8>& Value)
|
||||
{
|
||||
return Base64UrlEncode(Value);
|
||||
|
@ -73,7 +73,8 @@ class {{classname}} {
|
||||
extra: <String, dynamic>{
|
||||
'secure': <Map<String, String>>[{{^hasAuthMethods}}],{{/hasAuthMethods}}{{#hasAuthMethods}}
|
||||
{{#authMethods}}{
|
||||
'type': '{{type}}',
|
||||
'type': '{{type}}',{{#scheme}}
|
||||
'scheme': '{{scheme}}',{{/scheme}}
|
||||
'name': '{{name}}',{{#isApiKey}}
|
||||
'keyName': '{{keyParamName}}',
|
||||
'where': '{{#isKeyInQuery}}query{{/isKeyInQuery}}{{#isKeyInHeader}}header{{/isKeyInHeader}}',{{/isApiKey}}
|
||||
|
@ -4,6 +4,7 @@ import 'package:built_value/serializer.dart';
|
||||
import 'package:{{pubName}}/src/serializers.dart';{{/useBuiltValue}}
|
||||
import 'package:{{pubName}}/src/auth/api_key_auth.dart';
|
||||
import 'package:{{pubName}}/src/auth/basic_auth.dart';
|
||||
import 'package:{{pubName}}/src/auth/bearer_auth.dart';
|
||||
import 'package:{{pubName}}/src/auth/oauth.dart';
|
||||
{{#apiInfo}}{{#apis}}import 'package:{{pubName}}/src/api/{{classFilename}}.dart';
|
||||
{{/apis}}{{/apiInfo}}
|
||||
@ -31,6 +32,7 @@ class {{clientName}} {
|
||||
this.dio.interceptors.addAll([
|
||||
OAuthInterceptor(),
|
||||
BasicAuthInterceptor(),
|
||||
BearerAuthInterceptor(),
|
||||
ApiKeyAuthInterceptor(),
|
||||
]);
|
||||
} else {
|
||||
@ -44,6 +46,12 @@ class {{clientName}} {
|
||||
}
|
||||
}
|
||||
|
||||
void setBearerAuth(String name, String token) {
|
||||
if (this.dio.interceptors.any((i) => i is BearerAuthInterceptor)) {
|
||||
(this.dio.interceptors.firstWhere((i) => i is BearerAuthInterceptor) as BearerAuthInterceptor).tokens[name] = token;
|
||||
}
|
||||
}
|
||||
|
||||
void setBasicAuth(String name, String username, String password) {
|
||||
if (this.dio.interceptors.any((i) => i is BasicAuthInterceptor)) {
|
||||
(this.dio.interceptors.firstWhere((i) => i is BasicAuthInterceptor) as BasicAuthInterceptor).authInfo[name] = BasicAuthInfo(username, password);
|
||||
|
@ -8,7 +8,7 @@ class ApiKeyAuthInterceptor extends AuthInterceptor {
|
||||
|
||||
@override
|
||||
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
|
||||
final authInfo = getAuthInfo(options, 'apiKey');
|
||||
final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'apiKey');
|
||||
for (final info in authInfo) {
|
||||
final authName = info['name'] as String;
|
||||
final authKeyName = info['keyName'] as String;
|
||||
|
@ -5,16 +5,10 @@ abstract class AuthInterceptor extends Interceptor {
|
||||
/// Get auth information on given route for the given type.
|
||||
/// Can return an empty list if type is not present on auth data or
|
||||
/// if route doesn't need authentication.
|
||||
List<Map<String, dynamic>> getAuthInfo(RequestOptions route, String type) {
|
||||
List<Map<String, String>> getAuthInfo(RequestOptions route, bool Function(Map<String, String> secure) handles) {
|
||||
if (route.extra.containsKey('secure')) {
|
||||
final auth = route.extra['secure'] as List<Map<String, String>>;
|
||||
final results = <Map<String, dynamic>>[];
|
||||
for (final info in auth) {
|
||||
if (info['type'] == type) {
|
||||
results.add(info);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
return auth.where((secure) => handles(secure)).toList();
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ class BasicAuthInterceptor extends AuthInterceptor {
|
||||
RequestOptions options,
|
||||
RequestInterceptorHandler handler,
|
||||
) {
|
||||
final metadataAuthInfo = getAuthInfo(options, 'basic');
|
||||
final metadataAuthInfo = getAuthInfo(options, (secure) => (secure['type'] == 'http' && secure['scheme'] == 'basic') || secure['type'] == 'basic');
|
||||
for (final info in metadataAuthInfo) {
|
||||
final authName = info['name'] as String;
|
||||
final basicAuthInfo = authInfo[authName];
|
||||
|
23
modules/openapi-generator/src/main/resources/dart/libraries/dio/auth/bearer_auth.mustache
vendored
Normal file
23
modules/openapi-generator/src/main/resources/dart/libraries/dio/auth/bearer_auth.mustache
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
{{>header}}
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:{{pubName}}/src/auth/auth.dart';
|
||||
|
||||
class BearerAuthInterceptor extends AuthInterceptor {
|
||||
final Map<String, String> tokens = {};
|
||||
|
||||
@override
|
||||
void onRequest(
|
||||
RequestOptions options,
|
||||
RequestInterceptorHandler handler,
|
||||
) {
|
||||
final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'http' && secure['scheme'] == 'bearer');
|
||||
for (final info in authInfo) {
|
||||
final token = tokens[info['name']];
|
||||
if (token != null) {
|
||||
options.headers['Authorization'] = 'Bearer ${token}';
|
||||
break;
|
||||
}
|
||||
}
|
||||
super.onRequest(options, handler);
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@ class OAuthInterceptor extends AuthInterceptor {
|
||||
RequestOptions options,
|
||||
RequestInterceptorHandler handler,
|
||||
) {
|
||||
final authInfo = getAuthInfo(options, 'oauth');
|
||||
final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'oauth' && secure['type'] == 'oauth2');
|
||||
for (final info in authInfo) {
|
||||
final token = tokens[info['name']];
|
||||
if (token != null) {
|
||||
|
@ -7,6 +7,8 @@ defmodule {{moduleName}}.Mixfile do
|
||||
elixir: "~> {{supportedElixirVersion}}",
|
||||
build_embedded: Mix.env == :prod,
|
||||
start_permanent: Mix.env == :prod,
|
||||
package: package(),
|
||||
description: "{{appDescription}}",
|
||||
deps: deps()]
|
||||
end
|
||||
|
||||
@ -34,4 +36,12 @@ defmodule {{moduleName}}.Mixfile do
|
||||
{{/deps}}
|
||||
]
|
||||
end
|
||||
|
||||
defp package() do
|
||||
[
|
||||
name: "{{#underscored}}{{packageName}}{{/underscored}}",
|
||||
files: ~w(lib mix.exs README* LICENSE*),
|
||||
licenses: ["{{licenseId}}"]
|
||||
]
|
||||
end
|
||||
end
|
||||
|
@ -29,10 +29,12 @@
|
||||
-spec init(Req :: cowboy_req:req(), Opts :: {{packageName}}_router:init_opts()) ->
|
||||
{cowboy_rest, Req :: cowboy_req:req(), State :: state()}.
|
||||
|
||||
init(Req, {Operations, LogicHandler, ValidatorState}) ->
|
||||
init(Req, {Operations, LogicHandler, ValidatorMod}) ->
|
||||
Method = cowboy_req:method(Req),
|
||||
OperationID = maps:get(Method, Operations, undefined),
|
||||
|
||||
ValidatorState = ValidatorMod:get_validator_state(),
|
||||
|
||||
error_logger:info_msg("Attempt to process operation: ~p", [OperationID]),
|
||||
|
||||
State = #state{
|
||||
|
@ -1,6 +1,6 @@
|
||||
-module({{packageName}}_router).
|
||||
|
||||
-export([get_paths/1]).
|
||||
-export([get_paths/1, get_validator_state/0]).
|
||||
|
||||
-type operations() :: #{
|
||||
Method :: binary() => {{packageName}}_api:operation_id()
|
||||
@ -9,7 +9,7 @@
|
||||
-type init_opts() :: {
|
||||
Operations :: operations(),
|
||||
LogicHandler :: atom(),
|
||||
ValidatorState :: jesse_state:state()
|
||||
ValidatorMod :: module()
|
||||
}.
|
||||
|
||||
-export_type([init_opts/0]).
|
||||
@ -62,9 +62,15 @@ get_operations() ->
|
||||
}{{^-last}},{{/-last}}{{/operation}}{{^-last}},{{/-last}}{{/operations}}{{/apis}}{{/apiInfo}}
|
||||
}.
|
||||
|
||||
get_validator_state() ->
|
||||
persistent_term:get({?MODULE, validator_state}).
|
||||
|
||||
|
||||
prepare_validator() ->
|
||||
R = jsx:decode(element(2, file:read_file(get_openapi_path()))),
|
||||
jesse_state:new(R, [{default_schema_ver, <<"http://json-schema.org/draft-04/schema#">>}]).
|
||||
JesseState = jesse_state:new(R, [{default_schema_ver, <<"http://json-schema.org/draft-04/schema#">>}]),
|
||||
persistent_term:put({?MODULE, validator_state}, JesseState),
|
||||
?MODULE.
|
||||
|
||||
|
||||
get_openapi_path() ->
|
||||
|
@ -27,6 +27,8 @@ module {{title}}.API
|
||||
, {{title}}ClientError(..)
|
||||
-- ** Servant
|
||||
, {{title}}API
|
||||
-- ** Plain WAI Application
|
||||
, serverWaiApplication{{title}}
|
||||
) where
|
||||
|
||||
import {{title}}.Types
|
||||
@ -232,7 +234,13 @@ run{{title}}MiddlewareServer Config{..} middleware backend = do
|
||||
let warpSettings = Warp.defaultSettings
|
||||
& Warp.setPort (baseUrlPort url)
|
||||
& Warp.setHost (fromString $ baseUrlHost url)
|
||||
liftIO $ Warp.runSettings warpSettings $ middleware $ serve (Proxy :: Proxy {{title}}API) (serverFromBackend backend)
|
||||
liftIO $ Warp.runSettings warpSettings $ middleware $ serverWaiApplication{{title}} backend
|
||||
|
||||
-- | Plain "Network.Wai" Application for the {{title}} server.
|
||||
--
|
||||
-- Can be used to implement e.g. tests that call the API without a full webserver.
|
||||
serverWaiApplication{{title}} :: {{title}}Backend (ExceptT ServerError IO) -> Application
|
||||
serverWaiApplication{{title}} backend = serve (Proxy :: Proxy {{title}}API) (serverFromBackend backend)
|
||||
where
|
||||
serverFromBackend {{title}}Backend{..} =
|
||||
({{#apis}}{{#operations}}{{#operation}}coerce {{operationId}}{{^-last}} :<|>
|
||||
|
@ -16,7 +16,7 @@
|
||||
<cucumber-java.version>1.2.5</cucumber-java.version>
|
||||
<cucumber-reporting.version>3.10.0</cucumber-reporting.version>
|
||||
<javax-annotation-version>1.3.2</javax-annotation-version>
|
||||
<springfox-swagger2>2.6.1-SNAPSHOT</springfox-swagger2>
|
||||
<springfox-swagger2>2.6.0</springfox-swagger2>
|
||||
<springfox-swagger-ui>2.6.0</springfox-swagger-ui>
|
||||
<slf4j-api>1.7.25</slf4j-api>
|
||||
<logstash-logback-encoder>4.11</logstash-logback-encoder>
|
||||
@ -36,14 +36,6 @@
|
||||
<!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>oss-snapshots</id>
|
||||
<name>JFrog OSS Snapshots</name>
|
||||
<url>https://oss.jfrog.org/simple/oss-snapshot-local/</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>central</id>
|
||||
<name>Maven Repository Switchboard</name>
|
||||
|
@ -53,13 +53,20 @@ test {
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
{{^doNotUseRxAndCoroutines}}
|
||||
{{#useCoroutines}}
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1"
|
||||
{{/useCoroutines}}
|
||||
{{/doNotUseRxAndCoroutines}}
|
||||
{{#moshi}}
|
||||
{{^moshiCodeGen}}
|
||||
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
||||
implementation "com.squareup.moshi:moshi-kotlin:1.12.0"
|
||||
implementation "com.squareup.moshi:moshi-adapters:1.12.0"
|
||||
{{/moshiCodeGen}}
|
||||
{{#moshiCodeGen}}
|
||||
implementation "com.squareup.moshi:moshi:1.12.0"
|
||||
implementation "com.squareup.moshi:moshi-adapters:1.12.0"
|
||||
kapt "com.squareup.moshi:moshi-kotlin-codegen:1.12.0"
|
||||
{{/moshiCodeGen}}
|
||||
{{/moshi}}
|
||||
|
@ -4,6 +4,12 @@ package {{apiPackage}}
|
||||
{{#imports}}import {{import}}
|
||||
{{/imports}}
|
||||
|
||||
{{^doNotUseRxAndCoroutines}}
|
||||
{{#useCoroutines}}
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
{{/useCoroutines}}
|
||||
{{/doNotUseRxAndCoroutines}}
|
||||
import {{packageName}}.infrastructure.ApiClient
|
||||
import {{packageName}}.infrastructure.ClientException
|
||||
import {{packageName}}.infrastructure.ClientError
|
||||
@ -40,7 +46,7 @@ import {{packageName}}.infrastructure.toMultiValue
|
||||
{{#isDeprecated}}
|
||||
@Deprecated(message = "This operation is deprecated.")
|
||||
{{/isDeprecated}}
|
||||
{{^doNotUseRxAndCoroutines}}{{#useCoroutines}}suspend {{/useCoroutines}}{{/doNotUseRxAndCoroutines}}fun {{operationId}}({{#allParams}}{{{paramName}}}: {{{dataType}}}{{^required}}?{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) : {{#returnType}}{{{returnType}}}{{#nullableReturnType}}?{{/nullableReturnType}}{{/returnType}}{{^returnType}}Unit{{/returnType}} {
|
||||
{{^doNotUseRxAndCoroutines}}{{#useCoroutines}}suspend {{/useCoroutines}}{{/doNotUseRxAndCoroutines}}fun {{operationId}}({{#allParams}}{{{paramName}}}: {{{dataType}}}{{^required}}?{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) : {{#returnType}}{{{returnType}}}{{#nullableReturnType}}?{{/nullableReturnType}}{{/returnType}}{{^returnType}}Unit{{/returnType}}{{^doNotUseRxAndCoroutines}}{{#useCoroutines}} = withContext(Dispatchers.IO){{/useCoroutines}}{{/doNotUseRxAndCoroutines}} {
|
||||
{{#isDeprecated}}
|
||||
@Suppress("DEPRECATION")
|
||||
{{/isDeprecated}}
|
||||
@ -50,7 +56,7 @@ import {{packageName}}.infrastructure.toMultiValue
|
||||
localVariableConfig
|
||||
)
|
||||
|
||||
return when (localVarResponse.responseType) {
|
||||
return{{^doNotUseRxAndCoroutines}}{{#useCoroutines}}@withContext{{/useCoroutines}}{{/doNotUseRxAndCoroutines}} when (localVarResponse.responseType) {
|
||||
ResponseType.Success -> {{#returnType}}(localVarResponse as Success<*>).data as {{{returnType}}}{{#nullableReturnType}}?{{/nullableReturnType}}{{/returnType}}{{^returnType}}Unit{{/returnType}}
|
||||
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
|
||||
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
|
||||
|
@ -55,6 +55,15 @@ import org.threeten.bp.LocalTime
|
||||
import org.threeten.bp.OffsetDateTime
|
||||
import org.threeten.bp.OffsetTime
|
||||
{{/threetenbp}}
|
||||
{{#gson}}
|
||||
import com.google.gson.reflect.TypeToken
|
||||
{{/gson}}
|
||||
{{#jackson}}
|
||||
import com.fasterxml.jackson.core.type.TypeReference
|
||||
{{/jackson}}
|
||||
{{#moshi}}
|
||||
import com.squareup.moshi.adapter
|
||||
{{/moshi}}
|
||||
|
||||
{{#nonPublicApi}}internal {{/nonPublicApi}}open class ApiClient(val baseUrl: String) {
|
||||
{{#nonPublicApi}}internal {{/nonPublicApi}}companion object {
|
||||
@ -173,6 +182,9 @@ import org.threeten.bp.OffsetTime
|
||||
else -> throw UnsupportedOperationException("requestBody currently only supports JSON body and File body.")
|
||||
}
|
||||
|
||||
{{#moshi}}
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
{{/moshi}}
|
||||
protected inline fun <reified T: Any?> responseBody(body: ResponseBody?, mediaType: String? = JsonMediaType): T? {
|
||||
if(body == null) {
|
||||
return null
|
||||
@ -201,7 +213,7 @@ import org.threeten.bp.OffsetTime
|
||||
return f as T
|
||||
}
|
||||
return when(mediaType) {
|
||||
JsonMediaType -> {{#moshi}}Serializer.moshi.adapter(T::class.java).fromJson(bodyContent){{/moshi}}{{#gson}}Serializer.gson.fromJson(bodyContent, T::class.java){{/gson}}{{#jackson}}Serializer.jacksonObjectMapper.readValue(bodyContent, T::class.java){{/jackson}}{{#kotlinx_serialization}}Serializer.jvmJson.decodeFromString<T>(bodyContent){{/kotlinx_serialization}}
|
||||
JsonMediaType -> {{#moshi}}Serializer.moshi.adapter<T>().fromJson(bodyContent){{/moshi}}{{#gson}}Serializer.gson.fromJson(bodyContent, (object: TypeToken<T>(){}).getType()){{/gson}}{{#jackson}}Serializer.jacksonObjectMapper.readValue(bodyContent, object: TypeReference<T>() {}){{/jackson}}{{#kotlinx_serialization}}Serializer.jvmJson.decodeFromString<T>(bodyContent){{/kotlinx_serialization}}
|
||||
else -> throw UnsupportedOperationException("responseBody currently only supports JSON body.")
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{{#useBeanValidation}}{{>beanValidation}}{{>beanValidationModel}}{{/useBeanValidation}}{{#swaggerAnnotations}}
|
||||
@ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}value = "{{{description}}}"){{/swaggerAnnotations}}{{#deprecated}}
|
||||
@Deprecated(message = ""){{/deprecated}}
|
||||
@field:JsonProperty("{{{baseName}}}"){{#isInherited}} override{{/isInherited}} {{>modelMutable}} {{{name}}}: {{#isEnum}}{{#isArray}}{{baseType}}<{{/isArray}}{{classname}}.{{nameInCamelCase}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}? = {{#defaultValue}}{{defaultValue}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}
|
||||
@field:JsonProperty("{{{baseName}}}"){{#isInherited}} override{{/isInherited}} {{>modelMutable}} {{{name}}}: {{#isEnum}}{{#isArray}}{{baseType}}<{{/isArray}}{{classname}}.{{nameInCamelCase}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}? = {{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}
|
@ -1,3 +1,3 @@
|
||||
{{#useBeanValidation}}{{>beanValidation}}{{>beanValidationModel}}{{/useBeanValidation}}{{#swaggerAnnotations}}
|
||||
@ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}required = true, {{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}value = "{{{description}}}"){{/swaggerAnnotations}}
|
||||
@field:JsonProperty("{{{baseName}}}", required = true){{#isInherited}} override{{/isInherited}} {{>modelMutable}} {{{name}}}: {{#isEnum}}{{#isArray}}{{baseType}}<{{/isArray}}{{classname}}.{{nameInCamelCase}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isReadOnly}}?{{/isReadOnly}}{{#defaultValue}} = {{defaultValue}}{{/defaultValue}}{{#isReadOnly}}{{^defaultValue}} = null{{/defaultValue}}{{/isReadOnly}}
|
||||
@field:JsonProperty("{{{baseName}}}", required = true){{#isInherited}} override{{/isInherited}} {{>modelMutable}} {{{name}}}: {{#isEnum}}{{#isArray}}{{baseType}}<{{/isArray}}{{classname}}.{{nameInCamelCase}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isReadOnly}}?{{/isReadOnly}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}{{#isReadOnly}}{{^defaultValue}} = null{{/defaultValue}}{{/isReadOnly}}
|
@ -3,7 +3,6 @@ language: php
|
||||
# https://docs.travis-ci.com/user/reference/bionic/#php-support
|
||||
dist: bionic
|
||||
php:
|
||||
- 7.2
|
||||
- 7.3
|
||||
- 7.4
|
||||
before_install: "composer install"
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* ApiException
|
||||
* PHP version 7.2
|
||||
* PHP version 7.3
|
||||
*
|
||||
* @category Class
|
||||
* @package {{invokerPackage}}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Configuration
|
||||
* PHP version 7.2
|
||||
* PHP version 7.3
|
||||
*
|
||||
* @category Class
|
||||
* @package {{invokerPackage}}
|
||||
@ -20,7 +20,7 @@ namespace {{invokerPackage}};
|
||||
|
||||
/**
|
||||
* Configuration Class Doc Comment
|
||||
* PHP version 7.2
|
||||
* PHP version 7.3
|
||||
*
|
||||
* @category Class
|
||||
* @package {{invokerPackage}}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* ApiException
|
||||
* PHP version 7.2
|
||||
* PHP version 7.3
|
||||
*
|
||||
* @category Class
|
||||
* @package {{invokerPackage}}
|
||||
|
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* ModelInterface
|
||||
*
|
||||
* PHP version 7.2
|
||||
* PHP version 7.3
|
||||
*
|
||||
* @category Class
|
||||
* @package {{modelPackage}}
|
||||
|
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* ObjectSerializer
|
||||
*
|
||||
* PHP version 7.2
|
||||
* PHP version 7.3
|
||||
*
|
||||
* @category Class
|
||||
* @package {{invokerPackage}}
|
||||
|
@ -12,7 +12,8 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}).
|
||||
|
||||
### Requirements
|
||||
|
||||
PHP 7.2 and later.
|
||||
PHP 7.3 and later.
|
||||
Should also work with PHP 8.0 but has not been tested.
|
||||
|
||||
### Composer
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* {{classname}}
|
||||
* PHP version 7.2
|
||||
* PHP version 7.3
|
||||
*
|
||||
* @category Class
|
||||
* @package {{invokerPackage}}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* {{classname}}Test
|
||||
* PHP version 7.2
|
||||
* PHP version 7.3
|
||||
*
|
||||
* @category Class
|
||||
* @package {{invokerPackage}}
|
||||
|
@ -1,5 +1,7 @@
|
||||
{
|
||||
"name": "{{gitUserId}}/{{gitRepoId}}",
|
||||
{{#composerPackageName}}
|
||||
"name": "{{composerPackageName}}",
|
||||
{{/composerPackageName}}
|
||||
{{#artifactVersion}}
|
||||
"version": "{{artifactVersion}}",
|
||||
{{/artifactVersion}}
|
||||
@ -22,7 +24,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.2",
|
||||
"php": "^7.3 || ^8.0",
|
||||
"ext-curl": "*",
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
|
@ -4,7 +4,7 @@
|
||||
/**
|
||||
* {{classname}}
|
||||
*
|
||||
* PHP version 7.2
|
||||
* PHP version 7.3
|
||||
*
|
||||
* @category Class
|
||||
* @package {{invokerPackage}}
|
||||
|
@ -4,7 +4,7 @@
|
||||
/**
|
||||
* {{classname}}Test
|
||||
*
|
||||
* PHP version 7.2
|
||||
* PHP version 7.3
|
||||
*
|
||||
* @category Class
|
||||
* @package {{invokerPackage}}
|
||||
|
@ -4,6 +4,9 @@ rvm:
|
||||
- 2.3
|
||||
- 2.4
|
||||
- 2.5
|
||||
- 2.6
|
||||
- 2.7
|
||||
- 3.0
|
||||
script:
|
||||
- bundle install --path vendor/bundle
|
||||
- bundle exec rspec
|
||||
|
@ -251,6 +251,12 @@ extension {{projectName}} {
|
||||
{{#queryParams}}
|
||||
var {{paramName}}: {{#isEnum}}{{#isArray}}[{{enumName}}_{{operationId}}]{{/isArray}}{{^isArray}}{{#isContainer}}{{{dataType}}}{{/isContainer}}{{^isContainer}}{{{datatypeWithEnum}}}_{{operationId}}{{/isContainer}}{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{^required}}?{{/required}}
|
||||
{{/queryParams}}
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
{{#queryParams}}
|
||||
case {{paramName}}{{#baseName}} = "{{baseName}}"{{/baseName}}
|
||||
{{/queryParams}}
|
||||
}
|
||||
}
|
||||
try localVariableRequest.query.encode(QueryParams({{#queryParams}}{{paramName}}: {{paramName}}{{^-last}}, {{/-last}}{{/queryParams}})){{/hasQueryParams}}
|
||||
{{#hasBodyParam}}
|
||||
|
@ -277,7 +277,7 @@ private var managerStore = SynchronizedDictionary<String, Alamofire.SessionManag
|
||||
|
||||
let filenameKey = "filename="
|
||||
guard let range = contentItem.range(of: filenameKey) else {
|
||||
break
|
||||
continue
|
||||
}
|
||||
|
||||
filename = contentItem
|
||||
|
@ -270,7 +270,7 @@ private var urlSessionStore = SynchronizedDictionary<String, URLSession>()
|
||||
|
||||
let filenameKey = "filename="
|
||||
guard let range = contentItem.range(of: filenameKey) else {
|
||||
break
|
||||
continue
|
||||
}
|
||||
|
||||
filename = contentItem
|
||||
|
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
* Copyright 2018 SmartBear Software
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.samskivert.mustache.Mustache.Lambda;
|
||||
|
||||
import io.swagger.parser.OpenAPIParser;
|
||||
import io.swagger.v3.oas.models.Components;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.PathItem;
|
||||
import io.swagger.v3.oas.models.headers.Header;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
import io.swagger.v3.oas.models.parameters.QueryParameter;
|
||||
import io.swagger.v3.oas.models.parameters.RequestBody;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponses;
|
||||
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||
import io.swagger.v3.parser.core.models.ParseOptions;
|
||||
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.config.CodegenConfigurator;
|
||||
import org.openapitools.codegen.config.GlobalSettings;
|
||||
import org.openapitools.codegen.languages.AbstractCSharpCodegen;
|
||||
import org.openapitools.codegen.languages.AspNetCoreServerCodegen;
|
||||
import org.openapitools.codegen.languages.CSharpNetCoreClientCodegen;
|
||||
import org.openapitools.codegen.templating.mustache.CamelCaseLambda;
|
||||
import org.openapitools.codegen.templating.mustache.IndentedLambda;
|
||||
import org.openapitools.codegen.templating.mustache.LowercaseLambda;
|
||||
import org.openapitools.codegen.templating.mustache.TitlecaseLambda;
|
||||
import org.openapitools.codegen.templating.mustache.UppercaseLambda;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.utils.SemVer;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.util.*;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.accessibility.AccessibleAttributeSequence;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
public class CSharpOperationTest {
|
||||
|
||||
@Test
|
||||
public void assertMethodOptionalParameterDataType() {
|
||||
assertEquals(getOperationOptionalParameterDataType(new AspNetCoreServerCodegen(), 2, false), "System.IO.Stream");
|
||||
assertEquals(getOperationOptionalParameterDataType(new AspNetCoreServerCodegen(), 2, true), "System.IO.Stream?");
|
||||
assertEquals(getOperationOptionalParameterDataType(new AspNetCoreServerCodegen(), 3, false), "System.IO.Stream");
|
||||
assertEquals(getOperationOptionalParameterDataType(new AspNetCoreServerCodegen(), 3, true), "System.IO.Stream?");
|
||||
|
||||
assertEquals(getOperationOptionalParameterDataType(new CSharpNetCoreClientCodegen(), 2, false), "System.IO.Stream");
|
||||
assertEquals(getOperationOptionalParameterDataType(new CSharpNetCoreClientCodegen(), 2, true), "System.IO.Stream?");
|
||||
assertEquals(getOperationOptionalParameterDataType(new CSharpNetCoreClientCodegen(), 3, false), "System.IO.Stream");
|
||||
assertEquals(getOperationOptionalParameterDataType(new CSharpNetCoreClientCodegen(), 3, true), "System.IO.Stream?");
|
||||
}
|
||||
|
||||
public String getOperationOptionalParameterDataType(final AbstractCSharpCodegen codegen, final int openApiVersion, final Boolean nullableReferenceTypes){
|
||||
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/" + Integer.toString(openApiVersion) + "_0/petstore-with-fake-endpoints-models-for-testing.yaml");
|
||||
codegen.setNullableReferenceTypes(nullableReferenceTypes);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
|
||||
final String path = "/pet/{petId}/uploadImage";
|
||||
final Operation postOperation = openAPI.getPaths().get(path).getPost();
|
||||
final CodegenOperation codegenOperation = codegen.fromOperation(path, "post", postOperation, null);
|
||||
|
||||
return codegenOperation.allParams.get(2).dataType;
|
||||
}
|
||||
}
|
@ -22,10 +22,8 @@ import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponses;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.CodegenResponse;
|
||||
import org.openapitools.codegen.TestUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.languages.AbstractJavaCodegen;
|
||||
import org.openapitools.codegen.languages.JavaCXFClientCodegen;
|
||||
import org.openapitools.codegen.languages.features.BeanValidationFeatures;
|
||||
import org.openapitools.codegen.languages.features.GzipTestFeatures;
|
||||
@ -179,4 +177,121 @@ public class JavaCXFClientCodegenTest {
|
||||
Assert.assertTrue(codegen.isUseGzipFeatureForTests());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOpenApiNullableAdditionalProperty() throws Exception {
|
||||
JavaCXFClientCodegen codegen = new JavaCXFClientCodegen();
|
||||
|
||||
codegen.processOpts();
|
||||
Assert.assertNotNull(codegen.additionalProperties().get(AbstractJavaCodegen.OPENAPI_NULLABLE));
|
||||
Assert.assertTrue(codegen.isOpenApiNullable());
|
||||
|
||||
codegen.additionalProperties().put(AbstractJavaCodegen.OPENAPI_NULLABLE, false);
|
||||
codegen.processOpts();
|
||||
Assert.assertEquals(codegen.additionalProperties().get(AbstractJavaCodegen.OPENAPI_NULLABLE), Boolean.FALSE);
|
||||
Assert.assertFalse(codegen.isOpenApiNullable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPostProcessNullableModelPropertyWithOpenApiNullableEnabled() throws Exception {
|
||||
JavaCXFClientCodegen codegen = new JavaCXFClientCodegen();
|
||||
codegen.additionalProperties().put(AbstractJavaCodegen.JACKSON, true);
|
||||
codegen.additionalProperties().put(AbstractJavaCodegen.OPENAPI_NULLABLE, true);
|
||||
codegen.processOpts();
|
||||
|
||||
CodegenModel codegenModel = new CodegenModel();
|
||||
CodegenProperty codegenProperty = new CodegenProperty();
|
||||
codegenProperty.required = false;
|
||||
codegenProperty.isNullable = true;
|
||||
|
||||
codegen.postProcessModelProperty(codegenModel, codegenProperty);
|
||||
Assert.assertTrue(codegenModel.imports.contains("JsonNullable"));
|
||||
Assert.assertTrue(codegenModel.imports.contains("JsonIgnore"));
|
||||
Assert.assertEquals(codegenProperty.getVendorExtensions().get("x-is-jackson-optional-nullable"), Boolean.TRUE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPostProcessNullableModelPropertyWithOpenApiNullableDisabled() throws Exception {
|
||||
JavaCXFClientCodegen codegen = new JavaCXFClientCodegen();
|
||||
codegen.additionalProperties().put(AbstractJavaCodegen.JACKSON, true);
|
||||
codegen.additionalProperties().put(AbstractJavaCodegen.OPENAPI_NULLABLE, false);
|
||||
codegen.processOpts();
|
||||
|
||||
CodegenModel codegenModel = new CodegenModel();
|
||||
CodegenProperty codegenProperty = new CodegenProperty();
|
||||
codegenProperty.required = false;
|
||||
codegenProperty.isNullable = true;
|
||||
|
||||
codegen.postProcessModelProperty(codegenModel, codegenProperty);
|
||||
Assert.assertFalse(codegenModel.imports.contains("JsonNullable"));
|
||||
Assert.assertFalse(codegenModel.imports.contains("JsonIgnore"));
|
||||
Assert.assertNull(codegenProperty.getVendorExtensions().get("x-is-jackson-optional-nullable"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPostProcessNullableModelPropertyWithOpenApiNullableEnabledForRequiredProperties() throws Exception {
|
||||
JavaCXFClientCodegen codegen = new JavaCXFClientCodegen();
|
||||
codegen.additionalProperties().put(AbstractJavaCodegen.JACKSON, true);
|
||||
codegen.additionalProperties().put(AbstractJavaCodegen.OPENAPI_NULLABLE, true);
|
||||
codegen.processOpts();
|
||||
|
||||
CodegenModel codegenModel = new CodegenModel();
|
||||
CodegenProperty codegenProperty = new CodegenProperty();
|
||||
codegenProperty.required = true;
|
||||
codegenProperty.isNullable = true;
|
||||
|
||||
codegen.postProcessModelProperty(codegenModel, codegenProperty);
|
||||
Assert.assertFalse(codegenModel.imports.contains("JsonNullable"));
|
||||
Assert.assertFalse(codegenModel.imports.contains("JsonIgnore"));
|
||||
Assert.assertNull(codegenProperty.getVendorExtensions().get("x-is-jackson-optional-nullable"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPostProcessNotNullableModelPropertyWithOpenApiNullableEnabled() throws Exception {
|
||||
JavaCXFClientCodegen codegen = new JavaCXFClientCodegen();
|
||||
codegen.additionalProperties().put(AbstractJavaCodegen.JACKSON, true);
|
||||
codegen.additionalProperties().put(AbstractJavaCodegen.OPENAPI_NULLABLE, true);
|
||||
codegen.processOpts();
|
||||
|
||||
CodegenModel codegenModel = new CodegenModel();
|
||||
CodegenProperty codegenProperty = new CodegenProperty();
|
||||
codegenProperty.required = false;
|
||||
codegenProperty.isNullable = false;
|
||||
|
||||
codegen.postProcessModelProperty(codegenModel, codegenProperty);
|
||||
Assert.assertFalse(codegenModel.imports.contains("JsonNullable"));
|
||||
Assert.assertFalse(codegenModel.imports.contains("JsonIgnore"));
|
||||
Assert.assertNull(codegenProperty.getVendorExtensions().get("x-is-jackson-optional-nullable"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPostProcessNullableModelPropertyWithOpenApiNullableEnabledButJacksonDisabled() throws Exception {
|
||||
JavaCXFClientCodegen codegen = new JavaCXFClientCodegen();
|
||||
codegen.additionalProperties().put(AbstractJavaCodegen.JACKSON, false);
|
||||
codegen.additionalProperties().put(AbstractJavaCodegen.OPENAPI_NULLABLE, true);
|
||||
codegen.processOpts();
|
||||
|
||||
CodegenModel codegenModel = new CodegenModel();
|
||||
CodegenProperty codegenProperty = new CodegenProperty();
|
||||
codegenProperty.required = false;
|
||||
codegenProperty.isNullable = true;
|
||||
|
||||
codegen.postProcessModelProperty(codegenModel, codegenProperty);
|
||||
Assert.assertFalse(codegenModel.imports.contains("JsonNullable"));
|
||||
Assert.assertFalse(codegenModel.imports.contains("JsonIgnore"));
|
||||
Assert.assertNull(codegenProperty.getVendorExtensions().get("x-is-jackson-optional-nullable"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUseJackson() throws Exception {
|
||||
JavaCXFClientCodegen codegen = new JavaCXFClientCodegen();
|
||||
|
||||
codegen.processOpts();
|
||||
Assert.assertNull(codegen.additionalProperties().get(AbstractJavaCodegen.JACKSON));
|
||||
Assert.assertFalse(codegen.isUseJackson());
|
||||
|
||||
codegen.additionalProperties().put(AbstractJavaCodegen.JACKSON, true);
|
||||
codegen.processOpts();
|
||||
Assert.assertEquals(codegen.additionalProperties().get(AbstractJavaCodegen.JACKSON), Boolean.TRUE);
|
||||
Assert.assertTrue(codegen.isUseJackson());
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import java.nio.file.Paths;
|
||||
|
||||
import static org.openapitools.codegen.TestUtils.assertFileContains;
|
||||
import static org.openapitools.codegen.TestUtils.assertFileNotContains;
|
||||
import static org.openapitools.codegen.languages.AbstractJavaCodegen.JACKSON;
|
||||
|
||||
public abstract class JavaJaxrsBaseTest {
|
||||
|
||||
@ -59,7 +60,7 @@ public abstract class JavaJaxrsBaseTest {
|
||||
|
||||
@Test
|
||||
public void doNotGenerateJsonAnnotationForPolymorphismIfJsonExclude() throws IOException {
|
||||
codegen.additionalProperties().put("jackson", false);
|
||||
codegen.additionalProperties().put(JACKSON, false);
|
||||
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||
output.deleteOnExit();
|
||||
String outputPath = output.getAbsolutePath().replace('\\', '/');
|
||||
|
@ -22,6 +22,7 @@ import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.languages.AbstractPhpCodegen;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
@ -100,6 +101,27 @@ public class AbstractPhpCodegenTest {
|
||||
Assert.assertEquals(codegenOperation.produces.get(1).get("mediaType"), "application/json");
|
||||
}
|
||||
|
||||
@Test(dataProvider = "composerNames", description = "Issue #9998")
|
||||
public void testGetComposerPackageName(String gitUserId, String gitRepoId, String result) {
|
||||
final AbstractPhpCodegen codegen = new P_AbstractPhpCodegen();
|
||||
codegen.processOpts();
|
||||
|
||||
codegen.setGitUserId(gitUserId);
|
||||
codegen.setGitRepoId(gitRepoId);
|
||||
Assert.assertEquals(codegen.getComposerPackageName(), result);
|
||||
}
|
||||
|
||||
@DataProvider(name = "composerNames")
|
||||
public static Object[][] composerNames() {
|
||||
return new Object[][] {
|
||||
{"", "", ""},
|
||||
{"null", "null", ""},
|
||||
{"GIT_REPO_ID", "GIT_USER_ID", ""},
|
||||
{"git_repo_id", "git_user_id", "git_repo_id/git_user_id"},
|
||||
{"foo", "bar", "foo/bar"},
|
||||
};
|
||||
}
|
||||
|
||||
private static class P_AbstractPhpCodegen extends AbstractPhpCodegen {
|
||||
@Override
|
||||
public CodegenType getTag() {
|
||||
|
@ -2121,3 +2121,24 @@ components:
|
||||
default: '2010-01-01T10:10:10.000111+01:00'
|
||||
example: '2010-01-01T10:10:10.000111+01:00'
|
||||
format: date-time
|
||||
DeprecatedObject:
|
||||
type: object
|
||||
deprecated: true
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
ObjectWithDeprecatedFields:
|
||||
type: object
|
||||
properties:
|
||||
uuid:
|
||||
type: string
|
||||
id:
|
||||
type: number
|
||||
deprecated: true
|
||||
deprecatedRef:
|
||||
$ref: '#/components/schemas/DeprecatedObject'
|
||||
bars:
|
||||
type: array
|
||||
deprecated: true
|
||||
items:
|
||||
$ref: '#/components/schemas/Bar'
|
||||
|
@ -1862,3 +1862,24 @@ components:
|
||||
properties:
|
||||
value:
|
||||
$ref: '#/components/schemas/OuterEnumInteger'
|
||||
DeprecatedObject:
|
||||
type: object
|
||||
deprecated: true
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
ObjectWithDeprecatedFields:
|
||||
type: object
|
||||
properties:
|
||||
uuid:
|
||||
type: string
|
||||
id:
|
||||
type: number
|
||||
deprecated: true
|
||||
deprecatedRef:
|
||||
$ref: '#/components/schemas/DeprecatedObject'
|
||||
bars:
|
||||
type: array
|
||||
deprecated: true
|
||||
items:
|
||||
$ref: '#/components/schemas/Bar'
|
||||
|
@ -1779,6 +1779,12 @@ components:
|
||||
enum:
|
||||
- 1.1
|
||||
- -1.2
|
||||
enum_bool:
|
||||
type: boolean
|
||||
enum:
|
||||
- false
|
||||
boolEnum:
|
||||
$ref: '#/components/schemas/BooleanEnum'
|
||||
stringEnum:
|
||||
$ref: '#/components/schemas/StringEnum'
|
||||
IntegerEnum:
|
||||
@ -2445,3 +2451,7 @@ components:
|
||||
type: boolean
|
||||
seeingGhosts:
|
||||
type: boolean
|
||||
BooleanEnum:
|
||||
type: boolean
|
||||
enum:
|
||||
- true
|
@ -1 +1 @@
|
||||
5.1.1-SNAPSHOT
|
||||
5.2.1-SNAPSHOT
|
@ -36,6 +36,30 @@ inline FString ToString(const OpenAPIOrder::StatusEnum& Value)
|
||||
return TEXT("");
|
||||
}
|
||||
|
||||
FString OpenAPIOrder::EnumToString(const OpenAPIOrder::StatusEnum& EnumValue)
|
||||
{
|
||||
return ToString(EnumValue);
|
||||
}
|
||||
|
||||
inline bool FromString(const FString& EnumAsString, OpenAPIOrder::StatusEnum& Value)
|
||||
{
|
||||
static TMap<FString, OpenAPIOrder::StatusEnum> StringToEnum = {
|
||||
{ TEXT("placed"), OpenAPIOrder::StatusEnum::Placed },
|
||||
{ TEXT("approved"), OpenAPIOrder::StatusEnum::Approved },
|
||||
{ TEXT("delivered"), OpenAPIOrder::StatusEnum::Delivered }, };
|
||||
|
||||
const auto Found = StringToEnum.Find(EnumAsString);
|
||||
if(Found)
|
||||
Value = *Found;
|
||||
|
||||
return Found != nullptr;
|
||||
}
|
||||
|
||||
bool OpenAPIOrder::EnumFromString(const FString& EnumAsString, OpenAPIOrder::StatusEnum& EnumValue)
|
||||
{
|
||||
return FromString(EnumAsString, EnumValue);
|
||||
}
|
||||
|
||||
inline FStringFormatArg ToStringFormatArg(const OpenAPIOrder::StatusEnum& Value)
|
||||
{
|
||||
return FStringFormatArg(ToString(Value));
|
||||
@ -51,18 +75,9 @@ inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, OpenAPIOrde
|
||||
FString TmpValue;
|
||||
if (JsonValue->TryGetString(TmpValue))
|
||||
{
|
||||
static TMap<FString, OpenAPIOrder::StatusEnum> StringToEnum = {
|
||||
{ TEXT("placed"), OpenAPIOrder::StatusEnum::Placed },
|
||||
{ TEXT("approved"), OpenAPIOrder::StatusEnum::Approved },
|
||||
{ TEXT("delivered"), OpenAPIOrder::StatusEnum::Delivered }, };
|
||||
|
||||
const auto Found = StringToEnum.Find(TmpValue);
|
||||
if(Found)
|
||||
{
|
||||
Value = *Found;
|
||||
if(FromString(TmpValue, Value))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,30 @@ inline FString ToString(const OpenAPIPet::StatusEnum& Value)
|
||||
return TEXT("");
|
||||
}
|
||||
|
||||
FString OpenAPIPet::EnumToString(const OpenAPIPet::StatusEnum& EnumValue)
|
||||
{
|
||||
return ToString(EnumValue);
|
||||
}
|
||||
|
||||
inline bool FromString(const FString& EnumAsString, OpenAPIPet::StatusEnum& Value)
|
||||
{
|
||||
static TMap<FString, OpenAPIPet::StatusEnum> StringToEnum = {
|
||||
{ TEXT("available"), OpenAPIPet::StatusEnum::Available },
|
||||
{ TEXT("pending"), OpenAPIPet::StatusEnum::Pending },
|
||||
{ TEXT("sold"), OpenAPIPet::StatusEnum::Sold }, };
|
||||
|
||||
const auto Found = StringToEnum.Find(EnumAsString);
|
||||
if(Found)
|
||||
Value = *Found;
|
||||
|
||||
return Found != nullptr;
|
||||
}
|
||||
|
||||
bool OpenAPIPet::EnumFromString(const FString& EnumAsString, OpenAPIPet::StatusEnum& EnumValue)
|
||||
{
|
||||
return FromString(EnumAsString, EnumValue);
|
||||
}
|
||||
|
||||
inline FStringFormatArg ToStringFormatArg(const OpenAPIPet::StatusEnum& Value)
|
||||
{
|
||||
return FStringFormatArg(ToString(Value));
|
||||
@ -51,18 +75,9 @@ inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, OpenAPIPet:
|
||||
FString TmpValue;
|
||||
if (JsonValue->TryGetString(TmpValue))
|
||||
{
|
||||
static TMap<FString, OpenAPIPet::StatusEnum> StringToEnum = {
|
||||
{ TEXT("available"), OpenAPIPet::StatusEnum::Available },
|
||||
{ TEXT("pending"), OpenAPIPet::StatusEnum::Pending },
|
||||
{ TEXT("sold"), OpenAPIPet::StatusEnum::Sold }, };
|
||||
|
||||
const auto Found = StringToEnum.Find(TmpValue);
|
||||
if(Found)
|
||||
{
|
||||
Value = *Found;
|
||||
if(FromString(TmpValue, Value))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -132,10 +132,10 @@ void OpenAPIPetApi::HandleResponse(FHttpResponsePtr HttpResponse, bool bSucceede
|
||||
InOutResponse.SetHttpResponseCode(EHttpResponseCodes::RequestTimeout);
|
||||
}
|
||||
|
||||
bool OpenAPIPetApi::AddPet(const AddPetRequest& Request, const FAddPetDelegate& Delegate /*= FAddPetDelegate()*/) const
|
||||
FHttpRequestPtr OpenAPIPetApi::AddPet(const AddPetRequest& Request, const FAddPetDelegate& Delegate /*= FAddPetDelegate()*/) const
|
||||
{
|
||||
if (!IsValid())
|
||||
return false;
|
||||
return nullptr;
|
||||
|
||||
FHttpRequestRef HttpRequest = CreateHttpRequest(Request);
|
||||
HttpRequest->SetURL(*(Url + Request.ComputePath()));
|
||||
@ -148,7 +148,8 @@ bool OpenAPIPetApi::AddPet(const AddPetRequest& Request, const FAddPetDelegate&
|
||||
Request.SetupHttpRequest(HttpRequest);
|
||||
|
||||
HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnAddPetResponse, Delegate);
|
||||
return HttpRequest->ProcessRequest();
|
||||
HttpRequest->ProcessRequest();
|
||||
return HttpRequest;
|
||||
}
|
||||
|
||||
void OpenAPIPetApi::OnAddPetResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FAddPetDelegate Delegate) const
|
||||
@ -158,10 +159,10 @@ void OpenAPIPetApi::OnAddPetResponse(FHttpRequestPtr HttpRequest, FHttpResponseP
|
||||
Delegate.ExecuteIfBound(Response);
|
||||
}
|
||||
|
||||
bool OpenAPIPetApi::DeletePet(const DeletePetRequest& Request, const FDeletePetDelegate& Delegate /*= FDeletePetDelegate()*/) const
|
||||
FHttpRequestPtr OpenAPIPetApi::DeletePet(const DeletePetRequest& Request, const FDeletePetDelegate& Delegate /*= FDeletePetDelegate()*/) const
|
||||
{
|
||||
if (!IsValid())
|
||||
return false;
|
||||
return nullptr;
|
||||
|
||||
FHttpRequestRef HttpRequest = CreateHttpRequest(Request);
|
||||
HttpRequest->SetURL(*(Url + Request.ComputePath()));
|
||||
@ -174,7 +175,8 @@ bool OpenAPIPetApi::DeletePet(const DeletePetRequest& Request, const FDeletePetD
|
||||
Request.SetupHttpRequest(HttpRequest);
|
||||
|
||||
HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnDeletePetResponse, Delegate);
|
||||
return HttpRequest->ProcessRequest();
|
||||
HttpRequest->ProcessRequest();
|
||||
return HttpRequest;
|
||||
}
|
||||
|
||||
void OpenAPIPetApi::OnDeletePetResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FDeletePetDelegate Delegate) const
|
||||
@ -184,10 +186,10 @@ void OpenAPIPetApi::OnDeletePetResponse(FHttpRequestPtr HttpRequest, FHttpRespon
|
||||
Delegate.ExecuteIfBound(Response);
|
||||
}
|
||||
|
||||
bool OpenAPIPetApi::FindPetsByStatus(const FindPetsByStatusRequest& Request, const FFindPetsByStatusDelegate& Delegate /*= FFindPetsByStatusDelegate()*/) const
|
||||
FHttpRequestPtr OpenAPIPetApi::FindPetsByStatus(const FindPetsByStatusRequest& Request, const FFindPetsByStatusDelegate& Delegate /*= FFindPetsByStatusDelegate()*/) const
|
||||
{
|
||||
if (!IsValid())
|
||||
return false;
|
||||
return nullptr;
|
||||
|
||||
FHttpRequestRef HttpRequest = CreateHttpRequest(Request);
|
||||
HttpRequest->SetURL(*(Url + Request.ComputePath()));
|
||||
@ -200,7 +202,8 @@ bool OpenAPIPetApi::FindPetsByStatus(const FindPetsByStatusRequest& Request, con
|
||||
Request.SetupHttpRequest(HttpRequest);
|
||||
|
||||
HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnFindPetsByStatusResponse, Delegate);
|
||||
return HttpRequest->ProcessRequest();
|
||||
HttpRequest->ProcessRequest();
|
||||
return HttpRequest;
|
||||
}
|
||||
|
||||
void OpenAPIPetApi::OnFindPetsByStatusResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FFindPetsByStatusDelegate Delegate) const
|
||||
@ -210,10 +213,10 @@ void OpenAPIPetApi::OnFindPetsByStatusResponse(FHttpRequestPtr HttpRequest, FHtt
|
||||
Delegate.ExecuteIfBound(Response);
|
||||
}
|
||||
|
||||
bool OpenAPIPetApi::FindPetsByTags(const FindPetsByTagsRequest& Request, const FFindPetsByTagsDelegate& Delegate /*= FFindPetsByTagsDelegate()*/) const
|
||||
FHttpRequestPtr OpenAPIPetApi::FindPetsByTags(const FindPetsByTagsRequest& Request, const FFindPetsByTagsDelegate& Delegate /*= FFindPetsByTagsDelegate()*/) const
|
||||
{
|
||||
if (!IsValid())
|
||||
return false;
|
||||
return nullptr;
|
||||
|
||||
FHttpRequestRef HttpRequest = CreateHttpRequest(Request);
|
||||
HttpRequest->SetURL(*(Url + Request.ComputePath()));
|
||||
@ -226,7 +229,8 @@ bool OpenAPIPetApi::FindPetsByTags(const FindPetsByTagsRequest& Request, const F
|
||||
Request.SetupHttpRequest(HttpRequest);
|
||||
|
||||
HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnFindPetsByTagsResponse, Delegate);
|
||||
return HttpRequest->ProcessRequest();
|
||||
HttpRequest->ProcessRequest();
|
||||
return HttpRequest;
|
||||
}
|
||||
|
||||
void OpenAPIPetApi::OnFindPetsByTagsResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FFindPetsByTagsDelegate Delegate) const
|
||||
@ -236,10 +240,10 @@ void OpenAPIPetApi::OnFindPetsByTagsResponse(FHttpRequestPtr HttpRequest, FHttpR
|
||||
Delegate.ExecuteIfBound(Response);
|
||||
}
|
||||
|
||||
bool OpenAPIPetApi::GetPetById(const GetPetByIdRequest& Request, const FGetPetByIdDelegate& Delegate /*= FGetPetByIdDelegate()*/) const
|
||||
FHttpRequestPtr OpenAPIPetApi::GetPetById(const GetPetByIdRequest& Request, const FGetPetByIdDelegate& Delegate /*= FGetPetByIdDelegate()*/) const
|
||||
{
|
||||
if (!IsValid())
|
||||
return false;
|
||||
return nullptr;
|
||||
|
||||
FHttpRequestRef HttpRequest = CreateHttpRequest(Request);
|
||||
HttpRequest->SetURL(*(Url + Request.ComputePath()));
|
||||
@ -252,7 +256,8 @@ bool OpenAPIPetApi::GetPetById(const GetPetByIdRequest& Request, const FGetPetBy
|
||||
Request.SetupHttpRequest(HttpRequest);
|
||||
|
||||
HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnGetPetByIdResponse, Delegate);
|
||||
return HttpRequest->ProcessRequest();
|
||||
HttpRequest->ProcessRequest();
|
||||
return HttpRequest;
|
||||
}
|
||||
|
||||
void OpenAPIPetApi::OnGetPetByIdResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FGetPetByIdDelegate Delegate) const
|
||||
@ -262,10 +267,10 @@ void OpenAPIPetApi::OnGetPetByIdResponse(FHttpRequestPtr HttpRequest, FHttpRespo
|
||||
Delegate.ExecuteIfBound(Response);
|
||||
}
|
||||
|
||||
bool OpenAPIPetApi::UpdatePet(const UpdatePetRequest& Request, const FUpdatePetDelegate& Delegate /*= FUpdatePetDelegate()*/) const
|
||||
FHttpRequestPtr OpenAPIPetApi::UpdatePet(const UpdatePetRequest& Request, const FUpdatePetDelegate& Delegate /*= FUpdatePetDelegate()*/) const
|
||||
{
|
||||
if (!IsValid())
|
||||
return false;
|
||||
return nullptr;
|
||||
|
||||
FHttpRequestRef HttpRequest = CreateHttpRequest(Request);
|
||||
HttpRequest->SetURL(*(Url + Request.ComputePath()));
|
||||
@ -278,7 +283,8 @@ bool OpenAPIPetApi::UpdatePet(const UpdatePetRequest& Request, const FUpdatePetD
|
||||
Request.SetupHttpRequest(HttpRequest);
|
||||
|
||||
HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnUpdatePetResponse, Delegate);
|
||||
return HttpRequest->ProcessRequest();
|
||||
HttpRequest->ProcessRequest();
|
||||
return HttpRequest;
|
||||
}
|
||||
|
||||
void OpenAPIPetApi::OnUpdatePetResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FUpdatePetDelegate Delegate) const
|
||||
@ -288,10 +294,10 @@ void OpenAPIPetApi::OnUpdatePetResponse(FHttpRequestPtr HttpRequest, FHttpRespon
|
||||
Delegate.ExecuteIfBound(Response);
|
||||
}
|
||||
|
||||
bool OpenAPIPetApi::UpdatePetWithForm(const UpdatePetWithFormRequest& Request, const FUpdatePetWithFormDelegate& Delegate /*= FUpdatePetWithFormDelegate()*/) const
|
||||
FHttpRequestPtr OpenAPIPetApi::UpdatePetWithForm(const UpdatePetWithFormRequest& Request, const FUpdatePetWithFormDelegate& Delegate /*= FUpdatePetWithFormDelegate()*/) const
|
||||
{
|
||||
if (!IsValid())
|
||||
return false;
|
||||
return nullptr;
|
||||
|
||||
FHttpRequestRef HttpRequest = CreateHttpRequest(Request);
|
||||
HttpRequest->SetURL(*(Url + Request.ComputePath()));
|
||||
@ -304,7 +310,8 @@ bool OpenAPIPetApi::UpdatePetWithForm(const UpdatePetWithFormRequest& Request, c
|
||||
Request.SetupHttpRequest(HttpRequest);
|
||||
|
||||
HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnUpdatePetWithFormResponse, Delegate);
|
||||
return HttpRequest->ProcessRequest();
|
||||
HttpRequest->ProcessRequest();
|
||||
return HttpRequest;
|
||||
}
|
||||
|
||||
void OpenAPIPetApi::OnUpdatePetWithFormResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FUpdatePetWithFormDelegate Delegate) const
|
||||
@ -314,10 +321,10 @@ void OpenAPIPetApi::OnUpdatePetWithFormResponse(FHttpRequestPtr HttpRequest, FHt
|
||||
Delegate.ExecuteIfBound(Response);
|
||||
}
|
||||
|
||||
bool OpenAPIPetApi::UploadFile(const UploadFileRequest& Request, const FUploadFileDelegate& Delegate /*= FUploadFileDelegate()*/) const
|
||||
FHttpRequestPtr OpenAPIPetApi::UploadFile(const UploadFileRequest& Request, const FUploadFileDelegate& Delegate /*= FUploadFileDelegate()*/) const
|
||||
{
|
||||
if (!IsValid())
|
||||
return false;
|
||||
return nullptr;
|
||||
|
||||
FHttpRequestRef HttpRequest = CreateHttpRequest(Request);
|
||||
HttpRequest->SetURL(*(Url + Request.ComputePath()));
|
||||
@ -330,7 +337,8 @@ bool OpenAPIPetApi::UploadFile(const UploadFileRequest& Request, const FUploadFi
|
||||
Request.SetupHttpRequest(HttpRequest);
|
||||
|
||||
HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnUploadFileResponse, Delegate);
|
||||
return HttpRequest->ProcessRequest();
|
||||
HttpRequest->ProcessRequest();
|
||||
return HttpRequest;
|
||||
}
|
||||
|
||||
void OpenAPIPetApi::OnUploadFileResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FUploadFileDelegate Delegate) const
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user