forked from loafle/openapi-generator-original
Added a property to the Spring generator to avoid the use of the ResponseEntity
type (#11537)
* Added the useResponseEntity additional parameter for Spring generator * Changed the mustache templates using the new useResponseEntity property * Added the new property to the documentation * Merging with remote master * #11537 Added missing configuration for the delegate pattern case * #11537 Added autogenerated @ResponseStatus on Spring methods * #11537 Fixed borsch comments * #11537 Added the default 200 HTTP Status for empty response HTTP code * [Java][Spring] useResponseEntity sample + remove blank line * [Java][Spring] useResponseEntity sample + remove blank line * [Java][Spring] useResponseEntity sample + remove blank line --------- Co-authored-by: Oleh Kurpiak <oleh.kurpiak@gmail.com>
This commit is contained in:
parent
217d052bf7
commit
e626b43e27
1
.github/workflows/samples-spring.yaml
vendored
1
.github/workflows/samples-spring.yaml
vendored
@ -36,6 +36,7 @@ jobs:
|
|||||||
- samples/server/petstore/springboot-implicitHeaders
|
- samples/server/petstore/springboot-implicitHeaders
|
||||||
- samples/openapi3/server/petstore/springboot-implicitHeaders
|
- samples/openapi3/server/petstore/springboot-implicitHeaders
|
||||||
- samples/server/petstore/springboot-delegate
|
- samples/server/petstore/springboot-delegate
|
||||||
|
- samples/server/petstore/springboot-delegate-no-response-entity
|
||||||
- samples/openapi3/server/petstore/springboot-delegate
|
- samples/openapi3/server/petstore/springboot-delegate
|
||||||
- samples/server/petstore/spring-boot-nullable-set
|
- samples/server/petstore/spring-boot-nullable-set
|
||||||
- samples/server/petstore/spring-boot-defaultInterface-unhandledException
|
- samples/server/petstore/spring-boot-defaultInterface-unhandledException
|
||||||
|
11
bin/configs/spring-boot-delegate-no-response-entity.yaml
Normal file
11
bin/configs/spring-boot-delegate-no-response-entity.yaml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
generatorName: spring
|
||||||
|
outputDir: samples/server/petstore/springboot-delegate-no-response-entity
|
||||||
|
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||||
|
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||||
|
additionalProperties:
|
||||||
|
documentationProvider: springfox
|
||||||
|
artifactId: springboot-delegate-no-response-entity
|
||||||
|
hideGenerationTimestamp: "true"
|
||||||
|
java8: true
|
||||||
|
delegatePattern: "true"
|
||||||
|
useResponseEntity: "false"
|
@ -97,6 +97,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
|useFeignClientUrl|Whether to generate Feign client with url parameter.| |true|
|
|useFeignClientUrl|Whether to generate Feign client with url parameter.| |true|
|
||||||
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|
||||||
|useOptional|Use Optional container for optional parameters| |false|
|
|useOptional|Use Optional container for optional parameters| |false|
|
||||||
|
|useResponseEntity|Use the `ResponseEntity` type to wrap return values of generated API methods. If disabled, method are annotated using a `@ResponseStatus` annotation, which has the status of the first response declared in the Api definition| |true|
|
||||||
|useSpringBoot3|Generate code and provide dependencies for use with Spring Boot 3.x. (Use jakarta instead of javax in imports). Enabling this option will also enable `useJakartaEe`.| |false|
|
|useSpringBoot3|Generate code and provide dependencies for use with Spring Boot 3.x. (Use jakarta instead of javax in imports). Enabling this option will also enable `useJakartaEe`.| |false|
|
||||||
|useSpringController|Annotate the generated API as a Spring Controller| |false|
|
|useSpringController|Annotate the generated API as a Spring Controller| |false|
|
||||||
|useSwaggerUI|Open the OpenApi specification in swagger-ui. Will also import and configure needed dependencies| |true|
|
|useSwaggerUI|Open the OpenApi specification in swagger-ui. Will also import and configure needed dependencies| |true|
|
||||||
|
@ -90,6 +90,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
|useFeignClientUrl|Whether to generate Feign client with url parameter.| |true|
|
|useFeignClientUrl|Whether to generate Feign client with url parameter.| |true|
|
||||||
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|
||||||
|useOptional|Use Optional container for optional parameters| |false|
|
|useOptional|Use Optional container for optional parameters| |false|
|
||||||
|
|useResponseEntity|Use the `ResponseEntity` type to wrap return values of generated API methods. If disabled, method are annotated using a `@ResponseStatus` annotation, which has the status of the first response declared in the Api definition| |true|
|
||||||
|useSpringBoot3|Generate code and provide dependencies for use with Spring Boot 3.x. (Use jakarta instead of javax in imports). Enabling this option will also enable `useJakartaEe`.| |false|
|
|useSpringBoot3|Generate code and provide dependencies for use with Spring Boot 3.x. (Use jakarta instead of javax in imports). Enabling this option will also enable `useJakartaEe`.| |false|
|
||||||
|useSpringController|Annotate the generated API as a Spring Controller| |false|
|
|useSpringController|Annotate the generated API as a Spring Controller| |false|
|
||||||
|useSwaggerUI|Open the OpenApi specification in swagger-ui. Will also import and configure needed dependencies| |true|
|
|useSwaggerUI|Open the OpenApi specification in swagger-ui. Will also import and configure needed dependencies| |true|
|
||||||
|
@ -65,6 +65,7 @@ import org.openapitools.codegen.model.ModelsMap;
|
|||||||
import org.openapitools.codegen.model.OperationMap;
|
import org.openapitools.codegen.model.OperationMap;
|
||||||
import org.openapitools.codegen.model.OperationsMap;
|
import org.openapitools.codegen.model.OperationsMap;
|
||||||
import org.openapitools.codegen.templating.mustache.SplitStringLambda;
|
import org.openapitools.codegen.templating.mustache.SplitStringLambda;
|
||||||
|
import org.openapitools.codegen.templating.mustache.SpringHttpStatusLambda;
|
||||||
import org.openapitools.codegen.templating.mustache.TrimWhitespaceLambda;
|
import org.openapitools.codegen.templating.mustache.TrimWhitespaceLambda;
|
||||||
import org.openapitools.codegen.utils.URLPathUtils;
|
import org.openapitools.codegen.utils.URLPathUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -110,6 +111,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
public static final String HATEOAS = "hateoas";
|
public static final String HATEOAS = "hateoas";
|
||||||
public static final String RETURN_SUCCESS_CODE = "returnSuccessCode";
|
public static final String RETURN_SUCCESS_CODE = "returnSuccessCode";
|
||||||
public static final String UNHANDLED_EXCEPTION_HANDLING = "unhandledException";
|
public static final String UNHANDLED_EXCEPTION_HANDLING = "unhandledException";
|
||||||
|
public static final String USE_RESPONSE_ENTITY = "useResponseEntity";
|
||||||
public static final String USE_SPRING_BOOT3 = "useSpringBoot3";
|
public static final String USE_SPRING_BOOT3 = "useSpringBoot3";
|
||||||
public static final String REQUEST_MAPPING_OPTION = "requestMappingMode";
|
public static final String REQUEST_MAPPING_OPTION = "requestMappingMode";
|
||||||
public static final String USE_REQUEST_MAPPING_ON_CONTROLLER = "useRequestMappingOnController";
|
public static final String USE_REQUEST_MAPPING_ON_CONTROLLER = "useRequestMappingOnController";
|
||||||
@ -157,6 +159,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
protected boolean unhandledException = false;
|
protected boolean unhandledException = false;
|
||||||
protected boolean useSpringController = false;
|
protected boolean useSpringController = false;
|
||||||
protected boolean useSwaggerUI = true;
|
protected boolean useSwaggerUI = true;
|
||||||
|
protected boolean useResponseEntity = true;
|
||||||
protected boolean useSpringBoot3 = false;
|
protected boolean useSpringBoot3 = false;
|
||||||
protected boolean generatedConstructorWithRequiredArgs = true;
|
protected boolean generatedConstructorWithRequiredArgs = true;
|
||||||
protected RequestMappingMode requestMappingMode = RequestMappingMode.controller;
|
protected RequestMappingMode requestMappingMode = RequestMappingMode.controller;
|
||||||
@ -247,6 +250,10 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
cliOptions.add(CliOption.newBoolean(USE_SWAGGER_UI,
|
cliOptions.add(CliOption.newBoolean(USE_SWAGGER_UI,
|
||||||
"Open the OpenApi specification in swagger-ui. Will also import and configure needed dependencies",
|
"Open the OpenApi specification in swagger-ui. Will also import and configure needed dependencies",
|
||||||
useSwaggerUI));
|
useSwaggerUI));
|
||||||
|
cliOptions.add(CliOption.newBoolean(USE_RESPONSE_ENTITY,
|
||||||
|
"Use the `ResponseEntity` type to wrap return values of generated API methods. "
|
||||||
|
+ "If disabled, method are annotated using a `@ResponseStatus` annotation, which has the status of the first response declared in the Api definition",
|
||||||
|
useResponseEntity));
|
||||||
cliOptions.add(CliOption.newBoolean(USE_SPRING_BOOT3,
|
cliOptions.add(CliOption.newBoolean(USE_SPRING_BOOT3,
|
||||||
"Generate code and provide dependencies for use with Spring Boot 3.x. (Use jakarta instead of javax in imports). Enabling this option will also enable `useJakartaEe`.",
|
"Generate code and provide dependencies for use with Spring Boot 3.x. (Use jakarta instead of javax in imports). Enabling this option will also enable `useJakartaEe`.",
|
||||||
useSpringBoot3));
|
useSpringBoot3));
|
||||||
@ -487,6 +494,13 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
}
|
}
|
||||||
additionalProperties.put(UNHANDLED_EXCEPTION_HANDLING, this.isUnhandledException());
|
additionalProperties.put(UNHANDLED_EXCEPTION_HANDLING, this.isUnhandledException());
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(USE_RESPONSE_ENTITY)) {
|
||||||
|
this.setUseResponseEntity(
|
||||||
|
Boolean.parseBoolean(additionalProperties.get(USE_RESPONSE_ENTITY).toString()));
|
||||||
|
}
|
||||||
|
writePropertyBack(USE_RESPONSE_ENTITY, useResponseEntity);
|
||||||
|
additionalProperties.put("springHttpStatus", new SpringHttpStatusLambda());
|
||||||
|
|
||||||
if (additionalProperties.containsKey(USE_SPRING_BOOT3)) {
|
if (additionalProperties.containsKey(USE_SPRING_BOOT3)) {
|
||||||
this.setUseSpringBoot3(convertPropertyToBoolean(USE_SPRING_BOOT3));
|
this.setUseSpringBoot3(convertPropertyToBoolean(USE_SPRING_BOOT3));
|
||||||
}
|
}
|
||||||
@ -503,6 +517,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
}
|
}
|
||||||
writePropertyBack(USE_SPRING_BOOT3, isUseSpringBoot3());
|
writePropertyBack(USE_SPRING_BOOT3, isUseSpringBoot3());
|
||||||
|
|
||||||
|
|
||||||
typeMapping.put("file", "org.springframework.core.io.Resource");
|
typeMapping.put("file", "org.springframework.core.io.Resource");
|
||||||
importMapping.put("org.springframework.core.io.Resource", "org.springframework.core.io.Resource");
|
importMapping.put("org.springframework.core.io.Resource", "org.springframework.core.io.Resource");
|
||||||
importMapping.put("Pageable", "org.springframework.data.domain.Pageable");
|
importMapping.put("Pageable", "org.springframework.data.domain.Pageable");
|
||||||
@ -1028,6 +1043,10 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
this.unhandledException = unhandledException;
|
this.unhandledException = unhandledException;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUseResponseEntity(boolean useResponseEntity) {
|
||||||
|
this.useResponseEntity = useResponseEntity;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
|
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
|
||||||
super.postProcessModelProperty(model, property);
|
super.postProcessModelProperty(model, property);
|
||||||
|
@ -0,0 +1,220 @@
|
|||||||
|
package org.openapitools.codegen.templating.mustache;
|
||||||
|
|
||||||
|
import com.samskivert.mustache.Mustache;
|
||||||
|
import com.samskivert.mustache.Template;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.Writer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Spring {@code org.springframework.http.HttpStatus} enumeration for the given status text.
|
||||||
|
* It throws an IllegalArgumentException if the status text is handled by the Spring framework.
|
||||||
|
*
|
||||||
|
* Register:
|
||||||
|
* <pre>
|
||||||
|
* additionalProperties.put("springHttpStatus", new SpringHttpStatusLambda());
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* Use:
|
||||||
|
* <pre>
|
||||||
|
* {{#springHttpStatus}}{{statusCode}}{{/springHttpStatus}}
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
public class SpringHttpStatusLambda implements Mustache.Lambda {
|
||||||
|
|
||||||
|
final static String HTTP_STATUS_PREFIX = "HttpStatus.";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(Template.Fragment fragment, Writer writer) throws IOException {
|
||||||
|
final String httpCode = fragment.execute();
|
||||||
|
switch (httpCode) {
|
||||||
|
case "202":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "ACCEPTED");
|
||||||
|
break;
|
||||||
|
case "208":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "ALREADY_REPORTED");
|
||||||
|
break;
|
||||||
|
case "502":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "BAD_GATEWAY");
|
||||||
|
break;
|
||||||
|
case "400":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "BAD_REQUEST");
|
||||||
|
break;
|
||||||
|
case "509":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "BANDWIDTH_LIMIT_EXCEEDED");
|
||||||
|
break;
|
||||||
|
case "409":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "CONFLICT");
|
||||||
|
break;
|
||||||
|
case "100":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "CONTINUE");
|
||||||
|
break;
|
||||||
|
case "201":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "CREATED");
|
||||||
|
break;
|
||||||
|
case "103":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "EARLY_HINTS");
|
||||||
|
break;
|
||||||
|
case "417":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "EXPECTATION_FAILED");
|
||||||
|
break;
|
||||||
|
case "424":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "FAILED_DEPENDENCY");
|
||||||
|
break;
|
||||||
|
case "403":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "FORBIDDEN");
|
||||||
|
break;
|
||||||
|
case "302":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "FOUND");
|
||||||
|
break;
|
||||||
|
case "504":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "GATEWAY_TIMEOUT");
|
||||||
|
break;
|
||||||
|
case "410":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "GONE");
|
||||||
|
break;
|
||||||
|
case "505":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "HTTP_VERSION_NOT_SUPPORTED");
|
||||||
|
break;
|
||||||
|
case "418":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "I_AM_A_TEAPOT");
|
||||||
|
break;
|
||||||
|
case "226":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "IM_USED");
|
||||||
|
break;
|
||||||
|
case "507":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "INSUFFICIENT_STORAGE");
|
||||||
|
break;
|
||||||
|
case "500":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "INTERNAL_SERVER_ERROR");
|
||||||
|
break;
|
||||||
|
case "411":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "LENGTH_REQUIRED");
|
||||||
|
break;
|
||||||
|
case "423":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "LOCKED");
|
||||||
|
break;
|
||||||
|
case "508":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "LOOP_DETECTED");
|
||||||
|
break;
|
||||||
|
case "405":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "METHOD_NOT_ALLOWED");
|
||||||
|
break;
|
||||||
|
case "301":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "MOVED_PERMANENTLY");
|
||||||
|
break;
|
||||||
|
case "207":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "MULTI_STATUS");
|
||||||
|
break;
|
||||||
|
case "300":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "MULTIPLE_CHOICES");
|
||||||
|
break;
|
||||||
|
case "511":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "NETWORK_AUTHENTICATION_REQUIRED");
|
||||||
|
break;
|
||||||
|
case "204":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "NO_CONTENT");
|
||||||
|
break;
|
||||||
|
case "203":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "NON_AUTHORITATIVE_INFORMATION");
|
||||||
|
break;
|
||||||
|
case "406":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "NOT_ACCEPTABLE");
|
||||||
|
break;
|
||||||
|
case "510":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "NOT_EXTENDED");
|
||||||
|
break;
|
||||||
|
case "404":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "NOT_FOUND");
|
||||||
|
break;
|
||||||
|
case "501":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "NOT_IMPLEMENTED");
|
||||||
|
break;
|
||||||
|
case "304":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "NOT_MODIFIED");
|
||||||
|
break;
|
||||||
|
case "":
|
||||||
|
case "200":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "OK");
|
||||||
|
break;
|
||||||
|
case "206":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "PARTIAL_CONTENT");
|
||||||
|
break;
|
||||||
|
case "413":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "PAYLOAD_TOO_LARGE");
|
||||||
|
break;
|
||||||
|
case "402":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "PAYMENT_REQUIRED");
|
||||||
|
break;
|
||||||
|
case "308":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "PERMANENT_REDIRECT");
|
||||||
|
break;
|
||||||
|
case "412":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "PRECONDITION_FAILED");
|
||||||
|
break;
|
||||||
|
case "428":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "PRECONDITION_REQUIRED");
|
||||||
|
break;
|
||||||
|
case "102":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "PROCESSING");
|
||||||
|
break;
|
||||||
|
case "407":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "PROXY_AUTHENTICATION_REQUIRED");
|
||||||
|
break;
|
||||||
|
case "431":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "REQUEST_HEADER_FIELDS_TOO_LARGE");
|
||||||
|
break;
|
||||||
|
case "408":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "REQUEST_TIMEOUT");
|
||||||
|
break;
|
||||||
|
case "416":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "REQUESTED_RANGE_NOT_SATISFIABLE");
|
||||||
|
break;
|
||||||
|
case "205":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "RESET_CONTENT");
|
||||||
|
break;
|
||||||
|
case "303":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "SEE_OTHER");
|
||||||
|
break;
|
||||||
|
case "503":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "SERVICE_UNAVAILABLE");
|
||||||
|
break;
|
||||||
|
case "101":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "SWITCHING_PROTOCOLS");
|
||||||
|
break;
|
||||||
|
case "307":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "TEMPORARY_REDIRECT");
|
||||||
|
break;
|
||||||
|
case "425":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "TOO_EARLY");
|
||||||
|
break;
|
||||||
|
case "429":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "TOO_MANY_REQUESTS");
|
||||||
|
break;
|
||||||
|
case "401":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "UNAUTHORIZED");
|
||||||
|
break;
|
||||||
|
case "451":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "UNAVAILABLE_FOR_LEGAL_REASONS");
|
||||||
|
break;
|
||||||
|
case "422":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "UNPROCESSABLE_ENTITY");
|
||||||
|
break;
|
||||||
|
case "415":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "UNSUPPORTED_MEDIA_TYPE");
|
||||||
|
break;
|
||||||
|
case "426":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "UPGRADE_REQUIRED");
|
||||||
|
break;
|
||||||
|
case "414":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "URI_TOO_LONG");
|
||||||
|
break;
|
||||||
|
case "506":
|
||||||
|
writer.write(HTTP_STATUS_PREFIX + "VARIANT_ALSO_NEGOTIATES");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("The given HTTP status code: " + httpCode
|
||||||
|
+ " is not supported by the 'org.springframework.http.HttpStatus' enum.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -31,7 +31,12 @@ import io.virtualan.annotation.VirtualService;
|
|||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
{{/jdk8-no-delegate}}
|
{{/jdk8-no-delegate}}
|
||||||
|
{{^useResponseEntity}}
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
{{/useResponseEntity}}
|
||||||
|
{{#useResponseEntity}}
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
{{/useResponseEntity}}
|
||||||
{{#useBeanValidation}}
|
{{#useBeanValidation}}
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
{{/useBeanValidation}}
|
{{/useBeanValidation}}
|
||||||
@ -222,7 +227,10 @@ public interface {{classname}} {
|
|||||||
headers = { {{#vendorExtensions.versionHeaderParamsList}}"{{baseName}}{{#defaultValue}}={{{.}}}{{/defaultValue}}"{{^-last}}, {{/-last}}{{/vendorExtensions.versionHeaderParamsList}} } {{/hasVersionHeaders}}{{#hasVersionQueryParams}},
|
headers = { {{#vendorExtensions.versionHeaderParamsList}}"{{baseName}}{{#defaultValue}}={{{.}}}{{/defaultValue}}"{{^-last}}, {{/-last}}{{/vendorExtensions.versionHeaderParamsList}} } {{/hasVersionHeaders}}{{#hasVersionQueryParams}},
|
||||||
params = { {{#vendorExtensions.versionQueryParamsList}}"{{baseName}}{{#defaultValue}}={{{.}}}{{/defaultValue}}"{{^-last}}, {{/-last}}{{/vendorExtensions.versionQueryParamsList}} } {{/hasVersionQueryParams}}
|
params = { {{#vendorExtensions.versionQueryParamsList}}"{{baseName}}{{#defaultValue}}={{{.}}}{{/defaultValue}}"{{^-last}}, {{/-last}}{{/vendorExtensions.versionQueryParamsList}} } {{/hasVersionQueryParams}}
|
||||||
)
|
)
|
||||||
{{#jdk8-default-interface}}default {{/jdk8-default-interface}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{#delegate-method}}_{{/delegate-method}}{{operationId}}(
|
{{^useResponseEntity}}
|
||||||
|
@ResponseStatus({{#springHttpStatus}}{{#responses.0}}{{{code}}}{{/responses.0}}{{/springHttpStatus}})
|
||||||
|
{{/useResponseEntity}}
|
||||||
|
{{#jdk8-default-interface}}default {{/jdk8-default-interface}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}{{#useResponseEntity}}ResponseEntity<{{/useResponseEntity}}{{>returnTypes}}{{#useResponseEntity}}>{{/useResponseEntity}}{{#responseWrapper}}>{{/responseWrapper}} {{#delegate-method}}_{{/delegate-method}}{{operationId}}(
|
||||||
{{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{>cookieParams}}{{^-last}},
|
{{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{>cookieParams}}{{^-last}},
|
||||||
{{/-last}}{{/allParams}}{{#reactive}}{{#hasParams}},
|
{{/-last}}{{/allParams}}{{#reactive}}{{#hasParams}},
|
||||||
{{/hasParams}}{{#swagger2AnnotationLibrary}}@Parameter(hidden = true){{/swagger2AnnotationLibrary}}{{#springFoxDocumentationProvider}}@ApiIgnore{{/springFoxDocumentationProvider}} final ServerWebExchange exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}{{#hasParams}},
|
{{/hasParams}}{{#swagger2AnnotationLibrary}}@Parameter(hidden = true){{/swagger2AnnotationLibrary}}{{#springFoxDocumentationProvider}}@ApiIgnore{{/springFoxDocumentationProvider}} final ServerWebExchange exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}{{#hasParams}},
|
||||||
@ -233,7 +241,7 @@ public interface {{classname}} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Override this method
|
// Override this method
|
||||||
{{#jdk8-default-interface}}default {{/jdk8-default-interface}} {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{^isFile}}{{^isBodyParam}}{{>optionalDataType}}{{/isBodyParam}}{{#isBodyParam}}{{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isArray}}Mono<{{{dataType}}}>{{/isArray}}{{#isArray}}Flux<{{{baseType}}}>{{/isArray}}{{/reactive}}{{/isBodyParam}}{{/isFile}}{{#isFile}}{{#reactive}}Flux<Part>{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{/isFile}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#reactive}}{{#hasParams}}, {{/hasParams}}{{#springFoxDocumentationProvider}}@ApiIgnore{{/springFoxDocumentationProvider}} final ServerWebExchange exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}, {{#springFoxDocumentationProvider}}@ApiIgnore{{/springFoxDocumentationProvider}} final Pageable pageable{{/vendorExtensions.x-spring-paginated}}){{#unhandledException}} throws Exception{{/unhandledException}} {
|
{{#jdk8-default-interface}}default {{/jdk8-default-interface}} {{#responseWrapper}}{{.}}<{{/responseWrapper}}{{#useResponseEntity}}ResponseEntity<{{/useResponseEntity}}{{>returnTypes}}{{#useResponseEntity}}>{{/useResponseEntity}}{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{^isFile}}{{^isBodyParam}}{{>optionalDataType}}{{/isBodyParam}}{{#isBodyParam}}{{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isArray}}Mono<{{{dataType}}}>{{/isArray}}{{#isArray}}Flux<{{{baseType}}}>{{/isArray}}{{/reactive}}{{/isBodyParam}}{{/isFile}}{{#isFile}}{{#reactive}}Flux<Part>{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{/isFile}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#reactive}}{{#hasParams}}, {{/hasParams}}{{#springFoxDocumentationProvider}}@ApiIgnore{{/springFoxDocumentationProvider}} final ServerWebExchange exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}, {{#springFoxDocumentationProvider}}@ApiIgnore{{/springFoxDocumentationProvider}} final Pageable pageable{{/vendorExtensions.x-spring-paginated}}){{#unhandledException}} throws Exception{{/unhandledException}} {
|
||||||
{{/delegate-method}}
|
{{/delegate-method}}
|
||||||
{{^isDelegate}}
|
{{^isDelegate}}
|
||||||
{{>methodBody}}
|
{{>methodBody}}
|
||||||
|
@ -21,7 +21,9 @@ import io.swagger.annotations.*;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
{{#useResponseEntity}}
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
{{/useResponseEntity}}
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
@ -109,7 +111,7 @@ public class {{classname}}Controller implements {{classname}} {
|
|||||||
{{#isDeprecated}}
|
{{#isDeprecated}}
|
||||||
@Deprecated
|
@Deprecated
|
||||||
{{/isDeprecated}}
|
{{/isDeprecated}}
|
||||||
public {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}(
|
public {{#responseWrapper}}{{.}}<{{/responseWrapper}}{{#useResponseEntity}}ResponseEntity<{{/useResponseEntity}}{{>returnTypes}}{{#useResponseEntity}}>{{/useResponseEntity}}{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}(
|
||||||
{{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{>cookieParams}}{{^-last}},
|
{{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{>cookieParams}}{{^-last}},
|
||||||
{{/-last}}{{/allParams}}{{#vendorExtensions.x-spring-paginated}}{{#hasParams}},
|
{{/-last}}{{/allParams}}{{#vendorExtensions.x-spring-paginated}}{{#hasParams}},
|
||||||
{{/hasParams}}{{#springFoxDocumentationProvider}}@ApiIgnore {{/springFoxDocumentationProvider}}final Pageable pageable{{/vendorExtensions.x-spring-paginated}}
|
{{/hasParams}}{{#springFoxDocumentationProvider}}@ApiIgnore {{/springFoxDocumentationProvider}}final Pageable pageable{{/vendorExtensions.x-spring-paginated}}
|
||||||
@ -119,9 +121,9 @@ public class {{classname}}Controller implements {{classname}} {
|
|||||||
{{>methodBody}}
|
{{>methodBody}}
|
||||||
{{/async}}
|
{{/async}}
|
||||||
{{#async}}
|
{{#async}}
|
||||||
return new Callable<ResponseEntity<{{>returnTypes}}>>() {
|
return new Callable<{{#useResponseEntity}}ResponseEntity<{{/useResponseEntity}}{{>returnTypes}}{{#useResponseEntity}}>{{/useResponseEntity}}>() {
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<{{>returnTypes}}> call() {
|
public {{#useResponseEntity}}ResponseEntity<{{/useResponseEntity}}{{>returnTypes}}{{#useResponseEntity}}>{{/useResponseEntity}} call() {
|
||||||
{{>methodBody}}
|
{{>methodBody}}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -4,7 +4,9 @@ package {{package}};
|
|||||||
{{/imports}}
|
{{/imports}}
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
{{#useResponseEntity}}
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
{{/useResponseEntity}}
|
||||||
import org.springframework.web.context.request.NativeWebRequest;
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
{{#reactive}}
|
{{#reactive}}
|
||||||
@ -60,7 +62,7 @@ public interface {{classname}}Delegate {
|
|||||||
{{#isDeprecated}}
|
{{#isDeprecated}}
|
||||||
@Deprecated
|
@Deprecated
|
||||||
{{/isDeprecated}}
|
{{/isDeprecated}}
|
||||||
{{#jdk8-default-interface}}default {{/jdk8-default-interface}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{^isFile}}{{^isBodyParam}}{{>optionalDataType}}{{/isBodyParam}}{{#isBodyParam}}{{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isArray}}Mono<{{{dataType}}}>{{/isArray}}{{#isArray}}Flux<{{{baseType}}}>{{/isArray}}{{/reactive}}{{/isBodyParam}}{{/isFile}}{{#isFile}}{{#isArray}}List<{{/isArray}}{{#reactive}}Flux<Part>{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{#isArray}}>{{/isArray}}{{/isFile}} {{paramName}}{{^-last}},
|
{{#jdk8-default-interface}}default {{/jdk8-default-interface}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}{{#useResponseEntity}}ResponseEntity<{{/useResponseEntity}}{{>returnTypes}}{{#useResponseEntity}}>{{/useResponseEntity}}{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{^isFile}}{{^isBodyParam}}{{>optionalDataType}}{{/isBodyParam}}{{#isBodyParam}}{{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isArray}}Mono<{{{dataType}}}>{{/isArray}}{{#isArray}}Flux<{{{baseType}}}>{{/isArray}}{{/reactive}}{{/isBodyParam}}{{/isFile}}{{#isFile}}{{#isArray}}List<{{/isArray}}{{#reactive}}Flux<Part>{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{#isArray}}>{{/isArray}}{{/isFile}} {{paramName}}{{^-last}},
|
||||||
{{/-last}}{{/allParams}}{{#reactive}}{{#hasParams}},
|
{{/-last}}{{/allParams}}{{#reactive}}{{#hasParams}},
|
||||||
{{/hasParams}}ServerWebExchange exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}, final Pageable pageable{{/vendorExtensions.x-spring-paginated}}){{#unhandledException}} throws Exception{{/unhandledException}}{{^jdk8-default-interface}};{{/jdk8-default-interface}}{{#jdk8-default-interface}} {
|
{{/hasParams}}ServerWebExchange exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}, final Pageable pageable{{/vendorExtensions.x-spring-paginated}}){{#unhandledException}} throws Exception{{/unhandledException}}{{^jdk8-default-interface}};{{/jdk8-default-interface}}{{#jdk8-default-interface}} {
|
||||||
{{>methodBody}}
|
{{>methodBody}}
|
||||||
|
@ -14,14 +14,20 @@ return CompletableFuture.supplyAsync(()-> {
|
|||||||
{{#-last}}
|
{{#-last}}
|
||||||
{{#async}} {{/async}}{{^async}} {{/async}} }
|
{{#async}} {{/async}}{{^async}} {{/async}} }
|
||||||
{{#async}} {{/async}} });
|
{{#async}} {{/async}} });
|
||||||
{{#async}} {{/async}} return new ResponseEntity<>({{#returnSuccessCode}}HttpStatus.valueOf({{{statusCode}}}){{/returnSuccessCode}}{{^returnSuccessCode}}HttpStatus.NOT_IMPLEMENTED{{/returnSuccessCode}});
|
{{#async}} {{/async}} {{#useResponseEntity}}return new ResponseEntity<>({{#returnSuccessCode}}HttpStatus.valueOf({{{statusCode}}}){{/returnSuccessCode}}{{^returnSuccessCode}}HttpStatus.NOT_IMPLEMENTED{{/returnSuccessCode}});
|
||||||
|
{{/useResponseEntity}}
|
||||||
|
{{^useResponseEntity}}throw new IllegalArgumentException("Not implemented");
|
||||||
|
{{/useResponseEntity}}
|
||||||
{{#async}}
|
{{#async}}
|
||||||
}, Runnable::run);
|
}, Runnable::run);
|
||||||
{{/async}}
|
{{/async}}
|
||||||
{{/-last}}
|
{{/-last}}
|
||||||
{{/examples}}
|
{{/examples}}
|
||||||
{{^examples}}
|
{{^examples}}
|
||||||
return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>({{#returnSuccessCode}}HttpStatus.OK{{/returnSuccessCode}}{{^returnSuccessCode}}HttpStatus.NOT_IMPLEMENTED{{/returnSuccessCode}}){{#async}}){{/async}};
|
{{#useResponseEntity}}return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>({{#returnSuccessCode}}HttpStatus.OK{{/returnSuccessCode}}{{^returnSuccessCode}}HttpStatus.NOT_IMPLEMENTED{{/returnSuccessCode}}){{#async}}){{/async}};
|
||||||
|
{{/useResponseEntity}}
|
||||||
|
{{^useResponseEntity}}throw new IllegalArgumentException("Not implemented");
|
||||||
|
{{/useResponseEntity}}
|
||||||
{{/examples}}
|
{{/examples}}
|
||||||
{{/reactive}}
|
{{/reactive}}
|
||||||
{{#reactive}}
|
{{#reactive}}
|
||||||
|
@ -17,16 +17,7 @@
|
|||||||
|
|
||||||
package org.openapitools.codegen.java.spring;
|
package org.openapitools.codegen.java.spring;
|
||||||
|
|
||||||
import static java.util.stream.Collectors.groupingBy;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
|
||||||
import static org.openapitools.codegen.TestUtils.assertFileContains;
|
|
||||||
import static org.openapitools.codegen.TestUtils.assertFileNotContains;
|
|
||||||
import static org.openapitools.codegen.languages.SpringCodegen.*;
|
|
||||||
import static org.openapitools.codegen.languages.features.DocumentationProviderFeatures.ANNOTATION_LIBRARY;
|
|
||||||
import static org.openapitools.codegen.languages.features.DocumentationProviderFeatures.DOCUMENTATION_PROVIDER;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
import static org.testng.Assert.fail;
|
|
||||||
|
|
||||||
import io.swagger.parser.OpenAPIParser;
|
import io.swagger.parser.OpenAPIParser;
|
||||||
import io.swagger.v3.oas.models.OpenAPI;
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
import io.swagger.v3.oas.models.Operation;
|
import io.swagger.v3.oas.models.Operation;
|
||||||
@ -34,28 +25,9 @@ import io.swagger.v3.oas.models.info.Info;
|
|||||||
import io.swagger.v3.oas.models.media.Schema;
|
import io.swagger.v3.oas.models.media.Schema;
|
||||||
import io.swagger.v3.oas.models.servers.Server;
|
import io.swagger.v3.oas.models.servers.Server;
|
||||||
import io.swagger.v3.parser.core.models.ParseOptions;
|
import io.swagger.v3.parser.core.models.ParseOptions;
|
||||||
|
import org.openapitools.codegen.*;
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.openapitools.codegen.config.GlobalSettings;
|
import org.openapitools.codegen.config.GlobalSettings;
|
||||||
import org.openapitools.codegen.java.assertions.JavaFileAssert;
|
import org.openapitools.codegen.java.assertions.JavaFileAssert;
|
||||||
import org.openapitools.codegen.CliOption;
|
|
||||||
import org.openapitools.codegen.ClientOptInput;
|
|
||||||
import org.openapitools.codegen.CodegenConstants;
|
|
||||||
import org.openapitools.codegen.CodegenModel;
|
|
||||||
import org.openapitools.codegen.CodegenOperation;
|
|
||||||
import org.openapitools.codegen.CodegenParameter;
|
|
||||||
import org.openapitools.codegen.CodegenProperty;
|
|
||||||
import org.openapitools.codegen.DefaultGenerator;
|
|
||||||
import org.openapitools.codegen.SupportingFile;
|
|
||||||
import org.openapitools.codegen.TestUtils;
|
|
||||||
import org.openapitools.codegen.languages.AbstractJavaCodegen;
|
import org.openapitools.codegen.languages.AbstractJavaCodegen;
|
||||||
import org.openapitools.codegen.languages.SpringCodegen;
|
import org.openapitools.codegen.languages.SpringCodegen;
|
||||||
import org.openapitools.codegen.languages.features.BeanValidationFeatures;
|
import org.openapitools.codegen.languages.features.BeanValidationFeatures;
|
||||||
@ -66,7 +38,26 @@ import org.testng.annotations.DataProvider;
|
|||||||
import org.testng.annotations.Ignore;
|
import org.testng.annotations.Ignore;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static java.util.stream.Collectors.groupingBy;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.openapitools.codegen.TestUtils.assertFileContains;
|
||||||
|
import static org.openapitools.codegen.TestUtils.assertFileNotContains;
|
||||||
|
import static org.openapitools.codegen.languages.SpringCodegen.*;
|
||||||
|
import static org.openapitools.codegen.languages.features.DocumentationProviderFeatures.ANNOTATION_LIBRARY;
|
||||||
|
import static org.openapitools.codegen.languages.features.DocumentationProviderFeatures.DOCUMENTATION_PROVIDER;
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
import static org.testng.Assert.fail;
|
||||||
|
|
||||||
public class SpringCodegenTest {
|
public class SpringCodegenTest {
|
||||||
|
|
||||||
@ -552,6 +543,7 @@ public class SpringCodegenTest {
|
|||||||
Assert.assertEquals(codegen.additionalProperties().get(SpringCodegen.CONFIG_PACKAGE), "org.openapitools.configuration");
|
Assert.assertEquals(codegen.additionalProperties().get(SpringCodegen.CONFIG_PACKAGE), "org.openapitools.configuration");
|
||||||
Assert.assertEquals(codegen.additionalProperties().get(SpringCodegen.SERVER_PORT), "8082");
|
Assert.assertEquals(codegen.additionalProperties().get(SpringCodegen.SERVER_PORT), "8082");
|
||||||
Assert.assertEquals(codegen.additionalProperties().get(SpringCodegen.UNHANDLED_EXCEPTION_HANDLING), false);
|
Assert.assertEquals(codegen.additionalProperties().get(SpringCodegen.UNHANDLED_EXCEPTION_HANDLING), false);
|
||||||
|
Assert.assertEquals(codegen.additionalProperties().get(SpringCodegen.USE_RESPONSE_ENTITY), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -1213,7 +1205,7 @@ public class SpringCodegenTest {
|
|||||||
codegen.setHateoas(true);
|
codegen.setHateoas(true);
|
||||||
generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true");
|
generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true");
|
||||||
generator.setGeneratorPropertyDefault(CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR, "false");
|
generator.setGeneratorPropertyDefault(CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR, "false");
|
||||||
|
|
||||||
|
|
||||||
codegen.setUseOneOfInterfaces(true);
|
codegen.setUseOneOfInterfaces(true);
|
||||||
codegen.setLegacyDiscriminatorBehavior(false);
|
codegen.setLegacyDiscriminatorBehavior(false);
|
||||||
@ -1574,6 +1566,75 @@ public class SpringCodegenTest {
|
|||||||
.assertMethod("getWithMapOfStrings").hasReturnType("ResponseEntity<Map<String, String>>");
|
.assertMethod("getWithMapOfStrings").hasReturnType("ResponseEntity<Map<String, String>>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldGenerateMethodsWithoutUsingResponseEntityAndWithoutDelegation_issue11537() throws IOException {
|
||||||
|
Map<String, Object> additionalProperties = new HashMap<>();
|
||||||
|
additionalProperties.put(AbstractJavaCodegen.FULL_JAVA_UTIL, "true");
|
||||||
|
additionalProperties.put(SpringCodegen.USE_TAGS, "true");
|
||||||
|
additionalProperties.put(SpringCodegen.INTERFACE_ONLY, "true");
|
||||||
|
additionalProperties.put(SpringCodegen.SKIP_DEFAULT_INTERFACE, "true");
|
||||||
|
additionalProperties.put(SpringCodegen.PERFORM_BEANVALIDATION, "true");
|
||||||
|
additionalProperties.put(SpringCodegen.SPRING_CONTROLLER, "true");
|
||||||
|
additionalProperties.put(CodegenConstants.SERIALIZATION_LIBRARY, "jackson");
|
||||||
|
additionalProperties.put(USE_RESPONSE_ENTITY, "false");
|
||||||
|
Map<String, File> files = generateFromContract("src/test/resources/bugs/issue_11537.yaml", SPRING_BOOT, additionalProperties);
|
||||||
|
|
||||||
|
JavaFileAssert.assertThat(files.get("MetadataApi.java"))
|
||||||
|
.assertMethod("getSomething")
|
||||||
|
.hasReturnType("List<String>")
|
||||||
|
.assertMethodAnnotations()
|
||||||
|
.containsWithNameAndAttributes(
|
||||||
|
"ResponseStatus",
|
||||||
|
ImmutableMap.of("value", "HttpStatus.OK")
|
||||||
|
)
|
||||||
|
.toMethod()
|
||||||
|
.toFileAssert()
|
||||||
|
.assertMethod("putSomething")
|
||||||
|
.hasReturnType("String")
|
||||||
|
.assertMethodAnnotations()
|
||||||
|
.containsWithNameAndAttributes(
|
||||||
|
"ResponseStatus",
|
||||||
|
ImmutableMap.of("value", "HttpStatus.CREATED")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldGenerateMethodsWithoutUsingResponseEntityAndDelegation_issue11537() throws IOException {
|
||||||
|
Map<String, Object> additionalProperties = new HashMap<>();
|
||||||
|
additionalProperties.put(AbstractJavaCodegen.FULL_JAVA_UTIL, "true");
|
||||||
|
additionalProperties.put(SpringCodegen.USE_TAGS, "true");
|
||||||
|
additionalProperties.put(SpringCodegen.SKIP_DEFAULT_INTERFACE, "true");
|
||||||
|
additionalProperties.put(SpringCodegen.PERFORM_BEANVALIDATION, "true");
|
||||||
|
additionalProperties.put(SpringCodegen.SPRING_CONTROLLER, "true");
|
||||||
|
additionalProperties.put(CodegenConstants.SERIALIZATION_LIBRARY, "jackson");
|
||||||
|
additionalProperties.put(USE_RESPONSE_ENTITY, "false");
|
||||||
|
additionalProperties.put(DELEGATE_PATTERN, "true");
|
||||||
|
Map<String, File> files = generateFromContract("src/test/resources/bugs/issue_11537.yaml", SPRING_BOOT, additionalProperties);
|
||||||
|
|
||||||
|
JavaFileAssert.assertThat(files.get("MetadataApiDelegate.java"))
|
||||||
|
.assertMethod("getSomething").hasReturnType("List<String>")
|
||||||
|
.toFileAssert()
|
||||||
|
.assertMethod("putSomething").hasReturnType("String");
|
||||||
|
|
||||||
|
JavaFileAssert.assertThat(files.get("MetadataApi.java"))
|
||||||
|
.assertMethod("getSomething")
|
||||||
|
.hasReturnType("List<String>")
|
||||||
|
.assertMethodAnnotations()
|
||||||
|
.containsWithNameAndAttributes(
|
||||||
|
"ResponseStatus",
|
||||||
|
ImmutableMap.of("value", "HttpStatus.OK")
|
||||||
|
)
|
||||||
|
.toMethod()
|
||||||
|
.toFileAssert()
|
||||||
|
.assertMethod("putSomething")
|
||||||
|
.hasReturnType("String")
|
||||||
|
.assertMethodAnnotations()
|
||||||
|
.containsWithNameAndAttributes(
|
||||||
|
"ResponseStatus",
|
||||||
|
ImmutableMap.of("value", "HttpStatus.CREATED")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testResponseWithArray_issue12524() throws Exception {
|
public void testResponseWithArray_issue12524() throws Exception {
|
||||||
GlobalSettings.setProperty("skipFormModel", "true");
|
GlobalSettings.setProperty("skipFormModel", "true");
|
||||||
@ -1970,7 +2031,7 @@ public class SpringCodegenTest {
|
|||||||
.assertParameterAnnotations()
|
.assertParameterAnnotations()
|
||||||
.containsWithNameAndAttributes("Min", ImmutableMap.of("value", "2"));
|
.containsWithNameAndAttributes("Min", ImmutableMap.of("value", "2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldHandleSeparatelyInterfaceAndModelAdditionalAnnotations() throws IOException {
|
public void shouldHandleSeparatelyInterfaceAndModelAdditionalAnnotations() throws IOException {
|
||||||
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||||
|
@ -0,0 +1,106 @@
|
|||||||
|
package org.openapitools.codegen.templating.mustache;
|
||||||
|
|
||||||
|
import org.testng.annotations.DataProvider;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.openapitools.codegen.templating.mustache.SpringHttpStatusLambda.HTTP_STATUS_PREFIX;
|
||||||
|
import static org.testng.Assert.assertThrows;
|
||||||
|
|
||||||
|
public class SpringHttpStatusLambdaTest extends LambdaTest {
|
||||||
|
|
||||||
|
@DataProvider(name = "springHttpStatusCodes")
|
||||||
|
public static Object[][] springHttpStatusCodes() {
|
||||||
|
return new Object[][] {
|
||||||
|
{"ACCEPTED", "202"},
|
||||||
|
{"ALREADY_REPORTED", "208"},
|
||||||
|
{"BAD_GATEWAY", "502"},
|
||||||
|
{"BAD_REQUEST", "400"},
|
||||||
|
{"BANDWIDTH_LIMIT_EXCEEDED", "509"},
|
||||||
|
{"CONFLICT", "409"},
|
||||||
|
{"CONTINUE", "100"},
|
||||||
|
{"CREATED", "201"},
|
||||||
|
{"EARLY_HINTS", "103"},
|
||||||
|
{"EXPECTATION_FAILED", "417"},
|
||||||
|
{"FAILED_DEPENDENCY", "424"},
|
||||||
|
{"FORBIDDEN", "403"},
|
||||||
|
{"FOUND", "302"},
|
||||||
|
{"GATEWAY_TIMEOUT", "504"},
|
||||||
|
{"GONE", "410"},
|
||||||
|
{"HTTP_VERSION_NOT_SUPPORTED", "505"},
|
||||||
|
{"I_AM_A_TEAPOT", "418"},
|
||||||
|
{"IM_USED", "226"},
|
||||||
|
{"INSUFFICIENT_STORAGE", "507"},
|
||||||
|
{"INTERNAL_SERVER_ERROR", "500"},
|
||||||
|
{"LENGTH_REQUIRED", "411"},
|
||||||
|
{"LOCKED", "423"},
|
||||||
|
{"LOOP_DETECTED", "508"},
|
||||||
|
{"METHOD_NOT_ALLOWED", "405"},
|
||||||
|
{"MOVED_PERMANENTLY", "301"},
|
||||||
|
{"MULTI_STATUS", "207"},
|
||||||
|
{"MULTIPLE_CHOICES", "300"},
|
||||||
|
{"NETWORK_AUTHENTICATION_REQUIRED", "511"},
|
||||||
|
{"NO_CONTENT", "204"},
|
||||||
|
{"NON_AUTHORITATIVE_INFORMATION", "203"},
|
||||||
|
{"NOT_ACCEPTABLE", "406"},
|
||||||
|
{"NOT_EXTENDED", "510"},
|
||||||
|
{"NOT_FOUND", "404"},
|
||||||
|
{"NOT_IMPLEMENTED", "501"},
|
||||||
|
{"NOT_MODIFIED", "304"},
|
||||||
|
{"OK", "200"},
|
||||||
|
{"PARTIAL_CONTENT", "206"},
|
||||||
|
{"PAYLOAD_TOO_LARGE", "413"},
|
||||||
|
{"PAYMENT_REQUIRED", "402"},
|
||||||
|
{"PERMANENT_REDIRECT", "308"},
|
||||||
|
{"PRECONDITION_FAILED", "412"},
|
||||||
|
{"PRECONDITION_REQUIRED", "428"},
|
||||||
|
{"PROCESSING", "102"},
|
||||||
|
{"PROXY_AUTHENTICATION_REQUIRED", "407"},
|
||||||
|
{"REQUEST_HEADER_FIELDS_TOO_LARGE", "431"},
|
||||||
|
{"REQUEST_TIMEOUT", "408"},
|
||||||
|
{"REQUESTED_RANGE_NOT_SATISFIABLE", "416"},
|
||||||
|
{"RESET_CONTENT", "205"},
|
||||||
|
{"SEE_OTHER", "303"},
|
||||||
|
{"SERVICE_UNAVAILABLE", "503"},
|
||||||
|
{"SWITCHING_PROTOCOLS", "101"},
|
||||||
|
{"TEMPORARY_REDIRECT", "307"},
|
||||||
|
{"TOO_EARLY", "425"},
|
||||||
|
{"TOO_MANY_REQUESTS", "429"},
|
||||||
|
{"UNAUTHORIZED", "401"},
|
||||||
|
{"UNAVAILABLE_FOR_LEGAL_REASONS", "451"},
|
||||||
|
{"UNPROCESSABLE_ENTITY", "422"},
|
||||||
|
{"UNSUPPORTED_MEDIA_TYPE", "415"},
|
||||||
|
{"UPGRADE_REQUIRED", "426"},
|
||||||
|
{"URI_TOO_LONG", "414"},
|
||||||
|
{"VARIANT_ALSO_NEGOTIATES", "506"}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "springHttpStatusCodes")
|
||||||
|
public void executeShouldConvertValues(String expectedHttpStatus, String httpCode) {
|
||||||
|
Map<String, Object> ctx = context("springHttpStatus", new SpringHttpStatusLambda());
|
||||||
|
|
||||||
|
test(
|
||||||
|
HTTP_STATUS_PREFIX + expectedHttpStatus,
|
||||||
|
String.format(Locale.ROOT, "{{#springHttpStatus}}%s{{/springHttpStatus}}", httpCode),
|
||||||
|
ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void executeShouldConvertEmptyHttpStatusTo200Ok() {
|
||||||
|
Map<String, Object> ctx = context("springHttpStatus", new SpringHttpStatusLambda());
|
||||||
|
|
||||||
|
test(HTTP_STATUS_PREFIX + "OK", "{{#springHttpStatus}}{{/springHttpStatus}}", ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void executeShouldConvertToHttpStatusNotImplementedAnyOtherStatus() {
|
||||||
|
Map<String, Object> ctx = context("springHttpStatus", new SpringHttpStatusLambda());
|
||||||
|
|
||||||
|
assertThrows(
|
||||||
|
IllegalArgumentException.class,
|
||||||
|
() -> execute("{{#springHttpStatus}}305{{/springHttpStatus}}", ctx));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
openapi: 3.0.1
|
||||||
|
info:
|
||||||
|
title: metadata-svc
|
||||||
|
description: Metadata Service
|
||||||
|
contact:
|
||||||
|
name: Test Svc
|
||||||
|
email: xyz@xyz.com
|
||||||
|
version: 3.1.2
|
||||||
|
servers:
|
||||||
|
- url: https://localhost:8080/
|
||||||
|
tags:
|
||||||
|
- name: metadata
|
||||||
|
description: APIs to get metadata.
|
||||||
|
paths:
|
||||||
|
/v1/a-path:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- metadata
|
||||||
|
summary: A generic getter operation.
|
||||||
|
description: Get something from somewhere.
|
||||||
|
operationId: getSomething
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: List of groups.
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
/v1/another-path:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- metadata
|
||||||
|
summary: Insert something.
|
||||||
|
description: Insert something somewhere.
|
||||||
|
operationId: putSomething
|
||||||
|
responses:
|
||||||
|
201:
|
||||||
|
description: List of groups.
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: string
|
@ -99,6 +99,7 @@ public interface PetApi {
|
|||||||
) {
|
) {
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -152,6 +153,7 @@ public interface PetApi {
|
|||||||
});
|
});
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -207,6 +209,7 @@ public interface PetApi {
|
|||||||
});
|
});
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -258,6 +261,7 @@ public interface PetApi {
|
|||||||
});
|
});
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -296,6 +300,7 @@ public interface PetApi {
|
|||||||
) {
|
) {
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -334,6 +339,7 @@ public interface PetApi {
|
|||||||
) {
|
) {
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -383,6 +389,7 @@ public interface PetApi {
|
|||||||
});
|
});
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,7 @@ public interface StoreApi {
|
|||||||
) {
|
) {
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -93,6 +94,7 @@ public interface StoreApi {
|
|||||||
) {
|
) {
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -141,6 +143,7 @@ public interface StoreApi {
|
|||||||
});
|
});
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -186,6 +189,7 @@ public interface StoreApi {
|
|||||||
});
|
});
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@ public interface UserApi {
|
|||||||
) {
|
) {
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -86,6 +87,7 @@ public interface UserApi {
|
|||||||
) {
|
) {
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -113,6 +115,7 @@ public interface UserApi {
|
|||||||
) {
|
) {
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -143,6 +146,7 @@ public interface UserApi {
|
|||||||
) {
|
) {
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -190,6 +194,7 @@ public interface UserApi {
|
|||||||
});
|
});
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -223,6 +228,7 @@ public interface UserApi {
|
|||||||
) {
|
) {
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -249,6 +255,7 @@ public interface UserApi {
|
|||||||
) {
|
) {
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -281,6 +288,7 @@ public interface UserApi {
|
|||||||
) {
|
) {
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
# OpenAPI Generator Ignore
|
||||||
|
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||||
|
|
||||||
|
# Use this file to prevent files from being overwritten by the generator.
|
||||||
|
# The patterns follow closely to .gitignore or .dockerignore.
|
||||||
|
|
||||||
|
# As an example, the C# client generator defines ApiClient.cs.
|
||||||
|
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||||
|
#ApiClient.cs
|
||||||
|
|
||||||
|
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||||
|
#foo/*/qux
|
||||||
|
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||||
|
|
||||||
|
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||||
|
#foo/**/qux
|
||||||
|
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||||
|
|
||||||
|
# You can also negate patterns with an exclamation (!).
|
||||||
|
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||||
|
#docs/*.md
|
||||||
|
# Then explicitly reverse the ignore rule for a single file:
|
||||||
|
#!docs/README.md
|
@ -0,0 +1,26 @@
|
|||||||
|
README.md
|
||||||
|
pom.xml
|
||||||
|
src/main/java/org/openapitools/OpenApiGeneratorApplication.java
|
||||||
|
src/main/java/org/openapitools/RFC3339DateFormat.java
|
||||||
|
src/main/java/org/openapitools/api/ApiUtil.java
|
||||||
|
src/main/java/org/openapitools/api/PetApi.java
|
||||||
|
src/main/java/org/openapitools/api/PetApiController.java
|
||||||
|
src/main/java/org/openapitools/api/PetApiDelegate.java
|
||||||
|
src/main/java/org/openapitools/api/StoreApi.java
|
||||||
|
src/main/java/org/openapitools/api/StoreApiController.java
|
||||||
|
src/main/java/org/openapitools/api/StoreApiDelegate.java
|
||||||
|
src/main/java/org/openapitools/api/UserApi.java
|
||||||
|
src/main/java/org/openapitools/api/UserApiController.java
|
||||||
|
src/main/java/org/openapitools/api/UserApiDelegate.java
|
||||||
|
src/main/java/org/openapitools/configuration/HomeController.java
|
||||||
|
src/main/java/org/openapitools/configuration/SpringFoxConfiguration.java
|
||||||
|
src/main/java/org/openapitools/model/Category.java
|
||||||
|
src/main/java/org/openapitools/model/ModelApiResponse.java
|
||||||
|
src/main/java/org/openapitools/model/Order.java
|
||||||
|
src/main/java/org/openapitools/model/Pet.java
|
||||||
|
src/main/java/org/openapitools/model/Tag.java
|
||||||
|
src/main/java/org/openapitools/model/User.java
|
||||||
|
src/main/resources/application.properties
|
||||||
|
src/main/resources/openapi.yaml
|
||||||
|
src/main/resources/static/swagger-ui.html
|
||||||
|
src/test/java/org/openapitools/OpenApiGeneratorApplicationTests.java
|
@ -0,0 +1 @@
|
|||||||
|
6.5.0-SNAPSHOT
|
@ -0,0 +1,27 @@
|
|||||||
|
# OpenAPI generated server
|
||||||
|
|
||||||
|
Spring Boot Server
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project.
|
||||||
|
By using the [OpenAPI-Spec](https://openapis.org), you can easily generate a server stub.
|
||||||
|
This is an example of building a OpenAPI-enabled server in Java using the SpringBoot framework.
|
||||||
|
|
||||||
|
The underlying library integrating OpenAPI to Spring Boot is [springfox](https://github.com/springfox/springfox).
|
||||||
|
Springfox will generate an OpenAPI v2 (fka Swagger RESTful API Documentation Specification) specification based on the
|
||||||
|
generated Controller and Model classes. The specification is available to download using the following url:
|
||||||
|
http://localhost:8080/v2/api-docs/
|
||||||
|
|
||||||
|
**HEADS-UP**: Springfox is deprecated for removal in version 6.0.0 of openapi-generator. The project seems to be no longer
|
||||||
|
maintained (last commit is of Oct 14, 2020). It works with Spring Boot 2.5.x but not with 2.6. Spring Boot 2.5 is
|
||||||
|
supported until 2022-05-19. Users of openapi-generator should migrate to the springdoc documentation provider which is,
|
||||||
|
as an added bonus, OpenAPI v3 compatible.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Start your server as a simple java application
|
||||||
|
|
||||||
|
You can view the api documentation in swagger-ui by pointing to
|
||||||
|
http://localhost:8080/swagger-ui.html
|
||||||
|
|
||||||
|
Change default port value in application.properties
|
@ -0,0 +1,89 @@
|
|||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>springboot-delegate-no-response-entity</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>springboot-delegate-no-response-entity</name>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||||
|
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<springfox.version>2.9.2</springfox.version>
|
||||||
|
<swagger-ui.version>4.15.5</swagger-ui.version>
|
||||||
|
</properties>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>2.5.14</version>
|
||||||
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
|
</parent>
|
||||||
|
<build>
|
||||||
|
<sourceDirectory>src/main/java</sourceDirectory>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.data</groupId>
|
||||||
|
<artifactId>spring-data-commons</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!--SpringFox dependencies -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger2</artifactId>
|
||||||
|
<version>${springfox.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.webjars</groupId>
|
||||||
|
<artifactId>swagger-ui</artifactId>
|
||||||
|
<version>${swagger-ui.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.webjars</groupId>
|
||||||
|
<artifactId>webjars-locator-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- @Nullable annotation -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.findbugs</groupId>
|
||||||
|
<artifactId>jsr305</artifactId>
|
||||||
|
<version>3.0.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||||
|
<artifactId>jackson-dataformat-yaml</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>jackson-databind-nullable</artifactId>
|
||||||
|
<version>0.2.6</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- Bean Validation API support -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
@ -0,0 +1,30 @@
|
|||||||
|
package org.openapitools;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.Module;
|
||||||
|
import org.openapitools.jackson.nullable.JsonNullableModule;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.context.annotation.FilterType;
|
||||||
|
import org.springframework.context.annotation.FullyQualifiedAnnotationBeanNameGenerator;
|
||||||
|
|
||||||
|
@SpringBootApplication(
|
||||||
|
nameGenerator = FullyQualifiedAnnotationBeanNameGenerator.class
|
||||||
|
)
|
||||||
|
@ComponentScan(
|
||||||
|
basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"},
|
||||||
|
nameGenerator = FullyQualifiedAnnotationBeanNameGenerator.class
|
||||||
|
)
|
||||||
|
public class OpenApiGeneratorApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(OpenApiGeneratorApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean(name = "org.openapitools.OpenApiGeneratorApplication.jsonNullableModule")
|
||||||
|
public Module jsonNullableModule() {
|
||||||
|
return new JsonNullableModule();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package org.openapitools;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.FieldPosition;
|
||||||
|
import java.text.ParsePosition;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
|
public class RFC3339DateFormat extends DateFormat {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
|
||||||
|
|
||||||
|
private final StdDateFormat fmt = new StdDateFormat()
|
||||||
|
.withTimeZone(TIMEZONE_Z)
|
||||||
|
.withColonInTimeZone(true);
|
||||||
|
|
||||||
|
public RFC3339DateFormat() {
|
||||||
|
this.calendar = new GregorianCalendar();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Date parse(String source, ParsePosition pos) {
|
||||||
|
return fmt.parse(source, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
|
||||||
|
return fmt.format(date, toAppendTo, fieldPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object clone() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package org.openapitools.api;
|
||||||
|
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class ApiUtil {
|
||||||
|
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
||||||
|
try {
|
||||||
|
HttpServletResponse res = req.getNativeResponse(HttpServletResponse.class);
|
||||||
|
res.setCharacterEncoding("UTF-8");
|
||||||
|
res.addHeader("Content-Type", contentType);
|
||||||
|
res.getWriter().print(example);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,345 @@
|
|||||||
|
/**
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (6.5.0-SNAPSHOT).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
package org.openapitools.api;
|
||||||
|
|
||||||
|
import org.openapitools.model.ModelApiResponse;
|
||||||
|
import org.openapitools.model.Pet;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
|
||||||
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
|
@Validated
|
||||||
|
@Api(value = "pet", description = "Everything about your Pets")
|
||||||
|
public interface PetApi {
|
||||||
|
|
||||||
|
default PetApiDelegate getDelegate() {
|
||||||
|
return new PetApiDelegate() {};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POST /pet : Add a new pet to the store
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param pet Pet object that needs to be added to the store (required)
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
* or Invalid input (status code 405)
|
||||||
|
*/
|
||||||
|
@ApiOperation(
|
||||||
|
tags = { "pet" },
|
||||||
|
value = "Add a new pet to the store",
|
||||||
|
nickname = "addPet",
|
||||||
|
notes = "",
|
||||||
|
response = Pet.class,
|
||||||
|
authorizations = {
|
||||||
|
@Authorization(value = "petstore_auth", scopes = {
|
||||||
|
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
||||||
|
@AuthorizationScope(scope = "read:pets", description = "read your pets")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses({
|
||||||
|
@ApiResponse(code = 200, message = "successful operation", response = Pet.class),
|
||||||
|
@ApiResponse(code = 405, message = "Invalid input")
|
||||||
|
})
|
||||||
|
@RequestMapping(
|
||||||
|
method = RequestMethod.POST,
|
||||||
|
value = "/pet",
|
||||||
|
produces = { "application/xml", "application/json" },
|
||||||
|
consumes = { "application/json", "application/xml" }
|
||||||
|
)
|
||||||
|
@ResponseStatus(HttpStatus.OK)
|
||||||
|
default Pet addPet(
|
||||||
|
@ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet
|
||||||
|
) {
|
||||||
|
return getDelegate().addPet(pet);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DELETE /pet/{petId} : Deletes a pet
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param petId Pet id to delete (required)
|
||||||
|
* @param apiKey (optional)
|
||||||
|
* @return Invalid pet value (status code 400)
|
||||||
|
*/
|
||||||
|
@ApiOperation(
|
||||||
|
tags = { "pet" },
|
||||||
|
value = "Deletes a pet",
|
||||||
|
nickname = "deletePet",
|
||||||
|
notes = "",
|
||||||
|
authorizations = {
|
||||||
|
@Authorization(value = "petstore_auth", scopes = {
|
||||||
|
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
||||||
|
@AuthorizationScope(scope = "read:pets", description = "read your pets")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses({
|
||||||
|
@ApiResponse(code = 400, message = "Invalid pet value")
|
||||||
|
})
|
||||||
|
@RequestMapping(
|
||||||
|
method = RequestMethod.DELETE,
|
||||||
|
value = "/pet/{petId}"
|
||||||
|
)
|
||||||
|
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||||
|
default Void deletePet(
|
||||||
|
@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId,
|
||||||
|
@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey
|
||||||
|
) {
|
||||||
|
return getDelegate().deletePet(petId, apiKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /pet/findByStatus : Finds Pets by status
|
||||||
|
* Multiple status values can be provided with comma separated strings
|
||||||
|
*
|
||||||
|
* @param status Status values that need to be considered for filter (required)
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
* or Invalid status value (status code 400)
|
||||||
|
*/
|
||||||
|
@ApiOperation(
|
||||||
|
tags = { "pet" },
|
||||||
|
value = "Finds Pets by status",
|
||||||
|
nickname = "findPetsByStatus",
|
||||||
|
notes = "Multiple status values can be provided with comma separated strings",
|
||||||
|
response = Pet.class,
|
||||||
|
responseContainer = "List",
|
||||||
|
authorizations = {
|
||||||
|
@Authorization(value = "petstore_auth", scopes = {
|
||||||
|
@AuthorizationScope(scope = "read:pets", description = "read your pets")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses({
|
||||||
|
@ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"),
|
||||||
|
@ApiResponse(code = 400, message = "Invalid status value")
|
||||||
|
})
|
||||||
|
@RequestMapping(
|
||||||
|
method = RequestMethod.GET,
|
||||||
|
value = "/pet/findByStatus",
|
||||||
|
produces = { "application/xml", "application/json" }
|
||||||
|
)
|
||||||
|
@ResponseStatus(HttpStatus.OK)
|
||||||
|
default List<Pet> findPetsByStatus(
|
||||||
|
@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List<String> status
|
||||||
|
) {
|
||||||
|
return getDelegate().findPetsByStatus(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /pet/findByTags : Finds Pets by tags
|
||||||
|
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||||
|
*
|
||||||
|
* @param tags Tags to filter by (required)
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
* or Invalid tag value (status code 400)
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@ApiOperation(
|
||||||
|
tags = { "pet" },
|
||||||
|
value = "Finds Pets by tags",
|
||||||
|
nickname = "findPetsByTags",
|
||||||
|
notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.",
|
||||||
|
response = Pet.class,
|
||||||
|
responseContainer = "List",
|
||||||
|
authorizations = {
|
||||||
|
@Authorization(value = "petstore_auth", scopes = {
|
||||||
|
@AuthorizationScope(scope = "read:pets", description = "read your pets")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses({
|
||||||
|
@ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"),
|
||||||
|
@ApiResponse(code = 400, message = "Invalid tag value")
|
||||||
|
})
|
||||||
|
@RequestMapping(
|
||||||
|
method = RequestMethod.GET,
|
||||||
|
value = "/pet/findByTags",
|
||||||
|
produces = { "application/xml", "application/json" }
|
||||||
|
)
|
||||||
|
@ResponseStatus(HttpStatus.OK)
|
||||||
|
default List<Pet> findPetsByTags(
|
||||||
|
@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List<String> tags
|
||||||
|
) {
|
||||||
|
return getDelegate().findPetsByTags(tags);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /pet/{petId} : Find pet by ID
|
||||||
|
* Returns a single pet
|
||||||
|
*
|
||||||
|
* @param petId ID of pet to return (required)
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
* or Invalid ID supplied (status code 400)
|
||||||
|
* or Pet not found (status code 404)
|
||||||
|
*/
|
||||||
|
@ApiOperation(
|
||||||
|
tags = { "pet" },
|
||||||
|
value = "Find pet by ID",
|
||||||
|
nickname = "getPetById",
|
||||||
|
notes = "Returns a single pet",
|
||||||
|
response = Pet.class,
|
||||||
|
authorizations = {
|
||||||
|
@Authorization(value = "api_key")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses({
|
||||||
|
@ApiResponse(code = 200, message = "successful operation", response = Pet.class),
|
||||||
|
@ApiResponse(code = 400, message = "Invalid ID supplied"),
|
||||||
|
@ApiResponse(code = 404, message = "Pet not found")
|
||||||
|
})
|
||||||
|
@RequestMapping(
|
||||||
|
method = RequestMethod.GET,
|
||||||
|
value = "/pet/{petId}",
|
||||||
|
produces = { "application/xml", "application/json" }
|
||||||
|
)
|
||||||
|
@ResponseStatus(HttpStatus.OK)
|
||||||
|
default Pet getPetById(
|
||||||
|
@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId
|
||||||
|
) {
|
||||||
|
return getDelegate().getPetById(petId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PUT /pet : Update an existing pet
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param pet Pet object that needs to be added to the store (required)
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
* or Invalid ID supplied (status code 400)
|
||||||
|
* or Pet not found (status code 404)
|
||||||
|
* or Validation exception (status code 405)
|
||||||
|
* API documentation for the updatePet operation
|
||||||
|
* @see <a href="http://petstore.swagger.io/v2/doc/updatePet">Update an existing pet Documentation</a>
|
||||||
|
*/
|
||||||
|
@ApiOperation(
|
||||||
|
tags = { "pet" },
|
||||||
|
value = "Update an existing pet",
|
||||||
|
nickname = "updatePet",
|
||||||
|
notes = "",
|
||||||
|
response = Pet.class,
|
||||||
|
authorizations = {
|
||||||
|
@Authorization(value = "petstore_auth", scopes = {
|
||||||
|
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
||||||
|
@AuthorizationScope(scope = "read:pets", description = "read your pets")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses({
|
||||||
|
@ApiResponse(code = 200, message = "successful operation", response = Pet.class),
|
||||||
|
@ApiResponse(code = 400, message = "Invalid ID supplied"),
|
||||||
|
@ApiResponse(code = 404, message = "Pet not found"),
|
||||||
|
@ApiResponse(code = 405, message = "Validation exception")
|
||||||
|
})
|
||||||
|
@RequestMapping(
|
||||||
|
method = RequestMethod.PUT,
|
||||||
|
value = "/pet",
|
||||||
|
produces = { "application/xml", "application/json" },
|
||||||
|
consumes = { "application/json", "application/xml" }
|
||||||
|
)
|
||||||
|
@ResponseStatus(HttpStatus.OK)
|
||||||
|
default Pet updatePet(
|
||||||
|
@ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet
|
||||||
|
) {
|
||||||
|
return getDelegate().updatePet(pet);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POST /pet/{petId} : Updates a pet in the store with form data
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param petId ID of pet that needs to be updated (required)
|
||||||
|
* @param name Updated name of the pet (optional)
|
||||||
|
* @param status Updated status of the pet (optional)
|
||||||
|
* @return Invalid input (status code 405)
|
||||||
|
*/
|
||||||
|
@ApiOperation(
|
||||||
|
tags = { "pet" },
|
||||||
|
value = "Updates a pet in the store with form data",
|
||||||
|
nickname = "updatePetWithForm",
|
||||||
|
notes = "",
|
||||||
|
authorizations = {
|
||||||
|
@Authorization(value = "petstore_auth", scopes = {
|
||||||
|
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
||||||
|
@AuthorizationScope(scope = "read:pets", description = "read your pets")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses({
|
||||||
|
@ApiResponse(code = 405, message = "Invalid input")
|
||||||
|
})
|
||||||
|
@RequestMapping(
|
||||||
|
method = RequestMethod.POST,
|
||||||
|
value = "/pet/{petId}",
|
||||||
|
consumes = { "application/x-www-form-urlencoded" }
|
||||||
|
)
|
||||||
|
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
|
||||||
|
default Void updatePetWithForm(
|
||||||
|
@ApiParam(value = "ID of pet that needs to be updated", required = true) @PathVariable("petId") Long petId,
|
||||||
|
@ApiParam(value = "Updated name of the pet") @Valid @RequestParam(value = "name", required = false) String name,
|
||||||
|
@ApiParam(value = "Updated status of the pet") @Valid @RequestParam(value = "status", required = false) String status
|
||||||
|
) {
|
||||||
|
return getDelegate().updatePetWithForm(petId, name, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POST /pet/{petId}/uploadImage : uploads an image
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param petId ID of pet to update (required)
|
||||||
|
* @param additionalMetadata Additional data to pass to server (optional)
|
||||||
|
* @param file file to upload (optional)
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
*/
|
||||||
|
@ApiOperation(
|
||||||
|
tags = { "pet" },
|
||||||
|
value = "uploads an image",
|
||||||
|
nickname = "uploadFile",
|
||||||
|
notes = "",
|
||||||
|
response = ModelApiResponse.class,
|
||||||
|
authorizations = {
|
||||||
|
@Authorization(value = "petstore_auth", scopes = {
|
||||||
|
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
||||||
|
@AuthorizationScope(scope = "read:pets", description = "read your pets")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses({
|
||||||
|
@ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class)
|
||||||
|
})
|
||||||
|
@RequestMapping(
|
||||||
|
method = RequestMethod.POST,
|
||||||
|
value = "/pet/{petId}/uploadImage",
|
||||||
|
produces = { "application/json" },
|
||||||
|
consumes = { "multipart/form-data" }
|
||||||
|
)
|
||||||
|
@ResponseStatus(HttpStatus.OK)
|
||||||
|
default ModelApiResponse uploadFile(
|
||||||
|
@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId,
|
||||||
|
@ApiParam(value = "Additional data to pass to server") @Valid @RequestParam(value = "additionalMetadata", required = false) String additionalMetadata,
|
||||||
|
@ApiParam(value = "file to upload") @RequestPart(value = "file", required = false) MultipartFile file
|
||||||
|
) {
|
||||||
|
return getDelegate().uploadFile(petId, additionalMetadata, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package org.openapitools.api;
|
||||||
|
|
||||||
|
import org.openapitools.model.ModelApiResponse;
|
||||||
|
import org.openapitools.model.Pet;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.CookieValue;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
|
||||||
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
||||||
|
public class PetApiController implements PetApi {
|
||||||
|
|
||||||
|
private final PetApiDelegate delegate;
|
||||||
|
|
||||||
|
public PetApiController(@Autowired(required = false) PetApiDelegate delegate) {
|
||||||
|
this.delegate = Optional.ofNullable(delegate).orElse(new PetApiDelegate() {});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PetApiDelegate getDelegate() {
|
||||||
|
return delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,231 @@
|
|||||||
|
package org.openapitools.api;
|
||||||
|
|
||||||
|
import org.openapitools.model.ModelApiResponse;
|
||||||
|
import org.openapitools.model.Pet;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A delegate to be called by the {@link PetApiController}}.
|
||||||
|
* Implement this interface with a {@link org.springframework.stereotype.Service} annotated class.
|
||||||
|
*/
|
||||||
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
|
public interface PetApiDelegate {
|
||||||
|
|
||||||
|
default Optional<NativeWebRequest> getRequest() {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POST /pet : Add a new pet to the store
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param pet Pet object that needs to be added to the store (required)
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
* or Invalid input (status code 405)
|
||||||
|
* @see PetApi#addPet
|
||||||
|
*/
|
||||||
|
default Pet addPet(Pet pet) {
|
||||||
|
getRequest().ifPresent(request -> {
|
||||||
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
|
String exampleString = "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }";
|
||||||
|
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
String exampleString = "<Pet> <id>123456789</id> <Category> <id>123456789</id> <name>aeiou</name> </Category> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> <Tag> <id>123456789</id> <name>aeiou</name> </Tag> </tags> <status>aeiou</status> </Pet>";
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
throw new IllegalArgumentException("Not implemented");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DELETE /pet/{petId} : Deletes a pet
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param petId Pet id to delete (required)
|
||||||
|
* @param apiKey (optional)
|
||||||
|
* @return Invalid pet value (status code 400)
|
||||||
|
* @see PetApi#deletePet
|
||||||
|
*/
|
||||||
|
default Void deletePet(Long petId,
|
||||||
|
String apiKey) {
|
||||||
|
throw new IllegalArgumentException("Not implemented");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /pet/findByStatus : Finds Pets by status
|
||||||
|
* Multiple status values can be provided with comma separated strings
|
||||||
|
*
|
||||||
|
* @param status Status values that need to be considered for filter (required)
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
* or Invalid status value (status code 400)
|
||||||
|
* @see PetApi#findPetsByStatus
|
||||||
|
*/
|
||||||
|
default List<Pet> findPetsByStatus(List<String> status) {
|
||||||
|
getRequest().ifPresent(request -> {
|
||||||
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
|
String exampleString = "[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" } ]";
|
||||||
|
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
String exampleString = "<Pet> <id>123456789</id> <Category> <id>123456789</id> <name>aeiou</name> </Category> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> <Tag> <id>123456789</id> <name>aeiou</name> </Tag> </tags> <status>aeiou</status> </Pet>";
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
throw new IllegalArgumentException("Not implemented");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /pet/findByTags : Finds Pets by tags
|
||||||
|
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||||
|
*
|
||||||
|
* @param tags Tags to filter by (required)
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
* or Invalid tag value (status code 400)
|
||||||
|
* @deprecated
|
||||||
|
* @see PetApi#findPetsByTags
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
default List<Pet> findPetsByTags(List<String> tags) {
|
||||||
|
getRequest().ifPresent(request -> {
|
||||||
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
|
String exampleString = "[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" } ]";
|
||||||
|
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
String exampleString = "<Pet> <id>123456789</id> <Category> <id>123456789</id> <name>aeiou</name> </Category> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> <Tag> <id>123456789</id> <name>aeiou</name> </Tag> </tags> <status>aeiou</status> </Pet>";
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
throw new IllegalArgumentException("Not implemented");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /pet/{petId} : Find pet by ID
|
||||||
|
* Returns a single pet
|
||||||
|
*
|
||||||
|
* @param petId ID of pet to return (required)
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
* or Invalid ID supplied (status code 400)
|
||||||
|
* or Pet not found (status code 404)
|
||||||
|
* @see PetApi#getPetById
|
||||||
|
*/
|
||||||
|
default Pet getPetById(Long petId) {
|
||||||
|
getRequest().ifPresent(request -> {
|
||||||
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
|
String exampleString = "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }";
|
||||||
|
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
String exampleString = "<Pet> <id>123456789</id> <Category> <id>123456789</id> <name>aeiou</name> </Category> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> <Tag> <id>123456789</id> <name>aeiou</name> </Tag> </tags> <status>aeiou</status> </Pet>";
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
throw new IllegalArgumentException("Not implemented");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PUT /pet : Update an existing pet
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param pet Pet object that needs to be added to the store (required)
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
* or Invalid ID supplied (status code 400)
|
||||||
|
* or Pet not found (status code 404)
|
||||||
|
* or Validation exception (status code 405)
|
||||||
|
* API documentation for the updatePet operation
|
||||||
|
* @see <a href="http://petstore.swagger.io/v2/doc/updatePet">Update an existing pet Documentation</a>
|
||||||
|
* @see PetApi#updatePet
|
||||||
|
*/
|
||||||
|
default Pet updatePet(Pet pet) {
|
||||||
|
getRequest().ifPresent(request -> {
|
||||||
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
|
String exampleString = "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }";
|
||||||
|
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
String exampleString = "<Pet> <id>123456789</id> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> </tags> <status>aeiou</status> </Pet>";
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
throw new IllegalArgumentException("Not implemented");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POST /pet/{petId} : Updates a pet in the store with form data
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param petId ID of pet that needs to be updated (required)
|
||||||
|
* @param name Updated name of the pet (optional)
|
||||||
|
* @param status Updated status of the pet (optional)
|
||||||
|
* @return Invalid input (status code 405)
|
||||||
|
* @see PetApi#updatePetWithForm
|
||||||
|
*/
|
||||||
|
default Void updatePetWithForm(Long petId,
|
||||||
|
String name,
|
||||||
|
String status) {
|
||||||
|
throw new IllegalArgumentException("Not implemented");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POST /pet/{petId}/uploadImage : uploads an image
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param petId ID of pet to update (required)
|
||||||
|
* @param additionalMetadata Additional data to pass to server (optional)
|
||||||
|
* @param file file to upload (optional)
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
* @see PetApi#uploadFile
|
||||||
|
*/
|
||||||
|
default ModelApiResponse uploadFile(Long petId,
|
||||||
|
String additionalMetadata,
|
||||||
|
MultipartFile file) {
|
||||||
|
getRequest().ifPresent(request -> {
|
||||||
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
|
String exampleString = "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\" }";
|
||||||
|
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
throw new IllegalArgumentException("Not implemented");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,160 @@
|
|||||||
|
/**
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (6.5.0-SNAPSHOT).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
package org.openapitools.api;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import org.openapitools.model.Order;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
|
||||||
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
|
@Validated
|
||||||
|
@Api(value = "store", description = "Access to Petstore orders")
|
||||||
|
public interface StoreApi {
|
||||||
|
|
||||||
|
default StoreApiDelegate getDelegate() {
|
||||||
|
return new StoreApiDelegate() {};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DELETE /store/order/{orderId} : Delete purchase order by ID
|
||||||
|
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
|
*
|
||||||
|
* @param orderId ID of the order that needs to be deleted (required)
|
||||||
|
* @return Invalid ID supplied (status code 400)
|
||||||
|
* or Order not found (status code 404)
|
||||||
|
*/
|
||||||
|
@ApiOperation(
|
||||||
|
tags = { "store" },
|
||||||
|
value = "Delete purchase order by ID",
|
||||||
|
nickname = "deleteOrder",
|
||||||
|
notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors"
|
||||||
|
)
|
||||||
|
@ApiResponses({
|
||||||
|
@ApiResponse(code = 400, message = "Invalid ID supplied"),
|
||||||
|
@ApiResponse(code = 404, message = "Order not found")
|
||||||
|
})
|
||||||
|
@RequestMapping(
|
||||||
|
method = RequestMethod.DELETE,
|
||||||
|
value = "/store/order/{orderId}"
|
||||||
|
)
|
||||||
|
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||||
|
default Void deleteOrder(
|
||||||
|
@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") String orderId
|
||||||
|
) {
|
||||||
|
return getDelegate().deleteOrder(orderId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /store/inventory : Returns pet inventories by status
|
||||||
|
* Returns a map of status codes to quantities
|
||||||
|
*
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
*/
|
||||||
|
@ApiOperation(
|
||||||
|
tags = { "store" },
|
||||||
|
value = "Returns pet inventories by status",
|
||||||
|
nickname = "getInventory",
|
||||||
|
notes = "Returns a map of status codes to quantities",
|
||||||
|
response = Integer.class,
|
||||||
|
responseContainer = "Map",
|
||||||
|
authorizations = {
|
||||||
|
@Authorization(value = "api_key")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses({
|
||||||
|
@ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map")
|
||||||
|
})
|
||||||
|
@RequestMapping(
|
||||||
|
method = RequestMethod.GET,
|
||||||
|
value = "/store/inventory",
|
||||||
|
produces = { "application/json" }
|
||||||
|
)
|
||||||
|
@ResponseStatus(HttpStatus.OK)
|
||||||
|
default Map<String, Integer> getInventory(
|
||||||
|
|
||||||
|
) {
|
||||||
|
return getDelegate().getInventory();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /store/order/{orderId} : Find purchase order by ID
|
||||||
|
* For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions
|
||||||
|
*
|
||||||
|
* @param orderId ID of pet that needs to be fetched (required)
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
* or Invalid ID supplied (status code 400)
|
||||||
|
* or Order not found (status code 404)
|
||||||
|
*/
|
||||||
|
@ApiOperation(
|
||||||
|
tags = { "store" },
|
||||||
|
value = "Find purchase order by ID",
|
||||||
|
nickname = "getOrderById",
|
||||||
|
notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions",
|
||||||
|
response = Order.class
|
||||||
|
)
|
||||||
|
@ApiResponses({
|
||||||
|
@ApiResponse(code = 200, message = "successful operation", response = Order.class),
|
||||||
|
@ApiResponse(code = 400, message = "Invalid ID supplied"),
|
||||||
|
@ApiResponse(code = 404, message = "Order not found")
|
||||||
|
})
|
||||||
|
@RequestMapping(
|
||||||
|
method = RequestMethod.GET,
|
||||||
|
value = "/store/order/{orderId}",
|
||||||
|
produces = { "application/xml", "application/json" }
|
||||||
|
)
|
||||||
|
@ResponseStatus(HttpStatus.OK)
|
||||||
|
default Order getOrderById(
|
||||||
|
@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") Long orderId
|
||||||
|
) {
|
||||||
|
return getDelegate().getOrderById(orderId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POST /store/order : Place an order for a pet
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param order order placed for purchasing the pet (required)
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
* or Invalid Order (status code 400)
|
||||||
|
*/
|
||||||
|
@ApiOperation(
|
||||||
|
tags = { "store" },
|
||||||
|
value = "Place an order for a pet",
|
||||||
|
nickname = "placeOrder",
|
||||||
|
notes = "",
|
||||||
|
response = Order.class
|
||||||
|
)
|
||||||
|
@ApiResponses({
|
||||||
|
@ApiResponse(code = 200, message = "successful operation", response = Order.class),
|
||||||
|
@ApiResponse(code = 400, message = "Invalid Order")
|
||||||
|
})
|
||||||
|
@RequestMapping(
|
||||||
|
method = RequestMethod.POST,
|
||||||
|
value = "/store/order",
|
||||||
|
produces = { "application/xml", "application/json" },
|
||||||
|
consumes = { "application/json" }
|
||||||
|
)
|
||||||
|
@ResponseStatus(HttpStatus.OK)
|
||||||
|
default Order placeOrder(
|
||||||
|
@ApiParam(value = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order order
|
||||||
|
) {
|
||||||
|
return getDelegate().placeOrder(order);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package org.openapitools.api;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import org.openapitools.model.Order;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.CookieValue;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
|
||||||
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
||||||
|
public class StoreApiController implements StoreApi {
|
||||||
|
|
||||||
|
private final StoreApiDelegate delegate;
|
||||||
|
|
||||||
|
public StoreApiController(@Autowired(required = false) StoreApiDelegate delegate) {
|
||||||
|
this.delegate = Optional.ofNullable(delegate).orElse(new StoreApiDelegate() {});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StoreApiDelegate getDelegate() {
|
||||||
|
return delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,109 @@
|
|||||||
|
package org.openapitools.api;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import org.openapitools.model.Order;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A delegate to be called by the {@link StoreApiController}}.
|
||||||
|
* Implement this interface with a {@link org.springframework.stereotype.Service} annotated class.
|
||||||
|
*/
|
||||||
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
|
public interface StoreApiDelegate {
|
||||||
|
|
||||||
|
default Optional<NativeWebRequest> getRequest() {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DELETE /store/order/{orderId} : Delete purchase order by ID
|
||||||
|
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
|
*
|
||||||
|
* @param orderId ID of the order that needs to be deleted (required)
|
||||||
|
* @return Invalid ID supplied (status code 400)
|
||||||
|
* or Order not found (status code 404)
|
||||||
|
* @see StoreApi#deleteOrder
|
||||||
|
*/
|
||||||
|
default Void deleteOrder(String orderId) {
|
||||||
|
throw new IllegalArgumentException("Not implemented");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /store/inventory : Returns pet inventories by status
|
||||||
|
* Returns a map of status codes to quantities
|
||||||
|
*
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
* @see StoreApi#getInventory
|
||||||
|
*/
|
||||||
|
default Map<String, Integer> getInventory() {
|
||||||
|
throw new IllegalArgumentException("Not implemented");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /store/order/{orderId} : Find purchase order by ID
|
||||||
|
* For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions
|
||||||
|
*
|
||||||
|
* @param orderId ID of pet that needs to be fetched (required)
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
* or Invalid ID supplied (status code 400)
|
||||||
|
* or Order not found (status code 404)
|
||||||
|
* @see StoreApi#getOrderById
|
||||||
|
*/
|
||||||
|
default Order getOrderById(Long orderId) {
|
||||||
|
getRequest().ifPresent(request -> {
|
||||||
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
|
String exampleString = "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\" }";
|
||||||
|
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
String exampleString = "<Order> <id>123456789</id> <petId>123456789</petId> <quantity>123</quantity> <shipDate>2000-01-23T04:56:07.000Z</shipDate> <status>aeiou</status> <complete>true</complete> </Order>";
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
throw new IllegalArgumentException("Not implemented");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POST /store/order : Place an order for a pet
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param order order placed for purchasing the pet (required)
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
* or Invalid Order (status code 400)
|
||||||
|
* @see StoreApi#placeOrder
|
||||||
|
*/
|
||||||
|
default Order placeOrder(Order order) {
|
||||||
|
getRequest().ifPresent(request -> {
|
||||||
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
|
String exampleString = "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\" }";
|
||||||
|
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
String exampleString = "<Order> <id>123456789</id> <petId>123456789</petId> <quantity>123</quantity> <shipDate>2000-01-23T04:56:07.000Z</shipDate> <status>aeiou</status> <complete>true</complete> </Order>";
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
throw new IllegalArgumentException("Not implemented");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,294 @@
|
|||||||
|
/**
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (6.5.0-SNAPSHOT).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
package org.openapitools.api;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.time.OffsetDateTime;
|
||||||
|
import org.openapitools.model.User;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
|
||||||
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
|
@Validated
|
||||||
|
@Api(value = "user", description = "Operations about user")
|
||||||
|
public interface UserApi {
|
||||||
|
|
||||||
|
default UserApiDelegate getDelegate() {
|
||||||
|
return new UserApiDelegate() {};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POST /user : Create user
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
*
|
||||||
|
* @param user Created user object (required)
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
*/
|
||||||
|
@ApiOperation(
|
||||||
|
tags = { "user" },
|
||||||
|
value = "Create user",
|
||||||
|
nickname = "createUser",
|
||||||
|
notes = "This can only be done by the logged in user.",
|
||||||
|
authorizations = {
|
||||||
|
@Authorization(value = "api_key")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses({
|
||||||
|
@ApiResponse(code = 200, message = "successful operation")
|
||||||
|
})
|
||||||
|
@RequestMapping(
|
||||||
|
method = RequestMethod.POST,
|
||||||
|
value = "/user",
|
||||||
|
consumes = { "application/json" }
|
||||||
|
)
|
||||||
|
@ResponseStatus(HttpStatus.OK)
|
||||||
|
default Void createUser(
|
||||||
|
@ApiParam(value = "Created user object", required = true) @Valid @RequestBody User user
|
||||||
|
) {
|
||||||
|
return getDelegate().createUser(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POST /user/createWithArray : Creates list of users with given input array
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param user List of user object (required)
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
*/
|
||||||
|
@ApiOperation(
|
||||||
|
tags = { "user" },
|
||||||
|
value = "Creates list of users with given input array",
|
||||||
|
nickname = "createUsersWithArrayInput",
|
||||||
|
notes = "",
|
||||||
|
authorizations = {
|
||||||
|
@Authorization(value = "api_key")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses({
|
||||||
|
@ApiResponse(code = 200, message = "successful operation")
|
||||||
|
})
|
||||||
|
@RequestMapping(
|
||||||
|
method = RequestMethod.POST,
|
||||||
|
value = "/user/createWithArray",
|
||||||
|
consumes = { "application/json" }
|
||||||
|
)
|
||||||
|
@ResponseStatus(HttpStatus.OK)
|
||||||
|
default Void createUsersWithArrayInput(
|
||||||
|
@ApiParam(value = "List of user object", required = true) @Valid @RequestBody List<User> user
|
||||||
|
) {
|
||||||
|
return getDelegate().createUsersWithArrayInput(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POST /user/createWithList : Creates list of users with given input array
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param user List of user object (required)
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
*/
|
||||||
|
@ApiOperation(
|
||||||
|
tags = { "user" },
|
||||||
|
value = "Creates list of users with given input array",
|
||||||
|
nickname = "createUsersWithListInput",
|
||||||
|
notes = "",
|
||||||
|
authorizations = {
|
||||||
|
@Authorization(value = "api_key")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses({
|
||||||
|
@ApiResponse(code = 200, message = "successful operation")
|
||||||
|
})
|
||||||
|
@RequestMapping(
|
||||||
|
method = RequestMethod.POST,
|
||||||
|
value = "/user/createWithList",
|
||||||
|
consumes = { "application/json" }
|
||||||
|
)
|
||||||
|
@ResponseStatus(HttpStatus.OK)
|
||||||
|
default Void createUsersWithListInput(
|
||||||
|
@ApiParam(value = "List of user object", required = true) @Valid @RequestBody List<User> user
|
||||||
|
) {
|
||||||
|
return getDelegate().createUsersWithListInput(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DELETE /user/{username} : Delete user
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
*
|
||||||
|
* @param username The name that needs to be deleted (required)
|
||||||
|
* @return Invalid username supplied (status code 400)
|
||||||
|
* or User not found (status code 404)
|
||||||
|
*/
|
||||||
|
@ApiOperation(
|
||||||
|
tags = { "user" },
|
||||||
|
value = "Delete user",
|
||||||
|
nickname = "deleteUser",
|
||||||
|
notes = "This can only be done by the logged in user.",
|
||||||
|
authorizations = {
|
||||||
|
@Authorization(value = "api_key")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses({
|
||||||
|
@ApiResponse(code = 400, message = "Invalid username supplied"),
|
||||||
|
@ApiResponse(code = 404, message = "User not found")
|
||||||
|
})
|
||||||
|
@RequestMapping(
|
||||||
|
method = RequestMethod.DELETE,
|
||||||
|
value = "/user/{username}"
|
||||||
|
)
|
||||||
|
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||||
|
default Void deleteUser(
|
||||||
|
@ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username
|
||||||
|
) {
|
||||||
|
return getDelegate().deleteUser(username);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /user/{username} : Get user by user name
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param username The name that needs to be fetched. Use user1 for testing. (required)
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
* or Invalid username supplied (status code 400)
|
||||||
|
* or User not found (status code 404)
|
||||||
|
*/
|
||||||
|
@ApiOperation(
|
||||||
|
tags = { "user" },
|
||||||
|
value = "Get user by user name",
|
||||||
|
nickname = "getUserByName",
|
||||||
|
notes = "",
|
||||||
|
response = User.class
|
||||||
|
)
|
||||||
|
@ApiResponses({
|
||||||
|
@ApiResponse(code = 200, message = "successful operation", response = User.class),
|
||||||
|
@ApiResponse(code = 400, message = "Invalid username supplied"),
|
||||||
|
@ApiResponse(code = 404, message = "User not found")
|
||||||
|
})
|
||||||
|
@RequestMapping(
|
||||||
|
method = RequestMethod.GET,
|
||||||
|
value = "/user/{username}",
|
||||||
|
produces = { "application/xml", "application/json" }
|
||||||
|
)
|
||||||
|
@ResponseStatus(HttpStatus.OK)
|
||||||
|
default User getUserByName(
|
||||||
|
@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username
|
||||||
|
) {
|
||||||
|
return getDelegate().getUserByName(username);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /user/login : Logs user into the system
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param username The user name for login (required)
|
||||||
|
* @param password The password for login in clear text (required)
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
* or Invalid username/password supplied (status code 400)
|
||||||
|
*/
|
||||||
|
@ApiOperation(
|
||||||
|
tags = { "user" },
|
||||||
|
value = "Logs user into the system",
|
||||||
|
nickname = "loginUser",
|
||||||
|
notes = "",
|
||||||
|
response = String.class
|
||||||
|
)
|
||||||
|
@ApiResponses({
|
||||||
|
@ApiResponse(code = 200, message = "successful operation", response = String.class),
|
||||||
|
@ApiResponse(code = 400, message = "Invalid username/password supplied")
|
||||||
|
})
|
||||||
|
@RequestMapping(
|
||||||
|
method = RequestMethod.GET,
|
||||||
|
value = "/user/login",
|
||||||
|
produces = { "application/xml", "application/json" }
|
||||||
|
)
|
||||||
|
@ResponseStatus(HttpStatus.OK)
|
||||||
|
default String loginUser(
|
||||||
|
@NotNull @Pattern(regexp = "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,
|
||||||
|
@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password
|
||||||
|
) {
|
||||||
|
return getDelegate().loginUser(username, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /user/logout : Logs out current logged in user session
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
*/
|
||||||
|
@ApiOperation(
|
||||||
|
tags = { "user" },
|
||||||
|
value = "Logs out current logged in user session",
|
||||||
|
nickname = "logoutUser",
|
||||||
|
notes = "",
|
||||||
|
authorizations = {
|
||||||
|
@Authorization(value = "api_key")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses({
|
||||||
|
@ApiResponse(code = 200, message = "successful operation")
|
||||||
|
})
|
||||||
|
@RequestMapping(
|
||||||
|
method = RequestMethod.GET,
|
||||||
|
value = "/user/logout"
|
||||||
|
)
|
||||||
|
@ResponseStatus(HttpStatus.OK)
|
||||||
|
default Void logoutUser(
|
||||||
|
|
||||||
|
) {
|
||||||
|
return getDelegate().logoutUser();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PUT /user/{username} : Updated user
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
*
|
||||||
|
* @param username name that need to be deleted (required)
|
||||||
|
* @param user Updated user object (required)
|
||||||
|
* @return Invalid user supplied (status code 400)
|
||||||
|
* or User not found (status code 404)
|
||||||
|
*/
|
||||||
|
@ApiOperation(
|
||||||
|
tags = { "user" },
|
||||||
|
value = "Updated user",
|
||||||
|
nickname = "updateUser",
|
||||||
|
notes = "This can only be done by the logged in user.",
|
||||||
|
authorizations = {
|
||||||
|
@Authorization(value = "api_key")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses({
|
||||||
|
@ApiResponse(code = 400, message = "Invalid user supplied"),
|
||||||
|
@ApiResponse(code = 404, message = "User not found")
|
||||||
|
})
|
||||||
|
@RequestMapping(
|
||||||
|
method = RequestMethod.PUT,
|
||||||
|
value = "/user/{username}",
|
||||||
|
consumes = { "application/json" }
|
||||||
|
)
|
||||||
|
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||||
|
default Void updateUser(
|
||||||
|
@ApiParam(value = "name that need to be deleted", required = true) @PathVariable("username") String username,
|
||||||
|
@ApiParam(value = "Updated user object", required = true) @Valid @RequestBody User user
|
||||||
|
) {
|
||||||
|
return getDelegate().updateUser(username, user);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package org.openapitools.api;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.time.OffsetDateTime;
|
||||||
|
import org.openapitools.model.User;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.CookieValue;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
|
||||||
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
||||||
|
public class UserApiController implements UserApi {
|
||||||
|
|
||||||
|
private final UserApiDelegate delegate;
|
||||||
|
|
||||||
|
public UserApiController(@Autowired(required = false) UserApiDelegate delegate) {
|
||||||
|
this.delegate = Optional.ofNullable(delegate).orElse(new UserApiDelegate() {});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserApiDelegate getDelegate() {
|
||||||
|
return delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,153 @@
|
|||||||
|
package org.openapitools.api;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.time.OffsetDateTime;
|
||||||
|
import org.openapitools.model.User;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A delegate to be called by the {@link UserApiController}}.
|
||||||
|
* Implement this interface with a {@link org.springframework.stereotype.Service} annotated class.
|
||||||
|
*/
|
||||||
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
|
public interface UserApiDelegate {
|
||||||
|
|
||||||
|
default Optional<NativeWebRequest> getRequest() {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POST /user : Create user
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
*
|
||||||
|
* @param user Created user object (required)
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
* @see UserApi#createUser
|
||||||
|
*/
|
||||||
|
default Void createUser(User user) {
|
||||||
|
throw new IllegalArgumentException("Not implemented");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POST /user/createWithArray : Creates list of users with given input array
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param user List of user object (required)
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
* @see UserApi#createUsersWithArrayInput
|
||||||
|
*/
|
||||||
|
default Void createUsersWithArrayInput(List<User> user) {
|
||||||
|
throw new IllegalArgumentException("Not implemented");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POST /user/createWithList : Creates list of users with given input array
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param user List of user object (required)
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
* @see UserApi#createUsersWithListInput
|
||||||
|
*/
|
||||||
|
default Void createUsersWithListInput(List<User> user) {
|
||||||
|
throw new IllegalArgumentException("Not implemented");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DELETE /user/{username} : Delete user
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
*
|
||||||
|
* @param username The name that needs to be deleted (required)
|
||||||
|
* @return Invalid username supplied (status code 400)
|
||||||
|
* or User not found (status code 404)
|
||||||
|
* @see UserApi#deleteUser
|
||||||
|
*/
|
||||||
|
default Void deleteUser(String username) {
|
||||||
|
throw new IllegalArgumentException("Not implemented");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /user/{username} : Get user by user name
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param username The name that needs to be fetched. Use user1 for testing. (required)
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
* or Invalid username supplied (status code 400)
|
||||||
|
* or User not found (status code 404)
|
||||||
|
* @see UserApi#getUserByName
|
||||||
|
*/
|
||||||
|
default User getUserByName(String username) {
|
||||||
|
getRequest().ifPresent(request -> {
|
||||||
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
|
String exampleString = "{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\" }";
|
||||||
|
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
String exampleString = "<User> <id>123456789</id> <username>aeiou</username> <firstName>aeiou</firstName> <lastName>aeiou</lastName> <email>aeiou</email> <password>aeiou</password> <phone>aeiou</phone> <userStatus>123</userStatus> </User>";
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
throw new IllegalArgumentException("Not implemented");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /user/login : Logs user into the system
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param username The user name for login (required)
|
||||||
|
* @param password The password for login in clear text (required)
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
* or Invalid username/password supplied (status code 400)
|
||||||
|
* @see UserApi#loginUser
|
||||||
|
*/
|
||||||
|
default String loginUser(String username,
|
||||||
|
String password) {
|
||||||
|
throw new IllegalArgumentException("Not implemented");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /user/logout : Logs out current logged in user session
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return successful operation (status code 200)
|
||||||
|
* @see UserApi#logoutUser
|
||||||
|
*/
|
||||||
|
default Void logoutUser() {
|
||||||
|
throw new IllegalArgumentException("Not implemented");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PUT /user/{username} : Updated user
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
*
|
||||||
|
* @param username name that need to be deleted (required)
|
||||||
|
* @param user Updated user object (required)
|
||||||
|
* @return Invalid user supplied (status code 400)
|
||||||
|
* or User not found (status code 404)
|
||||||
|
* @see UserApi#updateUser
|
||||||
|
*/
|
||||||
|
default Void updateUser(String username,
|
||||||
|
User user) {
|
||||||
|
throw new IllegalArgumentException("Not implemented");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package org.openapitools.configuration;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Home redirection to OpenAPI api documentation
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
public class HomeController {
|
||||||
|
|
||||||
|
static final String API_DOCS_PATH = "/v2/api-docs";
|
||||||
|
|
||||||
|
@GetMapping(value = "/swagger-config.yaml", produces = "text/plain")
|
||||||
|
@ResponseBody
|
||||||
|
public String swaggerConfig() {
|
||||||
|
return "url: " + API_DOCS_PATH + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/")
|
||||||
|
public String index() {
|
||||||
|
return "redirect:swagger-ui.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
package org.openapitools.configuration;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import org.springframework.web.util.UriComponentsBuilder;
|
||||||
|
import springfox.documentation.builders.ApiInfoBuilder;
|
||||||
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
|
import springfox.documentation.service.ApiInfo;
|
||||||
|
import springfox.documentation.service.Contact;
|
||||||
|
import springfox.documentation.spi.DocumentationType;
|
||||||
|
import springfox.documentation.spring.web.paths.Paths;
|
||||||
|
import springfox.documentation.spring.web.paths.RelativePathProvider;
|
||||||
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
|
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||||
|
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
|
|
||||||
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
|
@Configuration
|
||||||
|
@EnableSwagger2
|
||||||
|
public class SpringFoxConfiguration {
|
||||||
|
|
||||||
|
ApiInfo apiInfo() {
|
||||||
|
return new ApiInfoBuilder()
|
||||||
|
.title("OpenAPI Petstore")
|
||||||
|
.description("This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.")
|
||||||
|
.license("Apache-2.0")
|
||||||
|
.licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html")
|
||||||
|
.termsOfServiceUrl("")
|
||||||
|
.version("1.0.0")
|
||||||
|
.contact(new Contact("","", ""))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) {
|
||||||
|
return new Docket(DocumentationType.SWAGGER_2)
|
||||||
|
.select()
|
||||||
|
.apis(RequestHandlerSelectors.basePackage("org.openapitools.api"))
|
||||||
|
.build()
|
||||||
|
.pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath))
|
||||||
|
.directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class)
|
||||||
|
.directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class)
|
||||||
|
.apiInfo(apiInfo());
|
||||||
|
}
|
||||||
|
|
||||||
|
class BasePathAwareRelativePathProvider extends RelativePathProvider {
|
||||||
|
private String basePath;
|
||||||
|
|
||||||
|
public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) {
|
||||||
|
super(servletContext);
|
||||||
|
this.basePath = basePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String applicationPath() {
|
||||||
|
return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getOperationPath(String operationPath) {
|
||||||
|
UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/");
|
||||||
|
return Paths.removeAdjacentForwardSlashes(
|
||||||
|
uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,109 @@
|
|||||||
|
package org.openapitools.model;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Objects;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import org.openapitools.jackson.nullable.JsonNullable;
|
||||||
|
import java.time.OffsetDateTime;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A category for a pet
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModel(description = "A category for a pet")
|
||||||
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
|
public class Category {
|
||||||
|
|
||||||
|
@JsonProperty("id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@JsonProperty("name")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public Category id(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get id
|
||||||
|
* @return id
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Category name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get name
|
||||||
|
* @return name
|
||||||
|
*/
|
||||||
|
@Pattern(regexp = "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$")
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Category category = (Category) o;
|
||||||
|
return Objects.equals(this.id, category.id) &&
|
||||||
|
Objects.equals(this.name, category.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("class Category {\n");
|
||||||
|
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||||
|
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||||
|
sb.append("}");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given object to string with each line indented by 4 spaces
|
||||||
|
* (except the first line).
|
||||||
|
*/
|
||||||
|
private String toIndentedString(Object o) {
|
||||||
|
if (o == null) {
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
return o.toString().replace("\n", "\n ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,135 @@
|
|||||||
|
package org.openapitools.model;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Objects;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import org.openapitools.jackson.nullable.JsonNullable;
|
||||||
|
import java.time.OffsetDateTime;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Describes the result of uploading an image resource
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModel(description = "Describes the result of uploading an image resource")
|
||||||
|
@JsonTypeName("ApiResponse")
|
||||||
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
|
public class ModelApiResponse {
|
||||||
|
|
||||||
|
@JsonProperty("code")
|
||||||
|
private Integer code;
|
||||||
|
|
||||||
|
@JsonProperty("type")
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
@JsonProperty("message")
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
public ModelApiResponse code(Integer code) {
|
||||||
|
this.code = code;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get code
|
||||||
|
* @return code
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
public Integer getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(Integer code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ModelApiResponse type(String type) {
|
||||||
|
this.type = type;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get type
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ModelApiResponse message(String message) {
|
||||||
|
this.message = message;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get message
|
||||||
|
* @return message
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
ModelApiResponse _apiResponse = (ModelApiResponse) o;
|
||||||
|
return Objects.equals(this.code, _apiResponse.code) &&
|
||||||
|
Objects.equals(this.type, _apiResponse.type) &&
|
||||||
|
Objects.equals(this.message, _apiResponse.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(code, type, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("class ModelApiResponse {\n");
|
||||||
|
sb.append(" code: ").append(toIndentedString(code)).append("\n");
|
||||||
|
sb.append(" type: ").append(toIndentedString(type)).append("\n");
|
||||||
|
sb.append(" message: ").append(toIndentedString(message)).append("\n");
|
||||||
|
sb.append("}");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given object to string with each line indented by 4 spaces
|
||||||
|
* (except the first line).
|
||||||
|
*/
|
||||||
|
private String toIndentedString(Object o) {
|
||||||
|
if (o == null) {
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
return o.toString().replace("\n", "\n ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,246 @@
|
|||||||
|
package org.openapitools.model;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Objects;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import java.time.OffsetDateTime;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import org.openapitools.jackson.nullable.JsonNullable;
|
||||||
|
import java.time.OffsetDateTime;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An order for a pets from the pet store
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModel(description = "An order for a pets from the pet store")
|
||||||
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
|
public class Order {
|
||||||
|
|
||||||
|
@JsonProperty("id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@JsonProperty("petId")
|
||||||
|
private Long petId;
|
||||||
|
|
||||||
|
@JsonProperty("quantity")
|
||||||
|
private Integer quantity;
|
||||||
|
|
||||||
|
@JsonProperty("shipDate")
|
||||||
|
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
|
||||||
|
private OffsetDateTime shipDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Order Status
|
||||||
|
*/
|
||||||
|
public enum StatusEnum {
|
||||||
|
PLACED("placed"),
|
||||||
|
|
||||||
|
APPROVED("approved"),
|
||||||
|
|
||||||
|
DELIVERED("delivered");
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
StatusEnum(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonValue
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.valueOf(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonCreator
|
||||||
|
public static StatusEnum fromValue(String value) {
|
||||||
|
for (StatusEnum b : StatusEnum.values()) {
|
||||||
|
if (b.value.equals(value)) {
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonProperty("status")
|
||||||
|
private StatusEnum status;
|
||||||
|
|
||||||
|
@JsonProperty("complete")
|
||||||
|
private Boolean complete = false;
|
||||||
|
|
||||||
|
public Order id(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get id
|
||||||
|
* @return id
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Order petId(Long petId) {
|
||||||
|
this.petId = petId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get petId
|
||||||
|
* @return petId
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
public Long getPetId() {
|
||||||
|
return petId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPetId(Long petId) {
|
||||||
|
this.petId = petId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Order quantity(Integer quantity) {
|
||||||
|
this.quantity = quantity;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get quantity
|
||||||
|
* @return quantity
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
public Integer getQuantity() {
|
||||||
|
return quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuantity(Integer quantity) {
|
||||||
|
this.quantity = quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Order shipDate(OffsetDateTime shipDate) {
|
||||||
|
this.shipDate = shipDate;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get shipDate
|
||||||
|
* @return shipDate
|
||||||
|
*/
|
||||||
|
@Valid
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
public OffsetDateTime getShipDate() {
|
||||||
|
return shipDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShipDate(OffsetDateTime shipDate) {
|
||||||
|
this.shipDate = shipDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Order status(StatusEnum status) {
|
||||||
|
this.status = status;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Order Status
|
||||||
|
* @return status
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "Order Status")
|
||||||
|
public StatusEnum getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(StatusEnum status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Order complete(Boolean complete) {
|
||||||
|
this.complete = complete;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get complete
|
||||||
|
* @return complete
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
public Boolean getComplete() {
|
||||||
|
return complete;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComplete(Boolean complete) {
|
||||||
|
this.complete = complete;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Order order = (Order) o;
|
||||||
|
return Objects.equals(this.id, order.id) &&
|
||||||
|
Objects.equals(this.petId, order.petId) &&
|
||||||
|
Objects.equals(this.quantity, order.quantity) &&
|
||||||
|
Objects.equals(this.shipDate, order.shipDate) &&
|
||||||
|
Objects.equals(this.status, order.status) &&
|
||||||
|
Objects.equals(this.complete, order.complete);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id, petId, quantity, shipDate, status, complete);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("class Order {\n");
|
||||||
|
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||||
|
sb.append(" petId: ").append(toIndentedString(petId)).append("\n");
|
||||||
|
sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n");
|
||||||
|
sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n");
|
||||||
|
sb.append(" status: ").append(toIndentedString(status)).append("\n");
|
||||||
|
sb.append(" complete: ").append(toIndentedString(complete)).append("\n");
|
||||||
|
sb.append("}");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given object to string with each line indented by 4 spaces
|
||||||
|
* (except the first line).
|
||||||
|
*/
|
||||||
|
private String toIndentedString(Object o) {
|
||||||
|
if (o == null) {
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
return o.toString().replace("\n", "\n ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,279 @@
|
|||||||
|
package org.openapitools.model;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Objects;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import org.openapitools.model.Category;
|
||||||
|
import org.openapitools.model.Tag;
|
||||||
|
import org.openapitools.jackson.nullable.JsonNullable;
|
||||||
|
import java.time.OffsetDateTime;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A pet for sale in the pet store
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModel(description = "A pet for sale in the pet store")
|
||||||
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
|
public class Pet {
|
||||||
|
|
||||||
|
@JsonProperty("id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@JsonProperty("category")
|
||||||
|
private Category category;
|
||||||
|
|
||||||
|
@JsonProperty("name")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@JsonProperty("photoUrls")
|
||||||
|
@Valid
|
||||||
|
private List<String> photoUrls = new ArrayList<>();
|
||||||
|
|
||||||
|
@JsonProperty("tags")
|
||||||
|
@Valid
|
||||||
|
private List<@Valid Tag> tags = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pet status in the store
|
||||||
|
*/
|
||||||
|
public enum StatusEnum {
|
||||||
|
AVAILABLE("available"),
|
||||||
|
|
||||||
|
PENDING("pending"),
|
||||||
|
|
||||||
|
SOLD("sold");
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
StatusEnum(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonValue
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.valueOf(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonCreator
|
||||||
|
public static StatusEnum fromValue(String value) {
|
||||||
|
for (StatusEnum b : StatusEnum.values()) {
|
||||||
|
if (b.value.equals(value)) {
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonProperty("status")
|
||||||
|
private StatusEnum status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor
|
||||||
|
* @deprecated Use {@link Pet#Pet(String, List<String>)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public Pet() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor with only required parameters
|
||||||
|
*/
|
||||||
|
public Pet(String name, List<String> photoUrls) {
|
||||||
|
this.name = name;
|
||||||
|
this.photoUrls = photoUrls;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pet id(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get id
|
||||||
|
* @return id
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pet category(Category category) {
|
||||||
|
this.category = category;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get category
|
||||||
|
* @return category
|
||||||
|
*/
|
||||||
|
@Valid
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
public Category getCategory() {
|
||||||
|
return category;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategory(Category category) {
|
||||||
|
this.category = category;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pet name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get name
|
||||||
|
* @return name
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
@ApiModelProperty(example = "doggie", required = true, value = "")
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pet photoUrls(List<String> photoUrls) {
|
||||||
|
this.photoUrls = photoUrls;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pet addPhotoUrlsItem(String photoUrlsItem) {
|
||||||
|
this.photoUrls.add(photoUrlsItem);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get photoUrls
|
||||||
|
* @return photoUrls
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
@ApiModelProperty(required = true, value = "")
|
||||||
|
public List<String> getPhotoUrls() {
|
||||||
|
return photoUrls;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhotoUrls(List<String> photoUrls) {
|
||||||
|
this.photoUrls = photoUrls;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pet tags(List<@Valid Tag> tags) {
|
||||||
|
this.tags = tags;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pet addTagsItem(Tag tagsItem) {
|
||||||
|
if (this.tags == null) {
|
||||||
|
this.tags = new ArrayList<>();
|
||||||
|
}
|
||||||
|
this.tags.add(tagsItem);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get tags
|
||||||
|
* @return tags
|
||||||
|
*/
|
||||||
|
@Valid
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
public List<@Valid Tag> getTags() {
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTags(List<@Valid Tag> tags) {
|
||||||
|
this.tags = tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pet status(StatusEnum status) {
|
||||||
|
this.status = status;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pet status in the store
|
||||||
|
* @return status
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "pet status in the store")
|
||||||
|
public StatusEnum getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(StatusEnum status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Pet pet = (Pet) o;
|
||||||
|
return Objects.equals(this.id, pet.id) &&
|
||||||
|
Objects.equals(this.category, pet.category) &&
|
||||||
|
Objects.equals(this.name, pet.name) &&
|
||||||
|
Objects.equals(this.photoUrls, pet.photoUrls) &&
|
||||||
|
Objects.equals(this.tags, pet.tags) &&
|
||||||
|
Objects.equals(this.status, pet.status);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id, category, name, photoUrls, tags, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("class Pet {\n");
|
||||||
|
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||||
|
sb.append(" category: ").append(toIndentedString(category)).append("\n");
|
||||||
|
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||||
|
sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n");
|
||||||
|
sb.append(" tags: ").append(toIndentedString(tags)).append("\n");
|
||||||
|
sb.append(" status: ").append(toIndentedString(status)).append("\n");
|
||||||
|
sb.append("}");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given object to string with each line indented by 4 spaces
|
||||||
|
* (except the first line).
|
||||||
|
*/
|
||||||
|
private String toIndentedString(Object o) {
|
||||||
|
if (o == null) {
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
return o.toString().replace("\n", "\n ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,109 @@
|
|||||||
|
package org.openapitools.model;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Objects;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import org.openapitools.jackson.nullable.JsonNullable;
|
||||||
|
import java.time.OffsetDateTime;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A tag for a pet
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModel(description = "A tag for a pet")
|
||||||
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
|
public class Tag {
|
||||||
|
|
||||||
|
@JsonProperty("id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@JsonProperty("name")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public Tag id(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get id
|
||||||
|
* @return id
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Tag name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get name
|
||||||
|
* @return name
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Tag tag = (Tag) o;
|
||||||
|
return Objects.equals(this.id, tag.id) &&
|
||||||
|
Objects.equals(this.name, tag.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("class Tag {\n");
|
||||||
|
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||||
|
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||||
|
sb.append("}");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given object to string with each line indented by 4 spaces
|
||||||
|
* (except the first line).
|
||||||
|
*/
|
||||||
|
private String toIndentedString(Object o) {
|
||||||
|
if (o == null) {
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
return o.toString().replace("\n", "\n ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,253 @@
|
|||||||
|
package org.openapitools.model;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Objects;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import org.openapitools.jackson.nullable.JsonNullable;
|
||||||
|
import java.time.OffsetDateTime;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A User who is purchasing from the pet store
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModel(description = "A User who is purchasing from the pet store")
|
||||||
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
|
public class User {
|
||||||
|
|
||||||
|
@JsonProperty("id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@JsonProperty("username")
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
@JsonProperty("firstName")
|
||||||
|
private String firstName;
|
||||||
|
|
||||||
|
@JsonProperty("lastName")
|
||||||
|
private String lastName;
|
||||||
|
|
||||||
|
@JsonProperty("email")
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
@JsonProperty("password")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
@JsonProperty("phone")
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
@JsonProperty("userStatus")
|
||||||
|
private Integer userStatus;
|
||||||
|
|
||||||
|
public User id(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get id
|
||||||
|
* @return id
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User username(String username) {
|
||||||
|
this.username = username;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get username
|
||||||
|
* @return username
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User firstName(String firstName) {
|
||||||
|
this.firstName = firstName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get firstName
|
||||||
|
* @return firstName
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
public String getFirstName() {
|
||||||
|
return firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFirstName(String firstName) {
|
||||||
|
this.firstName = firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User lastName(String lastName) {
|
||||||
|
this.lastName = lastName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get lastName
|
||||||
|
* @return lastName
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
public String getLastName() {
|
||||||
|
return lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastName(String lastName) {
|
||||||
|
this.lastName = lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User email(String email) {
|
||||||
|
this.email = email;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get email
|
||||||
|
* @return email
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User password(String password) {
|
||||||
|
this.password = password;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get password
|
||||||
|
* @return password
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User phone(String phone) {
|
||||||
|
this.phone = phone;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get phone
|
||||||
|
* @return phone
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
public String getPhone() {
|
||||||
|
return phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhone(String phone) {
|
||||||
|
this.phone = phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User userStatus(Integer userStatus) {
|
||||||
|
this.userStatus = userStatus;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User Status
|
||||||
|
* @return userStatus
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "User Status")
|
||||||
|
public Integer getUserStatus() {
|
||||||
|
return userStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserStatus(Integer userStatus) {
|
||||||
|
this.userStatus = userStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
User user = (User) o;
|
||||||
|
return Objects.equals(this.id, user.id) &&
|
||||||
|
Objects.equals(this.username, user.username) &&
|
||||||
|
Objects.equals(this.firstName, user.firstName) &&
|
||||||
|
Objects.equals(this.lastName, user.lastName) &&
|
||||||
|
Objects.equals(this.email, user.email) &&
|
||||||
|
Objects.equals(this.password, user.password) &&
|
||||||
|
Objects.equals(this.phone, user.phone) &&
|
||||||
|
Objects.equals(this.userStatus, user.userStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("class User {\n");
|
||||||
|
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||||
|
sb.append(" username: ").append(toIndentedString(username)).append("\n");
|
||||||
|
sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n");
|
||||||
|
sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n");
|
||||||
|
sb.append(" email: ").append(toIndentedString(email)).append("\n");
|
||||||
|
sb.append(" password: ").append(toIndentedString(password)).append("\n");
|
||||||
|
sb.append(" phone: ").append(toIndentedString(phone)).append("\n");
|
||||||
|
sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n");
|
||||||
|
sb.append("}");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given object to string with each line indented by 4 spaces
|
||||||
|
* (except the first line).
|
||||||
|
*/
|
||||||
|
private String toIndentedString(Object o) {
|
||||||
|
if (o == null) {
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
return o.toString().replace("\n", "\n ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
|||||||
|
server.port=8080
|
||||||
|
spring.jackson.date-format=org.openapitools.RFC3339DateFormat
|
||||||
|
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false
|
@ -0,0 +1,880 @@
|
|||||||
|
openapi: 3.0.0
|
||||||
|
info:
|
||||||
|
description: "This is a sample server Petstore server. For this sample, you can\
|
||||||
|
\ use the api key `special-key` to test the authorization filters."
|
||||||
|
license:
|
||||||
|
name: Apache-2.0
|
||||||
|
url: https://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
title: OpenAPI Petstore
|
||||||
|
version: 1.0.0
|
||||||
|
externalDocs:
|
||||||
|
description: Find out more about Swagger
|
||||||
|
url: http://swagger.io
|
||||||
|
servers:
|
||||||
|
- url: http://petstore.swagger.io/v2
|
||||||
|
tags:
|
||||||
|
- description: Everything about your Pets
|
||||||
|
name: pet
|
||||||
|
- description: Access to Petstore orders
|
||||||
|
name: store
|
||||||
|
- description: Operations about user
|
||||||
|
name: user
|
||||||
|
paths:
|
||||||
|
/pet:
|
||||||
|
post:
|
||||||
|
description: ""
|
||||||
|
operationId: addPet
|
||||||
|
requestBody:
|
||||||
|
$ref: '#/components/requestBodies/Pet'
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
content:
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
description: successful operation
|
||||||
|
"405":
|
||||||
|
description: Invalid input
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- write:pets
|
||||||
|
- read:pets
|
||||||
|
summary: Add a new pet to the store
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
x-content-type: application/json
|
||||||
|
x-accepts: application/json
|
||||||
|
x-tags:
|
||||||
|
- tag: pet
|
||||||
|
put:
|
||||||
|
description: ""
|
||||||
|
externalDocs:
|
||||||
|
description: API documentation for the updatePet operation
|
||||||
|
url: http://petstore.swagger.io/v2/doc/updatePet
|
||||||
|
operationId: updatePet
|
||||||
|
requestBody:
|
||||||
|
$ref: '#/components/requestBodies/Pet'
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
content:
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
description: successful operation
|
||||||
|
"400":
|
||||||
|
description: Invalid ID supplied
|
||||||
|
"404":
|
||||||
|
description: Pet not found
|
||||||
|
"405":
|
||||||
|
description: Validation exception
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- write:pets
|
||||||
|
- read:pets
|
||||||
|
summary: Update an existing pet
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
x-content-type: application/json
|
||||||
|
x-accepts: application/json
|
||||||
|
x-tags:
|
||||||
|
- tag: pet
|
||||||
|
/pet/findByStatus:
|
||||||
|
get:
|
||||||
|
description: Multiple status values can be provided with comma separated strings
|
||||||
|
operationId: findPetsByStatus
|
||||||
|
parameters:
|
||||||
|
- deprecated: true
|
||||||
|
description: Status values that need to be considered for filter
|
||||||
|
explode: false
|
||||||
|
in: query
|
||||||
|
name: status
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
items:
|
||||||
|
default: available
|
||||||
|
enum:
|
||||||
|
- available
|
||||||
|
- pending
|
||||||
|
- sold
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
|
style: form
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
content:
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
type: array
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
type: array
|
||||||
|
description: successful operation
|
||||||
|
"400":
|
||||||
|
description: Invalid status value
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- read:pets
|
||||||
|
summary: Finds Pets by status
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
x-accepts: application/json
|
||||||
|
x-tags:
|
||||||
|
- tag: pet
|
||||||
|
/pet/findByTags:
|
||||||
|
get:
|
||||||
|
deprecated: true
|
||||||
|
description: "Multiple tags can be provided with comma separated strings. Use\
|
||||||
|
\ tag1, tag2, tag3 for testing."
|
||||||
|
operationId: findPetsByTags
|
||||||
|
parameters:
|
||||||
|
- description: Tags to filter by
|
||||||
|
explode: false
|
||||||
|
in: query
|
||||||
|
name: tags
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
|
style: form
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
content:
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
type: array
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
type: array
|
||||||
|
description: successful operation
|
||||||
|
"400":
|
||||||
|
description: Invalid tag value
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- read:pets
|
||||||
|
summary: Finds Pets by tags
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
x-accepts: application/json
|
||||||
|
x-tags:
|
||||||
|
- tag: pet
|
||||||
|
/pet/{petId}:
|
||||||
|
delete:
|
||||||
|
description: ""
|
||||||
|
operationId: deletePet
|
||||||
|
parameters:
|
||||||
|
- explode: false
|
||||||
|
in: header
|
||||||
|
name: api_key
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
style: simple
|
||||||
|
- description: Pet id to delete
|
||||||
|
explode: false
|
||||||
|
in: path
|
||||||
|
name: petId
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
format: int64
|
||||||
|
type: integer
|
||||||
|
style: simple
|
||||||
|
responses:
|
||||||
|
"400":
|
||||||
|
description: Invalid pet value
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- write:pets
|
||||||
|
- read:pets
|
||||||
|
summary: Deletes a pet
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
x-accepts: application/json
|
||||||
|
x-tags:
|
||||||
|
- tag: pet
|
||||||
|
get:
|
||||||
|
description: Returns a single pet
|
||||||
|
operationId: getPetById
|
||||||
|
parameters:
|
||||||
|
- description: ID of pet to return
|
||||||
|
explode: false
|
||||||
|
in: path
|
||||||
|
name: petId
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
format: int64
|
||||||
|
type: integer
|
||||||
|
style: simple
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
content:
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
description: successful operation
|
||||||
|
"400":
|
||||||
|
description: Invalid ID supplied
|
||||||
|
"404":
|
||||||
|
description: Pet not found
|
||||||
|
security:
|
||||||
|
- api_key: []
|
||||||
|
summary: Find pet by ID
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
x-accepts: application/json
|
||||||
|
x-tags:
|
||||||
|
- tag: pet
|
||||||
|
post:
|
||||||
|
description: ""
|
||||||
|
operationId: updatePetWithForm
|
||||||
|
parameters:
|
||||||
|
- description: ID of pet that needs to be updated
|
||||||
|
explode: false
|
||||||
|
in: path
|
||||||
|
name: petId
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
format: int64
|
||||||
|
type: integer
|
||||||
|
style: simple
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/x-www-form-urlencoded:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/updatePetWithForm_request'
|
||||||
|
responses:
|
||||||
|
"405":
|
||||||
|
description: Invalid input
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- write:pets
|
||||||
|
- read:pets
|
||||||
|
summary: Updates a pet in the store with form data
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
x-content-type: application/x-www-form-urlencoded
|
||||||
|
x-accepts: application/json
|
||||||
|
x-tags:
|
||||||
|
- tag: pet
|
||||||
|
/pet/{petId}/uploadImage:
|
||||||
|
post:
|
||||||
|
description: ""
|
||||||
|
operationId: uploadFile
|
||||||
|
parameters:
|
||||||
|
- description: ID of pet to update
|
||||||
|
explode: false
|
||||||
|
in: path
|
||||||
|
name: petId
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
format: int64
|
||||||
|
type: integer
|
||||||
|
style: simple
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
multipart/form-data:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/uploadFile_request'
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/ApiResponse'
|
||||||
|
description: successful operation
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- write:pets
|
||||||
|
- read:pets
|
||||||
|
summary: uploads an image
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
x-content-type: multipart/form-data
|
||||||
|
x-accepts: application/json
|
||||||
|
x-tags:
|
||||||
|
- tag: pet
|
||||||
|
/store/inventory:
|
||||||
|
get:
|
||||||
|
description: Returns a map of status codes to quantities
|
||||||
|
operationId: getInventory
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
additionalProperties:
|
||||||
|
format: int32
|
||||||
|
type: integer
|
||||||
|
type: object
|
||||||
|
description: successful operation
|
||||||
|
security:
|
||||||
|
- api_key: []
|
||||||
|
summary: Returns pet inventories by status
|
||||||
|
tags:
|
||||||
|
- store
|
||||||
|
x-accepts: application/json
|
||||||
|
x-tags:
|
||||||
|
- tag: store
|
||||||
|
/store/order:
|
||||||
|
post:
|
||||||
|
description: ""
|
||||||
|
operationId: placeOrder
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Order'
|
||||||
|
description: order placed for purchasing the pet
|
||||||
|
required: true
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
content:
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Order'
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Order'
|
||||||
|
description: successful operation
|
||||||
|
"400":
|
||||||
|
description: Invalid Order
|
||||||
|
summary: Place an order for a pet
|
||||||
|
tags:
|
||||||
|
- store
|
||||||
|
x-content-type: application/json
|
||||||
|
x-accepts: application/json
|
||||||
|
x-tags:
|
||||||
|
- tag: store
|
||||||
|
/store/order/{orderId}:
|
||||||
|
delete:
|
||||||
|
description: For valid response try integer IDs with value < 1000. Anything
|
||||||
|
above 1000 or nonintegers will generate API errors
|
||||||
|
operationId: deleteOrder
|
||||||
|
parameters:
|
||||||
|
- description: ID of the order that needs to be deleted
|
||||||
|
explode: false
|
||||||
|
in: path
|
||||||
|
name: orderId
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
style: simple
|
||||||
|
responses:
|
||||||
|
"400":
|
||||||
|
description: Invalid ID supplied
|
||||||
|
"404":
|
||||||
|
description: Order not found
|
||||||
|
summary: Delete purchase order by ID
|
||||||
|
tags:
|
||||||
|
- store
|
||||||
|
x-accepts: application/json
|
||||||
|
x-tags:
|
||||||
|
- tag: store
|
||||||
|
get:
|
||||||
|
description: For valid response try integer IDs with value <= 5 or > 10. Other
|
||||||
|
values will generate exceptions
|
||||||
|
operationId: getOrderById
|
||||||
|
parameters:
|
||||||
|
- description: ID of pet that needs to be fetched
|
||||||
|
explode: false
|
||||||
|
in: path
|
||||||
|
name: orderId
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
format: int64
|
||||||
|
maximum: 5
|
||||||
|
minimum: 1
|
||||||
|
type: integer
|
||||||
|
style: simple
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
content:
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Order'
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Order'
|
||||||
|
description: successful operation
|
||||||
|
"400":
|
||||||
|
description: Invalid ID supplied
|
||||||
|
"404":
|
||||||
|
description: Order not found
|
||||||
|
summary: Find purchase order by ID
|
||||||
|
tags:
|
||||||
|
- store
|
||||||
|
x-accepts: application/json
|
||||||
|
x-tags:
|
||||||
|
- tag: store
|
||||||
|
/user:
|
||||||
|
post:
|
||||||
|
description: This can only be done by the logged in user.
|
||||||
|
operationId: createUser
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/User'
|
||||||
|
description: Created user object
|
||||||
|
required: true
|
||||||
|
responses:
|
||||||
|
default:
|
||||||
|
description: successful operation
|
||||||
|
security:
|
||||||
|
- api_key: []
|
||||||
|
summary: Create user
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
x-content-type: application/json
|
||||||
|
x-accepts: application/json
|
||||||
|
x-tags:
|
||||||
|
- tag: user
|
||||||
|
/user/createWithArray:
|
||||||
|
post:
|
||||||
|
description: ""
|
||||||
|
operationId: createUsersWithArrayInput
|
||||||
|
requestBody:
|
||||||
|
$ref: '#/components/requestBodies/UserArray'
|
||||||
|
responses:
|
||||||
|
default:
|
||||||
|
description: successful operation
|
||||||
|
security:
|
||||||
|
- api_key: []
|
||||||
|
summary: Creates list of users with given input array
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
x-content-type: application/json
|
||||||
|
x-accepts: application/json
|
||||||
|
x-tags:
|
||||||
|
- tag: user
|
||||||
|
/user/createWithList:
|
||||||
|
post:
|
||||||
|
description: ""
|
||||||
|
operationId: createUsersWithListInput
|
||||||
|
requestBody:
|
||||||
|
$ref: '#/components/requestBodies/UserArray'
|
||||||
|
responses:
|
||||||
|
default:
|
||||||
|
description: successful operation
|
||||||
|
security:
|
||||||
|
- api_key: []
|
||||||
|
summary: Creates list of users with given input array
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
x-content-type: application/json
|
||||||
|
x-accepts: application/json
|
||||||
|
x-tags:
|
||||||
|
- tag: user
|
||||||
|
/user/login:
|
||||||
|
get:
|
||||||
|
description: ""
|
||||||
|
operationId: loginUser
|
||||||
|
parameters:
|
||||||
|
- description: The user name for login
|
||||||
|
explode: true
|
||||||
|
in: query
|
||||||
|
name: username
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
pattern: "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$"
|
||||||
|
type: string
|
||||||
|
style: form
|
||||||
|
- description: The password for login in clear text
|
||||||
|
explode: true
|
||||||
|
in: query
|
||||||
|
name: password
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
style: form
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
content:
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
description: successful operation
|
||||||
|
headers:
|
||||||
|
Set-Cookie:
|
||||||
|
description: Cookie authentication key for use with the `api_key` apiKey
|
||||||
|
authentication.
|
||||||
|
explode: false
|
||||||
|
schema:
|
||||||
|
example: AUTH_KEY=abcde12345; Path=/; HttpOnly
|
||||||
|
type: string
|
||||||
|
style: simple
|
||||||
|
X-Rate-Limit:
|
||||||
|
description: calls per hour allowed by the user
|
||||||
|
explode: false
|
||||||
|
schema:
|
||||||
|
format: int32
|
||||||
|
type: integer
|
||||||
|
style: simple
|
||||||
|
X-Expires-After:
|
||||||
|
description: date in UTC when token expires
|
||||||
|
explode: false
|
||||||
|
schema:
|
||||||
|
format: date-time
|
||||||
|
type: string
|
||||||
|
style: simple
|
||||||
|
"400":
|
||||||
|
description: Invalid username/password supplied
|
||||||
|
summary: Logs user into the system
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
x-accepts: application/json
|
||||||
|
x-tags:
|
||||||
|
- tag: user
|
||||||
|
/user/logout:
|
||||||
|
get:
|
||||||
|
description: ""
|
||||||
|
operationId: logoutUser
|
||||||
|
responses:
|
||||||
|
default:
|
||||||
|
description: successful operation
|
||||||
|
security:
|
||||||
|
- api_key: []
|
||||||
|
summary: Logs out current logged in user session
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
x-accepts: application/json
|
||||||
|
x-tags:
|
||||||
|
- tag: user
|
||||||
|
/user/{username}:
|
||||||
|
delete:
|
||||||
|
description: This can only be done by the logged in user.
|
||||||
|
operationId: deleteUser
|
||||||
|
parameters:
|
||||||
|
- description: The name that needs to be deleted
|
||||||
|
explode: false
|
||||||
|
in: path
|
||||||
|
name: username
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
style: simple
|
||||||
|
responses:
|
||||||
|
"400":
|
||||||
|
description: Invalid username supplied
|
||||||
|
"404":
|
||||||
|
description: User not found
|
||||||
|
security:
|
||||||
|
- api_key: []
|
||||||
|
summary: Delete user
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
x-accepts: application/json
|
||||||
|
x-tags:
|
||||||
|
- tag: user
|
||||||
|
get:
|
||||||
|
description: ""
|
||||||
|
operationId: getUserByName
|
||||||
|
parameters:
|
||||||
|
- description: The name that needs to be fetched. Use user1 for testing.
|
||||||
|
explode: false
|
||||||
|
in: path
|
||||||
|
name: username
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
style: simple
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
content:
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/User'
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/User'
|
||||||
|
description: successful operation
|
||||||
|
"400":
|
||||||
|
description: Invalid username supplied
|
||||||
|
"404":
|
||||||
|
description: User not found
|
||||||
|
summary: Get user by user name
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
x-accepts: application/json
|
||||||
|
x-tags:
|
||||||
|
- tag: user
|
||||||
|
put:
|
||||||
|
description: This can only be done by the logged in user.
|
||||||
|
operationId: updateUser
|
||||||
|
parameters:
|
||||||
|
- description: name that need to be deleted
|
||||||
|
explode: false
|
||||||
|
in: path
|
||||||
|
name: username
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
style: simple
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/User'
|
||||||
|
description: Updated user object
|
||||||
|
required: true
|
||||||
|
responses:
|
||||||
|
"400":
|
||||||
|
description: Invalid user supplied
|
||||||
|
"404":
|
||||||
|
description: User not found
|
||||||
|
security:
|
||||||
|
- api_key: []
|
||||||
|
summary: Updated user
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
x-content-type: application/json
|
||||||
|
x-accepts: application/json
|
||||||
|
x-tags:
|
||||||
|
- tag: user
|
||||||
|
components:
|
||||||
|
requestBodies:
|
||||||
|
UserArray:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/User'
|
||||||
|
type: array
|
||||||
|
description: List of user object
|
||||||
|
required: true
|
||||||
|
Pet:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
description: Pet object that needs to be added to the store
|
||||||
|
required: true
|
||||||
|
schemas:
|
||||||
|
Order:
|
||||||
|
description: An order for a pets from the pet store
|
||||||
|
example:
|
||||||
|
petId: 6
|
||||||
|
quantity: 1
|
||||||
|
id: 0
|
||||||
|
shipDate: 2000-01-23T04:56:07.000+00:00
|
||||||
|
complete: false
|
||||||
|
status: placed
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
format: int64
|
||||||
|
type: integer
|
||||||
|
petId:
|
||||||
|
format: int64
|
||||||
|
type: integer
|
||||||
|
quantity:
|
||||||
|
format: int32
|
||||||
|
type: integer
|
||||||
|
shipDate:
|
||||||
|
format: date-time
|
||||||
|
type: string
|
||||||
|
status:
|
||||||
|
description: Order Status
|
||||||
|
enum:
|
||||||
|
- placed
|
||||||
|
- approved
|
||||||
|
- delivered
|
||||||
|
type: string
|
||||||
|
complete:
|
||||||
|
default: false
|
||||||
|
type: boolean
|
||||||
|
title: Pet Order
|
||||||
|
type: object
|
||||||
|
xml:
|
||||||
|
name: Order
|
||||||
|
Category:
|
||||||
|
description: A category for a pet
|
||||||
|
example:
|
||||||
|
name: name
|
||||||
|
id: 6
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
format: int64
|
||||||
|
type: integer
|
||||||
|
name:
|
||||||
|
pattern: "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$"
|
||||||
|
type: string
|
||||||
|
title: Pet category
|
||||||
|
type: object
|
||||||
|
xml:
|
||||||
|
name: Category
|
||||||
|
User:
|
||||||
|
description: A User who is purchasing from the pet store
|
||||||
|
example:
|
||||||
|
firstName: firstName
|
||||||
|
lastName: lastName
|
||||||
|
password: password
|
||||||
|
userStatus: 6
|
||||||
|
phone: phone
|
||||||
|
id: 0
|
||||||
|
email: email
|
||||||
|
username: username
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
format: int64
|
||||||
|
type: integer
|
||||||
|
username:
|
||||||
|
type: string
|
||||||
|
firstName:
|
||||||
|
type: string
|
||||||
|
lastName:
|
||||||
|
type: string
|
||||||
|
email:
|
||||||
|
type: string
|
||||||
|
password:
|
||||||
|
type: string
|
||||||
|
phone:
|
||||||
|
type: string
|
||||||
|
userStatus:
|
||||||
|
description: User Status
|
||||||
|
format: int32
|
||||||
|
type: integer
|
||||||
|
title: a User
|
||||||
|
type: object
|
||||||
|
xml:
|
||||||
|
name: User
|
||||||
|
Tag:
|
||||||
|
description: A tag for a pet
|
||||||
|
example:
|
||||||
|
name: name
|
||||||
|
id: 1
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
format: int64
|
||||||
|
type: integer
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
title: Pet Tag
|
||||||
|
type: object
|
||||||
|
xml:
|
||||||
|
name: Tag
|
||||||
|
Pet:
|
||||||
|
description: A pet for sale in the pet store
|
||||||
|
example:
|
||||||
|
photoUrls:
|
||||||
|
- photoUrls
|
||||||
|
- photoUrls
|
||||||
|
name: doggie
|
||||||
|
id: 0
|
||||||
|
category:
|
||||||
|
name: name
|
||||||
|
id: 6
|
||||||
|
tags:
|
||||||
|
- name: name
|
||||||
|
id: 1
|
||||||
|
- name: name
|
||||||
|
id: 1
|
||||||
|
status: available
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
format: int64
|
||||||
|
type: integer
|
||||||
|
category:
|
||||||
|
$ref: '#/components/schemas/Category'
|
||||||
|
name:
|
||||||
|
example: doggie
|
||||||
|
type: string
|
||||||
|
photoUrls:
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
|
xml:
|
||||||
|
name: photoUrl
|
||||||
|
wrapped: true
|
||||||
|
tags:
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/Tag'
|
||||||
|
type: array
|
||||||
|
xml:
|
||||||
|
name: tag
|
||||||
|
wrapped: true
|
||||||
|
status:
|
||||||
|
deprecated: true
|
||||||
|
description: pet status in the store
|
||||||
|
enum:
|
||||||
|
- available
|
||||||
|
- pending
|
||||||
|
- sold
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- name
|
||||||
|
- photoUrls
|
||||||
|
title: a Pet
|
||||||
|
type: object
|
||||||
|
xml:
|
||||||
|
name: Pet
|
||||||
|
ApiResponse:
|
||||||
|
description: Describes the result of uploading an image resource
|
||||||
|
example:
|
||||||
|
code: 0
|
||||||
|
type: type
|
||||||
|
message: message
|
||||||
|
properties:
|
||||||
|
code:
|
||||||
|
format: int32
|
||||||
|
type: integer
|
||||||
|
type:
|
||||||
|
type: string
|
||||||
|
message:
|
||||||
|
type: string
|
||||||
|
title: An uploaded response
|
||||||
|
type: object
|
||||||
|
updatePetWithForm_request:
|
||||||
|
properties:
|
||||||
|
name:
|
||||||
|
description: Updated name of the pet
|
||||||
|
type: string
|
||||||
|
status:
|
||||||
|
description: Updated status of the pet
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
uploadFile_request:
|
||||||
|
properties:
|
||||||
|
additionalMetadata:
|
||||||
|
description: Additional data to pass to server
|
||||||
|
type: string
|
||||||
|
file:
|
||||||
|
description: file to upload
|
||||||
|
format: binary
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
securitySchemes:
|
||||||
|
petstore_auth:
|
||||||
|
flows:
|
||||||
|
implicit:
|
||||||
|
authorizationUrl: http://petstore.swagger.io/api/oauth/dialog
|
||||||
|
scopes:
|
||||||
|
write:pets: modify pets in your account
|
||||||
|
read:pets: read your pets
|
||||||
|
type: oauth2
|
||||||
|
api_key:
|
||||||
|
in: header
|
||||||
|
name: api_key
|
||||||
|
type: apiKey
|
@ -0,0 +1,60 @@
|
|||||||
|
<!-- HTML for static distribution bundle build -->
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Swagger UI</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="webjars/swagger-ui/swagger-ui.css" />
|
||||||
|
<link rel="icon" type="image/png" href="webjars/swagger-ui/favicon-32x32.png" sizes="32x32" />
|
||||||
|
<link rel="icon" type="image/png" href="webjars/swagger-ui/favicon-16x16.png" sizes="16x16" />
|
||||||
|
<style>
|
||||||
|
html
|
||||||
|
{
|
||||||
|
box-sizing: border-box;
|
||||||
|
overflow: -moz-scrollbars-vertical;
|
||||||
|
overflow-y: scroll;
|
||||||
|
}
|
||||||
|
|
||||||
|
*,
|
||||||
|
*:before,
|
||||||
|
*:after
|
||||||
|
{
|
||||||
|
box-sizing: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
body
|
||||||
|
{
|
||||||
|
margin:0;
|
||||||
|
background: #fafafa;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="swagger-ui"></div>
|
||||||
|
|
||||||
|
<script src="webjars/swagger-ui/swagger-ui-bundle.js" charset="UTF-8"> </script>
|
||||||
|
<script src="webjars/swagger-ui/swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
|
||||||
|
<script>
|
||||||
|
window.onload = function() {
|
||||||
|
// Begin Swagger UI call region
|
||||||
|
const ui = SwaggerUIBundle({
|
||||||
|
configUrl: 'swagger-config.yaml',
|
||||||
|
dom_id: '#swagger-ui',
|
||||||
|
deepLinking: true,
|
||||||
|
presets: [
|
||||||
|
SwaggerUIBundle.presets.apis,
|
||||||
|
SwaggerUIStandalonePreset
|
||||||
|
],
|
||||||
|
plugins: [
|
||||||
|
SwaggerUIBundle.plugins.DownloadUrl
|
||||||
|
],
|
||||||
|
layout: "StandaloneLayout"
|
||||||
|
});
|
||||||
|
// End Swagger UI call region
|
||||||
|
|
||||||
|
window.ui = ui;
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,13 @@
|
|||||||
|
package org.openapitools;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
class OpenApiGeneratorApplicationTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void contextLoads() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user