mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2026-03-17 10:19:04 +00:00
Compare commits
12 Commits
snakeyaml-
...
parser-res
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b352c2d00 | ||
|
|
991883636f | ||
|
|
3ef45f1b4d | ||
|
|
7e439fd0bd | ||
|
|
63df7ca574 | ||
|
|
98b315c137 | ||
|
|
a809c187b4 | ||
|
|
d966f1234d | ||
|
|
6fdb632fb9 | ||
|
|
c7542dea3e | ||
|
|
66dfad2b09 | ||
|
|
9e5e4b1fd4 |
3
.github/workflows/samples-spring-jdk17.yaml
vendored
3
.github/workflows/samples-spring-jdk17.yaml
vendored
@@ -10,6 +10,7 @@ on:
|
||||
- samples/server/petstore/springboot-lombok-tostring
|
||||
- samples/server/petstore/springboot-file-delegate-optional
|
||||
- samples/server/petstore/springboot-petstore-with-api-response-examples
|
||||
- samples/server/petstore/spring-boot-oneof-sealed
|
||||
pull_request:
|
||||
paths:
|
||||
- samples/openapi3/client/petstore/spring-cloud-3-with-optional
|
||||
@@ -19,6 +20,7 @@ on:
|
||||
- samples/server/petstore/springboot-lombok-tostring
|
||||
- samples/server/petstore/springboot-file-delegate-optional
|
||||
- samples/server/petstore/springboot-petstore-with-api-response-examples
|
||||
- samples/server/petstore/spring-boot-oneof-sealed
|
||||
jobs:
|
||||
build:
|
||||
name: Build Java Spring (JDK17)
|
||||
@@ -36,6 +38,7 @@ jobs:
|
||||
- samples/server/petstore/springboot-lombok-tostring
|
||||
- samples/server/petstore/springboot-file-delegate-optional
|
||||
- samples/server/petstore/springboot-petstore-with-api-response-examples
|
||||
- samples/server/petstore/spring-boot-oneof-sealed
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-java@v4
|
||||
|
||||
@@ -76,6 +76,7 @@ If you find OpenAPI Generator useful for work, please consider asking your compa
|
||||
[<img src="https://openapi-generator.tech/img/companies/clickit.jpg" width="128" height="128">](https://www.clickittech.com/?utm_source=openapi-generator&utm_medium=sponsorship&utm_campaign=oss-sponsorship)
|
||||
[<img src="https://openapi-generator.tech/img/companies/unified_to.jpg" width="128" height="128">](https://unified.to/?utm_source=openapi-generator&utm_medium=sponsorship&utm_campaign=oss-sponsorship)
|
||||
[<img src="https://openapi-generator.tech/img/companies/savetwt.jpg" width="128" height="128">](https://savetwt.com/?utm_source=openapi-generator&utm_medium=sponsorship&utm_campaign=oss-sponsorship)
|
||||
[<img src="https://openapi-generator.tech/img/companies/serpapi.png" width="128" height="128">](https://serpapi.com/?utm_source=openapi-generator&utm_medium=sponsorship&utm_campaign=oss-sponsorship)
|
||||
|
||||
#### Thank you GoDaddy for sponsoring the domain names, Linode for sponsoring the VPS, Checkly for sponsoring the API monitoring and Gradle for sponsoring Develocity
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
generatorName: dart-dio
|
||||
outputDir: samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/dart/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/dart/libraries/dio
|
||||
typeMappings:
|
||||
Client: "ModelClient"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
generatorName: dart-dio
|
||||
outputDir: samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/dart/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/dart/libraries/dio
|
||||
typeMappings:
|
||||
Client: "ModelClient"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
generatorName: dart
|
||||
outputDir: samples/openapi3/client/petstore/dart2/petstore_client_lib_fake
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/dart/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/dart2
|
||||
typeMappings:
|
||||
Client: "ModelClient"
|
||||
|
||||
13
bin/configs/spring-boot-oneof-sealed.yaml
Normal file
13
bin/configs/spring-boot-oneof-sealed.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/openapi3/server/petstore/spring-boot-oneof-sealed
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneof_polymorphism_and_inheritance.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
groupId: org.openapitools.openapi3
|
||||
documentationProvider: springdoc
|
||||
artifactId: springboot-oneof-sealed
|
||||
snapshotVersion: "true"
|
||||
hideGenerationTimestamp: "true"
|
||||
generateBuilders: true
|
||||
useOneOfInterfaces: true
|
||||
useSealed: true
|
||||
@@ -162,7 +162,7 @@ public class Generate extends OpenApiGeneratorCommand {
|
||||
|
||||
@Option(
|
||||
name = {"--openapi-generator-ignore-list"},
|
||||
title = ".openapi-generaotr-ignore list",
|
||||
title = ".openapi-generator-ignore list",
|
||||
description = "specifies entries in the .openapi-generator-ignore file relative/path/to/file1,relative/path/to/file2. For example: README.md,pom.xml"
|
||||
+ " You can also have multiple occurrences of this option.")
|
||||
private List<String> openapiGeneratorIgnoreList = new ArrayList<>();
|
||||
|
||||
@@ -3682,7 +3682,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (ModelUtils.isComposedSchema(schema) && !this.getLegacyDiscriminatorBehavior()) {
|
||||
List<MappedModel> otherDescendants = getOneOfAnyOfDescendants(schemaName, discriminatorPropertyName, schema);
|
||||
for (MappedModel otherDescendant : otherDescendants) {
|
||||
if (!uniqueDescendants.contains(otherDescendant)) {
|
||||
// add only if the model names are not the same
|
||||
if (uniqueDescendants.stream().map(MappedModel::getModelName).noneMatch(it -> it.equals(otherDescendant.getModelName()))) {
|
||||
uniqueDescendants.add(otherDescendant);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ import {{invokerPackage}}.auth.OAuth;
|
||||
{{/hasOAuthMethods}}
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
protected Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||
protected Map<String, String> defaultCookieMap = new HashMap<String, String>();
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class Configuration {
|
||||
public static final String VERSION = "{{{artifactVersion}}}";
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.time.format.DateTimeParseException;
|
||||
* It's generated for java clients when {@code AbstractJavaCodegen#dateLibrary} specified as {@code java8}.
|
||||
*/
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class JavaTimeFormatter {
|
||||
private DateTimeFormatter offsetDateTimeFormatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
package {{invokerPackage}};
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class Pair {
|
||||
private final String name;
|
||||
private final String value;
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.util.GregorianCalendar;
|
||||
import java.util.TimeZone;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class RFC3339DateFormat extends DateFormat {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeFeature;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class RFC3339InstantDeserializer<T extends Temporal> extends InstantDeserializer<T> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final static boolean DEFAULT_NORMALIZE_ZONE_ID = JavaTimeFeature.NORMALIZE_DESERIALIZED_ZONE_ID.enabledByDefault();
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.time.ZonedDateTime;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class RFC3339JavaTimeModule extends SimpleModule {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.Map;
|
||||
* Representing a Server configuration.
|
||||
*/
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class ServerConfiguration {
|
||||
public String URL;
|
||||
public String description;
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.HashSet;
|
||||
* Representing a Server Variable for server URL template substitution.
|
||||
*/
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class ServerVariable {
|
||||
public String description;
|
||||
public String defaultValue;
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class StringUtil {
|
||||
/**
|
||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||
|
||||
@@ -19,6 +19,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
{{#operations}}
|
||||
public class {{classname}} {
|
||||
private ApiClient apiClient;
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class ApiException extends{{#useRuntimeException}} RuntimeException {{/useRuntimeException}}{{^useRuntimeException}} Exception {{/useRuntimeException}}{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class ApiKeyAuth implements Authentication {
|
||||
private final String location;
|
||||
private final String paramName;
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public interface Authentication {
|
||||
/**
|
||||
* Apply authentication settings to header and query params.
|
||||
|
||||
@@ -11,6 +11,7 @@ import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class HttpBasicAuth implements Authentication {
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class HttpBearerAuth implements Authentication {
|
||||
private final String scheme;
|
||||
private Supplier<String> tokenSupplier;
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class OAuth implements Authentication {
|
||||
private String accessToken;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ package {{invokerPackage}}.auth;
|
||||
* OAuth flows that are supported by this client
|
||||
*/
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public enum OAuthFlow {
|
||||
ACCESS_CODE, //called authorizationCode in OpenAPI 3.0
|
||||
IMPLICIT,
|
||||
|
||||
@@ -86,6 +86,7 @@ import {{invokerPackage}}.auth.OAuth;
|
||||
{{/hasOAuthMethods}}
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
protected Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||
protected Map<String, String> defaultCookieMap = new HashMap<String, String>();
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public abstract class BaseApi {
|
||||
|
||||
protected ApiClient apiClient;
|
||||
|
||||
@@ -29,6 +29,7 @@ import {{javaxPackage}}.validation.Valid;
|
||||
|
||||
{{/useBeanValidation}}
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
{{#operations}}
|
||||
public class {{classname}} extends BaseApi {
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ import feign.Retryer;
|
||||
{{/hasOAuthMethods}}
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class ApiClient {
|
||||
protected static final Logger log = Logger.getLogger(ApiClient.class.getName());
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import {{javaxPackage}}.validation.Valid;
|
||||
import feign.*;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public interface {{classname}} extends ApiClient.Api {
|
||||
|
||||
{{#operations}}{{#operation}}
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.github.scribejava.core.oauth2.clientauthentication.ClientAuthenticati
|
||||
import com.github.scribejava.core.oauth2.clientauthentication.RequestBodyAuthenticationScheme;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class DefaultApi20Impl extends DefaultApi20 {
|
||||
|
||||
private final String accessTokenEndpoint;
|
||||
|
||||
@@ -10,6 +10,7 @@ import feign.RequestTemplate;
|
||||
import java.util.Collection;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public abstract class OAuth implements RequestInterceptor {
|
||||
|
||||
//https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.4
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.github.scribejava.core.builder.ServiceBuilder;
|
||||
import com.github.scribejava.core.model.OAuth2AccessToken;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class OauthClientCredentialsGrant extends OAuth {
|
||||
|
||||
public OauthClientCredentialsGrant(String authorizationUrl, String tokenUrl, String scopes) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.github.scribejava.core.builder.ServiceBuilder;
|
||||
import com.github.scribejava.core.model.OAuth2AccessToken;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class OauthPasswordGrant extends OAuth {
|
||||
|
||||
private String username;
|
||||
|
||||
@@ -33,10 +33,12 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
{{#isEnum}}
|
||||
{{^isContainer}}
|
||||
{{>modelInnerEnum}}
|
||||
|
||||
{{/isContainer}}
|
||||
{{#isContainer}}
|
||||
{{#mostInnerItems}}
|
||||
{{>modelInnerEnum}}
|
||||
|
||||
{{/mostInnerItems}}
|
||||
{{/isContainer}}
|
||||
{{/isEnum}}
|
||||
@@ -72,7 +74,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
{{/isContainer}}
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{^vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{>nullable_var_annotations}}
|
||||
{{>nullable_var_annotations}}{{! prevent indent}}
|
||||
{{#isContainer}}
|
||||
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
|
||||
{{/isContainer}}
|
||||
@@ -190,12 +192,13 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
{{#deprecated}}
|
||||
@Deprecated
|
||||
{{/deprecated}}
|
||||
{{>nullable_var_annotations}}
|
||||
{{>nullable_var_annotations}}{{! prevent indent}}
|
||||
{{#jsonb}}
|
||||
@JsonbProperty("{{baseName}}")
|
||||
{{/jsonb}}
|
||||
{{#useBeanValidation}}
|
||||
{{>beanValidation}}
|
||||
|
||||
{{/useBeanValidation}}
|
||||
{{#swagger1AnnotationLibrary}}
|
||||
@ApiModelProperty({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
|
||||
@@ -224,6 +227,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
|
||||
{{#vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{> jackson_annotations}}
|
||||
|
||||
public JsonNullable<{{{datatypeWithEnum}}}> {{getter}}_JsonNullable() {
|
||||
return {{name}};
|
||||
}
|
||||
@@ -249,6 +253,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
|
||||
{{/vars}}
|
||||
{{>libraries/feign/additional_properties}}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
{{#useReflectionEqualsHashCode}}
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class ApiClient {
|
||||
protected final String basePath;
|
||||
protected final HttpRequestFactory httpRequestFactory;
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
{{#operations}}
|
||||
public class {{classname}} {
|
||||
private ApiClient apiClient;
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
* Abstract class for oneOf,anyOf schemas defined in OpenAPI spec
|
||||
*/
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public abstract class AbstractOpenApiSchema {
|
||||
|
||||
// store the actual instance of the schema/object
|
||||
@@ -135,4 +136,5 @@ public abstract class AbstractOpenApiSchema {
|
||||
|
||||
{{>libraries/jersey2/additional_properties}}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -84,6 +84,7 @@ import {{invokerPackage}}.auth.OAuth;
|
||||
* <p>ApiClient class.</p>
|
||||
*/
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
protected static final Pattern JSON_MIME_PATTERN = Pattern.compile("(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$");
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import {{javaxPackage}}.ws.rs.core.GenericType;
|
||||
import {{javaxPackage}}.ws.rs.ext.ContextResolver;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class JSON implements ContextResolver<ObjectMapper> {
|
||||
private ObjectMapper mapper;
|
||||
|
||||
|
||||
@@ -119,6 +119,7 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
|
||||
super("anyOf", {{#isNullable}}Boolean.TRUE{{/isNullable}}{{^isNullable}}Boolean.FALSE{{/isNullable}});
|
||||
}
|
||||
{{> libraries/jersey2/additional_properties }}
|
||||
|
||||
{{#additionalPropertiesType}}
|
||||
/**
|
||||
* Return true if this {{name}} object is equal to o.
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
{{#operations}}
|
||||
public class {{classname}} {
|
||||
private ApiClient apiClient;
|
||||
@@ -205,7 +206,7 @@ public class {{classname}} {
|
||||
|
||||
public class API{{operationId}}Request {
|
||||
{{#allParams}}
|
||||
{{>nullable_var_annotations}}
|
||||
{{>nullable_var_annotations}}{{! prevent indent}}
|
||||
private {{{dataType}}} {{paramName}};
|
||||
{{/allParams}}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.TreeMap;
|
||||
* API Exception
|
||||
*/
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class ApiException extends{{#useRuntimeException}} RuntimeException {{/useRuntimeException}}{{^useRuntimeException}} Exception {{/useRuntimeException}}{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class ApiKeyAuth implements Authentication {
|
||||
private final String location;
|
||||
private final String paramName;
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public interface Authentication {
|
||||
/**
|
||||
* Apply authentication settings to header and query params.
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class HttpBasicAuth implements Authentication {
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class HttpBearerAuth implements Authentication {
|
||||
private final String scheme;
|
||||
private String bearerToken;
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class OAuth implements Authentication {
|
||||
private static final Logger log = Logger.getLogger(OAuth.class.getName());
|
||||
|
||||
|
||||
@@ -2,17 +2,21 @@
|
||||
|
||||
{{#isEnum}}
|
||||
{{>enum_outer_doc}}
|
||||
|
||||
{{/isEnum}}
|
||||
{{^isEnum}}
|
||||
{{^oneOf.isEmpty}}
|
||||
{{>model_oneof_doc}}
|
||||
|
||||
{{/oneOf.isEmpty}}
|
||||
{{^anyOf.isEmpty}}
|
||||
{{>model_anyof_doc}}
|
||||
|
||||
{{/anyOf.isEmpty}}
|
||||
{{^anyOf}}
|
||||
{{^oneOf}}
|
||||
{{>pojo_doc}}
|
||||
|
||||
{{/oneOf}}
|
||||
{{/anyOf}}
|
||||
{{/isEnum}}
|
||||
|
||||
@@ -181,6 +181,7 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
|
||||
super("oneOf", {{#isNullable}}Boolean.TRUE{{/isNullable}}{{^isNullable}}Boolean.FALSE{{/isNullable}});
|
||||
}
|
||||
{{> libraries/jersey2/additional_properties }}
|
||||
|
||||
{{#additionalPropertiesType}}
|
||||
/**
|
||||
* Return true if this {{name}} object is equal to o.
|
||||
|
||||
@@ -37,11 +37,13 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
{{^isContainer}}
|
||||
{{^vendorExtensions.x-enum-as-string}}
|
||||
{{>modelInnerEnum}}
|
||||
|
||||
{{/vendorExtensions.x-enum-as-string}}
|
||||
{{/isContainer}}
|
||||
{{#isContainer}}
|
||||
{{#mostInnerItems}}
|
||||
{{>modelInnerEnum}}
|
||||
|
||||
{{/mostInnerItems}}
|
||||
{{/isContainer}}
|
||||
{{/isEnum}}
|
||||
@@ -81,7 +83,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
{{#deprecated}}
|
||||
@Deprecated
|
||||
{{/deprecated}}
|
||||
{{>nullable_var_annotations}}
|
||||
{{>nullable_var_annotations}}{{! prevent indent}}
|
||||
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
|
||||
@@ -198,9 +200,10 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
{{#deprecated}}
|
||||
@Deprecated
|
||||
{{/deprecated}}
|
||||
{{>nullable_var_annotations}}
|
||||
{{>nullable_var_annotations}}{{! prevent indent}}
|
||||
{{#useBeanValidation}}
|
||||
{{>beanValidation}}
|
||||
|
||||
{{/useBeanValidation}}
|
||||
{{#swagger1AnnotationLibrary}}
|
||||
@ApiModelProperty({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
|
||||
@@ -232,6 +235,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
|
||||
{{#vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{> jackson_annotations}}
|
||||
|
||||
public JsonNullable<{{{datatypeWithEnum}}}> {{getter}}_JsonNullable() {
|
||||
return {{name}};
|
||||
}
|
||||
@@ -266,6 +270,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
|
||||
{{/vars}}
|
||||
{{>libraries/jersey2/additional_properties}}
|
||||
|
||||
/**
|
||||
* Return true if this {{name}} object is equal to o.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
* Abstract class for oneOf,anyOf schemas defined in OpenAPI spec
|
||||
*/
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public abstract class AbstractOpenApiSchema {
|
||||
|
||||
// store the actual instance of the schema/object
|
||||
@@ -135,4 +136,5 @@ public abstract class AbstractOpenApiSchema {
|
||||
|
||||
{{>libraries/jersey2/additional_properties}}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -84,6 +84,7 @@ import {{invokerPackage}}.auth.OAuth;
|
||||
* <p>ApiClient class.</p>
|
||||
*/
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
protected static final Pattern JSON_MIME_PATTERN = Pattern.compile("(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$");
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import {{javaxPackage}}.ws.rs.core.GenericType;
|
||||
import {{javaxPackage}}.ws.rs.ext.ContextResolver;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class JSON implements ContextResolver<ObjectMapper> {
|
||||
private ObjectMapper mapper;
|
||||
|
||||
|
||||
@@ -119,6 +119,7 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
|
||||
super("anyOf", {{#isNullable}}Boolean.TRUE{{/isNullable}}{{^isNullable}}Boolean.FALSE{{/isNullable}});
|
||||
}
|
||||
{{> libraries/jersey2/additional_properties }}
|
||||
|
||||
{{#additionalPropertiesType}}
|
||||
/**
|
||||
* Return true if this {{name}} object is equal to o.
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
{{#operations}}
|
||||
public class {{classname}} {
|
||||
private ApiClient apiClient;
|
||||
@@ -205,7 +206,7 @@ public class {{classname}} {
|
||||
|
||||
public class API{{operationId}}Request {
|
||||
{{#allParams}}
|
||||
{{>nullable_var_annotations}}
|
||||
{{>nullable_var_annotations}}{{! prevent indent}}
|
||||
private {{{dataType}}} {{paramName}};
|
||||
{{/allParams}}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.TreeMap;
|
||||
* API Exception
|
||||
*/
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class ApiException extends{{#useRuntimeException}} RuntimeException {{/useRuntimeException}}{{^useRuntimeException}} Exception {{/useRuntimeException}}{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class ApiKeyAuth implements Authentication {
|
||||
private final String location;
|
||||
private final String paramName;
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public interface Authentication {
|
||||
/**
|
||||
* Apply authentication settings to header and query params.
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class HttpBasicAuth implements Authentication {
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class HttpBearerAuth implements Authentication {
|
||||
private final String scheme;
|
||||
private String bearerToken;
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class OAuth implements Authentication {
|
||||
private static final Logger log = Logger.getLogger(OAuth.class.getName());
|
||||
|
||||
|
||||
@@ -2,17 +2,21 @@
|
||||
|
||||
{{#isEnum}}
|
||||
{{>enum_outer_doc}}
|
||||
|
||||
{{/isEnum}}
|
||||
{{^isEnum}}
|
||||
{{^oneOf.isEmpty}}
|
||||
{{>model_oneof_doc}}
|
||||
|
||||
{{/oneOf.isEmpty}}
|
||||
{{^anyOf.isEmpty}}
|
||||
{{>model_anyof_doc}}
|
||||
|
||||
{{/anyOf.isEmpty}}
|
||||
{{^anyOf}}
|
||||
{{^oneOf}}
|
||||
{{>pojo_doc}}
|
||||
|
||||
{{/oneOf}}
|
||||
{{/anyOf}}
|
||||
{{/isEnum}}
|
||||
|
||||
@@ -181,6 +181,7 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
|
||||
super("oneOf", {{#isNullable}}Boolean.TRUE{{/isNullable}}{{^isNullable}}Boolean.FALSE{{/isNullable}});
|
||||
}
|
||||
{{> libraries/jersey2/additional_properties }}
|
||||
|
||||
{{#additionalPropertiesType}}
|
||||
/**
|
||||
* Return true if this {{name}} object is equal to o.
|
||||
|
||||
@@ -37,11 +37,13 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
{{^isContainer}}
|
||||
{{^vendorExtensions.x-enum-as-string}}
|
||||
{{>modelInnerEnum}}
|
||||
|
||||
{{/vendorExtensions.x-enum-as-string}}
|
||||
{{/isContainer}}
|
||||
{{#isContainer}}
|
||||
{{#mostInnerItems}}
|
||||
{{>modelInnerEnum}}
|
||||
|
||||
{{/mostInnerItems}}
|
||||
{{/isContainer}}
|
||||
{{/isEnum}}
|
||||
@@ -81,7 +83,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
{{#deprecated}}
|
||||
@Deprecated
|
||||
{{/deprecated}}
|
||||
{{>nullable_var_annotations}}
|
||||
{{>nullable_var_annotations}}{{! prevent indent}}
|
||||
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
|
||||
@@ -198,9 +200,10 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
{{#deprecated}}
|
||||
@Deprecated
|
||||
{{/deprecated}}
|
||||
{{>nullable_var_annotations}}
|
||||
{{>nullable_var_annotations}}{{! prevent indent}}
|
||||
{{#useBeanValidation}}
|
||||
{{>beanValidation}}
|
||||
|
||||
{{/useBeanValidation}}
|
||||
{{#swagger1AnnotationLibrary}}
|
||||
@ApiModelProperty({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
|
||||
@@ -232,6 +235,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
|
||||
{{#vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{> jackson_annotations}}
|
||||
|
||||
public JsonNullable<{{{datatypeWithEnum}}}> {{getter}}_JsonNullable() {
|
||||
return {{name}};
|
||||
}
|
||||
@@ -266,6 +270,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
|
||||
{{/vars}}
|
||||
{{>libraries/jersey2/additional_properties}}
|
||||
|
||||
/**
|
||||
* Return true if this {{name}} object is equal to o.
|
||||
*/
|
||||
|
||||
@@ -55,9 +55,11 @@ import {{rootJavaEEPackage}}.validation.Valid;
|
||||
{{#model}}
|
||||
{{#isEnum}}
|
||||
{{>enumOuterClass}}
|
||||
|
||||
{{/isEnum}}
|
||||
{{^isEnum}}
|
||||
{{>pojo}}
|
||||
|
||||
{{/isEnum}}
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
@@ -4,6 +4,7 @@
|
||||
){{/hasVars}}
|
||||
{{^hasVars}}@XmlType(name = "{{classname}}"){{/hasVars}}
|
||||
{{> xmlAnnotation }}
|
||||
|
||||
{{/withXml}}
|
||||
{{#jackson}}
|
||||
@JsonPropertyOrder({
|
||||
@@ -58,6 +59,7 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}}{{#vendorExtensi
|
||||
{{/isContainer}}
|
||||
{{/vars}}
|
||||
{{>additional_properties}}
|
||||
|
||||
{{#vendorExtensions.x-has-readonly-properties}}{{^withXml}}
|
||||
public {{classname}}() {
|
||||
}
|
||||
@@ -150,4 +152,5 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}}{{#vendorExtensi
|
||||
|
||||
{{/vars}}
|
||||
{{>pojoOverrides}}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
* Abstract class for oneOf,anyOf schemas defined in OpenAPI spec
|
||||
*/
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public abstract class AbstractOpenApiSchema {
|
||||
|
||||
// store the actual instance of the schema/object
|
||||
@@ -133,4 +134,5 @@ public abstract class AbstractOpenApiSchema {
|
||||
|
||||
{{>libraries/native/additional_properties}}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
* a fluent style of configuration.</p>
|
||||
*/
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class ApiClient {
|
||||
|
||||
protected HttpClient.Builder builder;
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.TreeMap;
|
||||
* @param <T> The type of data that is deserialized from response body
|
||||
*/
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class ApiResponse<T> {
|
||||
final private int statusCode;
|
||||
final private Map<String, List<String>> headers;
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class JSON {
|
||||
private ObjectMapper mapper;
|
||||
|
||||
@@ -88,7 +89,7 @@ public class JSON {
|
||||
/**
|
||||
* Helper class to register the discriminator mappings.
|
||||
*/
|
||||
{{>generatedAnnotation}}
|
||||
{{>generatedAnnotation}}{{! prevent indent}}
|
||||
private static class ClassDiscriminatorMapping {
|
||||
// The model class name.
|
||||
Class<?> modelClass;
|
||||
|
||||
@@ -103,6 +103,7 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
|
||||
super("anyOf", {{#isNullable}}Boolean.TRUE{{/isNullable}}{{^isNullable}}Boolean.FALSE{{/isNullable}});
|
||||
}
|
||||
{{> libraries/native/additional_properties }}
|
||||
|
||||
{{#additionalPropertiesType}}
|
||||
/**
|
||||
* Return true if this {{name}} object is equal to o.
|
||||
|
||||
@@ -54,6 +54,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
{{/asyncNative}}
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
{{#operations}}
|
||||
public class {{classname}} {
|
||||
private final HttpClient memberVarHttpClient;
|
||||
@@ -100,6 +101,54 @@ public class {{classname}} {
|
||||
return operationId + " call failed with: " + statusCode + " - " + body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file from the given response.
|
||||
*
|
||||
* @param response Response
|
||||
* @return File
|
||||
* @throws ApiException If fail to read file content from response and write to disk
|
||||
*/
|
||||
public File downloadFileFromResponse(HttpResponse<InputStream> response) throws ApiException {
|
||||
try {
|
||||
File file = prepareDownloadFile(response);
|
||||
java.nio.file.Files.copy(response.body(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Prepare the file for download from the response.</p>
|
||||
*
|
||||
* @param response a {@link java.net.http.HttpResponse} object.
|
||||
* @return a {@link java.io.File} object.
|
||||
* @throws java.io.IOException if any.
|
||||
*/
|
||||
private File prepareDownloadFile(HttpResponse<InputStream> response) throws IOException {
|
||||
String filename = null;
|
||||
java.util.Optional<String> contentDisposition = response.headers().firstValue("Content-Disposition");
|
||||
if (contentDisposition.isPresent() && !"".equals(contentDisposition.get())) {
|
||||
// Get filename from the Content-Disposition header.
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
|
||||
java.util.regex.Matcher matcher = pattern.matcher(contentDisposition.get());
|
||||
if (matcher.find())
|
||||
filename = matcher.group(1);
|
||||
}
|
||||
File file = null;
|
||||
if (filename != null) {
|
||||
java.nio.file.Path tempDir = java.nio.file.Files.createTempDirectory("swagger-gen-native");
|
||||
java.nio.file.Path filePath = java.nio.file.Files.createFile(tempDir.resolve(filename));
|
||||
file = filePath.toFile();
|
||||
tempDir.toFile().deleteOnExit(); // best effort cleanup
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
} else {
|
||||
file = java.nio.file.Files.createTempFile("download-", "").toFile();
|
||||
file.deleteOnExit(); // best effort cleanup
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
{{#operation}}
|
||||
{{#vendorExtensions.x-group-parameters}}
|
||||
{{#hasParams}}
|
||||
@@ -129,7 +178,7 @@ public class {{classname}} {
|
||||
{{/isDeprecated}}
|
||||
public {{#returnType}}{{#asyncNative}}CompletableFuture<{{{returnType}}}>{{/asyncNative}}{{^asyncNative}}{{{returnType}}}{{/asyncNative}}{{/returnType}}{{^returnType}}{{#asyncNative}}CompletableFuture<Void>{{/asyncNative}}{{^asyncNative}}void{{/asyncNative}}{{/returnType}} {{operationId}}(API{{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Request apiRequest) throws ApiException {
|
||||
{{#allParams}}
|
||||
{{>nullable_var_annotations}}
|
||||
{{>nullable_var_annotations}}{{! prevent indent}}
|
||||
{{{dataType}}} {{paramName}} = apiRequest.{{paramName}}();
|
||||
{{/allParams}}
|
||||
{{#returnType}}return {{/returnType}}{{^returnType}}{{#asyncNative}}return {{/asyncNative}}{{/returnType}}{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
|
||||
@@ -291,13 +340,23 @@ public class {{classname}} {
|
||||
);
|
||||
}
|
||||
|
||||
{{^isResponseFile}}{{#isResponseBinary}}
|
||||
Byte[] responseValue = localVarResponse.body().readAllBytes();
|
||||
{{/isResponseBinary}}{{/isResponseFile}}
|
||||
{{#isResponseFile}}
|
||||
// Handle file downloading.
|
||||
File responseValue = downloadFileFromResponse(localVarResponse);
|
||||
{{/isResponseFile}}
|
||||
{{^isResponseBinary}}{{^isResponseFile}}
|
||||
String responseBody = new String(localVarResponse.body().readAllBytes());
|
||||
{{{returnType}}} responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<{{{returnType}}}>() {});
|
||||
{{/isResponseFile}}{{/isResponseBinary}}
|
||||
localVarResponse.body().close();
|
||||
|
||||
return new ApiResponse<{{{returnType}}}>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<{{{returnType}}}>() {})
|
||||
responseValue
|
||||
);
|
||||
{{/returnType}}
|
||||
{{^returnType}}
|
||||
@@ -580,11 +639,11 @@ public class {{classname}} {
|
||||
|
||||
public static final class API{{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Request {
|
||||
{{#requiredParams}}
|
||||
{{>nullable_var_annotations}}
|
||||
{{>nullable_var_annotations}}{{! prevent indent}}
|
||||
private {{{dataType}}} {{paramName}}; // {{description}} (required)
|
||||
{{/requiredParams}}
|
||||
{{#optionalParams}}
|
||||
{{>nullable_var_annotations}}
|
||||
{{>nullable_var_annotations}}{{! prevent indent}}
|
||||
private {{{dataType}}} {{paramName}}; // {{description}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}})
|
||||
{{/optionalParams}}
|
||||
|
||||
@@ -597,7 +656,7 @@ public class {{classname}} {
|
||||
{{/optionalParams}}
|
||||
}
|
||||
{{#allParams}}
|
||||
{{>nullable_var_annotations}}
|
||||
{{>nullable_var_annotations}}{{! prevent indent}}
|
||||
public {{{dataType}}} {{paramName}}() {
|
||||
return {{paramName}};
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ package {{invokerPackage}};
|
||||
import java.net.http.HttpHeaders;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class ApiException extends{{#useRuntimeException}} RuntimeException {{/useRuntimeException}}{{^useRuntimeException}} Exception {{/useRuntimeException}}{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -2,17 +2,21 @@
|
||||
|
||||
{{#isEnum}}
|
||||
{{>enum_outer_doc}}
|
||||
|
||||
{{/isEnum}}
|
||||
{{^isEnum}}
|
||||
{{^oneOf.isEmpty}}
|
||||
{{>model_oneof_doc}}
|
||||
|
||||
{{/oneOf.isEmpty}}
|
||||
{{^anyOf.isEmpty}}
|
||||
{{>model_anyof_doc}}
|
||||
|
||||
{{/anyOf.isEmpty}}
|
||||
{{^anyOf}}
|
||||
{{^oneOf}}
|
||||
{{>pojo_doc}}
|
||||
|
||||
{{/oneOf}}
|
||||
{{/anyOf}}
|
||||
{{/isEnum}}
|
||||
|
||||
@@ -136,6 +136,7 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
|
||||
super("oneOf", {{#isNullable}}Boolean.TRUE{{/isNullable}}{{^isNullable}}Boolean.FALSE{{/isNullable}});
|
||||
}
|
||||
{{> libraries/native/additional_properties }}
|
||||
|
||||
{{#additionalPropertiesType}}
|
||||
/**
|
||||
* Return true if this {{name}} object is equal to o.
|
||||
|
||||
@@ -40,11 +40,13 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
{{^isContainer}}
|
||||
{{^vendorExtensions.x-enum-as-string}}
|
||||
{{>modelInnerEnum}}
|
||||
|
||||
{{/vendorExtensions.x-enum-as-string}}
|
||||
{{/isContainer}}
|
||||
{{#isContainer}}
|
||||
{{#mostInnerItems}}
|
||||
{{>modelInnerEnum}}
|
||||
|
||||
{{/mostInnerItems}}
|
||||
{{/isContainer}}
|
||||
{{/isEnum}}
|
||||
@@ -75,7 +77,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
{{/isContainer}}
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{^vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{>nullable_var_annotations}}
|
||||
{{>nullable_var_annotations}}{{! prevent indent}}
|
||||
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
|
||||
@@ -189,9 +191,10 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
{{#deprecated}}
|
||||
@Deprecated
|
||||
{{/deprecated}}
|
||||
{{>nullable_var_annotations}}
|
||||
{{>nullable_var_annotations}}{{! prevent indent}}
|
||||
{{#useBeanValidation}}
|
||||
{{>beanValidation}}
|
||||
|
||||
{{/useBeanValidation}}
|
||||
{{#swagger1AnnotationLibrary}}
|
||||
@ApiModelProperty({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
|
||||
@@ -222,6 +225,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
|
||||
{{#vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{> jackson_annotations}}
|
||||
|
||||
public JsonNullable<{{{datatypeWithEnum}}}> {{getter}}_JsonNullable() {
|
||||
return {{name}};
|
||||
}
|
||||
@@ -253,6 +257,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
|
||||
{{/vars}}
|
||||
{{>libraries/native/additional_properties}}
|
||||
|
||||
{{#parent}}
|
||||
{{#allVars}}
|
||||
{{#isOverridden}}
|
||||
@@ -573,6 +578,6 @@ static {
|
||||
{{/discriminator}}
|
||||
{{#generateBuilders}}
|
||||
|
||||
{{>javaBuilder}}
|
||||
{{>javaBuilder}}{{! prevent indent}}
|
||||
{{/generateBuilders}}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import java.util.Map;
|
||||
* Abstract class for oneOf,anyOf schemas defined in OpenAPI spec
|
||||
*/
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public abstract class AbstractOpenApiSchema {
|
||||
|
||||
// store the actual instance of the schema/object
|
||||
@@ -132,4 +133,5 @@ public abstract class AbstractOpenApiSchema {
|
||||
|
||||
{{>libraries/jersey2/additional_properties}}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -431,11 +431,11 @@ public class {{classname}} {
|
||||
|
||||
public class API{{operationId}}Request {
|
||||
{{#requiredParams}}
|
||||
{{>nullable_var_annotations}}
|
||||
{{>nullable_var_annotations}}{{! prevent indent}}
|
||||
private final {{{dataType}}} {{paramName}};
|
||||
{{/requiredParams}}
|
||||
{{#optionalParams}}
|
||||
{{>nullable_var_annotations}}
|
||||
{{>nullable_var_annotations}}{{! prevent indent}}
|
||||
private {{{dataType}}} {{paramName}};
|
||||
{{/optionalParams}}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.TreeMap;
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class ApiException extends{{#useRuntimeException}} RuntimeException {{/useRuntimeException}}{{^useRuntimeException}} Exception {{/useRuntimeException}}{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import software.amazon.awssdk.regions.Region;
|
||||
import okio.Buffer;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class AWS4Auth implements Authentication {
|
||||
|
||||
private AwsCredentials credentials;
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class ApiKeyAuth implements Authentication {
|
||||
private final String location;
|
||||
private final String paramName;
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public interface Authentication {
|
||||
/**
|
||||
* Apply authentication settings to header and query params.
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.util.Optional;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class HttpBearerAuth implements Authentication {
|
||||
private final String scheme;
|
||||
private Supplier<String> tokenSupplier;
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class OAuth implements Authentication {
|
||||
private String accessToken;
|
||||
|
||||
|
||||
@@ -49,10 +49,12 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
{{#isEnum}}
|
||||
{{^isContainer}}
|
||||
{{>modelInnerEnum}}
|
||||
|
||||
{{/isContainer}}
|
||||
{{#isContainer}}
|
||||
{{#mostInnerItems}}
|
||||
{{>modelInnerEnum}}
|
||||
|
||||
{{/mostInnerItems}}
|
||||
{{/isContainer}}
|
||||
{{/isEnum}}
|
||||
@@ -70,7 +72,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
{{#vendorExtensions.x-field-extra-annotation}}
|
||||
{{{vendorExtensions.x-field-extra-annotation}}}
|
||||
{{/vendorExtensions.x-field-extra-annotation}}
|
||||
{{>nullable_var_annotations}}
|
||||
{{>nullable_var_annotations}}{{! prevent indent}}
|
||||
{{#isDiscriminator}}protected{{/isDiscriminator}}{{^isDiscriminator}}private{{/isDiscriminator}} {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
|
||||
|
||||
{{/vars}}
|
||||
@@ -159,9 +161,10 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
{{#deprecated}}
|
||||
@Deprecated
|
||||
{{/deprecated}}
|
||||
{{>nullable_var_annotations}}
|
||||
{{>nullable_var_annotations}}{{! prevent indent}}
|
||||
{{#useBeanValidation}}
|
||||
{{>beanValidation}}
|
||||
|
||||
{{/useBeanValidation}}
|
||||
{{#swagger1AnnotationLibrary}}
|
||||
@ApiModelProperty({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
|
||||
@@ -187,6 +190,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
{{/vars}}
|
||||
{{>libraries/okhttp-gson/additional_properties}}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
{{#useReflectionEqualsHashCode}}
|
||||
|
||||
@@ -67,6 +67,7 @@ import {{invokerPackage}}.auth.OAuth;
|
||||
{{/hasOAuthMethods}}
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
{{#generateClientAsBean}}
|
||||
@Component("{{invokerPackage}}.ApiClient")
|
||||
{{/generateClientAsBean}}
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.springframework.web.client.RestClient.ResponseSpec;
|
||||
import org.springframework.web.client.RestClientResponseException;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
{{#generateClientAsBean}}
|
||||
@Component("{{package}}.{{classname}}")
|
||||
{{/generateClientAsBean}}
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class ApiKeyAuth implements Authentication {
|
||||
private final String location;
|
||||
private final String paramName;
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public interface Authentication {
|
||||
/**
|
||||
* Apply authentication settings to header and / or query parameters.
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class HttpBasicAuth implements Authentication {
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class HttpBearerAuth implements Authentication {
|
||||
private final String scheme;
|
||||
private Supplier<String> tokenSupplier;
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.springframework.util.MultiValueMap;
|
||||
* Provides support for RFC 6750 - Bearer Token usage for OAUTH 2.0 Authorization.
|
||||
*/
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class OAuth implements Authentication {
|
||||
private Supplier<String> tokenSupplier;
|
||||
|
||||
|
||||
@@ -38,10 +38,12 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
{{#isEnum}}
|
||||
{{^isContainer}}
|
||||
{{>modelInnerEnum}}
|
||||
|
||||
{{/isContainer}}
|
||||
{{#isContainer}}
|
||||
{{#mostInnerItems}}
|
||||
{{>modelInnerEnum}}
|
||||
|
||||
{{/mostInnerItems}}
|
||||
{{/isContainer}}
|
||||
{{/isEnum}}
|
||||
@@ -65,7 +67,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
{{#gson}}
|
||||
@SerializedName(SERIALIZED_NAME_{{nameInSnakeCase}})
|
||||
{{/gson}}
|
||||
{{>nullable_var_annotations}}
|
||||
{{>nullable_var_annotations}}{{! prevent indent}}
|
||||
{{#vendorExtensions.x-field-extra-annotation}}
|
||||
{{{vendorExtensions.x-field-extra-annotation}}}
|
||||
{{/vendorExtensions.x-field-extra-annotation}}
|
||||
@@ -211,12 +213,13 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
{{#deprecated}}
|
||||
@Deprecated
|
||||
{{/deprecated}}
|
||||
{{>nullable_var_annotations}}
|
||||
{{>nullable_var_annotations}}{{! prevent indent}}
|
||||
{{#jsonb}}
|
||||
@JsonbProperty("{{baseName}}")
|
||||
{{/jsonb}}
|
||||
{{#useBeanValidation}}
|
||||
{{>beanValidation}}
|
||||
|
||||
{{/useBeanValidation}}
|
||||
{{#swagger1AnnotationLibrary}}
|
||||
@ApiModelProperty({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
|
||||
@@ -248,6 +251,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
|
||||
{{#vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{> jackson_annotations}}
|
||||
|
||||
public JsonNullable<{{{datatypeWithEnum}}}> {{getter}}_JsonNullable() {
|
||||
return {{name}};
|
||||
}
|
||||
@@ -273,6 +277,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
|
||||
{{/vars}}
|
||||
{{>libraries/restclient/additional_properties}}
|
||||
|
||||
{{#parent}}
|
||||
{{#readWriteVars}}
|
||||
{{#isOverridden}}
|
||||
@@ -614,7 +619,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
{{/parcelableModel}}
|
||||
{{#generateBuilders}}
|
||||
|
||||
{{>javaBuilder}}
|
||||
{{>javaBuilder}}{{! prevent indent}}
|
||||
{{/generateBuilders}}
|
||||
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ import {{invokerPackage}}.auth.OAuth;
|
||||
{{/hasOAuthMethods}}
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
protected Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||
protected Map<String, String> defaultCookieMap = new HashMap<String, String>();
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.text.DateFormat;
|
||||
import {{javaxPackage}}.ws.rs.ext.ContextResolver;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class JSON implements ContextResolver<ObjectMapper> {
|
||||
private ObjectMapper mapper;
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
{{#operations}}
|
||||
public class {{classname}} {
|
||||
private ApiClient apiClient;
|
||||
|
||||
@@ -86,6 +86,7 @@ import {{invokerPackage}}.auth.OAuth;
|
||||
{{/hasOAuthMethods}}
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
{{#generateClientAsBean}}
|
||||
@Component("{{invokerPackage}}.ApiClient")
|
||||
{{/generateClientAsBean}}
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public abstract class BaseApi {
|
||||
|
||||
protected ApiClient apiClient;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user