forked from loafle/openapi-generator-original
Compare commits
29 Commits
v7.0.0
...
Nuglif-kot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e26400a300 | ||
|
|
bceae5695e | ||
|
|
9cc5513a1c | ||
|
|
20692aa891 | ||
|
|
35f5852cc0 | ||
|
|
134dc98a71 | ||
|
|
8386a6eaaf | ||
|
|
611a60411b | ||
|
|
b1564d8002 | ||
|
|
b14f99df92 | ||
|
|
5ab1badbef | ||
|
|
9b6e6b3e49 | ||
|
|
b5867ebf2b | ||
|
|
020415facc | ||
|
|
b457c3de70 | ||
|
|
1a654eba5c | ||
|
|
56105fbbe6 | ||
|
|
55252f4b25 | ||
|
|
21cbd1ab71 | ||
|
|
6310ecdb0f | ||
|
|
0dcd8b42b0 | ||
|
|
ec835fbd94 | ||
|
|
0f8f18e727 | ||
|
|
80121aa88f | ||
|
|
c7100b9e61 | ||
|
|
47b38469a3 | ||
|
|
82367bbeec | ||
|
|
7decab556b | ||
|
|
755eb43a49 |
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -21,5 +21,5 @@
|
||||
./bin/utils/ensure-up-to-date
|
||||
```
|
||||
Commit all changed files.
|
||||
- [ ] File the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master` (6.3.0) (minor release - breaking changes with fallbacks), `7.0.x` (breaking changes without fallbacks)
|
||||
- [ ] File the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master` (7.0.1 - patch release), `7.1.x` (minor release - breaking changes with fallbacks), `8.0.x` (breaking changes without fallbacks)
|
||||
- [ ] 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.
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`7.0.0`):
|
||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`7.0.1`):
|
||||
[](https://app.travis-ci.com/github/OpenAPITools/openapi-generator/builds)
|
||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator)
|
||||
|
||||
@@ -6,3 +6,8 @@ templateDir: modules/openapi-generator/src/main/resources/Java
|
||||
additionalProperties:
|
||||
artifactId: echo-api-native
|
||||
hideGenerationTimestamp: "true"
|
||||
|
||||
typeMappings:
|
||||
OffsetDateTime: "Instant"
|
||||
importMappings:
|
||||
OffsetDateTime: "java.time.Instant"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
generatorName: java
|
||||
outputDir: samples/client/petstore/java/resteasy
|
||||
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:
|
||||
artifactId: petstore-resteasy
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
generatorName: java
|
||||
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
|
||||
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:
|
||||
java8: true
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
generatorName: java
|
||||
outputDir: samples/client/petstore/java/resttemplate
|
||||
library: resttemplate
|
||||
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:
|
||||
artifactId: petstore-resttemplate
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
generatorName: java
|
||||
outputDir: samples/client/petstore/java/vertx
|
||||
library: vertx
|
||||
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:
|
||||
artifactId: petstore-vertx
|
||||
|
||||
@@ -85,6 +85,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|testOutput|Set output folder for models and APIs tests| |${project.build.directory}/generated-test-sources/openapi|
|
||||
|useAbstractionForFiles|Use alternative types instead of java.io.File to allow passing bytes without a file on disk. Available on resttemplate, webclient, libraries| |false|
|
||||
|useBeanValidation|Use BeanValidation API annotations| |false|
|
||||
|useEnumCaseInsensitive|Use `equalsIgnoreCase` when String for enum comparison| |false|
|
||||
|useGzipFeature|Send gzip-encoded requests| |false|
|
||||
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|
||||
|useOneOfDiscriminatorLookup|Use the discriminator's mapping in oneOf to speed up the model lookup. IMPORTANT: Validation (e.g. one and only one match in oneOf's schemas) will be skipped. Only jersey2, jersey3, native, okhttp-gson support this option.| |false|
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.0.0</version>
|
||||
<version>7.0.1-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.0.0</version>
|
||||
<version>7.0.1-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# RELEASE_VERSION
|
||||
openApiGeneratorVersion=7.0.0
|
||||
openApiGeneratorVersion=7.0.1-SNAPSHOT
|
||||
# /RELEASE_VERSION
|
||||
|
||||
# BEGIN placeholders
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.0.0</version>
|
||||
<version>7.0.1-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# RELEASE_VERSION
|
||||
openApiGeneratorVersion=7.0.0
|
||||
openApiGeneratorVersion=7.0.1-SNAPSHOT
|
||||
# /RELEASE_VERSION
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.0.0</version>
|
||||
<version>7.0.1-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.0.0</version>
|
||||
<version>7.0.1-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.0.0</version>
|
||||
<version>7.0.1-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.0.0</version>
|
||||
<version>7.0.1-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.0.0</version>
|
||||
<version>7.0.1-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.0.0</version>
|
||||
<version>7.0.1-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.0.0</version>
|
||||
<version>7.0.1-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.0.0</version>
|
||||
<version>7.0.1-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.0.0</version>
|
||||
<version>7.0.1-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -22,11 +22,13 @@ import io.swagger.v3.parser.core.models.AuthorizationValue;
|
||||
|
||||
import org.openapitools.codegen.api.TemplateDefinition;
|
||||
import org.openapitools.codegen.auth.AuthParser;
|
||||
import org.openapitools.codegen.config.GeneratorSettings;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ClientOptInput {
|
||||
private CodegenConfig config;
|
||||
private GeneratorSettings generatorSettings;
|
||||
private OpenAPI openAPI;
|
||||
private List<AuthorizationValue> auths;
|
||||
private List<TemplateDefinition> userDefinedTemplates;
|
||||
@@ -36,6 +38,11 @@ public class ClientOptInput {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ClientOptInput generatorSettings(GeneratorSettings generatorSettings) {
|
||||
this.setGeneratorSettings(generatorSettings);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ClientOptInput config(CodegenConfig codegenConfig) {
|
||||
this.setConfig(codegenConfig);
|
||||
return this;
|
||||
@@ -92,6 +99,20 @@ public class ClientOptInput {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public GeneratorSettings getGeneratorSettings() {
|
||||
return generatorSettings;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private void setGeneratorSettings(GeneratorSettings generatorSettings) {
|
||||
this.generatorSettings = generatorSettings;
|
||||
// TODO: ClientOptInputs needs to be retired
|
||||
if (this.openAPI != null) {
|
||||
this.config.setOpenAPI(this.openAPI);
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public OpenAPI getOpenAPI() {
|
||||
return openAPI;
|
||||
|
||||
@@ -89,6 +89,10 @@ public class CodegenSecurity {
|
||||
public CodegenSecurity filterByScopeNames(List<String> filterScopes) {
|
||||
CodegenSecurity filteredSecurity = new CodegenSecurity(this);
|
||||
|
||||
if (scopes == null) {
|
||||
return filteredSecurity;
|
||||
}
|
||||
|
||||
List<Map<String, Object>> returnedScopes = new ArrayList<Map<String, Object>>();
|
||||
Map<String, Object> lastScope = null;
|
||||
for (String filterScopeName : filterScopes) {
|
||||
|
||||
@@ -7496,9 +7496,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
String name = null;
|
||||
LOGGER.debug("Request body = {}", body);
|
||||
Schema schema = ModelUtils.getSchemaFromRequestBody(body);
|
||||
if (schema == null) {
|
||||
throw new RuntimeException("Request body cannot be null. Possible cause: missing schema in body parameter (OAS v2): " + body);
|
||||
}
|
||||
codegenParameter.setContent(getContent(body.getContent(), imports, "RequestBody"));
|
||||
|
||||
if (StringUtils.isNotBlank(schema.get$ref())) {
|
||||
@@ -7563,7 +7560,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
updateRequestBodyForPrimitiveType(codegenParameter, schema, bodyParameterName, imports);
|
||||
}
|
||||
|
||||
|
||||
addJsonSchemaForBodyRequestInCaseItsNotPresent(codegenParameter, body);
|
||||
|
||||
// set the parameter's example value
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.api.TemplateDefinition;
|
||||
import org.openapitools.codegen.api.TemplatePathLocator;
|
||||
import org.openapitools.codegen.api.TemplateProcessor;
|
||||
import org.openapitools.codegen.config.GeneratorSettings;
|
||||
import org.openapitools.codegen.config.GlobalSettings;
|
||||
import org.openapitools.codegen.api.TemplatingEngineAdapter;
|
||||
import org.openapitools.codegen.api.TemplateFileType;
|
||||
@@ -253,6 +254,10 @@ public class DefaultGenerator implements Generator {
|
||||
}
|
||||
|
||||
config.processOpts();
|
||||
if (opts != null && opts.getGeneratorSettings() != null) {
|
||||
config.typeMapping().putAll(opts.getGeneratorSettings().getTypeMappings());
|
||||
config.importMapping().putAll(opts.getGeneratorSettings().getImportMappings());
|
||||
}
|
||||
|
||||
// normalize the spec
|
||||
try {
|
||||
|
||||
@@ -753,6 +753,7 @@ public class CodegenConfigurator {
|
||||
|
||||
ClientOptInput input = new ClientOptInput()
|
||||
.config(config)
|
||||
.generatorSettings(generatorSettings)
|
||||
.userDefinedTemplates(userDefinedTemplates);
|
||||
|
||||
return input.openAPI((OpenAPI)context.getSpecDocument());
|
||||
|
||||
@@ -759,8 +759,10 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
}
|
||||
|
||||
CodegenProperty returnProperty = op.returnProperty;
|
||||
CodegenProperty returnType = null;
|
||||
if (returnProperty != null) {
|
||||
CodegenProperty itemType = returnProperty.getItems();
|
||||
returnType = itemType;
|
||||
if (itemType != null) {
|
||||
String dataType;
|
||||
if (itemType.vendorExtensions.containsKey(X_ADA_VECTOR_TYPE_NAME)) {
|
||||
@@ -778,6 +780,73 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
}
|
||||
}
|
||||
|
||||
for (CodegenResponse rsp : op.responses) {
|
||||
|
||||
if (rsp.dataType != null) {
|
||||
String dataType = rsp.dataType;
|
||||
if (returnType != null) {
|
||||
if (returnType.vendorExtensions.containsKey(X_ADA_VECTOR_TYPE_NAME)) {
|
||||
dataType = (String) returnType.vendorExtensions.get(X_ADA_VECTOR_TYPE_NAME);
|
||||
rsp.vendorExtensions.put(X_ADA_TYPE_NAME, dataType);
|
||||
}
|
||||
rsp.vendorExtensions.put("x-is-model-type", isModelType(returnType));
|
||||
rsp.vendorExtensions.put("x-is-stream-type", isStreamType(returnType));
|
||||
rsp.vendorExtensions.put("x-is-nullable", returnType.isNull);
|
||||
|
||||
// Convert optional members to use the Nullable_<T> type.
|
||||
Boolean required = returnType.getHasRequired();
|
||||
if (!Boolean.TRUE.equals(required) && nullableTypeMapping.containsKey(dataType)) {
|
||||
rsp.dataType = nullableTypeMapping.get(dataType);
|
||||
rsp.vendorExtensions.put("x-is-required", false);
|
||||
} else {
|
||||
rsp.vendorExtensions.put("x-is-required", true);
|
||||
}
|
||||
if (!rsp.vendorExtensions.containsKey(X_ADA_SERIALIZE_OP)) {
|
||||
if (returnType.isLong && !required) {
|
||||
rsp.vendorExtensions.put(X_ADA_SERIALIZE_OP, "Write_Entity");
|
||||
} else if (rsp.isLong && "int64".equals(returnType.dataFormat)) {
|
||||
rsp.vendorExtensions.put(X_ADA_SERIALIZE_OP, "Write_Long_Entity");
|
||||
} else {
|
||||
rsp.vendorExtensions.put(X_ADA_SERIALIZE_OP, "Write_Entity");
|
||||
}
|
||||
}
|
||||
rsp.vendorExtensions.put("x-scz-return", true);
|
||||
} else {
|
||||
rsp.vendorExtensions.put("x-scz-no-return", true);
|
||||
if (returnProperty != null) {
|
||||
if (!rsp.vendorExtensions.containsKey(X_ADA_TYPE_NAME)) {
|
||||
rsp.vendorExtensions.put(X_ADA_TYPE_NAME, returnProperty.dataType);
|
||||
}
|
||||
rsp.vendorExtensions.put("x-is-model-type", isModelType(returnProperty));
|
||||
rsp.vendorExtensions.put("x-is-stream-type", isStreamType(returnProperty));
|
||||
rsp.vendorExtensions.put("x-is-nullable", returnProperty.isNull);
|
||||
|
||||
// Convert optional members to use the Nullable_<T> type.
|
||||
Boolean required = returnProperty.getHasRequired();
|
||||
if (!Boolean.TRUE.equals(required) && nullableTypeMapping.containsKey(dataType)) {
|
||||
rsp.dataType = nullableTypeMapping.get(dataType);
|
||||
rsp.vendorExtensions.put("x-is-required", false);
|
||||
} else {
|
||||
rsp.vendorExtensions.put("x-is-required", true);
|
||||
}
|
||||
if (!rsp.vendorExtensions.containsKey(X_ADA_SERIALIZE_OP)) {
|
||||
if (returnProperty.isLong && !required) {
|
||||
rsp.vendorExtensions.put(X_ADA_SERIALIZE_OP, "Write_Entity");
|
||||
} else if (rsp.isLong && "int64".equals(returnProperty.dataFormat)) {
|
||||
rsp.vendorExtensions.put(X_ADA_SERIALIZE_OP, "Write_Long_Entity");
|
||||
} else {
|
||||
rsp.vendorExtensions.put(X_ADA_SERIALIZE_OP, "Write_Entity");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (CodegenProperty header : rsp.headers) {
|
||||
header.nameInCamelCase = toModelName(header.baseName);
|
||||
header.nameInLowerCase = header.baseName.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Scan the path parameter to construct a x-path-index that tells the index of
|
||||
* the path parameter.
|
||||
|
||||
@@ -986,10 +986,10 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
final_values.add(element.asText());
|
||||
});
|
||||
} else if (schema.getDefault() instanceof Collection) {
|
||||
var _default = (Collection<String>) schema.getDefault();
|
||||
var _default = (Collection<Object>) schema.getDefault();
|
||||
List<String> final_values = _values;
|
||||
_default.forEach((element) -> {
|
||||
final_values.add(element);
|
||||
final_values.add(String.valueOf(element));
|
||||
});
|
||||
} else { // single value
|
||||
_values = java.util.Collections.singletonList(String.valueOf(schema.getDefault()));
|
||||
|
||||
@@ -422,7 +422,7 @@ public abstract class AbstractJuliaCodegen extends DefaultCodegen {
|
||||
} else if (ModelUtils.isIntegerSchema(schema) || ModelUtils.isLongSchema(schema) || ModelUtils.isNumberSchema(schema)) {
|
||||
return schema.getDefault().toString();
|
||||
} else if (ModelUtils.isStringSchema(schema)) {
|
||||
String _default = (String) schema.getDefault();
|
||||
String _default = String.valueOf(schema.getDefault());
|
||||
return "\"" + _default + "\"";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,14 +182,16 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
|
||||
return p.getDefault().toString();
|
||||
}
|
||||
} else if (ModelUtils.isStringSchema(p)) {
|
||||
String defaultValue = (String)p.getDefault();
|
||||
if (defaultValue != null) {
|
||||
defaultValue = defaultValue.replace("\\", "\\\\")
|
||||
.replace("'", "\'");
|
||||
if (Pattern.compile("\r\n|\r|\n").matcher(defaultValue).find()) {
|
||||
return "'''" + defaultValue + "'''";
|
||||
} else {
|
||||
return "'" + defaultValue + "'";
|
||||
if (p.getDefault() != null) {
|
||||
String defaultValue = String.valueOf(p.getDefault());
|
||||
if (defaultValue != null) {
|
||||
defaultValue = defaultValue.replace("\\", "\\\\")
|
||||
.replace("'", "\'");
|
||||
if (Pattern.compile("\r\n|\r|\n").matcher(defaultValue).find()) {
|
||||
return "'''" + defaultValue + "'''";
|
||||
} else {
|
||||
return "'" + defaultValue + "'";
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (ModelUtils.isArraySchema(p)) {
|
||||
|
||||
@@ -512,9 +512,9 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
// obtain the name from nameMapping directly if provided
|
||||
if (nameMapping.containsKey(name)) {
|
||||
return nameMapping.get(name);
|
||||
// obtain the name from parameterNameMapping directly if provided
|
||||
if (parameterNameMapping.containsKey(name)) {
|
||||
return parameterNameMapping.get(name);
|
||||
}
|
||||
|
||||
name = sanitizeName(name, "[^\\w$]");
|
||||
@@ -557,6 +557,11 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
|
||||
@Override
|
||||
public String toModelName(final String name) {
|
||||
// obtain the name from modelNameMapping directly if provided
|
||||
if (modelNameMapping.containsKey(name)) {
|
||||
return modelNameMapping.get(name);
|
||||
}
|
||||
|
||||
String fullModelName = name;
|
||||
fullModelName = addPrefix(fullModelName, modelNamePrefix);
|
||||
fullModelName = addSuffix(fullModelName, modelNameSuffix);
|
||||
@@ -630,6 +635,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
} else if (ModelUtils.isBinarySchema(p)) {
|
||||
return "ArrayBuffer";
|
||||
}
|
||||
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
|
||||
@@ -754,6 +760,17 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
|
||||
@Override
|
||||
public String getSchemaType(Schema p) {
|
||||
// check if $ref is a model and modelNameMapping is used
|
||||
if (StringUtils.isNotBlank(p.get$ref())) {
|
||||
Schema unaliasSchema = unaliasSchema(p);
|
||||
Schema actualSchema = ModelUtils.getReferencedSchema(openAPI, unaliasSchema);
|
||||
String modelName = ModelUtils.getSimpleRef(unaliasSchema.get$ref());
|
||||
|
||||
if (ModelUtils.isModel(actualSchema) && modelNameMapping.containsKey(modelName)) {
|
||||
return toModelName(modelNameMapping.get(modelName));
|
||||
}
|
||||
}
|
||||
|
||||
String openAPIType = super.getSchemaType(p);
|
||||
String type = null;
|
||||
if (ModelUtils.isComposedSchema(p)) {
|
||||
|
||||
@@ -89,13 +89,14 @@ public class AdaCodegen extends AbstractAdaCodegen implements CodegenConfig {
|
||||
if (StringUtils.isEmpty(packageName)) {
|
||||
packageName = modelPackage;
|
||||
}
|
||||
String srcPrefix = "src" + File.separator;
|
||||
String modelPrefix = srcPrefix + "model" + File.separator + toFilename(modelPackage);
|
||||
String clientPrefix = srcPrefix + "client" + File.separator + toFilename(modelPackage);
|
||||
supportingFiles.add(new SupportingFile("model-spec.mustache", "", modelPrefix + "-models.ads"));
|
||||
supportingFiles.add(new SupportingFile("model-body.mustache", "", modelPrefix + "-models.adb"));
|
||||
supportingFiles.add(new SupportingFile("client-spec.mustache", "", clientPrefix + "-clients.ads"));
|
||||
supportingFiles.add(new SupportingFile("client-body.mustache", "", clientPrefix + "-clients.adb"));
|
||||
String srcDir = "src" + File.separator;
|
||||
String clientDir = srcDir + "client";
|
||||
String modelDir = srcDir + "model";
|
||||
String modelPrefix = toFilename(modelPackage);
|
||||
supportingFiles.add(new SupportingFile("model-spec.mustache", modelDir, modelPrefix + "-models.ads"));
|
||||
supportingFiles.add(new SupportingFile("model-body.mustache", modelDir, modelPrefix + "-models.adb"));
|
||||
supportingFiles.add(new SupportingFile("client-spec.mustache", clientDir, modelPrefix + "-clients.ads"));
|
||||
supportingFiles.add(new SupportingFile("client-body.mustache", clientDir, modelPrefix + "-clients.adb"));
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.PROJECT_NAME)) {
|
||||
projectName = (String) additionalProperties.get(CodegenConstants.PROJECT_NAME);
|
||||
@@ -121,23 +122,23 @@ public class AdaCodegen extends AbstractAdaCodegen implements CodegenConfig {
|
||||
additionalProperties.put("httpClientPackageName", httpClientPackageName);
|
||||
additionalProperties.put("openApiPackageName", openApiPackageName);
|
||||
additionalProperties.put("openApiGprName", openApiPackageName.toLowerCase(Locale.ROOT));
|
||||
additionalProperties.put("httpClientGprName", httpClientPackageName.toLowerCase(Locale.ROOT));
|
||||
additionalProperties.put(CodegenConstants.PROJECT_NAME, projectName);
|
||||
|
||||
String[] names = this.modelPackage.split("\\.");
|
||||
String pkgName = names[0];
|
||||
additionalProperties.put("packageLevel1", pkgName);
|
||||
supportingFiles.add(new SupportingFile("package-spec-level1.mustache", "",
|
||||
"src" + File.separator + toFilename(names[0]) + ".ads"));
|
||||
supportingFiles.add(new SupportingFile("package-spec-level1.mustache", "src",
|
||||
toFilename(names[0]) + ".ads"));
|
||||
if (names.length > 1) {
|
||||
String fileName = toFilename(names[0]) + "-" + toFilename(names[1]) + ".ads";
|
||||
pkgName = names[0] + "." + names[1];
|
||||
additionalProperties.put("packageLevel2", pkgName);
|
||||
supportingFiles.add(new SupportingFile("package-spec-level2.mustache", "",
|
||||
"src" + File.separator + fileName));
|
||||
supportingFiles.add(new SupportingFile("package-spec-level2.mustache", "src", fileName));
|
||||
}
|
||||
pkgName = this.modelPackage;
|
||||
supportingFiles.add(new SupportingFile("client.mustache", "",
|
||||
"src" + File.separator + toFilename(pkgName) + "-client.adb"));
|
||||
supportingFiles.add(new SupportingFile("client.mustache", "src",
|
||||
toFilename(pkgName) + "-client.adb"));
|
||||
additionalProperties.put("packageName", toFilename(pkgName));
|
||||
|
||||
// add lambda for mustache templates
|
||||
|
||||
@@ -86,16 +86,20 @@ public class AdaServerCodegen extends AbstractAdaCodegen implements CodegenConfi
|
||||
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
|
||||
packageName = (String) additionalProperties.get(CodegenConstants.PACKAGE_NAME);
|
||||
}
|
||||
String srcPrefix = "src" + File.separator;
|
||||
String serverPrefix = srcPrefix + "server" + File.separator + toFilename(modelPackage);
|
||||
String modelPrefix = srcPrefix + "model" + File.separator + toFilename(modelPackage);
|
||||
String implPrefix = srcPrefix + toFilename(modelPackage);
|
||||
supportingFiles.add(new SupportingFile("model-spec.mustache", "", modelPrefix + "-models.ads"));
|
||||
supportingFiles.add(new SupportingFile("model-body.mustache", "", modelPrefix + "-models.adb"));
|
||||
supportingFiles.add(new SupportingFile("server-skeleton-spec.mustache", "", serverPrefix + "-skeletons.ads"));
|
||||
supportingFiles.add(new SupportingFile("server-skeleton-body.mustache", "", serverPrefix + "-skeletons.adb"));
|
||||
supportingFiles.add(new SupportingFile("server-spec.mustache", "", implPrefix + "-servers.ads"));
|
||||
supportingFiles.add(new SupportingFile("server-body.mustache", "", implPrefix + "-servers.adb"));
|
||||
String srcDir = "src" + File.separator;
|
||||
String awsDir = srcDir + "aws";
|
||||
String ewsDir = srcDir + "ews";
|
||||
String serverDir = srcDir + "server";
|
||||
String modelDir = srcDir + "model";
|
||||
String modelPrefix = toFilename(modelPackage);
|
||||
supportingFiles.add(new SupportingFile("model-spec.mustache", modelDir, modelPrefix + "-models.ads"));
|
||||
supportingFiles.add(new SupportingFile("model-body.mustache", modelDir, modelPrefix + "-models.adb"));
|
||||
supportingFiles.add(new SupportingFile("server-skeleton-spec.mustache", serverDir, modelPrefix + "-skeletons.ads"));
|
||||
supportingFiles.add(new SupportingFile("server-skeleton-body.mustache", serverDir, modelPrefix + "-skeletons.adb"));
|
||||
supportingFiles.add(new SupportingFile("server-spec.mustache", srcDir, modelPrefix + "-servers.ads"));
|
||||
supportingFiles.add(new SupportingFile("server-body.mustache", srcDir, modelPrefix + "-servers.adb"));
|
||||
supportingFiles.add(new SupportingFile("server-aws.mustache", awsDir, modelPrefix + "_aws.adb"));
|
||||
supportingFiles.add(new SupportingFile("server-ews.mustache", ewsDir, modelPrefix + "_ews.adb"));
|
||||
|
||||
supportingFiles.add(new SupportingFile("openapi.mustache", "web" + File.separator + "swagger", "openapi.json"));
|
||||
|
||||
@@ -124,23 +128,23 @@ public class AdaServerCodegen extends AbstractAdaCodegen implements CodegenConfi
|
||||
additionalProperties.put("httpClientPackageName", httpClientPackageName);
|
||||
additionalProperties.put("openApiPackageName", openApiPackageName);
|
||||
additionalProperties.put("openApiGprName", openApiPackageName.toLowerCase(Locale.ROOT));
|
||||
additionalProperties.put("httpClientGprName", httpClientPackageName.toLowerCase(Locale.ROOT));
|
||||
additionalProperties.put(CodegenConstants.PROJECT_NAME, projectName);
|
||||
|
||||
String names[] = this.modelPackage.split("\\.");
|
||||
String pkgName = names[0];
|
||||
additionalProperties.put("packageLevel1", pkgName);
|
||||
supportingFiles.add(new SupportingFile("package-spec-level1.mustache", "",
|
||||
"src" + File.separator + toFilename(names[0]) + ".ads"));
|
||||
supportingFiles.add(new SupportingFile("package-spec-level1.mustache", "src",
|
||||
toFilename(names[0]) + ".ads"));
|
||||
if (names.length > 1) {
|
||||
String fileName = toFilename(names[0]) + "-" + toFilename(names[1]) + ".ads";
|
||||
pkgName = names[0] + "." + names[1];
|
||||
additionalProperties.put("packageLevel2", pkgName);
|
||||
supportingFiles.add(new SupportingFile("package-spec-level2.mustache", "",
|
||||
"src" + File.separator + fileName));
|
||||
supportingFiles.add(new SupportingFile("package-spec-level2.mustache", "src", fileName));
|
||||
}
|
||||
pkgName = this.modelPackage;
|
||||
supportingFiles.add(new SupportingFile("server.mustache", "",
|
||||
"src" + File.separator + toFilename(pkgName) + "-server.adb"));
|
||||
supportingFiles.add(new SupportingFile("server.mustache", "src",
|
||||
toFilename(pkgName) + "-server.adb"));
|
||||
additionalProperties.put("packageName", toFilename(pkgName));
|
||||
|
||||
// add lambda for mustache templates
|
||||
|
||||
@@ -367,11 +367,17 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
}
|
||||
}
|
||||
|
||||
public void setDateTimeFormat(String value) { setStringProp(PROP_DATETIME_FORMAT, value); }
|
||||
public void setDateTimeFormat(String value) {
|
||||
setStringProp(PROP_DATETIME_FORMAT, value);
|
||||
}
|
||||
|
||||
public void setDateTimeParseFormat(String value) { setStringProp(PROP_DATETIME_PARSE_FORMAT, value); }
|
||||
public void setDateTimeParseFormat(String value) {
|
||||
setStringProp(PROP_DATETIME_PARSE_FORMAT, value);
|
||||
}
|
||||
|
||||
public void setDateFormat(String value) { setStringProp(PROP_DATE_FORMAT, value); }
|
||||
public void setDateFormat(String value) {
|
||||
setStringProp(PROP_DATE_FORMAT, value);
|
||||
}
|
||||
|
||||
public void setCabalPackage(String value) {
|
||||
setStringProp(PROP_CABAL_PACKAGE, value);
|
||||
@@ -406,7 +412,9 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
this.useKatip = value;
|
||||
}
|
||||
|
||||
public void setCustomTestInstanceModule(String value) { setStringProp(PROP_CUSTOM_TEST_INSTANCE_MODULE, value); }
|
||||
public void setCustomTestInstanceModule(String value) {
|
||||
setStringProp(PROP_CUSTOM_TEST_INSTANCE_MODULE, value);
|
||||
}
|
||||
|
||||
private void setStringProp(String key, String value) {
|
||||
if (StringUtils.isBlank(value)) {
|
||||
@@ -1260,7 +1268,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
public String toDefaultValue(Schema p) {
|
||||
if (ModelUtils.isStringSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
return "\"" + escapeText((String) p.getDefault()) + "\"";
|
||||
return "\"" + escapeText((String.valueOf(p.getDefault()))) + "\"";
|
||||
}
|
||||
} else if (ModelUtils.isBooleanSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
@@ -1436,8 +1444,8 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
// finally escalate characters avoiding code injection
|
||||
return escapeUnsafeCharacters(
|
||||
StringEscapeUtils.unescapeJava(
|
||||
StringEscapeUtils.escapeJava(input)
|
||||
.replace("\\/", "/"))
|
||||
StringEscapeUtils.escapeJava(input)
|
||||
.replace("\\/", "/"))
|
||||
.replaceAll("[\\t\\n\\r]", " ")
|
||||
.replace("\\", "\\\\")
|
||||
.replace("\"", "\\\""));
|
||||
@@ -1471,10 +1479,13 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static boolean ContainsJsonMimeType(String mime) {
|
||||
return mime != null && CONTAINS_JSON_MIME_PATTERN.matcher(mime).matches();
|
||||
return mime != null && CONTAINS_JSON_MIME_PATTERN.matcher(mime).matches();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.HASKELL; }
|
||||
public GeneratorLanguage generatorLanguage() {
|
||||
return GeneratorLanguage.HASKELL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +96,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
public static final String MICROPROFILE_DEFAULT = "default";
|
||||
public static final String MICROPROFILE_KUMULUZEE = "kumuluzee";
|
||||
public static final String WEBCLIENT_BLOCKING_OPERATIONS = "webclientBlockingOperations";
|
||||
public static final String USE_ENUM_CASE_INSENSITIVE = "useEnumCaseInsensitive";
|
||||
|
||||
public static final String SERIALIZATION_LIBRARY_GSON = "gson";
|
||||
public static final String SERIALIZATION_LIBRARY_JACKSON = "jackson";
|
||||
@@ -137,6 +138,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
protected boolean useSingleRequestParameter = false;
|
||||
protected boolean webclientBlockingOperations = false;
|
||||
protected boolean generateClientAsBean = false;
|
||||
protected boolean useEnumCaseInsensitive = false;
|
||||
|
||||
private static class MpRestClientVersion {
|
||||
public final String rootPackage;
|
||||
@@ -225,6 +227,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
cliOptions.add(CliOption.newBoolean(WEBCLIENT_BLOCKING_OPERATIONS, "Making all WebClient operations blocking(sync). Note that if on operation 'x-webclient-blocking: false' then such operation won't be sync", this.webclientBlockingOperations));
|
||||
cliOptions.add(CliOption.newBoolean(GENERATE_CLIENT_AS_BEAN, "For resttemplate, configure whether to create `ApiClient.java` and Apis clients as bean (with `@Component` annotation).", this.generateClientAsBean));
|
||||
cliOptions.add(CliOption.newBoolean(SUPPORT_URL_QUERY, "Generate toUrlQueryString in POJO (default to true). Available on `native`, `apache-httpclient` libraries."));
|
||||
cliOptions.add(CliOption.newBoolean(USE_ENUM_CASE_INSENSITIVE, "Use `equalsIgnoreCase` when String for enum comparison", useEnumCaseInsensitive));
|
||||
|
||||
supportedLibraries.put(JERSEY1, "HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.9.x. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey3' or other HTTP libraries instead.");
|
||||
supportedLibraries.put(JERSEY2, "HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x");
|
||||
@@ -461,6 +464,11 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
this.setGenerateClientAsBean(convertPropertyToBooleanAndWriteBack(GENERATE_CLIENT_AS_BEAN));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(USE_ENUM_CASE_INSENSITIVE)) {
|
||||
this.setUseEnumCaseInsensitive(Boolean.parseBoolean(additionalProperties.get(USE_ENUM_CASE_INSENSITIVE).toString()));
|
||||
}
|
||||
writePropertyBack(USE_ENUM_CASE_INSENSITIVE, useEnumCaseInsensitive);
|
||||
|
||||
final String invokerFolder = (sourceFolder + '/' + invokerPackage).replace(".", "/");
|
||||
final String apiFolder = (sourceFolder + '/' + apiPackage).replace(".", "/");
|
||||
final String modelsFolder = (sourceFolder + File.separator + modelPackage().replace('.', File.separatorChar)).replace('/', File.separatorChar);
|
||||
@@ -1232,6 +1240,10 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
this.generateClientAsBean = generateClientAsBean;
|
||||
}
|
||||
|
||||
public void setUseEnumCaseInsensitive(boolean useEnumCaseInsensitive) {
|
||||
this.useEnumCaseInsensitive = useEnumCaseInsensitive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialization library.
|
||||
*
|
||||
|
||||
@@ -699,7 +699,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
} else if (ModelUtils.isStringSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
return "@\"" + (String) p.getDefault() + "\"";
|
||||
return "@\"" + String.valueOf(p.getDefault()) + "\"";
|
||||
}
|
||||
} else if (ModelUtils.isBooleanSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import com.samskivert.mustache.Mustache;
|
||||
import com.samskivert.mustache.Template;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
@@ -30,6 +32,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.*;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
@@ -286,6 +290,18 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
|
||||
.doNotOverwrite());
|
||||
supportingFiles.add(new SupportingFile("api_client_spec.mustache", specFolder, "api_client_spec.rb")
|
||||
.doNotOverwrite());
|
||||
|
||||
// add lambda to convert a symbol to a string if an underscore is included (e.g. :'user_uuid' => 'user_uuid')
|
||||
additionalProperties.put("lambdaFixHeaderKey", new Mustache.Lambda() {
|
||||
@Override
|
||||
public void execute(Template.Fragment fragment, Writer writer) throws IOException {
|
||||
String content = fragment.execute();
|
||||
if (content.contains("_")) {
|
||||
content = content.substring(1);
|
||||
}
|
||||
writer.write(content);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -770,9 +770,9 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
if (p.getEnum() != null && !p.getEnum().isEmpty()) {
|
||||
if (p.getDefault() != null) {
|
||||
if (ModelUtils.isStringSchema(p)) {
|
||||
return "." + toEnumVarName(escapeText((String) p.getDefault()), p.getType());
|
||||
return "." + toEnumVarName(escapeText(String.valueOf(p.getDefault())), p.getType());
|
||||
} else {
|
||||
return "." + toEnumVarName(escapeText(p.getDefault().toString()), p.getType());
|
||||
return "." + toEnumVarName(escapeText(String.valueOf(p.getDefault())), p.getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -786,7 +786,7 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
long epochMicro = TimeUnit.SECONDS.toMicros(instant.getEpochSecond()) + (instant.get(ChronoField.MICRO_OF_SECOND));
|
||||
return "Date(timeIntervalSince1970: " + epochMicro + ".0 / 1_000_000)";
|
||||
} else if (ModelUtils.isStringSchema(p)) {
|
||||
return "\"" + escapeText((String) p.getDefault()) + "\"";
|
||||
return "\"" + escapeText(String.valueOf(p.getDefault())) + "\"";
|
||||
}
|
||||
// TODO: Handle more cases from `ModelUtils`, such as Date
|
||||
}
|
||||
|
||||
@@ -6,23 +6,39 @@ This Ada server was generated by the [OpenAPI Generator](https://openapi-generat
|
||||
By using the [OpenAPI-Spec](https://github.com/OAI/OpenAPI-Specification) from a remote server,
|
||||
you can easily generate a server stub.
|
||||
|
||||
## Building
|
||||
## Alire setup
|
||||
|
||||
To build the server you will need the GNAT Ada compiler as well as
|
||||
the [OpenAPI Ada library](https://github.com/stcarrez/swagger-ada).
|
||||
|
||||
When the GNAT Ada compiler and OpenAPI Ada libraries are installed,
|
||||
run the following command:
|
||||
Use [Alire](https://github.com/alire-project/alire) to setup and build the project.
|
||||
First, import the [OpenAPI Ada](https://gitlab.com/stcarrez/openapi-ada) server library with:
|
||||
|
||||
```shell
|
||||
gprbuild -p -P{{projectName}}
|
||||
alr with openapi_server
|
||||
```
|
||||
|
||||
Then choose a servlet web container that will handle the requests.
|
||||
Two web server implementations are provided:
|
||||
|
||||
* [AWS](https://github.com/AdaCore/aws)
|
||||
* [EWS](https://github.com/simonjwright/ews)
|
||||
|
||||
and you should run one of the following `alr` command depending on your choice:
|
||||
|
||||
```
|
||||
alr with servletada_aws
|
||||
alr with servletada_ews
|
||||
```
|
||||
|
||||
Once these steps are made, build the project with
|
||||
|
||||
```
|
||||
alr build
|
||||
```
|
||||
|
||||
After the build is successful, you will get the server binary
|
||||
in bin/{{packageName}}-server and you can start it as follows:
|
||||
in `bin/{{packageName}}_aws` or `bin/{{packageName}}_ews` and you can start it as follows:
|
||||
|
||||
```shell
|
||||
./bin/{{packageName}}-server
|
||||
./bin/{{packageName}}_aws
|
||||
```
|
||||
|
||||
## Structure of the server
|
||||
@@ -40,6 +56,8 @@ src/server/{{packageName}}-skeletons.adb|{{package}}.Skeletons|The server skelet
|
||||
src/server/{{packageName}}-models.ads|{{package}}.Skeletons|The server model types declaration
|
||||
src/server/{{packageName}}-models.adb|{{package}}.Skeletons|The server model types implementation
|
||||
src/{{packageName}}-server.adb|{{package}}.Server|The server main procedure
|
||||
src/aws/{{packageName}}_aws.adb||The Ada Web Server server main procedure
|
||||
src/ews/{{packageName}}_ews.adb||The Embedded Web Server server main procedure
|
||||
|
||||
Files generated in **src/server** should not be modified. The server implementation
|
||||
files (**src/{{packageName}}-server.ads** and **src/{{packageName}}-server.adb**) should
|
||||
|
||||
@@ -8,21 +8,48 @@
|
||||
with "config";
|
||||
with "utilada_sys";
|
||||
with "utilada_xml";
|
||||
with "utilada_http";
|
||||
with "utilada_{{httpClientGprName}}";
|
||||
with "security";
|
||||
with "{{openApiGprName}}";{{#isServer}}
|
||||
with "servletada";
|
||||
with "servletada_aws";
|
||||
-- with "servletada_ews";
|
||||
with "{{openApiGprName}}_server";{{/isServer}}
|
||||
project {{{projectName}}} is
|
||||
|
||||
Mains := ("{{{packageName}}}-{{{mainName}}}.adb");
|
||||
for Main use Mains;
|
||||
for Source_Dirs use ("src", "src/model", "src/{{{packageDir}}}");
|
||||
for Object_Dir use "./" & Config'Exec_Dir & "/bin";
|
||||
for Object_Dir use "obj/";
|
||||
for Source_Dirs use ("src", "src/model", "src/{{{packageDir}}}");
|
||||
{{^isServer}}
|
||||
Mains := ("{{{packageName}}}-{{{mainName}}}.adb");
|
||||
{{/isServer}}
|
||||
{{#isServer}}
|
||||
for Main use ();
|
||||
|
||||
package Binder renames Config.Binder;
|
||||
package Builder renames Config.Builder;
|
||||
package Compiler renames Config.Compiler;
|
||||
package Linker renames Config.Linker;
|
||||
Build_AWS : Config.Yes_No := external ("BUILD_AWS", "yes");
|
||||
Build_EWS : Config.Yes_No := external ("BUILD_EWS", "no");
|
||||
|
||||
case Build_AWS is
|
||||
when "yes" =>
|
||||
for Main use Project'Main & ("{{{packageName}}}_aws.adb");
|
||||
for Source_Dirs use Project'Source_Dirs & ("src/aws");
|
||||
|
||||
when others =>
|
||||
null;
|
||||
end case;
|
||||
|
||||
case Build_EWS is
|
||||
when "yes" =>
|
||||
for Main use Project'Main & ("{{{packageName}}}_ews.adb");
|
||||
for Source_Dirs use Project'Source_Dirs & ("src/ews");
|
||||
|
||||
when others =>
|
||||
null;
|
||||
end case;
|
||||
{{/isServer}}
|
||||
|
||||
package Binder renames Config.Binder;
|
||||
package Builder renames Config.Builder;
|
||||
package Compiler renames Config.Compiler;
|
||||
package Linker renames Config.Linker;
|
||||
|
||||
end {{{projectName}}};
|
||||
|
||||
7
modules/openapi-generator/src/main/resources/Ada/server-aws.mustache
vendored
Normal file
7
modules/openapi-generator/src/main/resources/Ada/server-aws.mustache
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
with Servlet.Server.Web;
|
||||
with {{{projectName}}}.Server;
|
||||
procedure {{{projectName}}}_AWS is
|
||||
Container : Servlet.Server.Web.AWS_Container;
|
||||
begin
|
||||
{{{projectName}}}.Server (Container);
|
||||
end {{{projectName}}}_AWS;
|
||||
7
modules/openapi-generator/src/main/resources/Ada/server-ews.mustache
vendored
Normal file
7
modules/openapi-generator/src/main/resources/Ada/server-ews.mustache
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
with Servlet.Server.EWS;
|
||||
with {{{projectName}}}.Server;
|
||||
procedure {{{projectName}}}_EWS is
|
||||
Container : Servlet.Server.EWS.EWS_Container;
|
||||
begin
|
||||
{{{projectName}}}.Server (Container);
|
||||
end {{{projectName}}}_EWS;
|
||||
@@ -107,10 +107,7 @@ package body {{package}}.Skeletons is
|
||||
{{#returnType}}
|
||||
{{#responses}}
|
||||
if Context.Get_Status = {{code}} then{{#message}}
|
||||
Context.Set_Description ("{{message}}");{{/message}}
|
||||
{{#schema}}
|
||||
{{#vendorExtensions.x-produces-plain-text}}
|
||||
{{#isFile}}
|
||||
Context.Set_Description ("{{message}}");{{/message}}{{#-first}}{{#schema}}{{#vendorExtensions.x-produces-plain-text}}{{#isFile}}
|
||||
{{openApiPackageName}}.Streams.Write (Stream, Result);
|
||||
{{/isFile}}{{^isFile}}
|
||||
Stream.Write ({{openApiPackageName}}.To_String (Result));
|
||||
@@ -119,15 +116,22 @@ package body {{package}}.Skeletons is
|
||||
{{#isFile}}
|
||||
{{openApiPackageName}}.Streams.Write (Stream, Result);
|
||||
{{/isFile}}{{^isFile}}
|
||||
Stream.Start_Document;{{#vendorExtensions.x-codegen-response.isString}}
|
||||
{{openApiPackageName}}.Streams.Serialize (Stream, "", Result);{{/vendorExtensions.x-codegen-response.isString}}{{^vendorExtensions.x-codegen-response.isString}}{{#returnTypeIsPrimitive}}
|
||||
{{openApiPackageName}}.Streams.Serialize (Stream, "", Result);{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}
|
||||
{{package}}.Models.Serialize (Stream, "", Result);{{/returnTypeIsPrimitive}}{{/vendorExtensions.x-codegen-response.isString}}
|
||||
Stream.End_Document;
|
||||
{{/isFile}}{{/vendorExtensions.x-produces-plain-text}}
|
||||
{{/schema}}
|
||||
Stream.Start_Document;{{#vendorExtensions.x-is-stream-type}}{{^isLong}}{{#vendorExtensions.x-is-required}}
|
||||
Stream.{{vendorExtensions.x-ada-serialize-op}} ("", Result);{{/vendorExtensions.x-is-required}}{{^vendorExtensions.x-is-required}}{{#vendorExtensions.x-is-nullable}}
|
||||
Stream.{{vendorExtensions.x-ada-serialize-op}} ("", Result);{{/vendorExtensions.x-is-nullable}}{{^vendorExtensions.x-is-nullable}}
|
||||
if not {{#isFreeFormObject}}{{openApiPackageName}}.Is_Null (Result){{/isFreeFormObject}}{{^isFreeFormObject}}Value.{{name}}.Is_Null{{/isFreeFormObject}} then
|
||||
Stream.{{vendorExtensions.x-ada-serialize-op}} ("", Result);
|
||||
end if;{{/vendorExtensions.x-is-nullable}}{{/vendorExtensions.x-is-required}}{{/isLong}}{{#isLong}}{{#vendorExtensions.x-is-required}}
|
||||
Stream.{{vendorExtensions.x-ada-serialize-op}} ("", Result);{{/vendorExtensions.x-is-required}}{{^vendorExtensions.x-is-required}}{{#vendorExtensions.x-is-nullable}}
|
||||
Stream.{{vendorExtensions.x-ada-serialize-op}} ("", Result);{{/vendorExtensions.x-is-nullable}}{{^vendorExtensions.x-is-nullable}}
|
||||
if not Result.Is_Null then
|
||||
Stream.{{vendorExtensions.x-ada-serialize-op}} ("", Result);
|
||||
end if;{{/vendorExtensions.x-is-nullable}}{{/vendorExtensions.x-is-required}}{{/isLong}}{{/vendorExtensions.x-is-stream-type}}{{^vendorExtensions.x-is-stream-type}}
|
||||
Serialize (Stream, "", Result);{{/vendorExtensions.x-is-stream-type}}
|
||||
Stream.End_Document;{{/isFile}}{{/vendorExtensions.x-produces-plain-text}}{{/schema}}{{/-first}}
|
||||
return;
|
||||
end if;{{/responses}}{{/returnType}}
|
||||
end if;
|
||||
{{/responses}}{{/returnType}}
|
||||
end {{operationId}};
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
@@ -224,10 +228,7 @@ package body {{package}}.Skeletons is
|
||||
{{#returnType}}
|
||||
{{#responses}}
|
||||
if Context.Get_Status = {{code}} then{{#message}}
|
||||
Context.Set_Description ("{{message}}");{{/message}}
|
||||
{{#schema}}
|
||||
{{#vendorExtensions.x-produces-plain-text}}
|
||||
{{#isFile}}
|
||||
Context.Set_Description ("{{message}}");{{/message}}{{#-first}}{{#schema}}{{#vendorExtensions.x-produces-plain-text}}{{#isFile}}
|
||||
{{openApiPackageName}}.Streams.Write (Stream, Result);
|
||||
{{/isFile}}{{^isFile}}
|
||||
Stream.Write ({{openApiPackageName}}.To_String (Result));
|
||||
@@ -236,15 +237,22 @@ package body {{package}}.Skeletons is
|
||||
{{#isFile}}
|
||||
{{openApiPackageName}}.Streams.Write (Stream, Result);
|
||||
{{/isFile}}{{^isFile}}
|
||||
Stream.Start_Document;{{#vendorExtensions.x-codegen-response.isString}}
|
||||
{{openApiPackageName}}.Streams.Serialize (Stream, "", Result);{{/vendorExtensions.x-codegen-response.isString}}{{^vendorExtensions.x-codegen-response.isString}}{{#returnTypeIsPrimitive}}
|
||||
{{openApiPackageName}}.Streams.Serialize (Stream, "", Result);{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}
|
||||
{{package}}.Models.Serialize (Stream, "", Result);{{/returnTypeIsPrimitive}}{{/vendorExtensions.x-codegen-response.isString}}
|
||||
Stream.End_Document;
|
||||
{{/isFile}}{{/vendorExtensions.x-produces-plain-text}}
|
||||
{{/schema}}
|
||||
Stream.Start_Document;{{#vendorExtensions.x-is-stream-type}}{{^isLong}}{{#vendorExtensions.x-is-required}}
|
||||
Stream.{{vendorExtensions.x-ada-serialize-op}} ("", Result);{{/vendorExtensions.x-is-required}}{{^vendorExtensions.x-is-required}}{{#vendorExtensions.x-is-nullable}}
|
||||
Stream.{{vendorExtensions.x-ada-serialize-op}} ("", Result);{{/vendorExtensions.x-is-nullable}}{{^vendorExtensions.x-is-nullable}}
|
||||
if not {{#isFreeFormObject}}{{openApiPackageName}}.Is_Null (Result){{/isFreeFormObject}}{{^isFreeFormObject}}Value.{{name}}.Is_Null{{/isFreeFormObject}} then
|
||||
Stream.{{vendorExtensions.x-ada-serialize-op}} ("", Result);
|
||||
end if;{{/vendorExtensions.x-is-nullable}}{{/vendorExtensions.x-is-required}}{{/isLong}}{{#isLong}}{{#vendorExtensions.x-is-required}}
|
||||
Stream.{{vendorExtensions.x-ada-serialize-op}} ("", Result);{{/vendorExtensions.x-is-required}}{{^vendorExtensions.x-is-required}}{{#vendorExtensions.x-is-nullable}}
|
||||
Stream.{{vendorExtensions.x-ada-serialize-op}} ("", Result);{{/vendorExtensions.x-is-nullable}}{{^vendorExtensions.x-is-nullable}}
|
||||
if not Result.Is_Null then
|
||||
Stream.{{vendorExtensions.x-ada-serialize-op}} ("", Result);
|
||||
end if;{{/vendorExtensions.x-is-nullable}}{{/vendorExtensions.x-is-required}}{{/isLong}}{{/vendorExtensions.x-is-stream-type}}{{^vendorExtensions.x-is-stream-type}}
|
||||
Serialize (Stream, "", Result);{{/vendorExtensions.x-is-stream-type}}
|
||||
Stream.End_Document;{{/isFile}}{{/vendorExtensions.x-produces-plain-text}}{{/schema}}{{/-first}}
|
||||
return;
|
||||
end if;{{/responses}}{{/returnType}}
|
||||
end if;
|
||||
{{/responses}}{{/returnType}}
|
||||
end {{operationId}};
|
||||
|
||||
package API_{{operationId}} is
|
||||
|
||||
@@ -1,46 +1,37 @@
|
||||
with Ada.IO_Exceptions;
|
||||
with AWS.Config.Set;
|
||||
with {{openApiPackageName}}.Servers.AWS;
|
||||
with Servlet.Server;
|
||||
with {{openApiPackageName}}.Servers.Applications;
|
||||
with Util.Strings;
|
||||
with Util.Log.Loggers;
|
||||
with Util.Properties;
|
||||
with Util.Properties.Basic;
|
||||
with {{package}}.Servers;
|
||||
procedure {{package}}.Server is
|
||||
procedure Configure (Config : in out AWS.Config.Object);
|
||||
|
||||
procedure {{package}}.Server (Server : in out Servlet.Server.Container'Class) is
|
||||
use Util.Properties.Basic;
|
||||
|
||||
CONFIG_PATH : constant String := "{{packageConfig}}.properties";
|
||||
Port : Natural := 8080;
|
||||
|
||||
procedure Configure (Config : in out AWS.Config.Object) is
|
||||
begin
|
||||
AWS.Config.Set.Server_Port (Config, Port);
|
||||
AWS.Config.Set.Max_Connection (Config, 8);
|
||||
AWS.Config.Set.Accept_Queue_Size (Config, 512);
|
||||
end Configure;
|
||||
|
||||
Port : Natural := 8080;
|
||||
App : aliased {{openApiPackageName}}.Servers.Applications.Application_Type;
|
||||
WS : {{openApiPackageName}}.Servers.AWS.AWS_Container;
|
||||
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("{{package}}.Server");
|
||||
Props : Util.Properties.Manager;
|
||||
Config : Servlet.Server.Configuration;
|
||||
begin
|
||||
Props.Load_Properties (CONFIG_PATH);
|
||||
Util.Log.Loggers.Initialize (Props);
|
||||
|
||||
Port := Integer_Property.Get (Props, "swagger.port", Port);
|
||||
Config.Listening_Port := Port;
|
||||
App.Configure (Props);
|
||||
{{package}}.Servers.Server_Impl.Register (App);
|
||||
|
||||
WS.Configure (Configure'Access);
|
||||
WS.Register_Application ("{{basePathWithoutHost}}", App'Unchecked_Access);
|
||||
Server.Configure (Config);
|
||||
Server.Register_Application ("{{basePathWithoutHost}}", App'Unchecked_Access);
|
||||
App.Dump_Routes (Util.Log.INFO_LEVEL);
|
||||
Log.Info ("Connect your browser to: http://localhost:{0}{{basePathWithoutHost}}/ui/index.html",
|
||||
Util.Strings.Image (Port));
|
||||
|
||||
WS.Start;
|
||||
Server.Start;
|
||||
|
||||
delay 6000.0;
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import {{invokerPackage}}.JSON;
|
||||
@@ -462,9 +461,9 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
{{^hasChildren}}
|
||||
{{^isAdditionalPropertiesTrue}}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
for (Map.Entry<String, JsonElement> entry : entries) {
|
||||
if (!{{classname}}.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `{{classname}}` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
|
||||
@@ -216,7 +216,10 @@ func (a *{{{classname}}}Service) {{nickname}}Execute(r {{#structPrefix}}{{&class
|
||||
{{^isCollectionFormatMulti}}
|
||||
parameterAddToHeaderOrQuery(localVarQueryParams, "{{baseName}}", r.{{paramName}}, "{{collectionFormat}}")
|
||||
{{/isCollectionFormatMulti}}
|
||||
}
|
||||
{{#defaultValue}}} else {
|
||||
var defaultValue {{{dataType}}} = {{{.}}}
|
||||
r.{{paramName}} = &defaultValue
|
||||
{{/defaultValue}}}
|
||||
{{/required}}
|
||||
{{/queryParams}}
|
||||
// to determine the Content-Type header
|
||||
|
||||
@@ -36,6 +36,10 @@ import kotlinx.parcelize.Parcelize
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.descriptors.*
|
||||
import kotlinx.serialization.encoding.*
|
||||
{{#discriminator}}import kotlinx.serialization.json.JsonContentPolymorphicSerializer
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
import kotlinx.serialization.json.jsonObject
|
||||
{{/discriminator}}
|
||||
{{/multiplatform}}
|
||||
{{#serializableModel}}
|
||||
import java.io.Serializable
|
||||
@@ -55,18 +59,18 @@ import {{packageName}}.infrastructure.ITransformForStorage
|
||||
{{#parcelizeModels}}
|
||||
@Parcelize
|
||||
{{/parcelizeModels}}
|
||||
{{#multiplatform}}{{^discriminator}}@Serializable{{/discriminator}}{{/multiplatform}}{{#kotlinx_serialization}}{{#serializableModel}}@KSerializable{{/serializableModel}}{{^serializableModel}}@Serializable{{/serializableModel}}{{/kotlinx_serialization}}{{#moshi}}{{#moshiCodeGen}}@JsonClass(generateAdapter = true){{/moshiCodeGen}}{{/moshi}}{{#jackson}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{/jackson}}
|
||||
{{#multiplatform}}@Serializable{{#discriminator}}(with = {{classname}}Serializer::class){{/discriminator}}{{/multiplatform}}{{#kotlinx_serialization}}{{#serializableModel}}@KSerializable{{/serializableModel}}{{^serializableModel}}@Serializable{{/serializableModel}}{{/kotlinx_serialization}}{{#moshi}}{{#moshiCodeGen}}@JsonClass(generateAdapter = true){{/moshiCodeGen}}{{/moshi}}{{#jackson}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{/jackson}}
|
||||
{{#isDeprecated}}
|
||||
@Deprecated(message = "This schema is deprecated.")
|
||||
{{/isDeprecated}}
|
||||
{{>additionalModelTypeAnnotations}}
|
||||
{{#nonPublicApi}}internal {{/nonPublicApi}}{{#discriminator}}interface{{/discriminator}}{{^discriminator}}data class{{/discriminator}} {{classname}}{{^discriminator}} (
|
||||
{{#nonPublicApi}}internal {{/nonPublicApi}}{{#discriminator}}sealed class{{/discriminator}}{{^discriminator}}data class{{/discriminator}} {{classname}}{{^discriminator}} (
|
||||
|
||||
{{#allVars}}
|
||||
{{#required}}{{>data_class_req_var}}{{/required}}{{^required}}{{>data_class_opt_var}}{{/required}}{{^-last}},{{/-last}}
|
||||
|
||||
{{/allVars}}
|
||||
){{/discriminator}}{{#parent}}{{^serializableModel}}{{^parcelizeModels}} : {{{parent}}}{{#isMap}}(){{/isMap}}{{#isArray}}(){{/isArray}}{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{#parent}}{{#serializableModel}}{{^parcelizeModels}} : {{{parent}}}{{#isMap}}(){{/isMap}}{{#isArray}}(){{/isArray}}, Serializable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{#parent}}{{^serializableModel}}{{#parcelizeModels}} : {{{parent}}}{{#isMap}}(){{/isMap}}{{#isArray}}(){{/isArray}}, Parcelable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{#parent}}{{#serializableModel}}{{#parcelizeModels}} : {{{parent}}}{{#isMap}}(){{/isMap}}{{#isArray}}(){{/isArray}}, Serializable, Parcelable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{^parent}}{{#serializableModel}}{{^parcelizeModels}} : Serializable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{^parent}}{{^serializableModel}}{{#parcelizeModels}} : Parcelable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{^parent}}{{#serializableModel}}{{#parcelizeModels}} : Serializable, Parcelable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{#generateRoomModels}}{{#parent}}, {{/parent}}{{^discriminator}}{{^parent}}:{{/parent}} ITransformForStorage<{{classname}}RoomModel>{{/discriminator}}{{/generateRoomModels}}{{#vendorExtensions.x-has-data-class-body}} {
|
||||
){{/discriminator}}{{#parent}}{{^serializableModel}}{{^parcelizeModels}} : {{{parent}}}(){{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{#parent}}{{#serializableModel}}{{^parcelizeModels}} : {{{parent}}}(), Serializable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{#parent}}{{^serializableModel}}{{#parcelizeModels}} : {{{parent}}}(), Parcelable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{#parent}}{{#serializableModel}}{{#parcelizeModels}} : {{{parent}}}(), Serializable, Parcelable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{^parent}}{{#serializableModel}}{{^parcelizeModels}} : Serializable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{^parent}}{{^serializableModel}}{{#parcelizeModels}} : Parcelable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{^parent}}{{#serializableModel}}{{#parcelizeModels}} : Serializable, Parcelable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{#generateRoomModels}}{{#parent}}, {{/parent}}{{^discriminator}}{{^parent}}:{{/parent}} ITransformForStorage<{{classname}}RoomModel>{{/discriminator}}{{/generateRoomModels}}{{#vendorExtensions.x-has-data-class-body}} {
|
||||
{{/vendorExtensions.x-has-data-class-body}}
|
||||
{{#generateRoomModels}}
|
||||
companion object { }
|
||||
@@ -147,3 +151,13 @@ import {{packageName}}.infrastructure.ITransformForStorage
|
||||
{{#vendorExtensions.x-has-data-class-body}}
|
||||
}
|
||||
{{/vendorExtensions.x-has-data-class-body}}
|
||||
{{#discriminator}}
|
||||
|
||||
internal object {{classname}}Serializer : JsonContentPolymorphicSerializer<{{classname}}>({{classname}}::class) {
|
||||
override fun selectDeserializer(element: JsonElement) = when {
|
||||
{{#mappedModels}}
|
||||
"{{mappingName}}" in element.jsonObject["{{discriminatorName}}"].toString() -> {{modelName}}.serializer()
|
||||
{{/mappedModels}}
|
||||
else -> {{classname}}.serializer()
|
||||
}
|
||||
}{{/discriminator}}
|
||||
@@ -15,4 +15,4 @@
|
||||
{{^isEnum}}{{^isArray}}{{^isPrimitiveType}}{{^isModel}}@Contextual {{/isModel}}{{/isPrimitiveType}}{{/isArray}}{{/isEnum}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}")
|
||||
{{/kotlinx_serialization}}
|
||||
{{/multiplatform}}
|
||||
{{#multiplatform}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}") @Required {{/multiplatform}}{{>modelMutable}} {{{name}}}: {{#isArray}}{{#isList}}kotlin.collections.{{#modelMutable}}Mutable{{/modelMutable}}List{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{^items.isEnum}}{{^items.isPrimitiveType}}{{^items.isModel}}{{#kotlinx_serialization}}@Contextual {{/kotlinx_serialization}}{{/items.isModel}}{{/items.isPrimitiveType}}{{{items.dataType}}}{{/items.isEnum}}{{#items.isEnum}}{{classname}}.{{{nameInCamelCase}}}{{/items.isEnum}}>{{/isArray}}{{^isEnum}}{{^isArray}}{{{dataType}}}{{/isArray}}{{/isEnum}}{{#isEnum}}{{^isArray}}{{classname}}.{{{nameInCamelCase}}}{{/isArray}}{{/isEnum}}{{#isNullable}}?{{/isNullable}}
|
||||
{{#multiplatform}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}") @Required {{^isInherited}}abstract {{/isInherited}}{{/multiplatform}}{{>modelMutable}} {{{name}}}: {{#isArray}}{{#isList}}kotlin.collections.{{#modelMutable}}Mutable{{/modelMutable}}List{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{^items.isEnum}}{{^items.isPrimitiveType}}{{^items.isModel}}{{#kotlinx_serialization}}@Contextual {{/kotlinx_serialization}}{{/items.isModel}}{{/items.isPrimitiveType}}{{{items.dataType}}}{{/items.isEnum}}{{#items.isEnum}}{{classname}}.{{{nameInCamelCase}}}{{/items.isEnum}}>{{/isArray}}{{^isEnum}}{{^isArray}}{{{dataType}}}{{/isArray}}{{/isEnum}}{{#isEnum}}{{^isArray}}{{classname}}.{{{nameInCamelCase}}}{{/isArray}}{{/isEnum}}{{#isNullable}}?{{/isNullable}}
|
||||
@@ -147,7 +147,7 @@ import {{packageName}}.infrastructure.toMultiValue
|
||||
}
|
||||
ResponseType.ServerError -> {
|
||||
val localVarError = localVarResponse as ServerError<*>
|
||||
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
|
||||
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()} ${localVarError.body}", localVarError.statusCode, localVarResponse)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,14 +288,14 @@ import com.squareup.moshi.adapter
|
||||
requestConfig.headers["{{keyParamName}}"] = apiKeyPrefix["{{keyParamName}}"]!! + " " + apiKey["{{keyParamName}}"]!!
|
||||
{{/isKeyInHeader}}
|
||||
{{#isKeyInQuery}}
|
||||
requestConfig.query["{{keyParamName}}"] = apiKeyPrefix["{{keyParamName}}"]!! + " " + apiKey["{{keyParamName}}"]!!
|
||||
requestConfig.query["{{keyParamName}}"] = listOf(apiKeyPrefix["{{keyParamName}}"]!! + " " + apiKey["{{keyParamName}}"]!!)
|
||||
{{/isKeyInQuery}}
|
||||
} else {
|
||||
{{#isKeyInHeader}}
|
||||
requestConfig.headers["{{keyParamName}}"] = apiKey["{{keyParamName}}"]!!
|
||||
{{/isKeyInHeader}}
|
||||
{{#isKeyInQuery}}
|
||||
requestConfig.query["{{keyParamName}}"] = apiKey["{{keyParamName}}"]!!
|
||||
requestConfig.query["{{keyParamName}}"] = listOf(apiKey["{{keyParamName}}"]!!)
|
||||
{{/isKeyInQuery}}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,12 +199,12 @@ module {{moduleName}}
|
||||
{{/hasConsumes}}
|
||||
{{#headerParams}}
|
||||
{{#required}}
|
||||
header_params[:'{{{baseName}}}'] = {{#collectionFormat}}@api_client.build_collection_param({{{paramName}}}, :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}{{{paramName}}}{{/collectionFormat}}
|
||||
header_params[{{#lambdaFixHeaderKey}}:'{{{baseName}}}'{{/lambdaFixHeaderKey}}] = {{#collectionFormat}}@api_client.build_collection_param({{{paramName}}}, :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}{{{paramName}}}{{/collectionFormat}}
|
||||
{{/required}}
|
||||
{{/headerParams}}
|
||||
{{#headerParams}}
|
||||
{{^required}}
|
||||
header_params[:'{{{baseName}}}'] = {{#collectionFormat}}@api_client.build_collection_param(opts[:'{{{paramName}}}'], :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}opts[:'{{{paramName}}}']{{/collectionFormat}} if !opts[:'{{{paramName}}}'].nil?
|
||||
header_params[{{#lambdaFixHeaderKey}}:'{{{baseName}}}'{{/lambdaFixHeaderKey}}] = {{#collectionFormat}}@api_client.build_collection_param(opts[:'{{{paramName}}}'], :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}opts[:'{{{paramName}}}']{{/collectionFormat}} if !opts[:'{{{paramName}}}'].nil?
|
||||
{{/required}}
|
||||
{{/headerParams}}
|
||||
|
||||
|
||||
@@ -193,8 +193,8 @@ module {{moduleName}}
|
||||
|
||||
# Gets access_token using access_token_getter or uses the static access_token
|
||||
def access_token_with_refresh
|
||||
return access_token if access_token_getter.nil?
|
||||
access_token_getter.call
|
||||
return access_token if access_token_getter.nil?
|
||||
access_token_getter.call
|
||||
end
|
||||
|
||||
# Gets Basic Auth token string
|
||||
|
||||
@@ -93,7 +93,7 @@ export class {{classname}} {
|
||||
{{^isArray}}
|
||||
if ({{paramName}} !== undefined && {{paramName}} !== null) {
|
||||
{{#isDateTime}}
|
||||
queryParameters.append('{{baseName}}', <any>{{paramName}}.toISOString());
|
||||
queryParameters.append('{{baseName}}', (<any>{{paramName}}).toISOString());
|
||||
{{/isDateTime}}
|
||||
{{^isDateTime}}
|
||||
queryParameters.append('{{baseName}}', <any>{{paramName}});
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
*
|
||||
* 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 org.openapitools.codegen.config.CodegenConfigurator;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
|
||||
public class AllGeneratorsTest {
|
||||
|
||||
@Test
|
||||
public void testEachWithPetstore() throws IOException {
|
||||
for (final CodegenConfig codegenConfig : CodegenConfigLoader.getAll()) {
|
||||
File output = Files.createTempDirectory("test").toFile();
|
||||
output.deleteOnExit();
|
||||
|
||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||
.setGeneratorName(codegenConfig.getName())
|
||||
.setInputSpec("src/test/resources/3_0/petstore.yaml")
|
||||
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
|
||||
|
||||
final ClientOptInput clientOptInput = configurator.toClientOptInput();
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
List<File> files = generator.opts(clientOptInput).generate();
|
||||
|
||||
// Main intention of this test is to check that nothing crashes. Besides, we check here that
|
||||
// at least 1 file is generated, besides the common ".openapi-generator-ignore", "FILES" and "VERSION" files.
|
||||
Assert.assertTrue(files.size() >= 4);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -83,6 +83,7 @@ import java.util.stream.Collectors;
|
||||
import static org.openapitools.codegen.TestUtils.assertFileContains;
|
||||
import static org.openapitools.codegen.TestUtils.assertFileNotContains;
|
||||
import static org.openapitools.codegen.TestUtils.validateJavaSourceFiles;
|
||||
import static org.openapitools.codegen.languages.JavaClientCodegen.USE_ENUM_CASE_INSENSITIVE;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
@@ -244,6 +245,26 @@ public class JavaClientCodegenTest {
|
||||
TestUtils.ensureContainsFile(files, output, "src/main/java/xyz/abcdef/auth/HttpSignatureAuth.java");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testImportMappingResult() throws IOException {
|
||||
File output = Files.createTempDirectory("test").toFile();
|
||||
|
||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||
.addTypeMapping("OffsetDateTime", "Instant")
|
||||
.addImportMapping("OffsetDateTime", "java.time.Instant")
|
||||
.setGeneratorName("java")
|
||||
.setInputSpec("src/test/resources/3_0/echo_api.yaml")
|
||||
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
|
||||
|
||||
final ClientOptInput clientOptInput = configurator.toClientOptInput();
|
||||
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
|
||||
List<File> files = generator.opts(clientOptInput).generate();
|
||||
|
||||
TestUtils.assertFileContains(Paths.get(output + "/src/main/java/org/openapitools/client/api/QueryApi.java"), "import java.time.Instant;");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSupportedSecuritySchemesJersey() throws Exception {
|
||||
final JavaClientCodegen codegen = new JavaClientCodegen();
|
||||
@@ -2311,4 +2332,56 @@ public class JavaClientCodegenTest {
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEnumCaseInsensitive_issue8084() throws IOException {
|
||||
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||
output.deleteOnExit();
|
||||
|
||||
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/2_0/issue8084.yaml");
|
||||
final JavaClientCodegen codegen = new JavaClientCodegen();
|
||||
codegen.setOpenAPI(openAPI);
|
||||
codegen.setOutputDir(output.getAbsolutePath());
|
||||
codegen.additionalProperties().put(USE_ENUM_CASE_INSENSITIVE, "true");
|
||||
|
||||
ClientOptInput input = new ClientOptInput();
|
||||
input.openAPI(openAPI);
|
||||
input.config(codegen);
|
||||
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
|
||||
Map<String, File> files = generator.opts(input).generate().stream()
|
||||
.collect(Collectors.toMap(File::getName, Function.identity()));
|
||||
|
||||
JavaFileAssert javaFileAssert = JavaFileAssert.assertThat(files.get("EnumTest.java"));
|
||||
javaFileAssert
|
||||
.assertMethod("fromValue")
|
||||
.bodyContainsLines("if (b.value.equalsIgnoreCase(value)) {");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEnumCaseSensitive_issue8084() throws IOException {
|
||||
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||
output.deleteOnExit();
|
||||
|
||||
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/2_0/issue8084.yaml");
|
||||
final JavaClientCodegen codegen = new JavaClientCodegen();
|
||||
codegen.setOpenAPI(openAPI);
|
||||
codegen.setOutputDir(output.getAbsolutePath());
|
||||
codegen.additionalProperties().put(USE_ENUM_CASE_INSENSITIVE, "false");
|
||||
|
||||
ClientOptInput input = new ClientOptInput();
|
||||
input.openAPI(openAPI);
|
||||
input.config(codegen);
|
||||
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
|
||||
Map<String, File> files = generator.opts(input).generate().stream()
|
||||
.collect(Collectors.toMap(File::getName, Function.identity()));
|
||||
|
||||
JavaFileAssert javaFileAssert = JavaFileAssert.assertThat(files.get("EnumTest.java"));
|
||||
javaFileAssert
|
||||
.assertMethod("fromValue")
|
||||
.bodyContainsLines("if (b.value.equals(value)) {");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -226,10 +226,10 @@ public class TypeScriptAngularClientCodegenTest {
|
||||
|
||||
final String modelName = "FooResponse__links";
|
||||
final Schema schema = new Schema()
|
||||
.name(modelName)
|
||||
.description("an inline model with name previously prefixed with underscore")
|
||||
.addRequiredItem("self")
|
||||
.addProperty("self", new StringSchema());
|
||||
.name(modelName)
|
||||
.description("an inline model with name previously prefixed with underscore")
|
||||
.addRequiredItem("self")
|
||||
.addProperty("self", new StringSchema());
|
||||
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("test", schema);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
@@ -313,4 +313,35 @@ public class TypeScriptAngularClientCodegenTest {
|
||||
"export type Token = ExpressionToken | StringToken"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModelNameMappings() throws Exception {
|
||||
final String specPath = "src/test/resources/2_0/issue_8289.json";
|
||||
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put(TypeScriptAngularClientCodegen.TAGGED_UNIONS, "true");
|
||||
|
||||
File output = Files.createTempDirectory("test").toFile();
|
||||
output.deleteOnExit();
|
||||
|
||||
Map<String, String> modelNames = new HashMap<>();
|
||||
modelNames.put("File", "SystemFile");
|
||||
|
||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||
.setModelNameMappings(modelNames)
|
||||
.setGeneratorName("typescript-angular")
|
||||
.setInputSpec(specPath)
|
||||
.setAdditionalProperties(properties)
|
||||
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
|
||||
|
||||
final ClientOptInput clientOptInput = configurator.toClientOptInput();
|
||||
|
||||
Generator generator = new DefaultGenerator();
|
||||
generator.opts(clientOptInput).generate();
|
||||
|
||||
TestUtils.assertFileContains(
|
||||
Paths.get(output + "/model/folder.ts"),
|
||||
"files?: Array<SystemFile>;" // ensure it's an array of SystemFile (not Any)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"title": "Test swagger",
|
||||
"version": "0.1.0"
|
||||
},
|
||||
"definitions": {
|
||||
"File": {
|
||||
"title": "File",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Folder": {
|
||||
"title": "Folder",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"files": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/File"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"paths": {},
|
||||
"host": "localhost:3000",
|
||||
"schemes": ["http"]
|
||||
}
|
||||
@@ -1019,6 +1019,13 @@ paths:
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/Client'
|
||||
- in: header
|
||||
name: uuid_test
|
||||
description: to test uuid example value
|
||||
required: true
|
||||
default: 1111-2222-3333-4444
|
||||
type: string
|
||||
format: uuid
|
||||
responses:
|
||||
'200':
|
||||
description: successful operation
|
||||
|
||||
@@ -1155,6 +1155,26 @@ paths:
|
||||
responses:
|
||||
200:
|
||||
description: OK
|
||||
/fake/parameter-array-number:
|
||||
get:
|
||||
tags:
|
||||
- another_fake
|
||||
summary: parameter array number default value
|
||||
operationId: getParameterArrayNumber
|
||||
parameters:
|
||||
- name: array
|
||||
in: header
|
||||
description: array integer
|
||||
required: true
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
type: integer
|
||||
default:
|
||||
- 1
|
||||
responses:
|
||||
200:
|
||||
description: OK
|
||||
/values:
|
||||
get:
|
||||
tags:
|
||||
|
||||
@@ -569,6 +569,26 @@ paths:
|
||||
description: User not found
|
||||
security:
|
||||
- api_key: []
|
||||
/fake/uuid_default_value_test:
|
||||
get:
|
||||
tags:
|
||||
- fake
|
||||
summary: test uuid default value
|
||||
description: test uuid default value
|
||||
operationId: uuid_default_value
|
||||
parameters:
|
||||
- name: uuid_parameter
|
||||
in: header
|
||||
description: test uuid default value
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
format: uuid
|
||||
responses:
|
||||
'400':
|
||||
description: Invalid username supplied
|
||||
'404':
|
||||
description: User not found
|
||||
externalDocs:
|
||||
description: Find out more about Swagger
|
||||
url: 'http://swagger.io'
|
||||
@@ -746,3 +766,7 @@ components:
|
||||
another_property:
|
||||
type: integer
|
||||
format: int32
|
||||
uuid_default_value:
|
||||
type: string
|
||||
format: uuid
|
||||
default: 1111-2222-3333-4444
|
||||
|
||||
@@ -1253,6 +1253,24 @@ paths:
|
||||
responses:
|
||||
200:
|
||||
description: OK
|
||||
/fake/uuid_example:
|
||||
get:
|
||||
tags:
|
||||
- fake
|
||||
summary: test uuid example
|
||||
operationId: fakeUuidExample
|
||||
parameters:
|
||||
- name: uuid_example
|
||||
in: query
|
||||
description: uuid example
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
format: uuid
|
||||
example: 84529ad2-2265-4e15-b76b-c17025d848f6
|
||||
responses:
|
||||
"200":
|
||||
description: Get successful
|
||||
/fake/enum_ref_query_parameter:
|
||||
get:
|
||||
tags:
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -13,7 +13,7 @@
|
||||
<packaging>pom</packaging>
|
||||
<name>openapi-generator-project</name>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.0.0</version>
|
||||
<version>7.0.1-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<url>https://github.com/openapitools/openapi-generator</url>
|
||||
<scm>
|
||||
|
||||
@@ -1 +1 @@
|
||||
7.0.0-SNAPSHOT
|
||||
7.0.1-SNAPSHOT
|
||||
@@ -1 +1 @@
|
||||
7.0.0-SNAPSHOT
|
||||
7.0.1-SNAPSHOT
|
||||
@@ -1 +1 @@
|
||||
7.0.0-SNAPSHOT
|
||||
7.0.1-SNAPSHOT
|
||||
@@ -1 +1 @@
|
||||
7.0.0-SNAPSHOT
|
||||
7.0.1-SNAPSHOT
|
||||
@@ -9,7 +9,7 @@
|
||||
|------------ | ------------- | ------------- | -------------|
|
||||
|**suffix** | **String** | test suffix | [optional] |
|
||||
|**text** | **String** | Some text containing white spaces | [optional] |
|
||||
|**date** | **OffsetDateTime** | A date | [optional] |
|
||||
|**date** | **Instant** | A date | [optional] |
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ public class Example {
|
||||
defaultClient.setBasePath("http://localhost:3000");
|
||||
|
||||
QueryApi apiInstance = new QueryApi(defaultClient);
|
||||
OffsetDateTime datetimeQuery = OffsetDateTime.now(); // OffsetDateTime |
|
||||
Instant datetimeQuery = new Instant(); // Instant |
|
||||
LocalDate dateQuery = LocalDate.now(); // LocalDate |
|
||||
String stringQuery = "stringQuery_example"; // String |
|
||||
try {
|
||||
@@ -203,7 +203,7 @@ public class Example {
|
||||
|
||||
| Name | Type | Description | Notes |
|
||||
|------------- | ------------- | ------------- | -------------|
|
||||
| **datetimeQuery** | **OffsetDateTime**| | [optional] |
|
||||
| **datetimeQuery** | **Instant**| | [optional] |
|
||||
| **dateQuery** | **LocalDate**| | [optional] |
|
||||
| **stringQuery** | **String**| | [optional] |
|
||||
|
||||
@@ -251,7 +251,7 @@ public class Example {
|
||||
defaultClient.setBasePath("http://localhost:3000");
|
||||
|
||||
QueryApi apiInstance = new QueryApi(defaultClient);
|
||||
OffsetDateTime datetimeQuery = OffsetDateTime.now(); // OffsetDateTime |
|
||||
Instant datetimeQuery = new Instant(); // Instant |
|
||||
LocalDate dateQuery = LocalDate.now(); // LocalDate |
|
||||
String stringQuery = "stringQuery_example"; // String |
|
||||
try {
|
||||
@@ -275,7 +275,7 @@ public class Example {
|
||||
|
||||
| Name | Type | Description | Notes |
|
||||
|------------- | ------------- | ------------- | -------------|
|
||||
| **datetimeQuery** | **OffsetDateTime**| | [optional] |
|
||||
| **datetimeQuery** | **Instant**| | [optional] |
|
||||
| **dateQuery** | **LocalDate**| | [optional] |
|
||||
| **stringQuery** | **String**| | [optional] |
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import org.openapitools.client.Pair;
|
||||
|
||||
import org.openapitools.client.model.DataQuery;
|
||||
import java.time.LocalDate;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.Instant;
|
||||
import org.openapitools.client.model.Pet;
|
||||
import org.openapitools.client.model.StringEnumRef;
|
||||
import org.openapitools.client.model.TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter;
|
||||
@@ -192,7 +192,7 @@ public class QueryApi {
|
||||
* @return String
|
||||
* @throws ApiException if fails to make API call
|
||||
*/
|
||||
public String testQueryDatetimeDateString(OffsetDateTime datetimeQuery, LocalDate dateQuery, String stringQuery) throws ApiException {
|
||||
public String testQueryDatetimeDateString(Instant datetimeQuery, LocalDate dateQuery, String stringQuery) throws ApiException {
|
||||
ApiResponse<String> localVarResponse = testQueryDatetimeDateStringWithHttpInfo(datetimeQuery, dateQuery, stringQuery);
|
||||
return localVarResponse.getData();
|
||||
}
|
||||
@@ -206,7 +206,7 @@ public class QueryApi {
|
||||
* @return ApiResponse<String>
|
||||
* @throws ApiException if fails to make API call
|
||||
*/
|
||||
public ApiResponse<String> testQueryDatetimeDateStringWithHttpInfo(OffsetDateTime datetimeQuery, LocalDate dateQuery, String stringQuery) throws ApiException {
|
||||
public ApiResponse<String> testQueryDatetimeDateStringWithHttpInfo(Instant datetimeQuery, LocalDate dateQuery, String stringQuery) throws ApiException {
|
||||
HttpRequest.Builder localVarRequestBuilder = testQueryDatetimeDateStringRequestBuilder(datetimeQuery, dateQuery, stringQuery);
|
||||
try {
|
||||
HttpResponse<InputStream> localVarResponse = memberVarHttpClient.send(
|
||||
@@ -243,7 +243,7 @@ public class QueryApi {
|
||||
}
|
||||
}
|
||||
|
||||
private HttpRequest.Builder testQueryDatetimeDateStringRequestBuilder(OffsetDateTime datetimeQuery, LocalDate dateQuery, String stringQuery) throws ApiException {
|
||||
private HttpRequest.Builder testQueryDatetimeDateStringRequestBuilder(Instant datetimeQuery, LocalDate dateQuery, String stringQuery) throws ApiException {
|
||||
|
||||
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -49,7 +49,7 @@ public class DataQuery extends Query {
|
||||
private String text;
|
||||
|
||||
public static final String JSON_PROPERTY_DATE = "date";
|
||||
private OffsetDateTime date;
|
||||
private Instant date;
|
||||
|
||||
public DataQuery() {
|
||||
}
|
||||
@@ -104,7 +104,7 @@ public class DataQuery extends Query {
|
||||
}
|
||||
|
||||
|
||||
public DataQuery date(OffsetDateTime date) {
|
||||
public DataQuery date(Instant date) {
|
||||
this.date = date;
|
||||
return this;
|
||||
}
|
||||
@@ -117,14 +117,14 @@ public class DataQuery extends Query {
|
||||
@JsonProperty(JSON_PROPERTY_DATE)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
|
||||
public OffsetDateTime getDate() {
|
||||
public Instant getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_DATE)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
public void setDate(OffsetDateTime date) {
|
||||
public void setDate(Instant date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
7.0.0-SNAPSHOT
|
||||
7.0.1-SNAPSHOT
|
||||
@@ -42,7 +42,6 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
@@ -172,9 +171,9 @@ public class Bird {
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
for (Map.Entry<String, JsonElement> entry : entries) {
|
||||
if (!Bird.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Bird` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
@@ -172,9 +171,9 @@ public class Category {
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
for (Map.Entry<String, JsonElement> entry : entries) {
|
||||
if (!Category.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Category` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
@@ -208,9 +207,9 @@ public class DataQuery extends Query {
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
for (Map.Entry<String, JsonElement> entry : entries) {
|
||||
if (!DataQuery.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `DataQuery` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
@@ -460,9 +459,9 @@ public class DefaultValue {
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
for (Map.Entry<String, JsonElement> entry : entries) {
|
||||
if (!DefaultValue.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `DefaultValue` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
|
||||
@@ -43,7 +43,6 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
@@ -203,9 +202,9 @@ public class NumberPropertiesOnly {
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
for (Map.Entry<String, JsonElement> entry : entries) {
|
||||
if (!NumberPropertiesOnly.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `NumberPropertiesOnly` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
@@ -355,9 +354,9 @@ public class Pet {
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
for (Map.Entry<String, JsonElement> entry : entries) {
|
||||
if (!Pet.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Pet` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
|
||||
@@ -44,7 +44,6 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
@@ -42,7 +42,6 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
@@ -172,9 +171,9 @@ public class Tag {
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
for (Map.Entry<String, JsonElement> entry : entries) {
|
||||
if (!Tag.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Tag` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
@@ -228,9 +227,9 @@ public class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
for (Map.Entry<String, JsonElement> entry : entries) {
|
||||
if (!TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
|
||||
@@ -44,7 +44,6 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
@@ -154,9 +153,9 @@ public class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter {
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
for (Map.Entry<String, JsonElement> entry : entries) {
|
||||
if (!TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
7.0.0-SNAPSHOT
|
||||
7.0.1-SNAPSHOT
|
||||
@@ -1 +1 @@
|
||||
7.0.0-SNAPSHOT
|
||||
7.0.1-SNAPSHOT
|
||||
@@ -1 +1 @@
|
||||
7.0.0-SNAPSHOT
|
||||
7.0.1-SNAPSHOT
|
||||
@@ -43,7 +43,6 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
@@ -304,9 +303,9 @@ public class SomeObj implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
for (Map.Entry<String, JsonElement> entry : entries) {
|
||||
if (!SomeObj.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SomeObj` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
7.0.0-SNAPSHOT
|
||||
7.0.1-SNAPSHOT
|
||||
@@ -77,7 +77,7 @@ class DefaultApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient
|
||||
}
|
||||
ResponseType.ServerError -> {
|
||||
val localVarError = localVarResponse as ServerError<*>
|
||||
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
|
||||
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()} ${localVarError.body}", localVarError.statusCode, localVarResponse)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
7.0.0-SNAPSHOT
|
||||
7.0.1-SNAPSHOT
|
||||
@@ -1 +1 @@
|
||||
7.0.0-SNAPSHOT
|
||||
7.0.1-SNAPSHOT
|
||||
@@ -1 +1 @@
|
||||
7.0.0-SNAPSHOT
|
||||
7.0.1-SNAPSHOT
|
||||
@@ -1 +1 @@
|
||||
7.0.0-SNAPSHOT
|
||||
7.0.1-SNAPSHOT
|
||||
@@ -1 +1 @@
|
||||
7.0.0-SNAPSHOT
|
||||
7.0.1-SNAPSHOT
|
||||
@@ -1 +1 @@
|
||||
7.0.0-SNAPSHOT
|
||||
7.0.1-SNAPSHOT
|
||||
@@ -1 +1 @@
|
||||
7.0.0-SNAPSHOT
|
||||
7.0.1-SNAPSHOT
|
||||
@@ -1 +1 @@
|
||||
7.0.0-SNAPSHOT
|
||||
7.0.1-SNAPSHOT
|
||||
@@ -1 +1 @@
|
||||
7.0.0-SNAPSHOT
|
||||
7.0.1-SNAPSHOT
|
||||
@@ -1 +1 @@
|
||||
7.0.0-SNAPSHOT
|
||||
7.0.1-SNAPSHOT
|
||||
@@ -1,26 +1,25 @@
|
||||
-- Swagger Petstore
|
||||
-- This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special_key` to test the authorization filters.
|
||||
-- OpenAPI spec version: 1.0.0
|
||||
-- OpenAPI Petstore
|
||||
-- This is a sample server Petstore server. For this sample, you can use the api key `special_key` to test the authorization filters.
|
||||
-- The version of the OpenAPI document: 1.0.0
|
||||
--
|
||||
-- https://github.com/swagger-api/swagger-codegen.git
|
||||
-- https://openapi-generator.tech
|
||||
--
|
||||
-- NOTE: Auto generated by the swagger code generator program.
|
||||
-- NOTE: Auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
with "config";
|
||||
with "utilada_sys";
|
||||
with "utilada_xml";
|
||||
with "utilada_http";
|
||||
with "utilada_curl";
|
||||
with "security";
|
||||
with "swagger";
|
||||
project Petstore is
|
||||
|
||||
Mains := ("petstore.adb");
|
||||
for Main use Mains;
|
||||
for Source_Dirs use ("src", "src/model", "src/client");
|
||||
for Object_Dir use "./" & Config'Exec_Dir & "/bin";
|
||||
for Object_Dir use "obj/";
|
||||
for Source_Dirs use ("src", "src/model", "src/client");
|
||||
Mains := ("samples-petstore-client.adb");
|
||||
|
||||
package Binder renames Config.Binder;
|
||||
package Builder renames Config.Builder;
|
||||
package Compiler renames Config.Compiler;
|
||||
package Linker renames Config.Linker;
|
||||
package Binder renames Config.Binder;
|
||||
package Builder renames Config.Builder;
|
||||
package Compiler renames Config.Compiler;
|
||||
package Linker renames Config.Linker;
|
||||
|
||||
end Petstore;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
-- The version of the OpenAPI document: 1.0.0
|
||||
--
|
||||
--
|
||||
-- NOTE: This package is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
-- NOTE: This package is auto generated by OpenAPI-Generator 7.0.1-SNAPSHOT.
|
||||
-- https://openapi-generator.tech
|
||||
-- Do not edit the class manually.
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user