mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-10 09:16:11 +00:00
Compare commits
1 Commits
v6.5.0
...
devhl-labs
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a4a853430e |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -35,7 +35,6 @@ packages/
|
||||
nbproject/
|
||||
nbactions.xml
|
||||
nb-configuration.xml
|
||||
.direnv/
|
||||
|
||||
.settings
|
||||
|
||||
|
||||
14
README.md
14
README.md
@@ -263,20 +263,6 @@ If you don't have maven installed, you may directly use the included [maven wrap
|
||||
./mvnw clean install
|
||||
```
|
||||
|
||||
#### Nix users
|
||||
|
||||
If you're a nix user, you can enter OpenAPI Generator shell, by typing:
|
||||
```sh
|
||||
nix develop
|
||||
```
|
||||
It will enter a shell with Java 8 and Maven installed.
|
||||
|
||||
Direnv supports automatically loading of the nix developer shell, so if you're using direnv too, type:
|
||||
```sh
|
||||
direnv allow
|
||||
```
|
||||
and have `java` and `mvn` set up with correct versions each time you enter project directory.
|
||||
|
||||
The default build contains minimal static analysis (via CheckStyle). To run your build with PMD and Spotbugs, use the `static-analysis` profile:
|
||||
|
||||
```sh
|
||||
|
||||
@@ -4,3 +4,4 @@ inputSpec: modules/openapi-generator/src/test/resources/3_0/echo_api.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/python-nextgen
|
||||
additionalProperties:
|
||||
hideGenerationTimestamp: "true"
|
||||
allowStringInDateTimeParameters: true
|
||||
|
||||
@@ -458,6 +458,7 @@ OpenAPI Normalizer (off by default) transforms the input OpenAPI doc/spec (which
|
||||
|
||||
- `REF_AS_PARENT_IN_ALLOF`: when set to `true`, child schemas in `allOf` is considered a parent if it's a `$ref` (instead of inline schema).
|
||||
|
||||
|
||||
Example:
|
||||
```
|
||||
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -i modules/openapi-generator/src/test/resources/3_0/allOf_extension_parent.yaml -o /tmp/java-okhttp/ --openapi-normalizer REF_AS_PARENT_IN_ALLOF=true
|
||||
@@ -511,11 +512,3 @@ Example:
|
||||
```
|
||||
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -i modules/openapi-generator/src/test/resources/3_0/addUnsignedToIntegerWithInvalidMaxValue_test.yaml -o /tmp/java-okhttp/ --openapi-normalizer ADD_UNSIGNED_TO_INTEGER_WITH_INVALID_MAX_VALUE=true
|
||||
```
|
||||
|
||||
- `REFACTOR_ALLOF_WITH_PROPERTIES_ONLY`: When set to true, refactor schema with allOf and properties in the same level to a schema with allOf only and, the allOf contains a new schema containing the properties in the top level.
|
||||
|
||||
Example:
|
||||
```
|
||||
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -i modules/openapi-generator/src/test/resources/3_0/allOf_extension_parent.yaml -o /tmp/java-okhttp/ --openapi-normalizer REFACTOR_ALLOF_WITH_PROPERTIES_ONLY=true
|
||||
```
|
||||
|
||||
|
||||
@@ -29,13 +29,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|artifactId|artifactId in generated pom.xml. This also becomes part of the generated library's filename| |openapi-micronaut-client|
|
||||
|artifactUrl|artifact URL in generated pom.xml| |https://github.com/openapitools/openapi-generator|
|
||||
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|
||||
|authorizationFilterPattern|Configure the authorization filter pattern for the client. Generally defined when generating clients from multiple specification files| |null|
|
||||
|basePathSeparator|Configure the separator to use between the application name and base path when referencing the property| |-|
|
||||
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|
||||
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|
||||
|build|Specify for which build tool to generate files|<dl><dt>**gradle**</dt><dd>Gradle configuration is generated for the project</dd><dt>**all**</dt><dd>Both Gradle and Maven configurations are generated</dd><dt>**maven**</dt><dd>Maven configuration is generated for the project</dd></dl>|all|
|
||||
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|
||||
|clientId|Configure the service ID for the Client| |null|
|
||||
|configureAuth|Configure all the authorization methods as specified in the file| |false|
|
||||
|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
|
||||
|dateFormat|Specify the format pattern of date as a string| |null|
|
||||
|
||||
@@ -19,6 +19,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|allowStringInDateTimeParameters|Allow string as input to datetime/date parameters for backward compartibility.| |false|
|
||||
|dateFormat|date format for query parameters| |%Y-%m-%d|
|
||||
|datetimeFormat|datetime format for query parameters| |%Y-%m-%dT%H:%M:%S%z|
|
||||
|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|true|
|
||||
|
||||
42
flake.lock
generated
42
flake.lock
generated
@@ -1,42 +0,0 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1676283394,
|
||||
"narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1678083093,
|
||||
"narHash": "sha256-eTkS9GcdSAYA3cE9zCAAs9wY3+oM2zT45ydIkAcEFFQ=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "684306b246d05168e42425a3610df7e2c4d51fcd",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
23
flake.nix
23
flake.nix
@@ -1,23 +0,0 @@
|
||||
{
|
||||
description = "OpenAPI generator nix flake";
|
||||
|
||||
inputs.nixpkgs.url = "github:nixos/nixpkgs";
|
||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils, ... }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
in
|
||||
{
|
||||
devShells.default = pkgs.mkShell
|
||||
{
|
||||
buildInputs = with pkgs;[
|
||||
jdk8
|
||||
maven
|
||||
];
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>6.5.0</version>
|
||||
<version>6.5.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>6.5.0</version>
|
||||
<version>6.5.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# RELEASE_VERSION
|
||||
openApiGeneratorVersion=6.5.0
|
||||
openApiGeneratorVersion=6.5.0-SNAPSHOT
|
||||
# /RELEASE_VERSION
|
||||
|
||||
# BEGIN placeholders
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>6.5.0</version>
|
||||
<version>6.5.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# RELEASE_VERSION
|
||||
openApiGeneratorVersion=6.5.0
|
||||
openApiGeneratorVersion=6.5.0-SNAPSHOT
|
||||
# /RELEASE_VERSION
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>6.5.0</version>
|
||||
<version>6.5.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
@@ -67,7 +67,6 @@
|
||||
<apiPackage>remote.org.openapitools.client.api</apiPackage>
|
||||
<modelPackage>remote.org.openapitools.client.model</modelPackage>
|
||||
<invokerPackage>remote.org.openapitools.client</invokerPackage>
|
||||
<cleanupOutput>true</cleanupOutput>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
@@ -77,8 +76,8 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
<proc>none</proc>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>6.5.0</version>
|
||||
<version>6.5.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
@@ -26,7 +26,6 @@
|
||||
<configuration>
|
||||
<!-- specify the swagger yaml -->
|
||||
<inputSpec>${project.basedir}/swagger.yaml</inputSpec>
|
||||
<cleanupOutput>true</cleanupOutput>
|
||||
|
||||
<!-- target to generate kotlin client code -->
|
||||
<generatorName>kotlin</generatorName>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>6.5.0</version>
|
||||
<version>6.5.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@@ -59,8 +59,8 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
<proc>none</proc>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>6.5.0</version>
|
||||
<version>6.5.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>6.5.0</version>
|
||||
<version>6.5.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>6.5.0</version>
|
||||
<version>6.5.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>6.5.0</version>
|
||||
<version>6.5.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -41,7 +41,6 @@ import java.util.Set;
|
||||
import com.google.common.io.ByteSource;
|
||||
import com.google.common.io.CharSource;
|
||||
import io.swagger.v3.parser.util.ClasspathHelper;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecution;
|
||||
@@ -100,9 +99,6 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
@Parameter(name = "output", property = "openapi.generator.maven.plugin.output")
|
||||
private File output;
|
||||
|
||||
@Parameter(name = "cleanupOutput", property = "openapi.generator.maven.plugin.cleanupOutput", defaultValue = "false")
|
||||
private boolean cleanupOutput;
|
||||
|
||||
/**
|
||||
* Location of the OpenAPI spec, as URL or file.
|
||||
*/
|
||||
@@ -498,16 +494,6 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
LifecyclePhase.GENERATE_TEST_SOURCES.id().equals(mojo.getLifecyclePhase()) ?
|
||||
"generated-test-sources/openapi" : "generated-sources/openapi");
|
||||
}
|
||||
|
||||
if (cleanupOutput) {
|
||||
try {
|
||||
FileUtils.deleteDirectory(output);
|
||||
LOGGER.info("Previous run output is removed from {}", output);
|
||||
} catch (IOException e) {
|
||||
LOGGER.warn("Failed to clean-up output directory {}", output, e);
|
||||
}
|
||||
}
|
||||
|
||||
addCompileSourceRootIfConfigured();
|
||||
|
||||
try {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>6.5.0</version>
|
||||
<version>6.5.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>6.5.0</version>
|
||||
<version>6.5.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -1209,25 +1209,10 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/*
|
||||
* To clean up mapped models if needed and add mapped models to imports
|
||||
*
|
||||
* @param cleanUpMappedModels Clean up mapped models if set to true
|
||||
*/
|
||||
public void addDiscriminatorMappedModelsImports(boolean cleanUpMappedModels) {
|
||||
public void addDiscriminatorMappedModelsImports() {
|
||||
if (discriminator == null || discriminator.getMappedModels() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cleanUpMappedModels && !this.hasChildren && // no child
|
||||
(this.oneOf == null || this.oneOf.isEmpty()) && // not oneOf
|
||||
(this.anyOf == null || this.anyOf.isEmpty())) { // not anyOf
|
||||
//clear the mapping
|
||||
discriminator.setMappedModels(null);
|
||||
return;
|
||||
}
|
||||
|
||||
// import child schemas defined in mapped models
|
||||
for (CodegenDiscriminator.MappedModel mm : discriminator.getMappedModels()) {
|
||||
if (!"".equals(mm.getModelName())) {
|
||||
imports.add(mm.getModelName());
|
||||
|
||||
@@ -159,7 +159,6 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
||||
public boolean isCircularReference;
|
||||
public boolean isDiscriminator;
|
||||
public boolean isNew; // true when this property overrides an inherited property
|
||||
public Boolean isOverridden; // true if the property is a parent property (not defined in child/current schema)
|
||||
public List<String> _enum;
|
||||
public Map<String, Object> allowableValues;
|
||||
// If 'additionalProperties' is not set, items is null.
|
||||
@@ -1068,7 +1067,6 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
||||
sb.append(", isCircularReference=").append(isCircularReference);
|
||||
sb.append(", isDiscriminator=").append(isDiscriminator);
|
||||
sb.append(", isNew=").append(isNew);
|
||||
sb.append(", isOverridden=").append(isOverridden);
|
||||
sb.append(", _enum=").append(_enum);
|
||||
sb.append(", allowableValues=").append(allowableValues);
|
||||
sb.append(", items=").append(items);
|
||||
@@ -1161,7 +1159,6 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
||||
isCircularReference == that.isCircularReference &&
|
||||
isDiscriminator == that.isDiscriminator &&
|
||||
isNew == that.isNew &&
|
||||
isOverridden == that.isOverridden &&
|
||||
hasValidation == that.hasValidation &&
|
||||
isInherited == that.isInherited &&
|
||||
isXmlAttribute == that.isXmlAttribute &&
|
||||
@@ -1239,7 +1236,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
||||
isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary, isFile,
|
||||
isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isPassword, isFreeFormObject,
|
||||
isArray, isMap, isEnum, isInnerEnum, isEnumRef, isAnyType, isReadOnly, isWriteOnly, isNullable, isShort,
|
||||
isUnboundedInteger, isSelfReference, isCircularReference, isDiscriminator, isNew, isOverridden, _enum,
|
||||
isUnboundedInteger, isSelfReference, isCircularReference, isDiscriminator, isNew, _enum,
|
||||
allowableValues, items, mostInnerItems, additionalProperties, vars, requiredVars,
|
||||
vendorExtensions, hasValidation, isInherited, discriminatorValue, nameInCamelCase,
|
||||
nameInSnakeCase, enumName, maxItems, minItems, isXmlAttribute, xmlPrefix, xmlName,
|
||||
|
||||
@@ -50,7 +50,6 @@ import org.openapitools.codegen.CodegenDiscriminator.MappedModel;
|
||||
import org.openapitools.codegen.api.TemplatingEngineAdapter;
|
||||
import org.openapitools.codegen.config.GlobalSettings;
|
||||
import org.openapitools.codegen.examples.ExampleGenerator;
|
||||
import org.openapitools.codegen.languages.PythonClientCodegen;
|
||||
import org.openapitools.codegen.languages.RustServerCodegen;
|
||||
import org.openapitools.codegen.meta.FeatureSet;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
@@ -612,7 +611,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
/**
|
||||
* Loop through all models to update different flags (e.g. isSelfReference), children models, etc
|
||||
* and update mapped models for import.
|
||||
*
|
||||
* @param objs Map of models
|
||||
* @return maps of models with various updates
|
||||
@@ -663,17 +661,10 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
// loop through properties of each model to detect self-reference
|
||||
// and update mapped models for import
|
||||
for (ModelsMap entry : objs.values()) {
|
||||
for (ModelMap mo : entry.getModels()) {
|
||||
CodegenModel cm = mo.getModel();
|
||||
removeSelfReferenceImports(cm);
|
||||
|
||||
if (!this.getLegacyDiscriminatorBehavior()) {
|
||||
// skip cleaning up mapped models for python client generator
|
||||
// which uses its own logic
|
||||
cm.addDiscriminatorMappedModelsImports(!(this instanceof PythonClientCodegen));
|
||||
}
|
||||
}
|
||||
}
|
||||
setCircularReferences(allModels);
|
||||
@@ -2664,6 +2655,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (m.discriminator == null && innerSchema.getDiscriminator() != null) {
|
||||
LOGGER.debug("discriminator is set to null (not correctly set earlier): {}", m.name);
|
||||
m.setDiscriminator(createDiscriminator(m.name, innerSchema, this.openAPI));
|
||||
if (!this.getLegacyDiscriminatorBehavior()) {
|
||||
m.addDiscriminatorMappedModelsImports();
|
||||
}
|
||||
modelDiscriminators++;
|
||||
}
|
||||
|
||||
@@ -2818,7 +2812,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (Boolean.TRUE.equals(schema.getNullable())) {
|
||||
m.isNullable = Boolean.TRUE;
|
||||
}
|
||||
|
||||
// end of code block for composed schema
|
||||
}
|
||||
|
||||
@@ -3006,6 +2999,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
m.isAlias = (typeAliases.containsKey(name)
|
||||
|| isAliasOfSimpleTypes(schema)); // check if the unaliased schema is an alias of simple OAS types
|
||||
m.setDiscriminator(createDiscriminator(name, schema, this.openAPI));
|
||||
if (!this.getLegacyDiscriminatorBehavior()) {
|
||||
m.addDiscriminatorMappedModelsImports();
|
||||
}
|
||||
|
||||
if (schema.getDeprecated() != null) {
|
||||
m.isDeprecated = schema.getDeprecated();
|
||||
@@ -3459,15 +3455,15 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
break;
|
||||
}
|
||||
currentSchemaName = queue.remove(0);
|
||||
MappedModel mm = new MappedModel(currentSchemaName, toModelName(currentSchemaName));
|
||||
descendentSchemas.add(mm);
|
||||
Schema cs = schemas.get(currentSchemaName);
|
||||
Map<String, Object> vendorExtensions = cs.getExtensions();
|
||||
String mappingName =
|
||||
Optional.ofNullable(vendorExtensions)
|
||||
.map(ve -> ve.get("x-discriminator-value"))
|
||||
.map(discriminatorValue -> (String) discriminatorValue)
|
||||
.orElse(currentSchemaName);
|
||||
MappedModel mm = new MappedModel(mappingName, toModelName(currentSchemaName));
|
||||
descendentSchemas.add(mm);
|
||||
if (vendorExtensions != null && !vendorExtensions.isEmpty() && vendorExtensions.containsKey("x-discriminator-value")) {
|
||||
String xDiscriminatorValue = (String) vendorExtensions.get("x-discriminator-value");
|
||||
mm = new MappedModel(xDiscriminatorValue, toModelName(currentSchemaName));
|
||||
descendentSchemas.add(mm);
|
||||
}
|
||||
}
|
||||
return descendentSchemas;
|
||||
}
|
||||
@@ -3517,11 +3513,10 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// for schemas that allOf inherit from this schema, add those descendants to this discriminator map
|
||||
List<MappedModel> otherDescendants = getAllOfDescendants(schemaName, openAPI);
|
||||
for (MappedModel otherDescendant : otherDescendants) {
|
||||
// add only if the mapping names are not the same and the model names are not the same
|
||||
// add only if the mapping names are not the same
|
||||
boolean matched = false;
|
||||
for (MappedModel uniqueDescendant : uniqueDescendants) {
|
||||
if (uniqueDescendant.getMappingName().equals(otherDescendant.getMappingName())
|
||||
|| (uniqueDescendant.getModelName().equals(otherDescendant.getModelName()))) {
|
||||
if (uniqueDescendant.getMappingName().equals(otherDescendant.getMappingName())) {
|
||||
matched = true;
|
||||
break;
|
||||
}
|
||||
@@ -3795,8 +3790,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
Schema original = null;
|
||||
// check if it's allOf (only 1 sub schema) with or without default/nullable/etc set in the top level
|
||||
if (ModelUtils.isAllOf(p) && p.getAllOf().size() == 1 && !(this instanceof PythonClientCodegen)) {
|
||||
// check if it's allOf (only 1 sub schema) with default/nullable/etc set in the top level
|
||||
if (ModelUtils.isAllOf(p) && p.getAllOf().size() == 1 && ModelUtils.hasCommonAttributesDefined(p) ) {
|
||||
if (p.getAllOf().get(0) instanceof Schema) {
|
||||
original = p;
|
||||
p = (Schema) p.getAllOf().get(0);
|
||||
@@ -4002,7 +3997,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// restore original schema with default value, nullable, readonly etc
|
||||
if (original != null) {
|
||||
p = original;
|
||||
// evaluate common attributes if defined in the top level
|
||||
// evaluate common attributes defined in the top level
|
||||
if (p.getNullable() != null) {
|
||||
property.isNullable = p.getNullable();
|
||||
} else if (p.getExtensions() != null && p.getExtensions().containsKey("x-nullable")) {
|
||||
@@ -5724,7 +5719,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
for (CodegenProperty var : cm.vars) {
|
||||
// create a map of codegen properties for lookup later
|
||||
varsMap.put(var.baseName, var);
|
||||
var.isOverridden = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5749,10 +5743,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
cp = fromProperty(key, prop, mandatory.contains(key));
|
||||
}
|
||||
|
||||
if (cm != null && cm.allVars == vars && cp.isOverridden == null) { // processing allVars and it's a parent property
|
||||
cp.isOverridden = true;
|
||||
}
|
||||
|
||||
vars.add(cp);
|
||||
m.setHasVars(true);
|
||||
|
||||
@@ -7770,7 +7760,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
CodegenModel cm = new CodegenModel();
|
||||
|
||||
cm.setDiscriminator(createDiscriminator("", cs, openAPI));
|
||||
|
||||
if (!this.getLegacyDiscriminatorBehavior()) {
|
||||
cm.addDiscriminatorMappedModelsImports();
|
||||
}
|
||||
for (Schema o : Optional.ofNullable(cs.getOneOf()).orElse(Collections.emptyList())) {
|
||||
if (o.get$ref() == null) {
|
||||
if (cm.discriminator != null && o.get$ref() == null) {
|
||||
|
||||
@@ -82,11 +82,6 @@ public class OpenAPINormalizer {
|
||||
final String ADD_UNSIGNED_TO_INTEGER_WITH_INVALID_MAX_VALUE = "ADD_UNSIGNED_TO_INTEGER_WITH_INVALID_MAX_VALUE";
|
||||
boolean addUnsignedToIntegerWithInvalidMaxValue;
|
||||
|
||||
// when set to true, refactor schema with allOf and properties in the same level to a schema with allOf only and
|
||||
// the allOf contains a new schema containing the properties in the top level
|
||||
final String REFACTOR_ALLOF_WITH_PROPERTIES_ONLY = "REFACTOR_ALLOF_WITH_PROPERTIES_ONLY";
|
||||
boolean refactorAllOfWithPropertiesOnly;
|
||||
|
||||
// ============= end of rules =============
|
||||
|
||||
/**
|
||||
@@ -146,10 +141,6 @@ public class OpenAPINormalizer {
|
||||
if (enableAll || "true".equalsIgnoreCase(rules.get(ADD_UNSIGNED_TO_INTEGER_WITH_INVALID_MAX_VALUE))) {
|
||||
addUnsignedToIntegerWithInvalidMaxValue = true;
|
||||
}
|
||||
|
||||
if (enableAll || "true".equalsIgnoreCase(rules.get(REFACTOR_ALLOF_WITH_PROPERTIES_ONLY))) {
|
||||
refactorAllOfWithPropertiesOnly = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -355,9 +346,6 @@ public class OpenAPINormalizer {
|
||||
return normalizeOneOf(schema, visitedSchemas);
|
||||
} else if (ModelUtils.isAnyOf(schema)) { // anyOf
|
||||
return normalizeAnyOf(schema, visitedSchemas);
|
||||
} else if (ModelUtils.isAllOfWithProperties(schema)) { // allOf with properties
|
||||
schema = normalizeAllOfWithProperties(schema, visitedSchemas);
|
||||
normalizeSchema(schema, visitedSchemas);
|
||||
} else if (ModelUtils.isAllOf(schema)) { // allOf
|
||||
return normalizeAllOf(schema, visitedSchemas);
|
||||
} else if (ModelUtils.isComposedSchema(schema)) { // composed schema
|
||||
@@ -439,20 +427,6 @@ public class OpenAPINormalizer {
|
||||
return schema;
|
||||
}
|
||||
|
||||
private Schema normalizeAllOfWithProperties(Schema schema, Set<Schema> visitedSchemas) {
|
||||
for (Object item : schema.getAllOf()) {
|
||||
if (!(item instanceof Schema)) {
|
||||
throw new RuntimeException("Error! allOf schema is not of the type Schema: " + item);
|
||||
}
|
||||
// normalize allOf sub schemas one by one
|
||||
normalizeSchema((Schema) item, visitedSchemas);
|
||||
}
|
||||
// process rules here
|
||||
schema = processRefactorAllOfWithPropertiesOnly(schema);
|
||||
|
||||
return schema;
|
||||
}
|
||||
|
||||
private Schema normalizeOneOf(Schema schema, Set<Schema> visitedSchemas) {
|
||||
for (Object item : schema.getOneOf()) {
|
||||
if (item == null) {
|
||||
@@ -785,46 +759,5 @@ public class OpenAPINormalizer {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* When set to true, refactor schema with allOf and properties in the same level to a schema with allOf only and
|
||||
* the allOf contains a new schema containing the properties in the top level.
|
||||
*
|
||||
* @param schema Schema
|
||||
* @return Schema
|
||||
*/
|
||||
private Schema processRefactorAllOfWithPropertiesOnly(Schema schema) {
|
||||
if (!refactorAllOfWithPropertiesOnly && !enableAll) {
|
||||
return schema;
|
||||
}
|
||||
|
||||
ObjectSchema os = new ObjectSchema();
|
||||
// set the properties, etc of the new schema to the properties of schema
|
||||
os.setProperties(schema.getProperties());
|
||||
os.setRequired(schema.getRequired());
|
||||
os.setAdditionalProperties(schema.getAdditionalProperties());
|
||||
os.setNullable(schema.getNullable());
|
||||
os.setDescription(schema.getDescription());
|
||||
os.setDeprecated(schema.getDeprecated());
|
||||
os.setExample(schema.getExample());
|
||||
os.setExamples(schema.getExamples());
|
||||
os.setTitle(schema.getTitle());
|
||||
schema.getAllOf().add(os); // move new schema as a child schema of allOf
|
||||
// clean up by removing properties, etc
|
||||
schema.setProperties(null);
|
||||
schema.setRequired(null);
|
||||
schema.setAdditionalProperties(null);
|
||||
schema.setNullable(null);
|
||||
schema.setDescription(null);
|
||||
schema.setDeprecated(null);
|
||||
schema.setExample(null);
|
||||
schema.setExamples(null);
|
||||
schema.setTitle(null);
|
||||
|
||||
// at this point the schema becomes a simple allOf (no properties) with an additional schema containing
|
||||
// the properties
|
||||
|
||||
return schema;
|
||||
}
|
||||
|
||||
// ===================== end of rules =====================
|
||||
}
|
||||
|
||||
@@ -555,8 +555,8 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
|
||||
public CodegenProperty fromProperty(String name, Schema p, boolean required) {
|
||||
final CodegenProperty property = super.fromProperty(name, p, required);
|
||||
|
||||
// Handle composed properties and it's NOT allOf with a single ref only
|
||||
if (ModelUtils.isComposedSchema(p) && !(ModelUtils.isAllOf(p) && p.getAllOf().size() == 1)) {
|
||||
// Handle composed properties
|
||||
if (ModelUtils.isComposedSchema(p)) {
|
||||
ComposedSchema composed = (ComposedSchema) p;
|
||||
|
||||
// Count the occurrences of allOf/anyOf/oneOf with exactly one child element
|
||||
|
||||
@@ -2287,7 +2287,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
operation.allParams.add(p);
|
||||
}
|
||||
}
|
||||
operation.hasParams = !operation.allParams.isEmpty();
|
||||
}
|
||||
|
||||
private boolean shouldBeImplicitHeader(CodegenParameter parameter) {
|
||||
|
||||
@@ -337,6 +337,12 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
|
||||
objs = super.postProcessModels(objs);
|
||||
List<ModelMap> models = objs.getModels();
|
||||
ProcessUtils.addIndexToProperties(models, 1);
|
||||
|
||||
for (ModelMap mo : models) {
|
||||
CodegenModel cm = mo.getModel();
|
||||
cm.imports = rewriteImports(cm.imports, true);
|
||||
cm.vendorExtensions.put("x-has-vars", !cm.vars.isEmpty());
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
|
||||
@@ -577,16 +583,6 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
|
||||
adaptToDartInheritance(objs);
|
||||
syncRootTypesWithInnerVars(objs);
|
||||
}
|
||||
|
||||
// loop through models to update the imports
|
||||
for (ModelsMap entry : objs.values()) {
|
||||
for (ModelMap mo : entry.getModels()) {
|
||||
CodegenModel cm = mo.getModel();
|
||||
cm.imports = rewriteImports(cm.imports, true);
|
||||
cm.vendorExtensions.put("x-has-vars", !cm.vars.isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
@@ -734,10 +730,6 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
|
||||
resultImports.add(i);
|
||||
} else if (importMapping().containsKey(modelImport)) {
|
||||
resultImports.add(importMapping().get(modelImport));
|
||||
} else if (modelImport.startsWith("dart:")) { // import dart:* directly
|
||||
resultImports.add(modelImport);
|
||||
} else if (modelImport.startsWith("package:")) { // e.g. package:openapi/src/model/child.dart
|
||||
resultImports.add(modelImport);
|
||||
} else {
|
||||
resultImports.add("package:" + pubName + "/" + sourceFolder + "/" + modelPackage() + "/" + underscore(modelImport) + ".dart");
|
||||
}
|
||||
|
||||
@@ -13,20 +13,12 @@ import org.openapitools.codegen.meta.Stability;
|
||||
public class JavaMicronautClientCodegen extends JavaMicronautAbstractCodegen {
|
||||
|
||||
public static final String OPT_CONFIGURE_AUTH = "configureAuth";
|
||||
public static final String OPT_CONFIGURE_AUTH_FILTER_PATTERN = "configureAuthFilterPattern";
|
||||
public static final String OPT_CONFIGURE_CLIENT_ID = "configureClientId";
|
||||
public static final String ADDITIONAL_CLIENT_TYPE_ANNOTATIONS = "additionalClientTypeAnnotations";
|
||||
public static final String AUTHORIZATION_FILTER_PATTERN = "authorizationFilterPattern";
|
||||
public static final String BASE_PATH_SEPARATOR = "basePathSeparator";
|
||||
public static final String CLIENT_ID = "clientId";
|
||||
|
||||
public static final String NAME = "java-micronaut-client";
|
||||
|
||||
protected boolean configureAuthorization;
|
||||
protected List<String> additionalClientTypeAnnotations;
|
||||
protected String authorizationFilterPattern;
|
||||
protected String basePathSeparator = "-";
|
||||
protected String clientId;
|
||||
|
||||
public JavaMicronautClientCodegen() {
|
||||
super();
|
||||
@@ -41,9 +33,6 @@ public class JavaMicronautClientCodegen extends JavaMicronautAbstractCodegen {
|
||||
|
||||
cliOptions.add(CliOption.newBoolean(OPT_CONFIGURE_AUTH, "Configure all the authorization methods as specified in the file", configureAuthorization));
|
||||
cliOptions.add(CliOption.newString(ADDITIONAL_CLIENT_TYPE_ANNOTATIONS, "Additional annotations for client type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)"));
|
||||
cliOptions.add(CliOption.newString(AUTHORIZATION_FILTER_PATTERN, "Configure the authorization filter pattern for the client. Generally defined when generating clients from multiple specification files"));
|
||||
cliOptions.add(CliOption.newString(BASE_PATH_SEPARATOR, "Configure the separator to use between the application name and base path when referencing the property").defaultValue(basePathSeparator));
|
||||
cliOptions.add(CliOption.newString(CLIENT_ID, "Configure the service ID for the Client"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,14 +66,6 @@ public class JavaMicronautClientCodegen extends JavaMicronautAbstractCodegen {
|
||||
// Write property that is present in server
|
||||
writePropertyBack(OPT_USE_AUTH, true);
|
||||
|
||||
writePropertyBack(OPT_CONFIGURE_AUTH_FILTER_PATTERN, false);
|
||||
writePropertyBack(OPT_CONFIGURE_CLIENT_ID, false);
|
||||
|
||||
if(additionalProperties.containsKey(BASE_PATH_SEPARATOR)) {
|
||||
basePathSeparator = additionalProperties.get(BASE_PATH_SEPARATOR).toString();
|
||||
}
|
||||
writePropertyBack(BASE_PATH_SEPARATOR, basePathSeparator);
|
||||
|
||||
final String invokerFolder = (sourceFolder + '/' + invokerPackage).replace(".", "/");
|
||||
|
||||
// Authorization files
|
||||
@@ -98,12 +79,6 @@ public class JavaMicronautClientCodegen extends JavaMicronautAbstractCodegen {
|
||||
supportingFiles.add(new SupportingFile("client/auth/configuration/ApiKeyAuthConfiguration.mustache", authConfigurationFolder, "ApiKeyAuthConfiguration.java"));
|
||||
supportingFiles.add(new SupportingFile("client/auth/configuration/ConfigurableAuthorization.mustache", authConfigurationFolder, "ConfigurableAuthorization.java"));
|
||||
supportingFiles.add(new SupportingFile("client/auth/configuration/HttpBasicAuthConfiguration.mustache", authConfigurationFolder, "HttpBasicAuthConfiguration.java"));
|
||||
|
||||
if (additionalProperties.containsKey(AUTHORIZATION_FILTER_PATTERN)) {
|
||||
String pattern = additionalProperties.get(AUTHORIZATION_FILTER_PATTERN).toString();
|
||||
this.setAuthorizationFilterPattern(pattern);
|
||||
additionalProperties.put(AUTHORIZATION_FILTER_PATTERN, authorizationFilterPattern);
|
||||
}
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(ADDITIONAL_CLIENT_TYPE_ANNOTATIONS)) {
|
||||
@@ -112,18 +87,6 @@ public class JavaMicronautClientCodegen extends JavaMicronautAbstractCodegen {
|
||||
additionalProperties.put(ADDITIONAL_CLIENT_TYPE_ANNOTATIONS, additionalClientTypeAnnotations);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CLIENT_ID)) {
|
||||
String id = additionalProperties.get(CLIENT_ID).toString();
|
||||
this.setClientId(id);
|
||||
additionalProperties.put(CLIENT_ID, clientId);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(BASE_PATH_SEPARATOR)) {
|
||||
String separator = additionalProperties.get(BASE_PATH_SEPARATOR).toString();
|
||||
this.setBasePathSeparator(separator);
|
||||
additionalProperties.put(BASE_PATH_SEPARATOR, basePathSeparator);
|
||||
}
|
||||
|
||||
// Api file
|
||||
apiTemplateFiles.clear();
|
||||
apiTemplateFiles.put("client/api.mustache", ".java");
|
||||
@@ -146,18 +109,4 @@ public class JavaMicronautClientCodegen extends JavaMicronautAbstractCodegen {
|
||||
public void setAdditionalClientTypeAnnotations(final List<String> additionalClientTypeAnnotations) {
|
||||
this.additionalClientTypeAnnotations = additionalClientTypeAnnotations;
|
||||
}
|
||||
|
||||
public void setAuthorizationFilterPattern(final String pattern) {
|
||||
writePropertyBack(OPT_CONFIGURE_AUTH_FILTER_PATTERN, true);
|
||||
this.authorizationFilterPattern = pattern;
|
||||
}
|
||||
|
||||
public void setClientId(final String id) {
|
||||
writePropertyBack(OPT_CONFIGURE_CLIENT_ID, true);
|
||||
this.clientId = id;
|
||||
}
|
||||
|
||||
public void setBasePathSeparator(final String separator) {
|
||||
this.basePathSeparator = separator;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2438,17 +2438,8 @@ public class PythonClientCodegen extends AbstractPythonCodegen {
|
||||
if (m.discriminator == null && innerSchema.getDiscriminator() != null) {
|
||||
LOGGER.debug("discriminator is set to null (not correctly set earlier): {}", m.name);
|
||||
m.setDiscriminator(createDiscriminator(m.name, innerSchema, this.openAPI));
|
||||
// directly include the function `addDiscriminatorMappedModelsImports` inline below
|
||||
// as the function has been updated
|
||||
//m.addDiscriminatorMappedModelsImports();
|
||||
if (!this.getLegacyDiscriminatorBehavior()) {
|
||||
if (m.discriminator != null && m.discriminator.getMappedModels() != null) {
|
||||
for (CodegenDiscriminator.MappedModel mm : m.discriminator.getMappedModels()) {
|
||||
if (!"".equals(mm.getModelName())) {
|
||||
m.getImports().add(mm.getModelName());
|
||||
}
|
||||
}
|
||||
}
|
||||
m.addDiscriminatorMappedModelsImports();
|
||||
}
|
||||
modelDiscriminators++;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
public static final String PACKAGE_URL = "packageUrl";
|
||||
public static final String DEFAULT_LIBRARY = "urllib3";
|
||||
public static final String RECURSION_LIMIT = "recursionLimit";
|
||||
public static final String ALLOW_STRING_IN_DATETIME_PARAMETERS = "allowStringInDateTimeParameters";
|
||||
public static final String FLOAT_STRICT_TYPE = "floatStrictType";
|
||||
public static final String DATETIME_FORMAT = "datetimeFormat";
|
||||
public static final String DATE_FORMAT = "dateFormat";
|
||||
@@ -56,6 +57,7 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
protected String modelDocPath = "docs" + File.separator;
|
||||
protected boolean hasModelsToImport = Boolean.FALSE;
|
||||
protected boolean useOneOfDiscriminatorLookup = false; // use oneOf discriminator's mapping for model lookup
|
||||
protected boolean allowStringInDateTimeParameters = false; // use StrictStr instead of datetime in parameters
|
||||
protected boolean floatStrictType = true;
|
||||
protected String datetimeFormat = "%Y-%m-%dT%H:%M:%S.%f%z";
|
||||
protected String dateFormat = "%Y-%m-%d";
|
||||
@@ -64,11 +66,6 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
|
||||
private String testFolder;
|
||||
|
||||
// map of set (model imports)
|
||||
private HashMap<String, HashSet<String>> circularImports = new HashMap<>();
|
||||
// map of codegen models
|
||||
private HashMap<String, CodegenModel> codegenModelMap = new HashMap<>();
|
||||
|
||||
public PythonNextgenClientCodegen() {
|
||||
super();
|
||||
|
||||
@@ -113,10 +110,8 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
typeMapping.put("array", "List");
|
||||
typeMapping.put("set", "List");
|
||||
typeMapping.put("map", "Dict");
|
||||
typeMapping.put("file", "str");
|
||||
typeMapping.put("decimal", "decimal.Decimal");
|
||||
typeMapping.put("file", "bytearray");
|
||||
typeMapping.put("binary", "bytearray");
|
||||
typeMapping.put("ByteArray", "bytearray");
|
||||
|
||||
languageSpecificPrimitives.remove("file");
|
||||
languageSpecificPrimitives.add("decimal.Decimal");
|
||||
@@ -177,6 +172,8 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
cliOptions.add(new CliOption(CodegenConstants.SOURCECODEONLY_GENERATION, CodegenConstants.SOURCECODEONLY_GENERATION_DESC)
|
||||
.defaultValue(Boolean.FALSE.toString()));
|
||||
cliOptions.add(new CliOption(RECURSION_LIMIT, "Set the recursion limit. If not set, use the system default value."));
|
||||
cliOptions.add(new CliOption(ALLOW_STRING_IN_DATETIME_PARAMETERS, "Allow string as input to datetime/date parameters for backward compartibility.")
|
||||
.defaultValue(Boolean.FALSE.toString()));
|
||||
cliOptions.add(new CliOption(FLOAT_STRICT_TYPE, "Use strict type for float, i.e. StrictFloat or confloat(strict=true, ...)")
|
||||
.defaultValue(Boolean.TRUE.toString()));
|
||||
cliOptions.add(new CliOption(DATETIME_FORMAT, "datetime format for query parameters")
|
||||
@@ -281,6 +278,10 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
additionalProperties.put(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, useOneOfDiscriminatorLookup);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(ALLOW_STRING_IN_DATETIME_PARAMETERS)) {
|
||||
setAllowStringInDateTimeParameters(convertPropertyToBooleanAndWriteBack(ALLOW_STRING_IN_DATETIME_PARAMETERS));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(FLOAT_STRICT_TYPE)) {
|
||||
setFloatStrictType(convertPropertyToBooleanAndWriteBack(FLOAT_STRICT_TYPE));
|
||||
}
|
||||
@@ -411,8 +412,6 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
* @param typingImports typing imports
|
||||
* @param pydantic pydantic imports
|
||||
* @param datetimeImports datetime imports
|
||||
* @param modelImports model imports
|
||||
* @param classname class name
|
||||
* @return pydantic type
|
||||
*
|
||||
*/
|
||||
@@ -420,8 +419,7 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
Set<String> typingImports,
|
||||
Set<String> pydanticImports,
|
||||
Set<String> datetimeImports,
|
||||
Set<String> modelImports,
|
||||
String classname) {
|
||||
Set<String> modelImports) {
|
||||
if (cp == null) {
|
||||
// if codegen parameter (e.g. map/dict of undefined type) is null, default to string
|
||||
LOGGER.warn("Codegen property is null (e.g. map/dict of undefined type). Default to typing.Any.");
|
||||
@@ -442,12 +440,11 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
}
|
||||
pydanticImports.add("conlist");
|
||||
return String.format(Locale.ROOT, "conlist(%s%s)",
|
||||
getPydanticType(cp.items, typingImports, pydanticImports, datetimeImports, modelImports, classname),
|
||||
getPydanticType(cp.items, typingImports, pydanticImports, datetimeImports, modelImports),
|
||||
constraints);
|
||||
} else if (cp.isMap) {
|
||||
typingImports.add("Dict");
|
||||
return String.format(Locale.ROOT, "Dict[str, %s]",
|
||||
getPydanticType(cp.items, typingImports, pydanticImports, datetimeImports, modelImports, classname));
|
||||
return String.format(Locale.ROOT, "Dict[str, %s]", getPydanticType(cp.items, typingImports, pydanticImports, datetimeImports, modelImports));
|
||||
} else if (cp.isString || cp.isBinary || cp.isByteArray) {
|
||||
if (cp.hasValidation) {
|
||||
List<String> fieldCustomization = new ArrayList<>();
|
||||
@@ -605,7 +602,13 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
datetimeImports.add("datetime");
|
||||
}
|
||||
|
||||
return cp.dataType;
|
||||
if (allowStringInDateTimeParameters) {
|
||||
pydanticImports.add("StrictStr");
|
||||
typingImports.add("Union");
|
||||
return String.format(Locale.ROOT, "Union[StrictStr, %s]", cp.dataType);
|
||||
} else {
|
||||
return cp.dataType;
|
||||
}
|
||||
} else if (cp.isUuid) {
|
||||
return cp.dataType;
|
||||
} else if (cp.isFreeFormObject) { // type: object
|
||||
@@ -623,7 +626,7 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
CodegenMediaType cmt = contents.get(key);
|
||||
// TODO process the first one only at the moment
|
||||
if (cmt != null)
|
||||
return getPydanticType(cmt.getSchema(), typingImports, pydanticImports, datetimeImports, modelImports, classname);
|
||||
return getPydanticType(cmt.getSchema(), typingImports, pydanticImports, datetimeImports, modelImports);
|
||||
}
|
||||
throw new RuntimeException("Error! Failed to process getPydanticType when getting the content: " + cp);
|
||||
} else {
|
||||
@@ -638,8 +641,6 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
* @param typingImports typing imports
|
||||
* @param pydantic pydantic imports
|
||||
* @param datetimeImports datetime imports
|
||||
* @param modelImports model imports
|
||||
* @param classname class name
|
||||
* @return pydantic type
|
||||
*
|
||||
*/
|
||||
@@ -647,8 +648,7 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
Set<String> typingImports,
|
||||
Set<String> pydanticImports,
|
||||
Set<String> datetimeImports,
|
||||
Set<String> modelImports,
|
||||
String classname) {
|
||||
Set<String> modelImports) {
|
||||
if (cp == null) {
|
||||
// if codegen property (e.g. map/dict of undefined type) is null, default to string
|
||||
LOGGER.warn("Codegen property is null (e.g. map/dict of undefined type). Default to typing.Any.");
|
||||
@@ -688,11 +688,11 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
pydanticImports.add("conlist");
|
||||
typingImports.add("List"); // for return type
|
||||
return String.format(Locale.ROOT, "conlist(%s%s)",
|
||||
getPydanticType(cp.items, typingImports, pydanticImports, datetimeImports, modelImports, classname),
|
||||
getPydanticType(cp.items, typingImports, pydanticImports, datetimeImports, modelImports),
|
||||
constraints);
|
||||
} else if (cp.isMap) {
|
||||
typingImports.add("Dict");
|
||||
return String.format(Locale.ROOT, "Dict[str, %s]", getPydanticType(cp.items, typingImports, pydanticImports, datetimeImports, modelImports, classname));
|
||||
return String.format(Locale.ROOT, "Dict[str, %s]", getPydanticType(cp.items, typingImports, pydanticImports, datetimeImports, modelImports));
|
||||
} else if (cp.isString) {
|
||||
if (cp.hasValidation) {
|
||||
List<String> fieldCustomization = new ArrayList<>();
|
||||
@@ -860,24 +860,10 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
typingImports.add("Any");
|
||||
return "Dict[str, Any]";
|
||||
} else if (!cp.isPrimitiveType || cp.isModel) { // model
|
||||
// skip import if it's a circular reference
|
||||
if (classname == null) {
|
||||
// for parameter model, import directly
|
||||
if (!cp.isCircularReference) {
|
||||
// skip import if it's a circular reference
|
||||
hasModelsToImport = true;
|
||||
modelImports.add(cp.dataType);
|
||||
} else {
|
||||
if (circularImports.containsKey(cp.dataType)) {
|
||||
if (circularImports.get(cp.dataType).contains(classname)) {
|
||||
// cp.dataType import map of set contains this model (classname), don't import
|
||||
LOGGER.debug("Skipped importing {} in {} due to circular import.", cp.dataType, classname);
|
||||
} else {
|
||||
// not circular import, so ok to import it
|
||||
hasModelsToImport = true;
|
||||
modelImports.add(cp.dataType);
|
||||
}
|
||||
} else {
|
||||
LOGGER.error("Failed to look up {} from the imports (map of set) of models.", cp.dataType);
|
||||
}
|
||||
}
|
||||
return cp.dataType;
|
||||
} else {
|
||||
@@ -899,7 +885,7 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
|
||||
List<CodegenParameter> params = operation.allParams;
|
||||
for (CodegenParameter param : params) {
|
||||
String typing = getPydanticType(param, typingImports, pydanticImports, datetimeImports, modelImports, null);
|
||||
String typing = getPydanticType(param, typingImports, pydanticImports, datetimeImports, modelImports);
|
||||
List<String> fields = new ArrayList<>();
|
||||
String firstField = "";
|
||||
|
||||
@@ -951,7 +937,7 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
// update typing import for operation return type
|
||||
if (!StringUtils.isEmpty(operation.returnType)) {
|
||||
String typing = getPydanticType(operation.returnProperty, typingImports,
|
||||
new TreeSet<>() /* skip pydantic import for return type */, datetimeImports, modelImports, null);
|
||||
new TreeSet<>() /* skip pydantic import for return type */, datetimeImports, modelImports);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1011,18 +997,6 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
@Override
|
||||
public Map<String, ModelsMap> postProcessAllModels(Map<String, ModelsMap> objs) {
|
||||
final Map<String, ModelsMap> processed = super.postProcessAllModels(objs);
|
||||
|
||||
for (Map.Entry<String, ModelsMap> entry : objs.entrySet()) {
|
||||
// create hash map of codegen model
|
||||
CodegenModel cm = ModelUtils.getModelByName(entry.getKey(), objs);
|
||||
codegenModelMap.put(cm.classname, ModelUtils.getModelByName(entry.getKey(), objs));
|
||||
}
|
||||
|
||||
// create circular import
|
||||
for (String m : codegenModelMap.keySet()) {
|
||||
createImportMapOfSet(m, codegenModelMap);
|
||||
}
|
||||
|
||||
for (Map.Entry<String, ModelsMap> entry : processed.entrySet()) {
|
||||
entry.setValue(postProcessModelsMap(entry.getValue()));
|
||||
}
|
||||
@@ -1030,99 +1004,6 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
return processed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update circularImports with the model name (key) and its imports gathered recursively
|
||||
*
|
||||
* @param modelName model name
|
||||
* @param codegenModelMap a map of CodegenModel
|
||||
*/
|
||||
void createImportMapOfSet(String modelName, Map<String, CodegenModel> codegenModelMap) {
|
||||
HashSet<String> imports = new HashSet<>();
|
||||
circularImports.put(modelName, imports);
|
||||
|
||||
CodegenModel cm = codegenModelMap.get(modelName);
|
||||
|
||||
if (cm == null) {
|
||||
LOGGER.warn("Failed to lookup model in createImportMapOfSet: " + modelName);
|
||||
return;
|
||||
}
|
||||
|
||||
List<CodegenProperty> codegenProperties = null;
|
||||
if (cm.oneOf != null && !cm.oneOf.isEmpty()) { // oneOf
|
||||
codegenProperties = cm.getComposedSchemas().getOneOf();
|
||||
} else if (cm.anyOf != null && !cm.anyOf.isEmpty()) { // anyOF
|
||||
codegenProperties = cm.getComposedSchemas().getAnyOf();
|
||||
} else { // typical model
|
||||
codegenProperties = cm.vars;
|
||||
}
|
||||
|
||||
for (CodegenProperty cp : codegenProperties) {
|
||||
String modelNameFromDataType = getModelNameFromDataType(cp);
|
||||
if (modelNameFromDataType != null) { // model
|
||||
imports.add(modelNameFromDataType); // update import
|
||||
// go through properties or sub-schemas of the model recursively to identify more (model) import if any
|
||||
updateImportsFromCodegenModel(modelNameFromDataType, codegenModelMap.get(modelNameFromDataType), imports);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update set of imports from codegen model recursivly
|
||||
*
|
||||
* @param modelName model name
|
||||
* @param cm codegen model
|
||||
* @param imports set of imports
|
||||
*/
|
||||
public void updateImportsFromCodegenModel(String modelName, CodegenModel cm, Set<String> imports) {
|
||||
if (cm == null) {
|
||||
LOGGER.warn("Failed to lookup model in createImportMapOfSet " + modelName);
|
||||
return;
|
||||
}
|
||||
|
||||
List<CodegenProperty> codegenProperties = null;
|
||||
if (cm.oneOf != null && !cm.oneOf.isEmpty()) { // oneOfValidationError
|
||||
codegenProperties = cm.getComposedSchemas().getOneOf();
|
||||
} else if (cm.anyOf != null && !cm.anyOf.isEmpty()) { // anyOF
|
||||
codegenProperties = cm.getComposedSchemas().getAnyOf();
|
||||
} else { // typical model
|
||||
codegenProperties = cm.vars;
|
||||
}
|
||||
|
||||
for (CodegenProperty cp : codegenProperties) {
|
||||
String modelNameFromDataType = getModelNameFromDataType(cp);
|
||||
if (modelNameFromDataType != null) { // model
|
||||
if (modelName.equals(modelNameFromDataType)) { // self referencing
|
||||
continue;
|
||||
} else if (imports.contains(modelNameFromDataType)) { // circular import
|
||||
continue;
|
||||
} else {
|
||||
imports.add(modelNameFromDataType); // update import
|
||||
// go through properties of the model recursively to identify more (model) import if any
|
||||
updateImportsFromCodegenModel(modelNameFromDataType, codegenModelMap.get(modelNameFromDataType), imports);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the model name (if any) from data type of codegen property.
|
||||
* Returns null if it's not a model.
|
||||
*
|
||||
* @param cp Codegen property
|
||||
* @return model name
|
||||
*/
|
||||
private String getModelNameFromDataType(CodegenProperty cp) {
|
||||
if (cp.isArray) {
|
||||
return getModelNameFromDataType(cp.items);
|
||||
} else if (cp.isMap) {
|
||||
return getModelNameFromDataType(cp.items);
|
||||
} else if (!cp.isPrimitiveType || cp.isModel) {
|
||||
return cp.dataType;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private ModelsMap postProcessModelsMap(ModelsMap objs) {
|
||||
// process enum in models
|
||||
objs = postProcessModelsEnum(objs);
|
||||
@@ -1177,7 +1058,7 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
|
||||
//loop through properties/schemas to set up typing, pydantic
|
||||
for (CodegenProperty cp : codegenProperties) {
|
||||
String typing = getPydanticType(cp, typingImports, pydanticImports, datetimeImports, modelImports, model.classname);
|
||||
String typing = getPydanticType(cp, typingImports, pydanticImports, datetimeImports, modelImports);
|
||||
List<String> fields = new ArrayList<>();
|
||||
String firstField = "";
|
||||
|
||||
@@ -1334,8 +1215,7 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
}
|
||||
}
|
||||
|
||||
vendorExtensions.put("x-regex", regex.replace("\"","\\\""));
|
||||
vendorExtensions.put("x-pattern", pattern.replace("\"","\\\""));
|
||||
vendorExtensions.put("x-regex", regex);
|
||||
vendorExtensions.put("x-modifiers", modifiers);
|
||||
}
|
||||
}
|
||||
@@ -1529,6 +1409,10 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
return "var_" + name;
|
||||
}
|
||||
|
||||
public void setAllowStringInDateTimeParameters(boolean allowStringInDateTimeParameters) {
|
||||
this.allowStringInDateTimeParameters = allowStringInDateTimeParameters;
|
||||
}
|
||||
|
||||
public void setFloatStrictType(boolean floatStrictType) {
|
||||
this.floatStrictType = floatStrictType;
|
||||
}
|
||||
|
||||
@@ -412,7 +412,10 @@ public class ModelUtils {
|
||||
* @return true if the specified schema is an Object schema.
|
||||
*/
|
||||
public static boolean isTypeObjectSchema(Schema schema) {
|
||||
return SchemaTypeUtil.OBJECT_TYPE.equals(schema.getType());
|
||||
if (SchemaTypeUtil.OBJECT_TYPE.equals(schema.getType())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -438,11 +441,17 @@ public class ModelUtils {
|
||||
* @return true if the specified schema is an Object schema.
|
||||
*/
|
||||
public static boolean isObjectSchema(Schema schema) {
|
||||
return (schema instanceof ObjectSchema) ||
|
||||
// must not be a map
|
||||
(SchemaTypeUtil.OBJECT_TYPE.equals(schema.getType()) && !(schema instanceof MapSchema)) ||
|
||||
// must have at least one property
|
||||
(schema.getType() == null && schema.getProperties() != null && !schema.getProperties().isEmpty());
|
||||
if (schema instanceof ObjectSchema) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// must not be a map
|
||||
if (SchemaTypeUtil.OBJECT_TYPE.equals(schema.getType()) && !(schema instanceof MapSchema)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// must have at least one property
|
||||
return schema.getType() == null && schema.getProperties() != null && !schema.getProperties().isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -453,7 +462,10 @@ public class ModelUtils {
|
||||
* @return true if the specified schema is a Composed schema.
|
||||
*/
|
||||
public static boolean isComposedSchema(Schema schema) {
|
||||
return schema instanceof ComposedSchema;
|
||||
if (schema instanceof ComposedSchema) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -486,7 +498,11 @@ public class ModelUtils {
|
||||
count++;
|
||||
}
|
||||
|
||||
return count > 1;
|
||||
if (count > 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -524,9 +540,19 @@ public class ModelUtils {
|
||||
* @return true if the specified schema is a Map schema.
|
||||
*/
|
||||
public static boolean isMapSchema(Schema schema) {
|
||||
return (schema instanceof MapSchema) ||
|
||||
(schema.getAdditionalProperties() instanceof Schema) ||
|
||||
(schema.getAdditionalProperties() instanceof Boolean && (Boolean) schema.getAdditionalProperties());
|
||||
if (schema instanceof MapSchema) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (schema == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (schema.getAdditionalProperties() instanceof Schema) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return schema.getAdditionalProperties() instanceof Boolean && (Boolean) schema.getAdditionalProperties();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -548,7 +574,10 @@ public class ModelUtils {
|
||||
}
|
||||
|
||||
public static boolean isIntegerSchema(Schema schema) {
|
||||
return schema instanceof IntegerSchema || SchemaTypeUtil.INTEGER_TYPE.equals(schema.getType());
|
||||
if (schema instanceof IntegerSchema) {
|
||||
return true;
|
||||
}
|
||||
return SchemaTypeUtil.INTEGER_TYPE.equals(schema.getType());
|
||||
}
|
||||
|
||||
public static boolean isShortSchema(Schema schema) {
|
||||
@@ -558,9 +587,12 @@ public class ModelUtils {
|
||||
}
|
||||
|
||||
public static boolean isUnsignedIntegerSchema(Schema schema) {
|
||||
return SchemaTypeUtil.INTEGER_TYPE.equals(schema.getType()) && // type: integer
|
||||
if (SchemaTypeUtil.INTEGER_TYPE.equals(schema.getType()) && // type: integer
|
||||
("int32".equals(schema.getFormat()) || schema.getFormat() == null) && // format: int32
|
||||
(schema.getExtensions() != null && (Boolean) schema.getExtensions().getOrDefault("x-unsigned", Boolean.FALSE));
|
||||
(schema.getExtensions() != null && (Boolean) schema.getExtensions().getOrDefault("x-unsigned", Boolean.FALSE))) { // x-unsigned: true
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isLongSchema(Schema schema) {
|
||||
@@ -570,17 +602,26 @@ public class ModelUtils {
|
||||
}
|
||||
|
||||
public static boolean isUnsignedLongSchema(Schema schema) {
|
||||
return SchemaTypeUtil.INTEGER_TYPE.equals(schema.getType()) && // type: integer
|
||||
if (SchemaTypeUtil.INTEGER_TYPE.equals(schema.getType()) && // type: integer
|
||||
"int64".equals(schema.getFormat()) && // format: int64
|
||||
(schema.getExtensions() != null && (Boolean) schema.getExtensions().getOrDefault("x-unsigned", Boolean.FALSE));
|
||||
(schema.getExtensions() != null && (Boolean) schema.getExtensions().getOrDefault("x-unsigned", Boolean.FALSE))) { // x-unsigned: true
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isBooleanSchema(Schema schema) {
|
||||
return schema instanceof BooleanSchema || SchemaTypeUtil.BOOLEAN_TYPE.equals(schema.getType());
|
||||
if (schema instanceof BooleanSchema) {
|
||||
return true;
|
||||
}
|
||||
return SchemaTypeUtil.BOOLEAN_TYPE.equals(schema.getType());
|
||||
}
|
||||
|
||||
public static boolean isNumberSchema(Schema schema) {
|
||||
return schema instanceof NumberSchema || SchemaTypeUtil.NUMBER_TYPE.equals(schema.getType());
|
||||
if (schema instanceof NumberSchema) {
|
||||
return true;
|
||||
}
|
||||
return SchemaTypeUtil.NUMBER_TYPE.equals(schema.getType());
|
||||
}
|
||||
|
||||
public static boolean isFloatSchema(Schema schema) {
|
||||
@@ -596,51 +637,66 @@ public class ModelUtils {
|
||||
}
|
||||
|
||||
public static boolean isDateSchema(Schema schema) {
|
||||
return (schema instanceof DateSchema) ||
|
||||
// format: date
|
||||
(SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.DATE_FORMAT.equals(schema.getFormat()));
|
||||
if (schema instanceof DateSchema) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// format: date
|
||||
return SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.DATE_FORMAT.equals(schema.getFormat());
|
||||
}
|
||||
|
||||
public static boolean isDateTimeSchema(Schema schema) {
|
||||
return (schema instanceof DateTimeSchema) ||
|
||||
// format: date-time
|
||||
(SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.DATE_TIME_FORMAT.equals(schema.getFormat()));
|
||||
if (schema instanceof DateTimeSchema) {
|
||||
return true;
|
||||
}
|
||||
// format: date-time
|
||||
return SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.DATE_TIME_FORMAT.equals(schema.getFormat());
|
||||
}
|
||||
|
||||
public static boolean isPasswordSchema(Schema schema) {
|
||||
return (schema instanceof PasswordSchema) ||
|
||||
// double
|
||||
(SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.PASSWORD_FORMAT.equals(schema.getFormat()));
|
||||
if (schema instanceof PasswordSchema) {
|
||||
return true;
|
||||
}
|
||||
// double
|
||||
return SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.PASSWORD_FORMAT.equals(schema.getFormat());
|
||||
}
|
||||
|
||||
public static boolean isByteArraySchema(Schema schema) {
|
||||
return (schema instanceof ByteArraySchema) ||
|
||||
// format: byte
|
||||
(SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.BYTE_FORMAT.equals(schema.getFormat()));
|
||||
if (schema instanceof ByteArraySchema) {
|
||||
return true;
|
||||
}
|
||||
// format: byte
|
||||
return SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.BYTE_FORMAT.equals(schema.getFormat());
|
||||
}
|
||||
|
||||
public static boolean isBinarySchema(Schema schema) {
|
||||
return (schema instanceof BinarySchema) ||
|
||||
// format: binary
|
||||
(SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.BINARY_FORMAT.equals(schema.getFormat()));
|
||||
if (schema instanceof BinarySchema) {
|
||||
return true;
|
||||
}
|
||||
// format: binary
|
||||
return SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.BINARY_FORMAT.equals(schema.getFormat());
|
||||
}
|
||||
|
||||
public static boolean isFileSchema(Schema schema) {
|
||||
return (schema instanceof FileSchema) ||
|
||||
// file type in oas2 mapped to binary in oas3
|
||||
isBinarySchema(schema);
|
||||
if (schema instanceof FileSchema) {
|
||||
return true;
|
||||
}
|
||||
// file type in oas2 mapped to binary in oas3
|
||||
return isBinarySchema(schema);
|
||||
}
|
||||
|
||||
public static boolean isUUIDSchema(Schema schema) {
|
||||
return (schema instanceof UUIDSchema) ||
|
||||
// format: uuid
|
||||
(SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.UUID_FORMAT.equals(schema.getFormat()));
|
||||
if (schema instanceof UUIDSchema) {
|
||||
return true;
|
||||
}
|
||||
// format: uuid
|
||||
return SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.UUID_FORMAT.equals(schema.getFormat());
|
||||
}
|
||||
|
||||
public static boolean isURISchema(Schema schema) {
|
||||
@@ -650,10 +706,12 @@ public class ModelUtils {
|
||||
}
|
||||
|
||||
public static boolean isEmailSchema(Schema schema) {
|
||||
return (schema instanceof EmailSchema) ||
|
||||
// format: email
|
||||
(SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.EMAIL_FORMAT.equals(schema.getFormat()));
|
||||
if (schema instanceof EmailSchema) {
|
||||
return true;
|
||||
}
|
||||
// format: email
|
||||
return SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
|
||||
&& SchemaTypeUtil.EMAIL_FORMAT.equals(schema.getFormat());
|
||||
}
|
||||
|
||||
public static boolean isDecimalSchema(Schema schema) {
|
||||
@@ -669,11 +727,17 @@ public class ModelUtils {
|
||||
* @return true if it's a model with at least one properties
|
||||
*/
|
||||
public static boolean isModel(Schema schema) {
|
||||
return (schema != null) &&
|
||||
// has properties
|
||||
((null != schema.getProperties() && !schema.getProperties().isEmpty())
|
||||
// composed schema is a model, consider very simple ObjectSchema a model
|
||||
|| (schema instanceof ComposedSchema || schema instanceof ObjectSchema));
|
||||
if (schema == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// has properties
|
||||
if (null != schema.getProperties() && !schema.getProperties().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// composed schema is a model, consider very simple ObjectSchema a model
|
||||
return schema instanceof ComposedSchema || schema instanceof ObjectSchema;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -683,12 +747,16 @@ public class ModelUtils {
|
||||
* @return true if it's a model with at least one properties
|
||||
*/
|
||||
public static boolean isModelWithPropertiesOnly(Schema schema) {
|
||||
return (schema != null) &&
|
||||
// has properties
|
||||
(null != schema.getProperties() && !schema.getProperties().isEmpty()) &&
|
||||
// no additionalProperties is set
|
||||
(schema.getAdditionalProperties() == null ||
|
||||
(schema.getAdditionalProperties() instanceof Boolean && !(Boolean) schema.getAdditionalProperties()));
|
||||
if (schema == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (null != schema.getProperties() && !schema.getProperties().isEmpty() && // has properties
|
||||
(schema.getAdditionalProperties() == null || // no additionalProperties is set
|
||||
(schema.getAdditionalProperties() instanceof Boolean && !(Boolean) schema.getAdditionalProperties()))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean hasValidation(Schema sc) {
|
||||
@@ -899,7 +967,11 @@ public class ModelUtils {
|
||||
}
|
||||
|
||||
public static ApiResponse getApiResponse(OpenAPI openAPI, String name) {
|
||||
if (name != null && openAPI != null && openAPI.getComponents() != null && openAPI.getComponents().getResponses() != null) {
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (openAPI != null && openAPI.getComponents() != null && openAPI.getComponents().getResponses() != null) {
|
||||
return openAPI.getComponents().getResponses().get(name);
|
||||
}
|
||||
return null;
|
||||
@@ -924,7 +996,11 @@ public class ModelUtils {
|
||||
}
|
||||
|
||||
public static Parameter getParameter(OpenAPI openAPI, String name) {
|
||||
if (name != null && openAPI != null && openAPI.getComponents() != null && openAPI.getComponents().getParameters() != null) {
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (openAPI != null && openAPI.getComponents() != null && openAPI.getComponents().getParameters() != null) {
|
||||
return openAPI.getComponents().getParameters().get(name);
|
||||
}
|
||||
return null;
|
||||
@@ -949,7 +1025,11 @@ public class ModelUtils {
|
||||
}
|
||||
|
||||
public static Callback getCallback(OpenAPI openAPI, String name) {
|
||||
if (name != null && openAPI != null && openAPI.getComponents() != null && openAPI.getComponents().getCallbacks() != null) {
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (openAPI != null && openAPI.getComponents() != null && openAPI.getComponents().getCallbacks() != null) {
|
||||
return openAPI.getComponents().getCallbacks().get(name);
|
||||
}
|
||||
return null;
|
||||
@@ -1256,7 +1336,11 @@ public class ModelUtils {
|
||||
}
|
||||
|
||||
public static Header getHeader(OpenAPI openAPI, String name) {
|
||||
if (name != null && openAPI != null && openAPI.getComponents() != null && openAPI.getComponents().getHeaders() != null) {
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (openAPI != null && openAPI.getComponents() != null && openAPI.getComponents().getHeaders() != null) {
|
||||
return openAPI.getComponents().getHeaders().get(name);
|
||||
}
|
||||
return null;
|
||||
@@ -1454,17 +1538,17 @@ public class ModelUtils {
|
||||
public static boolean isExtensionParent(Schema schema) {
|
||||
if (schema.getExtensions() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Object xParent = schema.getExtensions().get("x-parent");
|
||||
if (xParent == null) {
|
||||
return false;
|
||||
} else if (xParent instanceof Boolean) {
|
||||
return (Boolean) xParent;
|
||||
} else if (xParent instanceof String) {
|
||||
return StringUtils.isNotEmpty((String) xParent);
|
||||
} else {
|
||||
return false;
|
||||
Object xParent = schema.getExtensions().get("x-parent");
|
||||
if (xParent == null) {
|
||||
return false;
|
||||
} else if (xParent instanceof Boolean) {
|
||||
return (Boolean) xParent;
|
||||
} else if (xParent instanceof String) {
|
||||
return StringUtils.isNotEmpty((String) xParent);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1811,19 +1895,6 @@ public class ModelUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the schema contains allOf and properties,
|
||||
* and no oneOf/anyOf defined.
|
||||
*
|
||||
* @param schema the schema
|
||||
* @return true if the schema contains allOf but no properties/oneOf/anyOf defined.
|
||||
*/
|
||||
public static boolean isAllOfWithProperties(Schema schema) {
|
||||
return hasAllOf(schema) && (schema.getProperties() != null && !schema.getProperties().isEmpty()) &&
|
||||
(schema.getOneOf() == null || schema.getOneOf().isEmpty()) &&
|
||||
(schema.getAnyOf() == null || schema.getAnyOf().isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the schema contains oneOf but
|
||||
* no properties/allOf/anyOf defined.
|
||||
|
||||
@@ -496,15 +496,11 @@ public class {{classname}} {
|
||||
{{#formParams}}
|
||||
{{#isArray}}
|
||||
for (int i=0; i < {{paramName}}.size(); i++) {
|
||||
if ({{paramName}}.get(i) != null) {
|
||||
formValues.add(new BasicNameValuePair("{{{baseName}}}", {{paramName}}.get(i).toString()));
|
||||
}
|
||||
formValues.add(new BasicNameValuePair("{{{baseName}}}", {{paramName}}.get(i).toString()));
|
||||
}
|
||||
{{/isArray}}
|
||||
{{^isArray}}
|
||||
if ({{paramName}} != null) {
|
||||
formValues.add(new BasicNameValuePair("{{{baseName}}}", {{paramName}}.toString()));
|
||||
}
|
||||
formValues.add(new BasicNameValuePair("{{{baseName}}}", {{paramName}}.toString()));
|
||||
{{/isArray}}
|
||||
{{/formParams}}
|
||||
HttpEntity entity = new UrlEncodedFormEntity(formValues, java.nio.charset.StandardCharsets.UTF_8);
|
||||
|
||||
@@ -270,23 +270,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
{{/isReadOnly}}
|
||||
|
||||
{{/vars}}
|
||||
{{#parent}}
|
||||
{{#allVars}}
|
||||
{{#isOverridden}}
|
||||
@Override
|
||||
public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) {
|
||||
{{#vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
this.{{setter}}(JsonNullable.<{{{datatypeWithEnum}}}>of({{name}}));
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{^vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
this.{{setter}}({{name}});
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
return this;
|
||||
}
|
||||
|
||||
{{/isOverridden}}
|
||||
{{/allVars}}
|
||||
{{/parent}}
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
{{#useReflectionEqualsHashCode}}
|
||||
|
||||
@@ -29,7 +29,7 @@ export default class <&classname> extends ApiClient {
|
||||
* <¬es></notes><#allParams><#required>
|
||||
* @param {<&vendorExtensions.x-jsdoc-type>} <¶mName> <&description></required></allParams><#hasOptionalParams>
|
||||
* @param {Object} opts Optional parameters<#allParams><^required>
|
||||
* @param {<&vendorExtensions.x-jsdoc-type>} [<¶mName><#defaultValue> = <&.></defaultValue>] <&description></required></allParams></hasOptionalParams>
|
||||
* @param {<&vendorExtensions.x-jsdoc-type>} opts.<¶mName> <&description><#defaultValue> (default to <&.>)</defaultValue></required></allParams></hasOptionalParams>
|
||||
* @param requestInit Dynamic configuration. @see {@link https://github.com/apollographql/apollo-server/pull/1277}
|
||||
<=| |=>* @return {Promise|#returnType|<|&vendorExtensions.x-jsdoc-type|>|/returnType|}|=< >=|
|
||||
*/
|
||||
|
||||
@@ -38,7 +38,7 @@ export default class <&classname> {
|
||||
* <¬es></notes><#allParams><#required>
|
||||
* @param {<&vendorExtensions.x-jsdoc-type>} <¶mName> <&description></required></allParams><#hasOptionalParams>
|
||||
* @param {Object} opts Optional parameters<#allParams><^required>
|
||||
* @param {<&vendorExtensions.x-jsdoc-type>} [<¶mName><#defaultValue> = <&.>)</defaultValue>] <&description></required></allParams></hasOptionalParams><^usePromises>
|
||||
* @param {<&vendorExtensions.x-jsdoc-type>} opts.<¶mName> <&description><#defaultValue> (default to <&.>)</defaultValue></required></allParams></hasOptionalParams><^usePromises>
|
||||
* @param {module:<#invokerPackage><&invokerPackage>/</invokerPackage><#apiPackage><&apiPackage>/</apiPackage><&classname>~<&operationId>Callback} callback The callback function, accepting three arguments: error, data, response<#returnType>
|
||||
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}</returnType></usePromises><#usePromises>
|
||||
* @return {Promise} a {@link https://www.promisejs.org/|Promise}<#returnType>, with an object containing data of type {@link <&vendorExtensions.x-jsdoc-type>} and HTTP response</returnType><^returnType>, with an object containing HTTP response</returnType></usePromises>
|
||||
|
||||
@@ -47,7 +47,7 @@ bool {{classname}}::IsValid() const
|
||||
|
||||
void {{classname}}::SetHttpRetryManager(FHttpRetrySystem::FManager& InRetryManager)
|
||||
{
|
||||
if (RetryManager != &InRetryManager)
|
||||
if(RetryManager != &GetHttpRetryManager())
|
||||
{
|
||||
DefaultRetryManager.Reset();
|
||||
RetryManager = &InRetryManager;
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace {{packageName}}.Client
|
||||
{
|
||||
"{{{name}}}", new Dictionary<string, object> {
|
||||
{"description", "{{{description}}}{{^description}}No description provided{{/description}}"},
|
||||
{"default_value", {{#isString}}{{^isEnum}}@{{/isEnum}}{{/isString}}"{{{defaultValue}}}"},
|
||||
{"default_value", "{{{defaultValue}}}"},
|
||||
{{#enumValues}}
|
||||
{{#-first}}
|
||||
{
|
||||
|
||||
@@ -1 +1 @@
|
||||
{{#model.allVars}}{{>PropertyDataType}} {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#defaultValue}} = {{^isDateTime}}{{#isString}}{{^isEnum}}@{{/isEnum}}{{/isString}}{{{defaultValue}}}{{/isDateTime}}{{#isDateTime}}default{{/isDateTime}}{{/defaultValue}}{{^defaultValue}}{{#isNullable}} = default{{/isNullable}}{{/defaultValue}} {{/model.allVars}}
|
||||
{{#model.allVars}}{{>PropertyDataType}} {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#defaultValue}} = {{^isDateTime}}{{{defaultValue}}}{{/isDateTime}}{{#isDateTime}}default{{/isDateTime}}{{/defaultValue}}{{^defaultValue}}{{#isNullable}} = default{{/isNullable}}{{/defaultValue}} {{/model.allVars}}
|
||||
@@ -134,7 +134,7 @@
|
||||
{{#hasOnlyReadOnly}}
|
||||
[JsonConstructorAttribute]
|
||||
{{/hasOnlyReadOnly}}
|
||||
public {{classname}}({{#readWriteVars}}{{{datatypeWithEnum}}}{{#isEnum}}{{^isContainer}}{{^required}}?{{/required}}{{/isContainer}}{{/isEnum}} {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{#defaultValue}}{{^isDateTime}}{{#isString}}{{^isEnum}}@{{/isEnum}}{{/isString}}{{{defaultValue}}}{{/isDateTime}}{{#isDateTime}}default({{{datatypeWithEnum}}}){{/isDateTime}}{{/defaultValue}}{{^defaultValue}}default({{{datatypeWithEnum}}}{{#isEnum}}{{^isContainer}}{{^required}}?{{/required}}{{/isContainer}}{{/isEnum}}){{/defaultValue}}{{^-last}}, {{/-last}}{{/readWriteVars}}){{#parent}} : base({{#parentVars}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{^-last}}, {{/-last}}{{/parentVars}}){{/parent}}
|
||||
public {{classname}}({{#readWriteVars}}{{{datatypeWithEnum}}}{{#isEnum}}{{^isContainer}}{{^required}}?{{/required}}{{/isContainer}}{{/isEnum}} {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{#defaultValue}}{{^isDateTime}}{{{defaultValue}}}{{/isDateTime}}{{#isDateTime}}default({{{datatypeWithEnum}}}){{/isDateTime}}{{/defaultValue}}{{^defaultValue}}default({{{datatypeWithEnum}}}{{#isEnum}}{{^isContainer}}{{^required}}?{{/required}}{{/isContainer}}{{/isEnum}}){{/defaultValue}}{{^-last}}, {{/-last}}{{/readWriteVars}}){{#parent}} : base({{#parentVars}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{^-last}}, {{/-last}}{{/parentVars}}){{/parent}}
|
||||
{
|
||||
{{#vars}}
|
||||
{{^isInherited}}
|
||||
@@ -178,7 +178,7 @@
|
||||
{{^conditionalSerialization}}
|
||||
{{^vendorExtensions.x-csharp-value-type}}
|
||||
// use default value if no "{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}" provided
|
||||
this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} ?? {{#isString}}@{{/isString}}{{{defaultValue}}};
|
||||
this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} ?? {{{defaultValue}}};
|
||||
{{/vendorExtensions.x-csharp-value-type}}
|
||||
{{#vendorExtensions.x-csharp-value-type}}
|
||||
this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
|
||||
|
||||
@@ -45,9 +45,7 @@ import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
{{{.}}}
|
||||
{{/additionalClientTypeAnnotations}}
|
||||
{{>common/generatedAnnotation}}
|
||||
@Client({{#configureClientId}}
|
||||
id = "{{clientId}}",
|
||||
path = {{/configureClientId}}"${{openbrace}}{{{applicationName}}}{{basePathSeparator}}base-path{{closebrace}}")
|
||||
@Client("${{openbrace}}{{{applicationName}}}-base-path{{closebrace}}")
|
||||
public interface {{classname}} {
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
|
||||
@@ -37,7 +37,7 @@ import {{javaxPackage}}.annotation.Generated;
|
||||
|
||||
|
||||
{{>common/generatedAnnotation}}
|
||||
@Filter({{#configureAuthFilterPattern}}"{{authorizationFilterPattern}}"{{/configureAuthFilterPattern}}{{^configureAuthFilterPattern}}Filter.MATCH_ALL_PATTERN{{/configureAuthFilterPattern}})
|
||||
@Filter(Filter.MATCH_ALL_PATTERN)
|
||||
public class AuthorizationFilter implements HttpClientFilter {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ClientCredentialsHttpClientFilter.class);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
# flake8: noqa
|
||||
|
||||
# import apis into api package
|
||||
{{#apiInfo}}{{#apis}}from {{apiPackage}}.{{classFilename}} import {{classname}}
|
||||
{{/apis}}{{/apiInfo}}
|
||||
{{/apis}}{{/apiInfo}}
|
||||
@@ -3,9 +3,11 @@
|
||||
# flake8: noqa
|
||||
{{>partial_header}}
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
# import models into model package
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
from {{modelPackage}}.{{classFilename}} import {{classname}}
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
{{/models}}
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
{{>partial_header}}
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
__version__ = "{{packageVersion}}"
|
||||
|
||||
# import apis into sdk package
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
{{>partial_header}}
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import re # noqa: F401
|
||||
|
||||
from pydantic import validate_arguments, ValidationError
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# coding: utf-8
|
||||
|
||||
{{>partial_header}}
|
||||
from __future__ import absolute_import
|
||||
|
||||
import atexit
|
||||
import datetime
|
||||
@@ -56,7 +56,7 @@ class ApiClient(object):
|
||||
|
||||
def __init__(self, configuration=None, header_name=None, header_value=None,
|
||||
cookie=None, pool_threads=1):
|
||||
# use default configuration if none is provided
|
||||
# use default configuraiton if none is provided
|
||||
if configuration is None:
|
||||
configuration = Configuration.get_default()
|
||||
self.configuration = configuration
|
||||
@@ -241,9 +241,7 @@ class ApiClient(object):
|
||||
|
||||
response_type = response_types_map.get(str(response_data.status), None)
|
||||
|
||||
if response_type == "bytearray":
|
||||
response_data.data = response_data.data
|
||||
else:
|
||||
if response_type not in ["file", "bytes"]:
|
||||
match = None
|
||||
content_type = response_data.getheader('content-type')
|
||||
if content_type is not None:
|
||||
@@ -252,9 +250,8 @@ class ApiClient(object):
|
||||
response_data.data = response_data.data.decode(encoding)
|
||||
|
||||
# deserialize response data
|
||||
if response_type == "bytearray":
|
||||
return_data = response_data.data
|
||||
elif response_type:
|
||||
|
||||
if response_type:
|
||||
return_data = self.deserialize(response_data, response_type)
|
||||
else:
|
||||
return_data = None
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
{{>partial_header}}
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import unittest
|
||||
|
||||
import {{packageName}}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
{{>partial_header}}
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import copy
|
||||
import logging
|
||||
{{^asyncio}}
|
||||
|
||||
@@ -16,12 +16,12 @@ jobs:
|
||||
matrix:
|
||||
python-version: ["3.7", "3.8", "3.9", "3.10"]
|
||||
|
||||
steps:
|
||||
steps:s
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
python-version: ${{ matrix.python-version }}s
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
@@ -35,4 +35,4 @@ jobs:
|
||||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
||||
- name: Test with pytest
|
||||
run: |
|
||||
pytest
|
||||
pytest
|
||||
@@ -33,7 +33,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
|
||||
@validator('{{{name}}}')
|
||||
def {{{name}}}_validate_regular_expression(cls, v):
|
||||
if not re.match(r"{{{.}}}", v{{#vendorExtensions.x-modifiers}} ,re.{{{.}}}{{/vendorExtensions.x-modifiers}}):
|
||||
raise ValueError(r"must validate the regular expression {{{vendorExtensions.x-pattern}}}")
|
||||
raise ValueError(r"must validate the regular expression {{{pattern}}}")
|
||||
return v
|
||||
{{/vendorExtensions.x-regex}}
|
||||
{{#isEnum}}
|
||||
@@ -162,8 +162,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
|
||||
{{#allVars}}
|
||||
{{#isNullable}}
|
||||
# set to None if {{{name}}} (nullable) is None
|
||||
# and __fields_set__ contains the field
|
||||
if self.{{name}} is None and "{{{name}}}" in self.__fields_set__:
|
||||
if self.{{name}} is None:
|
||||
_dict['{{{baseName}}}'] = None
|
||||
|
||||
{{/isNullable}}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
{{>partial_header}}
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import unittest
|
||||
import datetime
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
{{>partial_header}}
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import io
|
||||
import json
|
||||
import logging
|
||||
|
||||
@@ -1101,6 +1101,7 @@ public class DefaultCodegenTest {
|
||||
cm = codegen.fromModel(modelName, sc);
|
||||
hs.clear();
|
||||
hs.add(new CodegenDiscriminator.MappedModel("b", codegen.toModelName("B")));
|
||||
hs.add(new CodegenDiscriminator.MappedModel("B", codegen.toModelName("B")));
|
||||
hs.add(new CodegenDiscriminator.MappedModel("C", codegen.toModelName("C")));
|
||||
Assert.assertEquals(cm.getHasDiscriminatorWithNonEmptyMapping(), true);
|
||||
Assert.assertEquals(cm.discriminator.getMappedModels(), hs);
|
||||
@@ -1584,6 +1585,8 @@ public class DefaultCodegenTest {
|
||||
discriminator.setPropertyBaseName(prop);
|
||||
discriminator.setMapping(null);
|
||||
discriminator.setMappedModels(new HashSet<CodegenDiscriminator.MappedModel>() {{
|
||||
add(new CodegenDiscriminator.MappedModel("DailySubObj", "DailySubObj"));
|
||||
add(new CodegenDiscriminator.MappedModel("SubObj", "SubObj"));
|
||||
add(new CodegenDiscriminator.MappedModel("daily", "DailySubObj"));
|
||||
add(new CodegenDiscriminator.MappedModel("sub-obj", "SubObj"));
|
||||
}});
|
||||
@@ -1981,6 +1984,8 @@ public class DefaultCodegenTest {
|
||||
test.getMapping().put("c", "Child");
|
||||
test.getMappedModels().add(new CodegenDiscriminator.MappedModel("a", "Adult"));
|
||||
test.getMappedModels().add(new CodegenDiscriminator.MappedModel("c", "Child"));
|
||||
test.getMappedModels().add(new CodegenDiscriminator.MappedModel("Adult", "Adult"));
|
||||
test.getMappedModels().add(new CodegenDiscriminator.MappedModel("Child", "Child"));
|
||||
Assert.assertEquals(discriminator, test);
|
||||
}
|
||||
|
||||
@@ -4582,18 +4587,6 @@ public class DefaultCodegenTest {
|
||||
Assert.assertFalse(defaultEnumSchemaProperty.isContainer);
|
||||
Assert.assertFalse(defaultEnumSchemaProperty.isPrimitiveType);
|
||||
Assert.assertEquals(defaultEnumSchemaProperty.defaultValue, "2");
|
||||
|
||||
// test allOf with a single sub-schema and no default value set in the top level
|
||||
CodegenProperty allOfEnumSchemaProperty = modelWithReferencedSchema.vars.get(5);
|
||||
Assert.assertEquals(allOfEnumSchemaProperty.getName(), "allofMinusnumberMinusenum");
|
||||
Assert.assertFalse(allOfEnumSchemaProperty.isEnum);
|
||||
Assert.assertTrue(allOfEnumSchemaProperty.getIsEnumOrRef());
|
||||
Assert.assertTrue(allOfEnumSchemaProperty.isEnumRef);
|
||||
Assert.assertFalse(allOfEnumSchemaProperty.isInnerEnum);
|
||||
Assert.assertFalse(allOfEnumSchemaProperty.isString);
|
||||
Assert.assertFalse(allOfEnumSchemaProperty.isContainer);
|
||||
Assert.assertFalse(allOfEnumSchemaProperty.isPrimitiveType);
|
||||
Assert.assertEquals(allOfEnumSchemaProperty.defaultValue, "null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -278,30 +278,4 @@ public class OpenAPINormalizerTest {
|
||||
assertEquals(schema3.getAnyOf().size(), 2);
|
||||
assertTrue(schema3.getNullable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOpenAPINormalizerRefactorAllOfWithPropertiesOnly() {
|
||||
// to test the rule REFACTOR_ALLOF_WITH_PROPERTIES_ONLY
|
||||
OpenAPI openAPI = TestUtils.parseSpec("src/test/resources/3_0/allOf_extension_parent.yaml");
|
||||
|
||||
ComposedSchema schema = (ComposedSchema) openAPI.getComponents().getSchemas().get("allOfWithProperties");
|
||||
assertEquals(schema.getAllOf().size(), 1);
|
||||
assertEquals(schema.getProperties().size(), 2);
|
||||
assertEquals(((Schema) schema.getProperties().get("isParent")).getType(), "boolean");
|
||||
assertEquals(((Schema) schema.getProperties().get("mum_or_dad")).getType(), "string");
|
||||
|
||||
Map<String, String> options = new HashMap<>();
|
||||
options.put("REFACTOR_ALLOF_WITH_PROPERTIES_ONLY", "true");
|
||||
OpenAPINormalizer openAPINormalizer = new OpenAPINormalizer(openAPI, options);
|
||||
openAPINormalizer.normalize();
|
||||
|
||||
Schema schema2 = openAPI.getComponents().getSchemas().get("allOfWithProperties");
|
||||
assertEquals(schema2.getAllOf().size(), 2);
|
||||
assertNull(schema2.getProperties());
|
||||
|
||||
Schema newSchema = (Schema) (schema2.getAllOf().get(1));
|
||||
assertEquals(((Schema) newSchema.getProperties().get("isParent")).getType(), "boolean");
|
||||
assertEquals(((Schema) newSchema.getProperties().get("mum_or_dad")).getType(), "string");
|
||||
assertEquals(newSchema.getRequired().get(0), "isParent");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -903,7 +903,7 @@ public class JavaClientCodegenTest {
|
||||
|
||||
/**
|
||||
* See https://github.com/OpenAPITools/openapi-generator/issues/4803
|
||||
* <p>
|
||||
*
|
||||
* UPDATE: the following test has been ignored due to https://github.com/OpenAPITools/openapi-generator/pull/11081/
|
||||
* We will contact the contributor of the following test to see if the fix will break their use cases and
|
||||
* how we can fix it accordingly.
|
||||
@@ -951,7 +951,7 @@ public class JavaClientCodegenTest {
|
||||
|
||||
/**
|
||||
* See https://github.com/OpenAPITools/openapi-generator/issues/4803
|
||||
* <p>
|
||||
*
|
||||
* UPDATE: the following test has been ignored due to https://github.com/OpenAPITools/openapi-generator/pull/11081/
|
||||
* We will contact the contributor of the following test to see if the fix will break their use cases and
|
||||
* how we can fix it accordingly.
|
||||
@@ -1007,23 +1007,23 @@ public class JavaClientCodegenTest {
|
||||
output.deleteOnExit();
|
||||
|
||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||
.setGeneratorName("java")
|
||||
.setLibrary(JavaClientCodegen.WEBCLIENT)
|
||||
.setAdditionalProperties(properties)
|
||||
.setInputSpec("src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml")
|
||||
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
|
||||
.setGeneratorName("java")
|
||||
.setLibrary(JavaClientCodegen.WEBCLIENT)
|
||||
.setAdditionalProperties(properties)
|
||||
.setInputSpec("src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml")
|
||||
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
|
||||
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
Map<String, File> files = generator.opts(configurator.toClientOptInput()).generate().stream()
|
||||
.collect(Collectors.toMap(File::getName, Function.identity()));
|
||||
.collect(Collectors.toMap(File::getName, Function.identity()));
|
||||
|
||||
JavaFileAssert.assertThat(files.get("StoreApi.java"))
|
||||
.assertMethod("getInventory").hasReturnType("Mono<Map<String, Integer>>") //explicit 'x-webclient-blocking: false' which overrides global config
|
||||
.toFileAssert()
|
||||
.assertMethod("placeOrder").hasReturnType("Order"); // use global config
|
||||
.assertMethod("getInventory").hasReturnType("Mono<Map<String, Integer>>") //explicit 'x-webclient-blocking: false' which overrides global config
|
||||
.toFileAssert()
|
||||
.assertMethod("placeOrder").hasReturnType("Order"); // use global config
|
||||
|
||||
JavaFileAssert.assertThat(files.get("PetApi.java"))
|
||||
.assertMethod("findPetsByStatus").hasReturnType("List<Pet>"); // explicit 'x-webclient-blocking: true' which overrides global config
|
||||
.assertMethod("findPetsByStatus").hasReturnType("List<Pet>"); // explicit 'x-webclient-blocking: true' which overrides global config
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1057,7 +1057,7 @@ public class JavaClientCodegenTest {
|
||||
|
||||
/**
|
||||
* See https://github.com/OpenAPITools/openapi-generator/issues/6715
|
||||
* <p>
|
||||
*
|
||||
* UPDATE: the following test has been ignored due to https://github.com/OpenAPITools/openapi-generator/pull/11081/
|
||||
* We will contact the contributor of the following test to see if the fix will break their use cases and
|
||||
* how we can fix it accordingly.
|
||||
@@ -1151,7 +1151,7 @@ public class JavaClientCodegenTest {
|
||||
.orElseThrow(() -> new IllegalStateException(String.format(Locale.ROOT, "Operation with id [%s] does not exist", operationId)));
|
||||
}
|
||||
|
||||
private Optional<CodegenOperation> getByCriteria(List<CodegenOperation> codegenOperations, Predicate<CodegenOperation> filter) {
|
||||
private Optional<CodegenOperation> getByCriteria(List<CodegenOperation> codegenOperations, Predicate<CodegenOperation> filter){
|
||||
return codegenOperations.stream()
|
||||
.filter(filter)
|
||||
.findFirst();
|
||||
@@ -1190,7 +1190,7 @@ public class JavaClientCodegenTest {
|
||||
|
||||
/**
|
||||
* See https://github.com/OpenAPITools/openapi-generator/issues/6715
|
||||
* <p>
|
||||
*
|
||||
* UPDATE: the following test has been ignored due to https://github.com/OpenAPITools/openapi-generator/pull/11081/
|
||||
* We will contact the contributor of the following test to see if the fix will break their use cases and
|
||||
* how we can fix it accordingly.
|
||||
@@ -1554,24 +1554,24 @@ public class JavaClientCodegenTest {
|
||||
output.deleteOnExit();
|
||||
|
||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||
.setAdditionalProperties(properties)
|
||||
.setGeneratorName("java")
|
||||
.setLibrary(JavaClientCodegen.MICROPROFILE)
|
||||
.setInputSpec("src/test/resources/bugs/issue_12622.json")
|
||||
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
|
||||
.setAdditionalProperties(properties)
|
||||
.setGeneratorName("java")
|
||||
.setLibrary(JavaClientCodegen.MICROPROFILE)
|
||||
.setInputSpec("src/test/resources/bugs/issue_12622.json")
|
||||
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
|
||||
|
||||
final ClientOptInput clientOptInput = configurator.toClientOptInput();
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
Map<String, File> files = generator.opts(clientOptInput).generate().stream()
|
||||
.collect(Collectors.toMap(File::getName, Function.identity()));
|
||||
.collect(Collectors.toMap(File::getName, Function.identity()));
|
||||
|
||||
JavaFileAssert.assertThat(files.get("Foo.java"))
|
||||
.assertConstructor("String", "Integer")
|
||||
.hasParameter("b")
|
||||
.assertConstructor("String", "Integer")
|
||||
.hasParameter("b")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("JsonbProperty", ImmutableMap.of("value", "\"b\"", "nillable", "true"))
|
||||
.toParameter().toConstructor()
|
||||
.hasParameter("c")
|
||||
.toParameter().toConstructor()
|
||||
.hasParameter("c")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("JsonbProperty", ImmutableMap.of("value", "\"c\""));
|
||||
}
|
||||
@@ -1585,24 +1585,24 @@ public class JavaClientCodegenTest {
|
||||
output.deleteOnExit();
|
||||
|
||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||
.setAdditionalProperties(properties)
|
||||
.setGeneratorName("java")
|
||||
.setLibrary(JavaClientCodegen.WEBCLIENT)
|
||||
.setInputSpec("src/test/resources/bugs/issue_12790.yaml")
|
||||
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
|
||||
.setAdditionalProperties(properties)
|
||||
.setGeneratorName("java")
|
||||
.setLibrary(JavaClientCodegen.WEBCLIENT)
|
||||
.setInputSpec("src/test/resources/bugs/issue_12790.yaml")
|
||||
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
|
||||
|
||||
final ClientOptInput clientOptInput = configurator.toClientOptInput();
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
Map<String, File> files = generator.opts(clientOptInput).generate().stream()
|
||||
.collect(Collectors.toMap(File::getName, Function.identity()));
|
||||
.collect(Collectors.toMap(File::getName, Function.identity()));
|
||||
|
||||
JavaFileAssert.assertThat(files.get("TestObject.java"))
|
||||
.printFileContent()
|
||||
.assertConstructor("String", "String")
|
||||
.bodyContainsLines(
|
||||
"this.nullableProperty = nullableProperty == null ? JsonNullable.<String>undefined() : JsonNullable.of(nullableProperty);",
|
||||
"this.notNullableProperty = notNullableProperty;"
|
||||
);
|
||||
.printFileContent()
|
||||
.assertConstructor("String", "String")
|
||||
.bodyContainsLines(
|
||||
"this.nullableProperty = nullableProperty == null ? JsonNullable.<String>undefined() : JsonNullable.of(nullableProperty);",
|
||||
"this.notNullableProperty = notNullableProperty;"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1631,9 +1631,9 @@ public class JavaClientCodegenTest {
|
||||
|
||||
Path defaultApi = Paths.get(output + "/src/main/java/xyz/abcdef/api/ResourceApi.java");
|
||||
TestUtils.assertFileContains(defaultApi,
|
||||
"org.springframework.core.io.Resource resourceInResponse()",
|
||||
"ResponseEntity<org.springframework.core.io.Resource> resourceInResponseWithHttpInfo()",
|
||||
"ParameterizedTypeReference<org.springframework.core.io.Resource> localReturnType = new ParameterizedTypeReference<org.springframework.core.io.Resource>()"
|
||||
"org.springframework.core.io.Resource resourceInResponse()",
|
||||
"ResponseEntity<org.springframework.core.io.Resource> resourceInResponseWithHttpInfo()",
|
||||
"ParameterizedTypeReference<org.springframework.core.io.Resource> localReturnType = new ParameterizedTypeReference<org.springframework.core.io.Resource>()"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1689,13 +1689,13 @@ public class JavaClientCodegenTest {
|
||||
|
||||
JavaFileAssert.assertThat(files.get("DefaultApi.java"))
|
||||
.assertMethod("operationWithHttpInfo")
|
||||
.hasParameter("requestBody")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithName("NotNull")
|
||||
.hasParameter("requestBody")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithName("NotNull")
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("xNonNullHeaderParameter")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithName("NotNull");
|
||||
.hasParameter("xNonNullHeaderParameter")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithName("NotNull");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1707,18 +1707,18 @@ public class JavaClientCodegenTest {
|
||||
output.deleteOnExit();
|
||||
|
||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||
.setGeneratorName("java")
|
||||
.setLibrary(JavaClientCodegen.NATIVE)
|
||||
.setAdditionalProperties(properties)
|
||||
.setInputSpec("src/test/resources/3_0/exploded-query-param-array.yaml")
|
||||
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
|
||||
.setGeneratorName("java")
|
||||
.setLibrary(JavaClientCodegen.NATIVE)
|
||||
.setAdditionalProperties(properties)
|
||||
.setInputSpec("src/test/resources/3_0/exploded-query-param-array.yaml")
|
||||
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
|
||||
|
||||
final ClientOptInput clientOptInput = configurator.toClientOptInput();
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
generator.opts(clientOptInput).generate();
|
||||
|
||||
TestUtils.assertFileContains(Paths.get(output + "/src/main/java/xyz/abcdef/api/DefaultApi.java"),
|
||||
"localVarQueryParams.addAll(ApiClient.parameterToPairs(\"multi\", \"values\", queryObject.getValues()));"
|
||||
"localVarQueryParams.addAll(ApiClient.parameterToPairs(\"multi\", \"values\", queryObject.getValues()));"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1746,7 +1746,7 @@ public class JavaClientCodegenTest {
|
||||
generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true");
|
||||
List<File> files = generator.opts(clientOptInput).generate();
|
||||
|
||||
Assert.assertEquals(files.size(), 33);
|
||||
Assert.assertEquals(files.size(), 30);
|
||||
validateJavaSourceFiles(files);
|
||||
|
||||
TestUtils.assertFileContains(Paths.get(output + "/src/main/java/xyz/abcdef/model/Child.java"),
|
||||
@@ -1763,7 +1763,7 @@ public class JavaClientCodegenTest {
|
||||
output.deleteOnExit();
|
||||
String outputPath = output.getAbsolutePath().replace('\\', '/');
|
||||
OpenAPI openAPI = new OpenAPIParser()
|
||||
.readLocation("src/test/resources/bugs/issue_14731.yaml", null, new ParseOptions()).getOpenAPI();
|
||||
.readLocation("src/test/resources/bugs/issue_14731.yaml", null, new ParseOptions()).getOpenAPI();
|
||||
|
||||
JavaClientCodegen codegen = new JavaClientCodegen();
|
||||
codegen.setOutputDir(output.getAbsolutePath());
|
||||
@@ -1801,7 +1801,7 @@ public class JavaClientCodegenTest {
|
||||
output.deleteOnExit();
|
||||
String outputPath = output.getAbsolutePath().replace('\\', '/');
|
||||
OpenAPI openAPI = new OpenAPIParser()
|
||||
.readLocation("src/test/resources/bugs/issue_14731.yaml", null, new ParseOptions()).getOpenAPI();
|
||||
.readLocation("src/test/resources/bugs/issue_14731.yaml", null, new ParseOptions()).getOpenAPI();
|
||||
|
||||
JavaClientCodegen codegen = new JavaClientCodegen();
|
||||
codegen.setOutputDir(output.getAbsolutePath());
|
||||
@@ -1834,124 +1834,4 @@ public class JavaClientCodegenTest {
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/ChildWithoutMappingADTO.java"), "@JsonTypeName");
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/ChildWithoutMappingBDTO.java"), "@JsonTypeName");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testForJavaNativeJsonSubtype() throws IOException {
|
||||
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||
output.deleteOnExit();
|
||||
String outputPath = output.getAbsolutePath().replace('\\', '/');
|
||||
OpenAPI openAPI = new OpenAPIParser()
|
||||
.readLocation("src/test/resources/bugs/issue_14917.yaml", null, new ParseOptions()).getOpenAPI();
|
||||
|
||||
JavaClientCodegen codegen = new JavaClientCodegen();
|
||||
codegen.setOutputDir(output.getAbsolutePath());
|
||||
|
||||
ClientOptInput input = new ClientOptInput();
|
||||
input.openAPI(openAPI);
|
||||
input.config(codegen);
|
||||
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
codegen.setLibrary(JavaClientCodegen.NATIVE);
|
||||
|
||||
generator.opts(input).generate();
|
||||
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Cat.java"), "mappings.put(\"Cat\", Cat.class)");
|
||||
assertFileNotContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Cat.java"), "@JsonSubTypes");
|
||||
assertFileNotContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Cat.java"), "mappings.put(\"cat\", Cat.class);");
|
||||
assertFileNotContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Cat.java"), "mappings.put(\"dog\", Dog.class);");
|
||||
assertFileNotContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Cat.java"), "mappings.put(\"lizard\", Lizard.class);");
|
||||
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Pet.java"), "@JsonSubTypes.Type(value = Cat.class, name = \"cat\")");
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Pet.java"), "@JsonSubTypes.Type(value = Dog.class, name = \"dog\")");
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Pet.java"), "@JsonSubTypes.Type(value = Lizard.class, name = \"lizard\")");
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Pet.java"), "mappings.put(\"cat\", Cat.class)");
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Pet.java"), "mappings.put(\"dog\", Dog.class)");
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Pet.java"), "mappings.put(\"lizard\", Lizard.class)");
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Pet.java"), "mappings.put(\"Pet\", Pet.class)");
|
||||
|
||||
assertFileNotContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Pet.java"), "@JsonSubTypes.Type(value = Cat.class, name = \"Cat\")");
|
||||
assertFileNotContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Pet.java"), "@JsonSubTypes.Type(value = Dog.class, name = \"Dog\")");
|
||||
assertFileNotContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Pet.java"), "@JsonSubTypes.Type(value = Lizard.class, name = \"Lizard\")");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testForJavaApacheHttpClientJsonSubtype() throws IOException {
|
||||
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||
output.deleteOnExit();
|
||||
String outputPath = output.getAbsolutePath().replace('\\', '/');
|
||||
OpenAPI openAPI = new OpenAPIParser()
|
||||
.readLocation("src/test/resources/bugs/issue_14917.yaml", null, new ParseOptions()).getOpenAPI();
|
||||
|
||||
JavaClientCodegen codegen = new JavaClientCodegen();
|
||||
codegen.setOutputDir(output.getAbsolutePath());
|
||||
|
||||
ClientOptInput input = new ClientOptInput();
|
||||
input.openAPI(openAPI);
|
||||
input.config(codegen);
|
||||
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
codegen.setLibrary(JavaClientCodegen.APACHE);
|
||||
|
||||
generator.opts(input).generate();
|
||||
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Cat.java"), "@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = \"petType\", visible = true)");
|
||||
assertFileNotContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Cat.java"), "mappings.put");
|
||||
assertFileNotContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Cat.java"), "@JsonSubTypes.Type(value = Cat.class, name = \"cat\")");
|
||||
assertFileNotContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Cat.java"), "@JsonSubTypes.Type(value = Dog.class, name = \"dog\")");
|
||||
assertFileNotContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Cat.java"), "@JsonSubTypes.Type(value = Lizard.class, name = \"lizard\")");
|
||||
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Pet.java"), "@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = \"petType\", visible = true)");
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Pet.java"), "@JsonSubTypes.Type(value = Cat.class, name = \"cat\")");
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Pet.java"), "@JsonSubTypes.Type(value = Dog.class, name = \"dog\")");
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Pet.java"), "@JsonSubTypes.Type(value = Lizard.class, name = \"lizard\")");
|
||||
assertFileNotContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Pet.java"), "@JsonSubTypes.Type(value = Cat.class, name = \"Cat\")");
|
||||
assertFileNotContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Pet.java"), "@JsonSubTypes.Type(value = Dog.class, name = \"Dog\")");
|
||||
assertFileNotContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Pet.java"), "@JsonSubTypes.Type(value = Lizard.class, name = \"Lizard\")");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsOverriddenProperty() {
|
||||
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/allOf_composition_discriminator.yaml");
|
||||
JavaClientCodegen codegen = new JavaClientCodegen();
|
||||
|
||||
Schema test1 = openAPI.getComponents().getSchemas().get("Cat");
|
||||
codegen.setOpenAPI(openAPI);
|
||||
CodegenModel cm1 = codegen.fromModel("Cat", test1);
|
||||
|
||||
CodegenProperty cp0 = cm1.getAllVars().get(0);
|
||||
Assert.assertEquals(cp0.getName(), "petType");
|
||||
Assert.assertEquals(cp0.isOverridden, true);
|
||||
|
||||
CodegenProperty cp1 = cm1.getAllVars().get(1);
|
||||
Assert.assertEquals(cp1.getName(), "name");
|
||||
Assert.assertEquals(cp1.isOverridden, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testForJavaApacheHttpClientOverrideSetter() throws IOException {
|
||||
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||
output.deleteOnExit();
|
||||
String outputPath = output.getAbsolutePath().replace('\\', '/');
|
||||
OpenAPI openAPI = new OpenAPIParser()
|
||||
.readLocation("src/test/resources/3_0/allOf_composition_discriminator.yaml", null, new ParseOptions()).getOpenAPI();
|
||||
|
||||
JavaClientCodegen codegen = new JavaClientCodegen();
|
||||
codegen.setOutputDir(output.getAbsolutePath());
|
||||
|
||||
ClientOptInput input = new ClientOptInput();
|
||||
input.openAPI(openAPI);
|
||||
input.config(codegen);
|
||||
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
codegen.setLibrary(JavaClientCodegen.APACHE);
|
||||
|
||||
generator.opts(input).generate();
|
||||
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Cat.java"), " @Override\n" +
|
||||
" public Cat petType(String petType) {");
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/Pet.java"), " }\n" +
|
||||
"\n" +
|
||||
" public Pet petType(String petType) {\n");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,63 +251,4 @@ public class MicronautClientCodegenTest extends AbstractMicronautCodegenTest {
|
||||
assertFileContains(outputPath + "/src/main/java/org/openapitools/api/PetApi.java", "MyAdditionalAnnotation1(1,${param1})");
|
||||
assertFileContains(outputPath + "/src/main/java/org/openapitools/api/PetApi.java", "MyAdditionalAnnotation2(2,${param2})");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultAuthorizationFilterPattern() {
|
||||
JavaMicronautClientCodegen codegen = new JavaMicronautClientCodegen();
|
||||
codegen.additionalProperties().put(JavaMicronautClientCodegen.OPT_CONFIGURE_AUTH, "true");
|
||||
String outputPath = generateFiles(codegen, PETSTORE_PATH, CodegenConstants.SUPPORTING_FILES, CodegenConstants.APIS);
|
||||
|
||||
// Micronaut AuthorizationFilter should default to match all patterns
|
||||
assertFileContains(outputPath + "/src/main/java/org/openapitools/auth/AuthorizationFilter.java", "@Filter(Filter.MATCH_ALL_PATTERN)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAuthorizationFilterPattern() {
|
||||
JavaMicronautClientCodegen codegen = new JavaMicronautClientCodegen();
|
||||
codegen.additionalProperties().put(JavaMicronautClientCodegen.OPT_CONFIGURE_AUTH, "true");
|
||||
codegen.additionalProperties().put(JavaMicronautClientCodegen.AUTHORIZATION_FILTER_PATTERN, "pet/**");
|
||||
String outputPath = generateFiles(codegen, PETSTORE_PATH, CodegenConstants.SUPPORTING_FILES, CodegenConstants.APIS);
|
||||
|
||||
// Micronaut AuthorizationFilter should match the provided pattern
|
||||
assertFileContains(outputPath + "/src/main/java/org/openapitools/auth/AuthorizationFilter.java", "@Filter(\"pet/**\")");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoConfigureClientId() {
|
||||
JavaMicronautClientCodegen codegen = new JavaMicronautClientCodegen();
|
||||
String outputPath = generateFiles(codegen, PETSTORE_PATH, CodegenConstants.APIS);
|
||||
|
||||
// Micronaut declarative http client should not specify a Client id
|
||||
assertFileContains(outputPath + "/src/main/java/org/openapitools/api/PetApi.java", "@Client(\"${openapi-micronaut-client-base-path}\")");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigureClientId() {
|
||||
JavaMicronautClientCodegen codegen = new JavaMicronautClientCodegen();
|
||||
codegen.additionalProperties().put(JavaMicronautClientCodegen.CLIENT_ID, "unit-test");
|
||||
String outputPath = generateFiles(codegen, PETSTORE_PATH, CodegenConstants.APIS);
|
||||
|
||||
// Micronaut declarative http client should use the provided Client id
|
||||
assertFileContains(outputPath + "/src/main/java/org/openapitools/api/PetApi.java", "@Client( id = \"unit-test\", path = \"${openapi-micronaut-client-base-path}\")");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultPathSeparator() {
|
||||
JavaMicronautClientCodegen codegen = new JavaMicronautClientCodegen();
|
||||
String outputPath = generateFiles(codegen, PETSTORE_PATH, CodegenConstants.APIS);
|
||||
|
||||
// Micronaut declarative http client should use the default path separator
|
||||
assertFileContains(outputPath + "/src/main/java/org/openapitools/api/PetApi.java", "@Client(\"${openapi-micronaut-client-base-path}\")");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigurePathSeparator() {
|
||||
JavaMicronautClientCodegen codegen = new JavaMicronautClientCodegen();
|
||||
codegen.additionalProperties().put(JavaMicronautClientCodegen.BASE_PATH_SEPARATOR, ".");
|
||||
String outputPath = generateFiles(codegen, PETSTORE_PATH, CodegenConstants.APIS);
|
||||
|
||||
// Micronaut declarative http client should use the provided path separator
|
||||
assertFileContains(outputPath + "/src/main/java/org/openapitools/api/PetApi.java", "@Client(\"${openapi-micronaut-client.base-path}\")");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -915,37 +915,6 @@ public class SpringCodegenTest {
|
||||
assertFileNotContains(Paths.get(outputPath + "/src/main/java/org/openapitools/api/SomeApiDelegate.java"), "Mono<DummyRequest>");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldGenerateValidCodeForReactiveControllerWithoutParams_issue14907() throws IOException {
|
||||
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||
output.deleteOnExit();
|
||||
|
||||
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/bugs/issue_14907.yaml");
|
||||
final SpringCodegen codegen = new SpringCodegen();
|
||||
codegen.setOpenAPI(openAPI);
|
||||
codegen.setOutputDir(output.getAbsolutePath());
|
||||
|
||||
codegen.additionalProperties().put(SpringCodegen.REACTIVE, "true");
|
||||
codegen.additionalProperties().put(USE_TAGS, "true");
|
||||
codegen.additionalProperties().put(SpringCodegen.DATE_LIBRARY, "java8");
|
||||
codegen.additionalProperties().put(INTERFACE_ONLY, "true");
|
||||
codegen.additionalProperties().put(SKIP_DEFAULT_INTERFACE, "true");
|
||||
codegen.additionalProperties().put(IMPLICIT_HEADERS, "true");
|
||||
codegen.additionalProperties().put(OPENAPI_NULLABLE, "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.assertThat(files.get("ConsentControllerApi.java"))
|
||||
.assertMethod("readAgreements", "ServerWebExchange");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldEscapeReservedKeyWordsForRequestParameters_7506_Regression() throws Exception {
|
||||
final SpringCodegen codegen = new SpringCodegen();
|
||||
@@ -2191,44 +2160,6 @@ public class SpringCodegenTest {
|
||||
.collect(Collectors.toMap(File::getName, Function.identity()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMappingSubtypesIssue13150() throws IOException {
|
||||
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||
output.deleteOnExit();
|
||||
String outputPath = output.getAbsolutePath().replace('\\', '/');
|
||||
OpenAPI openAPI = new OpenAPIParser()
|
||||
.readLocation("src/test/resources/bugs/issue_13150.yaml", null, new ParseOptions()).getOpenAPI();
|
||||
|
||||
SpringCodegen codegen = new SpringCodegen();
|
||||
codegen.setOutputDir(output.getAbsolutePath());
|
||||
codegen.additionalProperties().put(CXFServerFeatures.LOAD_TEST_DATA_FROM_FILE, "true");
|
||||
codegen.setUseOneOfInterfaces(true);
|
||||
|
||||
ClientOptInput input = new ClientOptInput();
|
||||
input.openAPI(openAPI);
|
||||
input.config(codegen);
|
||||
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
codegen.setHateoas(true);
|
||||
generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true");
|
||||
generator.setGeneratorPropertyDefault(CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR, "false");
|
||||
|
||||
codegen.setUseOneOfInterfaces(true);
|
||||
codegen.setLegacyDiscriminatorBehavior(false);
|
||||
|
||||
generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false");
|
||||
generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false");
|
||||
generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true");
|
||||
generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false");
|
||||
|
||||
generator.opts(input).generate();
|
||||
|
||||
String jsonSubType = "@JsonSubTypes({\n" +
|
||||
" @JsonSubTypes.Type(value = Foo.class, name = \"foo\")\n" +
|
||||
"})";
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/model/Parent.java"), jsonSubType);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldGenerateJsonPropertyAnnotationLocatedInGetters_issue5705() throws IOException {
|
||||
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||
|
||||
@@ -388,6 +388,8 @@ public class RubyClientCodegenTest {
|
||||
Set<CodegenDiscriminator.MappedModel> mappedModels = new LinkedHashSet<CodegenDiscriminator.MappedModel>();
|
||||
mappedModels.add(new CodegenDiscriminator.MappedModel("a", "Adult"));
|
||||
mappedModels.add(new CodegenDiscriminator.MappedModel("c", "Child"));
|
||||
mappedModels.add(new CodegenDiscriminator.MappedModel("Adult", "Adult"));
|
||||
mappedModels.add(new CodegenDiscriminator.MappedModel("Child", "Child"));
|
||||
Assert.assertEquals(codegenDiscriminator.getMappedModels(), mappedModels);
|
||||
}
|
||||
|
||||
|
||||
@@ -85,15 +85,3 @@ components:
|
||||
type: boolean
|
||||
mum_or_dad:
|
||||
type: string
|
||||
allOfWithProperties:
|
||||
description: parent object without x-parent extension
|
||||
type: object
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/AnotherParent'
|
||||
properties:
|
||||
isParent:
|
||||
type: boolean
|
||||
mum_or_dad:
|
||||
type: string
|
||||
required:
|
||||
- isParent
|
||||
@@ -2259,13 +2259,4 @@ components:
|
||||
type: object
|
||||
properties:
|
||||
value:
|
||||
type: string
|
||||
LiteralStringClass:
|
||||
type: object
|
||||
properties:
|
||||
escapedLiteralString:
|
||||
type: string
|
||||
default: C:\\Users\\username
|
||||
unescapedLiteralString:
|
||||
type: string
|
||||
default: C:\Users\username
|
||||
type: string
|
||||
@@ -330,21 +330,6 @@ paths:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
/binary/gif:
|
||||
post:
|
||||
tags:
|
||||
- body
|
||||
summary: Test binary (gif) response body
|
||||
description: Test binary (gif) response body
|
||||
operationId: test/binary/gif
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
image/gif:
|
||||
schema:
|
||||
type: string
|
||||
format: binary
|
||||
|
||||
components:
|
||||
requestBodies:
|
||||
|
||||
@@ -215,7 +215,4 @@ components:
|
||||
default: 2
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/NumberEnum"
|
||||
allof-number-enum:
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/NumberEnum"
|
||||
|
||||
|
||||
@@ -1484,9 +1484,6 @@ components:
|
||||
type: object
|
||||
discriminator:
|
||||
propertyName: className
|
||||
mapping:
|
||||
DOG: '#/components/schemas/Dog'
|
||||
CAT: '#/components/schemas/Cat'
|
||||
required:
|
||||
- className
|
||||
properties:
|
||||
|
||||
@@ -1591,9 +1591,6 @@ components:
|
||||
string:
|
||||
type: string
|
||||
pattern: '/[a-z]/i'
|
||||
string_with_double_quote_pattern:
|
||||
type: string
|
||||
pattern: 'this is "something"'
|
||||
byte:
|
||||
type: string
|
||||
format: byte
|
||||
@@ -2126,24 +2123,3 @@ components:
|
||||
properties:
|
||||
optionalDict:
|
||||
$ref: "#/components/schemas/DictWithAdditionalProperties"
|
||||
Circular-Reference-Model:
|
||||
type: object
|
||||
properties:
|
||||
size:
|
||||
type: integer
|
||||
nested:
|
||||
$ref: '#/components/schemas/FirstRef'
|
||||
FirstRef:
|
||||
type: object
|
||||
properties:
|
||||
category:
|
||||
type: string
|
||||
self_ref:
|
||||
$ref: '#/components/schemas/SecondRef'
|
||||
SecondRef:
|
||||
type: object
|
||||
properties:
|
||||
category:
|
||||
type: string
|
||||
circular_ref:
|
||||
$ref: '#/components/schemas/Circular-Reference-Model'
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
openapi: '3.0.0'
|
||||
info:
|
||||
version: '1.0.0'
|
||||
title: 'FooService'
|
||||
paths:
|
||||
/parent:
|
||||
put:
|
||||
summary: put parent
|
||||
operationId: putParent
|
||||
parameters:
|
||||
- name: name
|
||||
in: path
|
||||
required: true
|
||||
description: Name of the account being updated.
|
||||
schema:
|
||||
type: string
|
||||
requestBody:
|
||||
description: The updated account definition to save.
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Parent'
|
||||
responses:
|
||||
'200':
|
||||
$ref: '#/components/responses/Parent'
|
||||
components:
|
||||
schemas:
|
||||
Parent:
|
||||
type: object
|
||||
description: Defines an account by name.
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
description: The account name.
|
||||
type:
|
||||
type: string
|
||||
description: The account type discriminator.
|
||||
required:
|
||||
- name
|
||||
- type
|
||||
discriminator:
|
||||
propertyName: type
|
||||
mapping:
|
||||
foo: '#/components/schemas/Foo'
|
||||
|
||||
Foo:
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/Parent"
|
||||
- type: object
|
||||
properties:
|
||||
fooType:
|
||||
type: string
|
||||
responses:
|
||||
Parent:
|
||||
description: The saved account definition.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Parent'
|
||||
@@ -1,54 +0,0 @@
|
||||
openapi: 3.0.1
|
||||
info:
|
||||
title: TEST
|
||||
description: |-
|
||||
## TEST
|
||||
version: 1.0.0
|
||||
|
||||
servers:
|
||||
- url: /v3
|
||||
description: Major version of service
|
||||
|
||||
tags:
|
||||
- name: consent-controller
|
||||
description: Consent API
|
||||
|
||||
|
||||
paths:
|
||||
/agreements:
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/x-client-ismobile'
|
||||
get:
|
||||
tags:
|
||||
- consent-controller
|
||||
operationId: readAgreements
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
'*/*':
|
||||
schema:
|
||||
$ref: '#/components/schemas/ListResponseResponseAgreement'
|
||||
components:
|
||||
schemas:
|
||||
ResponseAgreement:
|
||||
type: object
|
||||
properties:
|
||||
agreementId:
|
||||
type: string
|
||||
ListResponseResponseAgreement:
|
||||
type: object
|
||||
properties:
|
||||
list:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/ResponseAgreement'
|
||||
parameters:
|
||||
x-client-ismobile:
|
||||
name: x-client-ismobile
|
||||
in: header
|
||||
description: |
|
||||
blabla
|
||||
schema:
|
||||
type: boolean
|
||||
required: false
|
||||
@@ -1,66 +0,0 @@
|
||||
openapi: 3.0.0
|
||||
info:
|
||||
title: test
|
||||
description: >-
|
||||
test schema
|
||||
version: 1.0.0
|
||||
servers:
|
||||
- url: 'http://test.com'
|
||||
description: stage
|
||||
paths:
|
||||
/demo:
|
||||
get:
|
||||
summary: placeholder summary
|
||||
responses:
|
||||
'200':
|
||||
description: Success
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
components:
|
||||
schemas:
|
||||
AllPets:
|
||||
type: object
|
||||
properties:
|
||||
pets:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
Pet:
|
||||
type: object
|
||||
required:
|
||||
- petType
|
||||
properties:
|
||||
petType:
|
||||
type: string
|
||||
discriminator:
|
||||
propertyName: petType
|
||||
mapping:
|
||||
cat: '#/components/schemas/Cat'
|
||||
dog: '#/components/schemas/Dog'
|
||||
lizard: '#/components/schemas/Lizard'
|
||||
Cat:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/Pet'
|
||||
- type: object
|
||||
# all other properties specific to a `Cat`
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
Dog:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/Pet'
|
||||
- type: object
|
||||
# all other properties specific to a `Dog`
|
||||
properties:
|
||||
bark:
|
||||
type: string
|
||||
Lizard:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/Pet'
|
||||
- type: object
|
||||
# all other properties specific to a `Lizard`
|
||||
properties:
|
||||
lovesRocks:
|
||||
type: boolean
|
||||
2
pom.xml
2
pom.xml
@@ -13,7 +13,7 @@
|
||||
<packaging>pom</packaging>
|
||||
<name>openapi-generator-project</name>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>6.5.0</version>
|
||||
<version>6.5.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<url>https://github.com/openapitools/openapi-generator</url>
|
||||
<scm>
|
||||
|
||||
@@ -1 +1 @@
|
||||
6.5.0
|
||||
6.5.0-SNAPSHOT
|
||||
@@ -84,11 +84,12 @@ public class BodyApiExample {
|
||||
defaultClient.setBasePath("http://localhost:3000");
|
||||
|
||||
BodyApi apiInstance = new BodyApi(defaultClient);
|
||||
Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store
|
||||
try {
|
||||
File result = apiInstance.testBinaryGif();
|
||||
Pet result = apiInstance.testEchoBodyPet(pet);
|
||||
System.out.println(result);
|
||||
} catch (ApiException e) {
|
||||
System.err.println("Exception when calling BodyApi#testBinaryGif");
|
||||
System.err.println("Exception when calling BodyApi#testEchoBodyPet");
|
||||
System.err.println("Status code: " + e.getCode());
|
||||
System.err.println("Reason: " + e.getResponseBody());
|
||||
System.err.println("Response headers: " + e.getResponseHeaders());
|
||||
@@ -105,7 +106,6 @@ All URIs are relative to *http://localhost:3000*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
*BodyApi* | [**testBinaryGif**](docs/BodyApi.md#testBinaryGif) | **POST** /binary/gif | Test binary (gif) response body
|
||||
*BodyApi* | [**testEchoBodyPet**](docs/BodyApi.md#testEchoBodyPet) | **POST** /echo/body/Pet | Test body parameter(s)
|
||||
*BodyApi* | [**testEchoBodyPetResponseString**](docs/BodyApi.md#testEchoBodyPetResponseString) | **POST** /echo/body/Pet/response_string | Test empty response body
|
||||
*FormApi* | [**testFormIntegerBooleanString**](docs/FormApi.md#testFormIntegerBooleanString) | **POST** /form/integer/boolean/string | Test form parameter(s)
|
||||
|
||||
@@ -326,22 +326,6 @@ paths:
|
||||
- body
|
||||
x-content-type: application/json
|
||||
x-accepts: text/plain
|
||||
/binary/gif:
|
||||
post:
|
||||
description: Test binary (gif) response body
|
||||
operationId: test/binary/gif
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
image/gif:
|
||||
schema:
|
||||
format: binary
|
||||
type: string
|
||||
description: Successful operation
|
||||
summary: Test binary (gif) response body
|
||||
tags:
|
||||
- body
|
||||
x-accepts: image/gif
|
||||
components:
|
||||
requestBodies:
|
||||
Pet:
|
||||
|
||||
@@ -4,74 +4,11 @@ All URIs are relative to *http://localhost:3000*
|
||||
|
||||
| Method | HTTP request | Description |
|
||||
|------------- | ------------- | -------------|
|
||||
| [**testBinaryGif**](BodyApi.md#testBinaryGif) | **POST** /binary/gif | Test binary (gif) response body |
|
||||
| [**testEchoBodyPet**](BodyApi.md#testEchoBodyPet) | **POST** /echo/body/Pet | Test body parameter(s) |
|
||||
| [**testEchoBodyPetResponseString**](BodyApi.md#testEchoBodyPetResponseString) | **POST** /echo/body/Pet/response_string | Test empty response body |
|
||||
|
||||
|
||||
|
||||
## testBinaryGif
|
||||
|
||||
> File testBinaryGif()
|
||||
|
||||
Test binary (gif) response body
|
||||
|
||||
Test binary (gif) response body
|
||||
|
||||
### Example
|
||||
|
||||
```java
|
||||
// Import classes:
|
||||
import org.openapitools.client.ApiClient;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.Configuration;
|
||||
import org.openapitools.client.models.*;
|
||||
import org.openapitools.client.api.BodyApi;
|
||||
|
||||
public class Example {
|
||||
public static void main(String[] args) {
|
||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||
defaultClient.setBasePath("http://localhost:3000");
|
||||
|
||||
BodyApi apiInstance = new BodyApi(defaultClient);
|
||||
try {
|
||||
File result = apiInstance.testBinaryGif();
|
||||
System.out.println(result);
|
||||
} catch (ApiException e) {
|
||||
System.err.println("Exception when calling BodyApi#testBinaryGif");
|
||||
System.err.println("Status code: " + e.getCode());
|
||||
System.err.println("Reason: " + e.getResponseBody());
|
||||
System.err.println("Response headers: " + e.getResponseHeaders());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
[**File**](File.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: image/gif
|
||||
|
||||
|
||||
### HTTP response details
|
||||
| Status code | Description | Response headers |
|
||||
|-------------|-------------|------------------|
|
||||
| **200** | Successful operation | - |
|
||||
|
||||
|
||||
## testEchoBodyPet
|
||||
|
||||
> Pet testEchoBodyPet(pet)
|
||||
|
||||
@@ -20,7 +20,6 @@ import org.openapitools.client.Configuration;
|
||||
import org.openapitools.client.model.*;
|
||||
import org.openapitools.client.Pair;
|
||||
|
||||
import java.io.File;
|
||||
import org.openapitools.client.model.Pet;
|
||||
|
||||
|
||||
@@ -53,73 +52,6 @@ public class BodyApi {
|
||||
this.apiClient = apiClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test binary (gif) response body
|
||||
* Test binary (gif) response body
|
||||
* @return File
|
||||
* @throws ApiException if fails to make API call
|
||||
*/
|
||||
public File testBinaryGif() throws ApiException {
|
||||
return this.testBinaryGif(Collections.emptyMap());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test binary (gif) response body
|
||||
* Test binary (gif) response body
|
||||
* @param additionalHeaders additionalHeaders for this call
|
||||
* @return File
|
||||
* @throws ApiException if fails to make API call
|
||||
*/
|
||||
public File testBinaryGif(Map<String, String> additionalHeaders) throws ApiException {
|
||||
Object localVarPostBody = null;
|
||||
|
||||
// create path and map variables
|
||||
String localVarPath = "/binary/gif";
|
||||
|
||||
StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
|
||||
String localVarQueryParameterBaseName;
|
||||
List<Pair> localVarQueryParams = new ArrayList<Pair>();
|
||||
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
|
||||
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
|
||||
Map<String, String> localVarCookieParams = new HashMap<String, String>();
|
||||
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
|
||||
|
||||
|
||||
localVarHeaderParams.putAll(additionalHeaders);
|
||||
|
||||
|
||||
|
||||
final String[] localVarAccepts = {
|
||||
"image/gif"
|
||||
};
|
||||
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
|
||||
|
||||
final String[] localVarContentTypes = {
|
||||
|
||||
};
|
||||
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
|
||||
|
||||
String[] localVarAuthNames = new String[] { };
|
||||
|
||||
TypeReference<File> localVarReturnType = new TypeReference<File>() {};
|
||||
return apiClient.invokeAPI(
|
||||
localVarPath,
|
||||
"POST",
|
||||
localVarQueryParams,
|
||||
localVarCollectionQueryParams,
|
||||
localVarQueryStringJoiner.toString(),
|
||||
localVarPostBody,
|
||||
localVarHeaderParams,
|
||||
localVarCookieParams,
|
||||
localVarFormParams,
|
||||
localVarAccept,
|
||||
localVarContentType,
|
||||
localVarAuthNames,
|
||||
localVarReturnType
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test body parameter(s)
|
||||
* Test body parameter(s)
|
||||
|
||||
@@ -95,6 +95,7 @@ public class Bird {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
||||
@@ -95,6 +95,7 @@ public class Category {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
||||
@@ -130,17 +130,6 @@ public class DataQuery extends Query {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataQuery id(Long id) {
|
||||
this.setId(id);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataQuery outcomes(List<OutcomesEnum> outcomes) {
|
||||
this.setOutcomes(outcomes);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
@@ -127,6 +127,7 @@ public class DataQueryAllOf {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
||||
@@ -407,6 +407,7 @@ public class DefaultValue {
|
||||
this.stringNullable = JsonNullable.<String>of(stringNullable);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
||||
@@ -272,6 +272,7 @@ public class Pet {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
||||
@@ -142,6 +142,7 @@ public class Query {
|
||||
this.outcomes = outcomes;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
||||
@@ -95,6 +95,7 @@ public class Tag {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
||||
@@ -156,6 +156,7 @@ public class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
||||
@@ -76,6 +76,7 @@ public class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
||||
@@ -1 +1 @@
|
||||
6.5.0
|
||||
6.5.0-SNAPSHOT
|
||||
@@ -326,22 +326,6 @@ paths:
|
||||
- body
|
||||
x-content-type: application/json
|
||||
x-accepts: text/plain
|
||||
/binary/gif:
|
||||
post:
|
||||
description: Test binary (gif) response body
|
||||
operationId: test/binary/gif
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
image/gif:
|
||||
schema:
|
||||
format: binary
|
||||
type: string
|
||||
description: Successful operation
|
||||
summary: Test binary (gif) response body
|
||||
tags:
|
||||
- body
|
||||
x-accepts: image/gif
|
||||
components:
|
||||
requestBodies:
|
||||
Pet:
|
||||
|
||||
@@ -4,7 +4,6 @@ import org.openapitools.client.ApiClient;
|
||||
import org.openapitools.client.EncodingUtils;
|
||||
import org.openapitools.client.model.ApiResponse;
|
||||
|
||||
import java.io.File;
|
||||
import org.openapitools.client.model.Pet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -17,31 +16,6 @@ import feign.*;
|
||||
public interface BodyApi extends ApiClient.Api {
|
||||
|
||||
|
||||
/**
|
||||
* Test binary (gif) response body
|
||||
* Test binary (gif) response body
|
||||
* @return File
|
||||
*/
|
||||
@RequestLine("POST /binary/gif")
|
||||
@Headers({
|
||||
"Accept: image/gif",
|
||||
})
|
||||
File testBinaryGif();
|
||||
|
||||
/**
|
||||
* Test binary (gif) response body
|
||||
* Similar to <code>testBinaryGif</code> but it also returns the http response headers .
|
||||
* Test binary (gif) response body
|
||||
* @return A ApiResponse that wraps the response boyd and the http headers.
|
||||
*/
|
||||
@RequestLine("POST /binary/gif")
|
||||
@Headers({
|
||||
"Accept: image/gif",
|
||||
})
|
||||
ApiResponse<File> testBinaryGifWithHttpInfo();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Test body parameter(s)
|
||||
* Test body parameter(s)
|
||||
|
||||
@@ -81,6 +81,7 @@ public class Bird {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
||||
@@ -81,6 +81,7 @@ public class Category {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
||||
@@ -112,17 +112,6 @@ public class DataQuery extends Query {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataQuery id(Long id) {
|
||||
this.setId(id);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataQuery outcomes(List<OutcomesEnum> outcomes) {
|
||||
this.setOutcomes(outcomes);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
@@ -108,6 +108,7 @@ public class DataQueryAllOf {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
||||
@@ -346,6 +346,7 @@ public class DefaultValue {
|
||||
this.stringNullable = stringNullable;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
||||
@@ -254,6 +254,7 @@ public class Pet {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
||||
@@ -140,6 +140,7 @@ public class Query {
|
||||
this.outcomes = outcomes;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
||||
@@ -81,6 +81,7 @@ public class Tag {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
||||
@@ -133,6 +133,7 @@ public class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
||||
@@ -65,6 +65,7 @@ public class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user