diff --git a/bin/configs/java-play-framework-fake-endpoints-with-security.yaml b/bin/configs/java-play-framework-fake-endpoints-with-security.yaml new file mode 100644 index 000000000000..b21a8a9ba0cf --- /dev/null +++ b/bin/configs/java-play-framework-fake-endpoints-with-security.yaml @@ -0,0 +1,6 @@ +generatorName: java-play-framework +outputDir: samples/server/petstore/java-play-framework-fake-endpoints-with-security +inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-for-testing-playframework-with-security.yaml +templateDir: modules/openapi-generator/src/main/resources/JavaPlayFramework +additionalProperties: + hideGenerationTimestamp: "true" diff --git a/bin/configs/spring-boot-beanvalidation-no-nullable-oas3.yaml b/bin/configs/spring-boot-beanvalidation-no-nullable-oas3.yaml new file mode 100644 index 000000000000..760305ec6cbf --- /dev/null +++ b/bin/configs/spring-boot-beanvalidation-no-nullable-oas3.yaml @@ -0,0 +1,13 @@ +generatorName: spring +outputDir: samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable +library: spring-boot +inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml +templateDir: modules/openapi-generator/src/main/resources/JavaSpring +additionalProperties: + groupId: org.openapitools.openapi3 + oas3: "true" + java8: "false" + useBeanValidation: true + artifactId: spring-boot-beanvalidation-no-nullable + hideGenerationTimestamp: "true" + openApiNullable: "false" diff --git a/bin/configs/spring-boot-delegate-oas3.yaml b/bin/configs/spring-boot-delegate-oas3.yaml new file mode 100644 index 000000000000..7d8631523d8a --- /dev/null +++ b/bin/configs/spring-boot-delegate-oas3.yaml @@ -0,0 +1,11 @@ +generatorName: spring +outputDir: samples/openapi3/server/petstore/springboot-delegate +inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml +templateDir: modules/openapi-generator/src/main/resources/JavaSpring +additionalProperties: + groupId: org.openapitools.openapi3 + oas3: "true" + artifactId: springboot-delegate + hideGenerationTimestamp: "true" + java8: true + delegatePattern: "true" diff --git a/bin/configs/spring-boot-implicitHeaders-oas3.yaml b/bin/configs/spring-boot-implicitHeaders-oas3.yaml new file mode 100644 index 000000000000..973561fad57e --- /dev/null +++ b/bin/configs/spring-boot-implicitHeaders-oas3.yaml @@ -0,0 +1,10 @@ +generatorName: spring +outputDir: samples/openapi3/server/petstore/springboot-implicitHeaders +inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml +templateDir: modules/openapi-generator/src/main/resources/JavaSpring +additionalProperties: + groupId: org.openapitools.openapi3 + oas3: "true" + artifactId: springboot-implicitHeaders + hideGenerationTimestamp: "true" + implicitHeaders: true diff --git a/bin/configs/spring-boot-oas3.yaml b/bin/configs/spring-boot-oas3.yaml new file mode 100644 index 000000000000..9a0f864b2713 --- /dev/null +++ b/bin/configs/spring-boot-oas3.yaml @@ -0,0 +1,10 @@ +generatorName: spring +outputDir: samples/openapi3/server/petstore/springboot +inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml +templateDir: modules/openapi-generator/src/main/resources/JavaSpring +additionalProperties: + groupId: org.openapitools.openapi3 + artifactId: springboot + snapshotVersion: "true" + oas3: "true" + hideGenerationTimestamp: "true" diff --git a/bin/configs/spring-boot-reactive-oas3.yaml b/bin/configs/spring-boot-reactive-oas3.yaml new file mode 100644 index 000000000000..b3fc8278491a --- /dev/null +++ b/bin/configs/spring-boot-reactive-oas3.yaml @@ -0,0 +1,11 @@ +generatorName: spring +outputDir: samples/openapi3/server/petstore/springboot-reactive +inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml +templateDir: modules/openapi-generator/src/main/resources/JavaSpring +additionalProperties: + groupId: org.openapitools.openapi3 + oas3: "true" + artifactId: springboot-reactive + reactive: "true" + hideGenerationTimestamp: "true" + delegatePattern: "true" diff --git a/bin/configs/spring-boot-useoptional-oas3.yaml b/bin/configs/spring-boot-useoptional-oas3.yaml new file mode 100644 index 000000000000..6fd5755ca31c --- /dev/null +++ b/bin/configs/spring-boot-useoptional-oas3.yaml @@ -0,0 +1,10 @@ +generatorName: spring +outputDir: samples/openapi3/server/petstore/springboot-useoptional +inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml +templateDir: modules/openapi-generator/src/main/resources/JavaSpring +additionalProperties: + groupId: org.openapitools.openapi3 + oas3: "true" + useOptional: true + artifactId: spring-boot-useoptional + hideGenerationTimestamp: "true" diff --git a/bin/configs/spring-cloud-async-oas3.yaml b/bin/configs/spring-cloud-async-oas3.yaml new file mode 100644 index 000000000000..637e9b4d1626 --- /dev/null +++ b/bin/configs/spring-cloud-async-oas3.yaml @@ -0,0 +1,12 @@ +generatorName: spring +outputDir: samples/openapi3/client/petstore/spring-cloud-async +library: spring-cloud +inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml +templateDir: modules/openapi-generator/src/main/resources/JavaSpring +additionalProperties: + groupId: org.openapitools.openapi3 + oas3: "true" + async: "true" + java8: "true" + artifactId: petstore-spring-cloud + hideGenerationTimestamp: "true" diff --git a/bin/configs/spring-cloud-date-time-oas3.yaml b/bin/configs/spring-cloud-date-time-oas3.yaml new file mode 100644 index 000000000000..27cd8723133e --- /dev/null +++ b/bin/configs/spring-cloud-date-time-oas3.yaml @@ -0,0 +1,12 @@ +generatorName: spring +library: spring-cloud +outputDir: samples/openapi3/client/petstore/spring-cloud-date-time +inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/date-time-parameter-types-for-testing.yml +templateDir: modules/openapi-generator/src/main/resources/JavaSpring +additionalProperties: + groupId: org.openapitools.openapi3 + artifactId: spring-cloud-date-time-oas3 + interfaceOnly: "true" + singleContentTypes: "true" + hideGenerationTimestamp: "true" + oas3: "true" \ No newline at end of file diff --git a/bin/configs/spring-cloud-date-time.yaml b/bin/configs/spring-cloud-date-time.yaml new file mode 100644 index 000000000000..16686c8b9ac7 --- /dev/null +++ b/bin/configs/spring-cloud-date-time.yaml @@ -0,0 +1,10 @@ +generatorName: spring +library: spring-cloud +outputDir: samples/client/petstore/spring-cloud-date-time +inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/date-time-parameter-types-for-testing.yml +templateDir: modules/openapi-generator/src/main/resources/JavaSpring +additionalProperties: + artifactId: spring-cloud-date-time + interfaceOnly: "true" + singleContentTypes: "true" + hideGenerationTimestamp: "true" \ No newline at end of file diff --git a/bin/configs/spring-cloud-oas3-fakeapi.yaml b/bin/configs/spring-cloud-oas3-fakeapi.yaml new file mode 100644 index 000000000000..f12e8b601991 --- /dev/null +++ b/bin/configs/spring-cloud-oas3-fakeapi.yaml @@ -0,0 +1,12 @@ +generatorName: spring +library: spring-cloud +outputDir: samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi +inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml +templateDir: modules/openapi-generator/src/main/resources/JavaSpring +additionalProperties: + groupId: org.openapitools.openapi3 + artifactId: spring-cloud-oas3 + interfaceOnly: "true" + singleContentTypes: "true" + hideGenerationTimestamp: "true" + oas3: "true" diff --git a/bin/configs/spring-cloud-oas3.yaml b/bin/configs/spring-cloud-oas3.yaml new file mode 100644 index 000000000000..3d627dcca254 --- /dev/null +++ b/bin/configs/spring-cloud-oas3.yaml @@ -0,0 +1,12 @@ +generatorName: spring +library: spring-cloud +outputDir: samples/openapi3/client/petstore/spring-cloud +inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml +templateDir: modules/openapi-generator/src/main/resources/JavaSpring +additionalProperties: + groupId: org.openapitools.openapi3 + artifactId: spring-cloud-oas3 + interfaceOnly: "true" + singleContentTypes: "true" + hideGenerationTimestamp: "true" + oas3: "true" diff --git a/bin/configs/spring-cloud-petstore-feign-spring-pageable-oas3.yaml b/bin/configs/spring-cloud-petstore-feign-spring-pageable-oas3.yaml new file mode 100644 index 000000000000..64f048226e83 --- /dev/null +++ b/bin/configs/spring-cloud-petstore-feign-spring-pageable-oas3.yaml @@ -0,0 +1,10 @@ +generatorName: spring +outputDir: samples/openapi3/client/petstore/spring-cloud-spring-pageable +library: spring-cloud +inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-spring-pageable.yaml +templateDir: modules/openapi-generator/src/main/resources/JavaSpring +additionalProperties: + groupId: org.openapitools.openapi3 + oas3: "true" + artifactId: spring-cloud-spring-pageable + hideGenerationTimestamp: 'true' diff --git a/docs/generators/jaxrs-cxf-cdi.md b/docs/generators/jaxrs-cxf-cdi.md index 621f0dc3a735..c46ec4c96310 100644 --- a/docs/generators/jaxrs-cxf-cdi.md +++ b/docs/generators/jaxrs-cxf-cdi.md @@ -58,6 +58,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true| |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |sourceFolder|source folder for generated code| |src/gen/java| +|supportAsync|Wrap responses in CompletionStage type, allowing asynchronous computation (requires JAX-RS 2.1).| |false| |title|a title describing the application| |OpenAPI Server| |useBeanValidation|Use BeanValidation API annotations| |true| |useSwaggerAnnotations|Whether to generate Swagger annotations.| |true| diff --git a/docs/generators/jaxrs-spec.md b/docs/generators/jaxrs-spec.md index 621122f6eaa8..a29e8a931781 100644 --- a/docs/generators/jaxrs-spec.md +++ b/docs/generators/jaxrs-spec.md @@ -58,6 +58,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true| |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |sourceFolder|source folder for generated code| |src/main/java| +|supportAsync|Wrap responses in CompletionStage type, allowing asynchronous computation (requires JAX-RS 2.1).| |false| |title|a title describing the application| |OpenAPI Server| |useBeanValidation|Use BeanValidation API annotations| |true| |useSwaggerAnnotations|Whether to generate Swagger annotations.| |true| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index e28f4a03c33e..8a96688f5fac 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -4103,7 +4103,7 @@ public CodegenOperation fromOperation(String path, } // add example - if (schemas != null) { + if (schemas != null && !isSkipOperationExample()) { op.requestBodyExamples = new ExampleGenerator(schemas, this.openAPI).generate(null, new ArrayList<>(getConsumesInfo(this.openAPI, operation)), bodyParam.baseType); } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppTizenClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppTizenClientCodegen.java index a67bc3f1845e..a60e1cdb6beb 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppTizenClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppTizenClientCodegen.java @@ -175,7 +175,7 @@ public String getTypeDeclaration(String name) { if (languageSpecificPrimitives.contains(name)) { return name; } else { - return name; + return super.getTypeDeclaration(name); } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaJAXRSSpecServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaJAXRSSpecServerCodegen.java index a0313a6bc8e0..8b50933247a7 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaJAXRSSpecServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaJAXRSSpecServerCodegen.java @@ -102,6 +102,7 @@ public JavaJAXRSSpecServerCodegen() { cliOptions.add(CliOption.newBoolean(RETURN_RESPONSE, "Whether generate API interface should return javax.ws.rs.core.Response instead of a deserialized entity. Only useful if interfaceOnly is true.").defaultValue(String.valueOf(returnResponse))); cliOptions.add(CliOption.newBoolean(USE_SWAGGER_ANNOTATIONS, "Whether to generate Swagger annotations.", useSwaggerAnnotations)); cliOptions.add(CliOption.newString(OPEN_API_SPEC_FILE_LOCATION, "Location where the file containing the spec will be generated in the output folder. No file generated when set to null or empty string.")); + cliOptions.add(CliOption.newBoolean(SUPPORT_ASYNC, "Wrap responses in CompletionStage type, allowing asynchronous computation (requires JAX-RS 2.1).", supportAsync)); } @Override @@ -121,6 +122,14 @@ public void processOpts() { additionalProperties.remove(RETURN_RESPONSE); } } + if (additionalProperties.containsKey(SUPPORT_ASYNC)) { + supportAsync = Boolean.parseBoolean(additionalProperties.get(SUPPORT_ASYNC).toString()); + if (!supportAsync) { + additionalProperties.remove(SUPPORT_ASYNC); + } else { + setJava8ModeAndAdditionalProperties(true); + } + } if (QUARKUS_LIBRARY.equals(library) || THORNTAIL_LIBRARY.equals(library) || HELIDON_LIBRARY.equals(library) || OPEN_LIBERTY_LIBRARY.equals(library) || KUMULUZEE_LIBRARY.equals(library)) { useSwaggerAnnotations = false; } else { diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaMicronautClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaMicronautClientCodegen.java index c8516efc020b..f3d398c8e763 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaMicronautClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaMicronautClientCodegen.java @@ -15,6 +15,7 @@ import java.util.Arrays; import java.util.EnumSet; import java.util.HashMap; +import java.util.Map; import static org.openapitools.codegen.CodegenConstants.INVOKER_PACKAGE; @@ -97,18 +98,18 @@ public JavaMicronautClientCodegen() { cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations", useBeanValidation)); CliOption buildToolOption = new CliOption(OPT_BUILD, "Specify for which build tool to generate files").defaultValue(buildTool); - buildToolOption.setEnum(new HashMap() {{ - put(OPT_BUILD_GRADLE, "Gradle configuration is generated for the project"); - put(OPT_BUILD_MAVEN, "Maven configuration is generated for the project"); - put(OPT_BUILD_ALL, "Both Gradle and Maven configurations are generated"); - }}); + Map buildToolOptionMap = new HashMap(); + buildToolOptionMap.put(OPT_BUILD_GRADLE, "Gradle configuration is generated for the project"); + buildToolOptionMap.put(OPT_BUILD_MAVEN, "Maven configuration is generated for the project"); + buildToolOptionMap.put(OPT_BUILD_ALL, "Both Gradle and Maven configurations are generated"); + buildToolOption.setEnum(buildToolOptionMap); cliOptions.add(buildToolOption); CliOption testToolOption = new CliOption(OPT_TEST, "Specify which test tool to generate files for").defaultValue(testTool); - testToolOption.setEnum(new HashMap() {{ - put(OPT_TEST_JUNIT, "Use JUnit as test tool"); - put(OPT_TEST_SPOCK, "Use Spock as test tool"); - }}); + Map testToolOptionMap = new HashMap(); + testToolOptionMap.put(OPT_TEST_JUNIT, "Use JUnit as test tool"); + testToolOptionMap.put(OPT_TEST_SPOCK, "Use Spock as test tool"); + testToolOption.setEnum(testToolOptionMap); cliOptions.add(testToolOption); // Remove the date library option diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaPlayFrameworkCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaPlayFrameworkCodegen.java index 2b2ab17b7250..a152d69cf399 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaPlayFrameworkCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaPlayFrameworkCodegen.java @@ -18,6 +18,7 @@ package org.openapitools.codegen.languages; import io.swagger.v3.oas.models.media.Schema; +import io.swagger.v3.oas.models.security.SecurityScheme; import org.openapitools.codegen.*; import org.openapitools.codegen.languages.features.BeanValidationFeatures; import org.openapitools.codegen.meta.features.DocumentationFeature; @@ -25,11 +26,10 @@ import org.slf4j.LoggerFactory; import java.io.File; -import java.util.List; -import java.util.Locale; -import java.util.Map; +import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Collectors; import static org.openapitools.codegen.utils.StringUtils.camelize; @@ -45,6 +45,10 @@ public class JavaPlayFrameworkCodegen extends AbstractJavaCodegen implements Bea public static final String USE_SWAGGER_UI = "useSwaggerUI"; public static final String SUPPORT_ASYNC = "supportAsync"; + private static final String X_JWKS_URL = "x-jwksUrl"; + private static final String X_TOKEN_INTROSPECT_URL = "x-tokenIntrospectUrl"; + + protected String title = "openapi-java-playframework"; protected String configPackage = "org.openapitools.configuration"; protected String basePackage = "org.openapitools"; @@ -197,6 +201,7 @@ public void processOpts() { supportingFiles.add(new SupportingFile("module.mustache", "app", "Module.java")); } supportingFiles.add(new SupportingFile("openapiUtils.mustache", "app/openapitools", "OpenAPIUtils.java")); + supportingFiles.add(new SupportingFile("securityApiUtils.mustache", "app/openapitools", "SecurityAPIUtils.java")); if (this.handleExceptions) { supportingFiles.add(new SupportingFile("errorHandler.mustache", "app/openapitools", "ErrorHandler.java")); } @@ -376,4 +381,98 @@ public Map postProcessSupportingFileData(Map obj generateJSONSpecFile(objs); return super.postProcessSupportingFileData(objs); } + + @Override + public List fromSecurity(Map securitySchemeMap) { + List securities = super.fromSecurity(securitySchemeMap); + List extendedSecurities = new ArrayList<>(); + + for (CodegenSecurity codegenSecurity : securities) { + ExtendedCodegenSecurity extendedCodegenSecurity = new ExtendedCodegenSecurity(codegenSecurity); + Object jwksUrl = extendedCodegenSecurity.vendorExtensions.get(X_JWKS_URL); + + if (jwksUrl instanceof String) { + extendedCodegenSecurity.jwksUrl = (String) jwksUrl; + } + + Object tokenIntrospectUrl = extendedCodegenSecurity.vendorExtensions.get(X_TOKEN_INTROSPECT_URL); + + if (tokenIntrospectUrl instanceof String) { + extendedCodegenSecurity.tokenIntrospectUrl = (String) tokenIntrospectUrl; + } + extendedSecurities.add(extendedCodegenSecurity); + } + + return extendedSecurities; + } + + + class ExtendedCodegenSecurity extends CodegenSecurity { + public String jwksUrl; + public String tokenIntrospectUrl; + + public ExtendedCodegenSecurity(CodegenSecurity cm) { + super(); + + this.name = cm.name; + this.type = cm.type; + this.scheme = cm.scheme; + this.isBasic = cm.isBasic; + this.isOAuth = cm.isOAuth; + this.isApiKey = cm.isApiKey; + this.isBasicBasic = cm.isBasicBasic; + this.isBasicBearer = cm.isBasicBearer; + this.isHttpSignature = cm.isHttpSignature; + this.bearerFormat = cm.bearerFormat; + this.vendorExtensions = new HashMap(cm.vendorExtensions); + this.keyParamName = cm.keyParamName; + this.isKeyInQuery = cm.isKeyInQuery; + this.isKeyInHeader = cm.isKeyInHeader; + this.isKeyInCookie = cm.isKeyInCookie; + this.flow = cm.flow; + this.authorizationUrl = cm.authorizationUrl; + this.tokenUrl = cm.tokenUrl; + this.refreshUrl = cm.refreshUrl; + this.scopes = cm.scopes; + this.isCode = cm.isCode; + this.isPassword = cm.isPassword; + this.isApplication = cm.isApplication; + this.isImplicit = cm.isImplicit; + } + + @Override + public CodegenSecurity filterByScopeNames(List filterScopes) { + CodegenSecurity codegenSecurity = super.filterByScopeNames(filterScopes); + ExtendedCodegenSecurity extendedCodegenSecurity = new ExtendedCodegenSecurity(codegenSecurity); + extendedCodegenSecurity.jwksUrl = this.jwksUrl; + extendedCodegenSecurity.tokenIntrospectUrl = this.tokenIntrospectUrl; + return extendedCodegenSecurity; + } + + @Override + public boolean equals(Object o) { + boolean result = super.equals(o); + JavaPlayFrameworkCodegen.ExtendedCodegenSecurity that = (JavaPlayFrameworkCodegen.ExtendedCodegenSecurity) o; + return result && + Objects.equals(jwksUrl, that.jwksUrl) && + Objects.equals(tokenIntrospectUrl, that.tokenIntrospectUrl); + + } + + @Override + public int hashCode() { + int superHash = super.hashCode(); + return Objects.hash(superHash, tokenIntrospectUrl, jwksUrl); + } + + @Override + public String toString() { + String superString = super.toString(); + final StringBuilder sb = new StringBuilder(superString); + sb.append(", jwksUrl='").append(jwksUrl).append('\''); + sb.append(", tokenIntrospectUrl='").append(tokenIntrospectUrl).append('\''); + return sb.toString(); + } + + } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/K6ClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/K6ClientCodegen.java index 681594ea8eb4..982a3fefbe03 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/K6ClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/K6ClientCodegen.java @@ -1041,7 +1041,7 @@ private boolean shouldHideOperationResponse(ApiResponse resp) { Map respExtensions = (Map) resp.getExtensions().get(X_OPERATION_RESPONSE); Entry entry = respExtensions.entrySet().stream().findFirst().orElse(null); - if (entry.getKey().equals(X_OPERATION_RESPONSE_HIDE)) { + if (entry != null && entry.getKey().equals(X_OPERATION_RESPONSE_HIDE)) { return Boolean.parseBoolean(String.valueOf(entry.getValue())); } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java index 8960b2f8e696..ebbe0eacca07 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java @@ -541,10 +541,12 @@ public Map postProcessModelsEnum(Map objs) { .forEach(cm -> { cm.imports.add(importMapping.get("JsonValue")); cm.imports.add(importMapping.get("JsonProperty")); - Map item = new HashMap<>(); - item.put("import", importMapping.get("JsonValue")); - item.put("import", importMapping.get("JsonProperty")); - imports.add(item); + Map itemJsonValue = new HashMap<>(); + itemJsonValue.put("import", importMapping.get("JsonValue")); + imports.add(itemJsonValue); + Map itemJsonProperty = new HashMap<>(); + itemJsonProperty.put("import", importMapping.get("JsonProperty")); + imports.add(itemJsonProperty); }); return objs; diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java index 297c458e3c23..f2695d08cd21 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java @@ -20,6 +20,7 @@ import static org.apache.commons.lang3.StringUtils.isNotEmpty; import static org.openapitools.codegen.utils.StringUtils.camelize; +import io.swagger.v3.oas.models.media.Schema; import java.io.File; import java.net.URL; import java.util.ArrayList; @@ -923,6 +924,17 @@ public void postProcessModelProperty(CodegenModel model, CodegenProperty propert } } + @Override + public CodegenModel fromModel(String name, Schema model) { + CodegenModel codegenModel = super.fromModel(name, model); + if (oas3) { + // remove swagger2 imports + codegenModel.imports.remove("ApiModelProperty"); + codegenModel.imports.remove("ApiModel"); + } + return codegenModel; + } + @Override public Map postProcessModelsEnum(Map objs) { objs = super.postProcessModelsEnum(objs); diff --git a/modules/openapi-generator/src/main/resources/Java/Pair.mustache b/modules/openapi-generator/src/main/resources/Java/Pair.mustache index ff9e06b20d46..ed767ce72675 100644 --- a/modules/openapi-generator/src/main/resources/Java/Pair.mustache +++ b/modules/openapi-generator/src/main/resources/Java/Pair.mustache @@ -41,10 +41,6 @@ public class Pair { return false; } - if (arg.trim().isEmpty()) { - return false; - } - return true; } } diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/api.mustache index 2b623d2cf842..e0d605818d34 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/api.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/api.mustache @@ -173,7 +173,7 @@ public class {{classname}} { {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/api.mustache index 50b7cfc5ed53..c55259c44fee 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/api.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/api.mustache @@ -204,7 +204,7 @@ public class {{classname}} { {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/api.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/api.mustache index b19e2510d714..37f5ba040139 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/api.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/api.mustache @@ -9,6 +9,10 @@ import javax.ws.rs.core.Response; {{#useSwaggerAnnotations}} import io.swagger.annotations.*; {{/useSwaggerAnnotations}} +{{#supportAsync}} +import java.util.concurrent.CompletionStage; +import java.util.concurrent.CompletableFuture; +{{/supportAsync}} import java.io.InputStream; import java.util.Map; diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/apiInterface.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/apiInterface.mustache index 0fcf5420c282..77e7bd3e3dae 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/apiInterface.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/apiInterface.mustache @@ -10,4 +10,4 @@ {{/isOAuth}}{{/authMethods}} }{{/hasAuthMethods}}, tags={ {{#vendorExtensions.x-tags}}"{{tag}}"{{^-last}}, {{/-last}}{{/vendorExtensions.x-tags}} }) @ApiResponses(value = { {{#responses}} @ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{baseType}}}.class{{#returnContainer}}, responseContainer = "{{{.}}}"{{/returnContainer}}){{^-last}},{{/-last}}{{/responses}} }){{/useSwaggerAnnotations}} - {{#returnResponse}}Response{{/returnResponse}}{{^returnResponse}}{{>returnTypeInterface}}{{/returnResponse}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{^-last}},{{/-last}}{{/allParams}}); \ No newline at end of file + {{#supportAsync}}{{>returnAsyncTypeInterface}}{{/supportAsync}}{{^supportAsync}}{{#returnResponse}}Response{{/returnResponse}}{{^returnResponse}}{{>returnTypeInterface}}{{/returnResponse}}{{/supportAsync}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{^-last}},{{/-last}}{{/allParams}}); \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/apiMethod.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/apiMethod.mustache index d6c4ae7c82c1..edecd390f9cf 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/apiMethod.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/apiMethod.mustache @@ -11,6 +11,6 @@ @ApiResponses(value = { {{#responses}} @ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{baseType}}}.class{{#containerType}}, responseContainer = "{{{.}}}"{{/containerType}}){{^-last}},{{/-last}}{{/responses}} }){{/useSwaggerAnnotations}} - public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>cookieParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{^-last}},{{/-last}}{{/allParams}}) { - return Response.ok().entity("magic!").build(); + public {{#supportAsync}}CompletionStage<{{/supportAsync}}Response{{#supportAsync}}>{{/supportAsync}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>cookieParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{^-last}},{{/-last}}{{/allParams}}) { + return {{#supportAsync}}CompletableFuture.supplyAsync(() -> {{/supportAsync}}Response.ok().entity("magic!").build(){{#supportAsync}}){{/supportAsync}}; } \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/pom.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/pom.mustache index 48ac267133b9..3aa05e79fbd8 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/pom.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/pom.mustache @@ -140,6 +140,11 @@ {{/useBeanValidation}} +{{#java8}} + 1.8 + ${java.version} + ${java.version} +{{/java8}} 2.9.9 4.13.1 {{#useBeanValidation}} diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/returnAsyncTypeInterface.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/returnAsyncTypeInterface.mustache new file mode 100644 index 000000000000..0da348c7a224 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/returnAsyncTypeInterface.mustache @@ -0,0 +1 @@ +CompletionStage<{{#returnResponse}}Response{{/returnResponse}}{{^returnResponse}}{{#returnContainer}}{{#isMap}}Map{{/isMap}}{{#isArray}}{{{returnContainer}}}<{{{returnBaseType}}}>{{/isArray}}{{/returnContainer}}{{^returnContainer}}{{{returnBaseType}}}{{/returnContainer}}{{/returnResponse}}> \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaPlayFramework/build.mustache b/modules/openapi-generator/src/main/resources/JavaPlayFramework/build.mustache index df0dace75ba7..31b4262231f0 100644 --- a/modules/openapi-generator/src/main/resources/JavaPlayFramework/build.mustache +++ b/modules/openapi-generator/src/main/resources/JavaPlayFramework/build.mustache @@ -13,3 +13,6 @@ libraryDependencies += "org.webjars" % "swagger-ui" % "3.32.5" libraryDependencies += "javax.validation" % "validation-api" % "2.0.1.Final" {{/useBeanValidation}} libraryDependencies += guice +libraryDependencies += "com.auth0" % "java-jwt" % "3.18.1" +libraryDependencies += "com.auth0" % "jwks-rsa" % "0.19.0" +libraryDependencies += "org.apache.httpcomponents" % "httpclient" % "4.5.6" diff --git a/modules/openapi-generator/src/main/resources/JavaPlayFramework/module.mustache b/modules/openapi-generator/src/main/resources/JavaPlayFramework/module.mustache index 7556aa238964..4f77f551c568 100644 --- a/modules/openapi-generator/src/main/resources/JavaPlayFramework/module.mustache +++ b/modules/openapi-generator/src/main/resources/JavaPlayFramework/module.mustache @@ -1,6 +1,7 @@ import com.google.inject.AbstractModule; import {{apiPackage}}.*; +import openapitools.SecurityAPIUtils; public class Module extends AbstractModule { @@ -11,5 +12,6 @@ public class Module extends AbstractModule { bind({{classname}}ControllerImpInterface.class).to({{classname}}ControllerImp.class); {{/apis}} {{/apiInfo}} + bind(SecurityAPIUtils.class); } } \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiController.mustache b/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiController.mustache index 6d2f007bac9a..51205320c522 100644 --- a/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiController.mustache +++ b/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiController.mustache @@ -20,6 +20,9 @@ import play.libs.Files.TemporaryFile; import java.io.IOException; {{/handleExceptions}} import openapitools.OpenAPIUtils; +{{^useInterfaces}} +import openapitools.SecurityAPIUtils; +{{/useInterfaces}} import com.fasterxml.jackson.core.type.TypeReference; {{#supportAsync}} @@ -46,9 +49,12 @@ public class {{classname}}Controller extends Controller { {{#useBeanValidation}} private final Config configuration; {{/useBeanValidation}} +{{^useInterfaces}} + private final SecurityAPIUtils securityAPIUtils; +{{/useInterfaces}} @Inject - private {{classname}}Controller({{#useBeanValidation}}Config configuration{{^controllerOnly}}, {{/controllerOnly}}{{/useBeanValidation}}{{^controllerOnly}}{{classname}}ControllerImp{{#useInterfaces}}Interface{{/useInterfaces}} imp{{/controllerOnly}}) { + private {{classname}}Controller({{#useBeanValidation}}Config configuration{{^controllerOnly}}, {{/controllerOnly}}{{/useBeanValidation}}{{^controllerOnly}}{{classname}}ControllerImp{{#useInterfaces}}Interface{{/useInterfaces}} imp{{/controllerOnly}}{{^useInterfaces}}, SecurityAPIUtils securityAPIUtils{{/useInterfaces}}) { {{^controllerOnly}} this.imp = imp; {{/controllerOnly}} @@ -56,6 +62,9 @@ public class {{classname}}Controller extends Controller { {{#useBeanValidation}} this.configuration = configuration; {{/useBeanValidation}} +{{^useInterfaces}} + this.securityAPIUtils = securityAPIUtils; +{{/useInterfaces}} } {{#operation}} diff --git a/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiInterface.mustache b/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiInterface.mustache index 0fd7dac6b0e3..157ba3a0bc1a 100644 --- a/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiInterface.mustache +++ b/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiInterface.mustache @@ -14,7 +14,9 @@ import play.mvc.Result; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; {{#supportAsync}} import java.util.concurrent.CompletionException; @@ -32,11 +34,12 @@ public abstract class {{classname}}ControllerImpInterface { {{#useBeanValidation}} @Inject private Config configuration; {{/useBeanValidation}} + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); {{#operation}} public {{#supportAsync}}CompletionStage<{{/supportAsync}}Result{{#supportAsync}}>{{/supportAsync}} {{operationId}}Http(Http.Request request{{#hasParams}}, {{/hasParams}}{{#allParams}}{{>pathParams}}{{>queryParams}}{{>bodyParams}}{{>formParams}}{{>headerParams}}{{^-last}}, {{/-last}}{{/allParams}}) {{#handleExceptions}}throws Exception{{/handleExceptions}} { - {{>responseToResult}} +{{>responseToResult}} } public abstract {{^returnType}}void{{/returnType}}{{#returnType}}{{#supportAsync}}CompletionStage<{{/supportAsync}}{{>returnTypesNoVoid}}{{#supportAsync}}>{{/supportAsync}}{{/returnType}} {{operationId}}(Http.Request request{{#hasParams}}, {{/hasParams}}{{#allParams}}{{>pathParams}}{{>queryParams}}{{>bodyParams}}{{>formParams}}{{>headerParams}}{{^-last}}, {{/-last}}{{/allParams}}) {{#handleExceptions}}throws Exception{{/handleExceptions}}; diff --git a/modules/openapi-generator/src/main/resources/JavaPlayFramework/responseToResult.mustache b/modules/openapi-generator/src/main/resources/JavaPlayFramework/responseToResult.mustache index 7d5a43be4cb1..91f7c34fccd5 100644 --- a/modules/openapi-generator/src/main/resources/JavaPlayFramework/responseToResult.mustache +++ b/modules/openapi-generator/src/main/resources/JavaPlayFramework/responseToResult.mustache @@ -1,55 +1,46 @@ {{^controllerOnly}} +{{#authMethods.0}} +{{#isOAuth}} + if (!securityAPIUtils.isRequestTokenValid(request, "{{name}}")) { + return {{#supportAsync}}CompletableFuture.supplyAsync(play.mvc.Results::unauthorized){{/supportAsync}}{{^supportAsync}}unauthorized(){{/supportAsync}}; + } + +{{/isOAuth}} +{{/authMethods.0}} {{^returnType}} {{#supportAsync}} -CompletableFuture result = CompletableFuture.supplyAsync(() -> { + CompletableFuture result = CompletableFuture.supplyAsync(() -> { try { {{/supportAsync}} {{/returnType}} -{{#returnType}}{{#supportAsync}}CompletionStage<{{>returnTypesNoVoid}}> stage = {{/supportAsync}}{{^supportAsync}}{{>returnTypesNoVoid}} obj = {{/supportAsync}}{{/returnType}}{{^returnType}}{{#supportAsync}} {{/supportAsync}}{{/returnType}}{{^useInterfaces}}imp.{{/useInterfaces}}{{operationId}}(request{{#hasParams}}, {{/hasParams}}{{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}){{#returnType}}{{#supportAsync}}.thenApply(obj -> { {{/supportAsync}}{{/returnType}}{{^supportAsync}};{{/supportAsync}}{{#supportAsync}}{{^returnType}};{{/returnType}}{{/supportAsync}} + {{#returnType}}{{#supportAsync}}CompletionStage<{{>returnTypesNoVoid}}> stage = {{/supportAsync}}{{^supportAsync}}{{>returnTypesNoVoid}} obj = {{/supportAsync}}{{/returnType}}{{^returnType}}{{#supportAsync}} {{/supportAsync}}{{/returnType}}{{^useInterfaces}}imp.{{/useInterfaces}}{{operationId}}(request{{#hasParams}}, {{/hasParams}}{{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}){{#returnType}}{{#supportAsync}}.thenApply(obj -> { {{/supportAsync}}{{/returnType}}{{^supportAsync}};{{/supportAsync}}{{#supportAsync}}{{^returnType}};{{/returnType}}{{/supportAsync}} {{#returnType}} {{^isResponseFile}} {{^returnTypeIsPrimitive}} {{#useBeanValidation}} -{{^supportAsync}} - if (configuration.getBoolean("useOutputBeanValidation")) { - {{#isArray}} - for ({{{returnType}}} curItem : obj) { - OpenAPIUtils.validate(curItem); - } - {{/isArray}} - {{#isMap}} - for (Map.Entry entry : obj.entrySet()) { - OpenAPIUtils.validate(entry.getValue()); - } - {{/isMap}} - {{^returnContainer}} + + if (configuration.getBoolean("useOutputBeanValidation")) { + {{#isArray}} + for ({{{returnType}}} curItem : obj) { + OpenAPIUtils.validate(curItem); + } + {{/isArray}} + {{#isMap}} + for (Map.Entry entry : obj.entrySet()) { + OpenAPIUtils.validate(entry.getValue()); + } + {{/isMap}} + {{^returnContainer}} OpenAPIUtils.validate(obj); - {{/returnContainer}} - } -{{/supportAsync}} -{{#supportAsync}} - if (configuration.getBoolean("useOutputBeanValidation")) { - {{#isArray}} - for ({{{returnType}}} curItem : obj) { - OpenAPIUtils.validate(curItem); + {{/returnContainer}} } - {{/isArray}} - {{#isMap}} - for (Map.Entry entry : obj.entrySet()) { - OpenAPIUtils.validate(entry.getValue()); - } - {{/isMap}} - {{^returnContainer}} - OpenAPIUtils.validate(obj); - {{/returnContainer}} - } -{{/supportAsync}} + {{/useBeanValidation}} {{/returnTypeIsPrimitive}} {{/isResponseFile}} {{#supportAsync}} - return obj; -}); + return obj; + }); {{/supportAsync}} {{/returnType}} {{#returnType}} @@ -57,11 +48,13 @@ CompletableFuture result = CompletableFuture.supplyAsync(() -> { return stage.thenApply(obj -> { {{/supportAsync}} {{^isResponseFile}} -{{#supportAsync}} {{/supportAsync}}JsonNode result = mapper.valueToTree(obj); -{{#supportAsync}} {{/supportAsync}}return ok(result); +{{#supportAsync}} {{/supportAsync}} JsonNode result = mapper.valueToTree(obj); + +{{#supportAsync}} {{/supportAsync}} return ok(result); {{/isResponseFile}} {{#isResponseFile}} -{{#supportAsync}} {{/supportAsync}}return ok(obj); + +{{#supportAsync}} {{/supportAsync}} return ok(obj); {{/isResponseFile}} {{/returnType}} {{^returnType}} @@ -74,15 +67,15 @@ return stage.thenApply(obj -> { return result; {{/supportAsync}} {{^supportAsync}} -return ok(); + return ok(); {{/supportAsync}} {{/returnType}} {{#returnType}} {{#supportAsync}} -}); + }); {{/supportAsync}} {{/returnType}} {{/controllerOnly}} {{#controllerOnly}} -return ok(); + return ok(); {{/controllerOnly}} diff --git a/modules/openapi-generator/src/main/resources/JavaPlayFramework/securityApiUtils.mustache b/modules/openapi-generator/src/main/resources/JavaPlayFramework/securityApiUtils.mustache new file mode 100644 index 000000000000..ebbb7c0cd23a --- /dev/null +++ b/modules/openapi-generator/src/main/resources/JavaPlayFramework/securityApiUtils.mustache @@ -0,0 +1,173 @@ +package openapitools; + +import com.auth0.jwk.Jwk; +import com.auth0.jwk.UrlJwkProvider; +import com.auth0.jwt.JWT; +import com.auth0.jwt.JWTVerifier; +import com.auth0.jwt.algorithms.Algorithm; +import com.auth0.jwt.interfaces.DecodedJWT; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import org.apache.http.HttpHeaders; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.NameValuePair; +import org.apache.http.client.HttpClient; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; +import play.mvc.Http; + +import java.net.URL; +import java.security.PublicKey; +import java.security.interfaces.RSAPublicKey; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; + +@Singleton +public class SecurityAPIUtils { + private final String bearerPrefix = "Bearer "; + private final ObjectMapper mapper; + + private boolean useOnlineValidation = false; + + // Online validation + private HashMap tokenIntrospectEndpoints = new HashMap<>(); + private final String clientId; + private final String clientSecret; + + // Offline validation + private HashMap jwksEndpoints = new HashMap<>(); + private String tokenKeyId = ""; + private JWTVerifier tokenVerifier; //Reusable verifier instance until tokenKeyId changes. + + @Inject + SecurityAPIUtils(Config configuration) { + mapper = new ObjectMapper(); + + clientId = configuration.hasPath("oauth.clientId") ? configuration.getString("oauth.clientId") : ""; + clientSecret = configuration.hasPath("oauth.clientSecret") ? configuration.getString("oauth.clientSecret") : ""; + +{{#hasOAuthMethods}} +{{#oauthMethods}} + tokenIntrospectEndpoints.put("{{name}}", "{{tokenIntrospectUrl}}"); +{{/oauthMethods}} +{{/hasOAuthMethods}} + +{{#hasOAuthMethods}} +{{#oauthMethods}} + jwksEndpoints.put("{{name}}", "{{jwksUrl}}"); +{{/oauthMethods}} +{{/hasOAuthMethods}} + } + + private boolean isRequestTokenValidByOnlineCheck(Http.Request request, String securityMethodName) { + try { + Optional authToken = request.getHeaders().get(HttpHeaders.AUTHORIZATION); + + if (authToken.isPresent()) { + String tokenWithoutBearerPrefix = authToken.get().substring(bearerPrefix.length()); + + HttpClientBuilder builder = HttpClientBuilder.create(); + HttpClient httpClient = builder.build(); + HttpPost httppost = new HttpPost(this.tokenIntrospectEndpoints.get(securityMethodName)); + + List params = new ArrayList<>(); + params.add(new BasicNameValuePair("token", tokenWithoutBearerPrefix)); + params.add(new BasicNameValuePair("client_id", clientId)); + params.add(new BasicNameValuePair("client_secret", clientSecret)); + httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); + + HttpResponse response = httpClient.execute(httppost); + String responseJsonString = EntityUtils.toString(response.getEntity()); + HashMap responseJsonObject = mapper.readValue(responseJsonString, HashMap.class); + + return response.getStatusLine().getStatusCode() == HttpStatus.SC_OK && (boolean) responseJsonObject.get("active"); + } + } catch (Exception exception) { + return false; + } + + return false; + } + + private boolean isRequestTokenValidByOfflineCheck(Http.Request request, String securityMethodName) { + try { + Optional authHeader = request.getHeaders().get(HttpHeaders.AUTHORIZATION); + + if (authHeader.isPresent()) { + String bearerToken = authHeader.get().substring(bearerPrefix.length()); + return isTokenValidByOfflineCheck(bearerToken, securityMethodName); + } + } catch (Exception exception) { + return false; + } + + return false; + } + + public boolean isTokenValidByOfflineCheck(String bearerToken, String securityMethodName) { + try { + DecodedJWT jwt = JWT.decode(bearerToken); + String issuer = jwt.getIssuer(); + String keyId = jwt.getKeyId(); + if (!tokenKeyId.equals(keyId)) { + if (securityMethodName == null) { + securityMethodName = jwksEndpoints.keySet().stream().findFirst().get(); + } + + Jwk jwk = new UrlJwkProvider(new URL(this.jwksEndpoints.get(securityMethodName))).get(keyId); + final PublicKey publicKey = jwk.getPublicKey(); + + if (!(publicKey instanceof RSAPublicKey)) { + throw new IllegalArgumentException(String.format("Key with ID %s was found in JWKS but is not a RSA-key.", keyId)); + } + + Algorithm algorithm = Algorithm.RSA256((RSAPublicKey) publicKey, null); + tokenVerifier = JWT.require(algorithm) + .withIssuer(issuer) + .build(); + tokenKeyId = keyId; + } + + DecodedJWT verifiedJWT = tokenVerifier.verify(bearerToken); + + return true; + } catch (Exception exception) { + return false; + } + } + + public String getOAuthUserIdFromRequestToken(Http.Request requestWithPreviouslyVerifiedToken) { + try { + Optional authHeader = requestWithPreviouslyVerifiedToken.getHeaders().get(HttpHeaders.AUTHORIZATION); + if (authHeader.isPresent()) { + String bearerToken = authHeader.get().substring(bearerPrefix.length()); + return getOAuthUserIdFromToken(bearerToken); + } + } catch (Exception exception) { + return null; + } + + return null; + } + + public String getOAuthUserIdFromToken(String bearerToken) { + try { + DecodedJWT jwt = JWT.decode(bearerToken); + return jwt.getSubject(); + } catch (Exception exception) { + return null; + } + } + + public boolean isRequestTokenValid(Http.Request request, String securityMethodName) { + return useOnlineValidation ? isRequestTokenValidByOnlineCheck(request, securityMethodName) : isRequestTokenValidByOfflineCheck(request, securityMethodName); + } +} diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/allowableValues.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/allowableValues.mustache new file mode 100644 index 000000000000..1cba2038d870 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/JavaSpring/allowableValues.mustache @@ -0,0 +1 @@ +{{#allowableValues}}allowableValues ={{#oas3}} { {{#values}}"{{{.}}}"{{^-last}}, {{/-last}}{{/values}} }{{/oas3}}{{^oas3}} "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/oas3}}{{/allowableValues}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/api.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/api.mustache index 6647b5f084e5..66c398753e04 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/api.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/api.mustache @@ -10,9 +10,9 @@ package {{package}}; {{#oas3}} import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.parameters.RequestBody; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; @@ -120,29 +120,62 @@ public interface {{classname}} { @ApiVirtual {{/virtualService}} {{#oas3}} - @Operation(summary = "{{{summary}}}", tags={ {{#vendorExtensions.x-tags}}"{{tag}}",{{/vendorExtensions.x-tags}} }, responses = { {{#responses}} @ApiResponse(responseCode = "{{{code}}}", description = "{{{message}}}"{{#baseType}}, content = @Content(mediaType = "application/json", schema = @Schema(implementation = {{{baseType}}}.class)){{/baseType}}){{^-last}},{{/-last}}{{/responses}} }{{#hasAuthMethods}},security = { - {{#authMethods}}@SecurityRequirement(name = "{{name}}"{{#isOAuth}}, scopes={ {{#scopes}}"{{scope}}"{{^-last}}, {{/-last}}{{/scopes}} }{{/isOAuth}}){{^-last}},{{/-last}}{{/authMethods}} } {{/hasAuthMethods}}) - {{/oas3}}{{^oas3}} - @ApiOperation(value = "{{{summary}}}", nickname = "{{{operationId}}}", notes = "{{{notes}}}"{{#returnBaseType}}, response = {{{.}}}.class{{/returnBaseType}}{{#returnContainer}}, responseContainer = "{{{.}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = { - {{#authMethods}}{{#isOAuth}}@Authorization(value = "{{name}}", scopes = { - {{#scopes}}@AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{^-last}}, - {{/-last}}{{/scopes}} }){{^-last}},{{/-last}}{{/isOAuth}} - {{^isOAuth}}@Authorization(value = "{{name}}"){{^-last}},{{/-last}} - {{/isOAuth}}{{/authMethods}} }{{/hasAuthMethods}}, tags={ {{#vendorExtensions.x-tags}}"{{tag}}",{{/vendorExtensions.x-tags}} }) - @ApiResponses(value = { {{#responses}} - - @ApiResponse(code = {{{code}}}, message = "{{{message}}}"{{#baseType}}, response = {{{.}}}.class{{/baseType}}{{#containerType}}, responseContainer = "{{{.}}}"{{/containerType}}){{^-last}},{{/-last}}{{/responses}} }) + @Operation( + summary = "{{{summary}}}", + tags = { {{#vendorExtensions.x-tags}}"{{tag}}"{{^-last}}, {{/-last}}{{/vendorExtensions.x-tags}} }, + responses = { + {{#responses}} + @ApiResponse(responseCode = "{{{code}}}", description = "{{{message}}}"{{#baseType}}, content = @Content(mediaType = "application/json", schema = @Schema(implementation = {{{baseType}}}.class)){{/baseType}}){{^-last}},{{/-last}} + {{/responses}} + }{{#hasAuthMethods}}, + security = { + {{#authMethods}} + @SecurityRequirement(name = "{{name}}"{{#isOAuth}}, scopes={ {{#scopes}}"{{scope}}"{{^-last}}, {{/-last}}{{/scopes}} }{{/isOAuth}}){{^-last}},{{/-last}} + {{/authMethods}} + }{{/hasAuthMethods}} + ) + {{/oas3}} + {{^oas3}} + @ApiOperation( + tags = { {{#vendorExtensions.x-tags}}"{{tag}}"{{^-last}}, {{/-last}}{{/vendorExtensions.x-tags}} }, + value = "{{{summary}}}", + nickname = "{{{operationId}}}", + notes = "{{{notes}}}"{{#returnBaseType}}, + response = {{{.}}}.class{{/returnBaseType}}{{#returnContainer}}, + responseContainer = "{{{.}}}"{{/returnContainer}}{{#hasAuthMethods}}, + authorizations = { + {{#authMethods}} + {{#isOAuth}} + @Authorization(value = "{{name}}", scopes = { + {{#scopes}} + @AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{^-last}},{{/-last}} + {{/scopes}} + }){{^-last}},{{/-last}} + {{/isOAuth}} + {{^isOAuth}} + @Authorization(value = "{{name}}"){{^-last}},{{/-last}} + {{/isOAuth}} + {{/authMethods}} }{{/hasAuthMethods}} + ) + @ApiResponses({ + {{#responses}} + @ApiResponse(code = {{{code}}}, message = "{{{message}}}"{{#baseType}}, response = {{{.}}}.class{{/baseType}}{{#containerType}}, responseContainer = "{{{.}}}"{{/containerType}}){{^-last}},{{/-last}} + {{/responses}} + }) {{/oas3}} {{#implicitHeaders}} {{#oas3}} @Parameters({ + {{#headerParams}} + {{>paramDoc}}{{^-last}},{{/-last}} + {{/headerParams}} {{/oas3}} {{^oas3}} @ApiImplicitParams({ + {{#headerParams}} + {{>implicitHeader}}{{^-last}},{{/-last}} + {{/headerParams}} {{/oas3}} - {{#headerParams}} - {{>implicitHeader}} - {{/headerParams}} }) {{/implicitHeaders}} @RequestMapping( @@ -153,13 +186,18 @@ public interface {{classname}} { produces = { {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} }{{/hasProduces}}{{#hasConsumes}}, consumes = { {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }{{/hasConsumes}}{{/singleContentTypes}} ) - {{#jdk8-default-interface}}default {{/jdk8-default-interface}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{#delegate-method}}_{{/delegate-method}}{{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{>cookieParams}}{{^-last}},{{/-last}}{{#-last}}{{#reactive}}, {{/reactive}}{{/-last}}{{/allParams}}{{#reactive}}{{#oas3}}@Hidden{{/oas3}}{{^oas3}}@springfox.documentation.annotations.ApiIgnore{{/oas3}} final ServerWebExchange exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}, {{#oas3}}@Hidden{{/oas3}}{{^oas3}}@springfox.documentation.annotations.ApiIgnore{{/oas3}} final org.springframework.data.domain.Pageable pageable{{/vendorExtensions.x-spring-paginated}}){{^jdk8-default-interface}};{{/jdk8-default-interface}}{{#jdk8-default-interface}}{{#unhandledException}} throws Exception{{/unhandledException}} { + {{#jdk8-default-interface}}default {{/jdk8-default-interface}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{#delegate-method}}_{{/delegate-method}}{{operationId}}( + {{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{>cookieParams}}{{^-last}}, + {{/-last}}{{/allParams}}{{#reactive}}{{#hasParams}}, + {{/hasParams}}{{#oas3}}@Parameter(hidden = true){{/oas3}}{{#useSpringfox}}@springfox.documentation.annotations.ApiIgnore{{/useSpringfox}} final ServerWebExchange exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}{{#hasParams}}, + {{/hasParams}}{{#useSpringfox}}@springfox.documentation.annotations.ApiIgnore {{/useSpringfox}}final org.springframework.data.domain.Pageable pageable{{/vendorExtensions.x-spring-paginated}} + ){{^jdk8-default-interface}};{{/jdk8-default-interface}}{{#jdk8-default-interface}}{{#unhandledException}} throws Exception{{/unhandledException}} { {{#delegate-method}} return {{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#reactive}}{{#hasParams}}, {{/hasParams}}exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}, pageable{{/vendorExtensions.x-spring-paginated}}); } // 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{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{/isFile}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#reactive}}{{#hasParams}}, {{/hasParams}}{{#oas3}}@Hidden{{/oas3}}{{^oas3}}@springfox.documentation.annotations.ApiIgnore{{/oas3}} final ServerWebExchange exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}, {{#oas3}}@Hidden{{/oas3}}{{^oas3}}@springfox.documentation.annotations.ApiIgnore{{/oas3}} final org.springframework.data.domain.Pageable pageable{{/vendorExtensions.x-spring-paginated}}){{#unhandledException}} throws Exception{{/unhandledException}} { + {{#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{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{/isFile}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#reactive}}{{#hasParams}}, {{/hasParams}}{{#useSpringfox}}@springfox.documentation.annotations.ApiIgnore{{/useSpringfox}} final ServerWebExchange exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}, {{#useSpringfox}}@springfox.documentation.annotations.ApiIgnore{{/useSpringfox}} final org.springframework.data.domain.Pageable pageable{{/vendorExtensions.x-spring-paginated}}){{#unhandledException}} throws Exception{{/unhandledException}} { {{/delegate-method}} {{^isDelegate}} {{>methodBody}} diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/apiController.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/apiController.mustache index cfdf2b9772bd..0652a76d54ee 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/apiController.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/apiController.mustache @@ -3,7 +3,18 @@ package {{package}}; {{^jdk8}} {{#imports}}import {{import}}; {{/imports}} +{{#oas3}} +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +{{/oas3}} +{{^oas3}} import io.swagger.annotations.*; +{{/oas3}} import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; @@ -118,7 +129,11 @@ public class {{classname}}Controller implements {{classname}} { {{/externalDocs}} * @see {{classname}}#{{operationId}} */ - public {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{>cookieParams}}{{^-last}},{{/-last}}{{/allParams}}{{#vendorExtensions.x-spring-paginated}}, @springfox.documentation.annotations.ApiIgnore final Pageable pageable{{/vendorExtensions.x-spring-paginated}}) { + public {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}( + {{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{>cookieParams}}{{^-last}}, + {{/-last}}{{/allParams}}{{#vendorExtensions.x-spring-paginated}}{{#hasParams}}, + {{/hasParams}}{{#useSpringfox}}@springfox.documentation.annotations.ApiIgnore {{/useSpringfox}}final Pageable pageable{{/vendorExtensions.x-spring-paginated}} + ) { {{^isDelegate}} {{^async}} {{>methodBody}} diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/apiDelegate.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/apiDelegate.mustache index ca990e7146b8..1a97106dc8fb 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/apiDelegate.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/apiDelegate.mustache @@ -2,7 +2,6 @@ package {{package}}; {{#imports}}import {{import}}; {{/imports}} -import io.swagger.annotations.*; {{#vendorExtensions.x-spring-paginated}} import org.springframework.data.domain.Pageable; {{/vendorExtensions.x-spring-paginated}} @@ -73,7 +72,7 @@ public interface {{classname}}Delegate { */ {{#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{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{#isArray}}>{{/isArray}}{{/isFile}} {{paramName}}{{^-last}}, {{/-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 org.springframework.data.domain.Pageable pageable{{/vendorExtensions.x-spring-paginated}}){{#unhandledException}} throws Exception{{/unhandledException}}{{^jdk8-default-interface}};{{/jdk8-default-interface}}{{#jdk8-default-interface}} { {{>methodBody}} }{{/jdk8-default-interface}} diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/bodyParams.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/bodyParams.mustache index 7500b53a1bd1..137c4d86b7a3 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/bodyParams.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/bodyParams.mustache @@ -1 +1 @@ -{{#isBodyParam}}{{#oas3}}@Parameter(name ={{/oas3}}{{^oas3}}@ApiParam(value ={{/oas3}} "{{{description}}}"{{#required}}, required = true{{/required}} {{^isContainer}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}{{/isContainer}}{{#allowableValues}}, {{#oas3}}schema = @Schema({{/oas3}}allowableValues = "{{{.}}}"{{#oas3}}){{/oas3}}{{/allowableValues}}) {{#useBeanValidation}} @Valid{{/useBeanValidation}} @RequestBody{{^required}}(required = false){{/required}} {{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isArray}}Mono<{{{dataType}}}>{{/isArray}}{{#isArray}}Flux<{{{baseType}}}>{{/isArray}}{{/reactive}} {{paramName}}{{/isBodyParam}} \ No newline at end of file +{{#isBodyParam}}{{>paramDoc}}{{#useBeanValidation}} @Valid{{/useBeanValidation}} @RequestBody{{^required}}(required = false){{/required}} {{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isArray}}Mono<{{{dataType}}}>{{/isArray}}{{#isArray}}Flux<{{{baseType}}}>{{/isArray}}{{/reactive}} {{paramName}}{{/isBodyParam}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/cookieParams.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/cookieParams.mustache index d6bded4b731a..a4fe15cb9c2a 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/cookieParams.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/cookieParams.mustache @@ -1 +1 @@ -{{#isCookieParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{#oas3}}@Parameter(name = "{{{baseName}}}", description = {{/oas3}}{{^oas3}}@ApiParam(value = {{/oas3}}"{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#enumVars}}{{#lambdaEscapeDoubleQuote}}{{{value}}}{{/lambdaEscapeDoubleQuote}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/enumVars}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}{{/isContainer}}) @CookieValue("{{baseName}}") {{>optionalDataType}} {{paramName}}{{/isCookieParam}} \ No newline at end of file +{{#isCookieParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{>paramDoc}} @CookieValue("{{baseName}}"){{>dateTimeParam}} {{>optionalDataType}} {{paramName}}{{/isCookieParam}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/dateTimeParam.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/dateTimeParam.mustache new file mode 100644 index 000000000000..3155e5619566 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/JavaSpring/dateTimeParam.mustache @@ -0,0 +1 @@ +{{#isDate}} @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE){{/isDate}}{{#isDateTime}} @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME){{/isDateTime}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/formParams.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/formParams.mustache index 78df4981339e..ec6cac87c51d 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/formParams.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/formParams.mustache @@ -1 +1 @@ -{{#isFormParam}}{{^isFile}}{{#oas3}}@Parameter(name = "{{{baseName}}}", description = {{/oas3}}{{^oas3}}@ApiParam(value = {{/oas3}}"{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}{{/isContainer}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestPart(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}) {{{dataType}}} {{paramName}}{{/isFile}}{{#isFile}}{{#oas3}}@Parameter(name = "{{{baseName}}}", description = {{/oas3}}{{^oas3}}@ApiParam(value = {{/oas3}}"{{{description}}}") {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestPart(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}) {{#isArray}}List<{{/isArray}}{{#reactive}}Flux{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{#isArray}}>{{/isArray}} {{baseName}}{{/isFile}}{{/isFormParam}} \ No newline at end of file +{{#isFormParam}}{{^isFile}}{{>paramDoc}}{{#useBeanValidation}} @Valid{{/useBeanValidation}} @RequestPart(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}){{>dateTimeParam}} {{{dataType}}} {{paramName}}{{/isFile}}{{#isFile}}{{>paramDoc}} @RequestPart(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}) {{#isArray}}List<{{/isArray}}{{#reactive}}Flux{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{#isArray}}>{{/isArray}} {{baseName}}{{/isFile}}{{/isFormParam}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/headerParams.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/headerParams.mustache index 4b10916d66d4..54891a27d570 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/headerParams.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/headerParams.mustache @@ -1 +1 @@ -{{#isHeaderParam}}{{#oas3}}@Parameter(description ={{/oas3}}{{^oas3}}@ApiParam(value ={{/oas3}} "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}{{/isContainer}}) @RequestHeader(value = "{{baseName}}", required = {{#required}}true{{/required}}{{^required}}false{{/required}}) {{>optionalDataType}} {{paramName}}{{/isHeaderParam}} +{{#isHeaderParam}}{{>paramDoc}} @RequestHeader(value = "{{baseName}}", required = {{#required}}true{{/required}}{{^required}}false{{/required}}){{>dateTimeParam}} {{>optionalDataType}} {{paramName}}{{/isHeaderParam}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/implicitHeader.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/implicitHeader.mustache index a7a6851cb887..77e151eedaa6 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/implicitHeader.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/implicitHeader.mustache @@ -1 +1 @@ -{{#isHeaderParam}}@ApiImplicitParam(name = "{{{paramName}}}", value = "{{{description}}}", {{#required}}required = true,{{/required}} dataType = "{{{dataType}}}", paramType = "header"){{^-last}},{{/-last}}{{/isHeaderParam}} \ No newline at end of file +{{#isHeaderParam}}@ApiImplicitParam(name = "{{{paramName}}}", value = "{{{description}}}", {{#required}}required = true,{{/required}} dataType = "{{{dataType}}}", paramType = "header"){{/isHeaderParam}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom.mustache index 2f75d1c0f63b..05447fe9563d 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom.mustache @@ -10,7 +10,10 @@ ${java.version} ${java.version} {{#useSpringfox}} - 2.9.2 + 2.9.2 + {{/useSpringfox}} + {{^useSpringfox}} + {{#oas3}}2.1.11{{/oas3}}{{^oas3}}1.6.3{{/oas3}} {{/useSpringfox}} {{#parentOverridden}} @@ -24,7 +27,7 @@ org.springframework.boot spring-boot-starter-parent - {{#java8}}2.3.3.RELEASE{{/java8}}{{^java8}}1.5.12.RELEASE{{/java8}} + 2.5.8 {{/parentOverridden}} @@ -34,13 +37,6 @@ org.springframework.boot spring-boot-maven-plugin - - - - repackage - - - {{#apiFirst}} @@ -91,43 +87,25 @@ io.springfox springfox-swagger2 - ${springfox-version} - - - io.springfox - springfox-swagger-ui - ${springfox-version} - - - jakarta.xml.bind - jakarta.xml.bind-api + ${springfox.version} {{/useSpringfox}} {{^useSpringfox}} - - io.springfox - springfox-swagger2 - 2.8.0 - - - org.webjars - swagger-ui - 3.14.2 - {{#oas3}} io.swagger.core.v3 swagger-annotations - 2.1.2 + ${swagger-core-version} {{/oas3}} {{^oas3}} io.swagger swagger-annotations - 1.5.14 + ${swagger-core-version} {{/oas3}} + {{/useSpringfox}} com.google.code.findbugs @@ -138,9 +116,12 @@ com.fasterxml.jackson.dataformat jackson-dataformat-yaml - {{/useSpringfox}} {{#withXml}} + + jakarta.xml.bind + jakarta.xml.bind-api + com.fasterxml.jackson.dataformat jackson-dataformat-xml @@ -162,21 +143,21 @@ com.github.joschi.jackson jackson-datatype-threetenbp - 2.8.4 + 2.9.10 {{/threetenbp}} {{#openApiNullable}} org.openapitools jackson-databind-nullable - 0.2.1 + 0.2.2 {{/openApiNullable}} {{#useBeanValidation}} - + - jakarta.validation - jakarta.validation-api + org.springframework.boot + spring-boot-starter-validation {{/useBeanValidation}} {{#virtualService}} diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/formParams.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/formParams.mustache index ac337fecf6a8..2277efda1e1d 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/formParams.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/formParams.mustache @@ -1 +1 @@ -{{#isFormParam}}{{^isFile}}{{#oas3}}@Parameter(name = "{{{baseName}}}", description = {{/oas3}}{{^oas3}}@ApiParam(value = {{/oas3}}"{{{description}}}"{{#required}}, required=true{{/required}} {{#allowableValues}}, allowableValues="{{{.}}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue="{{{.}}}"{{/defaultValue}}{{/isContainer}}) @RequestParam(value="{{baseName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{{dataType}}} {{paramName}}{{/isFile}}{{#isFile}}{{#oas3}}@Parameter(name = "{{{baseName}}}", description = {{/oas3}}{{^oas3}}@ApiParam(value = {{/oas3}}"{{{description}}}") @RequestParam("{{baseName}}") {{#isArray}}List<{{/isArray}}{{#reactive}}Flux{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{#isArray}}>{{/isArray}} {{paramName}}{{/isFile}}{{/isFormParam}} \ No newline at end of file +{{#isFormParam}}{{^isFile}}{{>paramDoc}} @RequestParam(value="{{baseName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}){{>dateTimeParam}} {{{dataType}}} {{paramName}}{{/isFile}}{{#isFile}}{{>paramDoc}} @RequestParam("{{baseName}}") {{#isArray}}List<{{/isArray}}{{#reactive}}Flux{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{#isArray}}>{{/isArray}} {{paramName}}{{/isFile}}{{/isFormParam}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/pom.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/pom.mustache index 1636e5918366..f9228dd345e2 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/pom.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/pom.mustache @@ -9,7 +9,10 @@ {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} ${java.version} ${java.version} - 1.5.18 + {{#oas3}}2.1.11{{/oas3}}{{^oas3}}1.6.3{{/oas3}} + {{#useSpringfox}} + 2.9.2 + {{/useSpringfox}} {{#parentOverridden}} @@ -22,7 +25,7 @@ org.springframework.boot spring-boot-starter-parent - 2.5.5 + 2.6.2 {{/parentOverridden}} @@ -35,7 +38,7 @@ org.springframework.cloud spring-cloud-starter-parent - 2020.0.4 + 2021.0.0 pom import @@ -44,27 +47,37 @@ {{/parentOverridden}} + {{#useSpringfox}} + + + io.springfox + springfox-swagger2 + ${springfox.version} + + {{/useSpringfox}} + {{^useSpringfox}} {{#oas3}} io.swagger.core.v3 swagger-annotations - 2.1.2 + ${swagger-core-version} {{/oas3}} {{^oas3}} io.swagger swagger-annotations -{{^parentOverridden}} ${swagger-core-version} -{{/parentOverridden}} {{/oas3}} + {{/useSpringfox}} com.google.code.findbugs jsr305 + {{^parentOverridden}} 3.0.2 + {{/parentOverridden}} org.springframework.cloud @@ -73,7 +86,9 @@ org.springframework.cloud spring-cloud-starter-oauth2 + {{^parentOverridden}} 2.2.5.RELEASE + {{/parentOverridden}} {{#withXml}} @@ -107,40 +122,31 @@ org.openapitools jackson-databind-nullable - {{^parentOverridden}} - 0.2.1 - {{/parentOverridden}} + {{^parentOverridden}} + 0.2.2 + {{/parentOverridden}} {{/openApiNullable}} - - org.springframework.boot - spring-boot-starter-test - test - -{{#hateoas}} - + {{#hateoas}} org.springframework.boot spring-boot-starter-hateoas -{{/hateoas}} -{{#useBeanValidation}} - - org.hibernate.validator - hibernate-validator - {{^parentOverridden}} - 6.0.16.Final - {{/parentOverridden}} - -{{/useBeanValidation}} + {{/hateoas}} + {{#useBeanValidation}} - io.springfox - springfox-swagger2 - 3.0.0 + org.springframework.boot + spring-boot-starter-validation + {{/useBeanValidation}} org.springframework.data spring-data-commons + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/pom.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/pom.mustache index 9230b32c9d32..f0f17f6b2088 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/pom.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/pom.mustache @@ -187,14 +187,14 @@ io.swagger.core.v3 swagger-annotations - 2.1.2 + ${swagger-core-version} {{/oas3}} {{^oas3}} io.swagger swagger-annotations - 1.5.14 + ${swagger-core-version} {{/oas3}} @@ -289,12 +289,12 @@ ${java.version} ${java.version} 1.3.5 - 2.3.3 + 2.3.3 9.2.15.v20160210 1.7.21 4.13.1 4.0.4 - 2.8.0 + 2.9.2 2.9.9 2.8.4 {{#useBeanValidation}} @@ -305,5 +305,6 @@ 0.2.2 {{/openApiNullable}} 2.9.8 + {{#oas3}}2.1.11{{/oas3}}{{^oas3}}1.6.3{{/oas3}} diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/paramDoc.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/paramDoc.mustache new file mode 100644 index 000000000000..7f3eb71e0b01 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/JavaSpring/paramDoc.mustache @@ -0,0 +1 @@ +{{#oas3}}@Parameter(name = "{{{baseName}}}", description = "{{{description}}}"{{#required}}, required = true{{/required}}, schema = @Schema(description = ""{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}{{/isContainer}})){{/oas3}}{{^oas3}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}{{/isContainer}}){{/oas3}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/pathParams.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/pathParams.mustache index cf75bb92edec..16888518c1b9 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/pathParams.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/pathParams.mustache @@ -1 +1 @@ -{{#isPathParam}}{{#useBeanValidation}}{{>beanValidationPathParams}}{{/useBeanValidation}}{{#oas3}}@Parameter(name = "{{baseName}}", description ={{/oas3}}{{^oas3}}@ApiParam(value ={{/oas3}} "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#enumVars}}{{#lambdaRemoveDoubleQuote}}{{{value}}}{{/lambdaRemoveDoubleQuote}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/enumVars}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}{{/isContainer}}) @PathVariable("{{baseName}}") {{>optionalDataType}} {{paramName}}{{/isPathParam}} +{{#isPathParam}}{{#useBeanValidation}}{{>beanValidationPathParams}}{{/useBeanValidation}}{{>paramDoc}} @PathVariable("{{baseName}}"){{>dateTimeParam}} {{>optionalDataType}} {{paramName}}{{/isPathParam}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/queryParams.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/queryParams.mustache index 557b3ca837a8..2e8911d8f531 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/queryParams.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/queryParams.mustache @@ -1 +1 @@ -{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{#oas3}}@Parameter(name = "{{{baseName}}}", description = {{/oas3}}{{^oas3}}@ApiParam(value = {{/oas3}}"{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, {{#oas3}}schema = @Schema({{/oas3}}allowableValues = "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{#oas3}}){{/oas3}}{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}{{/isContainer}}){{#useBeanValidation}} @Valid{{/useBeanValidation}}{{^isModel}} @RequestParam(value = {{#isMap}}""{{/isMap}}{{^isMap}}"{{baseName}}"{{/isMap}}{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{^isContainer}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}{{/isContainer}}){{/isModel}}{{#isDate}} @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE){{/isDate}}{{#isDateTime}} @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME){{/isDateTime}} {{>optionalDataType}} {{paramName}}{{/isQueryParam}} \ No newline at end of file +{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{>paramDoc}}{{#useBeanValidation}} @Valid{{/useBeanValidation}}{{^isModel}} @RequestParam(value = {{#isMap}}""{{/isMap}}{{^isMap}}"{{baseName}}"{{/isMap}}{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{^isContainer}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}{{/isContainer}}){{/isModel}}{{>dateTimeParam}} {{>optionalDataType}} {{paramName}}{{/isQueryParam}} \ No newline at end of file diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/jaxrs/JavaJAXRSSpecServerCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/jaxrs/JavaJAXRSSpecServerCodegenTest.java index 3fe1133d755c..c04197d9091c 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/jaxrs/JavaJAXRSSpecServerCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/jaxrs/JavaJAXRSSpecServerCodegenTest.java @@ -28,6 +28,11 @@ import static org.openapitools.codegen.TestUtils.assertFileContains; import static org.openapitools.codegen.TestUtils.validateJavaSourceFiles; +import static org.openapitools.codegen.languages.AbstractJavaCodegen.JAVA8_MODE; +import static org.openapitools.codegen.languages.AbstractJavaJAXRSServerCodegen.USE_TAGS; +import static org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen.INTERFACE_ONLY; +import static org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen.SUPPORT_ASYNC; +import static org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen.RETURN_RESPONSE; import static org.testng.Assert.assertTrue; /** @@ -95,6 +100,8 @@ public void testAdditionalPropertiesPutForConfigValues() throws Exception { codegen.additionalProperties().put(CodegenConstants.INVOKER_PACKAGE, "xyz.yyyyy.iiii.invoker"); codegen.additionalProperties().put("serverPort", "8088"); codegen.additionalProperties().put(JavaJAXRSSpecServerCodegen.OPEN_API_SPEC_FILE_LOCATION, "openapi.yml"); + codegen.additionalProperties().put(SUPPORT_ASYNC, true); + codegen.additionalProperties().put(JAVA8_MODE, false); codegen.processOpts(); OpenAPI openAPI = new OpenAPI(); @@ -112,6 +119,8 @@ public void testAdditionalPropertiesPutForConfigValues() throws Exception { Assert.assertEquals(codegen.additionalProperties().get(AbstractJavaJAXRSServerCodegen.SERVER_PORT), "8088"); Assert.assertEquals(codegen.getOpenApiSpecFileLocation(), "openapi.yml"); Assert.assertEquals(codegen.additionalProperties().get(JavaJAXRSSpecServerCodegen.OPEN_API_SPEC_FILE_LOCATION), "openapi.yml"); + Assert.assertEquals(codegen.additionalProperties().get(SUPPORT_ASYNC), "true"); + Assert.assertEquals(codegen.additionalProperties().get(JAVA8_MODE), true); //overridden by supportAsync=true } /** @@ -419,4 +428,170 @@ public void addsImportForSetResponse() throws IOException { assertFileContains(path, "\nimport java.util.Set;\n"); } + + @Test + public void generateApiWithAsyncSupport() throws Exception { + final File output = Files.createTempDirectory("test").toFile(); + output.deleteOnExit(); + + final OpenAPI openAPI = new OpenAPIParser() + .readLocation("src/test/resources/3_0/ping.yaml", null, new ParseOptions()).getOpenAPI(); + + codegen.setOutputDir(output.getAbsolutePath()); + codegen.additionalProperties().put(SUPPORT_ASYNC, true); //Given support async is enabled + + final ClientOptInput input = new ClientOptInput() + .openAPI(openAPI) + .config(codegen); //Using JavaJAXRSSpecServerCodegen + + final DefaultGenerator generator = new DefaultGenerator(); + final List files = generator.opts(input).generate(); //When generating files + + //Then the java files are compilable + validateJavaSourceFiles(files); + + //And the generated class contains CompletionStage + TestUtils.ensureContainsFile(files, output, "src/gen/java/org/openapitools/api/PingApi.java"); + assertFileContains(output.toPath().resolve("src/gen/java/org/openapitools/api/PingApi.java"), + "\nimport java.util.concurrent.CompletionStage;\n", + "\nimport java.util.concurrent.CompletableFuture;\n", + "\npublic CompletionStage pingGet() {\n", + "\nCompletableFuture.supplyAsync(() -> Response.ok().entity(\"magic!\").build())\n" + ); + } + + @Test + public void generateApiWithAsyncSupportAndInterfaceOnly() throws Exception { + final File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); + output.deleteOnExit(); + + final OpenAPI openAPI = new OpenAPIParser() + .readLocation("src/test/resources/3_0/ping.yaml", null, new ParseOptions()).getOpenAPI(); + + codegen.setOutputDir(output.getAbsolutePath()); + codegen.additionalProperties().put(SUPPORT_ASYNC, true); //Given support async is enabled + codegen.additionalProperties().put(INTERFACE_ONLY, true); //And only interfaces are generated + + final ClientOptInput input = new ClientOptInput() + .openAPI(openAPI) + .config(codegen); //Using JavaJAXRSSpecServerCodegen + + final DefaultGenerator generator = new DefaultGenerator(); + final List files = generator.opts(input).generate(); //When generating files + + //Then the java files are compilable + validateJavaSourceFiles(files); + + //And the generated interface contains CompletionStage + TestUtils.ensureContainsFile(files, output, "src/gen/java/org/openapitools/api/PingApi.java"); + assertFileContains(output.toPath().resolve("src/gen/java/org/openapitools/api/PingApi.java"), + "\nimport java.util.concurrent.CompletionStage;\n", + "\nCompletionStage pingGet();\n"); + } + + @Test + public void generateApiWithAsyncSupportAndInterfaceOnlyAndResponse() throws Exception { + final File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); + output.deleteOnExit(); + + final OpenAPI openAPI = new OpenAPIParser() + .readLocation("src/test/resources/3_0/ping.yaml", null, new ParseOptions()).getOpenAPI(); + + codegen.setOutputDir(output.getAbsolutePath()); + codegen.additionalProperties().put(SUPPORT_ASYNC, true); //Given support async is enabled + codegen.additionalProperties().put(INTERFACE_ONLY, true); //And only interfaces are generated + codegen.additionalProperties().put(RETURN_RESPONSE, true); //And return type is Response + + final ClientOptInput input = new ClientOptInput() + .openAPI(openAPI) + .config(codegen); //Using JavaJAXRSSpecServerCodegen + + final DefaultGenerator generator = new DefaultGenerator(); + final List files = generator.opts(input).generate(); //When generating files + + //Then the java files are compilable + validateJavaSourceFiles(files); + + //And the generated interface contains CompletionStage + TestUtils.ensureContainsFile(files, output, "src/gen/java/org/openapitools/api/PingApi.java"); + assertFileContains(output.toPath().resolve( "src/gen/java/org/openapitools/api/PingApi.java"), + "\nimport java.util.concurrent.CompletionStage;\n", + "\nCompletionStage pingGet();\n"); + } + + + @Test + public void generatePetstoreAPIWithAsyncSupport() throws Exception { + final File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); + output.deleteOnExit(); + + final OpenAPI openAPI = new OpenAPIParser() + .readLocation("src/test/resources/3_0/petstore.yaml", null, new ParseOptions()).getOpenAPI(); + + codegen.setOutputDir(output.getAbsolutePath()); + codegen.additionalProperties().put(SUPPORT_ASYNC, true); //Given support async is enabled + codegen.additionalProperties().put(INTERFACE_ONLY, true); //And only interfaces are generated + + final ClientOptInput input = new ClientOptInput() + .openAPI(openAPI) + .config(codegen); //using JavaJAXRSSpecServerCodegen + + final DefaultGenerator generator = new DefaultGenerator(); + final List files = generator.opts(input).generate(); //When generating files + + //Then the java files are compilable + validateJavaSourceFiles(files); + + //And the generated interfaces contains CompletionStage + TestUtils.ensureContainsFile(files, output, "src/gen/java/org/openapitools/api/PetApi.java"); + assertFileContains(output.toPath().resolve("src/gen/java/org/openapitools/api/PetApi.java"), + "\nimport java.util.concurrent.CompletionStage;\n", + "CompletionStage deletePet", //Support empty response + "CompletionStage> findPetsByStatus", //Support type of arrays response + "CompletionStage getPetById" //Support single type response + ); + + TestUtils.ensureContainsFile(files, output, "src/gen/java/org/openapitools/api/StoreApi.java"); + assertFileContains(output.toPath().resolve("src/gen/java/org/openapitools/api/StoreApi.java"), + "\nimport java.util.concurrent.CompletionStage;\n", + "CompletionStage>" //Support map response + ); + + TestUtils.ensureContainsFile(files, output, "src/gen/java/org/openapitools/api/UserApi.java"); + assertFileContains(output.toPath().resolve("src/gen/java/org/openapitools/api/UserApi.java"), + "\nimport java.util.concurrent.CompletionStage;\n", + "CompletionStage" //Support simple types + ); + } + + @Test + public void generatePingWithAsyncSupportPrimitiveType() throws Exception { + final File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); + output.deleteOnExit(); + + final OpenAPI openAPI = new OpenAPIParser() + .readLocation("src/test/resources/3_0/issue_4832.yaml", null, new ParseOptions()).getOpenAPI(); + + codegen.setOutputDir(output.getAbsolutePath()); + codegen.additionalProperties().put(SUPPORT_ASYNC, true); //Given support async is enabled + codegen.additionalProperties().put(INTERFACE_ONLY, true); //And only interfaces are generated + codegen.additionalProperties().put(USE_TAGS, true); //And use tags to generate everything in PingApi.java + + final ClientOptInput input = new ClientOptInput() + .openAPI(openAPI) + .config(codegen); //using JavaJAXRSSpecServerCodegen + + final DefaultGenerator generator = new DefaultGenerator(); + final List files = generator.opts(input).generate(); //When generating files + + //Then the java files are compilable + validateJavaSourceFiles(files); + + //And the generated interfaces contains CompletionStage with proper classes instead of primitive types + TestUtils.ensureContainsFile(files, output, "src/gen/java/org/openapitools/api/PingApi.java"); + TestUtils.assertFileContains(output.toPath().resolve("src/gen/java/org/openapitools/api/PingApi.java"), + "CompletionStage pingGetBoolean", //Support primitive types response + "CompletionStage pingGetInteger" //Support primitive types response + ); + } } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/markdown/MarkdownSampleGeneratorTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/markdown/MarkdownSampleGeneratorTest.java index e59203fd50b2..803c00057ee8 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/markdown/MarkdownSampleGeneratorTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/markdown/MarkdownSampleGeneratorTest.java @@ -1,3 +1,4 @@ +/* package org.openapitools.codegen.markdown; import java.io.File; @@ -51,3 +52,4 @@ public void testSampleMarkdownGeneration() throws IOException { } } +*/ diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/scala/ScalaGatlingCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/scala/ScalaGatlingCodegenTest.java new file mode 100644 index 000000000000..5dfef81397a6 --- /dev/null +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/scala/ScalaGatlingCodegenTest.java @@ -0,0 +1,100 @@ +package org.openapitools.codegen.scala; + +import com.google.common.collect.ImmutableList; + +import org.openapitools.codegen.ClientOptInput; +import org.openapitools.codegen.CodegenConstants; +import org.openapitools.codegen.CodegenModel; +import org.openapitools.codegen.CodegenType; +import org.openapitools.codegen.DefaultGenerator; +import org.openapitools.codegen.TestUtils; +import org.openapitools.codegen.config.CodegenConfigurator; +import org.openapitools.codegen.languages.ScalaGatlingCodegen; +import static org.testng.Assert.assertEquals; + +import org.testng.annotations.Test; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.List; +import java.util.stream.Collectors; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.media.DateTimeSchema; +import io.swagger.v3.oas.models.media.IntegerSchema; +import io.swagger.v3.oas.models.media.Schema; +import io.swagger.v3.oas.models.media.StringSchema; +import io.swagger.v3.parser.util.SchemaTypeUtil; + +public class ScalaGatlingCodegenTest { + + private final ScalaGatlingCodegen codegen = new ScalaGatlingCodegen(); + + @Test + public void happyPath() throws IOException { + assertEquals(codegen.getName(), "scala-gatling"); + assertEquals(codegen.getTag(), CodegenType.CLIENT); + + final List filenames = codegen.supportingFiles().stream() + .map(supportingFile -> supportingFile.getDestinationFilename()) + .collect(Collectors.toList()); + assertEquals(filenames, ImmutableList.of( + "build.gradle", + "logback.xml", + "default.conf", + "CI.conf", + "CD.conf", + "stress.conf", + "baseline.conf", + "longevity.conf")); + + final Schema model = new Schema() + .description("a sample model") + .addProperties("id", new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT)) + .addProperties("name", new StringSchema()) + .addProperties("createdAt", new DateTimeSchema()) + .addRequiredItem("id") + .addRequiredItem("name"); + final OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model); + + codegen.setOpenAPI(openAPI); + final CodegenModel cm = codegen.fromModel("sample", model); + + assertEquals(cm.name, "sample"); + assertEquals(cm.classname, "Sample"); + assertEquals(cm.description, "a sample model"); + assertEquals(cm.vars.size(), 3); + + File output = Files.createTempDirectory("test").toFile(); + output.deleteOnExit(); + + final CodegenConfigurator configurator = new CodegenConfigurator() + .setGeneratorName(codegen.getName()) + .setInputSpec("src/test/resources/3_0/scala_reserved_words.yaml") + .setOutputDir(output.getAbsolutePath().replace("\\", "/")); + + final ClientOptInput clientOptInput = configurator.toClientOptInput(); + DefaultGenerator generator = new DefaultGenerator(); + + generator.setGenerateMetadata(false); + + generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true"); + generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false"); + generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false"); + generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "false"); + generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "true"); + + List files = generator.opts(clientOptInput).generate(); + + assertEquals(files.size(), 9); + + TestUtils.ensureContainsFile(files, output, "src/gatling/scala/org/openapitools/client/model/SomeObj.scala"); + TestUtils.ensureContainsFile(files, output, "build.gradle"); + TestUtils.ensureContainsFile(files, output, "src/gatling/resources/conf/logback.xml"); + TestUtils.ensureContainsFile(files, output, "src/gatling/resources/conf/baseline.conf"); + TestUtils.ensureContainsFile(files, output, "src/gatling/resources/conf/stress.conf"); + TestUtils.ensureContainsFile(files, output, "src/gatling/resources/conf/longevity.conf"); + } + +} diff --git a/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-for-testing-playframework-with-security.yaml b/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-for-testing-playframework-with-security.yaml new file mode 100644 index 000000000000..be54ca6da2b6 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-for-testing-playframework-with-security.yaml @@ -0,0 +1,254 @@ +swagger: '2.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.' + version: 1.0.0 + title: OpenAPI Petstore + license: + name: Apache-2.0 + url: 'https://www.apache.org/licenses/LICENSE-2.0.html' +host: petstore.swagger.io +basePath: /v2 +tags: + - name: pet + description: Everything about your Pets + - name: store + description: Access to Petstore orders + - name: user + description: Operations about user +schemes: + - http +paths: + /pet: + post: + tags: + - pet + summary: Add a new pet to the store + description: '' + operationId: addPet + consumes: + - application/json + - application/xml + produces: + - application/xml + - application/json + parameters: + - in: body + name: body + description: Pet object that needs to be added to the store + required: true + schema: + $ref: '#/definitions/Pet' + responses: + '405': + description: Invalid input + security: + - petstore_token: [base] + put: + tags: + - pet + summary: Update an existing pet + description: '' + operationId: updatePet + consumes: + - application/json + - application/xml + produces: + - application/xml + - application/json + parameters: + - in: body + name: body + description: Pet object that needs to be added to the store + required: true + schema: + $ref: '#/definitions/Pet' + responses: + '400': + description: Invalid ID supplied + '404': + description: Pet not found + '405': + description: Validation exception + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + /pet/findByStatus: + get: + tags: + - pet + summary: Finds Pets by status + description: Multiple status values can be provided with comma separated strings + operationId: findPetsByStatus + produces: + - application/xml + - application/json + parameters: + - name: status + in: query + description: Status values that need to be considered for filter + required: true + type: array + items: + type: string + enum: + - available + - pending + - sold + default: available + collectionFormat: csv + responses: + '200': + description: successful operation + schema: + type: array + items: + $ref: '#/definitions/Pet' + '400': + description: Invalid status value +securityDefinitions: + petstore_token: + type: oauth2 + description: security definition for using keycloak authentification with control site. + authorizationUrl: https://keycloak-dev.business.stingray.com/auth/realms/CSLocal/protocol/openid-connect/auth + tokenUrl: https://keycloak-dev.business.stingray.com/auth/realms/CSLocal/protocol/openid-connect/token + x-jwksUrl: https://keycloak-dev.business.stingray.com/auth/realms/CSLocal/protocol/openid-connect/certs + x-tokenIntrospectUrl: https://keycloak-dev.business.stingray.com/auth/realms/CSLocal/protocol/openid-connect/token/introspect + flow: accessCode + scopes: + base: not sure if we will be using scopes, at least in the beginning, but since we need to specify one.... + api_key: + type: apiKey + name: api_key + in: header +definitions: + Order: + title: Pet Order + description: An order for a pets from the pet store + type: object + properties: + id: + type: integer + format: int64 + petId: + type: integer + format: int64 + quantity: + type: integer + format: int32 + shipDate: + type: string + format: date-time + status: + type: string + description: Order Status + enum: + - placed + - approved + - delivered + complete: + type: boolean + default: false + xml: + name: Order + Category: + title: Pet category + description: A category for a pet + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + xml: + name: Category + User: + title: a User + description: A User who is purchasing from the pet store + type: object + properties: + id: + type: integer + format: int64 + username: + type: string + firstName: + type: string + lastName: + type: string + email: + type: string + password: + type: string + phone: + type: string + userStatus: + type: integer + format: int32 + description: User Status + xml: + name: User + Tag: + title: Pet Tag + description: A tag for a pet + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + xml: + name: Tag + Pet: + title: a Pet + description: A pet for sale in the pet store + type: object + required: + - name + - photoUrls + properties: + id: + type: integer + format: int64 + category: + $ref: '#/definitions/Category' + name: + type: string + example: doggie + photoUrls: + type: array + xml: + name: photoUrl + wrapped: true + items: + type: string + tags: + type: array + xml: + name: tag + wrapped: true + items: + $ref: '#/definitions/Tag' + status: + type: string + description: pet status in the store + enum: + - available + - pending + - sold + xml: + name: Pet + ApiResponse: + title: An uploaded response + description: Describes the result of uploading an image resource + type: object + properties: + code: + type: integer + format: int32 + type: + type: string + message: + type: string diff --git a/modules/openapi-generator/src/test/resources/3_0/issue_4832.yaml b/modules/openapi-generator/src/test/resources/3_0/issue_4832.yaml new file mode 100644 index 000000000000..581ffb146f67 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/issue_4832.yaml @@ -0,0 +1,31 @@ +openapi: 3.0.1 +info: + title: ping that return primitive types + version: '1.0' +servers: + - url: 'http://localhost:8082/' +paths: + /pingBoolean: + get: + operationId: pingGetBoolean + tags: [Ping] + responses: + '200': + description: OK + content: + 'application/json': + schema: + type: boolean + /pingInteger: + get: + operationId: pingGetInteger + tags: [Ping] + responses: + '200': + description: OK + content: + 'application/json': + schema: + type: integer + format: int32 + diff --git a/modules/openapi-generator/src/test/resources/3_0/spring/date-time-parameter-types-for-testing.yml b/modules/openapi-generator/src/test/resources/3_0/spring/date-time-parameter-types-for-testing.yml new file mode 100644 index 000000000000..f32cd9142666 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/spring/date-time-parameter-types-for-testing.yml @@ -0,0 +1,70 @@ +openapi: 3.0.3 +info: + title: Api Documentation + description: 'Demo Spring Mvc @DateTimeFormat across the different openapi parameter types' + version: '1.0' +paths: + /thingy/{date}: + post: + description: 'update with form data' + operationId: updatePetWithForm + parameters: + - name: date + in: path + description: 'A date path parameter' + required: true + schema: + type: string + format: date + example: '2021-01-01' + responses: + '405': + description: Invalid input + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + visitDate: + description: Updated last vist timestamp + type: string + format: date-time + get: + operationId: get + parameters: + - name: date + in: path + description: 'A date path parameter' + required: true + schema: + type: string + format: date + example: '2021-01-01' + - name: dateTime + description: 'A date-time query parameter' + in: query + required: true + schema: + type: string + format: date-time + example: '1996-12-19T16:39:57-08:00' + - name: X-Order-Date + in: header + description: 'A date header parameter' + required: true + schema: + type: string + format: date + example: '2021-01-01' + - name: loginDate + in: cookie + description: 'A date cookie parameter' + required: false + schema: + type: string + format: date + example: '2021-01-01' + responses: + '200': + description: OK \ No newline at end of file diff --git a/pom.xml b/pom.xml index e6463ca0bc08..19927acadef2 100644 --- a/pom.xml +++ b/pom.xml @@ -3,6 +3,7 @@ org.sonatype.oss oss-parent 5 + 4.0.0 org.openapitools @@ -1208,15 +1209,21 @@ samples/server/petstore/jaxrs-resteasy/joda samples/server/petstore/jaxrs-resteasy/default-value - samples/client/petstore/spring-cloud + samples/openapi3/client/petstore/spring-cloud + samples/client/petstore/spring-cloud-date-time + samples/openapi3/client/petstore/spring-cloud-date-time samples/server/petstore/springboot + samples/openapi3/server/petstore/springboot samples/server/petstore/springboot-beanvalidation samples/server/petstore/springboot-useoptional + samples/openapi3/server/petstore/springboot-useoptional samples/server/petstore/springboot-reactive + samples/openapi3/server/petstore/springboot-reactive + samples/server/petstore/springboot-implicitHeaders + samples/openapi3/server/petstore/springboot-implicitHeaders + samples/server/petstore/springboot-delegate + samples/openapi3/server/petstore/springboot-delegate samples/server/petstore/jaxrs-cxf samples/server/petstore/jaxrs-cxf-annotated-base-path samples/server/petstore/jaxrs-cxf-cdi @@ -1230,6 +1237,37 @@ samples/server/petstore/scala-finch + + samples.circleci.spring + + + env + samples.circleci.spring + + + + samples/server/petstore/spring-mvc + samples/server/petstore/spring-mvc-default-value + samples/server/petstore/spring-mvc-j8-async + samples/server/petstore/spring-mvc-j8-localdatetime + + samples/client/petstore/spring-cloud + samples/openapi3/client/petstore/spring-cloud + samples/client/petstore/spring-cloud-date-time + samples/openapi3/client/petstore/spring-cloud-date-time + samples/server/petstore/springboot + samples/openapi3/server/petstore/springboot + samples/server/petstore/springboot-beanvalidation + samples/server/petstore/springboot-useoptional + samples/openapi3/server/petstore/springboot-useoptional + samples/server/petstore/springboot-reactive + samples/openapi3/server/petstore/springboot-reactive + samples/server/petstore/springboot-implicitHeaders + samples/openapi3/server/petstore/springboot-implicitHeaders + samples/server/petstore/springboot-delegate + samples/openapi3/server/petstore/springboot-delegate + + samples.circleci.node3 diff --git a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/Pair.java b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/Pair.java index d94e354bf316..f17b3745f71b 100644 --- a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/Pair.java +++ b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/Pair.java @@ -52,10 +52,6 @@ private boolean isValidString(String arg) { return false; } - if (arg.trim().isEmpty()) { - return false; - } - return true; } } diff --git a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/api/PingApi.java b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/api/PingApi.java index 2f60324f3765..5f408920f53e 100644 --- a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/api/PingApi.java +++ b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/api/PingApi.java @@ -123,7 +123,7 @@ public okhttp3.Call postPingCall(SomeObj someObj, final ApiCallback _callback) t "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/Pair.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/Pair.java index 8352d84046a7..25b5a1b08792 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/Pair.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/Pair.java @@ -52,10 +52,6 @@ private boolean isValidString(String arg) { return false; } - if (arg.trim().isEmpty()) { - return false; - } - return true; } } diff --git a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/Pair.java b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/Pair.java index 8352d84046a7..25b5a1b08792 100644 --- a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/Pair.java +++ b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/Pair.java @@ -52,10 +52,6 @@ private boolean isValidString(String arg) { return false; } - if (arg.trim().isEmpty()) { - return false; - } - return true; } } diff --git a/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/Pair.java b/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/Pair.java index 8352d84046a7..25b5a1b08792 100644 --- a/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/Pair.java +++ b/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/Pair.java @@ -52,10 +52,6 @@ private boolean isValidString(String arg) { return false; } - if (arg.trim().isEmpty()) { - return false; - } - return true; } } diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/Pair.java b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/Pair.java index 8352d84046a7..25b5a1b08792 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/Pair.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/Pair.java @@ -52,10 +52,6 @@ private boolean isValidString(String arg) { return false; } - if (arg.trim().isEmpty()) { - return false; - } - return true; } } diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/Pair.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/Pair.java index e1afb8c039f6..4290a1e6da6f 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/Pair.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/Pair.java @@ -52,10 +52,6 @@ private boolean isValidString(String arg) { return false; } - if (arg.trim().isEmpty()) { - return false; - } - return true; } } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/Pair.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/Pair.java index e1afb8c039f6..4290a1e6da6f 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/Pair.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/Pair.java @@ -52,10 +52,6 @@ private boolean isValidString(String arg) { return false; } - if (arg.trim().isEmpty()) { - return false; - } - return true; } } diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/Pair.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/Pair.java index 8352d84046a7..25b5a1b08792 100644 --- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/Pair.java +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/Pair.java @@ -52,10 +52,6 @@ private boolean isValidString(String arg) { return false; } - if (arg.trim().isEmpty()) { - return false; - } - return true; } } diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/AnotherFakeApi.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/AnotherFakeApi.java index f85c9c873bf8..815719efc1f6 100644 --- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/AnotherFakeApi.java +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/AnotherFakeApi.java @@ -133,7 +133,7 @@ public okhttp3.Call call123testSpecialTagsCall(Client body, final ApiCallback _c "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/FakeApi.java index 5052c1b986c1..c7332815b44f 100644 --- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/FakeApi.java @@ -141,7 +141,7 @@ public okhttp3.Call createXmlItemCall(XmlItem xmlItem, final ApiCallback _callba "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -272,7 +272,7 @@ public okhttp3.Call fakeOuterBooleanSerializeCall(Boolean body, final ApiCallbac }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -402,7 +402,7 @@ public okhttp3.Call fakeOuterCompositeSerializeCall(OuterComposite body, final A }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -532,7 +532,7 @@ public okhttp3.Call fakeOuterNumberSerializeCall(BigDecimal body, final ApiCallb }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -662,7 +662,7 @@ public okhttp3.Call fakeOuterStringSerializeCall(String body, final ApiCallback }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -792,7 +792,7 @@ public okhttp3.Call testBodyWithFileSchemaCall(FileSchemaTestClass body, final A "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -925,7 +925,7 @@ public okhttp3.Call testBodyWithQueryParamsCall(String query, User body, final A "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1064,7 +1064,7 @@ public okhttp3.Call testClientModelCall(Client body, final ApiCallback _callback "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1269,7 +1269,7 @@ public okhttp3.Call testEndpointParametersCall(BigDecimal number, Double _double "application/x-www-form-urlencoded" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1479,7 +1479,7 @@ public okhttp3.Call testEnumParametersCall(List enumHeaderStringArray, S "application/x-www-form-urlencoded" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1623,7 +1623,7 @@ private okhttp3.Call testGroupParametersCall(Integer requiredStringGroup, Boolea }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1844,7 +1844,7 @@ public okhttp3.Call testInlineAdditionalPropertiesCall(Map param "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1984,7 +1984,7 @@ public okhttp3.Call testJsonFormDataCall(String param, String param2, final ApiC "application/x-www-form-urlencoded" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -2132,7 +2132,7 @@ public okhttp3.Call testQueryParameterCollectionFormatCall(List pipe, Li }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java index fcef8d5e735a..2483077a5c8b 100644 --- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java @@ -133,7 +133,7 @@ public okhttp3.Call testClassnameCall(Client body, final ApiCallback _callback) "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/PetApi.java index 2171c8f1a0de..e5ba04115881 100644 --- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/PetApi.java @@ -137,7 +137,7 @@ public okhttp3.Call addPetCall(Pet body, final ApiCallback _callback) throws Api "application/json", "application/xml" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -275,7 +275,7 @@ public okhttp3.Call deletePetCall(Long petId, String apiKey, final ApiCallback _ }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -414,7 +414,7 @@ public okhttp3.Call findPetsByStatusCall(List status, final ApiCallback }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -556,7 +556,7 @@ public okhttp3.Call findPetsByTagsCall(Set tags, final ApiCallback _call }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -704,7 +704,7 @@ public okhttp3.Call getPetByIdCall(Long petId, final ApiCallback _callback) thro }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -848,7 +848,7 @@ public okhttp3.Call updatePetCall(Pet body, final ApiCallback _callback) throws "application/json", "application/xml" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -999,7 +999,7 @@ public okhttp3.Call updatePetWithFormCall(Long petId, String name, String status "application/x-www-form-urlencoded" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1147,7 +1147,7 @@ public okhttp3.Call uploadFileCall(Long petId, String additionalMetadata, File f "multipart/form-data" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1299,7 +1299,7 @@ public okhttp3.Call uploadFileWithRequiredFileCall(Long petId, File requiredFile "multipart/form-data" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/StoreApi.java index a2d86c9f5416..1e32b8c76074 100644 --- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/StoreApi.java +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/StoreApi.java @@ -135,7 +135,7 @@ public okhttp3.Call deleteOrderCall(String orderId, final ApiCallback _callback) }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -268,7 +268,7 @@ public okhttp3.Call getInventoryCall(final ApiCallback _callback) throws ApiExce }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -398,7 +398,7 @@ public okhttp3.Call getOrderByIdCall(Long orderId, final ApiCallback _callback) }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -540,7 +540,7 @@ public okhttp3.Call placeOrderCall(Order body, final ApiCallback _callback) thro }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/UserApi.java index 706ac5239f7a..faf4e626946e 100644 --- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/UserApi.java @@ -134,7 +134,7 @@ public okhttp3.Call createUserCall(User body, final ApiCallback _callback) throw }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -265,7 +265,7 @@ public okhttp3.Call createUsersWithArrayInputCall(List body, final ApiCall }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -396,7 +396,7 @@ public okhttp3.Call createUsersWithListInputCall(List body, final ApiCallb }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -529,7 +529,7 @@ public okhttp3.Call deleteUserCall(String username, final ApiCallback _callback) }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -666,7 +666,7 @@ public okhttp3.Call getUserByNameCall(String username, final ApiCallback _callba }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -811,7 +811,7 @@ public okhttp3.Call loginUserCall(String username, String password, final ApiCal }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -956,7 +956,7 @@ public okhttp3.Call logoutUserCall(final ApiCallback _callback) throws ApiExcept }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1082,7 +1082,7 @@ public okhttp3.Call updateUserCall(String username, User body, final ApiCallback }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/Pair.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/Pair.java index 8352d84046a7..25b5a1b08792 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/Pair.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/Pair.java @@ -52,10 +52,6 @@ private boolean isValidString(String arg) { return false; } - if (arg.trim().isEmpty()) { - return false; - } - return true; } } diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/AnotherFakeApi.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/AnotherFakeApi.java index b0269aea9fcf..9482a5a5f86d 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/AnotherFakeApi.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/AnotherFakeApi.java @@ -91,7 +91,7 @@ public okhttp3.Call call123testSpecialTagsCall(Client client, final ApiCallback "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/DefaultApi.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/DefaultApi.java index 1c8e2d248561..70e9788eb14f 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/DefaultApi.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/DefaultApi.java @@ -90,7 +90,7 @@ public okhttp3.Call fooGetCall(final ApiCallback _callback) throws ApiException }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/FakeApi.java index 50c9b922e985..0e4cf97f1c83 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/FakeApi.java @@ -98,7 +98,7 @@ public okhttp3.Call fakeHealthGetCall(final ApiCallback _callback) throws ApiExc }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -209,7 +209,7 @@ public okhttp3.Call fakeOuterBooleanSerializeCall(Boolean body, final ApiCallbac "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -323,7 +323,7 @@ public okhttp3.Call fakeOuterCompositeSerializeCall(OuterComposite outerComposit "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -437,7 +437,7 @@ public okhttp3.Call fakeOuterNumberSerializeCall(BigDecimal body, final ApiCallb "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -551,7 +551,7 @@ public okhttp3.Call fakeOuterStringSerializeCall(String body, final ApiCallback "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -664,7 +664,7 @@ public okhttp3.Call getArrayOfEnumsCall(final ApiCallback _callback) throws ApiE }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -780,7 +780,7 @@ public okhttp3.Call testBodyWithQueryParamsCall(String query, User user, final A "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -897,7 +897,7 @@ public okhttp3.Call testClientModelCall(Client client, final ApiCallback _callba "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1086,7 +1086,7 @@ public okhttp3.Call testEndpointParametersCall(BigDecimal number, Double _double "application/x-www-form-urlencoded" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1292,7 +1292,7 @@ public okhttp3.Call testEnumParametersCall(List enumHeaderStringArray, S "application/x-www-form-urlencoded" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1432,7 +1432,7 @@ private okhttp3.Call testGroupParametersCall(Integer requiredStringGroup, Boolea }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1631,7 +1631,7 @@ public okhttp3.Call testInlineAdditionalPropertiesCall(Map reque "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1749,7 +1749,7 @@ public okhttp3.Call testJsonFormDataCall(String param, String param2, final ApiC "application/x-www-form-urlencoded" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1890,7 +1890,7 @@ public okhttp3.Call testQueryParameterCollectionFormatCall(List pipe, Li }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java index db7a5f435f4c..1fac7240705a 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java @@ -91,7 +91,7 @@ public okhttp3.Call testClassnameCall(Client client, final ApiCallback _callback "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/PetApi.java index 98d73aa76f0b..c1523ef07907 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/PetApi.java @@ -93,7 +93,7 @@ public okhttp3.Call addPetCall(Pet pet, final ApiCallback _callback) throws ApiE "application/json", "application/xml" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -208,7 +208,7 @@ public okhttp3.Call deletePetCall(Long petId, String apiKey, final ApiCallback _ }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -325,7 +325,7 @@ public okhttp3.Call findPetsByStatusCall(List status, final ApiCallback }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -454,7 +454,7 @@ public okhttp3.Call findPetsByTagsCall(List tags, final ApiCallback _cal }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -586,7 +586,7 @@ public okhttp3.Call getPetByIdCall(Long petId, final ApiCallback _callback) thro }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -713,7 +713,7 @@ public okhttp3.Call updatePetCall(Pet pet, final ApiCallback _callback) throws A "application/json", "application/xml" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -839,7 +839,7 @@ public okhttp3.Call updatePetWithFormCall(Long petId, String name, String status "application/x-www-form-urlencoded" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -965,7 +965,7 @@ public okhttp3.Call uploadFileCall(Long petId, String additionalMetadata, File f "multipart/form-data" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1101,7 +1101,7 @@ public okhttp3.Call uploadFileWithRequiredFileCall(Long petId, File requiredFile "multipart/form-data" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/StoreApi.java index ab5718fb99c5..5d93e6322231 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/StoreApi.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/StoreApi.java @@ -93,7 +93,7 @@ public okhttp3.Call deleteOrderCall(String orderId, final ApiCallback _callback) }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -204,7 +204,7 @@ public okhttp3.Call getInventoryCall(final ApiCallback _callback) throws ApiExce }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -318,7 +318,7 @@ public okhttp3.Call getOrderByIdCall(Long orderId, final ApiCallback _callback) }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -444,7 +444,7 @@ public okhttp3.Call placeOrderCall(Order order, final ApiCallback _callback) thr "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } diff --git a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/UserApi.java index df1e507d1e43..56c6433a490a 100644 --- a/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/okhttp-gson-nextgen/src/main/java/org/openapitools/client/api/UserApi.java @@ -92,7 +92,7 @@ public okhttp3.Call createUserCall(User user, final ApiCallback _callback) throw "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -201,7 +201,7 @@ public okhttp3.Call createUsersWithArrayInputCall(List user, final ApiCall "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -310,7 +310,7 @@ public okhttp3.Call createUsersWithListInputCall(List user, final ApiCallb "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -421,7 +421,7 @@ public okhttp3.Call deleteUserCall(String username, final ApiCallback _callback) }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -536,7 +536,7 @@ public okhttp3.Call getUserByNameCall(String username, final ApiCallback _callba }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -671,7 +671,7 @@ public okhttp3.Call loginUserCall(String username, String password, final ApiCal }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -800,7 +800,7 @@ public okhttp3.Call logoutUserCall(final ApiCallback _callback) throws ApiExcept }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -904,7 +904,7 @@ public okhttp3.Call updateUserCall(String username, User user, final ApiCallback "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/Pair.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/Pair.java index 8352d84046a7..25b5a1b08792 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/Pair.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/Pair.java @@ -52,10 +52,6 @@ private boolean isValidString(String arg) { return false; } - if (arg.trim().isEmpty()) { - return false; - } - return true; } } diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/AnotherFakeApi.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/AnotherFakeApi.java index 07dd5b37fb24..af9e915240d6 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/AnotherFakeApi.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/AnotherFakeApi.java @@ -122,7 +122,7 @@ public okhttp3.Call call123testSpecialTagsCall(Client body, final ApiCallback _c "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/FakeApi.java index 7c1a5959f08f..b27961d1479f 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/FakeApi.java @@ -130,7 +130,7 @@ public okhttp3.Call createXmlItemCall(XmlItem xmlItem, final ApiCallback _callba "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -253,7 +253,7 @@ public okhttp3.Call fakeOuterBooleanSerializeCall(Boolean body, final ApiCallbac }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -375,7 +375,7 @@ public okhttp3.Call fakeOuterCompositeSerializeCall(OuterComposite body, final A }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -497,7 +497,7 @@ public okhttp3.Call fakeOuterNumberSerializeCall(BigDecimal body, final ApiCallb }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -619,7 +619,7 @@ public okhttp3.Call fakeOuterStringSerializeCall(String body, final ApiCallback }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -741,7 +741,7 @@ public okhttp3.Call testBodyWithFileSchemaCall(FileSchemaTestClass body, final A "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -869,7 +869,7 @@ public okhttp3.Call testBodyWithQueryParamsCall(String query, User body, final A "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1000,7 +1000,7 @@ public okhttp3.Call testClientModelCall(Client body, final ApiCallback _callback "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1197,7 +1197,7 @@ public okhttp3.Call testEndpointParametersCall(BigDecimal number, Double _double "application/x-www-form-urlencoded" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1417,7 +1417,7 @@ public okhttp3.Call testEnumParametersCall(List enumHeaderStringArray, S "application/x-www-form-urlencoded" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1571,7 +1571,7 @@ private okhttp3.Call testGroupParametersCall(Integer requiredStringGroup, Boolea }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1784,7 +1784,7 @@ public okhttp3.Call testInlineAdditionalPropertiesCall(Map param "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1916,7 +1916,7 @@ public okhttp3.Call testJsonFormDataCall(String param, String param2, final ApiC "application/x-www-form-urlencoded" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -2071,7 +2071,7 @@ public okhttp3.Call testQueryParameterCollectionFormatCall(List pipe, Li }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java index 6073bb91da6d..d6bac0d84af7 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java @@ -122,7 +122,7 @@ public okhttp3.Call testClassnameCall(Client body, final ApiCallback _callback) "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/PetApi.java index 6f6083f2d2ca..2f90b4257f9e 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/PetApi.java @@ -126,7 +126,7 @@ public okhttp3.Call addPetCall(Pet body, final ApiCallback _callback) throws Api "application/json", "application/xml" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -259,7 +259,7 @@ public okhttp3.Call deletePetCall(Long petId, String apiKey, final ApiCallback _ }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -393,7 +393,7 @@ public okhttp3.Call findPetsByStatusCall(List status, final ApiCallback }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -530,7 +530,7 @@ public okhttp3.Call findPetsByTagsCall(Set tags, final ApiCallback _call }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -670,7 +670,7 @@ public okhttp3.Call getPetByIdCall(Long petId, final ApiCallback _callback) thro }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -806,7 +806,7 @@ public okhttp3.Call updatePetCall(Pet body, final ApiCallback _callback) throws "application/json", "application/xml" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -949,7 +949,7 @@ public okhttp3.Call updatePetWithFormCall(Long petId, String name, String status "application/x-www-form-urlencoded" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1089,7 +1089,7 @@ public okhttp3.Call uploadFileCall(Long petId, String additionalMetadata, File f "multipart/form-data" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1233,7 +1233,7 @@ public okhttp3.Call uploadFileWithRequiredFileCall(Long petId, File requiredFile "multipart/form-data" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/StoreApi.java index 21960166fd9b..9aeea0062d0d 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/StoreApi.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/StoreApi.java @@ -124,7 +124,7 @@ public okhttp3.Call deleteOrderCall(String orderId, final ApiCallback _callback) }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -249,7 +249,7 @@ public okhttp3.Call getInventoryCall(final ApiCallback _callback) throws ApiExce }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -371,7 +371,7 @@ public okhttp3.Call getOrderByIdCall(Long orderId, final ApiCallback _callback) }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -505,7 +505,7 @@ public okhttp3.Call placeOrderCall(Order body, final ApiCallback _callback) thro }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/UserApi.java index f47c499de125..abf14e6dba3f 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/api/UserApi.java @@ -123,7 +123,7 @@ public okhttp3.Call createUserCall(User body, final ApiCallback _callback) throw }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -246,7 +246,7 @@ public okhttp3.Call createUsersWithArrayInputCall(List body, final ApiCall }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -369,7 +369,7 @@ public okhttp3.Call createUsersWithListInputCall(List body, final ApiCallb }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -494,7 +494,7 @@ public okhttp3.Call deleteUserCall(String username, final ApiCallback _callback) }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -623,7 +623,7 @@ public okhttp3.Call getUserByNameCall(String username, final ApiCallback _callba }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -766,7 +766,7 @@ public okhttp3.Call loginUserCall(String username, String password, final ApiCal }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -903,7 +903,7 @@ public okhttp3.Call logoutUserCall(final ApiCallback _callback) throws ApiExcept }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1021,7 +1021,7 @@ public okhttp3.Call updateUserCall(String username, User body, final ApiCallback }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/Pair.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/Pair.java index 8352d84046a7..25b5a1b08792 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/Pair.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/Pair.java @@ -52,10 +52,6 @@ private boolean isValidString(String arg) { return false; } - if (arg.trim().isEmpty()) { - return false; - } - return true; } } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/AnotherFakeApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/AnotherFakeApi.java index 07dd5b37fb24..af9e915240d6 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/AnotherFakeApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/AnotherFakeApi.java @@ -122,7 +122,7 @@ public okhttp3.Call call123testSpecialTagsCall(Client body, final ApiCallback _c "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/FakeApi.java index 7c1a5959f08f..b27961d1479f 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/FakeApi.java @@ -130,7 +130,7 @@ public okhttp3.Call createXmlItemCall(XmlItem xmlItem, final ApiCallback _callba "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -253,7 +253,7 @@ public okhttp3.Call fakeOuterBooleanSerializeCall(Boolean body, final ApiCallbac }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -375,7 +375,7 @@ public okhttp3.Call fakeOuterCompositeSerializeCall(OuterComposite body, final A }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -497,7 +497,7 @@ public okhttp3.Call fakeOuterNumberSerializeCall(BigDecimal body, final ApiCallb }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -619,7 +619,7 @@ public okhttp3.Call fakeOuterStringSerializeCall(String body, final ApiCallback }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -741,7 +741,7 @@ public okhttp3.Call testBodyWithFileSchemaCall(FileSchemaTestClass body, final A "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -869,7 +869,7 @@ public okhttp3.Call testBodyWithQueryParamsCall(String query, User body, final A "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1000,7 +1000,7 @@ public okhttp3.Call testClientModelCall(Client body, final ApiCallback _callback "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1197,7 +1197,7 @@ public okhttp3.Call testEndpointParametersCall(BigDecimal number, Double _double "application/x-www-form-urlencoded" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1417,7 +1417,7 @@ public okhttp3.Call testEnumParametersCall(List enumHeaderStringArray, S "application/x-www-form-urlencoded" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1571,7 +1571,7 @@ private okhttp3.Call testGroupParametersCall(Integer requiredStringGroup, Boolea }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1784,7 +1784,7 @@ public okhttp3.Call testInlineAdditionalPropertiesCall(Map param "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1916,7 +1916,7 @@ public okhttp3.Call testJsonFormDataCall(String param, String param2, final ApiC "application/x-www-form-urlencoded" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -2071,7 +2071,7 @@ public okhttp3.Call testQueryParameterCollectionFormatCall(List pipe, Li }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java index 6073bb91da6d..d6bac0d84af7 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java @@ -122,7 +122,7 @@ public okhttp3.Call testClassnameCall(Client body, final ApiCallback _callback) "application/json" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/PetApi.java index 6f6083f2d2ca..2f90b4257f9e 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/PetApi.java @@ -126,7 +126,7 @@ public okhttp3.Call addPetCall(Pet body, final ApiCallback _callback) throws Api "application/json", "application/xml" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -259,7 +259,7 @@ public okhttp3.Call deletePetCall(Long petId, String apiKey, final ApiCallback _ }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -393,7 +393,7 @@ public okhttp3.Call findPetsByStatusCall(List status, final ApiCallback }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -530,7 +530,7 @@ public okhttp3.Call findPetsByTagsCall(Set tags, final ApiCallback _call }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -670,7 +670,7 @@ public okhttp3.Call getPetByIdCall(Long petId, final ApiCallback _callback) thro }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -806,7 +806,7 @@ public okhttp3.Call updatePetCall(Pet body, final ApiCallback _callback) throws "application/json", "application/xml" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -949,7 +949,7 @@ public okhttp3.Call updatePetWithFormCall(Long petId, String name, String status "application/x-www-form-urlencoded" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1089,7 +1089,7 @@ public okhttp3.Call uploadFileCall(Long petId, String additionalMetadata, File f "multipart/form-data" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1233,7 +1233,7 @@ public okhttp3.Call uploadFileWithRequiredFileCall(Long petId, File requiredFile "multipart/form-data" }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/StoreApi.java index 21960166fd9b..9aeea0062d0d 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/StoreApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/StoreApi.java @@ -124,7 +124,7 @@ public okhttp3.Call deleteOrderCall(String orderId, final ApiCallback _callback) }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -249,7 +249,7 @@ public okhttp3.Call getInventoryCall(final ApiCallback _callback) throws ApiExce }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -371,7 +371,7 @@ public okhttp3.Call getOrderByIdCall(Long orderId, final ApiCallback _callback) }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -505,7 +505,7 @@ public okhttp3.Call placeOrderCall(Order body, final ApiCallback _callback) thro }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/UserApi.java index f47c499de125..abf14e6dba3f 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/UserApi.java @@ -123,7 +123,7 @@ public okhttp3.Call createUserCall(User body, final ApiCallback _callback) throw }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -246,7 +246,7 @@ public okhttp3.Call createUsersWithArrayInputCall(List body, final ApiCall }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -369,7 +369,7 @@ public okhttp3.Call createUsersWithListInputCall(List body, final ApiCallb }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -494,7 +494,7 @@ public okhttp3.Call deleteUserCall(String username, final ApiCallback _callback) }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -623,7 +623,7 @@ public okhttp3.Call getUserByNameCall(String username, final ApiCallback _callba }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -766,7 +766,7 @@ public okhttp3.Call loginUserCall(String username, String password, final ApiCal }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -903,7 +903,7 @@ public okhttp3.Call logoutUserCall(final ApiCallback _callback) throws ApiExcept }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } @@ -1021,7 +1021,7 @@ public okhttp3.Call updateUserCall(String username, User body, final ApiCallback }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarHeaderParams != null) { + if (localVarHeaderParams != null && localVarContentTypes != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } diff --git a/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/Pair.java b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/Pair.java index 8352d84046a7..25b5a1b08792 100644 --- a/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/Pair.java +++ b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/Pair.java @@ -52,10 +52,6 @@ private boolean isValidString(String arg) { return false; } - if (arg.trim().isEmpty()) { - return false; - } - return true; } } diff --git a/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/Pair.java b/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/Pair.java index 8352d84046a7..25b5a1b08792 100644 --- a/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/Pair.java +++ b/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/Pair.java @@ -52,10 +52,6 @@ private boolean isValidString(String arg) { return false; } - if (arg.trim().isEmpty()) { - return false; - } - return true; } } diff --git a/samples/client/petstore/java/vertx-no-nullable/src/main/java/org/openapitools/client/Pair.java b/samples/client/petstore/java/vertx-no-nullable/src/main/java/org/openapitools/client/Pair.java index 8352d84046a7..25b5a1b08792 100644 --- a/samples/client/petstore/java/vertx-no-nullable/src/main/java/org/openapitools/client/Pair.java +++ b/samples/client/petstore/java/vertx-no-nullable/src/main/java/org/openapitools/client/Pair.java @@ -52,10 +52,6 @@ private boolean isValidString(String arg) { return false; } - if (arg.trim().isEmpty()) { - return false; - } - return true; } } diff --git a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/Pair.java b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/Pair.java index 8352d84046a7..25b5a1b08792 100644 --- a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/Pair.java +++ b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/Pair.java @@ -52,10 +52,6 @@ private boolean isValidString(String arg) { return false; } - if (arg.trim().isEmpty()) { - return false; - } - return true; } } diff --git a/samples/client/petstore/spring-cloud-async/pom.xml b/samples/client/petstore/spring-cloud-async/pom.xml index 254a8357fce7..6b400a3539fe 100644 --- a/samples/client/petstore/spring-cloud-async/pom.xml +++ b/samples/client/petstore/spring-cloud-async/pom.xml @@ -9,12 +9,13 @@ 1.8 ${java.version} ${java.version} - 1.5.18 + 1.6.3 + 2.9.2 org.springframework.boot spring-boot-starter-parent - 2.5.5 + 2.6.2 src/main/java @@ -25,7 +26,7 @@ org.springframework.cloud spring-cloud-starter-parent - 2020.0.4 + 2021.0.0 pom import @@ -33,10 +34,11 @@ + - io.swagger - swagger-annotations - ${swagger-core-version} + io.springfox + springfox-swagger2 + ${springfox.version} @@ -60,26 +62,20 @@ org.openapitools jackson-databind-nullable - 0.2.1 + 0.2.2 org.springframework.boot - spring-boot-starter-test - test - - - org.hibernate.validator - hibernate-validator - 6.0.16.Final - - - io.springfox - springfox-swagger2 - 3.0.0 + spring-boot-starter-validation org.springframework.data spring-data-commons + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/samples/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/PetApi.java b/samples/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/PetApi.java index 5dc83bfe7f5a..91ee30f66ad4 100644 --- a/samples/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/PetApi.java @@ -33,23 +33,29 @@ public interface PetApi { * @param body Pet object that needs to be added to the store (required) * @return Invalid input (status code 405) */ - - @ApiOperation(value = "Add a new pet to the store", nickname = "addPet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 405, message = "Invalid input") }) + @ApiOperation( + tags = { "pet" }, + value = "Add a new pet to the store", + nickname = "addPet", + 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", consumes = "application/json" ) CompletableFuture> addPet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body); + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ); /** @@ -59,24 +65,29 @@ CompletableFuture> addPet( * @param apiKey (optional) * @return Invalid pet value (status code 400) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 400, message = "Invalid pet value") }) + @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}" ) - CompletableFuture> deletePet(@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId - -, -@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey -); + CompletableFuture> deletePet( + @ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey + ); /** @@ -87,25 +98,32 @@ CompletableFuture> deletePet(@ApiParam(value = "Pet id to d * @return successful operation (status code 200) * or Invalid status value (status code 400) */ - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid status value") }) + @ApiResponse(code = 400, message = "Invalid status value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByStatus", produces = "application/json" ) - CompletableFuture>> 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 status - -); + CompletableFuture>> 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 status + ); /** @@ -117,25 +135,32 @@ CompletableFuture>> findPetsByStatus(@NotNull @ApiParam * or Invalid tag value (status code 400) * @deprecated */ - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid tag value") }) + @ApiResponse(code = 400, message = "Invalid tag value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByTags", produces = "application/json" ) - CompletableFuture>> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags - -); + CompletableFuture>> findPetsByTags( + @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags + ); /** @@ -147,26 +172,29 @@ CompletableFuture>> findPetsByTags(@NotNull @ApiParam(v * or Invalid ID supplied (status code 400) * or Pet not found (status code 404) */ - - @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { - - @Authorization(value = "api_key") - }, tags={ "pet", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Pet not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/{petId}", produces = "application/json" ) - CompletableFuture> getPetById(@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId - -); + CompletableFuture> getPetById( + @ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId + ); /** @@ -177,27 +205,31 @@ CompletableFuture> getPetById(@ApiParam(value = "ID of pet t * or Pet not found (status code 404) * or Validation exception (status code 405) */ - - @ApiOperation(value = "Update an existing pet", nickname = "updatePet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Update an existing pet", + nickname = "updatePet", + 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 ID supplied"), - @ApiResponse(code = 404, message = "Pet not found"), - - @ApiResponse(code = 405, message = "Validation exception") }) + @ApiResponse(code = 405, message = "Validation exception") + }) @RequestMapping( method = RequestMethod.PUT, value = "/pet", consumes = "application/json" ) CompletableFuture> updatePet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body); + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ); /** @@ -208,27 +240,31 @@ CompletableFuture> updatePet( * @param status Updated status of the pet (optional) * @return Invalid input (status code 405) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 405, message = "Invalid input") }) + @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" ) - CompletableFuture> updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "Updated name of the pet" ) @RequestParam(value="name", required=false) String name, - -@ApiParam(value = "Updated status of the pet" ) @RequestParam(value="status", required=false) String status); + CompletableFuture> updatePetWithForm( + @ApiParam(value = "ID of pet that needs to be updated", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "Updated name of the pet") @RequestParam(value="name", required=false) String name, + @ApiParam(value = "Updated status of the pet") @RequestParam(value="status", required=false) String status + ); /** @@ -239,27 +275,32 @@ CompletableFuture> updatePetWithForm(@ApiParam(value = "ID * @param file file to upload (optional) * @return successful operation (status code 200) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @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" ) - CompletableFuture> uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "Additional data to pass to server" ) @RequestParam(value="additionalMetadata", required=false) String additionalMetadata, - -@ApiParam(value = "file to upload") @RequestParam("file") MultipartFile file); + CompletableFuture> uploadFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "Additional data to pass to server") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata, + @ApiParam(value = "file to upload") @RequestParam("file") MultipartFile file + ); } diff --git a/samples/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/StoreApi.java b/samples/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/StoreApi.java index 4c4c4a22d856..064c2e04fccc 100644 --- a/samples/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/StoreApi.java @@ -35,20 +35,23 @@ public interface StoreApi { * @return Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(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", tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/store/order/{orderId}" ) - CompletableFuture> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") String orderId - -); + CompletableFuture> deleteOrder( + @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") String orderId + ); /** @@ -57,20 +60,28 @@ CompletableFuture> deleteOrder(@ApiParam(value = "ID of the * * @return successful operation (status code 200) */ - - @ApiOperation(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") - }, tags={ "store", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) + @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" ) - CompletableFuture>> getInventory(); + CompletableFuture>> getInventory( + + ); /** @@ -82,23 +93,26 @@ CompletableFuture> deleteOrder(@ApiParam(value = "ID of the * or Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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 generated 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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/store/order/{orderId}", produces = "application/json" ) - CompletableFuture> getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") Long orderId - -); + CompletableFuture> getOrderById( + @Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") Long orderId + ); /** @@ -108,20 +122,24 @@ CompletableFuture> getOrderById(@Min(1L) @Max(5L) @ApiPara * @return successful operation (status code 200) * or Invalid Order (status code 400) */ - - @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid Order") + }) @RequestMapping( method = RequestMethod.POST, value = "/store/order", produces = "application/json" ) CompletableFuture> placeOrder( - -@ApiParam(value = "order placed for purchasing the pet", required = true ) @Valid @RequestBody Order body); + @ApiParam(value = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order body + ); } diff --git a/samples/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/UserApi.java b/samples/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/UserApi.java index 00028e4eba77..d8ac4e40ef0c 100644 --- a/samples/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/UserApi.java @@ -35,18 +35,22 @@ public interface UserApi { * @param body Created user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Create user", + nickname = "createUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user" ) CompletableFuture> createUser( - -@ApiParam(value = "Created user object", required = true ) @Valid @RequestBody User body); + @ApiParam(value = "Created user object", required = true) @Valid @RequestBody User body + ); /** @@ -55,18 +59,22 @@ CompletableFuture> createUser( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithArrayInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithArray" ) CompletableFuture> createUsersWithArrayInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body); + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ); /** @@ -75,18 +83,22 @@ CompletableFuture> createUsersWithArrayInput( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithListInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithList" ) CompletableFuture> createUsersWithListInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body); + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ); /** @@ -97,20 +109,23 @@ CompletableFuture> createUsersWithListInput( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Delete user", + nickname = "deleteUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/user/{username}" ) - CompletableFuture> deleteUser(@ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username - -); + CompletableFuture> deleteUser( + @ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username + ); /** @@ -121,23 +136,26 @@ CompletableFuture> deleteUser(@ApiParam(value = "The name t * or Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/{username}", produces = "application/json" ) - CompletableFuture> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username - -); + CompletableFuture> getUserByName( + @ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username + ); /** @@ -148,23 +166,26 @@ CompletableFuture> getUserByName(@ApiParam(value = "The nam * @return successful operation (status code 200) * or Invalid username/password supplied (status code 400) */ - - @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid username/password supplied") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/login", produces = "application/json" ) - CompletableFuture> loginUser(@NotNull @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 - -); + CompletableFuture> loginUser( + @NotNull @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 + ); /** @@ -172,16 +193,22 @@ CompletableFuture> loginUser(@NotNull @ApiParam(value = " * * @return successful operation (status code 200) */ - - @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Logs out current logged in user session", + nickname = "logoutUser", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/logout" ) - CompletableFuture> logoutUser(); + CompletableFuture> logoutUser( + + ); /** @@ -193,21 +220,23 @@ CompletableFuture> loginUser(@NotNull @ApiParam(value = " * @return Invalid user supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Updated user", + nickname = "updateUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid user supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.PUT, value = "/user/{username}" ) - CompletableFuture> 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 body); + CompletableFuture> 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 body + ); } diff --git a/samples/client/petstore/spring-cloud-date-time/.openapi-generator-ignore b/samples/client/petstore/spring-cloud-date-time/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/spring-cloud-date-time/.openapi-generator-ignore @@ -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 diff --git a/samples/client/petstore/spring-cloud-date-time/.openapi-generator/FILES b/samples/client/petstore/spring-cloud-date-time/.openapi-generator/FILES new file mode 100644 index 000000000000..0849e5aac50a --- /dev/null +++ b/samples/client/petstore/spring-cloud-date-time/.openapi-generator/FILES @@ -0,0 +1,3 @@ +README.md +pom.xml +src/main/java/org/openapitools/api/DefaultApi.java diff --git a/samples/client/petstore/spring-cloud-date-time/.openapi-generator/VERSION b/samples/client/petstore/spring-cloud-date-time/.openapi-generator/VERSION new file mode 100644 index 000000000000..0984c4c1ad21 --- /dev/null +++ b/samples/client/petstore/spring-cloud-date-time/.openapi-generator/VERSION @@ -0,0 +1 @@ +5.4.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/spring-cloud-date-time/README.md b/samples/client/petstore/spring-cloud-date-time/README.md new file mode 100644 index 000000000000..a462be951ace --- /dev/null +++ b/samples/client/petstore/spring-cloud-date-time/README.md @@ -0,0 +1,26 @@ +# OpenAPI generated API stub + +Spring Framework stub + + +## Overview +This code was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. +By using the [OpenAPI-Spec](https://openapis.org), you can easily generate an API stub. +This is an example of building API stub interfaces in Java using the Spring framework. + +The stubs generated can be used in your existing Spring-MVC or Spring-Boot application to create controller endpoints +by adding ```@Controller``` classes that implement the interface. Eg: +```java +@Controller +public class PetController implements PetApi { +// implement all PetApi methods +} +``` + +You can also use the interface to create [Spring-Cloud Feign clients](http://projects.spring.io/spring-cloud/spring-cloud.html#spring-cloud-feign-inheritance).Eg: +```java +@FeignClient(name="pet", url="http://petstore.swagger.io/v2") +public interface PetClient extends PetApi { + +} +``` diff --git a/samples/client/petstore/spring-cloud-date-time/pom.xml b/samples/client/petstore/spring-cloud-date-time/pom.xml new file mode 100644 index 000000000000..c01b2969fb37 --- /dev/null +++ b/samples/client/petstore/spring-cloud-date-time/pom.xml @@ -0,0 +1,81 @@ + + 4.0.0 + org.openapitools + spring-cloud-date-time + jar + spring-cloud-date-time + 1.0 + + 1.8 + ${java.version} + ${java.version} + 1.6.3 + 2.9.2 + + + org.springframework.boot + spring-boot-starter-parent + 2.6.2 + + + src/main/java + + + + + + org.springframework.cloud + spring-cloud-starter-parent + 2021.0.0 + pom + import + + + + + + + + io.springfox + springfox-swagger2 + ${springfox.version} + + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + org.springframework.cloud + spring-cloud-starter-oauth2 + 2.2.5.RELEASE + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + + + org.openapitools + jackson-databind-nullable + 0.2.2 + + + org.springframework.boot + spring-boot-starter-validation + + + org.springframework.data + spring-data-commons + + + org.springframework.boot + spring-boot-starter-test + test + + + diff --git a/samples/client/petstore/spring-cloud-date-time/src/main/java/org/openapitools/api/DefaultApi.java b/samples/client/petstore/spring-cloud-date-time/src/main/java/org/openapitools/api/DefaultApi.java new file mode 100644 index 000000000000..54e556cb9ed2 --- /dev/null +++ b/samples/client/petstore/spring-cloud-date-time/src/main/java/org/openapitools/api/DefaultApi.java @@ -0,0 +1,86 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.openapitools.api; + +import java.time.LocalDate; +import java.time.OffsetDateTime; +import io.swagger.annotations.*; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Api(value = "Default", description = "the Default API") +public interface DefaultApi { + + /** + * GET /thingy/{date} + * + * @param date A date path parameter (required) + * @param dateTime A date-time query parameter (required) + * @param xOrderDate A date header parameter (required) + * @param loginDate A date cookie parameter (optional) + * @return OK (status code 200) + */ + @ApiOperation( + tags = { }, + value = "", + nickname = "get", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "OK") + }) + @RequestMapping( + method = RequestMethod.GET, + value = "/thingy/{date}" + ) + ResponseEntity get( + @ApiParam(value = "A date path parameter", required = true) @PathVariable("date") @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @NotNull @ApiParam(value = "A date-time query parameter", required = true) @Valid @RequestParam(value = "dateTime", required = true) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @ApiParam(value = "A date header parameter", required = true) @RequestHeader(value = "X-Order-Date", required = true) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate xOrderDate, + @ApiParam(value = "A date cookie parameter") @CookieValue("loginDate") @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate loginDate + ); + + + /** + * POST /thingy/{date} + * update with form data + * + * @param date A date path parameter (required) + * @param visitDate Updated last vist timestamp (optional) + * @return Invalid input (status code 405) + */ + @ApiOperation( + tags = { }, + value = "", + nickname = "updatePetWithForm", + notes = "update with form data" + ) + @ApiResponses({ + @ApiResponse(code = 405, message = "Invalid input") + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/thingy/{date}", + consumes = "application/x-www-form-urlencoded" + ) + ResponseEntity updatePetWithForm( + @ApiParam(value = "A date path parameter", required = true) @PathVariable("date") @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @ApiParam(value = "Updated last vist timestamp") @RequestParam(value="visitDate", required=false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime visitDate + ); + +} diff --git a/samples/client/petstore/spring-cloud-spring-pageable/pom.xml b/samples/client/petstore/spring-cloud-spring-pageable/pom.xml index 4d47a4864224..622e4334036f 100644 --- a/samples/client/petstore/spring-cloud-spring-pageable/pom.xml +++ b/samples/client/petstore/spring-cloud-spring-pageable/pom.xml @@ -9,12 +9,13 @@ 1.8 ${java.version} ${java.version} - 1.5.18 + 1.6.3 + 2.9.2 org.springframework.boot spring-boot-starter-parent - 2.5.5 + 2.6.2 src/main/java @@ -25,7 +26,7 @@ org.springframework.cloud spring-cloud-starter-parent - 2020.0.4 + 2021.0.0 pom import @@ -33,10 +34,11 @@ + - io.swagger - swagger-annotations - ${swagger-core-version} + io.springfox + springfox-swagger2 + ${springfox.version} @@ -60,26 +62,20 @@ org.openapitools jackson-databind-nullable - 0.2.1 + 0.2.2 org.springframework.boot - spring-boot-starter-test - test - - - org.hibernate.validator - hibernate-validator - 6.0.16.Final - - - io.springfox - springfox-swagger2 - 3.0.0 + spring-boot-starter-validation org.springframework.data spring-data-commons + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/samples/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/PetApi.java b/samples/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/PetApi.java index ff269d04b79d..47a8e6a4d2e8 100644 --- a/samples/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/PetApi.java @@ -32,23 +32,29 @@ public interface PetApi { * @param body Pet object that needs to be added to the store (required) * @return Invalid input (status code 405) */ - - @ApiOperation(value = "Add a new pet to the store", nickname = "addPet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 405, message = "Invalid input") }) + @ApiOperation( + tags = { "pet" }, + value = "Add a new pet to the store", + nickname = "addPet", + 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", consumes = "application/json" ) ResponseEntity addPet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body); + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ); /** @@ -58,24 +64,29 @@ ResponseEntity addPet( * @param apiKey (optional) * @return Invalid pet value (status code 400) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 400, message = "Invalid pet value") }) + @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}" ) - ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId - -, -@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey -); + ResponseEntity deletePet( + @ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey + ); /** @@ -86,25 +97,33 @@ ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", required = * @return successful operation (status code 200) * or Invalid status value (status code 400) */ - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid status value") }) + @ApiResponse(code = 400, message = "Invalid status value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByStatus", produces = "application/json" ) - ResponseEntity> 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 status - -, @springfox.documentation.annotations.ApiIgnore final org.springframework.data.domain.Pageable pageable); + ResponseEntity> 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 status, + @springfox.documentation.annotations.ApiIgnore final org.springframework.data.domain.Pageable pageable + ); /** @@ -116,25 +135,33 @@ ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status va * or Invalid tag value (status code 400) * @deprecated */ - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid tag value") }) + @ApiResponse(code = 400, message = "Invalid tag value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByTags", produces = "application/json" ) - ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags - -, @springfox.documentation.annotations.ApiIgnore final org.springframework.data.domain.Pageable pageable); + ResponseEntity> findPetsByTags( + @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, + @springfox.documentation.annotations.ApiIgnore final org.springframework.data.domain.Pageable pageable + ); /** @@ -146,26 +173,29 @@ ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to fil * or Invalid ID supplied (status code 400) * or Pet not found (status code 404) */ - - @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { - - @Authorization(value = "api_key") - }, tags={ "pet", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Pet not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/{petId}", produces = "application/json" ) - ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId - -); + ResponseEntity getPetById( + @ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId + ); /** @@ -176,27 +206,31 @@ ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", required * or Pet not found (status code 404) * or Validation exception (status code 405) */ - - @ApiOperation(value = "Update an existing pet", nickname = "updatePet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Update an existing pet", + nickname = "updatePet", + 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 ID supplied"), - @ApiResponse(code = 404, message = "Pet not found"), - - @ApiResponse(code = 405, message = "Validation exception") }) + @ApiResponse(code = 405, message = "Validation exception") + }) @RequestMapping( method = RequestMethod.PUT, value = "/pet", consumes = "application/json" ) ResponseEntity updatePet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body); + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ); /** @@ -207,27 +241,31 @@ ResponseEntity updatePet( * @param status Updated status of the pet (optional) * @return Invalid input (status code 405) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 405, message = "Invalid input") }) + @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" ) - ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "Updated name of the pet" ) @RequestParam(value="name", required=false) String name, - -@ApiParam(value = "Updated status of the pet" ) @RequestParam(value="status", required=false) String status); + ResponseEntity updatePetWithForm( + @ApiParam(value = "ID of pet that needs to be updated", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "Updated name of the pet") @RequestParam(value="name", required=false) String name, + @ApiParam(value = "Updated status of the pet") @RequestParam(value="status", required=false) String status + ); /** @@ -238,27 +276,32 @@ ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs t * @param file file to upload (optional) * @return successful operation (status code 200) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @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" ) - ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "Additional data to pass to server" ) @RequestParam(value="additionalMetadata", required=false) String additionalMetadata, - -@ApiParam(value = "file to upload") @RequestParam("file") MultipartFile file); + ResponseEntity uploadFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "Additional data to pass to server") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata, + @ApiParam(value = "file to upload") @RequestParam("file") MultipartFile file + ); } diff --git a/samples/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/StoreApi.java b/samples/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/StoreApi.java index 8da96775527c..5ed5ec1fd49c 100644 --- a/samples/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/StoreApi.java @@ -34,20 +34,23 @@ public interface StoreApi { * @return Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(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", tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/store/order/{orderId}" ) - ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") String orderId - -); + ResponseEntity deleteOrder( + @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") String orderId + ); /** @@ -56,20 +59,28 @@ ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs t * * @return successful operation (status code 200) */ - - @ApiOperation(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") - }, tags={ "store", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) + @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" ) - ResponseEntity> getInventory(); + ResponseEntity> getInventory( + + ); /** @@ -81,23 +92,26 @@ ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs t * or Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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 generated 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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/store/order/{orderId}", produces = "application/json" ) - ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") Long orderId - -); + ResponseEntity getOrderById( + @Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") Long orderId + ); /** @@ -107,20 +121,24 @@ ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pe * @return successful operation (status code 200) * or Invalid Order (status code 400) */ - - @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid Order") + }) @RequestMapping( method = RequestMethod.POST, value = "/store/order", produces = "application/json" ) ResponseEntity placeOrder( - -@ApiParam(value = "order placed for purchasing the pet", required = true ) @Valid @RequestBody Order body); + @ApiParam(value = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order body + ); } diff --git a/samples/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/UserApi.java b/samples/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/UserApi.java index 5c10794b34f7..f4d08190bdfb 100644 --- a/samples/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/UserApi.java @@ -34,18 +34,22 @@ public interface UserApi { * @param body Created user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Create user", + nickname = "createUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user" ) ResponseEntity createUser( - -@ApiParam(value = "Created user object", required = true ) @Valid @RequestBody User body); + @ApiParam(value = "Created user object", required = true) @Valid @RequestBody User body + ); /** @@ -54,18 +58,22 @@ ResponseEntity createUser( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithArrayInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithArray" ) ResponseEntity createUsersWithArrayInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body); + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ); /** @@ -74,18 +82,22 @@ ResponseEntity createUsersWithArrayInput( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithListInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithList" ) ResponseEntity createUsersWithListInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body); + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ); /** @@ -96,20 +108,23 @@ ResponseEntity createUsersWithListInput( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Delete user", + nickname = "deleteUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/user/{username}" ) - ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username - -); + ResponseEntity deleteUser( + @ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username + ); /** @@ -120,23 +135,26 @@ ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be del * or Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/{username}", produces = "application/json" ) - ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username - -); + ResponseEntity getUserByName( + @ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username + ); /** @@ -147,23 +165,26 @@ ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be * @return successful operation (status code 200) * or Invalid username/password supplied (status code 400) */ - - @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid username/password supplied") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/login", produces = "application/json" ) - ResponseEntity loginUser(@NotNull @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 - -); + ResponseEntity loginUser( + @NotNull @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 + ); /** @@ -171,16 +192,22 @@ ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for l * * @return successful operation (status code 200) */ - - @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Logs out current logged in user session", + nickname = "logoutUser", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/logout" ) - ResponseEntity logoutUser(); + ResponseEntity logoutUser( + + ); /** @@ -188,16 +215,22 @@ ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for l * * @return endpoint configuration response (status code 200) */ - - @ApiOperation(value = "logoutUserOptions", nickname = "logoutUserOptions", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "endpoint configuration response") }) + @ApiOperation( + tags = { "user" }, + value = "logoutUserOptions", + nickname = "logoutUserOptions", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "endpoint configuration response") + }) @RequestMapping( method = RequestMethod.OPTIONS, value = "/user/logout" ) - ResponseEntity logoutUserOptions(); + ResponseEntity logoutUserOptions( + + ); /** @@ -209,21 +242,23 @@ ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for l * @return Invalid user supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Updated user", + nickname = "updateUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid user supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.PUT, value = "/user/{username}" ) - ResponseEntity 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 body); + ResponseEntity 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 body + ); } diff --git a/samples/client/petstore/spring-cloud/pom.xml b/samples/client/petstore/spring-cloud/pom.xml index 254a8357fce7..6b400a3539fe 100644 --- a/samples/client/petstore/spring-cloud/pom.xml +++ b/samples/client/petstore/spring-cloud/pom.xml @@ -9,12 +9,13 @@ 1.8 ${java.version} ${java.version} - 1.5.18 + 1.6.3 + 2.9.2 org.springframework.boot spring-boot-starter-parent - 2.5.5 + 2.6.2 src/main/java @@ -25,7 +26,7 @@ org.springframework.cloud spring-cloud-starter-parent - 2020.0.4 + 2021.0.0 pom import @@ -33,10 +34,11 @@ + - io.swagger - swagger-annotations - ${swagger-core-version} + io.springfox + springfox-swagger2 + ${springfox.version} @@ -60,26 +62,20 @@ org.openapitools jackson-databind-nullable - 0.2.1 + 0.2.2 org.springframework.boot - spring-boot-starter-test - test - - - org.hibernate.validator - hibernate-validator - 6.0.16.Final - - - io.springfox - springfox-swagger2 - 3.0.0 + spring-boot-starter-validation org.springframework.data spring-data-commons + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/samples/client/petstore/spring-cloud/src/main/java/org/openapitools/api/PetApi.java b/samples/client/petstore/spring-cloud/src/main/java/org/openapitools/api/PetApi.java index a4c7219960e7..a9d95755cd06 100644 --- a/samples/client/petstore/spring-cloud/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/client/petstore/spring-cloud/src/main/java/org/openapitools/api/PetApi.java @@ -33,17 +33,23 @@ public interface PetApi { * @return successful operation (status code 200) * or Invalid input (status code 405) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 405, message = "Invalid input") + }) @RequestMapping( method = RequestMethod.POST, value = "/pet", @@ -51,8 +57,8 @@ public interface PetApi { consumes = "application/json" ) ResponseEntity addPet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet pet); + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet + ); /** @@ -62,24 +68,29 @@ ResponseEntity addPet( * @param apiKey (optional) * @return Invalid pet value (status code 400) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 400, message = "Invalid pet value") }) + @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}" ) - ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId - -, -@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey -); + ResponseEntity deletePet( + @ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey + ); /** @@ -90,24 +101,31 @@ ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", required = * @return successful operation (status code 200) * or Invalid status value (status code 400) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid status value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByStatus", produces = "application/json" ) - ResponseEntity> 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 status - -); + ResponseEntity> 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 status + ); /** @@ -119,24 +137,31 @@ ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status va * or Invalid tag value (status code 400) * @deprecated */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid tag value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByTags", produces = "application/json" ) - ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags - -); + ResponseEntity> findPetsByTags( + @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags + ); /** @@ -148,26 +173,29 @@ ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to fil * or Invalid ID supplied (status code 400) * or Pet not found (status code 404) */ - - @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { - - @Authorization(value = "api_key") - }, tags={ "pet", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Pet not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/{petId}", produces = "application/json" ) - ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId - -); + ResponseEntity getPetById( + @ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId + ); /** @@ -179,21 +207,25 @@ ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", required * or Pet not found (status code 404) * or Validation exception (status code 405) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 405, message = "Validation exception") + }) @RequestMapping( method = RequestMethod.PUT, value = "/pet", @@ -201,8 +233,8 @@ ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", required consumes = "application/json" ) ResponseEntity updatePet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet pet); + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet + ); /** @@ -213,27 +245,31 @@ ResponseEntity updatePet( * @param status Updated status of the pet (optional) * @return Invalid input (status code 405) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 405, message = "Invalid input") }) + @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" ) - ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "Updated name of the pet" ) @RequestParam(value="name", required=false) String name, - -@ApiParam(value = "Updated status of the pet" ) @RequestParam(value="status", required=false) String status); + ResponseEntity updatePetWithForm( + @ApiParam(value = "ID of pet that needs to be updated", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "Updated name of the pet") @RequestParam(value="name", required=false) String name, + @ApiParam(value = "Updated status of the pet") @RequestParam(value="status", required=false) String status + ); /** @@ -244,27 +280,32 @@ ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs t * @param file file to upload (optional) * @return successful operation (status code 200) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @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" ) - ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "Additional data to pass to server" ) @RequestParam(value="additionalMetadata", required=false) String additionalMetadata, - -@ApiParam(value = "file to upload") @RequestParam("file") MultipartFile file); + ResponseEntity uploadFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "Additional data to pass to server") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata, + @ApiParam(value = "file to upload") @RequestParam("file") MultipartFile file + ); } diff --git a/samples/client/petstore/spring-cloud/src/main/java/org/openapitools/api/StoreApi.java b/samples/client/petstore/spring-cloud/src/main/java/org/openapitools/api/StoreApi.java index 2c6907ad18eb..fa08ad193132 100644 --- a/samples/client/petstore/spring-cloud/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/client/petstore/spring-cloud/src/main/java/org/openapitools/api/StoreApi.java @@ -34,20 +34,23 @@ public interface StoreApi { * @return Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(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", tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/store/order/{orderId}" ) - ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") String orderId - -); + ResponseEntity deleteOrder( + @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") String orderId + ); /** @@ -56,20 +59,28 @@ ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs t * * @return successful operation (status code 200) */ - - @ApiOperation(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") - }, tags={ "store", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) + @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" ) - ResponseEntity> getInventory(); + ResponseEntity> getInventory( + + ); /** @@ -81,23 +92,26 @@ ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs t * or Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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 generated 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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/store/order/{orderId}", produces = "application/json" ) - ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") Long orderId - -); + ResponseEntity getOrderById( + @Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") Long orderId + ); /** @@ -107,13 +121,17 @@ ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pe * @return successful operation (status code 200) * or Invalid Order (status code 400) */ - - @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid Order") + }) @RequestMapping( method = RequestMethod.POST, value = "/store/order", @@ -121,7 +139,7 @@ ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pe consumes = "application/json" ) ResponseEntity placeOrder( - -@ApiParam(value = "order placed for purchasing the pet", required = true ) @Valid @RequestBody Order order); + @ApiParam(value = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order order + ); } diff --git a/samples/client/petstore/spring-cloud/src/main/java/org/openapitools/api/UserApi.java b/samples/client/petstore/spring-cloud/src/main/java/org/openapitools/api/UserApi.java index 10839b14aa54..9cecbee3e009 100644 --- a/samples/client/petstore/spring-cloud/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/client/petstore/spring-cloud/src/main/java/org/openapitools/api/UserApi.java @@ -34,22 +34,26 @@ public interface UserApi { * @param user Created user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", authorizations = { - - @Authorization(value = "api_key") - }, tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @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" ) ResponseEntity createUser( - -@ApiParam(value = "Created user object", required = true ) @Valid @RequestBody User user); + @ApiParam(value = "Created user object", required = true) @Valid @RequestBody User user + ); /** @@ -58,22 +62,26 @@ ResponseEntity createUser( * @param user List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", authorizations = { - - @Authorization(value = "api_key") - }, tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @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" ) ResponseEntity createUsersWithArrayInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List user); + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List user + ); /** @@ -82,22 +90,26 @@ ResponseEntity createUsersWithArrayInput( * @param user List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", authorizations = { - - @Authorization(value = "api_key") - }, tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @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" ) ResponseEntity createUsersWithListInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List user); + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List user + ); /** @@ -108,23 +120,26 @@ ResponseEntity createUsersWithListInput( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", authorizations = { - - @Authorization(value = "api_key") - }, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/user/{username}" ) - ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username - -); + ResponseEntity deleteUser( + @ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username + ); /** @@ -135,23 +150,26 @@ ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be del * or Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/{username}", produces = "application/json" ) - ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username - -); + ResponseEntity getUserByName( + @ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username + ); /** @@ -162,23 +180,26 @@ ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be * @return successful operation (status code 200) * or Invalid username/password supplied (status code 400) */ - - @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid username/password supplied") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/login", produces = "application/json" ) - ResponseEntity 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 - -); + ResponseEntity 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 + ); /** @@ -186,19 +207,25 @@ ResponseEntity loginUser(@NotNull @Pattern(regexp = "^[a-zA-Z0-9]+[a-zA- * * @return successful operation (status code 200) */ - - @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", authorizations = { - - @Authorization(value = "api_key") - }, tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @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" ) - ResponseEntity logoutUser(); + ResponseEntity logoutUser( + + ); /** @@ -210,25 +237,27 @@ ResponseEntity loginUser(@NotNull @Pattern(regexp = "^[a-zA-Z0-9]+[a-zA- * @return Invalid user supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", authorizations = { - - @Authorization(value = "api_key") - }, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.PUT, value = "/user/{username}", consumes = "application/json" ) - ResponseEntity 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); + ResponseEntity 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 + ); } diff --git a/samples/client/petstore/spring-stubs/pom.xml b/samples/client/petstore/spring-stubs/pom.xml index 2ae7301fc583..ef22a9c572a8 100644 --- a/samples/client/petstore/spring-stubs/pom.xml +++ b/samples/client/petstore/spring-stubs/pom.xml @@ -9,12 +9,12 @@ 1.8 ${java.version} ${java.version} - 2.9.2 + 2.9.2 org.springframework.boot spring-boot-starter-parent - 2.3.3.RELEASE + 2.5.8 src/main/java @@ -32,16 +32,17 @@ io.springfox springfox-swagger2 - ${springfox-version} + ${springfox.version} + - io.springfox - springfox-swagger-ui - ${springfox-version} + com.google.code.findbugs + jsr305 + 3.0.2 - jakarta.xml.bind - jakarta.xml.bind-api + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml com.fasterxml.jackson.datatype @@ -50,12 +51,12 @@ org.openapitools jackson-databind-nullable - 0.2.1 + 0.2.2 - + - jakarta.validation - jakarta.validation-api + org.springframework.boot + spring-boot-starter-validation com.fasterxml.jackson.core diff --git a/samples/client/petstore/spring-stubs/src/main/java/org/openapitools/api/PetApi.java b/samples/client/petstore/spring-stubs/src/main/java/org/openapitools/api/PetApi.java index 92cde931e9fc..bbbf2a70effe 100644 --- a/samples/client/petstore/spring-stubs/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/client/petstore/spring-stubs/src/main/java/org/openapitools/api/PetApi.java @@ -36,23 +36,29 @@ default Optional getRequest() { * @param body Pet object that needs to be added to the store (required) * @return Invalid input (status code 405) */ - - @ApiOperation(value = "Add a new pet to the store", nickname = "addPet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 405, message = "Invalid input") }) + @ApiOperation( + tags = { "pet" }, + value = "Add a new pet to the store", + nickname = "addPet", + 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", consumes = "application/json" ) default ResponseEntity addPet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -65,24 +71,29 @@ default ResponseEntity addPet( * @param apiKey (optional) * @return Invalid pet value (status code 400) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 400, message = "Invalid pet value") }) + @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}" ) - default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId - -, -@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey -) { + default ResponseEntity deletePet( + @ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -96,25 +107,32 @@ default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", req * @return successful operation (status code 200) * or Invalid status value (status code 400) */ - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid status value") }) + @ApiResponse(code = 400, message = "Invalid status value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByStatus", produces = "application/json" ) - default ResponseEntity> 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 status - -) { + default ResponseEntity> 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 status + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -143,25 +161,32 @@ default ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "S * or Invalid tag value (status code 400) * @deprecated */ - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid tag value") }) + @ApiResponse(code = 400, message = "Invalid tag value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByTags", produces = "application/json" ) - default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags - -) { + default ResponseEntity> findPetsByTags( + @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -190,26 +215,29 @@ default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tag * or Invalid ID supplied (status code 400) * or Pet not found (status code 404) */ - - @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { - - @Authorization(value = "api_key") - }, tags={ "pet", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Pet not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/{petId}", produces = "application/json" ) - default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId - -) { + default ResponseEntity getPetById( + @ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -237,27 +265,31 @@ default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", * or Pet not found (status code 404) * or Validation exception (status code 405) */ - - @ApiOperation(value = "Update an existing pet", nickname = "updatePet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Update an existing pet", + nickname = "updatePet", + 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 ID supplied"), - @ApiResponse(code = 404, message = "Pet not found"), - - @ApiResponse(code = 405, message = "Validation exception") }) + @ApiResponse(code = 405, message = "Validation exception") + }) @RequestMapping( method = RequestMethod.PUT, value = "/pet", consumes = "application/json" ) default ResponseEntity updatePet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -271,27 +303,31 @@ default ResponseEntity updatePet( * @param status Updated status of the pet (optional) * @return Invalid input (status code 405) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 405, message = "Invalid input") }) + @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" ) - default ResponseEntity 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 @RequestPart(value = "name", required = false) String name, - -@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status) { + default ResponseEntity 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 @RequestPart(value = "name", required = false) String name, + @ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -305,28 +341,33 @@ default ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that * @param file file to upload (optional) * @return successful operation (status code 200) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @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" ) - default ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { + default ResponseEntity uploadFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @ApiParam(value = "file to upload") @RequestPart(value = "file", required = false) MultipartFile file + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/client/petstore/spring-stubs/src/main/java/org/openapitools/api/StoreApi.java b/samples/client/petstore/spring-stubs/src/main/java/org/openapitools/api/StoreApi.java index 56961cda636c..9b34d820eeab 100644 --- a/samples/client/petstore/spring-stubs/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/client/petstore/spring-stubs/src/main/java/org/openapitools/api/StoreApi.java @@ -38,20 +38,23 @@ default Optional getRequest() { * @return Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(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", tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/store/order/{orderId}" ) - default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") String orderId - -) { + default ResponseEntity deleteOrder( + @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") String orderId + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -63,20 +66,28 @@ default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that * * @return successful operation (status code 200) */ - - @ApiOperation(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") - }, tags={ "store", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) + @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" ) - default ResponseEntity> getInventory() { + default ResponseEntity> getInventory( + + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -91,23 +102,26 @@ default ResponseEntity> getInventory() { * or Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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 generated 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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/store/order/{orderId}", produces = "application/json" ) - default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") Long orderId - -) { + default ResponseEntity getOrderById( + @Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") Long orderId + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -134,21 +148,25 @@ default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = " * @return successful operation (status code 200) * or Invalid Order (status code 400) */ - - @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid Order") + }) @RequestMapping( method = RequestMethod.POST, value = "/store/order", produces = "application/json" ) default ResponseEntity placeOrder( - -@ApiParam(value = "order placed for purchasing the pet", required = true ) @Valid @RequestBody Order body) { + @ApiParam(value = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/client/petstore/spring-stubs/src/main/java/org/openapitools/api/UserApi.java b/samples/client/petstore/spring-stubs/src/main/java/org/openapitools/api/UserApi.java index 31fe60107592..ce505560f765 100644 --- a/samples/client/petstore/spring-stubs/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/client/petstore/spring-stubs/src/main/java/org/openapitools/api/UserApi.java @@ -38,18 +38,22 @@ default Optional getRequest() { * @param body Created user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Create user", + nickname = "createUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user" ) default ResponseEntity createUser( - -@ApiParam(value = "Created user object", required = true ) @Valid @RequestBody User body) { + @ApiParam(value = "Created user object", required = true) @Valid @RequestBody User body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -61,18 +65,22 @@ default ResponseEntity createUser( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithArrayInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithArray" ) default ResponseEntity createUsersWithArrayInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -84,18 +92,22 @@ default ResponseEntity createUsersWithArrayInput( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithListInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithList" ) default ResponseEntity createUsersWithListInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -109,20 +121,23 @@ default ResponseEntity createUsersWithListInput( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Delete user", + nickname = "deleteUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/user/{username}" ) - default ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username - -) { + default ResponseEntity deleteUser( + @ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -136,23 +151,26 @@ default ResponseEntity deleteUser(@ApiParam(value = "The name that needs t * or Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/{username}", produces = "application/json" ) - default ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username - -) { + default ResponseEntity getUserByName( + @ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -180,23 +198,26 @@ default ResponseEntity getUserByName(@ApiParam(value = "The name that need * @return successful operation (status code 200) * or Invalid username/password supplied (status code 400) */ - - @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid username/password supplied") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/login", produces = "application/json" ) - default ResponseEntity loginUser(@NotNull @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 - -) { + default ResponseEntity loginUser( + @NotNull @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 new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -207,16 +228,22 @@ default ResponseEntity loginUser(@NotNull @ApiParam(value = "The user na * * @return successful operation (status code 200) */ - - @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Logs out current logged in user session", + nickname = "logoutUser", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/logout" ) - default ResponseEntity logoutUser() { + default ResponseEntity logoutUser( + + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -231,22 +258,24 @@ default ResponseEntity logoutUser() { * @return Invalid user supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Updated user", + nickname = "updateUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid user supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.PUT, value = "/user/{username}" ) - default ResponseEntity 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 body) { + default ResponseEntity 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 body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/package-lock.json b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/package-lock.json new file mode 100644 index 000000000000..93c65af45dab --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/package-lock.json @@ -0,0 +1,380 @@ +{ + "name": "@openapitools/typescript-fetch-petstore", + "version": "1.0.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "@openapitools/typescript-fetch-petstore", + "version": "1.0.0", + "devDependencies": { + "immutable": "^4.0.0-rc.12", + "normalizr": "^3.6.1", + "redux-saga": "^1.1.3", + "redux-ts-simple": "^3.2.0", + "reselect": "^4.0.0", + "typescript": "^3.9.5" + } + }, + "node_modules/@babel/runtime": { + "version": "7.12.5", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/@babel%2fruntime/-/runtime-7.12.5.tgz", + "integrity": "sha512-plcc+hbExy3McchJCEQG3knOsuh3HH+Prx1P6cLIkET/0dLuQDEnrT+s27Axgc9bqfsmNUNHfscgMUdBpC9xfg==", + "dev": true, + "license": "MIT", + "dependencies": { + "regenerator-runtime": "^0.13.4" + } + }, + "node_modules/@redux-saga/core": { + "version": "1.1.3", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/@redux-saga%2fcore/-/core-1.1.3.tgz", + "integrity": "sha512-8tInBftak8TPzE6X13ABmEtRJGjtK17w7VUs7qV17S8hCO5S3+aUTWZ/DBsBJPdE8Z5jOPwYALyvofgq1Ws+kg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.6.3", + "@redux-saga/deferred": "^1.1.2", + "@redux-saga/delay-p": "^1.1.2", + "@redux-saga/is": "^1.1.2", + "@redux-saga/symbols": "^1.1.2", + "@redux-saga/types": "^1.1.0", + "redux": "^4.0.4", + "typescript-tuple": "^2.2.1" + } + }, + "node_modules/@redux-saga/deferred": { + "version": "1.1.2", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/@redux-saga%2fdeferred/-/deferred-1.1.2.tgz", + "integrity": "sha512-908rDLHFN2UUzt2jb4uOzj6afpjgJe3MjICaUNO3bvkV/kN/cNeI9PMr8BsFXB/MR8WTAZQq/PlTq8Kww3TBSQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@redux-saga/delay-p": { + "version": "1.1.2", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/@redux-saga%2fdelay-p/-/delay-p-1.1.2.tgz", + "integrity": "sha512-ojc+1IoC6OP65Ts5+ZHbEYdrohmIw1j9P7HS9MOJezqMYtCDgpkoqB5enAAZrNtnbSL6gVCWPHaoaTY5KeO0/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@redux-saga/symbols": "^1.1.2" + } + }, + "node_modules/@redux-saga/is": { + "version": "1.1.2", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/@redux-saga%2fis/-/is-1.1.2.tgz", + "integrity": "sha512-OLbunKVsCVNTKEf2cH4TYyNbbPgvmZ52iaxBD4I1fTif4+MTXMa4/Z07L83zW/hTCXwpSZvXogqMqLfex2Tg6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@redux-saga/symbols": "^1.1.2", + "@redux-saga/types": "^1.1.0" + } + }, + "node_modules/@redux-saga/symbols": { + "version": "1.1.2", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/@redux-saga%2fsymbols/-/symbols-1.1.2.tgz", + "integrity": "sha512-EfdGnF423glv3uMwLsGAtE6bg+R9MdqlHEzExnfagXPrIiuxwr3bdiAwz3gi+PsrQ3yBlaBpfGLtDG8rf3LgQQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@redux-saga/types": { + "version": "1.1.0", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/@redux-saga%2ftypes/-/types-1.1.0.tgz", + "integrity": "sha512-afmTuJrylUU/0OtqzaRkbyYFFNgCF73Bvel/sw90pvGrWIZ+vyoIJqA6eMSoA6+nb443kTmulmBtC9NerXboNg==", + "dev": true, + "license": "MIT" + }, + "node_modules/immutable": { + "version": "4.0.0-rc.12", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/immutable/-/immutable-4.0.0-rc.12.tgz", + "integrity": "sha512-0M2XxkZLx/mi3t8NVwIm1g8nHoEmM9p9UBl/G9k4+hm0kBgOVdMV/B3CY5dQ8qG8qc80NN4gDV4HQv6FTJ5q7A==", + "dev": true, + "license": "MIT" + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/loose-envify": { + "version": "1.4.0", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "js-tokens": "^3.0.0 || ^4.0.0" + }, + "bin": { + "loose-envify": "cli.js" + } + }, + "node_modules/normalizr": { + "version": "3.6.1", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/normalizr/-/normalizr-3.6.1.tgz", + "integrity": "sha512-8iEmqXmPtll8PwbEFrbPoDxVw7MKnNvt3PZzR2Xvq9nggEEOgBlNICPXYzyZ4w4AkHUzCU998mdatER3n2VaMA==", + "dev": true, + "license": "MIT" + }, + "node_modules/redux": { + "version": "4.0.5", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/redux/-/redux-4.0.5.tgz", + "integrity": "sha512-VSz1uMAH24DM6MF72vcojpYPtrTUu3ByVWfPL1nPfVRb5mZVTve5GnNCUV53QM/BZ66xfWrm0CTWoM+Xlz8V1w==", + "dev": true, + "license": "MIT", + "dependencies": { + "loose-envify": "^1.4.0", + "symbol-observable": "^1.2.0" + } + }, + "node_modules/redux-saga": { + "version": "1.1.3", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/redux-saga/-/redux-saga-1.1.3.tgz", + "integrity": "sha512-RkSn/z0mwaSa5/xH/hQLo8gNf4tlvT18qXDNvedihLcfzh+jMchDgaariQoehCpgRltEm4zHKJyINEz6aqswTw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@redux-saga/core": "^1.1.3" + } + }, + "node_modules/redux-ts-simple": { + "version": "3.2.0", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/redux-ts-simple/-/redux-ts-simple-3.2.0.tgz", + "integrity": "sha512-cZGmkNlD+14tNKomgaLWv6giQmgI/c05g09UxbA04lr2TbqHH8/bUQLvJgTzPuGwsZCWQHizkQZt9EI0HLD+pg==", + "dev": true, + "license": "MIT" + }, + "node_modules/regenerator-runtime": { + "version": "0.13.7", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz", + "integrity": "sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew==", + "dev": true, + "license": "MIT" + }, + "node_modules/reselect": { + "version": "4.0.0", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/reselect/-/reselect-4.0.0.tgz", + "integrity": "sha512-qUgANli03jjAyGlnbYVAV5vvnOmJnODyABz51RdBN7M4WaVu8mecZWgyQNkG8Yqe3KRGRt0l4K4B3XVEULC4CA==", + "dev": true, + "license": "MIT" + }, + "node_modules/symbol-observable": { + "version": "1.2.0", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/symbol-observable/-/symbol-observable-1.2.0.tgz", + "integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/typescript": { + "version": "3.9.7", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/typescript/-/typescript-3.9.7.tgz", + "integrity": "sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "node_modules/typescript-compare": { + "version": "0.0.2", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/typescript-compare/-/typescript-compare-0.0.2.tgz", + "integrity": "sha512-8ja4j7pMHkfLJQO2/8tut7ub+J3Lw2S3061eJLFQcvs3tsmJKp8KG5NtpLn7KcY2w08edF74BSVN7qJS0U6oHA==", + "dev": true, + "license": "MIT", + "dependencies": { + "typescript-logic": "^0.0.0" + } + }, + "node_modules/typescript-logic": { + "version": "0.0.0", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/typescript-logic/-/typescript-logic-0.0.0.tgz", + "integrity": "sha512-zXFars5LUkI3zP492ls0VskH3TtdeHCqu0i7/duGt60i5IGPIpAHE/DWo5FqJ6EjQ15YKXrt+AETjv60Dat34Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/typescript-tuple": { + "version": "2.2.1", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/typescript-tuple/-/typescript-tuple-2.2.1.tgz", + "integrity": "sha512-Zcr0lbt8z5ZdEzERHAMAniTiIKerFCMgd7yjq1fPnDJ43et/k9twIFQMUYff9k5oXcsQ0WpvFcgzK2ZKASoW6Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "typescript-compare": "^0.0.2" + } + } + }, + "dependencies": { + "@babel/runtime": { + "version": "7.12.5", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/@babel%2fruntime/-/runtime-7.12.5.tgz", + "integrity": "sha512-plcc+hbExy3McchJCEQG3knOsuh3HH+Prx1P6cLIkET/0dLuQDEnrT+s27Axgc9bqfsmNUNHfscgMUdBpC9xfg==", + "dev": true, + "requires": { + "regenerator-runtime": "^0.13.4" + } + }, + "@redux-saga/core": { + "version": "1.1.3", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/@redux-saga%2fcore/-/core-1.1.3.tgz", + "integrity": "sha512-8tInBftak8TPzE6X13ABmEtRJGjtK17w7VUs7qV17S8hCO5S3+aUTWZ/DBsBJPdE8Z5jOPwYALyvofgq1Ws+kg==", + "dev": true, + "requires": { + "@babel/runtime": "^7.6.3", + "@redux-saga/deferred": "^1.1.2", + "@redux-saga/delay-p": "^1.1.2", + "@redux-saga/is": "^1.1.2", + "@redux-saga/symbols": "^1.1.2", + "@redux-saga/types": "^1.1.0", + "redux": "^4.0.4", + "typescript-tuple": "^2.2.1" + } + }, + "@redux-saga/deferred": { + "version": "1.1.2", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/@redux-saga%2fdeferred/-/deferred-1.1.2.tgz", + "integrity": "sha512-908rDLHFN2UUzt2jb4uOzj6afpjgJe3MjICaUNO3bvkV/kN/cNeI9PMr8BsFXB/MR8WTAZQq/PlTq8Kww3TBSQ==", + "dev": true + }, + "@redux-saga/delay-p": { + "version": "1.1.2", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/@redux-saga%2fdelay-p/-/delay-p-1.1.2.tgz", + "integrity": "sha512-ojc+1IoC6OP65Ts5+ZHbEYdrohmIw1j9P7HS9MOJezqMYtCDgpkoqB5enAAZrNtnbSL6gVCWPHaoaTY5KeO0/g==", + "dev": true, + "requires": { + "@redux-saga/symbols": "^1.1.2" + } + }, + "@redux-saga/is": { + "version": "1.1.2", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/@redux-saga%2fis/-/is-1.1.2.tgz", + "integrity": "sha512-OLbunKVsCVNTKEf2cH4TYyNbbPgvmZ52iaxBD4I1fTif4+MTXMa4/Z07L83zW/hTCXwpSZvXogqMqLfex2Tg6w==", + "dev": true, + "requires": { + "@redux-saga/symbols": "^1.1.2", + "@redux-saga/types": "^1.1.0" + } + }, + "@redux-saga/symbols": { + "version": "1.1.2", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/@redux-saga%2fsymbols/-/symbols-1.1.2.tgz", + "integrity": "sha512-EfdGnF423glv3uMwLsGAtE6bg+R9MdqlHEzExnfagXPrIiuxwr3bdiAwz3gi+PsrQ3yBlaBpfGLtDG8rf3LgQQ==", + "dev": true + }, + "@redux-saga/types": { + "version": "1.1.0", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/@redux-saga%2ftypes/-/types-1.1.0.tgz", + "integrity": "sha512-afmTuJrylUU/0OtqzaRkbyYFFNgCF73Bvel/sw90pvGrWIZ+vyoIJqA6eMSoA6+nb443kTmulmBtC9NerXboNg==", + "dev": true + }, + "immutable": { + "version": "4.0.0-rc.12", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/immutable/-/immutable-4.0.0-rc.12.tgz", + "integrity": "sha512-0M2XxkZLx/mi3t8NVwIm1g8nHoEmM9p9UBl/G9k4+hm0kBgOVdMV/B3CY5dQ8qG8qc80NN4gDV4HQv6FTJ5q7A==", + "dev": true + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "loose-envify": { + "version": "1.4.0", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dev": true, + "requires": { + "js-tokens": "^3.0.0 || ^4.0.0" + } + }, + "normalizr": { + "version": "3.6.1", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/normalizr/-/normalizr-3.6.1.tgz", + "integrity": "sha512-8iEmqXmPtll8PwbEFrbPoDxVw7MKnNvt3PZzR2Xvq9nggEEOgBlNICPXYzyZ4w4AkHUzCU998mdatER3n2VaMA==", + "dev": true + }, + "redux": { + "version": "4.0.5", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/redux/-/redux-4.0.5.tgz", + "integrity": "sha512-VSz1uMAH24DM6MF72vcojpYPtrTUu3ByVWfPL1nPfVRb5mZVTve5GnNCUV53QM/BZ66xfWrm0CTWoM+Xlz8V1w==", + "dev": true, + "requires": { + "loose-envify": "^1.4.0", + "symbol-observable": "^1.2.0" + } + }, + "redux-saga": { + "version": "1.1.3", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/redux-saga/-/redux-saga-1.1.3.tgz", + "integrity": "sha512-RkSn/z0mwaSa5/xH/hQLo8gNf4tlvT18qXDNvedihLcfzh+jMchDgaariQoehCpgRltEm4zHKJyINEz6aqswTw==", + "dev": true, + "requires": { + "@redux-saga/core": "^1.1.3" + } + }, + "redux-ts-simple": { + "version": "3.2.0", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/redux-ts-simple/-/redux-ts-simple-3.2.0.tgz", + "integrity": "sha512-cZGmkNlD+14tNKomgaLWv6giQmgI/c05g09UxbA04lr2TbqHH8/bUQLvJgTzPuGwsZCWQHizkQZt9EI0HLD+pg==", + "dev": true + }, + "regenerator-runtime": { + "version": "0.13.7", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz", + "integrity": "sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew==", + "dev": true + }, + "reselect": { + "version": "4.0.0", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/reselect/-/reselect-4.0.0.tgz", + "integrity": "sha512-qUgANli03jjAyGlnbYVAV5vvnOmJnODyABz51RdBN7M4WaVu8mecZWgyQNkG8Yqe3KRGRt0l4K4B3XVEULC4CA==", + "dev": true + }, + "symbol-observable": { + "version": "1.2.0", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/symbol-observable/-/symbol-observable-1.2.0.tgz", + "integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==", + "dev": true + }, + "typescript": { + "version": "3.9.7", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/typescript/-/typescript-3.9.7.tgz", + "integrity": "sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==", + "dev": true + }, + "typescript-compare": { + "version": "0.0.2", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/typescript-compare/-/typescript-compare-0.0.2.tgz", + "integrity": "sha512-8ja4j7pMHkfLJQO2/8tut7ub+J3Lw2S3061eJLFQcvs3tsmJKp8KG5NtpLn7KcY2w08edF74BSVN7qJS0U6oHA==", + "dev": true, + "requires": { + "typescript-logic": "^0.0.0" + } + }, + "typescript-logic": { + "version": "0.0.0", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/typescript-logic/-/typescript-logic-0.0.0.tgz", + "integrity": "sha512-zXFars5LUkI3zP492ls0VskH3TtdeHCqu0i7/duGt60i5IGPIpAHE/DWo5FqJ6EjQ15YKXrt+AETjv60Dat34Q==", + "dev": true + }, + "typescript-tuple": { + "version": "2.2.1", + "resolved": "http://verdaccio.corp.stingraydigital.com:4873/typescript-tuple/-/typescript-tuple-2.2.1.tgz", + "integrity": "sha512-Zcr0lbt8z5ZdEzERHAMAniTiIKerFCMgd7yjq1fPnDJ43et/k9twIFQMUYff9k5oXcsQ0WpvFcgzK2ZKASoW6Q==", + "dev": true, + "requires": { + "typescript-compare": "^0.0.2" + } + } + } +} diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/Pair.java b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/Pair.java index e62f20b92ee3..cacf6934c4cb 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/Pair.java +++ b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/Pair.java @@ -52,10 +52,6 @@ private boolean isValidString(String arg) { return false; } - if (arg.trim().isEmpty()) { - return false; - } - return true; } } diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/Pair.java b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/Pair.java index 6ee3b9c95a87..6eb6e3854aef 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/Pair.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/Pair.java @@ -52,10 +52,6 @@ private boolean isValidString(String arg) { return false; } - if (arg.trim().isEmpty()) { - return false; - } - return true; } } diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/Pair.java b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/Pair.java index 8352d84046a7..25b5a1b08792 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/Pair.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/Pair.java @@ -52,10 +52,6 @@ private boolean isValidString(String arg) { return false; } - if (arg.trim().isEmpty()) { - return false; - } - return true; } } diff --git a/samples/openapi3/client/petstore/spring-cloud-async/.openapi-generator-ignore b/samples/openapi3/client/petstore/spring-cloud-async/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-async/.openapi-generator-ignore @@ -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 diff --git a/samples/openapi3/client/petstore/spring-cloud-async/.openapi-generator/FILES b/samples/openapi3/client/petstore/spring-cloud-async/.openapi-generator/FILES new file mode 100644 index 000000000000..3510d2b2d276 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-async/.openapi-generator/FILES @@ -0,0 +1,16 @@ +README.md +pom.xml +src/main/java/org/openapitools/api/PetApi.java +src/main/java/org/openapitools/api/PetApiClient.java +src/main/java/org/openapitools/api/StoreApi.java +src/main/java/org/openapitools/api/StoreApiClient.java +src/main/java/org/openapitools/api/UserApi.java +src/main/java/org/openapitools/api/UserApiClient.java +src/main/java/org/openapitools/configuration/ApiKeyRequestInterceptor.java +src/main/java/org/openapitools/configuration/ClientConfiguration.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 diff --git a/samples/openapi3/client/petstore/spring-cloud-async/.openapi-generator/VERSION b/samples/openapi3/client/petstore/spring-cloud-async/.openapi-generator/VERSION new file mode 100644 index 000000000000..0984c4c1ad21 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-async/.openapi-generator/VERSION @@ -0,0 +1 @@ +5.4.0-SNAPSHOT \ No newline at end of file diff --git a/samples/openapi3/client/petstore/spring-cloud-async/README.md b/samples/openapi3/client/petstore/spring-cloud-async/README.md new file mode 100644 index 000000000000..db2e65302794 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-async/README.md @@ -0,0 +1,53 @@ +# petstore-spring-cloud + +## Requirements + +Building the API client library requires [Maven](https://maven.apache.org/) to be installed. + +## Installation + +To install the API client library to your local Maven repository, simply execute: + +```shell +mvn install +``` + +To deploy it to a remote Maven repository instead, configure the settings of the repository and execute: + +```shell +mvn deploy +``` + +Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information. + +### Maven users + +Add this dependency to your project's POM: + +```xml + + org.openapitools.openapi3 + petstore-spring-cloud + 1.0.0 + compile + +``` + +### Gradle users + +Add this dependency to your project's build file: + +```groovy +compile "org.openapitools.openapi3:petstore-spring-cloud:1.0.0" +``` + +### Others + +At first generate the JAR by executing: + +mvn package + +Then manually install the following JARs: + +* target/petstore-spring-cloud-1.0.0.jar +* target/lib/*.jar diff --git a/samples/openapi3/client/petstore/spring-cloud-async/pom.xml b/samples/openapi3/client/petstore/spring-cloud-async/pom.xml new file mode 100644 index 000000000000..950b9bbe3531 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-async/pom.xml @@ -0,0 +1,79 @@ + + 4.0.0 + org.openapitools.openapi3 + petstore-spring-cloud + jar + petstore-spring-cloud + 1.0.0 + + 1.8 + ${java.version} + ${java.version} + 2.1.11 + + + org.springframework.boot + spring-boot-starter-parent + 2.6.2 + + + src/main/java + + + + + + org.springframework.cloud + spring-cloud-starter-parent + 2021.0.0 + pom + import + + + + + + + io.swagger.core.v3 + swagger-annotations + ${swagger-core-version} + + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + org.springframework.cloud + spring-cloud-starter-oauth2 + 2.2.5.RELEASE + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + + + org.openapitools + jackson-databind-nullable + 0.2.2 + + + org.springframework.boot + spring-boot-starter-validation + + + org.springframework.data + spring-data-commons + + + org.springframework.boot + spring-boot-starter-test + test + + + diff --git a/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/PetApi.java b/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/PetApi.java new file mode 100644 index 000000000000..88803c5bac2a --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/PetApi.java @@ -0,0 +1,270 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "Pet", description = "the Pet API") +public interface PetApi { + + /** + * POST /pet : Add a new pet to the store + * + * @param body Pet object that needs to be added to the store (required) + * @return Invalid input (status code 405) + */ + @Operation( + summary = "Add a new pet to the store", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "405", description = "Invalid input") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet", + consumes = "application/json" + ) + CompletableFuture> addPet( + @Parameter(name = "body", description = "Pet object that needs to be added to the store", required = true, schema = @Schema(description = "")) @Valid @RequestBody Pet body + ); + + + /** + * DELETE /pet/{petId} : Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @return Invalid pet value (status code 400) + */ + @Operation( + summary = "Deletes a pet", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid pet value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/pet/{petId}" + ) + CompletableFuture> deletePet( + @Parameter(name = "petId", description = "Pet id to delete", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "api_key", description = "", schema = @Schema(description = "")) @RequestHeader(value = "api_key", required = false) String 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) + */ + @Operation( + summary = "Finds Pets by status", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid status value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/findByStatus", + produces = "application/json" + ) + CompletableFuture>> findPetsByStatus( + @NotNull @Parameter(name = "status", description = "Status values that need to be considered for filter", required = true, schema = @Schema(description = "", allowableValues = { "available", "pending", "sold" })) @Valid @RequestParam(value = "status", required = true) List 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 + */ + @Operation( + summary = "Finds Pets by tags", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid tag value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/findByTags", + produces = "application/json" + ) + CompletableFuture>> findPetsByTags( + @NotNull @Parameter(name = "tags", description = "Tags to filter by", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "tags", required = true) List 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) + */ + @Operation( + summary = "Find pet by ID", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/{petId}", + produces = "application/json" + ) + CompletableFuture> getPetById( + @Parameter(name = "petId", description = "ID of pet to return", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId + ); + + + /** + * PUT /pet : Update an existing pet + * + * @param body Pet object that needs to be added to the store (required) + * @return Invalid ID supplied (status code 400) + * or Pet not found (status code 404) + * or Validation exception (status code 405) + */ + @Operation( + summary = "Update an existing pet", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found"), + @ApiResponse(responseCode = "405", description = "Validation exception") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/pet", + consumes = "application/json" + ) + CompletableFuture> updatePet( + @Parameter(name = "body", description = "Pet object that needs to be added to the store", required = true, schema = @Schema(description = "")) @Valid @RequestBody Pet body + ); + + + /** + * 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) + */ + @Operation( + summary = "Updates a pet in the store with form data", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "405", description = "Invalid input") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet/{petId}", + consumes = "application/x-www-form-urlencoded" + ) + CompletableFuture> updatePetWithForm( + @Parameter(name = "petId", description = "ID of pet that needs to be updated", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "name", description = "Updated name of the pet", schema = @Schema(description = "")) @RequestParam(value="name", required=false) String name, + @Parameter(name = "status", description = "Updated status of the pet", schema = @Schema(description = "")) @RequestParam(value="status", required=false) String 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) + */ + @Operation( + summary = "uploads an image", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ModelApiResponse.class))) + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet/{petId}/uploadImage", + produces = "application/json", + consumes = "multipart/form-data" + ) + CompletableFuture> uploadFile( + @Parameter(name = "petId", description = "ID of pet to update", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "additionalMetadata", description = "Additional data to pass to server", schema = @Schema(description = "")) @RequestParam(value="additionalMetadata", required=false) String additionalMetadata, + @Parameter(name = "file", description = "file to upload", schema = @Schema(description = "")) @RequestParam("file") MultipartFile file + ); + +} diff --git a/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/PetApiClient.java b/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/PetApiClient.java new file mode 100644 index 000000000000..f80fe4ddc678 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/PetApiClient.java @@ -0,0 +1,8 @@ +package org.openapitools.api; + +import org.springframework.cloud.openfeign.FeignClient; +import org.openapitools.configuration.ClientConfiguration; + +@FeignClient(name="${pet.name:pet}", url="${pet.url:http://petstore.swagger.io/v2}", configuration = ClientConfiguration.class) +public interface PetApiClient extends PetApi { +} diff --git a/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/StoreApi.java b/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/StoreApi.java new file mode 100644 index 000000000000..da999d740a5a --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/StoreApi.java @@ -0,0 +1,140 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "Store", description = "the Store API") +public interface StoreApi { + + /** + * 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) + */ + @Operation( + summary = "Delete purchase order by ID", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/store/order/{orderId}" + ) + CompletableFuture> deleteOrder( + @Parameter(name = "orderId", description = "ID of the order that needs to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("orderId") String orderId + ); + + + /** + * GET /store/inventory : Returns pet inventories by status + * Returns a map of status codes to quantities + * + * @return successful operation (status code 200) + */ + @Operation( + summary = "Returns pet inventories by status", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Map.class))) + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/store/inventory", + produces = "application/json" + ) + CompletableFuture>> getInventory( + + ); + + + /** + * GET /store/order/{orderId} : Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated 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) + */ + @Operation( + summary = "Find purchase order by ID", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/store/order/{orderId}", + produces = "application/json" + ) + CompletableFuture> getOrderById( + @Min(1L) @Max(5L) @Parameter(name = "orderId", description = "ID of pet that needs to be fetched", required = true, schema = @Schema(description = "")) @PathVariable("orderId") Long orderId + ); + + + /** + * POST /store/order : Place an order for a pet + * + * @param body order placed for purchasing the pet (required) + * @return successful operation (status code 200) + * or Invalid Order (status code 400) + */ + @Operation( + summary = "Place an order for a pet", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid Order") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/store/order", + produces = "application/json" + ) + CompletableFuture> placeOrder( + @Parameter(name = "body", description = "order placed for purchasing the pet", required = true, schema = @Schema(description = "")) @Valid @RequestBody Order body + ); + +} diff --git a/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/StoreApiClient.java b/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/StoreApiClient.java new file mode 100644 index 000000000000..71d613a871dd --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/StoreApiClient.java @@ -0,0 +1,8 @@ +package org.openapitools.api; + +import org.springframework.cloud.openfeign.FeignClient; +import org.openapitools.configuration.ClientConfiguration; + +@FeignClient(name="${store.name:store}", url="${store.url:http://petstore.swagger.io/v2}", configuration = ClientConfiguration.class) +public interface StoreApiClient extends StoreApi { +} diff --git a/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/UserApi.java b/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/UserApi.java new file mode 100644 index 000000000000..225627cbacc0 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/UserApi.java @@ -0,0 +1,231 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "User", description = "the User API") +public interface UserApi { + + /** + * POST /user : Create user + * This can only be done by the logged in user. + * + * @param body Created user object (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "Create user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user" + ) + CompletableFuture> createUser( + @Parameter(name = "body", description = "Created user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody User body + ); + + + /** + * POST /user/createWithArray : Creates list of users with given input array + * + * @param body List of user object (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "Creates list of users with given input array", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user/createWithArray" + ) + CompletableFuture> createUsersWithArrayInput( + @Parameter(name = "body", description = "List of user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody List body + ); + + + /** + * POST /user/createWithList : Creates list of users with given input array + * + * @param body List of user object (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "Creates list of users with given input array", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user/createWithList" + ) + CompletableFuture> createUsersWithListInput( + @Parameter(name = "body", description = "List of user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody List body + ); + + + /** + * 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) + */ + @Operation( + summary = "Delete user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/user/{username}" + ) + CompletableFuture> deleteUser( + @Parameter(name = "username", description = "The name that needs to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("username") String 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) + */ + @Operation( + summary = "Get user by user name", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = User.class))), + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/{username}", + produces = "application/json" + ) + CompletableFuture> getUserByName( + @Parameter(name = "username", description = "The name that needs to be fetched. Use user1 for testing.", required = true, schema = @Schema(description = "")) @PathVariable("username") String 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) + */ + @Operation( + summary = "Logs user into the system", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "400", description = "Invalid username/password supplied") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/login", + produces = "application/json" + ) + CompletableFuture> loginUser( + @NotNull @Parameter(name = "username", description = "The user name for login", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "username", required = true) String username, + @NotNull @Parameter(name = "password", description = "The password for login in clear text", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "password", required = true) String password + ); + + + /** + * GET /user/logout : Logs out current logged in user session + * + * @return successful operation (status code 200) + */ + @Operation( + summary = "Logs out current logged in user session", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/logout" + ) + CompletableFuture> 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 body Updated user object (required) + * @return Invalid user supplied (status code 400) + * or User not found (status code 404) + */ + @Operation( + summary = "Updated user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid user supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/user/{username}" + ) + CompletableFuture> updateUser( + @Parameter(name = "username", description = "name that need to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("username") String username, + @Parameter(name = "body", description = "Updated user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody User body + ); + +} diff --git a/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/UserApiClient.java b/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/UserApiClient.java new file mode 100644 index 000000000000..1db4598108db --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/UserApiClient.java @@ -0,0 +1,8 @@ +package org.openapitools.api; + +import org.springframework.cloud.openfeign.FeignClient; +import org.openapitools.configuration.ClientConfiguration; + +@FeignClient(name="${user.name:user}", url="${user.url:http://petstore.swagger.io/v2}", configuration = ClientConfiguration.class) +public interface UserApiClient extends UserApi { +} diff --git a/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/configuration/ApiKeyRequestInterceptor.java b/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/configuration/ApiKeyRequestInterceptor.java new file mode 100644 index 000000000000..199278dcb539 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/configuration/ApiKeyRequestInterceptor.java @@ -0,0 +1,31 @@ +package org.openapitools.configuration; + +import feign.RequestInterceptor; +import feign.RequestTemplate; +import feign.Util; + + +public class ApiKeyRequestInterceptor implements RequestInterceptor { + private final String location; + private final String name; + private String value; + + public ApiKeyRequestInterceptor(String location, String name, String value) { + Util.checkNotNull(location, "location", new Object[0]); + Util.checkNotNull(name, "name", new Object[0]); + Util.checkNotNull(value, "value", new Object[0]); + this.location = location; + this.name = name; + this.value = value; + } + + @Override + public void apply(RequestTemplate requestTemplate) { + if(location.equals("header")) { + requestTemplate.header(name, value); + } else if(location.equals("query")) { + requestTemplate.query(name, value); + } + } + +} diff --git a/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/configuration/ClientConfiguration.java b/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/configuration/ClientConfiguration.java new file mode 100644 index 000000000000..4a28661290d9 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/configuration/ClientConfiguration.java @@ -0,0 +1,48 @@ +package org.openapitools.configuration; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.cloud.openfeign.security.OAuth2FeignRequestInterceptor; +import org.springframework.security.oauth2.client.DefaultOAuth2ClientContext; +import org.springframework.security.oauth2.client.OAuth2ClientContext; +import org.springframework.security.oauth2.client.token.grant.implicit.ImplicitResourceDetails; + +@Configuration +@EnableConfigurationProperties +public class ClientConfiguration { + + @Value("${openapipetstore.security.apiKey.key:}") + private String apiKeyKey; + + @Bean + @ConditionalOnProperty(name = "openapipetstore.security.apiKey.key") + public ApiKeyRequestInterceptor apiKeyRequestInterceptor() { + return new ApiKeyRequestInterceptor("header", "api_key", this.apiKeyKey); + } + + @Bean + @ConditionalOnProperty("openapipetstore.security.petstoreAuth.client-id") + public OAuth2FeignRequestInterceptor petstoreAuthRequestInterceptor(OAuth2ClientContext oAuth2ClientContext) { + return new OAuth2FeignRequestInterceptor(oAuth2ClientContext, petstoreAuthResourceDetails()); + } + + @Bean + @ConditionalOnProperty("openapipetstore.security.petstoreAuth.client-id") + public OAuth2ClientContext oAuth2ClientContext() { + return new DefaultOAuth2ClientContext(); + } + + @Bean + @ConditionalOnProperty("openapipetstore.security.petstoreAuth.client-id") + @ConfigurationProperties("openapipetstore.security.petstoreAuth") + public ImplicitResourceDetails petstoreAuthResourceDetails() { + ImplicitResourceDetails details = new ImplicitResourceDetails(); + details.setUserAuthorizationUri("http://petstore.swagger.io/api/oauth/dialog"); + return details; + } + +} diff --git a/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/model/Category.java b/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/model/Category.java new file mode 100644 index 000000000000..cb69c674a1e4 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/model/Category.java @@ -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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * A category for a pet + */ +@Schema(name = "Category",description = "A category for a pet") +@javax.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "name", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/model/ModelApiResponse.java b/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/model/ModelApiResponse.java new file mode 100644 index 000000000000..0ef610e38f01 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/model/ModelApiResponse.java @@ -0,0 +1,134 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Describes the result of uploading an image resource + */ +@Schema(name = "ApiResponse",description = "Describes the result of uploading an image resource") +@javax.annotation.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 + */ + @Schema(name = "code", defaultValue = "") + + + 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 + */ + @Schema(name = "type", defaultValue = "") + + + 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 + */ + @Schema(name = "message", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/model/Order.java b/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/model/Order.java new file mode 100644 index 000000000000..528598b79ea7 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/model/Order.java @@ -0,0 +1,250 @@ +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 java.time.OffsetDateTime; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * An order for a pets from the pet store + */ +@Schema(name = "Order",description = "An order for a pets from the pet store") +@javax.annotation.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") + @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "petId", defaultValue = "") + + + 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 + */ + @Schema(name = "quantity", defaultValue = "") + + + 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 + */ + @Schema(name = "shipDate", defaultValue = "") + + @Valid + + 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 + */ + @Schema(name = "status", defaultValue = "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 + */ + @Schema(name = "complete", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/model/Pet.java b/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/model/Pet.java new file mode 100644 index 000000000000..7c2986fea846 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/model/Pet.java @@ -0,0 +1,270 @@ +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 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 io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * A pet for sale in the pet store + */ +@Schema(name = "Pet",description = "A pet for sale in the pet store") +@javax.annotation.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 photoUrls = new ArrayList<>(); + + @JsonProperty("tags") + @Valid + private List 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; + + public Pet id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "category", defaultValue = "") + + @Valid + + 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 + */ + @Schema(name = "name", example = "doggie", required = true, defaultValue = "") + @NotNull + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Pet photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + public Pet addPhotoUrlsItem(String photoUrlsItem) { + this.photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get photoUrls + * @return photoUrls + */ + @Schema(name = "photoUrls", required = true, defaultValue = "") + @NotNull + + + public List getPhotoUrls() { + return photoUrls; + } + + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + public Pet tags(List 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 + */ + @Schema(name = "tags", defaultValue = "") + + @Valid + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * pet status in the store + * @return status + */ + @Schema(name = "status", defaultValue = "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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/model/Tag.java b/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/model/Tag.java new file mode 100644 index 000000000000..27166f687a27 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/model/Tag.java @@ -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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * A tag for a pet + */ +@Schema(name = "Tag",description = "A tag for a pet") +@javax.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "name", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/model/User.java b/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/model/User.java new file mode 100644 index 000000000000..ba24f681c1df --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-async/src/main/java/org/openapitools/model/User.java @@ -0,0 +1,259 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * A User who is purchasing from the pet store + */ +@Schema(name = "User",description = "A User who is purchasing from the pet store") +@javax.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "username", defaultValue = "") + + + 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 + */ + @Schema(name = "firstName", defaultValue = "") + + + 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 + */ + @Schema(name = "lastName", defaultValue = "") + + + 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 + */ + @Schema(name = "email", defaultValue = "") + + + 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 + */ + @Schema(name = "password", defaultValue = "") + + + 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 + */ + @Schema(name = "phone", defaultValue = "") + + + 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 + */ + @Schema(name = "userStatus", defaultValue = "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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-date-time/.openapi-generator-ignore b/samples/openapi3/client/petstore/spring-cloud-date-time/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-date-time/.openapi-generator-ignore @@ -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 diff --git a/samples/openapi3/client/petstore/spring-cloud-date-time/.openapi-generator/FILES b/samples/openapi3/client/petstore/spring-cloud-date-time/.openapi-generator/FILES new file mode 100644 index 000000000000..0849e5aac50a --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-date-time/.openapi-generator/FILES @@ -0,0 +1,3 @@ +README.md +pom.xml +src/main/java/org/openapitools/api/DefaultApi.java diff --git a/samples/openapi3/client/petstore/spring-cloud-date-time/.openapi-generator/VERSION b/samples/openapi3/client/petstore/spring-cloud-date-time/.openapi-generator/VERSION new file mode 100644 index 000000000000..0984c4c1ad21 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-date-time/.openapi-generator/VERSION @@ -0,0 +1 @@ +5.4.0-SNAPSHOT \ No newline at end of file diff --git a/samples/openapi3/client/petstore/spring-cloud-date-time/README.md b/samples/openapi3/client/petstore/spring-cloud-date-time/README.md new file mode 100644 index 000000000000..a462be951ace --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-date-time/README.md @@ -0,0 +1,26 @@ +# OpenAPI generated API stub + +Spring Framework stub + + +## Overview +This code was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. +By using the [OpenAPI-Spec](https://openapis.org), you can easily generate an API stub. +This is an example of building API stub interfaces in Java using the Spring framework. + +The stubs generated can be used in your existing Spring-MVC or Spring-Boot application to create controller endpoints +by adding ```@Controller``` classes that implement the interface. Eg: +```java +@Controller +public class PetController implements PetApi { +// implement all PetApi methods +} +``` + +You can also use the interface to create [Spring-Cloud Feign clients](http://projects.spring.io/spring-cloud/spring-cloud.html#spring-cloud-feign-inheritance).Eg: +```java +@FeignClient(name="pet", url="http://petstore.swagger.io/v2") +public interface PetClient extends PetApi { + +} +``` diff --git a/samples/openapi3/client/petstore/spring-cloud-date-time/pom.xml b/samples/openapi3/client/petstore/spring-cloud-date-time/pom.xml new file mode 100644 index 000000000000..9f8de9c14cdf --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-date-time/pom.xml @@ -0,0 +1,79 @@ + + 4.0.0 + org.openapitools.openapi3 + spring-cloud-date-time-oas3 + jar + spring-cloud-date-time-oas3 + 1.0 + + 1.8 + ${java.version} + ${java.version} + 2.1.11 + + + org.springframework.boot + spring-boot-starter-parent + 2.6.2 + + + src/main/java + + + + + + org.springframework.cloud + spring-cloud-starter-parent + 2021.0.0 + pom + import + + + + + + + io.swagger.core.v3 + swagger-annotations + ${swagger-core-version} + + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + org.springframework.cloud + spring-cloud-starter-oauth2 + 2.2.5.RELEASE + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + + + org.openapitools + jackson-databind-nullable + 0.2.2 + + + org.springframework.boot + spring-boot-starter-validation + + + org.springframework.data + spring-data-commons + + + org.springframework.boot + spring-boot-starter-test + test + + + diff --git a/samples/openapi3/client/petstore/spring-cloud-date-time/src/main/java/org/openapitools/api/DefaultApi.java b/samples/openapi3/client/petstore/spring-cloud-date-time/src/main/java/org/openapitools/api/DefaultApi.java new file mode 100644 index 000000000000..7dbf104466fb --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-date-time/src/main/java/org/openapitools/api/DefaultApi.java @@ -0,0 +1,89 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.openapitools.api; + +import java.time.LocalDate; +import java.time.OffsetDateTime; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "Default", description = "the Default API") +public interface DefaultApi { + + /** + * GET /thingy/{date} + * + * @param date A date path parameter (required) + * @param dateTime A date-time query parameter (required) + * @param xOrderDate A date header parameter (required) + * @param loginDate A date cookie parameter (optional) + * @return OK (status code 200) + */ + @Operation( + summary = "", + tags = { }, + responses = { + @ApiResponse(responseCode = "200", description = "OK") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/thingy/{date}" + ) + ResponseEntity get( + @Parameter(name = "date", description = "A date path parameter", required = true, schema = @Schema(description = "")) @PathVariable("date") @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @NotNull @Parameter(name = "dateTime", description = "A date-time query parameter", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "dateTime", required = true) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @Parameter(name = "X-Order-Date", description = "A date header parameter", required = true, schema = @Schema(description = "")) @RequestHeader(value = "X-Order-Date", required = true) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate xOrderDate, + @Parameter(name = "loginDate", description = "A date cookie parameter", schema = @Schema(description = "")) @CookieValue("loginDate") @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate loginDate + ); + + + /** + * POST /thingy/{date} + * update with form data + * + * @param date A date path parameter (required) + * @param visitDate Updated last vist timestamp (optional) + * @return Invalid input (status code 405) + */ + @Operation( + summary = "", + tags = { }, + responses = { + @ApiResponse(responseCode = "405", description = "Invalid input") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/thingy/{date}", + consumes = "application/x-www-form-urlencoded" + ) + ResponseEntity updatePetWithForm( + @Parameter(name = "date", description = "A date path parameter", required = true, schema = @Schema(description = "")) @PathVariable("date") @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @Parameter(name = "visitDate", description = "Updated last vist timestamp", schema = @Schema(description = "")) @RequestParam(value="visitDate", required=false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime visitDate + ); + +} diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/.openapi-generator-ignore b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/.openapi-generator-ignore @@ -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 diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/.openapi-generator/FILES b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/.openapi-generator/FILES new file mode 100644 index 000000000000..5248511085f8 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/.openapi-generator/FILES @@ -0,0 +1,54 @@ +README.md +pom.xml +src/main/java/org/openapitools/api/AnotherFakeApi.java +src/main/java/org/openapitools/api/FakeApi.java +src/main/java/org/openapitools/api/FakeClassnameTags123Api.java +src/main/java/org/openapitools/api/PetApi.java +src/main/java/org/openapitools/api/StoreApi.java +src/main/java/org/openapitools/api/UserApi.java +src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java +src/main/java/org/openapitools/model/AdditionalPropertiesArray.java +src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java +src/main/java/org/openapitools/model/AdditionalPropertiesClass.java +src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java +src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java +src/main/java/org/openapitools/model/AdditionalPropertiesObject.java +src/main/java/org/openapitools/model/AdditionalPropertiesString.java +src/main/java/org/openapitools/model/Animal.java +src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java +src/main/java/org/openapitools/model/ArrayOfNumberOnly.java +src/main/java/org/openapitools/model/ArrayTest.java +src/main/java/org/openapitools/model/BigCat.java +src/main/java/org/openapitools/model/BigCatAllOf.java +src/main/java/org/openapitools/model/Capitalization.java +src/main/java/org/openapitools/model/Cat.java +src/main/java/org/openapitools/model/CatAllOf.java +src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ClassModel.java +src/main/java/org/openapitools/model/Client.java +src/main/java/org/openapitools/model/Dog.java +src/main/java/org/openapitools/model/DogAllOf.java +src/main/java/org/openapitools/model/EnumArrays.java +src/main/java/org/openapitools/model/EnumClass.java +src/main/java/org/openapitools/model/EnumTest.java +src/main/java/org/openapitools/model/FileSchemaTestClass.java +src/main/java/org/openapitools/model/FormatTest.java +src/main/java/org/openapitools/model/HasOnlyReadOnly.java +src/main/java/org/openapitools/model/MapTest.java +src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java +src/main/java/org/openapitools/model/Model200Response.java +src/main/java/org/openapitools/model/ModelApiResponse.java +src/main/java/org/openapitools/model/ModelReturn.java +src/main/java/org/openapitools/model/Name.java +src/main/java/org/openapitools/model/NumberOnly.java +src/main/java/org/openapitools/model/Order.java +src/main/java/org/openapitools/model/OuterComposite.java +src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/Pet.java +src/main/java/org/openapitools/model/ReadOnlyFirst.java +src/main/java/org/openapitools/model/SpecialModelName.java +src/main/java/org/openapitools/model/Tag.java +src/main/java/org/openapitools/model/TypeHolderDefault.java +src/main/java/org/openapitools/model/TypeHolderExample.java +src/main/java/org/openapitools/model/User.java +src/main/java/org/openapitools/model/XmlItem.java diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/.openapi-generator/VERSION b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/.openapi-generator/VERSION new file mode 100644 index 000000000000..0984c4c1ad21 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/.openapi-generator/VERSION @@ -0,0 +1 @@ +5.4.0-SNAPSHOT \ No newline at end of file diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/README.md b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/README.md new file mode 100644 index 000000000000..a462be951ace --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/README.md @@ -0,0 +1,26 @@ +# OpenAPI generated API stub + +Spring Framework stub + + +## Overview +This code was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. +By using the [OpenAPI-Spec](https://openapis.org), you can easily generate an API stub. +This is an example of building API stub interfaces in Java using the Spring framework. + +The stubs generated can be used in your existing Spring-MVC or Spring-Boot application to create controller endpoints +by adding ```@Controller``` classes that implement the interface. Eg: +```java +@Controller +public class PetController implements PetApi { +// implement all PetApi methods +} +``` + +You can also use the interface to create [Spring-Cloud Feign clients](http://projects.spring.io/spring-cloud/spring-cloud.html#spring-cloud-feign-inheritance).Eg: +```java +@FeignClient(name="pet", url="http://petstore.swagger.io/v2") +public interface PetClient extends PetApi { + +} +``` diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/pom.xml b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/pom.xml new file mode 100644 index 000000000000..6cf023f501f2 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/pom.xml @@ -0,0 +1,79 @@ + + 4.0.0 + org.openapitools.openapi3 + spring-cloud-oas3 + jar + spring-cloud-oas3 + 1.0.0 + + 1.8 + ${java.version} + ${java.version} + 2.1.11 + + + org.springframework.boot + spring-boot-starter-parent + 2.6.2 + + + src/main/java + + + + + + org.springframework.cloud + spring-cloud-starter-parent + 2021.0.0 + pom + import + + + + + + + io.swagger.core.v3 + swagger-annotations + ${swagger-core-version} + + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + org.springframework.cloud + spring-cloud-starter-oauth2 + 2.2.5.RELEASE + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + + + org.openapitools + jackson-databind-nullable + 0.2.2 + + + org.springframework.boot + spring-boot-starter-validation + + + org.springframework.data + spring-data-commons + + + org.springframework.boot + spring-boot-starter-test + test + + + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/api/AnotherFakeApi.java new file mode 100644 index 000000000000..9085e07967bc --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -0,0 +1,59 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.openapitools.api; + +import org.openapitools.model.Client; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "AnotherFake", description = "the AnotherFake API") +public interface AnotherFakeApi { + + /** + * PATCH /another-fake/dummy : To test special tags + * To test special tags and operation ID starting with number + * + * @param body client model (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "To test special tags", + tags = { "$another-fake?" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Client.class))) + } + ) + @RequestMapping( + method = RequestMethod.PATCH, + value = "/another-fake/dummy", + produces = "application/json", + consumes = "application/json" + ) + ResponseEntity call123testSpecialTags( + @Parameter(name = "body", description = "client model", required = true, schema = @Schema(description = "")) @Valid @RequestBody Client body + ); + +} diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/api/FakeApi.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/api/FakeApi.java new file mode 100644 index 000000000000..a9d785eaea31 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/api/FakeApi.java @@ -0,0 +1,443 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.openapitools.api; + +import java.math.BigDecimal; +import org.openapitools.model.Client; +import org.openapitools.model.FileSchemaTestClass; +import java.time.LocalDate; +import java.util.Map; +import java.time.OffsetDateTime; +import org.openapitools.model.OuterComposite; +import org.openapitools.model.User; +import org.openapitools.model.XmlItem; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "Fake", description = "the Fake API") +public interface FakeApi { + + /** + * POST /fake/create_xml_item : creates an XmlItem + * this route creates an XmlItem + * + * @param xmlItem XmlItem Body (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "creates an XmlItem", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/create_xml_item", + consumes = "application/xml" + ) + ResponseEntity createXmlItem( + @Parameter(name = "XmlItem", description = "XmlItem Body", required = true, schema = @Schema(description = "")) @Valid @RequestBody XmlItem xmlItem + ); + + + /** + * POST /fake/outer/boolean + * Test serialization of outer boolean types + * + * @param body Input boolean as post body (optional) + * @return Output boolean (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Output boolean", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Boolean.class))) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/outer/boolean", + produces = "*/*" + ) + ResponseEntity fakeOuterBooleanSerialize( + @Parameter(name = "body", description = "Input boolean as post body", schema = @Schema(description = "")) @Valid @RequestBody(required = false) Boolean body + ); + + + /** + * POST /fake/outer/composite + * Test serialization of object with outer number type + * + * @param body Input composite as post body (optional) + * @return Output composite (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Output composite", content = @Content(mediaType = "application/json", schema = @Schema(implementation = OuterComposite.class))) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/outer/composite", + produces = "*/*" + ) + ResponseEntity fakeOuterCompositeSerialize( + @Parameter(name = "body", description = "Input composite as post body", schema = @Schema(description = "")) @Valid @RequestBody(required = false) OuterComposite body + ); + + + /** + * POST /fake/outer/number + * Test serialization of outer number types + * + * @param body Input number as post body (optional) + * @return Output number (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Output number", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BigDecimal.class))) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/outer/number", + produces = "*/*" + ) + ResponseEntity fakeOuterNumberSerialize( + @Parameter(name = "body", description = "Input number as post body", schema = @Schema(description = "")) @Valid @RequestBody(required = false) BigDecimal body + ); + + + /** + * POST /fake/outer/string + * Test serialization of outer string types + * + * @param body Input string as post body (optional) + * @return Output string (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Output string", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/outer/string", + produces = "*/*" + ) + ResponseEntity fakeOuterStringSerialize( + @Parameter(name = "body", description = "Input string as post body", schema = @Schema(description = "")) @Valid @RequestBody(required = false) String body + ); + + + /** + * PUT /fake/body-with-file-schema + * For this test, the body for this request much reference a schema named `File`. + * + * @param body (required) + * @return Success (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success") + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/fake/body-with-file-schema", + consumes = "application/json" + ) + ResponseEntity testBodyWithFileSchema( + @Parameter(name = "body", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestBody FileSchemaTestClass body + ); + + + /** + * PUT /fake/body-with-query-params + * + * @param query (required) + * @param body (required) + * @return Success (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success") + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/fake/body-with-query-params", + consumes = "application/json" + ) + ResponseEntity testBodyWithQueryParams( + @NotNull @Parameter(name = "query", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "query", required = true) String query, + @Parameter(name = "body", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestBody User body + ); + + + /** + * PATCH /fake : To test \"client\" model + * To test \"client\" model + * + * @param body client model (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "To test \"client\" model", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Client.class))) + } + ) + @RequestMapping( + method = RequestMethod.PATCH, + value = "/fake", + produces = "application/json", + consumes = "application/json" + ) + ResponseEntity testClientModel( + @Parameter(name = "body", description = "client model", required = true, schema = @Schema(description = "")) @Valid @RequestBody Client body + ); + + + /** + * POST /fake : Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * + * @param number None (required) + * @param _double None (required) + * @param patternWithoutDelimiter None (required) + * @param _byte None (required) + * @param integer None (optional) + * @param int32 None (optional) + * @param int64 None (optional) + * @param _float None (optional) + * @param string None (optional) + * @param binary None (optional) + * @param date None (optional) + * @param dateTime None (optional) + * @param password None (optional) + * @param paramCallback None (optional) + * @return Invalid username supplied (status code 400) + * or User not found (status code 404) + */ + @Operation( + summary = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + }, + security = { + @SecurityRequirement(name = "http_basic_test") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake", + consumes = "application/x-www-form-urlencoded" + ) + ResponseEntity testEndpointParameters( + @Parameter(name = "number", description = "None", required = true, schema = @Schema(description = "")) @RequestParam(value="number", required=true) BigDecimal number, + @Parameter(name = "double", description = "None", required = true, schema = @Schema(description = "")) @RequestParam(value="double", required=true) Double _double, + @Parameter(name = "pattern_without_delimiter", description = "None", required = true, schema = @Schema(description = "")) @RequestParam(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter, + @Parameter(name = "byte", description = "None", required = true, schema = @Schema(description = "")) @RequestParam(value="byte", required=true) byte[] _byte, + @Parameter(name = "integer", description = "None", schema = @Schema(description = "")) @RequestParam(value="integer", required=false) Integer integer, + @Parameter(name = "int32", description = "None", schema = @Schema(description = "")) @RequestParam(value="int32", required=false) Integer int32, + @Parameter(name = "int64", description = "None", schema = @Schema(description = "")) @RequestParam(value="int64", required=false) Long int64, + @Parameter(name = "float", description = "None", schema = @Schema(description = "")) @RequestParam(value="float", required=false) Float _float, + @Parameter(name = "string", description = "None", schema = @Schema(description = "")) @RequestParam(value="string", required=false) String string, + @Parameter(name = "binary", description = "None", schema = @Schema(description = "")) @RequestParam("binary") MultipartFile binary, + @Parameter(name = "date", description = "None", schema = @Schema(description = "")) @RequestParam(value="date", required=false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @Parameter(name = "dateTime", description = "None", schema = @Schema(description = "")) @RequestParam(value="dateTime", required=false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @Parameter(name = "password", description = "None", schema = @Schema(description = "")) @RequestParam(value="password", required=false) String password, + @Parameter(name = "callback", description = "None", schema = @Schema(description = "")) @RequestParam(value="callback", required=false) String paramCallback + ); + + + /** + * GET /fake : To test enum parameters + * To test enum parameters + * + * @param enumHeaderStringArray Header parameter enum test (string array) (optional) + * @param enumHeaderString Header parameter enum test (string) (optional, default to -efg) + * @param enumQueryStringArray Query parameter enum test (string array) (optional) + * @param enumQueryString Query parameter enum test (string) (optional, default to -efg) + * @param enumQueryInteger Query parameter enum test (double) (optional) + * @param enumQueryDouble Query parameter enum test (double) (optional) + * @param enumFormStringArray Form parameter enum test (string array) (optional, default to $) + * @param enumFormString Form parameter enum test (string) (optional, default to -efg) + * @return Invalid request (status code 400) + * or Not found (status code 404) + */ + @Operation( + summary = "To test enum parameters", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid request"), + @ApiResponse(responseCode = "404", description = "Not found") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/fake", + consumes = "application/x-www-form-urlencoded" + ) + ResponseEntity testEnumParameters( + @Parameter(name = "enum_header_string_array", description = "Header parameter enum test (string array)", schema = @Schema(description = "", allowableValues = { ">", "$" })) @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray, + @Parameter(name = "enum_header_string", description = "Header parameter enum test (string)", schema = @Schema(description = "", allowableValues = { "_abc", "-efg", "(xyz)" }, defaultValue = "-efg")) @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString, + @Parameter(name = "enum_query_string_array", description = "Query parameter enum test (string array)", schema = @Schema(description = "", allowableValues = { ">", "$" })) @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, + @Parameter(name = "enum_query_string", description = "Query parameter enum test (string)", schema = @Schema(description = "", allowableValues = { "_abc", "-efg", "(xyz)" }, defaultValue = "-efg")) @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString, + @Parameter(name = "enum_query_integer", description = "Query parameter enum test (double)", schema = @Schema(description = "", allowableValues = { "1", "-2" })) @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, + @Parameter(name = "enum_query_double", description = "Query parameter enum test (double)", schema = @Schema(description = "", allowableValues = { "1.1", "-1.2" })) @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble, + @Parameter(name = "enum_form_string_array", description = "Form parameter enum test (string array)", schema = @Schema(description = "", allowableValues = { ">", "$" })) @RequestParam(value="enum_form_string_array", required=false) List enumFormStringArray, + @Parameter(name = "enum_form_string", description = "Form parameter enum test (string)", schema = @Schema(description = "", allowableValues = { "_abc", "-efg", "(xyz)" }, defaultValue = "-efg")) @RequestParam(value="enum_form_string", required=false) String enumFormString + ); + + + /** + * DELETE /fake : Fake endpoint to test group parameters (optional) + * Fake endpoint to test group parameters (optional) + * + * @param requiredStringGroup Required String in group parameters (required) + * @param requiredBooleanGroup Required Boolean in group parameters (required) + * @param requiredInt64Group Required Integer in group parameters (required) + * @param stringGroup String in group parameters (optional) + * @param booleanGroup Boolean in group parameters (optional) + * @param int64Group Integer in group parameters (optional) + * @return Someting wrong (status code 400) + */ + @Operation( + summary = "Fake endpoint to test group parameters (optional)", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "400", description = "Someting wrong") + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/fake" + ) + ResponseEntity testGroupParameters( + @NotNull @Parameter(name = "required_string_group", description = "Required String in group parameters", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup, + @Parameter(name = "required_boolean_group", description = "Required Boolean in group parameters", required = true, schema = @Schema(description = "")) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup, + @NotNull @Parameter(name = "required_int64_group", description = "Required Integer in group parameters", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group, + @Parameter(name = "string_group", description = "String in group parameters", schema = @Schema(description = "")) @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup, + @Parameter(name = "boolean_group", description = "Boolean in group parameters", schema = @Schema(description = "")) @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup, + @Parameter(name = "int64_group", description = "Integer in group parameters", schema = @Schema(description = "")) @Valid @RequestParam(value = "int64_group", required = false) Long int64Group + ); + + + /** + * POST /fake/inline-additionalProperties : test inline additionalProperties + * + * @param param request body (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "test inline additionalProperties", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/inline-additionalProperties", + consumes = "application/json" + ) + ResponseEntity testInlineAdditionalProperties( + @Parameter(name = "param", description = "request body", required = true, schema = @Schema(description = "")) @Valid @RequestBody Map param + ); + + + /** + * GET /fake/jsonFormData : test json serialization of form data + * + * @param param field1 (required) + * @param param2 field2 (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "test json serialization of form data", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/fake/jsonFormData", + consumes = "application/x-www-form-urlencoded" + ) + ResponseEntity testJsonFormData( + @Parameter(name = "param", description = "field1", required = true, schema = @Schema(description = "")) @RequestParam(value="param", required=true) String param, + @Parameter(name = "param2", description = "field2", required = true, schema = @Schema(description = "")) @RequestParam(value="param2", required=true) String param2 + ); + + + /** + * PUT /fake/test-query-parameters + * To test the collection format in query parameters + * + * @param pipe (required) + * @param ioutil (required) + * @param http (required) + * @param url (required) + * @param context (required) + * @return Success (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success") + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/fake/test-query-parameters" + ) + ResponseEntity testQueryParameterCollectionFormat( + @NotNull @Parameter(name = "pipe", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "pipe", required = true) List pipe, + @NotNull @Parameter(name = "ioutil", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "ioutil", required = true) List ioutil, + @NotNull @Parameter(name = "http", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "http", required = true) List http, + @NotNull @Parameter(name = "url", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "url", required = true) List url, + @NotNull @Parameter(name = "context", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "context", required = true) List context + ); + +} diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/api/FakeClassnameTags123Api.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/api/FakeClassnameTags123Api.java new file mode 100644 index 000000000000..4239438bd3c1 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/api/FakeClassnameTags123Api.java @@ -0,0 +1,62 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.openapitools.api; + +import org.openapitools.model.Client; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "FakeClassnameTags123", description = "the FakeClassnameTags123 API") +public interface FakeClassnameTags123Api { + + /** + * PATCH /fake_classname_test : To test class name in snake case + * To test class name in snake case + * + * @param body client model (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "To test class name in snake case", + tags = { "fake_classname_tags 123#$%^" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Client.class))) + }, + security = { + @SecurityRequirement(name = "api_key_query") + } + ) + @RequestMapping( + method = RequestMethod.PATCH, + value = "/fake_classname_test", + produces = "application/json", + consumes = "application/json" + ) + ResponseEntity testClassname( + @Parameter(name = "body", description = "client model", required = true, schema = @Schema(description = "")) @Valid @RequestBody Client body + ); + +} diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/api/PetApi.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/api/PetApi.java new file mode 100644 index 000000000000..c618e1e4d902 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/api/PetApi.java @@ -0,0 +1,307 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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 java.util.Set; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "Pet", description = "the Pet API") +public interface PetApi { + + /** + * POST /pet : Add a new pet to the store + * + * @param body Pet object that needs to be added to the store (required) + * @return successful operation (status code 200) + * or Invalid input (status code 405) + */ + @Operation( + summary = "Add a new pet to the store", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation"), + @ApiResponse(responseCode = "405", description = "Invalid input") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet", + consumes = "application/json" + ) + ResponseEntity addPet( + @Parameter(name = "body", description = "Pet object that needs to be added to the store", required = true, schema = @Schema(description = "")) @Valid @RequestBody Pet body + ); + + + /** + * DELETE /pet/{petId} : Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @return successful operation (status code 200) + * or Invalid pet value (status code 400) + */ + @Operation( + summary = "Deletes a pet", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation"), + @ApiResponse(responseCode = "400", description = "Invalid pet value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/pet/{petId}" + ) + ResponseEntity deletePet( + @Parameter(name = "petId", description = "Pet id to delete", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "api_key", description = "", schema = @Schema(description = "")) @RequestHeader(value = "api_key", required = false) String 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) + */ + @Operation( + summary = "Finds Pets by status", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid status value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/findByStatus", + produces = "application/json" + ) + ResponseEntity> findPetsByStatus( + @NotNull @Parameter(name = "status", description = "Status values that need to be considered for filter", required = true, schema = @Schema(description = "", allowableValues = { "available", "pending", "sold" })) @Valid @RequestParam(value = "status", required = true) List 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 + */ + @Operation( + summary = "Finds Pets by tags", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid tag value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/findByTags", + produces = "application/json" + ) + ResponseEntity> findPetsByTags( + @NotNull @Parameter(name = "tags", description = "Tags to filter by", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "tags", required = true) Set 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) + */ + @Operation( + summary = "Find pet by ID", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/{petId}", + produces = "application/json" + ) + ResponseEntity getPetById( + @Parameter(name = "petId", description = "ID of pet to return", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId + ); + + + /** + * PUT /pet : Update an existing pet + * + * @param body 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) + */ + @Operation( + summary = "Update an existing pet", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation"), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found"), + @ApiResponse(responseCode = "405", description = "Validation exception") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/pet", + consumes = "application/json" + ) + ResponseEntity updatePet( + @Parameter(name = "body", description = "Pet object that needs to be added to the store", required = true, schema = @Schema(description = "")) @Valid @RequestBody Pet body + ); + + + /** + * 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) + */ + @Operation( + summary = "Updates a pet in the store with form data", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "405", description = "Invalid input") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet/{petId}", + consumes = "application/x-www-form-urlencoded" + ) + ResponseEntity updatePetWithForm( + @Parameter(name = "petId", description = "ID of pet that needs to be updated", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "name", description = "Updated name of the pet", schema = @Schema(description = "")) @RequestParam(value="name", required=false) String name, + @Parameter(name = "status", description = "Updated status of the pet", schema = @Schema(description = "")) @RequestParam(value="status", required=false) String 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) + */ + @Operation( + summary = "uploads an image", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ModelApiResponse.class))) + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet/{petId}/uploadImage", + produces = "application/json", + consumes = "multipart/form-data" + ) + ResponseEntity uploadFile( + @Parameter(name = "petId", description = "ID of pet to update", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "additionalMetadata", description = "Additional data to pass to server", schema = @Schema(description = "")) @RequestParam(value="additionalMetadata", required=false) String additionalMetadata, + @Parameter(name = "file", description = "file to upload", schema = @Schema(description = "")) @RequestParam("file") MultipartFile file + ); + + + /** + * POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required) + * + * @param petId ID of pet to update (required) + * @param requiredFile file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @return successful operation (status code 200) + */ + @Operation( + summary = "uploads an image (required)", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ModelApiResponse.class))) + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/{petId}/uploadImageWithRequiredFile", + produces = "application/json", + consumes = "multipart/form-data" + ) + ResponseEntity uploadFileWithRequiredFile( + @Parameter(name = "petId", description = "ID of pet to update", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "requiredFile", description = "file to upload", required = true, schema = @Schema(description = "")) @RequestParam("requiredFile") MultipartFile requiredFile, + @Parameter(name = "additionalMetadata", description = "Additional data to pass to server", schema = @Schema(description = "")) @RequestParam(value="additionalMetadata", required=false) String additionalMetadata + ); + +} diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/api/StoreApi.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/api/StoreApi.java new file mode 100644 index 000000000000..d8329e19d40b --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/api/StoreApi.java @@ -0,0 +1,139 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "Store", description = "the Store API") +public interface StoreApi { + + /** + * DELETE /store/order/{order_id} : 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) + */ + @Operation( + summary = "Delete purchase order by ID", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/store/order/{order_id}" + ) + ResponseEntity deleteOrder( + @Parameter(name = "order_id", description = "ID of the order that needs to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("order_id") String orderId + ); + + + /** + * GET /store/inventory : Returns pet inventories by status + * Returns a map of status codes to quantities + * + * @return successful operation (status code 200) + */ + @Operation( + summary = "Returns pet inventories by status", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Map.class))) + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/store/inventory", + produces = "application/json" + ) + ResponseEntity> getInventory( + + ); + + + /** + * GET /store/order/{order_id} : Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated 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) + */ + @Operation( + summary = "Find purchase order by ID", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/store/order/{order_id}", + produces = "application/json" + ) + ResponseEntity getOrderById( + @Min(1L) @Max(5L) @Parameter(name = "order_id", description = "ID of pet that needs to be fetched", required = true, schema = @Schema(description = "")) @PathVariable("order_id") Long orderId + ); + + + /** + * POST /store/order : Place an order for a pet + * + * @param body order placed for purchasing the pet (required) + * @return successful operation (status code 200) + * or Invalid Order (status code 400) + */ + @Operation( + summary = "Place an order for a pet", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid Order") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/store/order", + produces = "application/json" + ) + ResponseEntity placeOrder( + @Parameter(name = "body", description = "order placed for purchasing the pet", required = true, schema = @Schema(description = "")) @Valid @RequestBody Order body + ); + +} diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/api/UserApi.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/api/UserApi.java new file mode 100644 index 000000000000..665546ec700e --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/api/UserApi.java @@ -0,0 +1,230 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "User", description = "the User API") +public interface UserApi { + + /** + * POST /user : Create user + * This can only be done by the logged in user. + * + * @param body Created user object (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "Create user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user" + ) + ResponseEntity createUser( + @Parameter(name = "body", description = "Created user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody User body + ); + + + /** + * POST /user/createWithArray : Creates list of users with given input array + * + * @param body List of user object (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "Creates list of users with given input array", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user/createWithArray" + ) + ResponseEntity createUsersWithArrayInput( + @Parameter(name = "body", description = "List of user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody List body + ); + + + /** + * POST /user/createWithList : Creates list of users with given input array + * + * @param body List of user object (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "Creates list of users with given input array", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user/createWithList" + ) + ResponseEntity createUsersWithListInput( + @Parameter(name = "body", description = "List of user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody List body + ); + + + /** + * 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) + */ + @Operation( + summary = "Delete user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/user/{username}" + ) + ResponseEntity deleteUser( + @Parameter(name = "username", description = "The name that needs to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("username") String 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) + */ + @Operation( + summary = "Get user by user name", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = User.class))), + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/{username}", + produces = "application/json" + ) + ResponseEntity getUserByName( + @Parameter(name = "username", description = "The name that needs to be fetched. Use user1 for testing.", required = true, schema = @Schema(description = "")) @PathVariable("username") String 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) + */ + @Operation( + summary = "Logs user into the system", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "400", description = "Invalid username/password supplied") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/login", + produces = "application/json" + ) + ResponseEntity loginUser( + @NotNull @Parameter(name = "username", description = "The user name for login", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "username", required = true) String username, + @NotNull @Parameter(name = "password", description = "The password for login in clear text", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "password", required = true) String password + ); + + + /** + * GET /user/logout : Logs out current logged in user session + * + * @return successful operation (status code 200) + */ + @Operation( + summary = "Logs out current logged in user session", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/logout" + ) + ResponseEntity 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 body Updated user object (required) + * @return Invalid user supplied (status code 400) + * or User not found (status code 404) + */ + @Operation( + summary = "Updated user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid user supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/user/{username}" + ) + ResponseEntity updateUser( + @Parameter(name = "username", description = "name that need to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("username") String username, + @Parameter(name = "body", description = "Updated user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody User body + ); + +} diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java new file mode 100644 index 000000000000..0c57ae7dd14c --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java @@ -0,0 +1,86 @@ +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 java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesAnyType + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesAnyType extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesAnyType name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesAnyType additionalPropertiesAnyType = (AdditionalPropertiesAnyType) o; + return Objects.equals(this.name, additionalPropertiesAnyType.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesAnyType {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/AdditionalPropertiesArray.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/AdditionalPropertiesArray.java new file mode 100644 index 000000000000..b5285ec2f29b --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/AdditionalPropertiesArray.java @@ -0,0 +1,87 @@ +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 java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesArray + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesArray extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesArray name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesArray additionalPropertiesArray = (AdditionalPropertiesArray) o; + return Objects.equals(this.name, additionalPropertiesArray.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesArray {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java new file mode 100644 index 000000000000..f8ca38c286d5 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java @@ -0,0 +1,86 @@ +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 java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesBoolean + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesBoolean extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesBoolean name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesBoolean additionalPropertiesBoolean = (AdditionalPropertiesBoolean) o; + return Objects.equals(this.name, additionalPropertiesBoolean.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesBoolean {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java new file mode 100644 index 000000000000..dfd28ccb9963 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java @@ -0,0 +1,414 @@ +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 java.math.BigDecimal; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesClass + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesClass { + @JsonProperty("map_string") + @Valid + private Map mapString = null; + + @JsonProperty("map_number") + @Valid + private Map mapNumber = null; + + @JsonProperty("map_integer") + @Valid + private Map mapInteger = null; + + @JsonProperty("map_boolean") + @Valid + private Map mapBoolean = null; + + @JsonProperty("map_array_integer") + @Valid + private Map> mapArrayInteger = null; + + @JsonProperty("map_array_anytype") + @Valid + private Map> mapArrayAnytype = null; + + @JsonProperty("map_map_string") + @Valid + private Map> mapMapString = null; + + @JsonProperty("map_map_anytype") + @Valid + private Map> mapMapAnytype = null; + + @JsonProperty("anytype_1") + private Object anytype1; + + @JsonProperty("anytype_2") + private Object anytype2; + + @JsonProperty("anytype_3") + private Object anytype3; + + public AdditionalPropertiesClass mapString(Map mapString) { + this.mapString = mapString; + return this; + } + + public AdditionalPropertiesClass putMapStringItem(String key, String mapStringItem) { + if (this.mapString == null) { + this.mapString = new HashMap<>(); + } + this.mapString.put(key, mapStringItem); + return this; + } + + /** + * Get mapString + * @return mapString + */ + @Schema(name = "mapString", defaultValue = "") + + + public Map getMapString() { + return mapString; + } + + public void setMapString(Map mapString) { + this.mapString = mapString; + } + + public AdditionalPropertiesClass mapNumber(Map mapNumber) { + this.mapNumber = mapNumber; + return this; + } + + public AdditionalPropertiesClass putMapNumberItem(String key, BigDecimal mapNumberItem) { + if (this.mapNumber == null) { + this.mapNumber = new HashMap<>(); + } + this.mapNumber.put(key, mapNumberItem); + return this; + } + + /** + * Get mapNumber + * @return mapNumber + */ + @Schema(name = "mapNumber", defaultValue = "") + + @Valid + + public Map getMapNumber() { + return mapNumber; + } + + public void setMapNumber(Map mapNumber) { + this.mapNumber = mapNumber; + } + + public AdditionalPropertiesClass mapInteger(Map mapInteger) { + this.mapInteger = mapInteger; + return this; + } + + public AdditionalPropertiesClass putMapIntegerItem(String key, Integer mapIntegerItem) { + if (this.mapInteger == null) { + this.mapInteger = new HashMap<>(); + } + this.mapInteger.put(key, mapIntegerItem); + return this; + } + + /** + * Get mapInteger + * @return mapInteger + */ + @Schema(name = "mapInteger", defaultValue = "") + + + public Map getMapInteger() { + return mapInteger; + } + + public void setMapInteger(Map mapInteger) { + this.mapInteger = mapInteger; + } + + public AdditionalPropertiesClass mapBoolean(Map mapBoolean) { + this.mapBoolean = mapBoolean; + return this; + } + + public AdditionalPropertiesClass putMapBooleanItem(String key, Boolean mapBooleanItem) { + if (this.mapBoolean == null) { + this.mapBoolean = new HashMap<>(); + } + this.mapBoolean.put(key, mapBooleanItem); + return this; + } + + /** + * Get mapBoolean + * @return mapBoolean + */ + @Schema(name = "mapBoolean", defaultValue = "") + + + public Map getMapBoolean() { + return mapBoolean; + } + + public void setMapBoolean(Map mapBoolean) { + this.mapBoolean = mapBoolean; + } + + public AdditionalPropertiesClass mapArrayInteger(Map> mapArrayInteger) { + this.mapArrayInteger = mapArrayInteger; + return this; + } + + public AdditionalPropertiesClass putMapArrayIntegerItem(String key, List mapArrayIntegerItem) { + if (this.mapArrayInteger == null) { + this.mapArrayInteger = new HashMap<>(); + } + this.mapArrayInteger.put(key, mapArrayIntegerItem); + return this; + } + + /** + * Get mapArrayInteger + * @return mapArrayInteger + */ + @Schema(name = "mapArrayInteger", defaultValue = "") + + @Valid + + public Map> getMapArrayInteger() { + return mapArrayInteger; + } + + public void setMapArrayInteger(Map> mapArrayInteger) { + this.mapArrayInteger = mapArrayInteger; + } + + public AdditionalPropertiesClass mapArrayAnytype(Map> mapArrayAnytype) { + this.mapArrayAnytype = mapArrayAnytype; + return this; + } + + public AdditionalPropertiesClass putMapArrayAnytypeItem(String key, List mapArrayAnytypeItem) { + if (this.mapArrayAnytype == null) { + this.mapArrayAnytype = new HashMap<>(); + } + this.mapArrayAnytype.put(key, mapArrayAnytypeItem); + return this; + } + + /** + * Get mapArrayAnytype + * @return mapArrayAnytype + */ + @Schema(name = "mapArrayAnytype", defaultValue = "") + + @Valid + + public Map> getMapArrayAnytype() { + return mapArrayAnytype; + } + + public void setMapArrayAnytype(Map> mapArrayAnytype) { + this.mapArrayAnytype = mapArrayAnytype; + } + + public AdditionalPropertiesClass mapMapString(Map> mapMapString) { + this.mapMapString = mapMapString; + return this; + } + + public AdditionalPropertiesClass putMapMapStringItem(String key, Map mapMapStringItem) { + if (this.mapMapString == null) { + this.mapMapString = new HashMap<>(); + } + this.mapMapString.put(key, mapMapStringItem); + return this; + } + + /** + * Get mapMapString + * @return mapMapString + */ + @Schema(name = "mapMapString", defaultValue = "") + + @Valid + + public Map> getMapMapString() { + return mapMapString; + } + + public void setMapMapString(Map> mapMapString) { + this.mapMapString = mapMapString; + } + + public AdditionalPropertiesClass mapMapAnytype(Map> mapMapAnytype) { + this.mapMapAnytype = mapMapAnytype; + return this; + } + + public AdditionalPropertiesClass putMapMapAnytypeItem(String key, Map mapMapAnytypeItem) { + if (this.mapMapAnytype == null) { + this.mapMapAnytype = new HashMap<>(); + } + this.mapMapAnytype.put(key, mapMapAnytypeItem); + return this; + } + + /** + * Get mapMapAnytype + * @return mapMapAnytype + */ + @Schema(name = "mapMapAnytype", defaultValue = "") + + @Valid + + public Map> getMapMapAnytype() { + return mapMapAnytype; + } + + public void setMapMapAnytype(Map> mapMapAnytype) { + this.mapMapAnytype = mapMapAnytype; + } + + public AdditionalPropertiesClass anytype1(Object anytype1) { + this.anytype1 = anytype1; + return this; + } + + /** + * Get anytype1 + * @return anytype1 + */ + @Schema(name = "anytype1", defaultValue = "") + + + public Object getAnytype1() { + return anytype1; + } + + public void setAnytype1(Object anytype1) { + this.anytype1 = anytype1; + } + + public AdditionalPropertiesClass anytype2(Object anytype2) { + this.anytype2 = anytype2; + return this; + } + + /** + * Get anytype2 + * @return anytype2 + */ + @Schema(name = "anytype2", defaultValue = "") + + + public Object getAnytype2() { + return anytype2; + } + + public void setAnytype2(Object anytype2) { + this.anytype2 = anytype2; + } + + public AdditionalPropertiesClass anytype3(Object anytype3) { + this.anytype3 = anytype3; + return this; + } + + /** + * Get anytype3 + * @return anytype3 + */ + @Schema(name = "anytype3", defaultValue = "") + + + public Object getAnytype3() { + return anytype3; + } + + public void setAnytype3(Object anytype3) { + this.anytype3 = anytype3; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AdditionalPropertiesClass additionalPropertiesClass = (AdditionalPropertiesClass) o; + return Objects.equals(this.mapString, additionalPropertiesClass.mapString) && + Objects.equals(this.mapNumber, additionalPropertiesClass.mapNumber) && + Objects.equals(this.mapInteger, additionalPropertiesClass.mapInteger) && + Objects.equals(this.mapBoolean, additionalPropertiesClass.mapBoolean) && + Objects.equals(this.mapArrayInteger, additionalPropertiesClass.mapArrayInteger) && + Objects.equals(this.mapArrayAnytype, additionalPropertiesClass.mapArrayAnytype) && + Objects.equals(this.mapMapString, additionalPropertiesClass.mapMapString) && + Objects.equals(this.mapMapAnytype, additionalPropertiesClass.mapMapAnytype) && + Objects.equals(this.anytype1, additionalPropertiesClass.anytype1) && + Objects.equals(this.anytype2, additionalPropertiesClass.anytype2) && + Objects.equals(this.anytype3, additionalPropertiesClass.anytype3); + } + + @Override + public int hashCode() { + return Objects.hash(mapString, mapNumber, mapInteger, mapBoolean, mapArrayInteger, mapArrayAnytype, mapMapString, mapMapAnytype, anytype1, anytype2, anytype3); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesClass {\n"); + + sb.append(" mapString: ").append(toIndentedString(mapString)).append("\n"); + sb.append(" mapNumber: ").append(toIndentedString(mapNumber)).append("\n"); + sb.append(" mapInteger: ").append(toIndentedString(mapInteger)).append("\n"); + sb.append(" mapBoolean: ").append(toIndentedString(mapBoolean)).append("\n"); + sb.append(" mapArrayInteger: ").append(toIndentedString(mapArrayInteger)).append("\n"); + sb.append(" mapArrayAnytype: ").append(toIndentedString(mapArrayAnytype)).append("\n"); + sb.append(" mapMapString: ").append(toIndentedString(mapMapString)).append("\n"); + sb.append(" mapMapAnytype: ").append(toIndentedString(mapMapAnytype)).append("\n"); + sb.append(" anytype1: ").append(toIndentedString(anytype1)).append("\n"); + sb.append(" anytype2: ").append(toIndentedString(anytype2)).append("\n"); + sb.append(" anytype3: ").append(toIndentedString(anytype3)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java new file mode 100644 index 000000000000..5fea577ab44b --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java @@ -0,0 +1,86 @@ +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 java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesInteger + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesInteger extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesInteger name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesInteger additionalPropertiesInteger = (AdditionalPropertiesInteger) o; + return Objects.equals(this.name, additionalPropertiesInteger.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesInteger {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java new file mode 100644 index 000000000000..e6eee612a24f --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java @@ -0,0 +1,87 @@ +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 java.math.BigDecimal; +import java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesNumber + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesNumber extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesNumber name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesNumber additionalPropertiesNumber = (AdditionalPropertiesNumber) o; + return Objects.equals(this.name, additionalPropertiesNumber.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesNumber {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/AdditionalPropertiesObject.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/AdditionalPropertiesObject.java new file mode 100644 index 000000000000..d7116bd7572c --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/AdditionalPropertiesObject.java @@ -0,0 +1,86 @@ +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 java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesObject + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesObject extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesObject name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesObject additionalPropertiesObject = (AdditionalPropertiesObject) o; + return Objects.equals(this.name, additionalPropertiesObject.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesObject {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/AdditionalPropertiesString.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/AdditionalPropertiesString.java new file mode 100644 index 000000000000..d2022be266fb --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/AdditionalPropertiesString.java @@ -0,0 +1,86 @@ +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 java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesString + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesString extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesString name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesString additionalPropertiesString = (AdditionalPropertiesString) o; + return Objects.equals(this.name, additionalPropertiesString.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesString {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Animal.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Animal.java new file mode 100644 index 000000000000..6f096d5069ed --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Animal.java @@ -0,0 +1,118 @@ +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.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Animal + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "className", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = BigCat.class, name = "BigCat"), + @JsonSubTypes.Type(value = Cat.class, name = "Cat"), + @JsonSubTypes.Type(value = Dog.class, name = "Dog"), +}) + +public class Animal { + @JsonProperty("className") + private String className; + + @JsonProperty("color") + private String color = "red"; + + public Animal className(String className) { + this.className = className; + return this; + } + + /** + * Get className + * @return className + */ + @Schema(name = "className", required = true, defaultValue = "") + @NotNull + + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public Animal color(String color) { + this.color = color; + return this; + } + + /** + * Get color + * @return color + */ + @Schema(name = "color", defaultValue = "") + + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Animal animal = (Animal) o; + return Objects.equals(this.className, animal.className) && + Objects.equals(this.color, animal.color); + } + + @Override + public int hashCode() { + return Objects.hash(className, color); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Animal {\n"); + + sb.append(" className: ").append(toIndentedString(className)).append("\n"); + sb.append(" color: ").append(toIndentedString(color)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java new file mode 100644 index 000000000000..ebe36ad761a9 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java @@ -0,0 +1,96 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ArrayOfArrayOfNumberOnly + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ArrayOfArrayOfNumberOnly { + @JsonProperty("ArrayArrayNumber") + @Valid + private List> arrayArrayNumber = null; + + public ArrayOfArrayOfNumberOnly arrayArrayNumber(List> arrayArrayNumber) { + this.arrayArrayNumber = arrayArrayNumber; + return this; + } + + public ArrayOfArrayOfNumberOnly addArrayArrayNumberItem(List arrayArrayNumberItem) { + if (this.arrayArrayNumber == null) { + this.arrayArrayNumber = new ArrayList<>(); + } + this.arrayArrayNumber.add(arrayArrayNumberItem); + return this; + } + + /** + * Get arrayArrayNumber + * @return arrayArrayNumber + */ + @Schema(name = "arrayArrayNumber", defaultValue = "") + + @Valid + + public List> getArrayArrayNumber() { + return arrayArrayNumber; + } + + public void setArrayArrayNumber(List> arrayArrayNumber) { + this.arrayArrayNumber = arrayArrayNumber; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly = (ArrayOfArrayOfNumberOnly) o; + return Objects.equals(this.arrayArrayNumber, arrayOfArrayOfNumberOnly.arrayArrayNumber); + } + + @Override + public int hashCode() { + return Objects.hash(arrayArrayNumber); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayOfArrayOfNumberOnly {\n"); + + sb.append(" arrayArrayNumber: ").append(toIndentedString(arrayArrayNumber)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ArrayOfNumberOnly.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ArrayOfNumberOnly.java new file mode 100644 index 000000000000..8158dd44ab88 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ArrayOfNumberOnly.java @@ -0,0 +1,96 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ArrayOfNumberOnly + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ArrayOfNumberOnly { + @JsonProperty("ArrayNumber") + @Valid + private List arrayNumber = null; + + public ArrayOfNumberOnly arrayNumber(List arrayNumber) { + this.arrayNumber = arrayNumber; + return this; + } + + public ArrayOfNumberOnly addArrayNumberItem(BigDecimal arrayNumberItem) { + if (this.arrayNumber == null) { + this.arrayNumber = new ArrayList<>(); + } + this.arrayNumber.add(arrayNumberItem); + return this; + } + + /** + * Get arrayNumber + * @return arrayNumber + */ + @Schema(name = "arrayNumber", defaultValue = "") + + @Valid + + public List getArrayNumber() { + return arrayNumber; + } + + public void setArrayNumber(List arrayNumber) { + this.arrayNumber = arrayNumber; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayOfNumberOnly arrayOfNumberOnly = (ArrayOfNumberOnly) o; + return Objects.equals(this.arrayNumber, arrayOfNumberOnly.arrayNumber); + } + + @Override + public int hashCode() { + return Objects.hash(arrayNumber); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayOfNumberOnly {\n"); + + sb.append(" arrayNumber: ").append(toIndentedString(arrayNumber)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ArrayTest.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ArrayTest.java new file mode 100644 index 000000000000..420010561bcd --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ArrayTest.java @@ -0,0 +1,165 @@ +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 java.util.ArrayList; +import java.util.List; +import org.openapitools.model.ReadOnlyFirst; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ArrayTest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ArrayTest { + @JsonProperty("array_of_string") + @Valid + private List arrayOfString = null; + + @JsonProperty("array_array_of_integer") + @Valid + private List> arrayArrayOfInteger = null; + + @JsonProperty("array_array_of_model") + @Valid + private List> arrayArrayOfModel = null; + + public ArrayTest arrayOfString(List arrayOfString) { + this.arrayOfString = arrayOfString; + return this; + } + + public ArrayTest addArrayOfStringItem(String arrayOfStringItem) { + if (this.arrayOfString == null) { + this.arrayOfString = new ArrayList<>(); + } + this.arrayOfString.add(arrayOfStringItem); + return this; + } + + /** + * Get arrayOfString + * @return arrayOfString + */ + @Schema(name = "arrayOfString", defaultValue = "") + + + public List getArrayOfString() { + return arrayOfString; + } + + public void setArrayOfString(List arrayOfString) { + this.arrayOfString = arrayOfString; + } + + public ArrayTest arrayArrayOfInteger(List> arrayArrayOfInteger) { + this.arrayArrayOfInteger = arrayArrayOfInteger; + return this; + } + + public ArrayTest addArrayArrayOfIntegerItem(List arrayArrayOfIntegerItem) { + if (this.arrayArrayOfInteger == null) { + this.arrayArrayOfInteger = new ArrayList<>(); + } + this.arrayArrayOfInteger.add(arrayArrayOfIntegerItem); + return this; + } + + /** + * Get arrayArrayOfInteger + * @return arrayArrayOfInteger + */ + @Schema(name = "arrayArrayOfInteger", defaultValue = "") + + @Valid + + public List> getArrayArrayOfInteger() { + return arrayArrayOfInteger; + } + + public void setArrayArrayOfInteger(List> arrayArrayOfInteger) { + this.arrayArrayOfInteger = arrayArrayOfInteger; + } + + public ArrayTest arrayArrayOfModel(List> arrayArrayOfModel) { + this.arrayArrayOfModel = arrayArrayOfModel; + return this; + } + + public ArrayTest addArrayArrayOfModelItem(List arrayArrayOfModelItem) { + if (this.arrayArrayOfModel == null) { + this.arrayArrayOfModel = new ArrayList<>(); + } + this.arrayArrayOfModel.add(arrayArrayOfModelItem); + return this; + } + + /** + * Get arrayArrayOfModel + * @return arrayArrayOfModel + */ + @Schema(name = "arrayArrayOfModel", defaultValue = "") + + @Valid + + public List> getArrayArrayOfModel() { + return arrayArrayOfModel; + } + + public void setArrayArrayOfModel(List> arrayArrayOfModel) { + this.arrayArrayOfModel = arrayArrayOfModel; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayTest arrayTest = (ArrayTest) o; + return Objects.equals(this.arrayOfString, arrayTest.arrayOfString) && + Objects.equals(this.arrayArrayOfInteger, arrayTest.arrayArrayOfInteger) && + Objects.equals(this.arrayArrayOfModel, arrayTest.arrayArrayOfModel); + } + + @Override + public int hashCode() { + return Objects.hash(arrayOfString, arrayArrayOfInteger, arrayArrayOfModel); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayTest {\n"); + + sb.append(" arrayOfString: ").append(toIndentedString(arrayOfString)).append("\n"); + sb.append(" arrayArrayOfInteger: ").append(toIndentedString(arrayArrayOfInteger)).append("\n"); + sb.append(" arrayArrayOfModel: ").append(toIndentedString(arrayArrayOfModel)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/BigCat.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/BigCat.java new file mode 100644 index 000000000000..7f4a080ad8d2 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/BigCat.java @@ -0,0 +1,126 @@ +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 org.openapitools.model.BigCatAllOf; +import org.openapitools.model.Cat; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * BigCat + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class BigCat extends Cat { + /** + * Gets or Sets kind + */ + public enum KindEnum { + LIONS("lions"), + + TIGERS("tigers"), + + LEOPARDS("leopards"), + + JAGUARS("jaguars"); + + private String value; + + KindEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static KindEnum fromValue(String value) { + for (KindEnum b : KindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("kind") + private KindEnum kind; + + public BigCat kind(KindEnum kind) { + this.kind = kind; + return this; + } + + /** + * Get kind + * @return kind + */ + @Schema(name = "kind", defaultValue = "") + + + public KindEnum getKind() { + return kind; + } + + public void setKind(KindEnum kind) { + this.kind = kind; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BigCat bigCat = (BigCat) o; + return Objects.equals(this.kind, bigCat.kind) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(kind, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BigCat {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/BigCatAllOf.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/BigCatAllOf.java new file mode 100644 index 000000000000..d0a47ab5127c --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/BigCatAllOf.java @@ -0,0 +1,123 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * BigCatAllOf + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class BigCatAllOf { + /** + * Gets or Sets kind + */ + public enum KindEnum { + LIONS("lions"), + + TIGERS("tigers"), + + LEOPARDS("leopards"), + + JAGUARS("jaguars"); + + private String value; + + KindEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static KindEnum fromValue(String value) { + for (KindEnum b : KindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("kind") + private KindEnum kind; + + public BigCatAllOf kind(KindEnum kind) { + this.kind = kind; + return this; + } + + /** + * Get kind + * @return kind + */ + @Schema(name = "kind", defaultValue = "") + + + public KindEnum getKind() { + return kind; + } + + public void setKind(KindEnum kind) { + this.kind = kind; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BigCatAllOf bigCatAllOf = (BigCatAllOf) o; + return Objects.equals(this.kind, bigCatAllOf.kind); + } + + @Override + public int hashCode() { + return Objects.hash(kind); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BigCatAllOf {\n"); + + sb.append(" kind: ").append(toIndentedString(kind)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Capitalization.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Capitalization.java new file mode 100644 index 000000000000..92d9a7245f16 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Capitalization.java @@ -0,0 +1,208 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Capitalization + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Capitalization { + @JsonProperty("smallCamel") + private String smallCamel; + + @JsonProperty("CapitalCamel") + private String capitalCamel; + + @JsonProperty("small_Snake") + private String smallSnake; + + @JsonProperty("Capital_Snake") + private String capitalSnake; + + @JsonProperty("SCA_ETH_Flow_Points") + private String scAETHFlowPoints; + + @JsonProperty("ATT_NAME") + private String ATT_NAME; + + public Capitalization smallCamel(String smallCamel) { + this.smallCamel = smallCamel; + return this; + } + + /** + * Get smallCamel + * @return smallCamel + */ + @Schema(name = "smallCamel", defaultValue = "") + + + public String getSmallCamel() { + return smallCamel; + } + + public void setSmallCamel(String smallCamel) { + this.smallCamel = smallCamel; + } + + public Capitalization capitalCamel(String capitalCamel) { + this.capitalCamel = capitalCamel; + return this; + } + + /** + * Get capitalCamel + * @return capitalCamel + */ + @Schema(name = "capitalCamel", defaultValue = "") + + + public String getCapitalCamel() { + return capitalCamel; + } + + public void setCapitalCamel(String capitalCamel) { + this.capitalCamel = capitalCamel; + } + + public Capitalization smallSnake(String smallSnake) { + this.smallSnake = smallSnake; + return this; + } + + /** + * Get smallSnake + * @return smallSnake + */ + @Schema(name = "smallSnake", defaultValue = "") + + + public String getSmallSnake() { + return smallSnake; + } + + public void setSmallSnake(String smallSnake) { + this.smallSnake = smallSnake; + } + + public Capitalization capitalSnake(String capitalSnake) { + this.capitalSnake = capitalSnake; + return this; + } + + /** + * Get capitalSnake + * @return capitalSnake + */ + @Schema(name = "capitalSnake", defaultValue = "") + + + public String getCapitalSnake() { + return capitalSnake; + } + + public void setCapitalSnake(String capitalSnake) { + this.capitalSnake = capitalSnake; + } + + public Capitalization scAETHFlowPoints(String scAETHFlowPoints) { + this.scAETHFlowPoints = scAETHFlowPoints; + return this; + } + + /** + * Get scAETHFlowPoints + * @return scAETHFlowPoints + */ + @Schema(name = "scAETHFlowPoints", defaultValue = "") + + + public String getScAETHFlowPoints() { + return scAETHFlowPoints; + } + + public void setScAETHFlowPoints(String scAETHFlowPoints) { + this.scAETHFlowPoints = scAETHFlowPoints; + } + + public Capitalization ATT_NAME(String ATT_NAME) { + this.ATT_NAME = ATT_NAME; + return this; + } + + /** + * Name of the pet + * @return ATT_NAME + */ + @Schema(name = "ATT_NAME", defaultValue = "Name of the pet ") + + + public String getATTNAME() { + return ATT_NAME; + } + + public void setATTNAME(String ATT_NAME) { + this.ATT_NAME = ATT_NAME; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Capitalization capitalization = (Capitalization) o; + return Objects.equals(this.smallCamel, capitalization.smallCamel) && + Objects.equals(this.capitalCamel, capitalization.capitalCamel) && + Objects.equals(this.smallSnake, capitalization.smallSnake) && + Objects.equals(this.capitalSnake, capitalization.capitalSnake) && + Objects.equals(this.scAETHFlowPoints, capitalization.scAETHFlowPoints) && + Objects.equals(this.ATT_NAME, capitalization.ATT_NAME); + } + + @Override + public int hashCode() { + return Objects.hash(smallCamel, capitalCamel, smallSnake, capitalSnake, scAETHFlowPoints, ATT_NAME); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Capitalization {\n"); + + sb.append(" smallCamel: ").append(toIndentedString(smallCamel)).append("\n"); + sb.append(" capitalCamel: ").append(toIndentedString(capitalCamel)).append("\n"); + sb.append(" smallSnake: ").append(toIndentedString(smallSnake)).append("\n"); + sb.append(" capitalSnake: ").append(toIndentedString(capitalSnake)).append("\n"); + sb.append(" scAETHFlowPoints: ").append(toIndentedString(scAETHFlowPoints)).append("\n"); + sb.append(" ATT_NAME: ").append(toIndentedString(ATT_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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Cat.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Cat.java new file mode 100644 index 000000000000..2e496fb4accd --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Cat.java @@ -0,0 +1,86 @@ +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 org.openapitools.model.Animal; +import org.openapitools.model.CatAllOf; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Cat + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Cat extends Animal { + @JsonProperty("declawed") + private Boolean declawed; + + public Cat declawed(Boolean declawed) { + this.declawed = declawed; + return this; + } + + /** + * Get declawed + * @return declawed + */ + @Schema(name = "declawed", defaultValue = "") + + + public Boolean getDeclawed() { + return declawed; + } + + public void setDeclawed(Boolean declawed) { + this.declawed = declawed; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Cat cat = (Cat) o; + return Objects.equals(this.declawed, cat.declawed) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(declawed, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Cat {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" declawed: ").append(toIndentedString(declawed)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/CatAllOf.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/CatAllOf.java new file mode 100644 index 000000000000..b732a62b1bc3 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/CatAllOf.java @@ -0,0 +1,83 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * CatAllOf + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class CatAllOf { + @JsonProperty("declawed") + private Boolean declawed; + + public CatAllOf declawed(Boolean declawed) { + this.declawed = declawed; + return this; + } + + /** + * Get declawed + * @return declawed + */ + @Schema(name = "declawed", defaultValue = "") + + + public Boolean getDeclawed() { + return declawed; + } + + public void setDeclawed(Boolean declawed) { + this.declawed = declawed; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CatAllOf catAllOf = (CatAllOf) o; + return Objects.equals(this.declawed, catAllOf.declawed); + } + + @Override + public int hashCode() { + return Objects.hash(declawed); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CatAllOf {\n"); + + sb.append(" declawed: ").append(toIndentedString(declawed)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Category.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Category.java new file mode 100644 index 000000000000..038fc8df3afd --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Category.java @@ -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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Category + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Category { + @JsonProperty("id") + private Long id; + + @JsonProperty("name") + private String name = "default-name"; + + public Category id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "name", required = true, defaultValue = "") + @NotNull + + + 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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ClassModel.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ClassModel.java new file mode 100644 index 000000000000..fa2a736f4fb5 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ClassModel.java @@ -0,0 +1,84 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Model for testing model with \"_class\" property + */ +@Schema(name = "ClassModel",description = "Model for testing model with \"_class\" property") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ClassModel { + @JsonProperty("_class") + private String propertyClass; + + public ClassModel propertyClass(String propertyClass) { + this.propertyClass = propertyClass; + return this; + } + + /** + * Get propertyClass + * @return propertyClass + */ + @Schema(name = "propertyClass", defaultValue = "") + + + public String getPropertyClass() { + return propertyClass; + } + + public void setPropertyClass(String propertyClass) { + this.propertyClass = propertyClass; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClassModel classModel = (ClassModel) o; + return Objects.equals(this.propertyClass, classModel.propertyClass); + } + + @Override + public int hashCode() { + return Objects.hash(propertyClass); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ClassModel {\n"); + + sb.append(" propertyClass: ").append(toIndentedString(propertyClass)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Client.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Client.java new file mode 100644 index 000000000000..e11bd4ff1b13 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Client.java @@ -0,0 +1,83 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Client + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Client { + @JsonProperty("client") + private String client; + + public Client client(String client) { + this.client = client; + return this; + } + + /** + * Get client + * @return client + */ + @Schema(name = "client", defaultValue = "") + + + public String getClient() { + return client; + } + + public void setClient(String client) { + this.client = client; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Client client = (Client) o; + return Objects.equals(this.client, client.client); + } + + @Override + public int hashCode() { + return Objects.hash(client); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Client {\n"); + + sb.append(" client: ").append(toIndentedString(client)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Dog.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Dog.java new file mode 100644 index 000000000000..ed5dc71a4ba2 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Dog.java @@ -0,0 +1,86 @@ +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 org.openapitools.model.Animal; +import org.openapitools.model.DogAllOf; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Dog + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Dog extends Animal { + @JsonProperty("breed") + private String breed; + + public Dog breed(String breed) { + this.breed = breed; + return this; + } + + /** + * Get breed + * @return breed + */ + @Schema(name = "breed", defaultValue = "") + + + public String getBreed() { + return breed; + } + + public void setBreed(String breed) { + this.breed = breed; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Dog dog = (Dog) o; + return Objects.equals(this.breed, dog.breed) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(breed, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Dog {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" breed: ").append(toIndentedString(breed)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/DogAllOf.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/DogAllOf.java new file mode 100644 index 000000000000..2c99bc376c34 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/DogAllOf.java @@ -0,0 +1,83 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * DogAllOf + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class DogAllOf { + @JsonProperty("breed") + private String breed; + + public DogAllOf breed(String breed) { + this.breed = breed; + return this; + } + + /** + * Get breed + * @return breed + */ + @Schema(name = "breed", defaultValue = "") + + + public String getBreed() { + return breed; + } + + public void setBreed(String breed) { + this.breed = breed; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DogAllOf dogAllOf = (DogAllOf) o; + return Objects.equals(this.breed, dogAllOf.breed); + } + + @Override + public int hashCode() { + return Objects.hash(breed); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DogAllOf {\n"); + + sb.append(" breed: ").append(toIndentedString(breed)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/EnumArrays.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/EnumArrays.java new file mode 100644 index 000000000000..e1b2df0716a2 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/EnumArrays.java @@ -0,0 +1,190 @@ +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 java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * EnumArrays + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class EnumArrays { + /** + * Gets or Sets justSymbol + */ + public enum JustSymbolEnum { + GREATER_THAN_OR_EQUAL_TO(">="), + + DOLLAR("$"); + + private String value; + + JustSymbolEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static JustSymbolEnum fromValue(String value) { + for (JustSymbolEnum b : JustSymbolEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("just_symbol") + private JustSymbolEnum justSymbol; + + /** + * Gets or Sets arrayEnum + */ + public enum ArrayEnumEnum { + FISH("fish"), + + CRAB("crab"); + + private String value; + + ArrayEnumEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static ArrayEnumEnum fromValue(String value) { + for (ArrayEnumEnum b : ArrayEnumEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("array_enum") + @Valid + private List arrayEnum = null; + + public EnumArrays justSymbol(JustSymbolEnum justSymbol) { + this.justSymbol = justSymbol; + return this; + } + + /** + * Get justSymbol + * @return justSymbol + */ + @Schema(name = "justSymbol", defaultValue = "") + + + public JustSymbolEnum getJustSymbol() { + return justSymbol; + } + + public void setJustSymbol(JustSymbolEnum justSymbol) { + this.justSymbol = justSymbol; + } + + public EnumArrays arrayEnum(List arrayEnum) { + this.arrayEnum = arrayEnum; + return this; + } + + public EnumArrays addArrayEnumItem(ArrayEnumEnum arrayEnumItem) { + if (this.arrayEnum == null) { + this.arrayEnum = new ArrayList<>(); + } + this.arrayEnum.add(arrayEnumItem); + return this; + } + + /** + * Get arrayEnum + * @return arrayEnum + */ + @Schema(name = "arrayEnum", defaultValue = "") + + + public List getArrayEnum() { + return arrayEnum; + } + + public void setArrayEnum(List arrayEnum) { + this.arrayEnum = arrayEnum; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EnumArrays enumArrays = (EnumArrays) o; + return Objects.equals(this.justSymbol, enumArrays.justSymbol) && + Objects.equals(this.arrayEnum, enumArrays.arrayEnum); + } + + @Override + public int hashCode() { + return Objects.hash(justSymbol, arrayEnum); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EnumArrays {\n"); + + sb.append(" justSymbol: ").append(toIndentedString(justSymbol)).append("\n"); + sb.append(" arrayEnum: ").append(toIndentedString(arrayEnum)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/EnumClass.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/EnumClass.java new file mode 100644 index 000000000000..e3d30c1ad453 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/EnumClass.java @@ -0,0 +1,55 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Gets or Sets EnumClass + */ +public enum EnumClass { + + _ABC("_abc"), + + _EFG("-efg"), + + _XYZ_("(xyz)"); + + private String value; + + EnumClass(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumClass fromValue(String value) { + for (EnumClass b : EnumClass.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/EnumTest.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/EnumTest.java new file mode 100644 index 000000000000..938af53e2b81 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/EnumTest.java @@ -0,0 +1,331 @@ +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 org.openapitools.model.OuterEnum; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * EnumTest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class EnumTest { + /** + * Gets or Sets enumString + */ + public enum EnumStringEnum { + UPPER("UPPER"), + + LOWER("lower"), + + EMPTY(""); + + private String value; + + EnumStringEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumStringEnum fromValue(String value) { + for (EnumStringEnum b : EnumStringEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("enum_string") + private EnumStringEnum enumString; + + /** + * Gets or Sets enumStringRequired + */ + public enum EnumStringRequiredEnum { + UPPER("UPPER"), + + LOWER("lower"), + + EMPTY(""); + + private String value; + + EnumStringRequiredEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumStringRequiredEnum fromValue(String value) { + for (EnumStringRequiredEnum b : EnumStringRequiredEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("enum_string_required") + private EnumStringRequiredEnum enumStringRequired; + + /** + * Gets or Sets enumInteger + */ + public enum EnumIntegerEnum { + NUMBER_1(1), + + NUMBER_MINUS_1(-1); + + private Integer value; + + EnumIntegerEnum(Integer value) { + this.value = value; + } + + @JsonValue + public Integer getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumIntegerEnum fromValue(Integer value) { + for (EnumIntegerEnum b : EnumIntegerEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("enum_integer") + private EnumIntegerEnum enumInteger; + + /** + * Gets or Sets enumNumber + */ + public enum EnumNumberEnum { + NUMBER_1_DOT_1(1.1), + + NUMBER_MINUS_1_DOT_2(-1.2); + + private Double value; + + EnumNumberEnum(Double value) { + this.value = value; + } + + @JsonValue + public Double getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumNumberEnum fromValue(Double value) { + for (EnumNumberEnum b : EnumNumberEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("enum_number") + private EnumNumberEnum enumNumber; + + @JsonProperty("outerEnum") + private OuterEnum outerEnum; + + public EnumTest enumString(EnumStringEnum enumString) { + this.enumString = enumString; + return this; + } + + /** + * Get enumString + * @return enumString + */ + @Schema(name = "enumString", defaultValue = "") + + + public EnumStringEnum getEnumString() { + return enumString; + } + + public void setEnumString(EnumStringEnum enumString) { + this.enumString = enumString; + } + + public EnumTest enumStringRequired(EnumStringRequiredEnum enumStringRequired) { + this.enumStringRequired = enumStringRequired; + return this; + } + + /** + * Get enumStringRequired + * @return enumStringRequired + */ + @Schema(name = "enumStringRequired", required = true, defaultValue = "") + @NotNull + + + public EnumStringRequiredEnum getEnumStringRequired() { + return enumStringRequired; + } + + public void setEnumStringRequired(EnumStringRequiredEnum enumStringRequired) { + this.enumStringRequired = enumStringRequired; + } + + public EnumTest enumInteger(EnumIntegerEnum enumInteger) { + this.enumInteger = enumInteger; + return this; + } + + /** + * Get enumInteger + * @return enumInteger + */ + @Schema(name = "enumInteger", defaultValue = "") + + + public EnumIntegerEnum getEnumInteger() { + return enumInteger; + } + + public void setEnumInteger(EnumIntegerEnum enumInteger) { + this.enumInteger = enumInteger; + } + + public EnumTest enumNumber(EnumNumberEnum enumNumber) { + this.enumNumber = enumNumber; + return this; + } + + /** + * Get enumNumber + * @return enumNumber + */ + @Schema(name = "enumNumber", defaultValue = "") + + + public EnumNumberEnum getEnumNumber() { + return enumNumber; + } + + public void setEnumNumber(EnumNumberEnum enumNumber) { + this.enumNumber = enumNumber; + } + + public EnumTest outerEnum(OuterEnum outerEnum) { + this.outerEnum = outerEnum; + return this; + } + + /** + * Get outerEnum + * @return outerEnum + */ + @Schema(name = "outerEnum", defaultValue = "") + + @Valid + + public OuterEnum getOuterEnum() { + return outerEnum; + } + + public void setOuterEnum(OuterEnum outerEnum) { + this.outerEnum = outerEnum; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EnumTest enumTest = (EnumTest) o; + return Objects.equals(this.enumString, enumTest.enumString) && + Objects.equals(this.enumStringRequired, enumTest.enumStringRequired) && + Objects.equals(this.enumInteger, enumTest.enumInteger) && + Objects.equals(this.enumNumber, enumTest.enumNumber) && + Objects.equals(this.outerEnum, enumTest.outerEnum); + } + + @Override + public int hashCode() { + return Objects.hash(enumString, enumStringRequired, enumInteger, enumNumber, outerEnum); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EnumTest {\n"); + + sb.append(" enumString: ").append(toIndentedString(enumString)).append("\n"); + sb.append(" enumStringRequired: ").append(toIndentedString(enumStringRequired)).append("\n"); + sb.append(" enumInteger: ").append(toIndentedString(enumInteger)).append("\n"); + sb.append(" enumNumber: ").append(toIndentedString(enumNumber)).append("\n"); + sb.append(" outerEnum: ").append(toIndentedString(outerEnum)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/FileSchemaTestClass.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/FileSchemaTestClass.java new file mode 100644 index 000000000000..0d1e9ca8495c --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/FileSchemaTestClass.java @@ -0,0 +1,121 @@ +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 java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * FileSchemaTestClass + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class FileSchemaTestClass { + @JsonProperty("file") + private java.io.File file; + + @JsonProperty("files") + @Valid + private List files = null; + + public FileSchemaTestClass file(java.io.File file) { + this.file = file; + return this; + } + + /** + * Get file + * @return file + */ + @Schema(name = "file", defaultValue = "") + + @Valid + + public java.io.File getFile() { + return file; + } + + public void setFile(java.io.File file) { + this.file = file; + } + + public FileSchemaTestClass files(List files) { + this.files = files; + return this; + } + + public FileSchemaTestClass addFilesItem(java.io.File filesItem) { + if (this.files == null) { + this.files = new ArrayList<>(); + } + this.files.add(filesItem); + return this; + } + + /** + * Get files + * @return files + */ + @Schema(name = "files", defaultValue = "") + + @Valid + + public List getFiles() { + return files; + } + + public void setFiles(List files) { + this.files = files; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FileSchemaTestClass fileSchemaTestClass = (FileSchemaTestClass) o; + return Objects.equals(this.file, fileSchemaTestClass.file) && + Objects.equals(this.files, fileSchemaTestClass.files); + } + + @Override + public int hashCode() { + return Objects.hash(file, files); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FileSchemaTestClass {\n"); + + sb.append(" file: ").append(toIndentedString(file)).append("\n"); + sb.append(" files: ").append(toIndentedString(files)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/FormatTest.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/FormatTest.java new file mode 100644 index 000000000000..6546370cd329 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/FormatTest.java @@ -0,0 +1,435 @@ +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 java.math.BigDecimal; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.UUID; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * FormatTest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class FormatTest { + @JsonProperty("integer") + private Integer integer; + + @JsonProperty("int32") + private Integer int32; + + @JsonProperty("int64") + private Long int64; + + @JsonProperty("number") + private BigDecimal number; + + @JsonProperty("float") + private Float _float; + + @JsonProperty("double") + private Double _double; + + @JsonProperty("string") + private String string; + + @JsonProperty("byte") + private byte[] _byte; + + @JsonProperty("binary") + private org.springframework.core.io.Resource binary; + + @JsonProperty("date") + @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) + private LocalDate date; + + @JsonProperty("dateTime") + @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) + private OffsetDateTime dateTime; + + @JsonProperty("uuid") + private UUID uuid; + + @JsonProperty("password") + private String password; + + @JsonProperty("BigDecimal") + private BigDecimal bigDecimal; + + public FormatTest integer(Integer integer) { + this.integer = integer; + return this; + } + + /** + * Get integer + * minimum: 10 + * maximum: 100 + * @return integer + */ + @Schema(name = "integer", defaultValue = "") + +@Min(10) @Max(100) + public Integer getInteger() { + return integer; + } + + public void setInteger(Integer integer) { + this.integer = integer; + } + + public FormatTest int32(Integer int32) { + this.int32 = int32; + return this; + } + + /** + * Get int32 + * minimum: 20 + * maximum: 200 + * @return int32 + */ + @Schema(name = "int32", defaultValue = "") + +@Min(20) @Max(200) + public Integer getInt32() { + return int32; + } + + public void setInt32(Integer int32) { + this.int32 = int32; + } + + public FormatTest int64(Long int64) { + this.int64 = int64; + return this; + } + + /** + * Get int64 + * @return int64 + */ + @Schema(name = "int64", defaultValue = "") + + + public Long getInt64() { + return int64; + } + + public void setInt64(Long int64) { + this.int64 = int64; + } + + public FormatTest number(BigDecimal number) { + this.number = number; + return this; + } + + /** + * Get number + * minimum: 32.1 + * maximum: 543.2 + * @return number + */ + @Schema(name = "number", required = true, defaultValue = "") + @NotNull + + @Valid +@DecimalMin("32.1") @DecimalMax("543.2") + public BigDecimal getNumber() { + return number; + } + + public void setNumber(BigDecimal number) { + this.number = number; + } + + public FormatTest _float(Float _float) { + this._float = _float; + return this; + } + + /** + * Get _float + * minimum: 54.3 + * maximum: 987.6 + * @return _float + */ + @Schema(name = "_float", defaultValue = "") + +@DecimalMin("54.3") @DecimalMax("987.6") + public Float getFloat() { + return _float; + } + + public void setFloat(Float _float) { + this._float = _float; + } + + public FormatTest _double(Double _double) { + this._double = _double; + return this; + } + + /** + * Get _double + * minimum: 67.8 + * maximum: 123.4 + * @return _double + */ + @Schema(name = "_double", defaultValue = "") + +@DecimalMin("67.8") @DecimalMax("123.4") + public Double getDouble() { + return _double; + } + + public void setDouble(Double _double) { + this._double = _double; + } + + public FormatTest string(String string) { + this.string = string; + return this; + } + + /** + * Get string + * @return string + */ + @Schema(name = "string", defaultValue = "") + +@Pattern(regexp = "/[a-z]/i") + public String getString() { + return string; + } + + public void setString(String string) { + this.string = string; + } + + public FormatTest _byte(byte[] _byte) { + this._byte = _byte; + return this; + } + + /** + * Get _byte + * @return _byte + */ + @Schema(name = "_byte", required = true, defaultValue = "") + @NotNull + + + public byte[] getByte() { + return _byte; + } + + public void setByte(byte[] _byte) { + this._byte = _byte; + } + + public FormatTest binary(org.springframework.core.io.Resource binary) { + this.binary = binary; + return this; + } + + /** + * Get binary + * @return binary + */ + @Schema(name = "binary", defaultValue = "") + + @Valid + + public org.springframework.core.io.Resource getBinary() { + return binary; + } + + public void setBinary(org.springframework.core.io.Resource binary) { + this.binary = binary; + } + + public FormatTest date(LocalDate date) { + this.date = date; + return this; + } + + /** + * Get date + * @return date + */ + @Schema(name = "date", required = true, defaultValue = "") + @NotNull + + @Valid + + public LocalDate getDate() { + return date; + } + + public void setDate(LocalDate date) { + this.date = date; + } + + public FormatTest dateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + return this; + } + + /** + * Get dateTime + * @return dateTime + */ + @Schema(name = "dateTime", defaultValue = "") + + @Valid + + public OffsetDateTime getDateTime() { + return dateTime; + } + + public void setDateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + } + + public FormatTest uuid(UUID uuid) { + this.uuid = uuid; + return this; + } + + /** + * Get uuid + * @return uuid + */ + @Schema(name = "uuid", example = "72f98069-206d-4f12-9f12-3d1e525a8e84", defaultValue = "") + + @Valid + + public UUID getUuid() { + return uuid; + } + + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + public FormatTest password(String password) { + this.password = password; + return this; + } + + /** + * Get password + * @return password + */ + @Schema(name = "password", required = true, defaultValue = "") + @NotNull + +@Size(min = 10, max = 64) + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public FormatTest bigDecimal(BigDecimal bigDecimal) { + this.bigDecimal = bigDecimal; + return this; + } + + /** + * Get bigDecimal + * @return bigDecimal + */ + @Schema(name = "bigDecimal", defaultValue = "") + + @Valid + + public BigDecimal getBigDecimal() { + return bigDecimal; + } + + public void setBigDecimal(BigDecimal bigDecimal) { + this.bigDecimal = bigDecimal; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FormatTest formatTest = (FormatTest) o; + return Objects.equals(this.integer, formatTest.integer) && + Objects.equals(this.int32, formatTest.int32) && + Objects.equals(this.int64, formatTest.int64) && + Objects.equals(this.number, formatTest.number) && + Objects.equals(this._float, formatTest._float) && + Objects.equals(this._double, formatTest._double) && + Objects.equals(this.string, formatTest.string) && + Arrays.equals(this._byte, formatTest._byte) && + Objects.equals(this.binary, formatTest.binary) && + Objects.equals(this.date, formatTest.date) && + Objects.equals(this.dateTime, formatTest.dateTime) && + Objects.equals(this.uuid, formatTest.uuid) && + Objects.equals(this.password, formatTest.password) && + Objects.equals(this.bigDecimal, formatTest.bigDecimal); + } + + @Override + public int hashCode() { + return Objects.hash(integer, int32, int64, number, _float, _double, string, Arrays.hashCode(_byte), binary, date, dateTime, uuid, password, bigDecimal); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FormatTest {\n"); + + sb.append(" integer: ").append(toIndentedString(integer)).append("\n"); + sb.append(" int32: ").append(toIndentedString(int32)).append("\n"); + sb.append(" int64: ").append(toIndentedString(int64)).append("\n"); + sb.append(" number: ").append(toIndentedString(number)).append("\n"); + sb.append(" _float: ").append(toIndentedString(_float)).append("\n"); + sb.append(" _double: ").append(toIndentedString(_double)).append("\n"); + sb.append(" string: ").append(toIndentedString(string)).append("\n"); + sb.append(" _byte: ").append(toIndentedString(_byte)).append("\n"); + sb.append(" binary: ").append(toIndentedString(binary)).append("\n"); + sb.append(" date: ").append(toIndentedString(date)).append("\n"); + sb.append(" dateTime: ").append(toIndentedString(dateTime)).append("\n"); + sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" bigDecimal: ").append(toIndentedString(bigDecimal)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/HasOnlyReadOnly.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/HasOnlyReadOnly.java new file mode 100644 index 000000000000..dfb615a529fc --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/HasOnlyReadOnly.java @@ -0,0 +1,108 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * HasOnlyReadOnly + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class HasOnlyReadOnly { + @JsonProperty("bar") + private String bar; + + @JsonProperty("foo") + private String foo; + + public HasOnlyReadOnly bar(String bar) { + this.bar = bar; + return this; + } + + /** + * Get bar + * @return bar + */ + @Schema(name = "bar", readOnly = true, defaultValue = "") + + + public String getBar() { + return bar; + } + + public void setBar(String bar) { + this.bar = bar; + } + + public HasOnlyReadOnly foo(String foo) { + this.foo = foo; + return this; + } + + /** + * Get foo + * @return foo + */ + @Schema(name = "foo", readOnly = true, defaultValue = "") + + + public String getFoo() { + return foo; + } + + public void setFoo(String foo) { + this.foo = foo; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HasOnlyReadOnly hasOnlyReadOnly = (HasOnlyReadOnly) o; + return Objects.equals(this.bar, hasOnlyReadOnly.bar) && + Objects.equals(this.foo, hasOnlyReadOnly.foo); + } + + @Override + public int hashCode() { + return Objects.hash(bar, foo); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class HasOnlyReadOnly {\n"); + + sb.append(" bar: ").append(toIndentedString(bar)).append("\n"); + sb.append(" foo: ").append(toIndentedString(foo)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/MapTest.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/MapTest.java new file mode 100644 index 000000000000..3ff73062758f --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/MapTest.java @@ -0,0 +1,234 @@ +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 java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * MapTest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class MapTest { + @JsonProperty("map_map_of_string") + @Valid + private Map> mapMapOfString = null; + + /** + * Gets or Sets inner + */ + public enum InnerEnum { + UPPER("UPPER"), + + LOWER("lower"); + + private String value; + + InnerEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static InnerEnum fromValue(String value) { + for (InnerEnum b : InnerEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("map_of_enum_string") + @Valid + private Map mapOfEnumString = null; + + @JsonProperty("direct_map") + @Valid + private Map directMap = null; + + @JsonProperty("indirect_map") + @Valid + private Map indirectMap = null; + + public MapTest mapMapOfString(Map> mapMapOfString) { + this.mapMapOfString = mapMapOfString; + return this; + } + + public MapTest putMapMapOfStringItem(String key, Map mapMapOfStringItem) { + if (this.mapMapOfString == null) { + this.mapMapOfString = new HashMap<>(); + } + this.mapMapOfString.put(key, mapMapOfStringItem); + return this; + } + + /** + * Get mapMapOfString + * @return mapMapOfString + */ + @Schema(name = "mapMapOfString", defaultValue = "") + + @Valid + + public Map> getMapMapOfString() { + return mapMapOfString; + } + + public void setMapMapOfString(Map> mapMapOfString) { + this.mapMapOfString = mapMapOfString; + } + + public MapTest mapOfEnumString(Map mapOfEnumString) { + this.mapOfEnumString = mapOfEnumString; + return this; + } + + public MapTest putMapOfEnumStringItem(String key, InnerEnum mapOfEnumStringItem) { + if (this.mapOfEnumString == null) { + this.mapOfEnumString = new HashMap<>(); + } + this.mapOfEnumString.put(key, mapOfEnumStringItem); + return this; + } + + /** + * Get mapOfEnumString + * @return mapOfEnumString + */ + @Schema(name = "mapOfEnumString", defaultValue = "") + + + public Map getMapOfEnumString() { + return mapOfEnumString; + } + + public void setMapOfEnumString(Map mapOfEnumString) { + this.mapOfEnumString = mapOfEnumString; + } + + public MapTest directMap(Map directMap) { + this.directMap = directMap; + return this; + } + + public MapTest putDirectMapItem(String key, Boolean directMapItem) { + if (this.directMap == null) { + this.directMap = new HashMap<>(); + } + this.directMap.put(key, directMapItem); + return this; + } + + /** + * Get directMap + * @return directMap + */ + @Schema(name = "directMap", defaultValue = "") + + + public Map getDirectMap() { + return directMap; + } + + public void setDirectMap(Map directMap) { + this.directMap = directMap; + } + + public MapTest indirectMap(Map indirectMap) { + this.indirectMap = indirectMap; + return this; + } + + public MapTest putIndirectMapItem(String key, Boolean indirectMapItem) { + if (this.indirectMap == null) { + this.indirectMap = new HashMap<>(); + } + this.indirectMap.put(key, indirectMapItem); + return this; + } + + /** + * Get indirectMap + * @return indirectMap + */ + @Schema(name = "indirectMap", defaultValue = "") + + + public Map getIndirectMap() { + return indirectMap; + } + + public void setIndirectMap(Map indirectMap) { + this.indirectMap = indirectMap; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MapTest mapTest = (MapTest) o; + return Objects.equals(this.mapMapOfString, mapTest.mapMapOfString) && + Objects.equals(this.mapOfEnumString, mapTest.mapOfEnumString) && + Objects.equals(this.directMap, mapTest.directMap) && + Objects.equals(this.indirectMap, mapTest.indirectMap); + } + + @Override + public int hashCode() { + return Objects.hash(mapMapOfString, mapOfEnumString, directMap, indirectMap); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MapTest {\n"); + + sb.append(" mapMapOfString: ").append(toIndentedString(mapMapOfString)).append("\n"); + sb.append(" mapOfEnumString: ").append(toIndentedString(mapOfEnumString)).append("\n"); + sb.append(" directMap: ").append(toIndentedString(directMap)).append("\n"); + sb.append(" indirectMap: ").append(toIndentedString(indirectMap)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java new file mode 100644 index 000000000000..03a7be43cc4a --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java @@ -0,0 +1,152 @@ +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 java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import org.openapitools.model.Animal; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * MixedPropertiesAndAdditionalPropertiesClass + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class MixedPropertiesAndAdditionalPropertiesClass { + @JsonProperty("uuid") + private UUID uuid; + + @JsonProperty("dateTime") + @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) + private OffsetDateTime dateTime; + + @JsonProperty("map") + @Valid + private Map map = null; + + public MixedPropertiesAndAdditionalPropertiesClass uuid(UUID uuid) { + this.uuid = uuid; + return this; + } + + /** + * Get uuid + * @return uuid + */ + @Schema(name = "uuid", defaultValue = "") + + @Valid + + public UUID getUuid() { + return uuid; + } + + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + public MixedPropertiesAndAdditionalPropertiesClass dateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + return this; + } + + /** + * Get dateTime + * @return dateTime + */ + @Schema(name = "dateTime", defaultValue = "") + + @Valid + + public OffsetDateTime getDateTime() { + return dateTime; + } + + public void setDateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + } + + public MixedPropertiesAndAdditionalPropertiesClass map(Map map) { + this.map = map; + return this; + } + + public MixedPropertiesAndAdditionalPropertiesClass putMapItem(String key, Animal mapItem) { + if (this.map == null) { + this.map = new HashMap<>(); + } + this.map.put(key, mapItem); + return this; + } + + /** + * Get map + * @return map + */ + @Schema(name = "map", defaultValue = "") + + @Valid + + public Map getMap() { + return map; + } + + public void setMap(Map map) { + this.map = map; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass = (MixedPropertiesAndAdditionalPropertiesClass) o; + return Objects.equals(this.uuid, mixedPropertiesAndAdditionalPropertiesClass.uuid) && + Objects.equals(this.dateTime, mixedPropertiesAndAdditionalPropertiesClass.dateTime) && + Objects.equals(this.map, mixedPropertiesAndAdditionalPropertiesClass.map); + } + + @Override + public int hashCode() { + return Objects.hash(uuid, dateTime, map); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MixedPropertiesAndAdditionalPropertiesClass {\n"); + + sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); + sb.append(" dateTime: ").append(toIndentedString(dateTime)).append("\n"); + sb.append(" map: ").append(toIndentedString(map)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Model200Response.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Model200Response.java new file mode 100644 index 000000000000..77bf91649b08 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Model200Response.java @@ -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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Model for testing model name starting with number + */ +@Schema(name = "200_response",description = "Model for testing model name starting with number") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Model200Response { + @JsonProperty("name") + private Integer name; + + @JsonProperty("class") + private String propertyClass; + + public Model200Response name(Integer name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + public Integer getName() { + return name; + } + + public void setName(Integer name) { + this.name = name; + } + + public Model200Response propertyClass(String propertyClass) { + this.propertyClass = propertyClass; + return this; + } + + /** + * Get propertyClass + * @return propertyClass + */ + @Schema(name = "propertyClass", defaultValue = "") + + + public String getPropertyClass() { + return propertyClass; + } + + public void setPropertyClass(String propertyClass) { + this.propertyClass = propertyClass; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Model200Response _200response = (Model200Response) o; + return Objects.equals(this.name, _200response.name) && + Objects.equals(this.propertyClass, _200response.propertyClass); + } + + @Override + public int hashCode() { + return Objects.hash(name, propertyClass); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Model200Response {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" propertyClass: ").append(toIndentedString(propertyClass)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ModelApiResponse.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ModelApiResponse.java new file mode 100644 index 000000000000..2443600df226 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ModelApiResponse.java @@ -0,0 +1,133 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ModelApiResponse + */ +@javax.annotation.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 + */ + @Schema(name = "code", defaultValue = "") + + + 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 + */ + @Schema(name = "type", defaultValue = "") + + + 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 + */ + @Schema(name = "message", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ModelReturn.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ModelReturn.java new file mode 100644 index 000000000000..0301a47e9f3e --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ModelReturn.java @@ -0,0 +1,84 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Model for testing reserved words + */ +@Schema(name = "Return",description = "Model for testing reserved words") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ModelReturn { + @JsonProperty("return") + private Integer _return; + + public ModelReturn _return(Integer _return) { + this._return = _return; + return this; + } + + /** + * Get _return + * @return _return + */ + @Schema(name = "_return", defaultValue = "") + + + public Integer getReturn() { + return _return; + } + + public void setReturn(Integer _return) { + this._return = _return; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelReturn _return = (ModelReturn) o; + return Objects.equals(this._return, _return._return); + } + + @Override + public int hashCode() { + return Objects.hash(_return); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelReturn {\n"); + + sb.append(" _return: ").append(toIndentedString(_return)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Name.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Name.java new file mode 100644 index 000000000000..62a16f80ee07 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Name.java @@ -0,0 +1,160 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Model for testing model name same as property name + */ +@Schema(name = "Name",description = "Model for testing model name same as property name") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Name { + @JsonProperty("name") + private Integer name; + + @JsonProperty("snake_case") + private Integer snakeCase; + + @JsonProperty("property") + private String property; + + @JsonProperty("123Number") + private Integer _123number; + + public Name name(Integer name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", required = true, defaultValue = "") + @NotNull + + + public Integer getName() { + return name; + } + + public void setName(Integer name) { + this.name = name; + } + + public Name snakeCase(Integer snakeCase) { + this.snakeCase = snakeCase; + return this; + } + + /** + * Get snakeCase + * @return snakeCase + */ + @Schema(name = "snakeCase", readOnly = true, defaultValue = "") + + + public Integer getSnakeCase() { + return snakeCase; + } + + public void setSnakeCase(Integer snakeCase) { + this.snakeCase = snakeCase; + } + + public Name property(String property) { + this.property = property; + return this; + } + + /** + * Get property + * @return property + */ + @Schema(name = "property", defaultValue = "") + + + public String getProperty() { + return property; + } + + public void setProperty(String property) { + this.property = property; + } + + public Name _123number(Integer _123number) { + this._123number = _123number; + return this; + } + + /** + * Get _123number + * @return _123number + */ + @Schema(name = "_123number", readOnly = true, defaultValue = "") + + + public Integer get123number() { + return _123number; + } + + public void set123number(Integer _123number) { + this._123number = _123number; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Name name = (Name) o; + return Objects.equals(this.name, name.name) && + Objects.equals(this.snakeCase, name.snakeCase) && + Objects.equals(this.property, name.property) && + Objects.equals(this._123number, name._123number); + } + + @Override + public int hashCode() { + return Objects.hash(name, snakeCase, property, _123number); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Name {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n"); + sb.append(" property: ").append(toIndentedString(property)).append("\n"); + sb.append(" _123number: ").append(toIndentedString(_123number)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/NumberOnly.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/NumberOnly.java new file mode 100644 index 000000000000..521fad80d5a7 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/NumberOnly.java @@ -0,0 +1,85 @@ +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 java.math.BigDecimal; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * NumberOnly + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class NumberOnly { + @JsonProperty("JustNumber") + private BigDecimal justNumber; + + public NumberOnly justNumber(BigDecimal justNumber) { + this.justNumber = justNumber; + return this; + } + + /** + * Get justNumber + * @return justNumber + */ + @Schema(name = "justNumber", defaultValue = "") + + @Valid + + public BigDecimal getJustNumber() { + return justNumber; + } + + public void setJustNumber(BigDecimal justNumber) { + this.justNumber = justNumber; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NumberOnly numberOnly = (NumberOnly) o; + return Objects.equals(this.justNumber, numberOnly.justNumber); + } + + @Override + public int hashCode() { + return Objects.hash(justNumber); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NumberOnly {\n"); + + sb.append(" justNumber: ").append(toIndentedString(justNumber)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Order.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Order.java new file mode 100644 index 000000000000..05071bdfe2bf --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Order.java @@ -0,0 +1,249 @@ +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 java.time.OffsetDateTime; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Order + */ +@javax.annotation.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") + @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "petId", defaultValue = "") + + + 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 + */ + @Schema(name = "quantity", defaultValue = "") + + + 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 + */ + @Schema(name = "shipDate", defaultValue = "") + + @Valid + + 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 + */ + @Schema(name = "status", defaultValue = "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 + */ + @Schema(name = "complete", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/OuterComposite.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/OuterComposite.java new file mode 100644 index 000000000000..a721a3dde6a0 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/OuterComposite.java @@ -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 java.math.BigDecimal; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * OuterComposite + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class OuterComposite { + @JsonProperty("my_number") + private BigDecimal myNumber; + + @JsonProperty("my_string") + private String myString; + + @JsonProperty("my_boolean") + private Boolean myBoolean; + + public OuterComposite myNumber(BigDecimal myNumber) { + this.myNumber = myNumber; + return this; + } + + /** + * Get myNumber + * @return myNumber + */ + @Schema(name = "myNumber", defaultValue = "") + + @Valid + + public BigDecimal getMyNumber() { + return myNumber; + } + + public void setMyNumber(BigDecimal myNumber) { + this.myNumber = myNumber; + } + + public OuterComposite myString(String myString) { + this.myString = myString; + return this; + } + + /** + * Get myString + * @return myString + */ + @Schema(name = "myString", defaultValue = "") + + + public String getMyString() { + return myString; + } + + public void setMyString(String myString) { + this.myString = myString; + } + + public OuterComposite myBoolean(Boolean myBoolean) { + this.myBoolean = myBoolean; + return this; + } + + /** + * Get myBoolean + * @return myBoolean + */ + @Schema(name = "myBoolean", defaultValue = "") + + + public Boolean getMyBoolean() { + return myBoolean; + } + + public void setMyBoolean(Boolean myBoolean) { + this.myBoolean = myBoolean; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OuterComposite outerComposite = (OuterComposite) o; + return Objects.equals(this.myNumber, outerComposite.myNumber) && + Objects.equals(this.myString, outerComposite.myString) && + Objects.equals(this.myBoolean, outerComposite.myBoolean); + } + + @Override + public int hashCode() { + return Objects.hash(myNumber, myString, myBoolean); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OuterComposite {\n"); + + sb.append(" myNumber: ").append(toIndentedString(myNumber)).append("\n"); + sb.append(" myString: ").append(toIndentedString(myString)).append("\n"); + sb.append(" myBoolean: ").append(toIndentedString(myBoolean)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/OuterEnum.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/OuterEnum.java new file mode 100644 index 000000000000..ba0cca8a5e81 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/OuterEnum.java @@ -0,0 +1,55 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Gets or Sets OuterEnum + */ +public enum OuterEnum { + + PLACED("placed"), + + APPROVED("approved"), + + DELIVERED("delivered"); + + private String value; + + OuterEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static OuterEnum fromValue(String value) { + for (OuterEnum b : OuterEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Pet.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Pet.java new file mode 100644 index 000000000000..988eb317134d --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Pet.java @@ -0,0 +1,273 @@ +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 com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +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 io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Pet + */ +@javax.annotation.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 Set photoUrls = new LinkedHashSet<>(); + + @JsonProperty("tags") + @Valid + private List 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; + + public Pet id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "category", defaultValue = "") + + @Valid + + 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 + */ + @Schema(name = "name", example = "doggie", required = true, defaultValue = "") + @NotNull + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Pet photoUrls(Set photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + public Pet addPhotoUrlsItem(String photoUrlsItem) { + this.photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get photoUrls + * @return photoUrls + */ + @Schema(name = "photoUrls", required = true, defaultValue = "") + @NotNull + + + public Set getPhotoUrls() { + return photoUrls; + } + + @JsonDeserialize(as = LinkedHashSet.class) + public void setPhotoUrls(Set photoUrls) { + this.photoUrls = photoUrls; + } + + public Pet tags(List 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 + */ + @Schema(name = "tags", defaultValue = "") + + @Valid + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * pet status in the store + * @return status + */ + @Schema(name = "status", defaultValue = "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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ReadOnlyFirst.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ReadOnlyFirst.java new file mode 100644 index 000000000000..1c51770a8e66 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ReadOnlyFirst.java @@ -0,0 +1,108 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ReadOnlyFirst + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ReadOnlyFirst { + @JsonProperty("bar") + private String bar; + + @JsonProperty("baz") + private String baz; + + public ReadOnlyFirst bar(String bar) { + this.bar = bar; + return this; + } + + /** + * Get bar + * @return bar + */ + @Schema(name = "bar", readOnly = true, defaultValue = "") + + + public String getBar() { + return bar; + } + + public void setBar(String bar) { + this.bar = bar; + } + + public ReadOnlyFirst baz(String baz) { + this.baz = baz; + return this; + } + + /** + * Get baz + * @return baz + */ + @Schema(name = "baz", defaultValue = "") + + + public String getBaz() { + return baz; + } + + public void setBaz(String baz) { + this.baz = baz; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReadOnlyFirst readOnlyFirst = (ReadOnlyFirst) o; + return Objects.equals(this.bar, readOnlyFirst.bar) && + Objects.equals(this.baz, readOnlyFirst.baz); + } + + @Override + public int hashCode() { + return Objects.hash(bar, baz); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ReadOnlyFirst {\n"); + + sb.append(" bar: ").append(toIndentedString(bar)).append("\n"); + sb.append(" baz: ").append(toIndentedString(baz)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/SpecialModelName.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/SpecialModelName.java new file mode 100644 index 000000000000..75f4be4e9f8f --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/SpecialModelName.java @@ -0,0 +1,83 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * SpecialModelName + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class SpecialModelName { + @JsonProperty("$special[property.name]") + private Long $specialPropertyName; + + public SpecialModelName $specialPropertyName(Long $specialPropertyName) { + this.$specialPropertyName = $specialPropertyName; + return this; + } + + /** + * Get $specialPropertyName + * @return $specialPropertyName + */ + @Schema(name = "$specialPropertyName", defaultValue = "") + + + public Long get$SpecialPropertyName() { + return $specialPropertyName; + } + + public void set$SpecialPropertyName(Long $specialPropertyName) { + this.$specialPropertyName = $specialPropertyName; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SpecialModelName $specialModelName = (SpecialModelName) o; + return Objects.equals(this.$specialPropertyName, $specialModelName.$specialPropertyName); + } + + @Override + public int hashCode() { + return Objects.hash($specialPropertyName); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SpecialModelName {\n"); + + sb.append(" $specialPropertyName: ").append(toIndentedString($specialPropertyName)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Tag.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Tag.java new file mode 100644 index 000000000000..8722df999bfc --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/Tag.java @@ -0,0 +1,108 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Tag + */ +@javax.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "name", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/TypeHolderDefault.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/TypeHolderDefault.java new file mode 100644 index 000000000000..19e9bf310f76 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/TypeHolderDefault.java @@ -0,0 +1,198 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * TypeHolderDefault + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class TypeHolderDefault { + @JsonProperty("string_item") + private String stringItem = "what"; + + @JsonProperty("number_item") + private BigDecimal numberItem; + + @JsonProperty("integer_item") + private Integer integerItem; + + @JsonProperty("bool_item") + private Boolean boolItem = true; + + @JsonProperty("array_item") + @Valid + private List arrayItem = new ArrayList<>(); + + public TypeHolderDefault stringItem(String stringItem) { + this.stringItem = stringItem; + return this; + } + + /** + * Get stringItem + * @return stringItem + */ + @Schema(name = "stringItem", required = true, defaultValue = "") + @NotNull + + + public String getStringItem() { + return stringItem; + } + + public void setStringItem(String stringItem) { + this.stringItem = stringItem; + } + + public TypeHolderDefault numberItem(BigDecimal numberItem) { + this.numberItem = numberItem; + return this; + } + + /** + * Get numberItem + * @return numberItem + */ + @Schema(name = "numberItem", required = true, defaultValue = "") + @NotNull + + @Valid + + public BigDecimal getNumberItem() { + return numberItem; + } + + public void setNumberItem(BigDecimal numberItem) { + this.numberItem = numberItem; + } + + public TypeHolderDefault integerItem(Integer integerItem) { + this.integerItem = integerItem; + return this; + } + + /** + * Get integerItem + * @return integerItem + */ + @Schema(name = "integerItem", required = true, defaultValue = "") + @NotNull + + + public Integer getIntegerItem() { + return integerItem; + } + + public void setIntegerItem(Integer integerItem) { + this.integerItem = integerItem; + } + + public TypeHolderDefault boolItem(Boolean boolItem) { + this.boolItem = boolItem; + return this; + } + + /** + * Get boolItem + * @return boolItem + */ + @Schema(name = "boolItem", required = true, defaultValue = "") + @NotNull + + + public Boolean getBoolItem() { + return boolItem; + } + + public void setBoolItem(Boolean boolItem) { + this.boolItem = boolItem; + } + + public TypeHolderDefault arrayItem(List arrayItem) { + this.arrayItem = arrayItem; + return this; + } + + public TypeHolderDefault addArrayItemItem(Integer arrayItemItem) { + this.arrayItem.add(arrayItemItem); + return this; + } + + /** + * Get arrayItem + * @return arrayItem + */ + @Schema(name = "arrayItem", required = true, defaultValue = "") + @NotNull + + + public List getArrayItem() { + return arrayItem; + } + + public void setArrayItem(List arrayItem) { + this.arrayItem = arrayItem; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TypeHolderDefault typeHolderDefault = (TypeHolderDefault) o; + return Objects.equals(this.stringItem, typeHolderDefault.stringItem) && + Objects.equals(this.numberItem, typeHolderDefault.numberItem) && + Objects.equals(this.integerItem, typeHolderDefault.integerItem) && + Objects.equals(this.boolItem, typeHolderDefault.boolItem) && + Objects.equals(this.arrayItem, typeHolderDefault.arrayItem); + } + + @Override + public int hashCode() { + return Objects.hash(stringItem, numberItem, integerItem, boolItem, arrayItem); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TypeHolderDefault {\n"); + + sb.append(" stringItem: ").append(toIndentedString(stringItem)).append("\n"); + sb.append(" numberItem: ").append(toIndentedString(numberItem)).append("\n"); + sb.append(" integerItem: ").append(toIndentedString(integerItem)).append("\n"); + sb.append(" boolItem: ").append(toIndentedString(boolItem)).append("\n"); + sb.append(" arrayItem: ").append(toIndentedString(arrayItem)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/TypeHolderExample.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/TypeHolderExample.java new file mode 100644 index 000000000000..c9a3762bc74b --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/TypeHolderExample.java @@ -0,0 +1,224 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * TypeHolderExample + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class TypeHolderExample { + @JsonProperty("string_item") + private String stringItem; + + @JsonProperty("number_item") + private BigDecimal numberItem; + + @JsonProperty("float_item") + private Float floatItem; + + @JsonProperty("integer_item") + private Integer integerItem; + + @JsonProperty("bool_item") + private Boolean boolItem; + + @JsonProperty("array_item") + @Valid + private List arrayItem = new ArrayList<>(); + + public TypeHolderExample stringItem(String stringItem) { + this.stringItem = stringItem; + return this; + } + + /** + * Get stringItem + * @return stringItem + */ + @Schema(name = "stringItem", example = "what", required = true, defaultValue = "") + @NotNull + + + public String getStringItem() { + return stringItem; + } + + public void setStringItem(String stringItem) { + this.stringItem = stringItem; + } + + public TypeHolderExample numberItem(BigDecimal numberItem) { + this.numberItem = numberItem; + return this; + } + + /** + * Get numberItem + * @return numberItem + */ + @Schema(name = "numberItem", example = "1.234", required = true, defaultValue = "") + @NotNull + + @Valid + + public BigDecimal getNumberItem() { + return numberItem; + } + + public void setNumberItem(BigDecimal numberItem) { + this.numberItem = numberItem; + } + + public TypeHolderExample floatItem(Float floatItem) { + this.floatItem = floatItem; + return this; + } + + /** + * Get floatItem + * @return floatItem + */ + @Schema(name = "floatItem", example = "1.234", required = true, defaultValue = "") + @NotNull + + + public Float getFloatItem() { + return floatItem; + } + + public void setFloatItem(Float floatItem) { + this.floatItem = floatItem; + } + + public TypeHolderExample integerItem(Integer integerItem) { + this.integerItem = integerItem; + return this; + } + + /** + * Get integerItem + * @return integerItem + */ + @Schema(name = "integerItem", example = "-2", required = true, defaultValue = "") + @NotNull + + + public Integer getIntegerItem() { + return integerItem; + } + + public void setIntegerItem(Integer integerItem) { + this.integerItem = integerItem; + } + + public TypeHolderExample boolItem(Boolean boolItem) { + this.boolItem = boolItem; + return this; + } + + /** + * Get boolItem + * @return boolItem + */ + @Schema(name = "boolItem", example = "true", required = true, defaultValue = "") + @NotNull + + + public Boolean getBoolItem() { + return boolItem; + } + + public void setBoolItem(Boolean boolItem) { + this.boolItem = boolItem; + } + + public TypeHolderExample arrayItem(List arrayItem) { + this.arrayItem = arrayItem; + return this; + } + + public TypeHolderExample addArrayItemItem(Integer arrayItemItem) { + this.arrayItem.add(arrayItemItem); + return this; + } + + /** + * Get arrayItem + * @return arrayItem + */ + @Schema(name = "arrayItem", example = "[0, 1, 2, 3]", required = true, defaultValue = "") + @NotNull + + + public List getArrayItem() { + return arrayItem; + } + + public void setArrayItem(List arrayItem) { + this.arrayItem = arrayItem; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TypeHolderExample typeHolderExample = (TypeHolderExample) o; + return Objects.equals(this.stringItem, typeHolderExample.stringItem) && + Objects.equals(this.numberItem, typeHolderExample.numberItem) && + Objects.equals(this.floatItem, typeHolderExample.floatItem) && + Objects.equals(this.integerItem, typeHolderExample.integerItem) && + Objects.equals(this.boolItem, typeHolderExample.boolItem) && + Objects.equals(this.arrayItem, typeHolderExample.arrayItem); + } + + @Override + public int hashCode() { + return Objects.hash(stringItem, numberItem, floatItem, integerItem, boolItem, arrayItem); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TypeHolderExample {\n"); + + sb.append(" stringItem: ").append(toIndentedString(stringItem)).append("\n"); + sb.append(" numberItem: ").append(toIndentedString(numberItem)).append("\n"); + sb.append(" floatItem: ").append(toIndentedString(floatItem)).append("\n"); + sb.append(" integerItem: ").append(toIndentedString(integerItem)).append("\n"); + sb.append(" boolItem: ").append(toIndentedString(boolItem)).append("\n"); + sb.append(" arrayItem: ").append(toIndentedString(arrayItem)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/User.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/User.java new file mode 100644 index 000000000000..83152a155535 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/User.java @@ -0,0 +1,258 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * User + */ +@javax.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "username", defaultValue = "") + + + 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 + */ + @Schema(name = "firstName", defaultValue = "") + + + 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 + */ + @Schema(name = "lastName", defaultValue = "") + + + 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 + */ + @Schema(name = "email", defaultValue = "") + + + 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 + */ + @Schema(name = "password", defaultValue = "") + + + 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 + */ + @Schema(name = "phone", defaultValue = "") + + + 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 + */ + @Schema(name = "userStatus", defaultValue = "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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/XmlItem.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/XmlItem.java new file mode 100644 index 000000000000..59a183db0f62 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/XmlItem.java @@ -0,0 +1,872 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * XmlItem + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class XmlItem { + @JsonProperty("attribute_string") + private String attributeString; + + @JsonProperty("attribute_number") + private BigDecimal attributeNumber; + + @JsonProperty("attribute_integer") + private Integer attributeInteger; + + @JsonProperty("attribute_boolean") + private Boolean attributeBoolean; + + @JsonProperty("wrapped_array") + @Valid + private List wrappedArray = null; + + @JsonProperty("name_string") + private String nameString; + + @JsonProperty("name_number") + private BigDecimal nameNumber; + + @JsonProperty("name_integer") + private Integer nameInteger; + + @JsonProperty("name_boolean") + private Boolean nameBoolean; + + @JsonProperty("name_array") + @Valid + private List nameArray = null; + + @JsonProperty("name_wrapped_array") + @Valid + private List nameWrappedArray = null; + + @JsonProperty("prefix_string") + private String prefixString; + + @JsonProperty("prefix_number") + private BigDecimal prefixNumber; + + @JsonProperty("prefix_integer") + private Integer prefixInteger; + + @JsonProperty("prefix_boolean") + private Boolean prefixBoolean; + + @JsonProperty("prefix_array") + @Valid + private List prefixArray = null; + + @JsonProperty("prefix_wrapped_array") + @Valid + private List prefixWrappedArray = null; + + @JsonProperty("namespace_string") + private String namespaceString; + + @JsonProperty("namespace_number") + private BigDecimal namespaceNumber; + + @JsonProperty("namespace_integer") + private Integer namespaceInteger; + + @JsonProperty("namespace_boolean") + private Boolean namespaceBoolean; + + @JsonProperty("namespace_array") + @Valid + private List namespaceArray = null; + + @JsonProperty("namespace_wrapped_array") + @Valid + private List namespaceWrappedArray = null; + + @JsonProperty("prefix_ns_string") + private String prefixNsString; + + @JsonProperty("prefix_ns_number") + private BigDecimal prefixNsNumber; + + @JsonProperty("prefix_ns_integer") + private Integer prefixNsInteger; + + @JsonProperty("prefix_ns_boolean") + private Boolean prefixNsBoolean; + + @JsonProperty("prefix_ns_array") + @Valid + private List prefixNsArray = null; + + @JsonProperty("prefix_ns_wrapped_array") + @Valid + private List prefixNsWrappedArray = null; + + public XmlItem attributeString(String attributeString) { + this.attributeString = attributeString; + return this; + } + + /** + * Get attributeString + * @return attributeString + */ + @Schema(name = "attributeString", example = "string", defaultValue = "") + + + public String getAttributeString() { + return attributeString; + } + + public void setAttributeString(String attributeString) { + this.attributeString = attributeString; + } + + public XmlItem attributeNumber(BigDecimal attributeNumber) { + this.attributeNumber = attributeNumber; + return this; + } + + /** + * Get attributeNumber + * @return attributeNumber + */ + @Schema(name = "attributeNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getAttributeNumber() { + return attributeNumber; + } + + public void setAttributeNumber(BigDecimal attributeNumber) { + this.attributeNumber = attributeNumber; + } + + public XmlItem attributeInteger(Integer attributeInteger) { + this.attributeInteger = attributeInteger; + return this; + } + + /** + * Get attributeInteger + * @return attributeInteger + */ + @Schema(name = "attributeInteger", example = "-2", defaultValue = "") + + + public Integer getAttributeInteger() { + return attributeInteger; + } + + public void setAttributeInteger(Integer attributeInteger) { + this.attributeInteger = attributeInteger; + } + + public XmlItem attributeBoolean(Boolean attributeBoolean) { + this.attributeBoolean = attributeBoolean; + return this; + } + + /** + * Get attributeBoolean + * @return attributeBoolean + */ + @Schema(name = "attributeBoolean", example = "true", defaultValue = "") + + + public Boolean getAttributeBoolean() { + return attributeBoolean; + } + + public void setAttributeBoolean(Boolean attributeBoolean) { + this.attributeBoolean = attributeBoolean; + } + + public XmlItem wrappedArray(List wrappedArray) { + this.wrappedArray = wrappedArray; + return this; + } + + public XmlItem addWrappedArrayItem(Integer wrappedArrayItem) { + if (this.wrappedArray == null) { + this.wrappedArray = new ArrayList<>(); + } + this.wrappedArray.add(wrappedArrayItem); + return this; + } + + /** + * Get wrappedArray + * @return wrappedArray + */ + @Schema(name = "wrappedArray", defaultValue = "") + + + public List getWrappedArray() { + return wrappedArray; + } + + public void setWrappedArray(List wrappedArray) { + this.wrappedArray = wrappedArray; + } + + public XmlItem nameString(String nameString) { + this.nameString = nameString; + return this; + } + + /** + * Get nameString + * @return nameString + */ + @Schema(name = "nameString", example = "string", defaultValue = "") + + + public String getNameString() { + return nameString; + } + + public void setNameString(String nameString) { + this.nameString = nameString; + } + + public XmlItem nameNumber(BigDecimal nameNumber) { + this.nameNumber = nameNumber; + return this; + } + + /** + * Get nameNumber + * @return nameNumber + */ + @Schema(name = "nameNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getNameNumber() { + return nameNumber; + } + + public void setNameNumber(BigDecimal nameNumber) { + this.nameNumber = nameNumber; + } + + public XmlItem nameInteger(Integer nameInteger) { + this.nameInteger = nameInteger; + return this; + } + + /** + * Get nameInteger + * @return nameInteger + */ + @Schema(name = "nameInteger", example = "-2", defaultValue = "") + + + public Integer getNameInteger() { + return nameInteger; + } + + public void setNameInteger(Integer nameInteger) { + this.nameInteger = nameInteger; + } + + public XmlItem nameBoolean(Boolean nameBoolean) { + this.nameBoolean = nameBoolean; + return this; + } + + /** + * Get nameBoolean + * @return nameBoolean + */ + @Schema(name = "nameBoolean", example = "true", defaultValue = "") + + + public Boolean getNameBoolean() { + return nameBoolean; + } + + public void setNameBoolean(Boolean nameBoolean) { + this.nameBoolean = nameBoolean; + } + + public XmlItem nameArray(List nameArray) { + this.nameArray = nameArray; + return this; + } + + public XmlItem addNameArrayItem(Integer nameArrayItem) { + if (this.nameArray == null) { + this.nameArray = new ArrayList<>(); + } + this.nameArray.add(nameArrayItem); + return this; + } + + /** + * Get nameArray + * @return nameArray + */ + @Schema(name = "nameArray", defaultValue = "") + + + public List getNameArray() { + return nameArray; + } + + public void setNameArray(List nameArray) { + this.nameArray = nameArray; + } + + public XmlItem nameWrappedArray(List nameWrappedArray) { + this.nameWrappedArray = nameWrappedArray; + return this; + } + + public XmlItem addNameWrappedArrayItem(Integer nameWrappedArrayItem) { + if (this.nameWrappedArray == null) { + this.nameWrappedArray = new ArrayList<>(); + } + this.nameWrappedArray.add(nameWrappedArrayItem); + return this; + } + + /** + * Get nameWrappedArray + * @return nameWrappedArray + */ + @Schema(name = "nameWrappedArray", defaultValue = "") + + + public List getNameWrappedArray() { + return nameWrappedArray; + } + + public void setNameWrappedArray(List nameWrappedArray) { + this.nameWrappedArray = nameWrappedArray; + } + + public XmlItem prefixString(String prefixString) { + this.prefixString = prefixString; + return this; + } + + /** + * Get prefixString + * @return prefixString + */ + @Schema(name = "prefixString", example = "string", defaultValue = "") + + + public String getPrefixString() { + return prefixString; + } + + public void setPrefixString(String prefixString) { + this.prefixString = prefixString; + } + + public XmlItem prefixNumber(BigDecimal prefixNumber) { + this.prefixNumber = prefixNumber; + return this; + } + + /** + * Get prefixNumber + * @return prefixNumber + */ + @Schema(name = "prefixNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getPrefixNumber() { + return prefixNumber; + } + + public void setPrefixNumber(BigDecimal prefixNumber) { + this.prefixNumber = prefixNumber; + } + + public XmlItem prefixInteger(Integer prefixInteger) { + this.prefixInteger = prefixInteger; + return this; + } + + /** + * Get prefixInteger + * @return prefixInteger + */ + @Schema(name = "prefixInteger", example = "-2", defaultValue = "") + + + public Integer getPrefixInteger() { + return prefixInteger; + } + + public void setPrefixInteger(Integer prefixInteger) { + this.prefixInteger = prefixInteger; + } + + public XmlItem prefixBoolean(Boolean prefixBoolean) { + this.prefixBoolean = prefixBoolean; + return this; + } + + /** + * Get prefixBoolean + * @return prefixBoolean + */ + @Schema(name = "prefixBoolean", example = "true", defaultValue = "") + + + public Boolean getPrefixBoolean() { + return prefixBoolean; + } + + public void setPrefixBoolean(Boolean prefixBoolean) { + this.prefixBoolean = prefixBoolean; + } + + public XmlItem prefixArray(List prefixArray) { + this.prefixArray = prefixArray; + return this; + } + + public XmlItem addPrefixArrayItem(Integer prefixArrayItem) { + if (this.prefixArray == null) { + this.prefixArray = new ArrayList<>(); + } + this.prefixArray.add(prefixArrayItem); + return this; + } + + /** + * Get prefixArray + * @return prefixArray + */ + @Schema(name = "prefixArray", defaultValue = "") + + + public List getPrefixArray() { + return prefixArray; + } + + public void setPrefixArray(List prefixArray) { + this.prefixArray = prefixArray; + } + + public XmlItem prefixWrappedArray(List prefixWrappedArray) { + this.prefixWrappedArray = prefixWrappedArray; + return this; + } + + public XmlItem addPrefixWrappedArrayItem(Integer prefixWrappedArrayItem) { + if (this.prefixWrappedArray == null) { + this.prefixWrappedArray = new ArrayList<>(); + } + this.prefixWrappedArray.add(prefixWrappedArrayItem); + return this; + } + + /** + * Get prefixWrappedArray + * @return prefixWrappedArray + */ + @Schema(name = "prefixWrappedArray", defaultValue = "") + + + public List getPrefixWrappedArray() { + return prefixWrappedArray; + } + + public void setPrefixWrappedArray(List prefixWrappedArray) { + this.prefixWrappedArray = prefixWrappedArray; + } + + public XmlItem namespaceString(String namespaceString) { + this.namespaceString = namespaceString; + return this; + } + + /** + * Get namespaceString + * @return namespaceString + */ + @Schema(name = "namespaceString", example = "string", defaultValue = "") + + + public String getNamespaceString() { + return namespaceString; + } + + public void setNamespaceString(String namespaceString) { + this.namespaceString = namespaceString; + } + + public XmlItem namespaceNumber(BigDecimal namespaceNumber) { + this.namespaceNumber = namespaceNumber; + return this; + } + + /** + * Get namespaceNumber + * @return namespaceNumber + */ + @Schema(name = "namespaceNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getNamespaceNumber() { + return namespaceNumber; + } + + public void setNamespaceNumber(BigDecimal namespaceNumber) { + this.namespaceNumber = namespaceNumber; + } + + public XmlItem namespaceInteger(Integer namespaceInteger) { + this.namespaceInteger = namespaceInteger; + return this; + } + + /** + * Get namespaceInteger + * @return namespaceInteger + */ + @Schema(name = "namespaceInteger", example = "-2", defaultValue = "") + + + public Integer getNamespaceInteger() { + return namespaceInteger; + } + + public void setNamespaceInteger(Integer namespaceInteger) { + this.namespaceInteger = namespaceInteger; + } + + public XmlItem namespaceBoolean(Boolean namespaceBoolean) { + this.namespaceBoolean = namespaceBoolean; + return this; + } + + /** + * Get namespaceBoolean + * @return namespaceBoolean + */ + @Schema(name = "namespaceBoolean", example = "true", defaultValue = "") + + + public Boolean getNamespaceBoolean() { + return namespaceBoolean; + } + + public void setNamespaceBoolean(Boolean namespaceBoolean) { + this.namespaceBoolean = namespaceBoolean; + } + + public XmlItem namespaceArray(List namespaceArray) { + this.namespaceArray = namespaceArray; + return this; + } + + public XmlItem addNamespaceArrayItem(Integer namespaceArrayItem) { + if (this.namespaceArray == null) { + this.namespaceArray = new ArrayList<>(); + } + this.namespaceArray.add(namespaceArrayItem); + return this; + } + + /** + * Get namespaceArray + * @return namespaceArray + */ + @Schema(name = "namespaceArray", defaultValue = "") + + + public List getNamespaceArray() { + return namespaceArray; + } + + public void setNamespaceArray(List namespaceArray) { + this.namespaceArray = namespaceArray; + } + + public XmlItem namespaceWrappedArray(List namespaceWrappedArray) { + this.namespaceWrappedArray = namespaceWrappedArray; + return this; + } + + public XmlItem addNamespaceWrappedArrayItem(Integer namespaceWrappedArrayItem) { + if (this.namespaceWrappedArray == null) { + this.namespaceWrappedArray = new ArrayList<>(); + } + this.namespaceWrappedArray.add(namespaceWrappedArrayItem); + return this; + } + + /** + * Get namespaceWrappedArray + * @return namespaceWrappedArray + */ + @Schema(name = "namespaceWrappedArray", defaultValue = "") + + + public List getNamespaceWrappedArray() { + return namespaceWrappedArray; + } + + public void setNamespaceWrappedArray(List namespaceWrappedArray) { + this.namespaceWrappedArray = namespaceWrappedArray; + } + + public XmlItem prefixNsString(String prefixNsString) { + this.prefixNsString = prefixNsString; + return this; + } + + /** + * Get prefixNsString + * @return prefixNsString + */ + @Schema(name = "prefixNsString", example = "string", defaultValue = "") + + + public String getPrefixNsString() { + return prefixNsString; + } + + public void setPrefixNsString(String prefixNsString) { + this.prefixNsString = prefixNsString; + } + + public XmlItem prefixNsNumber(BigDecimal prefixNsNumber) { + this.prefixNsNumber = prefixNsNumber; + return this; + } + + /** + * Get prefixNsNumber + * @return prefixNsNumber + */ + @Schema(name = "prefixNsNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getPrefixNsNumber() { + return prefixNsNumber; + } + + public void setPrefixNsNumber(BigDecimal prefixNsNumber) { + this.prefixNsNumber = prefixNsNumber; + } + + public XmlItem prefixNsInteger(Integer prefixNsInteger) { + this.prefixNsInteger = prefixNsInteger; + return this; + } + + /** + * Get prefixNsInteger + * @return prefixNsInteger + */ + @Schema(name = "prefixNsInteger", example = "-2", defaultValue = "") + + + public Integer getPrefixNsInteger() { + return prefixNsInteger; + } + + public void setPrefixNsInteger(Integer prefixNsInteger) { + this.prefixNsInteger = prefixNsInteger; + } + + public XmlItem prefixNsBoolean(Boolean prefixNsBoolean) { + this.prefixNsBoolean = prefixNsBoolean; + return this; + } + + /** + * Get prefixNsBoolean + * @return prefixNsBoolean + */ + @Schema(name = "prefixNsBoolean", example = "true", defaultValue = "") + + + public Boolean getPrefixNsBoolean() { + return prefixNsBoolean; + } + + public void setPrefixNsBoolean(Boolean prefixNsBoolean) { + this.prefixNsBoolean = prefixNsBoolean; + } + + public XmlItem prefixNsArray(List prefixNsArray) { + this.prefixNsArray = prefixNsArray; + return this; + } + + public XmlItem addPrefixNsArrayItem(Integer prefixNsArrayItem) { + if (this.prefixNsArray == null) { + this.prefixNsArray = new ArrayList<>(); + } + this.prefixNsArray.add(prefixNsArrayItem); + return this; + } + + /** + * Get prefixNsArray + * @return prefixNsArray + */ + @Schema(name = "prefixNsArray", defaultValue = "") + + + public List getPrefixNsArray() { + return prefixNsArray; + } + + public void setPrefixNsArray(List prefixNsArray) { + this.prefixNsArray = prefixNsArray; + } + + public XmlItem prefixNsWrappedArray(List prefixNsWrappedArray) { + this.prefixNsWrappedArray = prefixNsWrappedArray; + return this; + } + + public XmlItem addPrefixNsWrappedArrayItem(Integer prefixNsWrappedArrayItem) { + if (this.prefixNsWrappedArray == null) { + this.prefixNsWrappedArray = new ArrayList<>(); + } + this.prefixNsWrappedArray.add(prefixNsWrappedArrayItem); + return this; + } + + /** + * Get prefixNsWrappedArray + * @return prefixNsWrappedArray + */ + @Schema(name = "prefixNsWrappedArray", defaultValue = "") + + + public List getPrefixNsWrappedArray() { + return prefixNsWrappedArray; + } + + public void setPrefixNsWrappedArray(List prefixNsWrappedArray) { + this.prefixNsWrappedArray = prefixNsWrappedArray; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + XmlItem xmlItem = (XmlItem) o; + return Objects.equals(this.attributeString, xmlItem.attributeString) && + Objects.equals(this.attributeNumber, xmlItem.attributeNumber) && + Objects.equals(this.attributeInteger, xmlItem.attributeInteger) && + Objects.equals(this.attributeBoolean, xmlItem.attributeBoolean) && + Objects.equals(this.wrappedArray, xmlItem.wrappedArray) && + Objects.equals(this.nameString, xmlItem.nameString) && + Objects.equals(this.nameNumber, xmlItem.nameNumber) && + Objects.equals(this.nameInteger, xmlItem.nameInteger) && + Objects.equals(this.nameBoolean, xmlItem.nameBoolean) && + Objects.equals(this.nameArray, xmlItem.nameArray) && + Objects.equals(this.nameWrappedArray, xmlItem.nameWrappedArray) && + Objects.equals(this.prefixString, xmlItem.prefixString) && + Objects.equals(this.prefixNumber, xmlItem.prefixNumber) && + Objects.equals(this.prefixInteger, xmlItem.prefixInteger) && + Objects.equals(this.prefixBoolean, xmlItem.prefixBoolean) && + Objects.equals(this.prefixArray, xmlItem.prefixArray) && + Objects.equals(this.prefixWrappedArray, xmlItem.prefixWrappedArray) && + Objects.equals(this.namespaceString, xmlItem.namespaceString) && + Objects.equals(this.namespaceNumber, xmlItem.namespaceNumber) && + Objects.equals(this.namespaceInteger, xmlItem.namespaceInteger) && + Objects.equals(this.namespaceBoolean, xmlItem.namespaceBoolean) && + Objects.equals(this.namespaceArray, xmlItem.namespaceArray) && + Objects.equals(this.namespaceWrappedArray, xmlItem.namespaceWrappedArray) && + Objects.equals(this.prefixNsString, xmlItem.prefixNsString) && + Objects.equals(this.prefixNsNumber, xmlItem.prefixNsNumber) && + Objects.equals(this.prefixNsInteger, xmlItem.prefixNsInteger) && + Objects.equals(this.prefixNsBoolean, xmlItem.prefixNsBoolean) && + Objects.equals(this.prefixNsArray, xmlItem.prefixNsArray) && + Objects.equals(this.prefixNsWrappedArray, xmlItem.prefixNsWrappedArray); + } + + @Override + public int hashCode() { + return Objects.hash(attributeString, attributeNumber, attributeInteger, attributeBoolean, wrappedArray, nameString, nameNumber, nameInteger, nameBoolean, nameArray, nameWrappedArray, prefixString, prefixNumber, prefixInteger, prefixBoolean, prefixArray, prefixWrappedArray, namespaceString, namespaceNumber, namespaceInteger, namespaceBoolean, namespaceArray, namespaceWrappedArray, prefixNsString, prefixNsNumber, prefixNsInteger, prefixNsBoolean, prefixNsArray, prefixNsWrappedArray); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class XmlItem {\n"); + + sb.append(" attributeString: ").append(toIndentedString(attributeString)).append("\n"); + sb.append(" attributeNumber: ").append(toIndentedString(attributeNumber)).append("\n"); + sb.append(" attributeInteger: ").append(toIndentedString(attributeInteger)).append("\n"); + sb.append(" attributeBoolean: ").append(toIndentedString(attributeBoolean)).append("\n"); + sb.append(" wrappedArray: ").append(toIndentedString(wrappedArray)).append("\n"); + sb.append(" nameString: ").append(toIndentedString(nameString)).append("\n"); + sb.append(" nameNumber: ").append(toIndentedString(nameNumber)).append("\n"); + sb.append(" nameInteger: ").append(toIndentedString(nameInteger)).append("\n"); + sb.append(" nameBoolean: ").append(toIndentedString(nameBoolean)).append("\n"); + sb.append(" nameArray: ").append(toIndentedString(nameArray)).append("\n"); + sb.append(" nameWrappedArray: ").append(toIndentedString(nameWrappedArray)).append("\n"); + sb.append(" prefixString: ").append(toIndentedString(prefixString)).append("\n"); + sb.append(" prefixNumber: ").append(toIndentedString(prefixNumber)).append("\n"); + sb.append(" prefixInteger: ").append(toIndentedString(prefixInteger)).append("\n"); + sb.append(" prefixBoolean: ").append(toIndentedString(prefixBoolean)).append("\n"); + sb.append(" prefixArray: ").append(toIndentedString(prefixArray)).append("\n"); + sb.append(" prefixWrappedArray: ").append(toIndentedString(prefixWrappedArray)).append("\n"); + sb.append(" namespaceString: ").append(toIndentedString(namespaceString)).append("\n"); + sb.append(" namespaceNumber: ").append(toIndentedString(namespaceNumber)).append("\n"); + sb.append(" namespaceInteger: ").append(toIndentedString(namespaceInteger)).append("\n"); + sb.append(" namespaceBoolean: ").append(toIndentedString(namespaceBoolean)).append("\n"); + sb.append(" namespaceArray: ").append(toIndentedString(namespaceArray)).append("\n"); + sb.append(" namespaceWrappedArray: ").append(toIndentedString(namespaceWrappedArray)).append("\n"); + sb.append(" prefixNsString: ").append(toIndentedString(prefixNsString)).append("\n"); + sb.append(" prefixNsNumber: ").append(toIndentedString(prefixNsNumber)).append("\n"); + sb.append(" prefixNsInteger: ").append(toIndentedString(prefixNsInteger)).append("\n"); + sb.append(" prefixNsBoolean: ").append(toIndentedString(prefixNsBoolean)).append("\n"); + sb.append(" prefixNsArray: ").append(toIndentedString(prefixNsArray)).append("\n"); + sb.append(" prefixNsWrappedArray: ").append(toIndentedString(prefixNsWrappedArray)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-spring-pageable/.openapi-generator-ignore b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/.openapi-generator-ignore @@ -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 diff --git a/samples/openapi3/client/petstore/spring-cloud-spring-pageable/.openapi-generator/FILES b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/.openapi-generator/FILES new file mode 100644 index 000000000000..3510d2b2d276 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/.openapi-generator/FILES @@ -0,0 +1,16 @@ +README.md +pom.xml +src/main/java/org/openapitools/api/PetApi.java +src/main/java/org/openapitools/api/PetApiClient.java +src/main/java/org/openapitools/api/StoreApi.java +src/main/java/org/openapitools/api/StoreApiClient.java +src/main/java/org/openapitools/api/UserApi.java +src/main/java/org/openapitools/api/UserApiClient.java +src/main/java/org/openapitools/configuration/ApiKeyRequestInterceptor.java +src/main/java/org/openapitools/configuration/ClientConfiguration.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 diff --git a/samples/openapi3/client/petstore/spring-cloud-spring-pageable/.openapi-generator/VERSION b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/.openapi-generator/VERSION new file mode 100644 index 000000000000..0984c4c1ad21 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/.openapi-generator/VERSION @@ -0,0 +1 @@ +5.4.0-SNAPSHOT \ No newline at end of file diff --git a/samples/openapi3/client/petstore/spring-cloud-spring-pageable/README.md b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/README.md new file mode 100644 index 000000000000..5a67356a900b --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/README.md @@ -0,0 +1,53 @@ +# spring-cloud-spring-pageable + +## Requirements + +Building the API client library requires [Maven](https://maven.apache.org/) to be installed. + +## Installation + +To install the API client library to your local Maven repository, simply execute: + +```shell +mvn install +``` + +To deploy it to a remote Maven repository instead, configure the settings of the repository and execute: + +```shell +mvn deploy +``` + +Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information. + +### Maven users + +Add this dependency to your project's POM: + +```xml + + org.openapitools.openapi3 + spring-cloud-spring-pageable + 1.0.0 + compile + +``` + +### Gradle users + +Add this dependency to your project's build file: + +```groovy +compile "org.openapitools.openapi3:spring-cloud-spring-pageable:1.0.0" +``` + +### Others + +At first generate the JAR by executing: + +mvn package + +Then manually install the following JARs: + +* target/spring-cloud-spring-pageable-1.0.0.jar +* target/lib/*.jar diff --git a/samples/openapi3/client/petstore/spring-cloud-spring-pageable/pom.xml b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/pom.xml new file mode 100644 index 000000000000..648e8d7f9950 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/pom.xml @@ -0,0 +1,79 @@ + + 4.0.0 + org.openapitools.openapi3 + spring-cloud-spring-pageable + jar + spring-cloud-spring-pageable + 1.0.0 + + 1.8 + ${java.version} + ${java.version} + 2.1.11 + + + org.springframework.boot + spring-boot-starter-parent + 2.6.2 + + + src/main/java + + + + + + org.springframework.cloud + spring-cloud-starter-parent + 2021.0.0 + pom + import + + + + + + + io.swagger.core.v3 + swagger-annotations + ${swagger-core-version} + + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + org.springframework.cloud + spring-cloud-starter-oauth2 + 2.2.5.RELEASE + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + + + org.openapitools + jackson-databind-nullable + 0.2.2 + + + org.springframework.boot + spring-boot-starter-validation + + + org.springframework.data + spring-data-commons + + + org.springframework.boot + spring-boot-starter-test + test + + + diff --git a/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/PetApi.java b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/PetApi.java new file mode 100644 index 000000000000..9eb95c97b891 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/PetApi.java @@ -0,0 +1,271 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "Pet", description = "the Pet API") +public interface PetApi { + + /** + * POST /pet : Add a new pet to the store + * + * @param body Pet object that needs to be added to the store (required) + * @return Invalid input (status code 405) + */ + @Operation( + summary = "Add a new pet to the store", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "405", description = "Invalid input") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet", + consumes = "application/json" + ) + ResponseEntity addPet( + @Parameter(name = "body", description = "Pet object that needs to be added to the store", required = true, schema = @Schema(description = "")) @Valid @RequestBody Pet body + ); + + + /** + * DELETE /pet/{petId} : Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @return Invalid pet value (status code 400) + */ + @Operation( + summary = "Deletes a pet", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid pet value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/pet/{petId}" + ) + ResponseEntity deletePet( + @Parameter(name = "petId", description = "Pet id to delete", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "api_key", description = "", schema = @Schema(description = "")) @RequestHeader(value = "api_key", required = false) String 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) + */ + @Operation( + summary = "Finds Pets by status", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid status value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/findByStatus", + produces = "application/json" + ) + ResponseEntity> findPetsByStatus( + @NotNull @Parameter(name = "status", description = "Status values that need to be considered for filter", required = true, schema = @Schema(description = "", allowableValues = { "available", "pending", "sold" })) @Valid @RequestParam(value = "status", required = true) List status, + final org.springframework.data.domain.Pageable pageable + ); + + + /** + * 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 + */ + @Operation( + summary = "Finds Pets by tags", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid tag value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/findByTags", + produces = "application/json" + ) + ResponseEntity> findPetsByTags( + @NotNull @Parameter(name = "tags", description = "Tags to filter by", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "tags", required = true) List tags, + final org.springframework.data.domain.Pageable pageable + ); + + + /** + * 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) + */ + @Operation( + summary = "Find pet by ID", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/{petId}", + produces = "application/json" + ) + ResponseEntity getPetById( + @Parameter(name = "petId", description = "ID of pet to return", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId + ); + + + /** + * PUT /pet : Update an existing pet + * + * @param body Pet object that needs to be added to the store (required) + * @return Invalid ID supplied (status code 400) + * or Pet not found (status code 404) + * or Validation exception (status code 405) + */ + @Operation( + summary = "Update an existing pet", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found"), + @ApiResponse(responseCode = "405", description = "Validation exception") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/pet", + consumes = "application/json" + ) + ResponseEntity updatePet( + @Parameter(name = "body", description = "Pet object that needs to be added to the store", required = true, schema = @Schema(description = "")) @Valid @RequestBody Pet body + ); + + + /** + * 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) + */ + @Operation( + summary = "Updates a pet in the store with form data", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "405", description = "Invalid input") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet/{petId}", + consumes = "application/x-www-form-urlencoded" + ) + ResponseEntity updatePetWithForm( + @Parameter(name = "petId", description = "ID of pet that needs to be updated", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "name", description = "Updated name of the pet", schema = @Schema(description = "")) @RequestParam(value="name", required=false) String name, + @Parameter(name = "status", description = "Updated status of the pet", schema = @Schema(description = "")) @RequestParam(value="status", required=false) String 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) + */ + @Operation( + summary = "uploads an image", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ModelApiResponse.class))) + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet/{petId}/uploadImage", + produces = "application/json", + consumes = "multipart/form-data" + ) + ResponseEntity uploadFile( + @Parameter(name = "petId", description = "ID of pet to update", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "additionalMetadata", description = "Additional data to pass to server", schema = @Schema(description = "")) @RequestParam(value="additionalMetadata", required=false) String additionalMetadata, + @Parameter(name = "file", description = "file to upload", schema = @Schema(description = "")) @RequestParam("file") MultipartFile file + ); + +} diff --git a/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/PetApiClient.java b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/PetApiClient.java new file mode 100644 index 000000000000..f80fe4ddc678 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/PetApiClient.java @@ -0,0 +1,8 @@ +package org.openapitools.api; + +import org.springframework.cloud.openfeign.FeignClient; +import org.openapitools.configuration.ClientConfiguration; + +@FeignClient(name="${pet.name:pet}", url="${pet.url:http://petstore.swagger.io/v2}", configuration = ClientConfiguration.class) +public interface PetApiClient extends PetApi { +} diff --git a/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/StoreApi.java b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/StoreApi.java new file mode 100644 index 000000000000..a11117a8c9fa --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/StoreApi.java @@ -0,0 +1,139 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "Store", description = "the Store API") +public interface StoreApi { + + /** + * 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) + */ + @Operation( + summary = "Delete purchase order by ID", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/store/order/{orderId}" + ) + ResponseEntity deleteOrder( + @Parameter(name = "orderId", description = "ID of the order that needs to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("orderId") String orderId + ); + + + /** + * GET /store/inventory : Returns pet inventories by status + * Returns a map of status codes to quantities + * + * @return successful operation (status code 200) + */ + @Operation( + summary = "Returns pet inventories by status", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Map.class))) + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/store/inventory", + produces = "application/json" + ) + ResponseEntity> getInventory( + + ); + + + /** + * GET /store/order/{orderId} : Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated 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) + */ + @Operation( + summary = "Find purchase order by ID", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/store/order/{orderId}", + produces = "application/json" + ) + ResponseEntity getOrderById( + @Min(1L) @Max(5L) @Parameter(name = "orderId", description = "ID of pet that needs to be fetched", required = true, schema = @Schema(description = "")) @PathVariable("orderId") Long orderId + ); + + + /** + * POST /store/order : Place an order for a pet + * + * @param body order placed for purchasing the pet (required) + * @return successful operation (status code 200) + * or Invalid Order (status code 400) + */ + @Operation( + summary = "Place an order for a pet", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid Order") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/store/order", + produces = "application/json" + ) + ResponseEntity placeOrder( + @Parameter(name = "body", description = "order placed for purchasing the pet", required = true, schema = @Schema(description = "")) @Valid @RequestBody Order body + ); + +} diff --git a/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/StoreApiClient.java b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/StoreApiClient.java new file mode 100644 index 000000000000..71d613a871dd --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/StoreApiClient.java @@ -0,0 +1,8 @@ +package org.openapitools.api; + +import org.springframework.cloud.openfeign.FeignClient; +import org.openapitools.configuration.ClientConfiguration; + +@FeignClient(name="${store.name:store}", url="${store.url:http://petstore.swagger.io/v2}", configuration = ClientConfiguration.class) +public interface StoreApiClient extends StoreApi { +} diff --git a/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/UserApi.java b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/UserApi.java new file mode 100644 index 000000000000..f583fb099e73 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/UserApi.java @@ -0,0 +1,251 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "User", description = "the User API") +public interface UserApi { + + /** + * POST /user : Create user + * This can only be done by the logged in user. + * + * @param body Created user object (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "Create user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user" + ) + ResponseEntity createUser( + @Parameter(name = "body", description = "Created user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody User body + ); + + + /** + * POST /user/createWithArray : Creates list of users with given input array + * + * @param body List of user object (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "Creates list of users with given input array", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user/createWithArray" + ) + ResponseEntity createUsersWithArrayInput( + @Parameter(name = "body", description = "List of user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody List body + ); + + + /** + * POST /user/createWithList : Creates list of users with given input array + * + * @param body List of user object (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "Creates list of users with given input array", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user/createWithList" + ) + ResponseEntity createUsersWithListInput( + @Parameter(name = "body", description = "List of user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody List body + ); + + + /** + * 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) + */ + @Operation( + summary = "Delete user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/user/{username}" + ) + ResponseEntity deleteUser( + @Parameter(name = "username", description = "The name that needs to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("username") String 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) + */ + @Operation( + summary = "Get user by user name", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = User.class))), + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/{username}", + produces = "application/json" + ) + ResponseEntity getUserByName( + @Parameter(name = "username", description = "The name that needs to be fetched. Use user1 for testing.", required = true, schema = @Schema(description = "")) @PathVariable("username") String 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) + */ + @Operation( + summary = "Logs user into the system", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "400", description = "Invalid username/password supplied") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/login", + produces = "application/json" + ) + ResponseEntity loginUser( + @NotNull @Parameter(name = "username", description = "The user name for login", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "username", required = true) String username, + @NotNull @Parameter(name = "password", description = "The password for login in clear text", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "password", required = true) String password + ); + + + /** + * GET /user/logout : Logs out current logged in user session + * + * @return successful operation (status code 200) + */ + @Operation( + summary = "Logs out current logged in user session", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/logout" + ) + ResponseEntity logoutUser( + + ); + + + /** + * OPTIONS /user/logout : logoutUserOptions + * + * @return endpoint configuration response (status code 200) + */ + @Operation( + summary = "logoutUserOptions", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "endpoint configuration response") + } + ) + @RequestMapping( + method = RequestMethod.OPTIONS, + value = "/user/logout" + ) + ResponseEntity logoutUserOptions( + + ); + + + /** + * 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 body Updated user object (required) + * @return Invalid user supplied (status code 400) + * or User not found (status code 404) + */ + @Operation( + summary = "Updated user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid user supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/user/{username}" + ) + ResponseEntity updateUser( + @Parameter(name = "username", description = "name that need to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("username") String username, + @Parameter(name = "body", description = "Updated user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody User body + ); + +} diff --git a/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/UserApiClient.java b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/UserApiClient.java new file mode 100644 index 000000000000..1db4598108db --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/UserApiClient.java @@ -0,0 +1,8 @@ +package org.openapitools.api; + +import org.springframework.cloud.openfeign.FeignClient; +import org.openapitools.configuration.ClientConfiguration; + +@FeignClient(name="${user.name:user}", url="${user.url:http://petstore.swagger.io/v2}", configuration = ClientConfiguration.class) +public interface UserApiClient extends UserApi { +} diff --git a/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/configuration/ApiKeyRequestInterceptor.java b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/configuration/ApiKeyRequestInterceptor.java new file mode 100644 index 000000000000..199278dcb539 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/configuration/ApiKeyRequestInterceptor.java @@ -0,0 +1,31 @@ +package org.openapitools.configuration; + +import feign.RequestInterceptor; +import feign.RequestTemplate; +import feign.Util; + + +public class ApiKeyRequestInterceptor implements RequestInterceptor { + private final String location; + private final String name; + private String value; + + public ApiKeyRequestInterceptor(String location, String name, String value) { + Util.checkNotNull(location, "location", new Object[0]); + Util.checkNotNull(name, "name", new Object[0]); + Util.checkNotNull(value, "value", new Object[0]); + this.location = location; + this.name = name; + this.value = value; + } + + @Override + public void apply(RequestTemplate requestTemplate) { + if(location.equals("header")) { + requestTemplate.header(name, value); + } else if(location.equals("query")) { + requestTemplate.query(name, value); + } + } + +} diff --git a/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/configuration/ClientConfiguration.java b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/configuration/ClientConfiguration.java new file mode 100644 index 000000000000..4a28661290d9 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/configuration/ClientConfiguration.java @@ -0,0 +1,48 @@ +package org.openapitools.configuration; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.cloud.openfeign.security.OAuth2FeignRequestInterceptor; +import org.springframework.security.oauth2.client.DefaultOAuth2ClientContext; +import org.springframework.security.oauth2.client.OAuth2ClientContext; +import org.springframework.security.oauth2.client.token.grant.implicit.ImplicitResourceDetails; + +@Configuration +@EnableConfigurationProperties +public class ClientConfiguration { + + @Value("${openapipetstore.security.apiKey.key:}") + private String apiKeyKey; + + @Bean + @ConditionalOnProperty(name = "openapipetstore.security.apiKey.key") + public ApiKeyRequestInterceptor apiKeyRequestInterceptor() { + return new ApiKeyRequestInterceptor("header", "api_key", this.apiKeyKey); + } + + @Bean + @ConditionalOnProperty("openapipetstore.security.petstoreAuth.client-id") + public OAuth2FeignRequestInterceptor petstoreAuthRequestInterceptor(OAuth2ClientContext oAuth2ClientContext) { + return new OAuth2FeignRequestInterceptor(oAuth2ClientContext, petstoreAuthResourceDetails()); + } + + @Bean + @ConditionalOnProperty("openapipetstore.security.petstoreAuth.client-id") + public OAuth2ClientContext oAuth2ClientContext() { + return new DefaultOAuth2ClientContext(); + } + + @Bean + @ConditionalOnProperty("openapipetstore.security.petstoreAuth.client-id") + @ConfigurationProperties("openapipetstore.security.petstoreAuth") + public ImplicitResourceDetails petstoreAuthResourceDetails() { + ImplicitResourceDetails details = new ImplicitResourceDetails(); + details.setUserAuthorizationUri("http://petstore.swagger.io/api/oauth/dialog"); + return details; + } + +} diff --git a/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/model/Category.java b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/model/Category.java new file mode 100644 index 000000000000..cb69c674a1e4 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/model/Category.java @@ -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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * A category for a pet + */ +@Schema(name = "Category",description = "A category for a pet") +@javax.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "name", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/model/ModelApiResponse.java b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/model/ModelApiResponse.java new file mode 100644 index 000000000000..0ef610e38f01 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/model/ModelApiResponse.java @@ -0,0 +1,134 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Describes the result of uploading an image resource + */ +@Schema(name = "ApiResponse",description = "Describes the result of uploading an image resource") +@javax.annotation.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 + */ + @Schema(name = "code", defaultValue = "") + + + 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 + */ + @Schema(name = "type", defaultValue = "") + + + 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 + */ + @Schema(name = "message", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/model/Order.java b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/model/Order.java new file mode 100644 index 000000000000..528598b79ea7 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/model/Order.java @@ -0,0 +1,250 @@ +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 java.time.OffsetDateTime; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * An order for a pets from the pet store + */ +@Schema(name = "Order",description = "An order for a pets from the pet store") +@javax.annotation.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") + @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "petId", defaultValue = "") + + + 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 + */ + @Schema(name = "quantity", defaultValue = "") + + + 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 + */ + @Schema(name = "shipDate", defaultValue = "") + + @Valid + + 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 + */ + @Schema(name = "status", defaultValue = "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 + */ + @Schema(name = "complete", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/model/Pet.java b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/model/Pet.java new file mode 100644 index 000000000000..7c2986fea846 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/model/Pet.java @@ -0,0 +1,270 @@ +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 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 io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * A pet for sale in the pet store + */ +@Schema(name = "Pet",description = "A pet for sale in the pet store") +@javax.annotation.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 photoUrls = new ArrayList<>(); + + @JsonProperty("tags") + @Valid + private List 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; + + public Pet id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "category", defaultValue = "") + + @Valid + + 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 + */ + @Schema(name = "name", example = "doggie", required = true, defaultValue = "") + @NotNull + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Pet photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + public Pet addPhotoUrlsItem(String photoUrlsItem) { + this.photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get photoUrls + * @return photoUrls + */ + @Schema(name = "photoUrls", required = true, defaultValue = "") + @NotNull + + + public List getPhotoUrls() { + return photoUrls; + } + + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + public Pet tags(List 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 + */ + @Schema(name = "tags", defaultValue = "") + + @Valid + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * pet status in the store + * @return status + */ + @Schema(name = "status", defaultValue = "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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/model/Tag.java b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/model/Tag.java new file mode 100644 index 000000000000..27166f687a27 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/model/Tag.java @@ -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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * A tag for a pet + */ +@Schema(name = "Tag",description = "A tag for a pet") +@javax.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "name", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/model/User.java b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/model/User.java new file mode 100644 index 000000000000..ba24f681c1df --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/model/User.java @@ -0,0 +1,259 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * A User who is purchasing from the pet store + */ +@Schema(name = "User",description = "A User who is purchasing from the pet store") +@javax.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "username", defaultValue = "") + + + 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 + */ + @Schema(name = "firstName", defaultValue = "") + + + 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 + */ + @Schema(name = "lastName", defaultValue = "") + + + 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 + */ + @Schema(name = "email", defaultValue = "") + + + 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 + */ + @Schema(name = "password", defaultValue = "") + + + 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 + */ + @Schema(name = "phone", defaultValue = "") + + + 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 + */ + @Schema(name = "userStatus", defaultValue = "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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud/.openapi-generator-ignore b/samples/openapi3/client/petstore/spring-cloud/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud/.openapi-generator-ignore @@ -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 diff --git a/samples/openapi3/client/petstore/spring-cloud/.openapi-generator/FILES b/samples/openapi3/client/petstore/spring-cloud/.openapi-generator/FILES new file mode 100644 index 000000000000..5e5e7f604560 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud/.openapi-generator/FILES @@ -0,0 +1,11 @@ +README.md +pom.xml +src/main/java/org/openapitools/api/PetApi.java +src/main/java/org/openapitools/api/StoreApi.java +src/main/java/org/openapitools/api/UserApi.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 diff --git a/samples/openapi3/client/petstore/spring-cloud/.openapi-generator/VERSION b/samples/openapi3/client/petstore/spring-cloud/.openapi-generator/VERSION new file mode 100644 index 000000000000..0984c4c1ad21 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud/.openapi-generator/VERSION @@ -0,0 +1 @@ +5.4.0-SNAPSHOT \ No newline at end of file diff --git a/samples/openapi3/client/petstore/spring-cloud/README.md b/samples/openapi3/client/petstore/spring-cloud/README.md new file mode 100644 index 000000000000..a462be951ace --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud/README.md @@ -0,0 +1,26 @@ +# OpenAPI generated API stub + +Spring Framework stub + + +## Overview +This code was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. +By using the [OpenAPI-Spec](https://openapis.org), you can easily generate an API stub. +This is an example of building API stub interfaces in Java using the Spring framework. + +The stubs generated can be used in your existing Spring-MVC or Spring-Boot application to create controller endpoints +by adding ```@Controller``` classes that implement the interface. Eg: +```java +@Controller +public class PetController implements PetApi { +// implement all PetApi methods +} +``` + +You can also use the interface to create [Spring-Cloud Feign clients](http://projects.spring.io/spring-cloud/spring-cloud.html#spring-cloud-feign-inheritance).Eg: +```java +@FeignClient(name="pet", url="http://petstore.swagger.io/v2") +public interface PetClient extends PetApi { + +} +``` diff --git a/samples/openapi3/client/petstore/spring-cloud/pom.xml b/samples/openapi3/client/petstore/spring-cloud/pom.xml new file mode 100644 index 000000000000..6cf023f501f2 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud/pom.xml @@ -0,0 +1,79 @@ + + 4.0.0 + org.openapitools.openapi3 + spring-cloud-oas3 + jar + spring-cloud-oas3 + 1.0.0 + + 1.8 + ${java.version} + ${java.version} + 2.1.11 + + + org.springframework.boot + spring-boot-starter-parent + 2.6.2 + + + src/main/java + + + + + + org.springframework.cloud + spring-cloud-starter-parent + 2021.0.0 + pom + import + + + + + + + io.swagger.core.v3 + swagger-annotations + ${swagger-core-version} + + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + org.springframework.cloud + spring-cloud-starter-oauth2 + 2.2.5.RELEASE + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + + + org.openapitools + jackson-databind-nullable + 0.2.2 + + + org.springframework.boot + spring-boot-starter-validation + + + org.springframework.data + spring-data-commons + + + org.springframework.boot + spring-boot-starter-test + test + + + diff --git a/samples/openapi3/client/petstore/spring-cloud/src/main/java/org/openapitools/api/PetApi.java b/samples/openapi3/client/petstore/spring-cloud/src/main/java/org/openapitools/api/PetApi.java new file mode 100644 index 000000000000..90dfd2c5f8e9 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud/src/main/java/org/openapitools/api/PetApi.java @@ -0,0 +1,275 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "Pet", description = "the Pet API") +public interface PetApi { + + /** + * 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) + */ + @Operation( + summary = "Add a new pet to the store", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "405", description = "Invalid input") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet", + produces = "application/json", + consumes = "application/json" + ) + ResponseEntity addPet( + @Parameter(name = "Pet", description = "Pet object that needs to be added to the store", required = true, schema = @Schema(description = "")) @Valid @RequestBody Pet pet + ); + + + /** + * DELETE /pet/{petId} : Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @return Invalid pet value (status code 400) + */ + @Operation( + summary = "Deletes a pet", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid pet value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/pet/{petId}" + ) + ResponseEntity deletePet( + @Parameter(name = "petId", description = "Pet id to delete", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "api_key", description = "", schema = @Schema(description = "")) @RequestHeader(value = "api_key", required = false) String 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) + */ + @Operation( + summary = "Finds Pets by status", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid status value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/findByStatus", + produces = "application/json" + ) + ResponseEntity> findPetsByStatus( + @NotNull @Parameter(name = "status", description = "Status values that need to be considered for filter", required = true, schema = @Schema(description = "", allowableValues = { "available", "pending", "sold" })) @Valid @RequestParam(value = "status", required = true) List 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 + */ + @Operation( + summary = "Finds Pets by tags", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid tag value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/findByTags", + produces = "application/json" + ) + ResponseEntity> findPetsByTags( + @NotNull @Parameter(name = "tags", description = "Tags to filter by", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "tags", required = true) List 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) + */ + @Operation( + summary = "Find pet by ID", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/{petId}", + produces = "application/json" + ) + ResponseEntity getPetById( + @Parameter(name = "petId", description = "ID of pet to return", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long 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) + */ + @Operation( + summary = "Update an existing pet", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found"), + @ApiResponse(responseCode = "405", description = "Validation exception") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/pet", + produces = "application/json", + consumes = "application/json" + ) + ResponseEntity updatePet( + @Parameter(name = "Pet", description = "Pet object that needs to be added to the store", required = true, schema = @Schema(description = "")) @Valid @RequestBody Pet 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) + */ + @Operation( + summary = "Updates a pet in the store with form data", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "405", description = "Invalid input") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet/{petId}", + consumes = "application/x-www-form-urlencoded" + ) + ResponseEntity updatePetWithForm( + @Parameter(name = "petId", description = "ID of pet that needs to be updated", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "name", description = "Updated name of the pet", schema = @Schema(description = "")) @RequestParam(value="name", required=false) String name, + @Parameter(name = "status", description = "Updated status of the pet", schema = @Schema(description = "")) @RequestParam(value="status", required=false) String 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) + */ + @Operation( + summary = "uploads an image", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ModelApiResponse.class))) + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet/{petId}/uploadImage", + produces = "application/json", + consumes = "multipart/form-data" + ) + ResponseEntity uploadFile( + @Parameter(name = "petId", description = "ID of pet to update", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "additionalMetadata", description = "Additional data to pass to server", schema = @Schema(description = "")) @RequestParam(value="additionalMetadata", required=false) String additionalMetadata, + @Parameter(name = "file", description = "file to upload", schema = @Schema(description = "")) @RequestParam("file") MultipartFile file + ); + +} diff --git a/samples/openapi3/client/petstore/spring-cloud/src/main/java/org/openapitools/api/StoreApi.java b/samples/openapi3/client/petstore/spring-cloud/src/main/java/org/openapitools/api/StoreApi.java new file mode 100644 index 000000000000..c42b27e3a5b8 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud/src/main/java/org/openapitools/api/StoreApi.java @@ -0,0 +1,140 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "Store", description = "the Store API") +public interface StoreApi { + + /** + * 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) + */ + @Operation( + summary = "Delete purchase order by ID", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/store/order/{orderId}" + ) + ResponseEntity deleteOrder( + @Parameter(name = "orderId", description = "ID of the order that needs to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("orderId") String orderId + ); + + + /** + * GET /store/inventory : Returns pet inventories by status + * Returns a map of status codes to quantities + * + * @return successful operation (status code 200) + */ + @Operation( + summary = "Returns pet inventories by status", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Map.class))) + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/store/inventory", + produces = "application/json" + ) + ResponseEntity> getInventory( + + ); + + + /** + * GET /store/order/{orderId} : Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated 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) + */ + @Operation( + summary = "Find purchase order by ID", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/store/order/{orderId}", + produces = "application/json" + ) + ResponseEntity getOrderById( + @Min(1L) @Max(5L) @Parameter(name = "orderId", description = "ID of pet that needs to be fetched", required = true, schema = @Schema(description = "")) @PathVariable("orderId") Long 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) + */ + @Operation( + summary = "Place an order for a pet", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid Order") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/store/order", + produces = "application/json", + consumes = "application/json" + ) + ResponseEntity placeOrder( + @Parameter(name = "Order", description = "order placed for purchasing the pet", required = true, schema = @Schema(description = "")) @Valid @RequestBody Order order + ); + +} diff --git a/samples/openapi3/client/petstore/spring-cloud/src/main/java/org/openapitools/api/UserApi.java b/samples/openapi3/client/petstore/spring-cloud/src/main/java/org/openapitools/api/UserApi.java new file mode 100644 index 000000000000..5b0522ee7758 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud/src/main/java/org/openapitools/api/UserApi.java @@ -0,0 +1,252 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "User", description = "the User API") +public interface UserApi { + + /** + * 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) + */ + @Operation( + summary = "Create user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user", + consumes = "application/json" + ) + ResponseEntity createUser( + @Parameter(name = "User", description = "Created user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody User 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) + */ + @Operation( + summary = "Creates list of users with given input array", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user/createWithArray", + consumes = "application/json" + ) + ResponseEntity createUsersWithArrayInput( + @Parameter(name = "User", description = "List of user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody List 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) + */ + @Operation( + summary = "Creates list of users with given input array", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user/createWithList", + consumes = "application/json" + ) + ResponseEntity createUsersWithListInput( + @Parameter(name = "User", description = "List of user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody List 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) + */ + @Operation( + summary = "Delete user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/user/{username}" + ) + ResponseEntity deleteUser( + @Parameter(name = "username", description = "The name that needs to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("username") String 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) + */ + @Operation( + summary = "Get user by user name", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = User.class))), + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/{username}", + produces = "application/json" + ) + ResponseEntity getUserByName( + @Parameter(name = "username", description = "The name that needs to be fetched. Use user1 for testing.", required = true, schema = @Schema(description = "")) @PathVariable("username") String 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) + */ + @Operation( + summary = "Logs user into the system", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "400", description = "Invalid username/password supplied") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/login", + produces = "application/json" + ) + ResponseEntity loginUser( + @NotNull @Pattern(regexp = "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") @Parameter(name = "username", description = "The user name for login", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "username", required = true) String username, + @NotNull @Parameter(name = "password", description = "The password for login in clear text", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "password", required = true) String password + ); + + + /** + * GET /user/logout : Logs out current logged in user session + * + * @return successful operation (status code 200) + */ + @Operation( + summary = "Logs out current logged in user session", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/logout" + ) + ResponseEntity 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) + */ + @Operation( + summary = "Updated user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid user supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/user/{username}", + consumes = "application/json" + ) + ResponseEntity updateUser( + @Parameter(name = "username", description = "name that need to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("username") String username, + @Parameter(name = "User", description = "Updated user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody User user + ); + +} diff --git a/samples/openapi3/client/petstore/spring-cloud/src/main/java/org/openapitools/model/Category.java b/samples/openapi3/client/petstore/spring-cloud/src/main/java/org/openapitools/model/Category.java new file mode 100644 index 000000000000..463de0ed39a3 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud/src/main/java/org/openapitools/model/Category.java @@ -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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * A category for a pet + */ +@Schema(name = "Category",description = "A category for a pet") +@javax.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "name", defaultValue = "") + +@Pattern(regexp = "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") + 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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud/src/main/java/org/openapitools/model/ModelApiResponse.java b/samples/openapi3/client/petstore/spring-cloud/src/main/java/org/openapitools/model/ModelApiResponse.java new file mode 100644 index 000000000000..0ef610e38f01 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud/src/main/java/org/openapitools/model/ModelApiResponse.java @@ -0,0 +1,134 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Describes the result of uploading an image resource + */ +@Schema(name = "ApiResponse",description = "Describes the result of uploading an image resource") +@javax.annotation.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 + */ + @Schema(name = "code", defaultValue = "") + + + 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 + */ + @Schema(name = "type", defaultValue = "") + + + 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 + */ + @Schema(name = "message", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud/src/main/java/org/openapitools/model/Order.java b/samples/openapi3/client/petstore/spring-cloud/src/main/java/org/openapitools/model/Order.java new file mode 100644 index 000000000000..528598b79ea7 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud/src/main/java/org/openapitools/model/Order.java @@ -0,0 +1,250 @@ +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 java.time.OffsetDateTime; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * An order for a pets from the pet store + */ +@Schema(name = "Order",description = "An order for a pets from the pet store") +@javax.annotation.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") + @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "petId", defaultValue = "") + + + 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 + */ + @Schema(name = "quantity", defaultValue = "") + + + 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 + */ + @Schema(name = "shipDate", defaultValue = "") + + @Valid + + 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 + */ + @Schema(name = "status", defaultValue = "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 + */ + @Schema(name = "complete", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud/src/main/java/org/openapitools/model/Pet.java b/samples/openapi3/client/petstore/spring-cloud/src/main/java/org/openapitools/model/Pet.java new file mode 100644 index 000000000000..7c2986fea846 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud/src/main/java/org/openapitools/model/Pet.java @@ -0,0 +1,270 @@ +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 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 io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * A pet for sale in the pet store + */ +@Schema(name = "Pet",description = "A pet for sale in the pet store") +@javax.annotation.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 photoUrls = new ArrayList<>(); + + @JsonProperty("tags") + @Valid + private List 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; + + public Pet id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "category", defaultValue = "") + + @Valid + + 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 + */ + @Schema(name = "name", example = "doggie", required = true, defaultValue = "") + @NotNull + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Pet photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + public Pet addPhotoUrlsItem(String photoUrlsItem) { + this.photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get photoUrls + * @return photoUrls + */ + @Schema(name = "photoUrls", required = true, defaultValue = "") + @NotNull + + + public List getPhotoUrls() { + return photoUrls; + } + + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + public Pet tags(List 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 + */ + @Schema(name = "tags", defaultValue = "") + + @Valid + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * pet status in the store + * @return status + */ + @Schema(name = "status", defaultValue = "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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud/src/main/java/org/openapitools/model/Tag.java b/samples/openapi3/client/petstore/spring-cloud/src/main/java/org/openapitools/model/Tag.java new file mode 100644 index 000000000000..27166f687a27 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud/src/main/java/org/openapitools/model/Tag.java @@ -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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * A tag for a pet + */ +@Schema(name = "Tag",description = "A tag for a pet") +@javax.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "name", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud/src/main/java/org/openapitools/model/User.java b/samples/openapi3/client/petstore/spring-cloud/src/main/java/org/openapitools/model/User.java new file mode 100644 index 000000000000..ba24f681c1df --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud/src/main/java/org/openapitools/model/User.java @@ -0,0 +1,259 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * A User who is purchasing from the pet store + */ +@Schema(name = "User",description = "A User who is purchasing from the pet store") +@javax.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "username", defaultValue = "") + + + 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 + */ + @Schema(name = "firstName", defaultValue = "") + + + 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 + */ + @Schema(name = "lastName", defaultValue = "") + + + 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 + */ + @Schema(name = "email", defaultValue = "") + + + 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 + */ + @Schema(name = "password", defaultValue = "") + + + 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 + */ + @Schema(name = "phone", defaultValue = "") + + + 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 + */ + @Schema(name = "userStatus", defaultValue = "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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/.openapi-generator-ignore b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/.openapi-generator-ignore @@ -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 diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/.openapi-generator/FILES b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/.openapi-generator/FILES new file mode 100644 index 000000000000..0616dc9030d3 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/.openapi-generator/FILES @@ -0,0 +1,68 @@ +README.md +pom.xml +src/main/java/org/openapitools/OpenAPI2SpringBoot.java +src/main/java/org/openapitools/RFC3339DateFormat.java +src/main/java/org/openapitools/api/AnotherFakeApi.java +src/main/java/org/openapitools/api/AnotherFakeApiController.java +src/main/java/org/openapitools/api/ApiUtil.java +src/main/java/org/openapitools/api/FakeApi.java +src/main/java/org/openapitools/api/FakeApiController.java +src/main/java/org/openapitools/api/FakeClassnameTestApi.java +src/main/java/org/openapitools/api/FakeClassnameTestApiController.java +src/main/java/org/openapitools/api/PetApi.java +src/main/java/org/openapitools/api/PetApiController.java +src/main/java/org/openapitools/api/StoreApi.java +src/main/java/org/openapitools/api/StoreApiController.java +src/main/java/org/openapitools/api/UserApi.java +src/main/java/org/openapitools/api/UserApiController.java +src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java +src/main/java/org/openapitools/configuration/HomeController.java +src/main/java/org/openapitools/configuration/JacksonConfiguration.java +src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java +src/main/java/org/openapitools/model/AdditionalPropertiesArray.java +src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java +src/main/java/org/openapitools/model/AdditionalPropertiesClass.java +src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java +src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java +src/main/java/org/openapitools/model/AdditionalPropertiesObject.java +src/main/java/org/openapitools/model/AdditionalPropertiesString.java +src/main/java/org/openapitools/model/Animal.java +src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java +src/main/java/org/openapitools/model/ArrayOfNumberOnly.java +src/main/java/org/openapitools/model/ArrayTest.java +src/main/java/org/openapitools/model/BigCat.java +src/main/java/org/openapitools/model/BigCatAllOf.java +src/main/java/org/openapitools/model/Capitalization.java +src/main/java/org/openapitools/model/Cat.java +src/main/java/org/openapitools/model/CatAllOf.java +src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ClassModel.java +src/main/java/org/openapitools/model/Client.java +src/main/java/org/openapitools/model/Dog.java +src/main/java/org/openapitools/model/DogAllOf.java +src/main/java/org/openapitools/model/EnumArrays.java +src/main/java/org/openapitools/model/EnumClass.java +src/main/java/org/openapitools/model/EnumTest.java +src/main/java/org/openapitools/model/FileSchemaTestClass.java +src/main/java/org/openapitools/model/FormatTest.java +src/main/java/org/openapitools/model/HasOnlyReadOnly.java +src/main/java/org/openapitools/model/MapTest.java +src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java +src/main/java/org/openapitools/model/Model200Response.java +src/main/java/org/openapitools/model/ModelApiResponse.java +src/main/java/org/openapitools/model/ModelReturn.java +src/main/java/org/openapitools/model/Name.java +src/main/java/org/openapitools/model/NumberOnly.java +src/main/java/org/openapitools/model/Order.java +src/main/java/org/openapitools/model/OuterComposite.java +src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/Pet.java +src/main/java/org/openapitools/model/ReadOnlyFirst.java +src/main/java/org/openapitools/model/SpecialModelName.java +src/main/java/org/openapitools/model/Tag.java +src/main/java/org/openapitools/model/TypeHolderDefault.java +src/main/java/org/openapitools/model/TypeHolderExample.java +src/main/java/org/openapitools/model/User.java +src/main/java/org/openapitools/model/XmlItem.java +src/main/resources/application.properties +src/main/resources/openapi.yaml diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/.openapi-generator/VERSION b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/.openapi-generator/VERSION new file mode 100644 index 000000000000..0984c4c1ad21 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/.openapi-generator/VERSION @@ -0,0 +1 @@ +5.4.0-SNAPSHOT \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/README.md b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/README.md new file mode 100644 index 000000000000..befc961488ae --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/README.md @@ -0,0 +1,16 @@ +# 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. + +Start your server as a simple java application + +You can view the api documentation in swagger-ui by pointing to +http://localhost:80/ + +Change default port value in application.properties \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/pom.xml b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/pom.xml new file mode 100644 index 000000000000..737d7740cd59 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/pom.xml @@ -0,0 +1,67 @@ + + 4.0.0 + org.openapitools.openapi3 + spring-boot-beanvalidation-no-nullable + jar + spring-boot-beanvalidation-no-nullable + 1.0.0 + + 1.7 + ${java.version} + ${java.version} + 2.1.11 + + + org.springframework.boot + spring-boot-starter-parent + 2.5.8 + + + src/main/java + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.data + spring-data-commons + + + io.swagger.core.v3 + swagger-annotations + ${swagger-core-version} + + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + + + com.github.joschi.jackson + jackson-datatype-threetenbp + 2.9.10 + + + + org.springframework.boot + spring-boot-starter-validation + + + com.fasterxml.jackson.core + jackson-databind + + + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..8f6282c8d10f --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,59 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.Module; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.ExitCodeGenerator; +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.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenAPI2SpringBoot implements CommandLineRunner { + + @Override + public void run(String... arg0) throws Exception { + if (arg0.length > 0 && arg0[0].equals("exitcode")) { + throw new ExitException(); + } + } + + public static void main(String[] args) throws Exception { + new SpringApplication(OpenAPI2SpringBoot.class).run(args); + } + + static class ExitException extends RuntimeException implements ExitCodeGenerator { + private static final long serialVersionUID = 1L; + + @Override + public int getExitCode() { + return 10; + } + + } + + @Bean + public WebMvcConfigurer webConfigurer() { + return new WebMvcConfigurerAdapter() { + /*@Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") + .allowedOrigins("*") + .allowedMethods("*") + .allowedHeaders("Content-Type"); + }*/ + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("/swagger-ui/**").addResourceLocations("classpath:/META-INF/resources/webjars/swagger-ui/3.14.2/"); + } + }; + } + + +} diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/RFC3339DateFormat.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/RFC3339DateFormat.java new file mode 100644 index 000000000000..bcd3936d8b34 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/RFC3339DateFormat.java @@ -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; + } +} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/AnotherFakeApi.java new file mode 100644 index 000000000000..81ca2e8ee07c --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -0,0 +1,55 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.openapitools.api; + +import org.openapitools.model.Client; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.ResponseEntity; +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; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "another-fake", description = "the another-fake API") +public interface AnotherFakeApi { + + /** + * PATCH /another-fake/dummy : To test special tags + * To test special tags and operation ID starting with number + * + * @param body client model (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "To test special tags", + tags = { "$another-fake?" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Client.class))) + } + ) + @RequestMapping( + method = RequestMethod.PATCH, + value = "/another-fake/dummy", + produces = { "application/json" }, + consumes = { "application/json" } + ) + ResponseEntity call123testSpecialTags( + @Parameter(name = "body", description = "client model", required = true, schema = @Schema(description = "")) @Valid @RequestBody Client body + ); + +} diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/AnotherFakeApiController.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/AnotherFakeApiController.java new file mode 100644 index 000000000000..7968826328d7 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/AnotherFakeApiController.java @@ -0,0 +1,63 @@ +package org.openapitools.api; + +import org.openapitools.model.Client; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +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.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.constraints.*; +import javax.validation.Valid; +import java.util.List; +import java.util.Map; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class AnotherFakeApiController implements AnotherFakeApi { + + private final NativeWebRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public AnotherFakeApiController(NativeWebRequest request) { + this.request = request; + } + + /** + * PATCH /another-fake/dummy : To test special tags + * To test special tags and operation ID starting with number + * + * @param body client model (required) + * @return successful operation (status code 200) + * @see AnotherFakeApi#call123testSpecialTags + */ + public ResponseEntity call123testSpecialTags( + @Parameter(name = "body", description = "client model", required = true, schema = @Schema(description = "")) @Valid @RequestBody Client body + ) { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"client\" : \"client\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/ApiUtil.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/ApiUtil.java new file mode 100644 index 000000000000..1245b1dd0ccf --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/ApiUtil.java @@ -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); + } + } +} diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApi.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApi.java new file mode 100644 index 000000000000..d634215d030b --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApi.java @@ -0,0 +1,471 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.openapitools.api; + +import java.math.BigDecimal; +import org.openapitools.model.Client; +import org.openapitools.model.FileSchemaTestClass; +import org.threeten.bp.LocalDate; +import java.util.Map; +import org.openapitools.model.ModelApiResponse; +import org.threeten.bp.OffsetDateTime; +import org.openapitools.model.OuterComposite; +import org.openapitools.model.User; +import org.openapitools.model.XmlItem; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.ResponseEntity; +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; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "fake", description = "the fake API") +public interface FakeApi { + + /** + * POST /fake/create_xml_item : creates an XmlItem + * this route creates an XmlItem + * + * @param xmlItem XmlItem Body (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "creates an XmlItem", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/create_xml_item", + consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } + ) + ResponseEntity createXmlItem( + @Parameter(name = "XmlItem", description = "XmlItem Body", required = true, schema = @Schema(description = "")) @Valid @RequestBody XmlItem xmlItem + ); + + + /** + * POST /fake/outer/boolean + * Test serialization of outer boolean types + * + * @param body Input boolean as post body (optional) + * @return Output boolean (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Output boolean", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Boolean.class))) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/outer/boolean", + produces = { "*/*" } + ) + ResponseEntity fakeOuterBooleanSerialize( + @Parameter(name = "body", description = "Input boolean as post body", schema = @Schema(description = "")) @Valid @RequestBody(required = false) Boolean body + ); + + + /** + * POST /fake/outer/composite + * Test serialization of object with outer number type + * + * @param body Input composite as post body (optional) + * @return Output composite (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Output composite", content = @Content(mediaType = "application/json", schema = @Schema(implementation = OuterComposite.class))) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/outer/composite", + produces = { "*/*" } + ) + ResponseEntity fakeOuterCompositeSerialize( + @Parameter(name = "body", description = "Input composite as post body", schema = @Schema(description = "")) @Valid @RequestBody(required = false) OuterComposite body + ); + + + /** + * POST /fake/outer/number + * Test serialization of outer number types + * + * @param body Input number as post body (optional) + * @return Output number (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Output number", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BigDecimal.class))) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/outer/number", + produces = { "*/*" } + ) + ResponseEntity fakeOuterNumberSerialize( + @Parameter(name = "body", description = "Input number as post body", schema = @Schema(description = "")) @Valid @RequestBody(required = false) BigDecimal body + ); + + + /** + * POST /fake/outer/string + * Test serialization of outer string types + * + * @param body Input string as post body (optional) + * @return Output string (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Output string", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/outer/string", + produces = { "*/*" } + ) + ResponseEntity fakeOuterStringSerialize( + @Parameter(name = "body", description = "Input string as post body", schema = @Schema(description = "")) @Valid @RequestBody(required = false) String body + ); + + + /** + * PUT /fake/body-with-file-schema + * For this test, the body for this request much reference a schema named `File`. + * + * @param body (required) + * @return Success (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success") + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/fake/body-with-file-schema", + consumes = { "application/json" } + ) + ResponseEntity testBodyWithFileSchema( + @Parameter(name = "body", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestBody FileSchemaTestClass body + ); + + + /** + * PUT /fake/body-with-query-params + * + * @param query (required) + * @param body (required) + * @return Success (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success") + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/fake/body-with-query-params", + consumes = { "application/json" } + ) + ResponseEntity testBodyWithQueryParams( + @NotNull @Parameter(name = "query", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "query", required = true) String query, + @Parameter(name = "body", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestBody User body + ); + + + /** + * PATCH /fake : To test \"client\" model + * To test \"client\" model + * + * @param body client model (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "To test \"client\" model", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Client.class))) + } + ) + @RequestMapping( + method = RequestMethod.PATCH, + value = "/fake", + produces = { "application/json" }, + consumes = { "application/json" } + ) + ResponseEntity testClientModel( + @Parameter(name = "body", description = "client model", required = true, schema = @Schema(description = "")) @Valid @RequestBody Client body + ); + + + /** + * POST /fake : Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * + * @param number None (required) + * @param _double None (required) + * @param patternWithoutDelimiter None (required) + * @param _byte None (required) + * @param integer None (optional) + * @param int32 None (optional) + * @param int64 None (optional) + * @param _float None (optional) + * @param string None (optional) + * @param binary None (optional) + * @param date None (optional) + * @param dateTime None (optional) + * @param password None (optional) + * @param paramCallback None (optional) + * @return Invalid username supplied (status code 400) + * or User not found (status code 404) + */ + @Operation( + summary = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + }, + security = { + @SecurityRequirement(name = "http_basic_test") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) + ResponseEntity testEndpointParameters( + @Parameter(name = "number", description = "None", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "number", required = true) BigDecimal number, + @Parameter(name = "double", description = "None", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "double", required = true) Double _double, + @Parameter(name = "pattern_without_delimiter", description = "None", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, + @Parameter(name = "byte", description = "None", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, + @Parameter(name = "integer", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "integer", required = false) Integer integer, + @Parameter(name = "int32", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "int32", required = false) Integer int32, + @Parameter(name = "int64", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "int64", required = false) Long int64, + @Parameter(name = "float", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "float", required = false) Float _float, + @Parameter(name = "string", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "string", required = false) String string, + @Parameter(name = "binary", description = "None", schema = @Schema(description = "")) @RequestPart(value = "binary", required = false) MultipartFile binary, + @Parameter(name = "date", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "date", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @Parameter(name = "dateTime", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "dateTime", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @Parameter(name = "password", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "password", required = false) String password, + @Parameter(name = "callback", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "callback", required = false) String paramCallback + ); + + + /** + * GET /fake : To test enum parameters + * To test enum parameters + * + * @param enumHeaderStringArray Header parameter enum test (string array) (optional) + * @param enumHeaderString Header parameter enum test (string) (optional, default to -efg) + * @param enumQueryStringArray Query parameter enum test (string array) (optional) + * @param enumQueryString Query parameter enum test (string) (optional, default to -efg) + * @param enumQueryInteger Query parameter enum test (double) (optional) + * @param enumQueryDouble Query parameter enum test (double) (optional) + * @param enumFormStringArray Form parameter enum test (string array) (optional, default to $) + * @param enumFormString Form parameter enum test (string) (optional, default to -efg) + * @return Invalid request (status code 400) + * or Not found (status code 404) + */ + @Operation( + summary = "To test enum parameters", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid request"), + @ApiResponse(responseCode = "404", description = "Not found") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) + ResponseEntity testEnumParameters( + @Parameter(name = "enum_header_string_array", description = "Header parameter enum test (string array)", schema = @Schema(description = "", allowableValues = { ">", "$" })) @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray, + @Parameter(name = "enum_header_string", description = "Header parameter enum test (string)", schema = @Schema(description = "", allowableValues = { "_abc", "-efg", "(xyz)" }, defaultValue = "-efg")) @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString, + @Parameter(name = "enum_query_string_array", description = "Query parameter enum test (string array)", schema = @Schema(description = "", allowableValues = { ">", "$" })) @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, + @Parameter(name = "enum_query_string", description = "Query parameter enum test (string)", schema = @Schema(description = "", allowableValues = { "_abc", "-efg", "(xyz)" }, defaultValue = "-efg")) @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString, + @Parameter(name = "enum_query_integer", description = "Query parameter enum test (double)", schema = @Schema(description = "", allowableValues = { "1", "-2" })) @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, + @Parameter(name = "enum_query_double", description = "Query parameter enum test (double)", schema = @Schema(description = "", allowableValues = { "1.1", "-1.2" })) @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble, + @Parameter(name = "enum_form_string_array", description = "Form parameter enum test (string array)", schema = @Schema(description = "", allowableValues = { ">", "$" })) @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, + @Parameter(name = "enum_form_string", description = "Form parameter enum test (string)", schema = @Schema(description = "", allowableValues = { "_abc", "-efg", "(xyz)" }, defaultValue = "-efg")) @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString + ); + + + /** + * DELETE /fake : Fake endpoint to test group parameters (optional) + * Fake endpoint to test group parameters (optional) + * + * @param requiredStringGroup Required String in group parameters (required) + * @param requiredBooleanGroup Required Boolean in group parameters (required) + * @param requiredInt64Group Required Integer in group parameters (required) + * @param stringGroup String in group parameters (optional) + * @param booleanGroup Boolean in group parameters (optional) + * @param int64Group Integer in group parameters (optional) + * @return Someting wrong (status code 400) + */ + @Operation( + summary = "Fake endpoint to test group parameters (optional)", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "400", description = "Someting wrong") + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/fake" + ) + ResponseEntity testGroupParameters( + @NotNull @Parameter(name = "required_string_group", description = "Required String in group parameters", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup, + @Parameter(name = "required_boolean_group", description = "Required Boolean in group parameters", required = true, schema = @Schema(description = "")) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup, + @NotNull @Parameter(name = "required_int64_group", description = "Required Integer in group parameters", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group, + @Parameter(name = "string_group", description = "String in group parameters", schema = @Schema(description = "")) @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup, + @Parameter(name = "boolean_group", description = "Boolean in group parameters", schema = @Schema(description = "")) @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup, + @Parameter(name = "int64_group", description = "Integer in group parameters", schema = @Schema(description = "")) @Valid @RequestParam(value = "int64_group", required = false) Long int64Group + ); + + + /** + * POST /fake/inline-additionalProperties : test inline additionalProperties + * + * @param param request body (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "test inline additionalProperties", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/inline-additionalProperties", + consumes = { "application/json" } + ) + ResponseEntity testInlineAdditionalProperties( + @Parameter(name = "param", description = "request body", required = true, schema = @Schema(description = "")) @Valid @RequestBody Map param + ); + + + /** + * GET /fake/jsonFormData : test json serialization of form data + * + * @param param field1 (required) + * @param param2 field2 (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "test json serialization of form data", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/fake/jsonFormData", + consumes = { "application/x-www-form-urlencoded" } + ) + ResponseEntity testJsonFormData( + @Parameter(name = "param", description = "field1", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "param", required = true) String param, + @Parameter(name = "param2", description = "field2", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "param2", required = true) String param2 + ); + + + /** + * PUT /fake/test-query-parameters + * To test the collection format in query parameters + * + * @param pipe (required) + * @param ioutil (required) + * @param http (required) + * @param url (required) + * @param context (required) + * @return Success (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success") + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/fake/test-query-parameters" + ) + ResponseEntity testQueryParameterCollectionFormat( + @NotNull @Parameter(name = "pipe", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "pipe", required = true) List pipe, + @NotNull @Parameter(name = "ioutil", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "ioutil", required = true) List ioutil, + @NotNull @Parameter(name = "http", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "http", required = true) List http, + @NotNull @Parameter(name = "url", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "url", required = true) List url, + @NotNull @Parameter(name = "context", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "context", required = true) List context + ); + + + /** + * POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required) + * + * @param petId ID of pet to update (required) + * @param requiredFile file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @return successful operation (status code 200) + */ + @Operation( + summary = "uploads an image (required)", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ModelApiResponse.class))) + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/{petId}/uploadImageWithRequiredFile", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) + ResponseEntity uploadFileWithRequiredFile( + @Parameter(name = "petId", description = "ID of pet to update", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "requiredFile", description = "file to upload", required = true, schema = @Schema(description = "")) @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, + @Parameter(name = "additionalMetadata", description = "Additional data to pass to server", schema = @Schema(description = "")) @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata + ); + +} diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApiController.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApiController.java new file mode 100644 index 000000000000..362ff5ff5e3a --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApiController.java @@ -0,0 +1,360 @@ +package org.openapitools.api; + +import java.math.BigDecimal; +import org.openapitools.model.Client; +import org.openapitools.model.FileSchemaTestClass; +import org.threeten.bp.LocalDate; +import java.util.Map; +import org.openapitools.model.ModelApiResponse; +import org.threeten.bp.OffsetDateTime; +import org.openapitools.model.OuterComposite; +import org.openapitools.model.User; +import org.openapitools.model.XmlItem; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +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.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.constraints.*; +import javax.validation.Valid; +import java.util.List; +import java.util.Map; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class FakeApiController implements FakeApi { + + private final NativeWebRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public FakeApiController(NativeWebRequest request) { + this.request = request; + } + + /** + * POST /fake/create_xml_item : creates an XmlItem + * this route creates an XmlItem + * + * @param xmlItem XmlItem Body (required) + * @return successful operation (status code 200) + * @see FakeApi#createXmlItem + */ + public ResponseEntity createXmlItem( + @Parameter(name = "XmlItem", description = "XmlItem Body", required = true, schema = @Schema(description = "")) @Valid @RequestBody XmlItem xmlItem + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * POST /fake/outer/boolean + * Test serialization of outer boolean types + * + * @param body Input boolean as post body (optional) + * @return Output boolean (status code 200) + * @see FakeApi#fakeOuterBooleanSerialize + */ + public ResponseEntity fakeOuterBooleanSerialize( + @Parameter(name = "body", description = "Input boolean as post body", schema = @Schema(description = "")) @Valid @RequestBody(required = false) Boolean body + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * POST /fake/outer/composite + * Test serialization of object with outer number type + * + * @param body Input composite as post body (optional) + * @return Output composite (status code 200) + * @see FakeApi#fakeOuterCompositeSerialize + */ + public ResponseEntity fakeOuterCompositeSerialize( + @Parameter(name = "body", description = "Input composite as post body", schema = @Schema(description = "")) @Valid @RequestBody(required = false) OuterComposite body + ) { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) { + String exampleString = "{ \"my_string\" : \"my_string\", \"my_number\" : 0.8008281904610115, \"my_boolean\" : true }"; + ApiUtil.setExampleResponse(request, "*/*", exampleString); + break; + } + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * POST /fake/outer/number + * Test serialization of outer number types + * + * @param body Input number as post body (optional) + * @return Output number (status code 200) + * @see FakeApi#fakeOuterNumberSerialize + */ + public ResponseEntity fakeOuterNumberSerialize( + @Parameter(name = "body", description = "Input number as post body", schema = @Schema(description = "")) @Valid @RequestBody(required = false) BigDecimal body + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * POST /fake/outer/string + * Test serialization of outer string types + * + * @param body Input string as post body (optional) + * @return Output string (status code 200) + * @see FakeApi#fakeOuterStringSerialize + */ + public ResponseEntity fakeOuterStringSerialize( + @Parameter(name = "body", description = "Input string as post body", schema = @Schema(description = "")) @Valid @RequestBody(required = false) String body + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * PUT /fake/body-with-file-schema + * For this test, the body for this request much reference a schema named `File`. + * + * @param body (required) + * @return Success (status code 200) + * @see FakeApi#testBodyWithFileSchema + */ + public ResponseEntity testBodyWithFileSchema( + @Parameter(name = "body", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestBody FileSchemaTestClass body + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * PUT /fake/body-with-query-params + * + * @param query (required) + * @param body (required) + * @return Success (status code 200) + * @see FakeApi#testBodyWithQueryParams + */ + public ResponseEntity testBodyWithQueryParams( + @NotNull @Parameter(name = "query", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "query", required = true) String query, + @Parameter(name = "body", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestBody User body + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * PATCH /fake : To test \"client\" model + * To test \"client\" model + * + * @param body client model (required) + * @return successful operation (status code 200) + * @see FakeApi#testClientModel + */ + public ResponseEntity testClientModel( + @Parameter(name = "body", description = "client model", required = true, schema = @Schema(description = "")) @Valid @RequestBody Client body + ) { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"client\" : \"client\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * POST /fake : Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * + * @param number None (required) + * @param _double None (required) + * @param patternWithoutDelimiter None (required) + * @param _byte None (required) + * @param integer None (optional) + * @param int32 None (optional) + * @param int64 None (optional) + * @param _float None (optional) + * @param string None (optional) + * @param binary None (optional) + * @param date None (optional) + * @param dateTime None (optional) + * @param password None (optional) + * @param paramCallback None (optional) + * @return Invalid username supplied (status code 400) + * or User not found (status code 404) + * @see FakeApi#testEndpointParameters + */ + public ResponseEntity testEndpointParameters( + @Parameter(name = "number", description = "None", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "number", required = true) BigDecimal number, + @Parameter(name = "double", description = "None", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "double", required = true) Double _double, + @Parameter(name = "pattern_without_delimiter", description = "None", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, + @Parameter(name = "byte", description = "None", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, + @Parameter(name = "integer", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "integer", required = false) Integer integer, + @Parameter(name = "int32", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "int32", required = false) Integer int32, + @Parameter(name = "int64", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "int64", required = false) Long int64, + @Parameter(name = "float", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "float", required = false) Float _float, + @Parameter(name = "string", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "string", required = false) String string, + @Parameter(name = "binary", description = "None", schema = @Schema(description = "")) @RequestPart(value = "binary", required = false) MultipartFile binary, + @Parameter(name = "date", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "date", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @Parameter(name = "dateTime", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "dateTime", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @Parameter(name = "password", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "password", required = false) String password, + @Parameter(name = "callback", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "callback", required = false) String paramCallback + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * GET /fake : To test enum parameters + * To test enum parameters + * + * @param enumHeaderStringArray Header parameter enum test (string array) (optional) + * @param enumHeaderString Header parameter enum test (string) (optional, default to -efg) + * @param enumQueryStringArray Query parameter enum test (string array) (optional) + * @param enumQueryString Query parameter enum test (string) (optional, default to -efg) + * @param enumQueryInteger Query parameter enum test (double) (optional) + * @param enumQueryDouble Query parameter enum test (double) (optional) + * @param enumFormStringArray Form parameter enum test (string array) (optional, default to $) + * @param enumFormString Form parameter enum test (string) (optional, default to -efg) + * @return Invalid request (status code 400) + * or Not found (status code 404) + * @see FakeApi#testEnumParameters + */ + public ResponseEntity testEnumParameters( + @Parameter(name = "enum_header_string_array", description = "Header parameter enum test (string array)", schema = @Schema(description = "", allowableValues = { ">", "$" })) @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray, + @Parameter(name = "enum_header_string", description = "Header parameter enum test (string)", schema = @Schema(description = "", allowableValues = { "_abc", "-efg", "(xyz)" }, defaultValue = "-efg")) @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString, + @Parameter(name = "enum_query_string_array", description = "Query parameter enum test (string array)", schema = @Schema(description = "", allowableValues = { ">", "$" })) @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, + @Parameter(name = "enum_query_string", description = "Query parameter enum test (string)", schema = @Schema(description = "", allowableValues = { "_abc", "-efg", "(xyz)" }, defaultValue = "-efg")) @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString, + @Parameter(name = "enum_query_integer", description = "Query parameter enum test (double)", schema = @Schema(description = "", allowableValues = { "1", "-2" })) @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, + @Parameter(name = "enum_query_double", description = "Query parameter enum test (double)", schema = @Schema(description = "", allowableValues = { "1.1", "-1.2" })) @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble, + @Parameter(name = "enum_form_string_array", description = "Form parameter enum test (string array)", schema = @Schema(description = "", allowableValues = { ">", "$" })) @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, + @Parameter(name = "enum_form_string", description = "Form parameter enum test (string)", schema = @Schema(description = "", allowableValues = { "_abc", "-efg", "(xyz)" }, defaultValue = "-efg")) @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * DELETE /fake : Fake endpoint to test group parameters (optional) + * Fake endpoint to test group parameters (optional) + * + * @param requiredStringGroup Required String in group parameters (required) + * @param requiredBooleanGroup Required Boolean in group parameters (required) + * @param requiredInt64Group Required Integer in group parameters (required) + * @param stringGroup String in group parameters (optional) + * @param booleanGroup Boolean in group parameters (optional) + * @param int64Group Integer in group parameters (optional) + * @return Someting wrong (status code 400) + * @see FakeApi#testGroupParameters + */ + public ResponseEntity testGroupParameters( + @NotNull @Parameter(name = "required_string_group", description = "Required String in group parameters", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup, + @Parameter(name = "required_boolean_group", description = "Required Boolean in group parameters", required = true, schema = @Schema(description = "")) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup, + @NotNull @Parameter(name = "required_int64_group", description = "Required Integer in group parameters", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group, + @Parameter(name = "string_group", description = "String in group parameters", schema = @Schema(description = "")) @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup, + @Parameter(name = "boolean_group", description = "Boolean in group parameters", schema = @Schema(description = "")) @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup, + @Parameter(name = "int64_group", description = "Integer in group parameters", schema = @Schema(description = "")) @Valid @RequestParam(value = "int64_group", required = false) Long int64Group + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * POST /fake/inline-additionalProperties : test inline additionalProperties + * + * @param param request body (required) + * @return successful operation (status code 200) + * @see FakeApi#testInlineAdditionalProperties + */ + public ResponseEntity testInlineAdditionalProperties( + @Parameter(name = "param", description = "request body", required = true, schema = @Schema(description = "")) @Valid @RequestBody Map param + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * GET /fake/jsonFormData : test json serialization of form data + * + * @param param field1 (required) + * @param param2 field2 (required) + * @return successful operation (status code 200) + * @see FakeApi#testJsonFormData + */ + public ResponseEntity testJsonFormData( + @Parameter(name = "param", description = "field1", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "param", required = true) String param, + @Parameter(name = "param2", description = "field2", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "param2", required = true) String param2 + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * PUT /fake/test-query-parameters + * To test the collection format in query parameters + * + * @param pipe (required) + * @param ioutil (required) + * @param http (required) + * @param url (required) + * @param context (required) + * @return Success (status code 200) + * @see FakeApi#testQueryParameterCollectionFormat + */ + public ResponseEntity testQueryParameterCollectionFormat( + @NotNull @Parameter(name = "pipe", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "pipe", required = true) List pipe, + @NotNull @Parameter(name = "ioutil", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "ioutil", required = true) List ioutil, + @NotNull @Parameter(name = "http", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "http", required = true) List http, + @NotNull @Parameter(name = "url", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "url", required = true) List url, + @NotNull @Parameter(name = "context", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "context", required = true) List context + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required) + * + * @param petId ID of pet to update (required) + * @param requiredFile file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @return successful operation (status code 200) + * @see FakeApi#uploadFileWithRequiredFile + */ + public ResponseEntity uploadFileWithRequiredFile( + @Parameter(name = "petId", description = "ID of pet to update", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "requiredFile", description = "file to upload", required = true, schema = @Schema(description = "")) @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, + @Parameter(name = "additionalMetadata", description = "Additional data to pass to server", schema = @Schema(description = "")) @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata + ) { + 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; + } + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeClassnameTestApi.java new file mode 100644 index 000000000000..5f640ca78deb --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -0,0 +1,58 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.openapitools.api; + +import org.openapitools.model.Client; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.ResponseEntity; +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; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "fake_classname_test", description = "the fake_classname_test API") +public interface FakeClassnameTestApi { + + /** + * PATCH /fake_classname_test : To test class name in snake case + * To test class name in snake case + * + * @param body client model (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "To test class name in snake case", + tags = { "fake_classname_tags 123#$%^" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Client.class))) + }, + security = { + @SecurityRequirement(name = "api_key_query") + } + ) + @RequestMapping( + method = RequestMethod.PATCH, + value = "/fake_classname_test", + produces = { "application/json" }, + consumes = { "application/json" } + ) + ResponseEntity testClassname( + @Parameter(name = "body", description = "client model", required = true, schema = @Schema(description = "")) @Valid @RequestBody Client body + ); + +} diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java new file mode 100644 index 000000000000..1f416d5ab25f --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java @@ -0,0 +1,63 @@ +package org.openapitools.api; + +import org.openapitools.model.Client; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +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.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.constraints.*; +import javax.validation.Valid; +import java.util.List; +import java.util.Map; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class FakeClassnameTestApiController implements FakeClassnameTestApi { + + private final NativeWebRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public FakeClassnameTestApiController(NativeWebRequest request) { + this.request = request; + } + + /** + * PATCH /fake_classname_test : To test class name in snake case + * To test class name in snake case + * + * @param body client model (required) + * @return successful operation (status code 200) + * @see FakeClassnameTestApi#testClassname + */ + public ResponseEntity testClassname( + @Parameter(name = "body", description = "client model", required = true, schema = @Schema(description = "")) @Valid @RequestBody Client body + ) { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"client\" : \"client\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/PetApi.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/PetApi.java new file mode 100644 index 000000000000..d4cbbab6f7b1 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/PetApi.java @@ -0,0 +1,272 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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 java.util.Set; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.ResponseEntity; +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; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "pet", description = "the pet API") +public interface PetApi { + + /** + * POST /pet : Add a new pet to the store + * + * @param body Pet object that needs to be added to the store (required) + * @return successful operation (status code 200) + * or Invalid input (status code 405) + */ + @Operation( + summary = "Add a new pet to the store", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation"), + @ApiResponse(responseCode = "405", description = "Invalid input") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet", + consumes = { "application/json", "application/xml" } + ) + ResponseEntity addPet( + @Parameter(name = "body", description = "Pet object that needs to be added to the store", required = true, schema = @Schema(description = "")) @Valid @RequestBody Pet body + ); + + + /** + * DELETE /pet/{petId} : Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @return successful operation (status code 200) + * or Invalid pet value (status code 400) + */ + @Operation( + summary = "Deletes a pet", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation"), + @ApiResponse(responseCode = "400", description = "Invalid pet value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/pet/{petId}" + ) + ResponseEntity deletePet( + @Parameter(name = "petId", description = "Pet id to delete", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "api_key", description = "", schema = @Schema(description = "")) @RequestHeader(value = "api_key", required = false) String 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) + */ + @Operation( + summary = "Finds Pets by status", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid status value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/findByStatus", + produces = { "application/xml", "application/json" } + ) + ResponseEntity> findPetsByStatus( + @NotNull @Parameter(name = "status", description = "Status values that need to be considered for filter", required = true, schema = @Schema(description = "", allowableValues = { "available", "pending", "sold" })) @Valid @RequestParam(value = "status", required = true) List 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 + */ + @Operation( + summary = "Finds Pets by tags", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid tag value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/findByTags", + produces = { "application/xml", "application/json" } + ) + ResponseEntity> findPetsByTags( + @NotNull @Parameter(name = "tags", description = "Tags to filter by", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "tags", required = true) Set 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) + */ + @Operation( + summary = "Find pet by ID", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/{petId}", + produces = { "application/xml", "application/json" } + ) + ResponseEntity getPetById( + @Parameter(name = "petId", description = "ID of pet to return", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId + ); + + + /** + * PUT /pet : Update an existing pet + * + * @param body 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) + */ + @Operation( + summary = "Update an existing pet", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation"), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found"), + @ApiResponse(responseCode = "405", description = "Validation exception") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/pet", + consumes = { "application/json", "application/xml" } + ) + ResponseEntity updatePet( + @Parameter(name = "body", description = "Pet object that needs to be added to the store", required = true, schema = @Schema(description = "")) @Valid @RequestBody Pet body + ); + + + /** + * 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) + */ + @Operation( + summary = "Updates a pet in the store with form data", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "405", description = "Invalid input") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet/{petId}", + consumes = { "application/x-www-form-urlencoded" } + ) + ResponseEntity updatePetWithForm( + @Parameter(name = "petId", description = "ID of pet that needs to be updated", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "name", description = "Updated name of the pet", schema = @Schema(description = "")) @Valid @RequestPart(value = "name", required = false) String name, + @Parameter(name = "status", description = "Updated status of the pet", schema = @Schema(description = "")) @Valid @RequestPart(value = "status", required = false) String 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) + */ + @Operation( + summary = "uploads an image", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ModelApiResponse.class))) + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet/{petId}/uploadImage", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) + ResponseEntity uploadFile( + @Parameter(name = "petId", description = "ID of pet to update", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "additionalMetadata", description = "Additional data to pass to server", schema = @Schema(description = "")) @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @Parameter(name = "file", description = "file to upload", schema = @Schema(description = "")) @RequestPart(value = "file", required = false) MultipartFile file + ); + +} diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/PetApiController.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/PetApiController.java new file mode 100644 index 000000000000..47d4ffcdb9d9 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/PetApiController.java @@ -0,0 +1,221 @@ +package org.openapitools.api; + +import org.openapitools.model.ModelApiResponse; +import org.openapitools.model.Pet; +import java.util.Set; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +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.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.constraints.*; +import javax.validation.Valid; +import java.util.List; +import java.util.Map; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class PetApiController implements PetApi { + + private final NativeWebRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public PetApiController(NativeWebRequest request) { + this.request = request; + } + + /** + * POST /pet : Add a new pet to the store + * + * @param body 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 + */ + public ResponseEntity addPet( + @Parameter(name = "body", description = "Pet object that needs to be added to the store", required = true, schema = @Schema(description = "")) @Valid @RequestBody Pet body + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * DELETE /pet/{petId} : Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @return successful operation (status code 200) + * or Invalid pet value (status code 400) + * @see PetApi#deletePet + */ + public ResponseEntity deletePet( + @Parameter(name = "petId", description = "Pet id to delete", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "api_key", description = "", schema = @Schema(description = "")) @RequestHeader(value = "api_key", required = false) String apiKey + ) { + return new ResponseEntity<>(HttpStatus.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 + */ + public ResponseEntity> findPetsByStatus( + @NotNull @Parameter(name = "status", description = "Status values that need to be considered for filter", required = true, schema = @Schema(description = "", allowableValues = { "available", "pending", "sold" })) @Valid @RequestParam(value = "status", required = true) List status + ) { + 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\" : \"default-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 = " 123456789 doggie aeiou aeiou "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + return new ResponseEntity<>(HttpStatus.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 + */ + public ResponseEntity> findPetsByTags( + @NotNull @Parameter(name = "tags", description = "Tags to filter by", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "tags", required = true) Set tags + ) { + 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\" : \"default-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 = " 123456789 doggie aeiou aeiou "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + return new ResponseEntity<>(HttpStatus.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 + */ + public ResponseEntity getPetById( + @Parameter(name = "petId", description = "ID of pet to return", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId + ) { + 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\" : \"default-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 = " 123456789 doggie aeiou aeiou "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * PUT /pet : Update an existing pet + * + * @param body 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) + * @see PetApi#updatePet + */ + public ResponseEntity updatePet( + @Parameter(name = "body", description = "Pet object that needs to be added to the store", required = true, schema = @Schema(description = "")) @Valid @RequestBody Pet body + ) { + return new ResponseEntity<>(HttpStatus.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 + */ + public ResponseEntity updatePetWithForm( + @Parameter(name = "petId", description = "ID of pet that needs to be updated", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "name", description = "Updated name of the pet", schema = @Schema(description = "")) @Valid @RequestPart(value = "name", required = false) String name, + @Parameter(name = "status", description = "Updated status of the pet", schema = @Schema(description = "")) @Valid @RequestPart(value = "status", required = false) String status + ) { + return new ResponseEntity<>(HttpStatus.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 + */ + public ResponseEntity uploadFile( + @Parameter(name = "petId", description = "ID of pet to update", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "additionalMetadata", description = "Additional data to pass to server", schema = @Schema(description = "")) @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @Parameter(name = "file", description = "file to upload", schema = @Schema(description = "")) @RequestPart(value = "file", required = false) MultipartFile file + ) { + 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; + } + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/StoreApi.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/StoreApi.java new file mode 100644 index 000000000000..26389c13ef58 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/StoreApi.java @@ -0,0 +1,135 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.ResponseEntity; +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; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "store", description = "the store API") +public interface StoreApi { + + /** + * DELETE /store/order/{order_id} : 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) + */ + @Operation( + summary = "Delete purchase order by ID", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/store/order/{order_id}" + ) + ResponseEntity deleteOrder( + @Parameter(name = "order_id", description = "ID of the order that needs to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("order_id") String orderId + ); + + + /** + * GET /store/inventory : Returns pet inventories by status + * Returns a map of status codes to quantities + * + * @return successful operation (status code 200) + */ + @Operation( + summary = "Returns pet inventories by status", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Map.class))) + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/store/inventory", + produces = { "application/json" } + ) + ResponseEntity> getInventory( + + ); + + + /** + * GET /store/order/{order_id} : Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated 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) + */ + @Operation( + summary = "Find purchase order by ID", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/store/order/{order_id}", + produces = { "application/xml", "application/json" } + ) + ResponseEntity getOrderById( + @Min(1L) @Max(5L) @Parameter(name = "order_id", description = "ID of pet that needs to be fetched", required = true, schema = @Schema(description = "")) @PathVariable("order_id") Long orderId + ); + + + /** + * POST /store/order : Place an order for a pet + * + * @param body order placed for purchasing the pet (required) + * @return successful operation (status code 200) + * or Invalid Order (status code 400) + */ + @Operation( + summary = "Place an order for a pet", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid Order") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/store/order", + produces = { "application/xml", "application/json" } + ) + ResponseEntity placeOrder( + @Parameter(name = "body", description = "order placed for purchasing the pet", required = true, schema = @Schema(description = "")) @Valid @RequestBody Order body + ); + +} diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/StoreApiController.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/StoreApiController.java new file mode 100644 index 000000000000..91b88d0652f3 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/StoreApiController.java @@ -0,0 +1,128 @@ +package org.openapitools.api; + +import java.util.Map; +import org.openapitools.model.Order; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +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.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.constraints.*; +import javax.validation.Valid; +import java.util.List; +import java.util.Map; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class StoreApiController implements StoreApi { + + private final NativeWebRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public StoreApiController(NativeWebRequest request) { + this.request = request; + } + + /** + * DELETE /store/order/{order_id} : 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 + */ + public ResponseEntity deleteOrder( + @Parameter(name = "order_id", description = "ID of the order that needs to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("order_id") String orderId + ) { + return new ResponseEntity<>(HttpStatus.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 + */ + public ResponseEntity> getInventory( + + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * GET /store/order/{order_id} : Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated 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 + */ + public ResponseEntity getOrderById( + @Min(1L) @Max(5L) @Parameter(name = "order_id", description = "ID of pet that needs to be fetched", required = true, schema = @Schema(description = "")) @PathVariable("order_id") Long orderId + ) { + 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 = " 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * POST /store/order : Place an order for a pet + * + * @param body order placed for purchasing the pet (required) + * @return successful operation (status code 200) + * or Invalid Order (status code 400) + * @see StoreApi#placeOrder + */ + public ResponseEntity placeOrder( + @Parameter(name = "body", description = "order placed for purchasing the pet", required = true, schema = @Schema(description = "")) @Valid @RequestBody Order body + ) { + 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 = " 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/UserApi.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/UserApi.java new file mode 100644 index 000000000000..3cdc6eeed919 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/UserApi.java @@ -0,0 +1,226 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.openapitools.api; + +import java.util.List; +import org.threeten.bp.OffsetDateTime; +import org.openapitools.model.User; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.ResponseEntity; +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; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "user", description = "the user API") +public interface UserApi { + + /** + * POST /user : Create user + * This can only be done by the logged in user. + * + * @param body Created user object (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "Create user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user" + ) + ResponseEntity createUser( + @Parameter(name = "body", description = "Created user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody User body + ); + + + /** + * POST /user/createWithArray : Creates list of users with given input array + * + * @param body List of user object (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "Creates list of users with given input array", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user/createWithArray" + ) + ResponseEntity createUsersWithArrayInput( + @Parameter(name = "body", description = "List of user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody List body + ); + + + /** + * POST /user/createWithList : Creates list of users with given input array + * + * @param body List of user object (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "Creates list of users with given input array", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user/createWithList" + ) + ResponseEntity createUsersWithListInput( + @Parameter(name = "body", description = "List of user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody List body + ); + + + /** + * 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) + */ + @Operation( + summary = "Delete user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/user/{username}" + ) + ResponseEntity deleteUser( + @Parameter(name = "username", description = "The name that needs to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("username") String 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) + */ + @Operation( + summary = "Get user by user name", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = User.class))), + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/{username}", + produces = { "application/xml", "application/json" } + ) + ResponseEntity getUserByName( + @Parameter(name = "username", description = "The name that needs to be fetched. Use user1 for testing.", required = true, schema = @Schema(description = "")) @PathVariable("username") String 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) + */ + @Operation( + summary = "Logs user into the system", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "400", description = "Invalid username/password supplied") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/login", + produces = { "application/xml", "application/json" } + ) + ResponseEntity loginUser( + @NotNull @Parameter(name = "username", description = "The user name for login", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "username", required = true) String username, + @NotNull @Parameter(name = "password", description = "The password for login in clear text", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "password", required = true) String password + ); + + + /** + * GET /user/logout : Logs out current logged in user session + * + * @return successful operation (status code 200) + */ + @Operation( + summary = "Logs out current logged in user session", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/logout" + ) + ResponseEntity 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 body Updated user object (required) + * @return Invalid user supplied (status code 400) + * or User not found (status code 404) + */ + @Operation( + summary = "Updated user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid user supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/user/{username}" + ) + ResponseEntity updateUser( + @Parameter(name = "username", description = "name that need to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("username") String username, + @Parameter(name = "body", description = "Updated user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody User body + ); + +} diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/UserApiController.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/UserApiController.java new file mode 100644 index 000000000000..c77024353b9c --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/UserApiController.java @@ -0,0 +1,178 @@ +package org.openapitools.api; + +import java.util.List; +import org.threeten.bp.OffsetDateTime; +import org.openapitools.model.User; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +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.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.constraints.*; +import javax.validation.Valid; +import java.util.List; +import java.util.Map; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class UserApiController implements UserApi { + + private final NativeWebRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public UserApiController(NativeWebRequest request) { + this.request = request; + } + + /** + * POST /user : Create user + * This can only be done by the logged in user. + * + * @param body Created user object (required) + * @return successful operation (status code 200) + * @see UserApi#createUser + */ + public ResponseEntity createUser( + @Parameter(name = "body", description = "Created user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody User body + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * POST /user/createWithArray : Creates list of users with given input array + * + * @param body List of user object (required) + * @return successful operation (status code 200) + * @see UserApi#createUsersWithArrayInput + */ + public ResponseEntity createUsersWithArrayInput( + @Parameter(name = "body", description = "List of user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody List body + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * POST /user/createWithList : Creates list of users with given input array + * + * @param body List of user object (required) + * @return successful operation (status code 200) + * @see UserApi#createUsersWithListInput + */ + public ResponseEntity createUsersWithListInput( + @Parameter(name = "body", description = "List of user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody List body + ) { + return new ResponseEntity<>(HttpStatus.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 + */ + public ResponseEntity deleteUser( + @Parameter(name = "username", description = "The name that needs to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("username") String username + ) { + return new ResponseEntity<>(HttpStatus.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 + */ + public ResponseEntity getUserByName( + @Parameter(name = "username", description = "The name that needs to be fetched. Use user1 for testing.", required = true, schema = @Schema(description = "")) @PathVariable("username") String username + ) { + 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 = " 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123 "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + return new ResponseEntity<>(HttpStatus.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 + */ + public ResponseEntity loginUser( + @NotNull @Parameter(name = "username", description = "The user name for login", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "username", required = true) String username, + @NotNull @Parameter(name = "password", description = "The password for login in clear text", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "password", required = true) String password + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * GET /user/logout : Logs out current logged in user session + * + * @return successful operation (status code 200) + * @see UserApi#logoutUser + */ + public ResponseEntity logoutUser( + + ) { + return new ResponseEntity<>(HttpStatus.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 body Updated user object (required) + * @return Invalid user supplied (status code 400) + * or User not found (status code 404) + * @see UserApi#updateUser + */ + public ResponseEntity updateUser( + @Parameter(name = "username", description = "name that need to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("username") String username, + @Parameter(name = "body", description = "Updated user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody User body + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java new file mode 100644 index 000000000000..8f936b311447 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java @@ -0,0 +1,232 @@ +package org.openapitools.configuration; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonTokenId; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.datatype.threetenbp.DecimalUtils; +import com.fasterxml.jackson.datatype.threetenbp.deser.ThreeTenDateTimeDeserializerBase; +import com.fasterxml.jackson.datatype.threetenbp.function.BiFunction; +import com.fasterxml.jackson.datatype.threetenbp.function.Function; +import org.threeten.bp.DateTimeException; +import org.threeten.bp.DateTimeUtils; +import org.threeten.bp.Instant; +import org.threeten.bp.OffsetDateTime; +import org.threeten.bp.ZoneId; +import org.threeten.bp.ZonedDateTime; +import org.threeten.bp.format.DateTimeFormatter; +import org.threeten.bp.temporal.Temporal; +import org.threeten.bp.temporal.TemporalAccessor; + +import java.io.IOException; +import java.math.BigDecimal; + +/** + * Deserializer for ThreeTen temporal {@link Instant}s, {@link OffsetDateTime}, and {@link ZonedDateTime}s. + * Adapted from the jackson threetenbp InstantDeserializer to add support for deserializing rfc822 format. + * + * @author Nick Williams + */ +public class CustomInstantDeserializer + extends ThreeTenDateTimeDeserializerBase { + private static final long serialVersionUID = 1L; + + public static final CustomInstantDeserializer INSTANT = new CustomInstantDeserializer( + Instant.class, DateTimeFormatter.ISO_INSTANT, + new Function() { + @Override + public Instant apply(TemporalAccessor temporalAccessor) { + return Instant.from(temporalAccessor); + } + }, + new Function() { + @Override + public Instant apply(FromIntegerArguments a) { + return Instant.ofEpochMilli(a.value); + } + }, + new Function() { + @Override + public Instant apply(FromDecimalArguments a) { + return Instant.ofEpochSecond(a.integer, a.fraction); + } + }, + null + ); + + public static final CustomInstantDeserializer OFFSET_DATE_TIME = new CustomInstantDeserializer( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + new Function() { + @Override + public OffsetDateTime apply(TemporalAccessor temporalAccessor) { + return OffsetDateTime.from(temporalAccessor); + } + }, + new Function() { + @Override + public OffsetDateTime apply(FromIntegerArguments a) { + return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); + } + }, + new Function() { + @Override + public OffsetDateTime apply(FromDecimalArguments a) { + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); + } + }, + new BiFunction() { + @Override + public OffsetDateTime apply(OffsetDateTime d, ZoneId z) { + return d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime())); + } + } + ); + + public static final CustomInstantDeserializer ZONED_DATE_TIME = new CustomInstantDeserializer( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + new Function() { + @Override + public ZonedDateTime apply(TemporalAccessor temporalAccessor) { + return ZonedDateTime.from(temporalAccessor); + } + }, + new Function() { + @Override + public ZonedDateTime apply(FromIntegerArguments a) { + return ZonedDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); + } + }, + new Function() { + @Override + public ZonedDateTime apply(FromDecimalArguments a) { + return ZonedDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); + } + }, + new BiFunction() { + @Override + public ZonedDateTime apply(ZonedDateTime zonedDateTime, ZoneId zoneId) { + return zonedDateTime.withZoneSameInstant(zoneId); + } + } + ); + + protected final Function fromMilliseconds; + + protected final Function fromNanoseconds; + + protected final Function parsedToValue; + + protected final BiFunction adjust; + + protected CustomInstantDeserializer(Class supportedType, + DateTimeFormatter parser, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust) { + super(supportedType, parser); + this.parsedToValue = parsedToValue; + this.fromMilliseconds = fromMilliseconds; + this.fromNanoseconds = fromNanoseconds; + this.adjust = adjust == null ? new BiFunction() { + @Override + public T apply(T t, ZoneId zoneId) { + return t; + } + } : adjust; + } + + @SuppressWarnings("unchecked") + protected CustomInstantDeserializer(CustomInstantDeserializer base, DateTimeFormatter f) { + super((Class) base.handledType(), f); + parsedToValue = base.parsedToValue; + fromMilliseconds = base.fromMilliseconds; + fromNanoseconds = base.fromNanoseconds; + adjust = base.adjust; + } + + @Override + protected JsonDeserializer withDateFormat(DateTimeFormatter dtf) { + if (dtf == _formatter) { + return this; + } + return new CustomInstantDeserializer(this, dtf); + } + + @Override + public T deserialize(JsonParser parser, DeserializationContext context) throws IOException { + //NOTE: Timestamps contain no timezone info, and are always in configured TZ. Only + //string values have to be adjusted to the configured TZ. + switch (parser.getCurrentTokenId()) { + case JsonTokenId.ID_NUMBER_FLOAT: { + BigDecimal value = parser.getDecimalValue(); + long seconds = value.longValue(); + int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds); + return fromNanoseconds.apply(new FromDecimalArguments( + seconds, nanoseconds, getZone(context))); + } + + case JsonTokenId.ID_NUMBER_INT: { + long timestamp = parser.getLongValue(); + if (context.isEnabled(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)) { + return this.fromNanoseconds.apply(new FromDecimalArguments( + timestamp, 0, this.getZone(context) + )); + } + return this.fromMilliseconds.apply(new FromIntegerArguments( + timestamp, this.getZone(context) + )); + } + + case JsonTokenId.ID_STRING: { + String string = parser.getText().trim(); + if (string.length() == 0) { + return null; + } + if (string.endsWith("+0000")) { + string = string.substring(0, string.length() - 5) + "Z"; + } + T value; + try { + TemporalAccessor acc = _formatter.parse(string); + value = parsedToValue.apply(acc); + if (context.isEnabled(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)) { + return adjust.apply(value, this.getZone(context)); + } + } catch (DateTimeException e) { + throw _peelDTE(e); + } + return value; + } + } + throw context.mappingException("Expected type float, integer, or string."); + } + + private ZoneId getZone(DeserializationContext context) { + // Instants are always in UTC, so don't waste compute cycles + return (_valueClass == Instant.class) ? null : DateTimeUtils.toZoneId(context.getTimeZone()); + } + + private static class FromIntegerArguments { + public final long value; + public final ZoneId zoneId; + + private FromIntegerArguments(long value, ZoneId zoneId) { + this.value = value; + this.zoneId = zoneId; + } + } + + private static class FromDecimalArguments { + public final long integer; + public final int fraction; + public final ZoneId zoneId; + + private FromDecimalArguments(long integer, int fraction, ZoneId zoneId) { + this.integer = integer; + this.fraction = fraction; + this.zoneId = zoneId; + } + } +} diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/HomeController.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/HomeController.java new file mode 100644 index 000000000000..34bae16b8986 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/HomeController.java @@ -0,0 +1,53 @@ +package org.openapitools.configuration; + +import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.core.io.Resource; +import org.springframework.stereotype.Controller; +import org.springframework.util.StreamUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.Charset; + +/** + * Home redirection to OpenAPI api documentation + */ +@Controller +public class HomeController { + + private static YAMLMapper yamlMapper = new YAMLMapper(); + + @Value("classpath:/openapi.yaml") + private Resource openapi; + + @Bean + public String openapiContent() throws IOException { + try(InputStream is = openapi.getInputStream()) { + return StreamUtils.copyToString(is, Charset.defaultCharset()); + } + } + + @GetMapping(value = "/openapi.yaml", produces = "application/vnd.oai.openapi") + @ResponseBody + public String openapiYaml() throws IOException { + return openapiContent(); + } + + @GetMapping(value = "/openapi.json", produces = "application/json") + @ResponseBody + public Object openapiJson() throws IOException { + return yamlMapper.readValue(openapiContent(), Object.class); + } + + @RequestMapping("/") + public String index() { + return "redirect:swagger-ui/index.html?url=../openapi.json"; + } + + +} diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/JacksonConfiguration.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/JacksonConfiguration.java new file mode 100644 index 000000000000..b481a87518f4 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/JacksonConfiguration.java @@ -0,0 +1,23 @@ +package org.openapitools.configuration; + +import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.threeten.bp.Instant; +import org.threeten.bp.OffsetDateTime; +import org.threeten.bp.ZonedDateTime; + +@Configuration +public class JacksonConfiguration { + + @Bean + @ConditionalOnMissingBean(ThreeTenModule.class) + ThreeTenModule threeTenModule() { + ThreeTenModule module = new ThreeTenModule(); + module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT); + module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME); + module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME); + return module; + } +} diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java new file mode 100644 index 000000000000..70f6bb0d1c47 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java @@ -0,0 +1,84 @@ +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 java.util.HashMap; +import java.util.Map; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesAnyType + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesAnyType extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesAnyType name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesAnyType additionalPropertiesAnyType = (AdditionalPropertiesAnyType) o; + return Objects.equals(this.name, additionalPropertiesAnyType.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesAnyType {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/AdditionalPropertiesArray.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/AdditionalPropertiesArray.java new file mode 100644 index 000000000000..ceb28401cd5e --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/AdditionalPropertiesArray.java @@ -0,0 +1,85 @@ +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 java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesArray + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesArray extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesArray name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesArray additionalPropertiesArray = (AdditionalPropertiesArray) o; + return Objects.equals(this.name, additionalPropertiesArray.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesArray {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java new file mode 100644 index 000000000000..9455c14cd5fd --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java @@ -0,0 +1,84 @@ +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 java.util.HashMap; +import java.util.Map; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesBoolean + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesBoolean extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesBoolean name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesBoolean additionalPropertiesBoolean = (AdditionalPropertiesBoolean) o; + return Objects.equals(this.name, additionalPropertiesBoolean.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesBoolean {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java new file mode 100644 index 000000000000..69e4ba3737e9 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java @@ -0,0 +1,412 @@ +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 java.math.BigDecimal; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesClass + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesClass { + @JsonProperty("map_string") + @Valid + private Map mapString = null; + + @JsonProperty("map_number") + @Valid + private Map mapNumber = null; + + @JsonProperty("map_integer") + @Valid + private Map mapInteger = null; + + @JsonProperty("map_boolean") + @Valid + private Map mapBoolean = null; + + @JsonProperty("map_array_integer") + @Valid + private Map> mapArrayInteger = null; + + @JsonProperty("map_array_anytype") + @Valid + private Map> mapArrayAnytype = null; + + @JsonProperty("map_map_string") + @Valid + private Map> mapMapString = null; + + @JsonProperty("map_map_anytype") + @Valid + private Map> mapMapAnytype = null; + + @JsonProperty("anytype_1") + private Object anytype1; + + @JsonProperty("anytype_2") + private Object anytype2; + + @JsonProperty("anytype_3") + private Object anytype3; + + public AdditionalPropertiesClass mapString(Map mapString) { + this.mapString = mapString; + return this; + } + + public AdditionalPropertiesClass putMapStringItem(String key, String mapStringItem) { + if (this.mapString == null) { + this.mapString = new HashMap(); + } + this.mapString.put(key, mapStringItem); + return this; + } + + /** + * Get mapString + * @return mapString + */ + @Schema(name = "mapString", defaultValue = "") + + + public Map getMapString() { + return mapString; + } + + public void setMapString(Map mapString) { + this.mapString = mapString; + } + + public AdditionalPropertiesClass mapNumber(Map mapNumber) { + this.mapNumber = mapNumber; + return this; + } + + public AdditionalPropertiesClass putMapNumberItem(String key, BigDecimal mapNumberItem) { + if (this.mapNumber == null) { + this.mapNumber = new HashMap(); + } + this.mapNumber.put(key, mapNumberItem); + return this; + } + + /** + * Get mapNumber + * @return mapNumber + */ + @Schema(name = "mapNumber", defaultValue = "") + + @Valid + + public Map getMapNumber() { + return mapNumber; + } + + public void setMapNumber(Map mapNumber) { + this.mapNumber = mapNumber; + } + + public AdditionalPropertiesClass mapInteger(Map mapInteger) { + this.mapInteger = mapInteger; + return this; + } + + public AdditionalPropertiesClass putMapIntegerItem(String key, Integer mapIntegerItem) { + if (this.mapInteger == null) { + this.mapInteger = new HashMap(); + } + this.mapInteger.put(key, mapIntegerItem); + return this; + } + + /** + * Get mapInteger + * @return mapInteger + */ + @Schema(name = "mapInteger", defaultValue = "") + + + public Map getMapInteger() { + return mapInteger; + } + + public void setMapInteger(Map mapInteger) { + this.mapInteger = mapInteger; + } + + public AdditionalPropertiesClass mapBoolean(Map mapBoolean) { + this.mapBoolean = mapBoolean; + return this; + } + + public AdditionalPropertiesClass putMapBooleanItem(String key, Boolean mapBooleanItem) { + if (this.mapBoolean == null) { + this.mapBoolean = new HashMap(); + } + this.mapBoolean.put(key, mapBooleanItem); + return this; + } + + /** + * Get mapBoolean + * @return mapBoolean + */ + @Schema(name = "mapBoolean", defaultValue = "") + + + public Map getMapBoolean() { + return mapBoolean; + } + + public void setMapBoolean(Map mapBoolean) { + this.mapBoolean = mapBoolean; + } + + public AdditionalPropertiesClass mapArrayInteger(Map> mapArrayInteger) { + this.mapArrayInteger = mapArrayInteger; + return this; + } + + public AdditionalPropertiesClass putMapArrayIntegerItem(String key, List mapArrayIntegerItem) { + if (this.mapArrayInteger == null) { + this.mapArrayInteger = new HashMap>(); + } + this.mapArrayInteger.put(key, mapArrayIntegerItem); + return this; + } + + /** + * Get mapArrayInteger + * @return mapArrayInteger + */ + @Schema(name = "mapArrayInteger", defaultValue = "") + + @Valid + + public Map> getMapArrayInteger() { + return mapArrayInteger; + } + + public void setMapArrayInteger(Map> mapArrayInteger) { + this.mapArrayInteger = mapArrayInteger; + } + + public AdditionalPropertiesClass mapArrayAnytype(Map> mapArrayAnytype) { + this.mapArrayAnytype = mapArrayAnytype; + return this; + } + + public AdditionalPropertiesClass putMapArrayAnytypeItem(String key, List mapArrayAnytypeItem) { + if (this.mapArrayAnytype == null) { + this.mapArrayAnytype = new HashMap>(); + } + this.mapArrayAnytype.put(key, mapArrayAnytypeItem); + return this; + } + + /** + * Get mapArrayAnytype + * @return mapArrayAnytype + */ + @Schema(name = "mapArrayAnytype", defaultValue = "") + + @Valid + + public Map> getMapArrayAnytype() { + return mapArrayAnytype; + } + + public void setMapArrayAnytype(Map> mapArrayAnytype) { + this.mapArrayAnytype = mapArrayAnytype; + } + + public AdditionalPropertiesClass mapMapString(Map> mapMapString) { + this.mapMapString = mapMapString; + return this; + } + + public AdditionalPropertiesClass putMapMapStringItem(String key, Map mapMapStringItem) { + if (this.mapMapString == null) { + this.mapMapString = new HashMap>(); + } + this.mapMapString.put(key, mapMapStringItem); + return this; + } + + /** + * Get mapMapString + * @return mapMapString + */ + @Schema(name = "mapMapString", defaultValue = "") + + @Valid + + public Map> getMapMapString() { + return mapMapString; + } + + public void setMapMapString(Map> mapMapString) { + this.mapMapString = mapMapString; + } + + public AdditionalPropertiesClass mapMapAnytype(Map> mapMapAnytype) { + this.mapMapAnytype = mapMapAnytype; + return this; + } + + public AdditionalPropertiesClass putMapMapAnytypeItem(String key, Map mapMapAnytypeItem) { + if (this.mapMapAnytype == null) { + this.mapMapAnytype = new HashMap>(); + } + this.mapMapAnytype.put(key, mapMapAnytypeItem); + return this; + } + + /** + * Get mapMapAnytype + * @return mapMapAnytype + */ + @Schema(name = "mapMapAnytype", defaultValue = "") + + @Valid + + public Map> getMapMapAnytype() { + return mapMapAnytype; + } + + public void setMapMapAnytype(Map> mapMapAnytype) { + this.mapMapAnytype = mapMapAnytype; + } + + public AdditionalPropertiesClass anytype1(Object anytype1) { + this.anytype1 = anytype1; + return this; + } + + /** + * Get anytype1 + * @return anytype1 + */ + @Schema(name = "anytype1", defaultValue = "") + + + public Object getAnytype1() { + return anytype1; + } + + public void setAnytype1(Object anytype1) { + this.anytype1 = anytype1; + } + + public AdditionalPropertiesClass anytype2(Object anytype2) { + this.anytype2 = anytype2; + return this; + } + + /** + * Get anytype2 + * @return anytype2 + */ + @Schema(name = "anytype2", defaultValue = "") + + + public Object getAnytype2() { + return anytype2; + } + + public void setAnytype2(Object anytype2) { + this.anytype2 = anytype2; + } + + public AdditionalPropertiesClass anytype3(Object anytype3) { + this.anytype3 = anytype3; + return this; + } + + /** + * Get anytype3 + * @return anytype3 + */ + @Schema(name = "anytype3", defaultValue = "") + + + public Object getAnytype3() { + return anytype3; + } + + public void setAnytype3(Object anytype3) { + this.anytype3 = anytype3; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AdditionalPropertiesClass additionalPropertiesClass = (AdditionalPropertiesClass) o; + return Objects.equals(this.mapString, additionalPropertiesClass.mapString) && + Objects.equals(this.mapNumber, additionalPropertiesClass.mapNumber) && + Objects.equals(this.mapInteger, additionalPropertiesClass.mapInteger) && + Objects.equals(this.mapBoolean, additionalPropertiesClass.mapBoolean) && + Objects.equals(this.mapArrayInteger, additionalPropertiesClass.mapArrayInteger) && + Objects.equals(this.mapArrayAnytype, additionalPropertiesClass.mapArrayAnytype) && + Objects.equals(this.mapMapString, additionalPropertiesClass.mapMapString) && + Objects.equals(this.mapMapAnytype, additionalPropertiesClass.mapMapAnytype) && + Objects.equals(this.anytype1, additionalPropertiesClass.anytype1) && + Objects.equals(this.anytype2, additionalPropertiesClass.anytype2) && + Objects.equals(this.anytype3, additionalPropertiesClass.anytype3); + } + + @Override + public int hashCode() { + return Objects.hash(mapString, mapNumber, mapInteger, mapBoolean, mapArrayInteger, mapArrayAnytype, mapMapString, mapMapAnytype, anytype1, anytype2, anytype3); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesClass {\n"); + + sb.append(" mapString: ").append(toIndentedString(mapString)).append("\n"); + sb.append(" mapNumber: ").append(toIndentedString(mapNumber)).append("\n"); + sb.append(" mapInteger: ").append(toIndentedString(mapInteger)).append("\n"); + sb.append(" mapBoolean: ").append(toIndentedString(mapBoolean)).append("\n"); + sb.append(" mapArrayInteger: ").append(toIndentedString(mapArrayInteger)).append("\n"); + sb.append(" mapArrayAnytype: ").append(toIndentedString(mapArrayAnytype)).append("\n"); + sb.append(" mapMapString: ").append(toIndentedString(mapMapString)).append("\n"); + sb.append(" mapMapAnytype: ").append(toIndentedString(mapMapAnytype)).append("\n"); + sb.append(" anytype1: ").append(toIndentedString(anytype1)).append("\n"); + sb.append(" anytype2: ").append(toIndentedString(anytype2)).append("\n"); + sb.append(" anytype3: ").append(toIndentedString(anytype3)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java new file mode 100644 index 000000000000..fb06ae322e26 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java @@ -0,0 +1,84 @@ +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 java.util.HashMap; +import java.util.Map; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesInteger + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesInteger extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesInteger name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesInteger additionalPropertiesInteger = (AdditionalPropertiesInteger) o; + return Objects.equals(this.name, additionalPropertiesInteger.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesInteger {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java new file mode 100644 index 000000000000..71868e473357 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java @@ -0,0 +1,85 @@ +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 java.math.BigDecimal; +import java.util.HashMap; +import java.util.Map; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesNumber + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesNumber extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesNumber name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesNumber additionalPropertiesNumber = (AdditionalPropertiesNumber) o; + return Objects.equals(this.name, additionalPropertiesNumber.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesNumber {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/AdditionalPropertiesObject.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/AdditionalPropertiesObject.java new file mode 100644 index 000000000000..75db554b3295 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/AdditionalPropertiesObject.java @@ -0,0 +1,84 @@ +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 java.util.HashMap; +import java.util.Map; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesObject + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesObject extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesObject name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesObject additionalPropertiesObject = (AdditionalPropertiesObject) o; + return Objects.equals(this.name, additionalPropertiesObject.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesObject {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/AdditionalPropertiesString.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/AdditionalPropertiesString.java new file mode 100644 index 000000000000..aa62e4fbb2ea --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/AdditionalPropertiesString.java @@ -0,0 +1,84 @@ +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 java.util.HashMap; +import java.util.Map; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesString + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesString extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesString name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesString additionalPropertiesString = (AdditionalPropertiesString) o; + return Objects.equals(this.name, additionalPropertiesString.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesString {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Animal.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Animal.java new file mode 100644 index 000000000000..26eeb264a74d --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Animal.java @@ -0,0 +1,116 @@ +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.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Animal + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "className", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = BigCat.class, name = "BigCat"), + @JsonSubTypes.Type(value = Cat.class, name = "Cat"), + @JsonSubTypes.Type(value = Dog.class, name = "Dog"), +}) + +public class Animal { + @JsonProperty("className") + private String className; + + @JsonProperty("color") + private String color = "red"; + + public Animal className(String className) { + this.className = className; + return this; + } + + /** + * Get className + * @return className + */ + @Schema(name = "className", required = true, defaultValue = "") + @NotNull + + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public Animal color(String color) { + this.color = color; + return this; + } + + /** + * Get color + * @return color + */ + @Schema(name = "color", defaultValue = "") + + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Animal animal = (Animal) o; + return Objects.equals(this.className, animal.className) && + Objects.equals(this.color, animal.color); + } + + @Override + public int hashCode() { + return Objects.hash(className, color); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Animal {\n"); + + sb.append(" className: ").append(toIndentedString(className)).append("\n"); + sb.append(" color: ").append(toIndentedString(color)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java new file mode 100644 index 000000000000..436750d2ef67 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java @@ -0,0 +1,94 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ArrayOfArrayOfNumberOnly + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ArrayOfArrayOfNumberOnly { + @JsonProperty("ArrayArrayNumber") + @Valid + private List> arrayArrayNumber = null; + + public ArrayOfArrayOfNumberOnly arrayArrayNumber(List> arrayArrayNumber) { + this.arrayArrayNumber = arrayArrayNumber; + return this; + } + + public ArrayOfArrayOfNumberOnly addArrayArrayNumberItem(List arrayArrayNumberItem) { + if (this.arrayArrayNumber == null) { + this.arrayArrayNumber = new ArrayList>(); + } + this.arrayArrayNumber.add(arrayArrayNumberItem); + return this; + } + + /** + * Get arrayArrayNumber + * @return arrayArrayNumber + */ + @Schema(name = "arrayArrayNumber", defaultValue = "") + + @Valid + + public List> getArrayArrayNumber() { + return arrayArrayNumber; + } + + public void setArrayArrayNumber(List> arrayArrayNumber) { + this.arrayArrayNumber = arrayArrayNumber; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly = (ArrayOfArrayOfNumberOnly) o; + return Objects.equals(this.arrayArrayNumber, arrayOfArrayOfNumberOnly.arrayArrayNumber); + } + + @Override + public int hashCode() { + return Objects.hash(arrayArrayNumber); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayOfArrayOfNumberOnly {\n"); + + sb.append(" arrayArrayNumber: ").append(toIndentedString(arrayArrayNumber)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ArrayOfNumberOnly.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ArrayOfNumberOnly.java new file mode 100644 index 000000000000..da9c15f73dd1 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ArrayOfNumberOnly.java @@ -0,0 +1,94 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ArrayOfNumberOnly + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ArrayOfNumberOnly { + @JsonProperty("ArrayNumber") + @Valid + private List arrayNumber = null; + + public ArrayOfNumberOnly arrayNumber(List arrayNumber) { + this.arrayNumber = arrayNumber; + return this; + } + + public ArrayOfNumberOnly addArrayNumberItem(BigDecimal arrayNumberItem) { + if (this.arrayNumber == null) { + this.arrayNumber = new ArrayList(); + } + this.arrayNumber.add(arrayNumberItem); + return this; + } + + /** + * Get arrayNumber + * @return arrayNumber + */ + @Schema(name = "arrayNumber", defaultValue = "") + + @Valid + + public List getArrayNumber() { + return arrayNumber; + } + + public void setArrayNumber(List arrayNumber) { + this.arrayNumber = arrayNumber; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayOfNumberOnly arrayOfNumberOnly = (ArrayOfNumberOnly) o; + return Objects.equals(this.arrayNumber, arrayOfNumberOnly.arrayNumber); + } + + @Override + public int hashCode() { + return Objects.hash(arrayNumber); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayOfNumberOnly {\n"); + + sb.append(" arrayNumber: ").append(toIndentedString(arrayNumber)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ArrayTest.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ArrayTest.java new file mode 100644 index 000000000000..6e995d00cb8d --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ArrayTest.java @@ -0,0 +1,163 @@ +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 java.util.ArrayList; +import java.util.List; +import org.openapitools.model.ReadOnlyFirst; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ArrayTest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ArrayTest { + @JsonProperty("array_of_string") + @Valid + private List arrayOfString = null; + + @JsonProperty("array_array_of_integer") + @Valid + private List> arrayArrayOfInteger = null; + + @JsonProperty("array_array_of_model") + @Valid + private List> arrayArrayOfModel = null; + + public ArrayTest arrayOfString(List arrayOfString) { + this.arrayOfString = arrayOfString; + return this; + } + + public ArrayTest addArrayOfStringItem(String arrayOfStringItem) { + if (this.arrayOfString == null) { + this.arrayOfString = new ArrayList(); + } + this.arrayOfString.add(arrayOfStringItem); + return this; + } + + /** + * Get arrayOfString + * @return arrayOfString + */ + @Schema(name = "arrayOfString", defaultValue = "") + + + public List getArrayOfString() { + return arrayOfString; + } + + public void setArrayOfString(List arrayOfString) { + this.arrayOfString = arrayOfString; + } + + public ArrayTest arrayArrayOfInteger(List> arrayArrayOfInteger) { + this.arrayArrayOfInteger = arrayArrayOfInteger; + return this; + } + + public ArrayTest addArrayArrayOfIntegerItem(List arrayArrayOfIntegerItem) { + if (this.arrayArrayOfInteger == null) { + this.arrayArrayOfInteger = new ArrayList>(); + } + this.arrayArrayOfInteger.add(arrayArrayOfIntegerItem); + return this; + } + + /** + * Get arrayArrayOfInteger + * @return arrayArrayOfInteger + */ + @Schema(name = "arrayArrayOfInteger", defaultValue = "") + + @Valid + + public List> getArrayArrayOfInteger() { + return arrayArrayOfInteger; + } + + public void setArrayArrayOfInteger(List> arrayArrayOfInteger) { + this.arrayArrayOfInteger = arrayArrayOfInteger; + } + + public ArrayTest arrayArrayOfModel(List> arrayArrayOfModel) { + this.arrayArrayOfModel = arrayArrayOfModel; + return this; + } + + public ArrayTest addArrayArrayOfModelItem(List arrayArrayOfModelItem) { + if (this.arrayArrayOfModel == null) { + this.arrayArrayOfModel = new ArrayList>(); + } + this.arrayArrayOfModel.add(arrayArrayOfModelItem); + return this; + } + + /** + * Get arrayArrayOfModel + * @return arrayArrayOfModel + */ + @Schema(name = "arrayArrayOfModel", defaultValue = "") + + @Valid + + public List> getArrayArrayOfModel() { + return arrayArrayOfModel; + } + + public void setArrayArrayOfModel(List> arrayArrayOfModel) { + this.arrayArrayOfModel = arrayArrayOfModel; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayTest arrayTest = (ArrayTest) o; + return Objects.equals(this.arrayOfString, arrayTest.arrayOfString) && + Objects.equals(this.arrayArrayOfInteger, arrayTest.arrayArrayOfInteger) && + Objects.equals(this.arrayArrayOfModel, arrayTest.arrayArrayOfModel); + } + + @Override + public int hashCode() { + return Objects.hash(arrayOfString, arrayArrayOfInteger, arrayArrayOfModel); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayTest {\n"); + + sb.append(" arrayOfString: ").append(toIndentedString(arrayOfString)).append("\n"); + sb.append(" arrayArrayOfInteger: ").append(toIndentedString(arrayArrayOfInteger)).append("\n"); + sb.append(" arrayArrayOfModel: ").append(toIndentedString(arrayArrayOfModel)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/BigCat.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/BigCat.java new file mode 100644 index 000000000000..1ca8388a6ce4 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/BigCat.java @@ -0,0 +1,124 @@ +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 org.openapitools.model.BigCatAllOf; +import org.openapitools.model.Cat; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * BigCat + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class BigCat extends Cat { + /** + * Gets or Sets kind + */ + public enum KindEnum { + LIONS("lions"), + + TIGERS("tigers"), + + LEOPARDS("leopards"), + + JAGUARS("jaguars"); + + private String value; + + KindEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static KindEnum fromValue(String value) { + for (KindEnum b : KindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("kind") + private KindEnum kind; + + public BigCat kind(KindEnum kind) { + this.kind = kind; + return this; + } + + /** + * Get kind + * @return kind + */ + @Schema(name = "kind", defaultValue = "") + + + public KindEnum getKind() { + return kind; + } + + public void setKind(KindEnum kind) { + this.kind = kind; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BigCat bigCat = (BigCat) o; + return Objects.equals(this.kind, bigCat.kind) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(kind, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BigCat {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/BigCatAllOf.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/BigCatAllOf.java new file mode 100644 index 000000000000..f39298398eb9 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/BigCatAllOf.java @@ -0,0 +1,121 @@ +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 javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * BigCatAllOf + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class BigCatAllOf { + /** + * Gets or Sets kind + */ + public enum KindEnum { + LIONS("lions"), + + TIGERS("tigers"), + + LEOPARDS("leopards"), + + JAGUARS("jaguars"); + + private String value; + + KindEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static KindEnum fromValue(String value) { + for (KindEnum b : KindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("kind") + private KindEnum kind; + + public BigCatAllOf kind(KindEnum kind) { + this.kind = kind; + return this; + } + + /** + * Get kind + * @return kind + */ + @Schema(name = "kind", defaultValue = "") + + + public KindEnum getKind() { + return kind; + } + + public void setKind(KindEnum kind) { + this.kind = kind; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BigCatAllOf bigCatAllOf = (BigCatAllOf) o; + return Objects.equals(this.kind, bigCatAllOf.kind); + } + + @Override + public int hashCode() { + return Objects.hash(kind); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BigCatAllOf {\n"); + + sb.append(" kind: ").append(toIndentedString(kind)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Capitalization.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Capitalization.java new file mode 100644 index 000000000000..ac4b97258888 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Capitalization.java @@ -0,0 +1,206 @@ +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 javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Capitalization + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Capitalization { + @JsonProperty("smallCamel") + private String smallCamel; + + @JsonProperty("CapitalCamel") + private String capitalCamel; + + @JsonProperty("small_Snake") + private String smallSnake; + + @JsonProperty("Capital_Snake") + private String capitalSnake; + + @JsonProperty("SCA_ETH_Flow_Points") + private String scAETHFlowPoints; + + @JsonProperty("ATT_NAME") + private String ATT_NAME; + + public Capitalization smallCamel(String smallCamel) { + this.smallCamel = smallCamel; + return this; + } + + /** + * Get smallCamel + * @return smallCamel + */ + @Schema(name = "smallCamel", defaultValue = "") + + + public String getSmallCamel() { + return smallCamel; + } + + public void setSmallCamel(String smallCamel) { + this.smallCamel = smallCamel; + } + + public Capitalization capitalCamel(String capitalCamel) { + this.capitalCamel = capitalCamel; + return this; + } + + /** + * Get capitalCamel + * @return capitalCamel + */ + @Schema(name = "capitalCamel", defaultValue = "") + + + public String getCapitalCamel() { + return capitalCamel; + } + + public void setCapitalCamel(String capitalCamel) { + this.capitalCamel = capitalCamel; + } + + public Capitalization smallSnake(String smallSnake) { + this.smallSnake = smallSnake; + return this; + } + + /** + * Get smallSnake + * @return smallSnake + */ + @Schema(name = "smallSnake", defaultValue = "") + + + public String getSmallSnake() { + return smallSnake; + } + + public void setSmallSnake(String smallSnake) { + this.smallSnake = smallSnake; + } + + public Capitalization capitalSnake(String capitalSnake) { + this.capitalSnake = capitalSnake; + return this; + } + + /** + * Get capitalSnake + * @return capitalSnake + */ + @Schema(name = "capitalSnake", defaultValue = "") + + + public String getCapitalSnake() { + return capitalSnake; + } + + public void setCapitalSnake(String capitalSnake) { + this.capitalSnake = capitalSnake; + } + + public Capitalization scAETHFlowPoints(String scAETHFlowPoints) { + this.scAETHFlowPoints = scAETHFlowPoints; + return this; + } + + /** + * Get scAETHFlowPoints + * @return scAETHFlowPoints + */ + @Schema(name = "scAETHFlowPoints", defaultValue = "") + + + public String getScAETHFlowPoints() { + return scAETHFlowPoints; + } + + public void setScAETHFlowPoints(String scAETHFlowPoints) { + this.scAETHFlowPoints = scAETHFlowPoints; + } + + public Capitalization ATT_NAME(String ATT_NAME) { + this.ATT_NAME = ATT_NAME; + return this; + } + + /** + * Name of the pet + * @return ATT_NAME + */ + @Schema(name = "ATT_NAME", defaultValue = "Name of the pet ") + + + public String getATTNAME() { + return ATT_NAME; + } + + public void setATTNAME(String ATT_NAME) { + this.ATT_NAME = ATT_NAME; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Capitalization capitalization = (Capitalization) o; + return Objects.equals(this.smallCamel, capitalization.smallCamel) && + Objects.equals(this.capitalCamel, capitalization.capitalCamel) && + Objects.equals(this.smallSnake, capitalization.smallSnake) && + Objects.equals(this.capitalSnake, capitalization.capitalSnake) && + Objects.equals(this.scAETHFlowPoints, capitalization.scAETHFlowPoints) && + Objects.equals(this.ATT_NAME, capitalization.ATT_NAME); + } + + @Override + public int hashCode() { + return Objects.hash(smallCamel, capitalCamel, smallSnake, capitalSnake, scAETHFlowPoints, ATT_NAME); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Capitalization {\n"); + + sb.append(" smallCamel: ").append(toIndentedString(smallCamel)).append("\n"); + sb.append(" capitalCamel: ").append(toIndentedString(capitalCamel)).append("\n"); + sb.append(" smallSnake: ").append(toIndentedString(smallSnake)).append("\n"); + sb.append(" capitalSnake: ").append(toIndentedString(capitalSnake)).append("\n"); + sb.append(" scAETHFlowPoints: ").append(toIndentedString(scAETHFlowPoints)).append("\n"); + sb.append(" ATT_NAME: ").append(toIndentedString(ATT_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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Cat.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Cat.java new file mode 100644 index 000000000000..e41f36a626bd --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Cat.java @@ -0,0 +1,84 @@ +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 org.openapitools.model.Animal; +import org.openapitools.model.CatAllOf; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Cat + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Cat extends Animal { + @JsonProperty("declawed") + private Boolean declawed; + + public Cat declawed(Boolean declawed) { + this.declawed = declawed; + return this; + } + + /** + * Get declawed + * @return declawed + */ + @Schema(name = "declawed", defaultValue = "") + + + public Boolean getDeclawed() { + return declawed; + } + + public void setDeclawed(Boolean declawed) { + this.declawed = declawed; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Cat cat = (Cat) o; + return Objects.equals(this.declawed, cat.declawed) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(declawed, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Cat {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" declawed: ").append(toIndentedString(declawed)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/CatAllOf.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/CatAllOf.java new file mode 100644 index 000000000000..9bc555ab0007 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/CatAllOf.java @@ -0,0 +1,81 @@ +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 javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * CatAllOf + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class CatAllOf { + @JsonProperty("declawed") + private Boolean declawed; + + public CatAllOf declawed(Boolean declawed) { + this.declawed = declawed; + return this; + } + + /** + * Get declawed + * @return declawed + */ + @Schema(name = "declawed", defaultValue = "") + + + public Boolean getDeclawed() { + return declawed; + } + + public void setDeclawed(Boolean declawed) { + this.declawed = declawed; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CatAllOf catAllOf = (CatAllOf) o; + return Objects.equals(this.declawed, catAllOf.declawed); + } + + @Override + public int hashCode() { + return Objects.hash(declawed); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CatAllOf {\n"); + + sb.append(" declawed: ").append(toIndentedString(declawed)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Category.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Category.java new file mode 100644 index 000000000000..03a760ee3fd5 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Category.java @@ -0,0 +1,107 @@ +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 javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Category + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Category { + @JsonProperty("id") + private Long id; + + @JsonProperty("name") + private String name = "default-name"; + + public Category id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "name", required = true, defaultValue = "") + @NotNull + + + 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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ClassModel.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ClassModel.java new file mode 100644 index 000000000000..878a45986a82 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ClassModel.java @@ -0,0 +1,82 @@ +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 javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Model for testing model with \"_class\" property + */ +@Schema(name = "ClassModel",description = "Model for testing model with \"_class\" property") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ClassModel { + @JsonProperty("_class") + private String propertyClass; + + public ClassModel propertyClass(String propertyClass) { + this.propertyClass = propertyClass; + return this; + } + + /** + * Get propertyClass + * @return propertyClass + */ + @Schema(name = "propertyClass", defaultValue = "") + + + public String getPropertyClass() { + return propertyClass; + } + + public void setPropertyClass(String propertyClass) { + this.propertyClass = propertyClass; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClassModel classModel = (ClassModel) o; + return Objects.equals(this.propertyClass, classModel.propertyClass); + } + + @Override + public int hashCode() { + return Objects.hash(propertyClass); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ClassModel {\n"); + + sb.append(" propertyClass: ").append(toIndentedString(propertyClass)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Client.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Client.java new file mode 100644 index 000000000000..74b85fd28234 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Client.java @@ -0,0 +1,81 @@ +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 javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Client + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Client { + @JsonProperty("client") + private String client; + + public Client client(String client) { + this.client = client; + return this; + } + + /** + * Get client + * @return client + */ + @Schema(name = "client", defaultValue = "") + + + public String getClient() { + return client; + } + + public void setClient(String client) { + this.client = client; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Client client = (Client) o; + return Objects.equals(this.client, client.client); + } + + @Override + public int hashCode() { + return Objects.hash(client); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Client {\n"); + + sb.append(" client: ").append(toIndentedString(client)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Dog.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Dog.java new file mode 100644 index 000000000000..1dbce140c902 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Dog.java @@ -0,0 +1,84 @@ +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 org.openapitools.model.Animal; +import org.openapitools.model.DogAllOf; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Dog + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Dog extends Animal { + @JsonProperty("breed") + private String breed; + + public Dog breed(String breed) { + this.breed = breed; + return this; + } + + /** + * Get breed + * @return breed + */ + @Schema(name = "breed", defaultValue = "") + + + public String getBreed() { + return breed; + } + + public void setBreed(String breed) { + this.breed = breed; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Dog dog = (Dog) o; + return Objects.equals(this.breed, dog.breed) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(breed, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Dog {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" breed: ").append(toIndentedString(breed)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/DogAllOf.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/DogAllOf.java new file mode 100644 index 000000000000..0af97ffbaf41 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/DogAllOf.java @@ -0,0 +1,81 @@ +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 javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * DogAllOf + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class DogAllOf { + @JsonProperty("breed") + private String breed; + + public DogAllOf breed(String breed) { + this.breed = breed; + return this; + } + + /** + * Get breed + * @return breed + */ + @Schema(name = "breed", defaultValue = "") + + + public String getBreed() { + return breed; + } + + public void setBreed(String breed) { + this.breed = breed; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DogAllOf dogAllOf = (DogAllOf) o; + return Objects.equals(this.breed, dogAllOf.breed); + } + + @Override + public int hashCode() { + return Objects.hash(breed); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DogAllOf {\n"); + + sb.append(" breed: ").append(toIndentedString(breed)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/EnumArrays.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/EnumArrays.java new file mode 100644 index 000000000000..ef006f92c684 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/EnumArrays.java @@ -0,0 +1,188 @@ +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 java.util.ArrayList; +import java.util.List; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * EnumArrays + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class EnumArrays { + /** + * Gets or Sets justSymbol + */ + public enum JustSymbolEnum { + GREATER_THAN_OR_EQUAL_TO(">="), + + DOLLAR("$"); + + private String value; + + JustSymbolEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static JustSymbolEnum fromValue(String value) { + for (JustSymbolEnum b : JustSymbolEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("just_symbol") + private JustSymbolEnum justSymbol; + + /** + * Gets or Sets arrayEnum + */ + public enum ArrayEnumEnum { + FISH("fish"), + + CRAB("crab"); + + private String value; + + ArrayEnumEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static ArrayEnumEnum fromValue(String value) { + for (ArrayEnumEnum b : ArrayEnumEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("array_enum") + @Valid + private List arrayEnum = null; + + public EnumArrays justSymbol(JustSymbolEnum justSymbol) { + this.justSymbol = justSymbol; + return this; + } + + /** + * Get justSymbol + * @return justSymbol + */ + @Schema(name = "justSymbol", defaultValue = "") + + + public JustSymbolEnum getJustSymbol() { + return justSymbol; + } + + public void setJustSymbol(JustSymbolEnum justSymbol) { + this.justSymbol = justSymbol; + } + + public EnumArrays arrayEnum(List arrayEnum) { + this.arrayEnum = arrayEnum; + return this; + } + + public EnumArrays addArrayEnumItem(ArrayEnumEnum arrayEnumItem) { + if (this.arrayEnum == null) { + this.arrayEnum = new ArrayList(); + } + this.arrayEnum.add(arrayEnumItem); + return this; + } + + /** + * Get arrayEnum + * @return arrayEnum + */ + @Schema(name = "arrayEnum", defaultValue = "") + + + public List getArrayEnum() { + return arrayEnum; + } + + public void setArrayEnum(List arrayEnum) { + this.arrayEnum = arrayEnum; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EnumArrays enumArrays = (EnumArrays) o; + return Objects.equals(this.justSymbol, enumArrays.justSymbol) && + Objects.equals(this.arrayEnum, enumArrays.arrayEnum); + } + + @Override + public int hashCode() { + return Objects.hash(justSymbol, arrayEnum); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EnumArrays {\n"); + + sb.append(" justSymbol: ").append(toIndentedString(justSymbol)).append("\n"); + sb.append(" arrayEnum: ").append(toIndentedString(arrayEnum)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/EnumClass.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/EnumClass.java new file mode 100644 index 000000000000..f5edf59363ac --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/EnumClass.java @@ -0,0 +1,53 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonValue; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Gets or Sets EnumClass + */ +public enum EnumClass { + + _ABC("_abc"), + + _EFG("-efg"), + + _XYZ_("(xyz)"); + + private String value; + + EnumClass(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumClass fromValue(String value) { + for (EnumClass b : EnumClass.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/EnumTest.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/EnumTest.java new file mode 100644 index 000000000000..f67ec5d041aa --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/EnumTest.java @@ -0,0 +1,329 @@ +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 org.openapitools.model.OuterEnum; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * EnumTest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class EnumTest { + /** + * Gets or Sets enumString + */ + public enum EnumStringEnum { + UPPER("UPPER"), + + LOWER("lower"), + + EMPTY(""); + + private String value; + + EnumStringEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumStringEnum fromValue(String value) { + for (EnumStringEnum b : EnumStringEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("enum_string") + private EnumStringEnum enumString; + + /** + * Gets or Sets enumStringRequired + */ + public enum EnumStringRequiredEnum { + UPPER("UPPER"), + + LOWER("lower"), + + EMPTY(""); + + private String value; + + EnumStringRequiredEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumStringRequiredEnum fromValue(String value) { + for (EnumStringRequiredEnum b : EnumStringRequiredEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("enum_string_required") + private EnumStringRequiredEnum enumStringRequired; + + /** + * Gets or Sets enumInteger + */ + public enum EnumIntegerEnum { + NUMBER_1(1), + + NUMBER_MINUS_1(-1); + + private Integer value; + + EnumIntegerEnum(Integer value) { + this.value = value; + } + + @JsonValue + public Integer getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumIntegerEnum fromValue(Integer value) { + for (EnumIntegerEnum b : EnumIntegerEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("enum_integer") + private EnumIntegerEnum enumInteger; + + /** + * Gets or Sets enumNumber + */ + public enum EnumNumberEnum { + NUMBER_1_DOT_1(1.1), + + NUMBER_MINUS_1_DOT_2(-1.2); + + private Double value; + + EnumNumberEnum(Double value) { + this.value = value; + } + + @JsonValue + public Double getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumNumberEnum fromValue(Double value) { + for (EnumNumberEnum b : EnumNumberEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("enum_number") + private EnumNumberEnum enumNumber; + + @JsonProperty("outerEnum") + private OuterEnum outerEnum; + + public EnumTest enumString(EnumStringEnum enumString) { + this.enumString = enumString; + return this; + } + + /** + * Get enumString + * @return enumString + */ + @Schema(name = "enumString", defaultValue = "") + + + public EnumStringEnum getEnumString() { + return enumString; + } + + public void setEnumString(EnumStringEnum enumString) { + this.enumString = enumString; + } + + public EnumTest enumStringRequired(EnumStringRequiredEnum enumStringRequired) { + this.enumStringRequired = enumStringRequired; + return this; + } + + /** + * Get enumStringRequired + * @return enumStringRequired + */ + @Schema(name = "enumStringRequired", required = true, defaultValue = "") + @NotNull + + + public EnumStringRequiredEnum getEnumStringRequired() { + return enumStringRequired; + } + + public void setEnumStringRequired(EnumStringRequiredEnum enumStringRequired) { + this.enumStringRequired = enumStringRequired; + } + + public EnumTest enumInteger(EnumIntegerEnum enumInteger) { + this.enumInteger = enumInteger; + return this; + } + + /** + * Get enumInteger + * @return enumInteger + */ + @Schema(name = "enumInteger", defaultValue = "") + + + public EnumIntegerEnum getEnumInteger() { + return enumInteger; + } + + public void setEnumInteger(EnumIntegerEnum enumInteger) { + this.enumInteger = enumInteger; + } + + public EnumTest enumNumber(EnumNumberEnum enumNumber) { + this.enumNumber = enumNumber; + return this; + } + + /** + * Get enumNumber + * @return enumNumber + */ + @Schema(name = "enumNumber", defaultValue = "") + + + public EnumNumberEnum getEnumNumber() { + return enumNumber; + } + + public void setEnumNumber(EnumNumberEnum enumNumber) { + this.enumNumber = enumNumber; + } + + public EnumTest outerEnum(OuterEnum outerEnum) { + this.outerEnum = outerEnum; + return this; + } + + /** + * Get outerEnum + * @return outerEnum + */ + @Schema(name = "outerEnum", defaultValue = "") + + @Valid + + public OuterEnum getOuterEnum() { + return outerEnum; + } + + public void setOuterEnum(OuterEnum outerEnum) { + this.outerEnum = outerEnum; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EnumTest enumTest = (EnumTest) o; + return Objects.equals(this.enumString, enumTest.enumString) && + Objects.equals(this.enumStringRequired, enumTest.enumStringRequired) && + Objects.equals(this.enumInteger, enumTest.enumInteger) && + Objects.equals(this.enumNumber, enumTest.enumNumber) && + Objects.equals(this.outerEnum, enumTest.outerEnum); + } + + @Override + public int hashCode() { + return Objects.hash(enumString, enumStringRequired, enumInteger, enumNumber, outerEnum); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EnumTest {\n"); + + sb.append(" enumString: ").append(toIndentedString(enumString)).append("\n"); + sb.append(" enumStringRequired: ").append(toIndentedString(enumStringRequired)).append("\n"); + sb.append(" enumInteger: ").append(toIndentedString(enumInteger)).append("\n"); + sb.append(" enumNumber: ").append(toIndentedString(enumNumber)).append("\n"); + sb.append(" outerEnum: ").append(toIndentedString(outerEnum)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/FileSchemaTestClass.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/FileSchemaTestClass.java new file mode 100644 index 000000000000..2de2ee314c03 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/FileSchemaTestClass.java @@ -0,0 +1,119 @@ +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 java.util.ArrayList; +import java.util.List; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * FileSchemaTestClass + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class FileSchemaTestClass { + @JsonProperty("file") + private java.io.File file; + + @JsonProperty("files") + @Valid + private List files = null; + + public FileSchemaTestClass file(java.io.File file) { + this.file = file; + return this; + } + + /** + * Get file + * @return file + */ + @Schema(name = "file", defaultValue = "") + + @Valid + + public java.io.File getFile() { + return file; + } + + public void setFile(java.io.File file) { + this.file = file; + } + + public FileSchemaTestClass files(List files) { + this.files = files; + return this; + } + + public FileSchemaTestClass addFilesItem(java.io.File filesItem) { + if (this.files == null) { + this.files = new ArrayList(); + } + this.files.add(filesItem); + return this; + } + + /** + * Get files + * @return files + */ + @Schema(name = "files", defaultValue = "") + + @Valid + + public List getFiles() { + return files; + } + + public void setFiles(List files) { + this.files = files; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FileSchemaTestClass fileSchemaTestClass = (FileSchemaTestClass) o; + return Objects.equals(this.file, fileSchemaTestClass.file) && + Objects.equals(this.files, fileSchemaTestClass.files); + } + + @Override + public int hashCode() { + return Objects.hash(file, files); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FileSchemaTestClass {\n"); + + sb.append(" file: ").append(toIndentedString(file)).append("\n"); + sb.append(" files: ").append(toIndentedString(files)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/FormatTest.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/FormatTest.java new file mode 100644 index 000000000000..e0203457d83b --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/FormatTest.java @@ -0,0 +1,433 @@ +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 java.math.BigDecimal; +import java.util.Arrays; +import java.util.UUID; +import org.threeten.bp.LocalDate; +import org.threeten.bp.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * FormatTest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class FormatTest { + @JsonProperty("integer") + private Integer integer; + + @JsonProperty("int32") + private Integer int32; + + @JsonProperty("int64") + private Long int64; + + @JsonProperty("number") + private BigDecimal number; + + @JsonProperty("float") + private Float _float; + + @JsonProperty("double") + private Double _double; + + @JsonProperty("string") + private String string; + + @JsonProperty("byte") + private byte[] _byte; + + @JsonProperty("binary") + private org.springframework.core.io.Resource binary; + + @JsonProperty("date") + @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) + private LocalDate date; + + @JsonProperty("dateTime") + @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) + private OffsetDateTime dateTime; + + @JsonProperty("uuid") + private UUID uuid; + + @JsonProperty("password") + private String password; + + @JsonProperty("BigDecimal") + private BigDecimal bigDecimal; + + public FormatTest integer(Integer integer) { + this.integer = integer; + return this; + } + + /** + * Get integer + * minimum: 10 + * maximum: 100 + * @return integer + */ + @Schema(name = "integer", defaultValue = "") + +@Min(10) @Max(100) + public Integer getInteger() { + return integer; + } + + public void setInteger(Integer integer) { + this.integer = integer; + } + + public FormatTest int32(Integer int32) { + this.int32 = int32; + return this; + } + + /** + * Get int32 + * minimum: 20 + * maximum: 200 + * @return int32 + */ + @Schema(name = "int32", defaultValue = "") + +@Min(20) @Max(200) + public Integer getInt32() { + return int32; + } + + public void setInt32(Integer int32) { + this.int32 = int32; + } + + public FormatTest int64(Long int64) { + this.int64 = int64; + return this; + } + + /** + * Get int64 + * @return int64 + */ + @Schema(name = "int64", defaultValue = "") + + + public Long getInt64() { + return int64; + } + + public void setInt64(Long int64) { + this.int64 = int64; + } + + public FormatTest number(BigDecimal number) { + this.number = number; + return this; + } + + /** + * Get number + * minimum: 32.1 + * maximum: 543.2 + * @return number + */ + @Schema(name = "number", required = true, defaultValue = "") + @NotNull + + @Valid +@DecimalMin("32.1") @DecimalMax("543.2") + public BigDecimal getNumber() { + return number; + } + + public void setNumber(BigDecimal number) { + this.number = number; + } + + public FormatTest _float(Float _float) { + this._float = _float; + return this; + } + + /** + * Get _float + * minimum: 54.3 + * maximum: 987.6 + * @return _float + */ + @Schema(name = "_float", defaultValue = "") + +@DecimalMin("54.3") @DecimalMax("987.6") + public Float getFloat() { + return _float; + } + + public void setFloat(Float _float) { + this._float = _float; + } + + public FormatTest _double(Double _double) { + this._double = _double; + return this; + } + + /** + * Get _double + * minimum: 67.8 + * maximum: 123.4 + * @return _double + */ + @Schema(name = "_double", defaultValue = "") + +@DecimalMin("67.8") @DecimalMax("123.4") + public Double getDouble() { + return _double; + } + + public void setDouble(Double _double) { + this._double = _double; + } + + public FormatTest string(String string) { + this.string = string; + return this; + } + + /** + * Get string + * @return string + */ + @Schema(name = "string", defaultValue = "") + +@Pattern(regexp = "/[a-z]/i") + public String getString() { + return string; + } + + public void setString(String string) { + this.string = string; + } + + public FormatTest _byte(byte[] _byte) { + this._byte = _byte; + return this; + } + + /** + * Get _byte + * @return _byte + */ + @Schema(name = "_byte", required = true, defaultValue = "") + @NotNull + + + public byte[] getByte() { + return _byte; + } + + public void setByte(byte[] _byte) { + this._byte = _byte; + } + + public FormatTest binary(org.springframework.core.io.Resource binary) { + this.binary = binary; + return this; + } + + /** + * Get binary + * @return binary + */ + @Schema(name = "binary", defaultValue = "") + + @Valid + + public org.springframework.core.io.Resource getBinary() { + return binary; + } + + public void setBinary(org.springframework.core.io.Resource binary) { + this.binary = binary; + } + + public FormatTest date(LocalDate date) { + this.date = date; + return this; + } + + /** + * Get date + * @return date + */ + @Schema(name = "date", required = true, defaultValue = "") + @NotNull + + @Valid + + public LocalDate getDate() { + return date; + } + + public void setDate(LocalDate date) { + this.date = date; + } + + public FormatTest dateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + return this; + } + + /** + * Get dateTime + * @return dateTime + */ + @Schema(name = "dateTime", defaultValue = "") + + @Valid + + public OffsetDateTime getDateTime() { + return dateTime; + } + + public void setDateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + } + + public FormatTest uuid(UUID uuid) { + this.uuid = uuid; + return this; + } + + /** + * Get uuid + * @return uuid + */ + @Schema(name = "uuid", example = "72f98069-206d-4f12-9f12-3d1e525a8e84", defaultValue = "") + + @Valid + + public UUID getUuid() { + return uuid; + } + + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + public FormatTest password(String password) { + this.password = password; + return this; + } + + /** + * Get password + * @return password + */ + @Schema(name = "password", required = true, defaultValue = "") + @NotNull + +@Size(min = 10, max = 64) + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public FormatTest bigDecimal(BigDecimal bigDecimal) { + this.bigDecimal = bigDecimal; + return this; + } + + /** + * Get bigDecimal + * @return bigDecimal + */ + @Schema(name = "bigDecimal", defaultValue = "") + + @Valid + + public BigDecimal getBigDecimal() { + return bigDecimal; + } + + public void setBigDecimal(BigDecimal bigDecimal) { + this.bigDecimal = bigDecimal; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FormatTest formatTest = (FormatTest) o; + return Objects.equals(this.integer, formatTest.integer) && + Objects.equals(this.int32, formatTest.int32) && + Objects.equals(this.int64, formatTest.int64) && + Objects.equals(this.number, formatTest.number) && + Objects.equals(this._float, formatTest._float) && + Objects.equals(this._double, formatTest._double) && + Objects.equals(this.string, formatTest.string) && + Arrays.equals(this._byte, formatTest._byte) && + Objects.equals(this.binary, formatTest.binary) && + Objects.equals(this.date, formatTest.date) && + Objects.equals(this.dateTime, formatTest.dateTime) && + Objects.equals(this.uuid, formatTest.uuid) && + Objects.equals(this.password, formatTest.password) && + Objects.equals(this.bigDecimal, formatTest.bigDecimal); + } + + @Override + public int hashCode() { + return Objects.hash(integer, int32, int64, number, _float, _double, string, Arrays.hashCode(_byte), binary, date, dateTime, uuid, password, bigDecimal); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FormatTest {\n"); + + sb.append(" integer: ").append(toIndentedString(integer)).append("\n"); + sb.append(" int32: ").append(toIndentedString(int32)).append("\n"); + sb.append(" int64: ").append(toIndentedString(int64)).append("\n"); + sb.append(" number: ").append(toIndentedString(number)).append("\n"); + sb.append(" _float: ").append(toIndentedString(_float)).append("\n"); + sb.append(" _double: ").append(toIndentedString(_double)).append("\n"); + sb.append(" string: ").append(toIndentedString(string)).append("\n"); + sb.append(" _byte: ").append(toIndentedString(_byte)).append("\n"); + sb.append(" binary: ").append(toIndentedString(binary)).append("\n"); + sb.append(" date: ").append(toIndentedString(date)).append("\n"); + sb.append(" dateTime: ").append(toIndentedString(dateTime)).append("\n"); + sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" bigDecimal: ").append(toIndentedString(bigDecimal)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/HasOnlyReadOnly.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/HasOnlyReadOnly.java new file mode 100644 index 000000000000..d2f0afa1d4ae --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/HasOnlyReadOnly.java @@ -0,0 +1,106 @@ +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 javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * HasOnlyReadOnly + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class HasOnlyReadOnly { + @JsonProperty("bar") + private String bar; + + @JsonProperty("foo") + private String foo; + + public HasOnlyReadOnly bar(String bar) { + this.bar = bar; + return this; + } + + /** + * Get bar + * @return bar + */ + @Schema(name = "bar", readOnly = true, defaultValue = "") + + + public String getBar() { + return bar; + } + + public void setBar(String bar) { + this.bar = bar; + } + + public HasOnlyReadOnly foo(String foo) { + this.foo = foo; + return this; + } + + /** + * Get foo + * @return foo + */ + @Schema(name = "foo", readOnly = true, defaultValue = "") + + + public String getFoo() { + return foo; + } + + public void setFoo(String foo) { + this.foo = foo; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HasOnlyReadOnly hasOnlyReadOnly = (HasOnlyReadOnly) o; + return Objects.equals(this.bar, hasOnlyReadOnly.bar) && + Objects.equals(this.foo, hasOnlyReadOnly.foo); + } + + @Override + public int hashCode() { + return Objects.hash(bar, foo); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class HasOnlyReadOnly {\n"); + + sb.append(" bar: ").append(toIndentedString(bar)).append("\n"); + sb.append(" foo: ").append(toIndentedString(foo)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/MapTest.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/MapTest.java new file mode 100644 index 000000000000..ed29ea575eef --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/MapTest.java @@ -0,0 +1,232 @@ +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 java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * MapTest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class MapTest { + @JsonProperty("map_map_of_string") + @Valid + private Map> mapMapOfString = null; + + /** + * Gets or Sets inner + */ + public enum InnerEnum { + UPPER("UPPER"), + + LOWER("lower"); + + private String value; + + InnerEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static InnerEnum fromValue(String value) { + for (InnerEnum b : InnerEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("map_of_enum_string") + @Valid + private Map mapOfEnumString = null; + + @JsonProperty("direct_map") + @Valid + private Map directMap = null; + + @JsonProperty("indirect_map") + @Valid + private Map indirectMap = null; + + public MapTest mapMapOfString(Map> mapMapOfString) { + this.mapMapOfString = mapMapOfString; + return this; + } + + public MapTest putMapMapOfStringItem(String key, Map mapMapOfStringItem) { + if (this.mapMapOfString == null) { + this.mapMapOfString = new HashMap>(); + } + this.mapMapOfString.put(key, mapMapOfStringItem); + return this; + } + + /** + * Get mapMapOfString + * @return mapMapOfString + */ + @Schema(name = "mapMapOfString", defaultValue = "") + + @Valid + + public Map> getMapMapOfString() { + return mapMapOfString; + } + + public void setMapMapOfString(Map> mapMapOfString) { + this.mapMapOfString = mapMapOfString; + } + + public MapTest mapOfEnumString(Map mapOfEnumString) { + this.mapOfEnumString = mapOfEnumString; + return this; + } + + public MapTest putMapOfEnumStringItem(String key, InnerEnum mapOfEnumStringItem) { + if (this.mapOfEnumString == null) { + this.mapOfEnumString = new HashMap(); + } + this.mapOfEnumString.put(key, mapOfEnumStringItem); + return this; + } + + /** + * Get mapOfEnumString + * @return mapOfEnumString + */ + @Schema(name = "mapOfEnumString", defaultValue = "") + + + public Map getMapOfEnumString() { + return mapOfEnumString; + } + + public void setMapOfEnumString(Map mapOfEnumString) { + this.mapOfEnumString = mapOfEnumString; + } + + public MapTest directMap(Map directMap) { + this.directMap = directMap; + return this; + } + + public MapTest putDirectMapItem(String key, Boolean directMapItem) { + if (this.directMap == null) { + this.directMap = new HashMap(); + } + this.directMap.put(key, directMapItem); + return this; + } + + /** + * Get directMap + * @return directMap + */ + @Schema(name = "directMap", defaultValue = "") + + + public Map getDirectMap() { + return directMap; + } + + public void setDirectMap(Map directMap) { + this.directMap = directMap; + } + + public MapTest indirectMap(Map indirectMap) { + this.indirectMap = indirectMap; + return this; + } + + public MapTest putIndirectMapItem(String key, Boolean indirectMapItem) { + if (this.indirectMap == null) { + this.indirectMap = new HashMap(); + } + this.indirectMap.put(key, indirectMapItem); + return this; + } + + /** + * Get indirectMap + * @return indirectMap + */ + @Schema(name = "indirectMap", defaultValue = "") + + + public Map getIndirectMap() { + return indirectMap; + } + + public void setIndirectMap(Map indirectMap) { + this.indirectMap = indirectMap; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MapTest mapTest = (MapTest) o; + return Objects.equals(this.mapMapOfString, mapTest.mapMapOfString) && + Objects.equals(this.mapOfEnumString, mapTest.mapOfEnumString) && + Objects.equals(this.directMap, mapTest.directMap) && + Objects.equals(this.indirectMap, mapTest.indirectMap); + } + + @Override + public int hashCode() { + return Objects.hash(mapMapOfString, mapOfEnumString, directMap, indirectMap); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MapTest {\n"); + + sb.append(" mapMapOfString: ").append(toIndentedString(mapMapOfString)).append("\n"); + sb.append(" mapOfEnumString: ").append(toIndentedString(mapOfEnumString)).append("\n"); + sb.append(" directMap: ").append(toIndentedString(directMap)).append("\n"); + sb.append(" indirectMap: ").append(toIndentedString(indirectMap)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java new file mode 100644 index 000000000000..e846cf63782d --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java @@ -0,0 +1,150 @@ +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 java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import org.openapitools.model.Animal; +import org.threeten.bp.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * MixedPropertiesAndAdditionalPropertiesClass + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class MixedPropertiesAndAdditionalPropertiesClass { + @JsonProperty("uuid") + private UUID uuid; + + @JsonProperty("dateTime") + @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) + private OffsetDateTime dateTime; + + @JsonProperty("map") + @Valid + private Map map = null; + + public MixedPropertiesAndAdditionalPropertiesClass uuid(UUID uuid) { + this.uuid = uuid; + return this; + } + + /** + * Get uuid + * @return uuid + */ + @Schema(name = "uuid", defaultValue = "") + + @Valid + + public UUID getUuid() { + return uuid; + } + + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + public MixedPropertiesAndAdditionalPropertiesClass dateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + return this; + } + + /** + * Get dateTime + * @return dateTime + */ + @Schema(name = "dateTime", defaultValue = "") + + @Valid + + public OffsetDateTime getDateTime() { + return dateTime; + } + + public void setDateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + } + + public MixedPropertiesAndAdditionalPropertiesClass map(Map map) { + this.map = map; + return this; + } + + public MixedPropertiesAndAdditionalPropertiesClass putMapItem(String key, Animal mapItem) { + if (this.map == null) { + this.map = new HashMap(); + } + this.map.put(key, mapItem); + return this; + } + + /** + * Get map + * @return map + */ + @Schema(name = "map", defaultValue = "") + + @Valid + + public Map getMap() { + return map; + } + + public void setMap(Map map) { + this.map = map; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass = (MixedPropertiesAndAdditionalPropertiesClass) o; + return Objects.equals(this.uuid, mixedPropertiesAndAdditionalPropertiesClass.uuid) && + Objects.equals(this.dateTime, mixedPropertiesAndAdditionalPropertiesClass.dateTime) && + Objects.equals(this.map, mixedPropertiesAndAdditionalPropertiesClass.map); + } + + @Override + public int hashCode() { + return Objects.hash(uuid, dateTime, map); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MixedPropertiesAndAdditionalPropertiesClass {\n"); + + sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); + sb.append(" dateTime: ").append(toIndentedString(dateTime)).append("\n"); + sb.append(" map: ").append(toIndentedString(map)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Model200Response.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Model200Response.java new file mode 100644 index 000000000000..8aa5b96e1dae --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Model200Response.java @@ -0,0 +1,107 @@ +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 javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Model for testing model name starting with number + */ +@Schema(name = "200_response",description = "Model for testing model name starting with number") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Model200Response { + @JsonProperty("name") + private Integer name; + + @JsonProperty("class") + private String propertyClass; + + public Model200Response name(Integer name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + public Integer getName() { + return name; + } + + public void setName(Integer name) { + this.name = name; + } + + public Model200Response propertyClass(String propertyClass) { + this.propertyClass = propertyClass; + return this; + } + + /** + * Get propertyClass + * @return propertyClass + */ + @Schema(name = "propertyClass", defaultValue = "") + + + public String getPropertyClass() { + return propertyClass; + } + + public void setPropertyClass(String propertyClass) { + this.propertyClass = propertyClass; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Model200Response _200response = (Model200Response) o; + return Objects.equals(this.name, _200response.name) && + Objects.equals(this.propertyClass, _200response.propertyClass); + } + + @Override + public int hashCode() { + return Objects.hash(name, propertyClass); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Model200Response {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" propertyClass: ").append(toIndentedString(propertyClass)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ModelApiResponse.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ModelApiResponse.java new file mode 100644 index 000000000000..86af4aba24a0 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ModelApiResponse.java @@ -0,0 +1,131 @@ +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 javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ModelApiResponse + */ +@javax.annotation.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 + */ + @Schema(name = "code", defaultValue = "") + + + 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 + */ + @Schema(name = "type", defaultValue = "") + + + 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 + */ + @Schema(name = "message", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ModelReturn.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ModelReturn.java new file mode 100644 index 000000000000..06bc8e6627cf --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ModelReturn.java @@ -0,0 +1,82 @@ +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 javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Model for testing reserved words + */ +@Schema(name = "Return",description = "Model for testing reserved words") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ModelReturn { + @JsonProperty("return") + private Integer _return; + + public ModelReturn _return(Integer _return) { + this._return = _return; + return this; + } + + /** + * Get _return + * @return _return + */ + @Schema(name = "_return", defaultValue = "") + + + public Integer getReturn() { + return _return; + } + + public void setReturn(Integer _return) { + this._return = _return; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelReturn _return = (ModelReturn) o; + return Objects.equals(this._return, _return._return); + } + + @Override + public int hashCode() { + return Objects.hash(_return); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelReturn {\n"); + + sb.append(" _return: ").append(toIndentedString(_return)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Name.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Name.java new file mode 100644 index 000000000000..5e755ef8dd18 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Name.java @@ -0,0 +1,158 @@ +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 javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Model for testing model name same as property name + */ +@Schema(name = "Name",description = "Model for testing model name same as property name") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Name { + @JsonProperty("name") + private Integer name; + + @JsonProperty("snake_case") + private Integer snakeCase; + + @JsonProperty("property") + private String property; + + @JsonProperty("123Number") + private Integer _123number; + + public Name name(Integer name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", required = true, defaultValue = "") + @NotNull + + + public Integer getName() { + return name; + } + + public void setName(Integer name) { + this.name = name; + } + + public Name snakeCase(Integer snakeCase) { + this.snakeCase = snakeCase; + return this; + } + + /** + * Get snakeCase + * @return snakeCase + */ + @Schema(name = "snakeCase", readOnly = true, defaultValue = "") + + + public Integer getSnakeCase() { + return snakeCase; + } + + public void setSnakeCase(Integer snakeCase) { + this.snakeCase = snakeCase; + } + + public Name property(String property) { + this.property = property; + return this; + } + + /** + * Get property + * @return property + */ + @Schema(name = "property", defaultValue = "") + + + public String getProperty() { + return property; + } + + public void setProperty(String property) { + this.property = property; + } + + public Name _123number(Integer _123number) { + this._123number = _123number; + return this; + } + + /** + * Get _123number + * @return _123number + */ + @Schema(name = "_123number", readOnly = true, defaultValue = "") + + + public Integer get123number() { + return _123number; + } + + public void set123number(Integer _123number) { + this._123number = _123number; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Name name = (Name) o; + return Objects.equals(this.name, name.name) && + Objects.equals(this.snakeCase, name.snakeCase) && + Objects.equals(this.property, name.property) && + Objects.equals(this._123number, name._123number); + } + + @Override + public int hashCode() { + return Objects.hash(name, snakeCase, property, _123number); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Name {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n"); + sb.append(" property: ").append(toIndentedString(property)).append("\n"); + sb.append(" _123number: ").append(toIndentedString(_123number)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/NumberOnly.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/NumberOnly.java new file mode 100644 index 000000000000..88b9009b1dc1 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/NumberOnly.java @@ -0,0 +1,83 @@ +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 java.math.BigDecimal; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * NumberOnly + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class NumberOnly { + @JsonProperty("JustNumber") + private BigDecimal justNumber; + + public NumberOnly justNumber(BigDecimal justNumber) { + this.justNumber = justNumber; + return this; + } + + /** + * Get justNumber + * @return justNumber + */ + @Schema(name = "justNumber", defaultValue = "") + + @Valid + + public BigDecimal getJustNumber() { + return justNumber; + } + + public void setJustNumber(BigDecimal justNumber) { + this.justNumber = justNumber; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NumberOnly numberOnly = (NumberOnly) o; + return Objects.equals(this.justNumber, numberOnly.justNumber); + } + + @Override + public int hashCode() { + return Objects.hash(justNumber); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NumberOnly {\n"); + + sb.append(" justNumber: ").append(toIndentedString(justNumber)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Order.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Order.java new file mode 100644 index 000000000000..5c9bb7ae7e4a --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Order.java @@ -0,0 +1,247 @@ +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 org.threeten.bp.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Order + */ +@javax.annotation.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") + @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "petId", defaultValue = "") + + + 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 + */ + @Schema(name = "quantity", defaultValue = "") + + + 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 + */ + @Schema(name = "shipDate", defaultValue = "") + + @Valid + + 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 + */ + @Schema(name = "status", defaultValue = "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 + */ + @Schema(name = "complete", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/OuterComposite.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/OuterComposite.java new file mode 100644 index 000000000000..cea0bf2f7578 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/OuterComposite.java @@ -0,0 +1,133 @@ +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 java.math.BigDecimal; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * OuterComposite + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class OuterComposite { + @JsonProperty("my_number") + private BigDecimal myNumber; + + @JsonProperty("my_string") + private String myString; + + @JsonProperty("my_boolean") + private Boolean myBoolean; + + public OuterComposite myNumber(BigDecimal myNumber) { + this.myNumber = myNumber; + return this; + } + + /** + * Get myNumber + * @return myNumber + */ + @Schema(name = "myNumber", defaultValue = "") + + @Valid + + public BigDecimal getMyNumber() { + return myNumber; + } + + public void setMyNumber(BigDecimal myNumber) { + this.myNumber = myNumber; + } + + public OuterComposite myString(String myString) { + this.myString = myString; + return this; + } + + /** + * Get myString + * @return myString + */ + @Schema(name = "myString", defaultValue = "") + + + public String getMyString() { + return myString; + } + + public void setMyString(String myString) { + this.myString = myString; + } + + public OuterComposite myBoolean(Boolean myBoolean) { + this.myBoolean = myBoolean; + return this; + } + + /** + * Get myBoolean + * @return myBoolean + */ + @Schema(name = "myBoolean", defaultValue = "") + + + public Boolean getMyBoolean() { + return myBoolean; + } + + public void setMyBoolean(Boolean myBoolean) { + this.myBoolean = myBoolean; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OuterComposite outerComposite = (OuterComposite) o; + return Objects.equals(this.myNumber, outerComposite.myNumber) && + Objects.equals(this.myString, outerComposite.myString) && + Objects.equals(this.myBoolean, outerComposite.myBoolean); + } + + @Override + public int hashCode() { + return Objects.hash(myNumber, myString, myBoolean); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OuterComposite {\n"); + + sb.append(" myNumber: ").append(toIndentedString(myNumber)).append("\n"); + sb.append(" myString: ").append(toIndentedString(myString)).append("\n"); + sb.append(" myBoolean: ").append(toIndentedString(myBoolean)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/OuterEnum.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/OuterEnum.java new file mode 100644 index 000000000000..72e7826828f3 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/OuterEnum.java @@ -0,0 +1,53 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonValue; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Gets or Sets OuterEnum + */ +public enum OuterEnum { + + PLACED("placed"), + + APPROVED("approved"), + + DELIVERED("delivered"); + + private String value; + + OuterEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static OuterEnum fromValue(String value) { + for (OuterEnum b : OuterEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Pet.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Pet.java new file mode 100644 index 000000000000..9ca656bd9170 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Pet.java @@ -0,0 +1,274 @@ +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 com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import org.openapitools.model.Category; +import org.openapitools.model.Tag; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Pet + */ +@javax.annotation.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 Set photoUrls = new LinkedHashSet(); + + @JsonProperty("tags") + @Valid + private List 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; + + public Pet id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "category", defaultValue = "") + + @Valid + + 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 + */ + @Schema(name = "name", example = "doggie", required = true, defaultValue = "") + @NotNull + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Pet photoUrls(Set photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + public Pet addPhotoUrlsItem(String photoUrlsItem) { + if (this.photoUrls == null) { + this.photoUrls = new LinkedHashSet(); + } + this.photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get photoUrls + * @return photoUrls + */ + @Schema(name = "photoUrls", required = true, defaultValue = "") + @NotNull + + + public Set getPhotoUrls() { + return photoUrls; + } + + @JsonDeserialize(as = LinkedHashSet.class) + public void setPhotoUrls(Set photoUrls) { + this.photoUrls = photoUrls; + } + + public Pet tags(List 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 + */ + @Schema(name = "tags", defaultValue = "") + + @Valid + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * pet status in the store + * @return status + */ + @Schema(name = "status", defaultValue = "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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ReadOnlyFirst.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ReadOnlyFirst.java new file mode 100644 index 000000000000..15b221c739be --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ReadOnlyFirst.java @@ -0,0 +1,106 @@ +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 javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ReadOnlyFirst + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ReadOnlyFirst { + @JsonProperty("bar") + private String bar; + + @JsonProperty("baz") + private String baz; + + public ReadOnlyFirst bar(String bar) { + this.bar = bar; + return this; + } + + /** + * Get bar + * @return bar + */ + @Schema(name = "bar", readOnly = true, defaultValue = "") + + + public String getBar() { + return bar; + } + + public void setBar(String bar) { + this.bar = bar; + } + + public ReadOnlyFirst baz(String baz) { + this.baz = baz; + return this; + } + + /** + * Get baz + * @return baz + */ + @Schema(name = "baz", defaultValue = "") + + + public String getBaz() { + return baz; + } + + public void setBaz(String baz) { + this.baz = baz; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReadOnlyFirst readOnlyFirst = (ReadOnlyFirst) o; + return Objects.equals(this.bar, readOnlyFirst.bar) && + Objects.equals(this.baz, readOnlyFirst.baz); + } + + @Override + public int hashCode() { + return Objects.hash(bar, baz); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ReadOnlyFirst {\n"); + + sb.append(" bar: ").append(toIndentedString(bar)).append("\n"); + sb.append(" baz: ").append(toIndentedString(baz)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/SpecialModelName.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/SpecialModelName.java new file mode 100644 index 000000000000..56ced4dc6f0a --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/SpecialModelName.java @@ -0,0 +1,81 @@ +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 javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * SpecialModelName + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class SpecialModelName { + @JsonProperty("$special[property.name]") + private Long $specialPropertyName; + + public SpecialModelName $specialPropertyName(Long $specialPropertyName) { + this.$specialPropertyName = $specialPropertyName; + return this; + } + + /** + * Get $specialPropertyName + * @return $specialPropertyName + */ + @Schema(name = "$specialPropertyName", defaultValue = "") + + + public Long get$SpecialPropertyName() { + return $specialPropertyName; + } + + public void set$SpecialPropertyName(Long $specialPropertyName) { + this.$specialPropertyName = $specialPropertyName; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SpecialModelName $specialModelName = (SpecialModelName) o; + return Objects.equals(this.$specialPropertyName, $specialModelName.$specialPropertyName); + } + + @Override + public int hashCode() { + return Objects.hash($specialPropertyName); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SpecialModelName {\n"); + + sb.append(" $specialPropertyName: ").append(toIndentedString($specialPropertyName)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Tag.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Tag.java new file mode 100644 index 000000000000..f98b6a0b281d --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Tag.java @@ -0,0 +1,106 @@ +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 javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Tag + */ +@javax.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "name", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/TypeHolderDefault.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/TypeHolderDefault.java new file mode 100644 index 000000000000..d346c36b80aa --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/TypeHolderDefault.java @@ -0,0 +1,199 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * TypeHolderDefault + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class TypeHolderDefault { + @JsonProperty("string_item") + private String stringItem = "what"; + + @JsonProperty("number_item") + private BigDecimal numberItem; + + @JsonProperty("integer_item") + private Integer integerItem; + + @JsonProperty("bool_item") + private Boolean boolItem = true; + + @JsonProperty("array_item") + @Valid + private List arrayItem = new ArrayList(); + + public TypeHolderDefault stringItem(String stringItem) { + this.stringItem = stringItem; + return this; + } + + /** + * Get stringItem + * @return stringItem + */ + @Schema(name = "stringItem", required = true, defaultValue = "") + @NotNull + + + public String getStringItem() { + return stringItem; + } + + public void setStringItem(String stringItem) { + this.stringItem = stringItem; + } + + public TypeHolderDefault numberItem(BigDecimal numberItem) { + this.numberItem = numberItem; + return this; + } + + /** + * Get numberItem + * @return numberItem + */ + @Schema(name = "numberItem", required = true, defaultValue = "") + @NotNull + + @Valid + + public BigDecimal getNumberItem() { + return numberItem; + } + + public void setNumberItem(BigDecimal numberItem) { + this.numberItem = numberItem; + } + + public TypeHolderDefault integerItem(Integer integerItem) { + this.integerItem = integerItem; + return this; + } + + /** + * Get integerItem + * @return integerItem + */ + @Schema(name = "integerItem", required = true, defaultValue = "") + @NotNull + + + public Integer getIntegerItem() { + return integerItem; + } + + public void setIntegerItem(Integer integerItem) { + this.integerItem = integerItem; + } + + public TypeHolderDefault boolItem(Boolean boolItem) { + this.boolItem = boolItem; + return this; + } + + /** + * Get boolItem + * @return boolItem + */ + @Schema(name = "boolItem", required = true, defaultValue = "") + @NotNull + + + public Boolean getBoolItem() { + return boolItem; + } + + public void setBoolItem(Boolean boolItem) { + this.boolItem = boolItem; + } + + public TypeHolderDefault arrayItem(List arrayItem) { + this.arrayItem = arrayItem; + return this; + } + + public TypeHolderDefault addArrayItemItem(Integer arrayItemItem) { + if (this.arrayItem == null) { + this.arrayItem = new ArrayList(); + } + this.arrayItem.add(arrayItemItem); + return this; + } + + /** + * Get arrayItem + * @return arrayItem + */ + @Schema(name = "arrayItem", required = true, defaultValue = "") + @NotNull + + + public List getArrayItem() { + return arrayItem; + } + + public void setArrayItem(List arrayItem) { + this.arrayItem = arrayItem; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TypeHolderDefault typeHolderDefault = (TypeHolderDefault) o; + return Objects.equals(this.stringItem, typeHolderDefault.stringItem) && + Objects.equals(this.numberItem, typeHolderDefault.numberItem) && + Objects.equals(this.integerItem, typeHolderDefault.integerItem) && + Objects.equals(this.boolItem, typeHolderDefault.boolItem) && + Objects.equals(this.arrayItem, typeHolderDefault.arrayItem); + } + + @Override + public int hashCode() { + return Objects.hash(stringItem, numberItem, integerItem, boolItem, arrayItem); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TypeHolderDefault {\n"); + + sb.append(" stringItem: ").append(toIndentedString(stringItem)).append("\n"); + sb.append(" numberItem: ").append(toIndentedString(numberItem)).append("\n"); + sb.append(" integerItem: ").append(toIndentedString(integerItem)).append("\n"); + sb.append(" boolItem: ").append(toIndentedString(boolItem)).append("\n"); + sb.append(" arrayItem: ").append(toIndentedString(arrayItem)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/TypeHolderExample.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/TypeHolderExample.java new file mode 100644 index 000000000000..c62a0e4dc71f --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/TypeHolderExample.java @@ -0,0 +1,225 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * TypeHolderExample + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class TypeHolderExample { + @JsonProperty("string_item") + private String stringItem; + + @JsonProperty("number_item") + private BigDecimal numberItem; + + @JsonProperty("float_item") + private Float floatItem; + + @JsonProperty("integer_item") + private Integer integerItem; + + @JsonProperty("bool_item") + private Boolean boolItem; + + @JsonProperty("array_item") + @Valid + private List arrayItem = new ArrayList(); + + public TypeHolderExample stringItem(String stringItem) { + this.stringItem = stringItem; + return this; + } + + /** + * Get stringItem + * @return stringItem + */ + @Schema(name = "stringItem", example = "what", required = true, defaultValue = "") + @NotNull + + + public String getStringItem() { + return stringItem; + } + + public void setStringItem(String stringItem) { + this.stringItem = stringItem; + } + + public TypeHolderExample numberItem(BigDecimal numberItem) { + this.numberItem = numberItem; + return this; + } + + /** + * Get numberItem + * @return numberItem + */ + @Schema(name = "numberItem", example = "1.234", required = true, defaultValue = "") + @NotNull + + @Valid + + public BigDecimal getNumberItem() { + return numberItem; + } + + public void setNumberItem(BigDecimal numberItem) { + this.numberItem = numberItem; + } + + public TypeHolderExample floatItem(Float floatItem) { + this.floatItem = floatItem; + return this; + } + + /** + * Get floatItem + * @return floatItem + */ + @Schema(name = "floatItem", example = "1.234", required = true, defaultValue = "") + @NotNull + + + public Float getFloatItem() { + return floatItem; + } + + public void setFloatItem(Float floatItem) { + this.floatItem = floatItem; + } + + public TypeHolderExample integerItem(Integer integerItem) { + this.integerItem = integerItem; + return this; + } + + /** + * Get integerItem + * @return integerItem + */ + @Schema(name = "integerItem", example = "-2", required = true, defaultValue = "") + @NotNull + + + public Integer getIntegerItem() { + return integerItem; + } + + public void setIntegerItem(Integer integerItem) { + this.integerItem = integerItem; + } + + public TypeHolderExample boolItem(Boolean boolItem) { + this.boolItem = boolItem; + return this; + } + + /** + * Get boolItem + * @return boolItem + */ + @Schema(name = "boolItem", example = "true", required = true, defaultValue = "") + @NotNull + + + public Boolean getBoolItem() { + return boolItem; + } + + public void setBoolItem(Boolean boolItem) { + this.boolItem = boolItem; + } + + public TypeHolderExample arrayItem(List arrayItem) { + this.arrayItem = arrayItem; + return this; + } + + public TypeHolderExample addArrayItemItem(Integer arrayItemItem) { + if (this.arrayItem == null) { + this.arrayItem = new ArrayList(); + } + this.arrayItem.add(arrayItemItem); + return this; + } + + /** + * Get arrayItem + * @return arrayItem + */ + @Schema(name = "arrayItem", example = "[0, 1, 2, 3]", required = true, defaultValue = "") + @NotNull + + + public List getArrayItem() { + return arrayItem; + } + + public void setArrayItem(List arrayItem) { + this.arrayItem = arrayItem; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TypeHolderExample typeHolderExample = (TypeHolderExample) o; + return Objects.equals(this.stringItem, typeHolderExample.stringItem) && + Objects.equals(this.numberItem, typeHolderExample.numberItem) && + Objects.equals(this.floatItem, typeHolderExample.floatItem) && + Objects.equals(this.integerItem, typeHolderExample.integerItem) && + Objects.equals(this.boolItem, typeHolderExample.boolItem) && + Objects.equals(this.arrayItem, typeHolderExample.arrayItem); + } + + @Override + public int hashCode() { + return Objects.hash(stringItem, numberItem, floatItem, integerItem, boolItem, arrayItem); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TypeHolderExample {\n"); + + sb.append(" stringItem: ").append(toIndentedString(stringItem)).append("\n"); + sb.append(" numberItem: ").append(toIndentedString(numberItem)).append("\n"); + sb.append(" floatItem: ").append(toIndentedString(floatItem)).append("\n"); + sb.append(" integerItem: ").append(toIndentedString(integerItem)).append("\n"); + sb.append(" boolItem: ").append(toIndentedString(boolItem)).append("\n"); + sb.append(" arrayItem: ").append(toIndentedString(arrayItem)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/User.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/User.java new file mode 100644 index 000000000000..155bdf978d59 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/User.java @@ -0,0 +1,256 @@ +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 javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * User + */ +@javax.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "username", defaultValue = "") + + + 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 + */ + @Schema(name = "firstName", defaultValue = "") + + + 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 + */ + @Schema(name = "lastName", defaultValue = "") + + + 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 + */ + @Schema(name = "email", defaultValue = "") + + + 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 + */ + @Schema(name = "password", defaultValue = "") + + + 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 + */ + @Schema(name = "phone", defaultValue = "") + + + 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 + */ + @Schema(name = "userStatus", defaultValue = "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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/XmlItem.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/XmlItem.java new file mode 100644 index 000000000000..9f829a1a26fe --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/XmlItem.java @@ -0,0 +1,870 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * XmlItem + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class XmlItem { + @JsonProperty("attribute_string") + private String attributeString; + + @JsonProperty("attribute_number") + private BigDecimal attributeNumber; + + @JsonProperty("attribute_integer") + private Integer attributeInteger; + + @JsonProperty("attribute_boolean") + private Boolean attributeBoolean; + + @JsonProperty("wrapped_array") + @Valid + private List wrappedArray = null; + + @JsonProperty("name_string") + private String nameString; + + @JsonProperty("name_number") + private BigDecimal nameNumber; + + @JsonProperty("name_integer") + private Integer nameInteger; + + @JsonProperty("name_boolean") + private Boolean nameBoolean; + + @JsonProperty("name_array") + @Valid + private List nameArray = null; + + @JsonProperty("name_wrapped_array") + @Valid + private List nameWrappedArray = null; + + @JsonProperty("prefix_string") + private String prefixString; + + @JsonProperty("prefix_number") + private BigDecimal prefixNumber; + + @JsonProperty("prefix_integer") + private Integer prefixInteger; + + @JsonProperty("prefix_boolean") + private Boolean prefixBoolean; + + @JsonProperty("prefix_array") + @Valid + private List prefixArray = null; + + @JsonProperty("prefix_wrapped_array") + @Valid + private List prefixWrappedArray = null; + + @JsonProperty("namespace_string") + private String namespaceString; + + @JsonProperty("namespace_number") + private BigDecimal namespaceNumber; + + @JsonProperty("namespace_integer") + private Integer namespaceInteger; + + @JsonProperty("namespace_boolean") + private Boolean namespaceBoolean; + + @JsonProperty("namespace_array") + @Valid + private List namespaceArray = null; + + @JsonProperty("namespace_wrapped_array") + @Valid + private List namespaceWrappedArray = null; + + @JsonProperty("prefix_ns_string") + private String prefixNsString; + + @JsonProperty("prefix_ns_number") + private BigDecimal prefixNsNumber; + + @JsonProperty("prefix_ns_integer") + private Integer prefixNsInteger; + + @JsonProperty("prefix_ns_boolean") + private Boolean prefixNsBoolean; + + @JsonProperty("prefix_ns_array") + @Valid + private List prefixNsArray = null; + + @JsonProperty("prefix_ns_wrapped_array") + @Valid + private List prefixNsWrappedArray = null; + + public XmlItem attributeString(String attributeString) { + this.attributeString = attributeString; + return this; + } + + /** + * Get attributeString + * @return attributeString + */ + @Schema(name = "attributeString", example = "string", defaultValue = "") + + + public String getAttributeString() { + return attributeString; + } + + public void setAttributeString(String attributeString) { + this.attributeString = attributeString; + } + + public XmlItem attributeNumber(BigDecimal attributeNumber) { + this.attributeNumber = attributeNumber; + return this; + } + + /** + * Get attributeNumber + * @return attributeNumber + */ + @Schema(name = "attributeNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getAttributeNumber() { + return attributeNumber; + } + + public void setAttributeNumber(BigDecimal attributeNumber) { + this.attributeNumber = attributeNumber; + } + + public XmlItem attributeInteger(Integer attributeInteger) { + this.attributeInteger = attributeInteger; + return this; + } + + /** + * Get attributeInteger + * @return attributeInteger + */ + @Schema(name = "attributeInteger", example = "-2", defaultValue = "") + + + public Integer getAttributeInteger() { + return attributeInteger; + } + + public void setAttributeInteger(Integer attributeInteger) { + this.attributeInteger = attributeInteger; + } + + public XmlItem attributeBoolean(Boolean attributeBoolean) { + this.attributeBoolean = attributeBoolean; + return this; + } + + /** + * Get attributeBoolean + * @return attributeBoolean + */ + @Schema(name = "attributeBoolean", example = "true", defaultValue = "") + + + public Boolean getAttributeBoolean() { + return attributeBoolean; + } + + public void setAttributeBoolean(Boolean attributeBoolean) { + this.attributeBoolean = attributeBoolean; + } + + public XmlItem wrappedArray(List wrappedArray) { + this.wrappedArray = wrappedArray; + return this; + } + + public XmlItem addWrappedArrayItem(Integer wrappedArrayItem) { + if (this.wrappedArray == null) { + this.wrappedArray = new ArrayList(); + } + this.wrappedArray.add(wrappedArrayItem); + return this; + } + + /** + * Get wrappedArray + * @return wrappedArray + */ + @Schema(name = "wrappedArray", defaultValue = "") + + + public List getWrappedArray() { + return wrappedArray; + } + + public void setWrappedArray(List wrappedArray) { + this.wrappedArray = wrappedArray; + } + + public XmlItem nameString(String nameString) { + this.nameString = nameString; + return this; + } + + /** + * Get nameString + * @return nameString + */ + @Schema(name = "nameString", example = "string", defaultValue = "") + + + public String getNameString() { + return nameString; + } + + public void setNameString(String nameString) { + this.nameString = nameString; + } + + public XmlItem nameNumber(BigDecimal nameNumber) { + this.nameNumber = nameNumber; + return this; + } + + /** + * Get nameNumber + * @return nameNumber + */ + @Schema(name = "nameNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getNameNumber() { + return nameNumber; + } + + public void setNameNumber(BigDecimal nameNumber) { + this.nameNumber = nameNumber; + } + + public XmlItem nameInteger(Integer nameInteger) { + this.nameInteger = nameInteger; + return this; + } + + /** + * Get nameInteger + * @return nameInteger + */ + @Schema(name = "nameInteger", example = "-2", defaultValue = "") + + + public Integer getNameInteger() { + return nameInteger; + } + + public void setNameInteger(Integer nameInteger) { + this.nameInteger = nameInteger; + } + + public XmlItem nameBoolean(Boolean nameBoolean) { + this.nameBoolean = nameBoolean; + return this; + } + + /** + * Get nameBoolean + * @return nameBoolean + */ + @Schema(name = "nameBoolean", example = "true", defaultValue = "") + + + public Boolean getNameBoolean() { + return nameBoolean; + } + + public void setNameBoolean(Boolean nameBoolean) { + this.nameBoolean = nameBoolean; + } + + public XmlItem nameArray(List nameArray) { + this.nameArray = nameArray; + return this; + } + + public XmlItem addNameArrayItem(Integer nameArrayItem) { + if (this.nameArray == null) { + this.nameArray = new ArrayList(); + } + this.nameArray.add(nameArrayItem); + return this; + } + + /** + * Get nameArray + * @return nameArray + */ + @Schema(name = "nameArray", defaultValue = "") + + + public List getNameArray() { + return nameArray; + } + + public void setNameArray(List nameArray) { + this.nameArray = nameArray; + } + + public XmlItem nameWrappedArray(List nameWrappedArray) { + this.nameWrappedArray = nameWrappedArray; + return this; + } + + public XmlItem addNameWrappedArrayItem(Integer nameWrappedArrayItem) { + if (this.nameWrappedArray == null) { + this.nameWrappedArray = new ArrayList(); + } + this.nameWrappedArray.add(nameWrappedArrayItem); + return this; + } + + /** + * Get nameWrappedArray + * @return nameWrappedArray + */ + @Schema(name = "nameWrappedArray", defaultValue = "") + + + public List getNameWrappedArray() { + return nameWrappedArray; + } + + public void setNameWrappedArray(List nameWrappedArray) { + this.nameWrappedArray = nameWrappedArray; + } + + public XmlItem prefixString(String prefixString) { + this.prefixString = prefixString; + return this; + } + + /** + * Get prefixString + * @return prefixString + */ + @Schema(name = "prefixString", example = "string", defaultValue = "") + + + public String getPrefixString() { + return prefixString; + } + + public void setPrefixString(String prefixString) { + this.prefixString = prefixString; + } + + public XmlItem prefixNumber(BigDecimal prefixNumber) { + this.prefixNumber = prefixNumber; + return this; + } + + /** + * Get prefixNumber + * @return prefixNumber + */ + @Schema(name = "prefixNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getPrefixNumber() { + return prefixNumber; + } + + public void setPrefixNumber(BigDecimal prefixNumber) { + this.prefixNumber = prefixNumber; + } + + public XmlItem prefixInteger(Integer prefixInteger) { + this.prefixInteger = prefixInteger; + return this; + } + + /** + * Get prefixInteger + * @return prefixInteger + */ + @Schema(name = "prefixInteger", example = "-2", defaultValue = "") + + + public Integer getPrefixInteger() { + return prefixInteger; + } + + public void setPrefixInteger(Integer prefixInteger) { + this.prefixInteger = prefixInteger; + } + + public XmlItem prefixBoolean(Boolean prefixBoolean) { + this.prefixBoolean = prefixBoolean; + return this; + } + + /** + * Get prefixBoolean + * @return prefixBoolean + */ + @Schema(name = "prefixBoolean", example = "true", defaultValue = "") + + + public Boolean getPrefixBoolean() { + return prefixBoolean; + } + + public void setPrefixBoolean(Boolean prefixBoolean) { + this.prefixBoolean = prefixBoolean; + } + + public XmlItem prefixArray(List prefixArray) { + this.prefixArray = prefixArray; + return this; + } + + public XmlItem addPrefixArrayItem(Integer prefixArrayItem) { + if (this.prefixArray == null) { + this.prefixArray = new ArrayList(); + } + this.prefixArray.add(prefixArrayItem); + return this; + } + + /** + * Get prefixArray + * @return prefixArray + */ + @Schema(name = "prefixArray", defaultValue = "") + + + public List getPrefixArray() { + return prefixArray; + } + + public void setPrefixArray(List prefixArray) { + this.prefixArray = prefixArray; + } + + public XmlItem prefixWrappedArray(List prefixWrappedArray) { + this.prefixWrappedArray = prefixWrappedArray; + return this; + } + + public XmlItem addPrefixWrappedArrayItem(Integer prefixWrappedArrayItem) { + if (this.prefixWrappedArray == null) { + this.prefixWrappedArray = new ArrayList(); + } + this.prefixWrappedArray.add(prefixWrappedArrayItem); + return this; + } + + /** + * Get prefixWrappedArray + * @return prefixWrappedArray + */ + @Schema(name = "prefixWrappedArray", defaultValue = "") + + + public List getPrefixWrappedArray() { + return prefixWrappedArray; + } + + public void setPrefixWrappedArray(List prefixWrappedArray) { + this.prefixWrappedArray = prefixWrappedArray; + } + + public XmlItem namespaceString(String namespaceString) { + this.namespaceString = namespaceString; + return this; + } + + /** + * Get namespaceString + * @return namespaceString + */ + @Schema(name = "namespaceString", example = "string", defaultValue = "") + + + public String getNamespaceString() { + return namespaceString; + } + + public void setNamespaceString(String namespaceString) { + this.namespaceString = namespaceString; + } + + public XmlItem namespaceNumber(BigDecimal namespaceNumber) { + this.namespaceNumber = namespaceNumber; + return this; + } + + /** + * Get namespaceNumber + * @return namespaceNumber + */ + @Schema(name = "namespaceNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getNamespaceNumber() { + return namespaceNumber; + } + + public void setNamespaceNumber(BigDecimal namespaceNumber) { + this.namespaceNumber = namespaceNumber; + } + + public XmlItem namespaceInteger(Integer namespaceInteger) { + this.namespaceInteger = namespaceInteger; + return this; + } + + /** + * Get namespaceInteger + * @return namespaceInteger + */ + @Schema(name = "namespaceInteger", example = "-2", defaultValue = "") + + + public Integer getNamespaceInteger() { + return namespaceInteger; + } + + public void setNamespaceInteger(Integer namespaceInteger) { + this.namespaceInteger = namespaceInteger; + } + + public XmlItem namespaceBoolean(Boolean namespaceBoolean) { + this.namespaceBoolean = namespaceBoolean; + return this; + } + + /** + * Get namespaceBoolean + * @return namespaceBoolean + */ + @Schema(name = "namespaceBoolean", example = "true", defaultValue = "") + + + public Boolean getNamespaceBoolean() { + return namespaceBoolean; + } + + public void setNamespaceBoolean(Boolean namespaceBoolean) { + this.namespaceBoolean = namespaceBoolean; + } + + public XmlItem namespaceArray(List namespaceArray) { + this.namespaceArray = namespaceArray; + return this; + } + + public XmlItem addNamespaceArrayItem(Integer namespaceArrayItem) { + if (this.namespaceArray == null) { + this.namespaceArray = new ArrayList(); + } + this.namespaceArray.add(namespaceArrayItem); + return this; + } + + /** + * Get namespaceArray + * @return namespaceArray + */ + @Schema(name = "namespaceArray", defaultValue = "") + + + public List getNamespaceArray() { + return namespaceArray; + } + + public void setNamespaceArray(List namespaceArray) { + this.namespaceArray = namespaceArray; + } + + public XmlItem namespaceWrappedArray(List namespaceWrappedArray) { + this.namespaceWrappedArray = namespaceWrappedArray; + return this; + } + + public XmlItem addNamespaceWrappedArrayItem(Integer namespaceWrappedArrayItem) { + if (this.namespaceWrappedArray == null) { + this.namespaceWrappedArray = new ArrayList(); + } + this.namespaceWrappedArray.add(namespaceWrappedArrayItem); + return this; + } + + /** + * Get namespaceWrappedArray + * @return namespaceWrappedArray + */ + @Schema(name = "namespaceWrappedArray", defaultValue = "") + + + public List getNamespaceWrappedArray() { + return namespaceWrappedArray; + } + + public void setNamespaceWrappedArray(List namespaceWrappedArray) { + this.namespaceWrappedArray = namespaceWrappedArray; + } + + public XmlItem prefixNsString(String prefixNsString) { + this.prefixNsString = prefixNsString; + return this; + } + + /** + * Get prefixNsString + * @return prefixNsString + */ + @Schema(name = "prefixNsString", example = "string", defaultValue = "") + + + public String getPrefixNsString() { + return prefixNsString; + } + + public void setPrefixNsString(String prefixNsString) { + this.prefixNsString = prefixNsString; + } + + public XmlItem prefixNsNumber(BigDecimal prefixNsNumber) { + this.prefixNsNumber = prefixNsNumber; + return this; + } + + /** + * Get prefixNsNumber + * @return prefixNsNumber + */ + @Schema(name = "prefixNsNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getPrefixNsNumber() { + return prefixNsNumber; + } + + public void setPrefixNsNumber(BigDecimal prefixNsNumber) { + this.prefixNsNumber = prefixNsNumber; + } + + public XmlItem prefixNsInteger(Integer prefixNsInteger) { + this.prefixNsInteger = prefixNsInteger; + return this; + } + + /** + * Get prefixNsInteger + * @return prefixNsInteger + */ + @Schema(name = "prefixNsInteger", example = "-2", defaultValue = "") + + + public Integer getPrefixNsInteger() { + return prefixNsInteger; + } + + public void setPrefixNsInteger(Integer prefixNsInteger) { + this.prefixNsInteger = prefixNsInteger; + } + + public XmlItem prefixNsBoolean(Boolean prefixNsBoolean) { + this.prefixNsBoolean = prefixNsBoolean; + return this; + } + + /** + * Get prefixNsBoolean + * @return prefixNsBoolean + */ + @Schema(name = "prefixNsBoolean", example = "true", defaultValue = "") + + + public Boolean getPrefixNsBoolean() { + return prefixNsBoolean; + } + + public void setPrefixNsBoolean(Boolean prefixNsBoolean) { + this.prefixNsBoolean = prefixNsBoolean; + } + + public XmlItem prefixNsArray(List prefixNsArray) { + this.prefixNsArray = prefixNsArray; + return this; + } + + public XmlItem addPrefixNsArrayItem(Integer prefixNsArrayItem) { + if (this.prefixNsArray == null) { + this.prefixNsArray = new ArrayList(); + } + this.prefixNsArray.add(prefixNsArrayItem); + return this; + } + + /** + * Get prefixNsArray + * @return prefixNsArray + */ + @Schema(name = "prefixNsArray", defaultValue = "") + + + public List getPrefixNsArray() { + return prefixNsArray; + } + + public void setPrefixNsArray(List prefixNsArray) { + this.prefixNsArray = prefixNsArray; + } + + public XmlItem prefixNsWrappedArray(List prefixNsWrappedArray) { + this.prefixNsWrappedArray = prefixNsWrappedArray; + return this; + } + + public XmlItem addPrefixNsWrappedArrayItem(Integer prefixNsWrappedArrayItem) { + if (this.prefixNsWrappedArray == null) { + this.prefixNsWrappedArray = new ArrayList(); + } + this.prefixNsWrappedArray.add(prefixNsWrappedArrayItem); + return this; + } + + /** + * Get prefixNsWrappedArray + * @return prefixNsWrappedArray + */ + @Schema(name = "prefixNsWrappedArray", defaultValue = "") + + + public List getPrefixNsWrappedArray() { + return prefixNsWrappedArray; + } + + public void setPrefixNsWrappedArray(List prefixNsWrappedArray) { + this.prefixNsWrappedArray = prefixNsWrappedArray; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + XmlItem xmlItem = (XmlItem) o; + return Objects.equals(this.attributeString, xmlItem.attributeString) && + Objects.equals(this.attributeNumber, xmlItem.attributeNumber) && + Objects.equals(this.attributeInteger, xmlItem.attributeInteger) && + Objects.equals(this.attributeBoolean, xmlItem.attributeBoolean) && + Objects.equals(this.wrappedArray, xmlItem.wrappedArray) && + Objects.equals(this.nameString, xmlItem.nameString) && + Objects.equals(this.nameNumber, xmlItem.nameNumber) && + Objects.equals(this.nameInteger, xmlItem.nameInteger) && + Objects.equals(this.nameBoolean, xmlItem.nameBoolean) && + Objects.equals(this.nameArray, xmlItem.nameArray) && + Objects.equals(this.nameWrappedArray, xmlItem.nameWrappedArray) && + Objects.equals(this.prefixString, xmlItem.prefixString) && + Objects.equals(this.prefixNumber, xmlItem.prefixNumber) && + Objects.equals(this.prefixInteger, xmlItem.prefixInteger) && + Objects.equals(this.prefixBoolean, xmlItem.prefixBoolean) && + Objects.equals(this.prefixArray, xmlItem.prefixArray) && + Objects.equals(this.prefixWrappedArray, xmlItem.prefixWrappedArray) && + Objects.equals(this.namespaceString, xmlItem.namespaceString) && + Objects.equals(this.namespaceNumber, xmlItem.namespaceNumber) && + Objects.equals(this.namespaceInteger, xmlItem.namespaceInteger) && + Objects.equals(this.namespaceBoolean, xmlItem.namespaceBoolean) && + Objects.equals(this.namespaceArray, xmlItem.namespaceArray) && + Objects.equals(this.namespaceWrappedArray, xmlItem.namespaceWrappedArray) && + Objects.equals(this.prefixNsString, xmlItem.prefixNsString) && + Objects.equals(this.prefixNsNumber, xmlItem.prefixNsNumber) && + Objects.equals(this.prefixNsInteger, xmlItem.prefixNsInteger) && + Objects.equals(this.prefixNsBoolean, xmlItem.prefixNsBoolean) && + Objects.equals(this.prefixNsArray, xmlItem.prefixNsArray) && + Objects.equals(this.prefixNsWrappedArray, xmlItem.prefixNsWrappedArray); + } + + @Override + public int hashCode() { + return Objects.hash(attributeString, attributeNumber, attributeInteger, attributeBoolean, wrappedArray, nameString, nameNumber, nameInteger, nameBoolean, nameArray, nameWrappedArray, prefixString, prefixNumber, prefixInteger, prefixBoolean, prefixArray, prefixWrappedArray, namespaceString, namespaceNumber, namespaceInteger, namespaceBoolean, namespaceArray, namespaceWrappedArray, prefixNsString, prefixNsNumber, prefixNsInteger, prefixNsBoolean, prefixNsArray, prefixNsWrappedArray); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class XmlItem {\n"); + + sb.append(" attributeString: ").append(toIndentedString(attributeString)).append("\n"); + sb.append(" attributeNumber: ").append(toIndentedString(attributeNumber)).append("\n"); + sb.append(" attributeInteger: ").append(toIndentedString(attributeInteger)).append("\n"); + sb.append(" attributeBoolean: ").append(toIndentedString(attributeBoolean)).append("\n"); + sb.append(" wrappedArray: ").append(toIndentedString(wrappedArray)).append("\n"); + sb.append(" nameString: ").append(toIndentedString(nameString)).append("\n"); + sb.append(" nameNumber: ").append(toIndentedString(nameNumber)).append("\n"); + sb.append(" nameInteger: ").append(toIndentedString(nameInteger)).append("\n"); + sb.append(" nameBoolean: ").append(toIndentedString(nameBoolean)).append("\n"); + sb.append(" nameArray: ").append(toIndentedString(nameArray)).append("\n"); + sb.append(" nameWrappedArray: ").append(toIndentedString(nameWrappedArray)).append("\n"); + sb.append(" prefixString: ").append(toIndentedString(prefixString)).append("\n"); + sb.append(" prefixNumber: ").append(toIndentedString(prefixNumber)).append("\n"); + sb.append(" prefixInteger: ").append(toIndentedString(prefixInteger)).append("\n"); + sb.append(" prefixBoolean: ").append(toIndentedString(prefixBoolean)).append("\n"); + sb.append(" prefixArray: ").append(toIndentedString(prefixArray)).append("\n"); + sb.append(" prefixWrappedArray: ").append(toIndentedString(prefixWrappedArray)).append("\n"); + sb.append(" namespaceString: ").append(toIndentedString(namespaceString)).append("\n"); + sb.append(" namespaceNumber: ").append(toIndentedString(namespaceNumber)).append("\n"); + sb.append(" namespaceInteger: ").append(toIndentedString(namespaceInteger)).append("\n"); + sb.append(" namespaceBoolean: ").append(toIndentedString(namespaceBoolean)).append("\n"); + sb.append(" namespaceArray: ").append(toIndentedString(namespaceArray)).append("\n"); + sb.append(" namespaceWrappedArray: ").append(toIndentedString(namespaceWrappedArray)).append("\n"); + sb.append(" prefixNsString: ").append(toIndentedString(prefixNsString)).append("\n"); + sb.append(" prefixNsNumber: ").append(toIndentedString(prefixNsNumber)).append("\n"); + sb.append(" prefixNsInteger: ").append(toIndentedString(prefixNsInteger)).append("\n"); + sb.append(" prefixNsBoolean: ").append(toIndentedString(prefixNsBoolean)).append("\n"); + sb.append(" prefixNsArray: ").append(toIndentedString(prefixNsArray)).append("\n"); + sb.append(" prefixNsWrappedArray: ").append(toIndentedString(prefixNsWrappedArray)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/resources/application.properties b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/resources/application.properties new file mode 100644 index 000000000000..9d06609db665 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/resources/application.properties @@ -0,0 +1,3 @@ +server.port=80 +spring.jackson.date-format=org.openapitools.RFC3339DateFormat +spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/resources/openapi.yaml b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/resources/openapi.yaml new file mode 100644 index 000000000000..d6386dc39bf4 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/resources/openapi.yaml @@ -0,0 +1,2264 @@ +openapi: 3.0.1 +info: + description: 'This spec is mainly for testing Petstore server and contains fake + endpoints, models. Please do not use this for any other purpose. Special characters: + " \' + license: + name: Apache-2.0 + url: https://www.apache.org/licenses/LICENSE-2.0.html + title: OpenAPI Petstore + version: 1.0.0 +servers: +- url: http://petstore.swagger.io:80/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: + operationId: addPet + requestBody: + 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 + responses: + "200": + content: {} + description: successful operation + "405": + content: {} + description: Invalid input + security: + - petstore_auth: + - write:pets + - read:pets + summary: Add a new pet to the store + tags: + - pet + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: pet + put: + operationId: updatePet + requestBody: + 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 + responses: + "200": + content: {} + description: successful operation + "400": + content: {} + description: Invalid ID supplied + "404": + content: {} + description: Pet not found + "405": + content: {} + description: Validation exception + security: + - petstore_auth: + - write:pets + - read:pets + summary: Update an existing pet + tags: + - pet + x-codegen-request-body-name: body + x-contentType: 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: + - 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": + content: {} + description: Invalid status value + security: + - petstore_auth: + - write:pets + - 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 + uniqueItems: true + style: form + responses: + "200": + content: + application/xml: + schema: + items: + $ref: '#/components/schemas/Pet' + type: array + uniqueItems: true + application/json: + schema: + items: + $ref: '#/components/schemas/Pet' + type: array + uniqueItems: true + description: successful operation + "400": + content: {} + description: Invalid tag value + security: + - petstore_auth: + - write:pets + - read:pets + summary: Finds Pets by tags + tags: + - pet + x-accepts: application/json + x-tags: + - tag: pet + /pet/{petId}: + delete: + operationId: deletePet + parameters: + - in: header + name: api_key + schema: + type: string + - description: Pet id to delete + in: path + name: petId + required: true + schema: + format: int64 + type: integer + responses: + "200": + content: {} + description: successful operation + "400": + content: {} + 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 + in: path + name: petId + required: true + schema: + format: int64 + type: integer + responses: + "200": + content: + application/xml: + schema: + $ref: '#/components/schemas/Pet' + application/json: + schema: + $ref: '#/components/schemas/Pet' + description: successful operation + "400": + content: {} + description: Invalid ID supplied + "404": + content: {} + description: Pet not found + security: + - api_key: [] + summary: Find pet by ID + tags: + - pet + x-accepts: application/json + x-tags: + - tag: pet + post: + operationId: updatePetWithForm + parameters: + - description: ID of pet that needs to be updated + in: path + name: petId + required: true + schema: + format: int64 + type: integer + requestBody: + content: + application/x-www-form-urlencoded: + schema: + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string + responses: + "405": + content: {} + description: Invalid input + security: + - petstore_auth: + - write:pets + - read:pets + summary: Updates a pet in the store with form data + tags: + - pet + x-contentType: application/x-www-form-urlencoded + x-accepts: application/json + x-tags: + - tag: pet + /pet/{petId}/uploadImage: + post: + operationId: uploadFile + parameters: + - description: ID of pet to update + in: path + name: petId + required: true + schema: + format: int64 + type: integer + requestBody: + content: + multipart/form-data: + schema: + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + format: binary + type: string + 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-contentType: 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: + operationId: placeOrder + requestBody: + content: + '*/*': + 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": + content: {} + description: Invalid Order + summary: Place an order for a pet + tags: + - store + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: application/json + x-tags: + - tag: store + /store/order/{order_id}: + 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 + in: path + name: order_id + required: true + schema: + type: string + responses: + "400": + content: {} + description: Invalid ID supplied + "404": + content: {} + 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 generated exceptions + operationId: getOrderById + parameters: + - description: ID of pet that needs to be fetched + in: path + name: order_id + required: true + schema: + format: int64 + maximum: 5 + minimum: 1 + type: integer + responses: + "200": + content: + application/xml: + schema: + $ref: '#/components/schemas/Order' + application/json: + schema: + $ref: '#/components/schemas/Order' + description: successful operation + "400": + content: {} + description: Invalid ID supplied + "404": + content: {} + 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: + '*/*': + schema: + $ref: '#/components/schemas/User' + description: Created user object + required: true + responses: + default: + content: {} + description: successful operation + summary: Create user + tags: + - user + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: application/json + x-tags: + - tag: user + /user/createWithArray: + post: + operationId: createUsersWithArrayInput + requestBody: + content: + '*/*': + schema: + items: + $ref: '#/components/schemas/User' + type: array + description: List of user object + required: true + responses: + default: + content: {} + description: successful operation + summary: Creates list of users with given input array + tags: + - user + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: application/json + x-tags: + - tag: user + /user/createWithList: + post: + operationId: createUsersWithListInput + requestBody: + content: + '*/*': + schema: + items: + $ref: '#/components/schemas/User' + type: array + description: List of user object + required: true + responses: + default: + content: {} + description: successful operation + summary: Creates list of users with given input array + tags: + - user + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: application/json + x-tags: + - tag: user + /user/login: + get: + operationId: loginUser + parameters: + - description: The user name for login + in: query + name: username + required: true + schema: + type: string + - description: The password for login in clear text + in: query + name: password + required: true + schema: + type: string + responses: + "200": + content: + application/xml: + schema: + type: string + application/json: + schema: + type: string + description: successful operation + headers: + X-Rate-Limit: + description: calls per hour allowed by the user + schema: + format: int32 + type: integer + X-Expires-After: + description: date in UTC when token expires + schema: + format: date-time + type: string + "400": + content: {} + description: Invalid username/password supplied + summary: Logs user into the system + tags: + - user + x-accepts: application/json + x-tags: + - tag: user + /user/logout: + get: + operationId: logoutUser + responses: + default: + content: {} + description: successful operation + 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 + in: path + name: username + required: true + schema: + type: string + responses: + "400": + content: {} + description: Invalid username supplied + "404": + content: {} + description: User not found + summary: Delete user + tags: + - user + x-accepts: application/json + x-tags: + - tag: user + get: + operationId: getUserByName + parameters: + - description: The name that needs to be fetched. Use user1 for testing. + in: path + name: username + required: true + schema: + type: string + responses: + "200": + content: + application/xml: + schema: + $ref: '#/components/schemas/User' + application/json: + schema: + $ref: '#/components/schemas/User' + description: successful operation + "400": + content: {} + description: Invalid username supplied + "404": + content: {} + 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 + in: path + name: username + required: true + schema: + type: string + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/User' + description: Updated user object + required: true + responses: + "400": + content: {} + description: Invalid user supplied + "404": + content: {} + description: User not found + summary: Updated user + tags: + - user + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: application/json + x-tags: + - tag: user + /fake_classname_test: + patch: + description: To test class name in snake case + operationId: testClassname + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: client model + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: successful operation + security: + - api_key_query: [] + summary: To test class name in snake case + tags: + - fake_classname_tags 123#$%^ + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: fake_classname_tags 123#$%^ + /fake: + delete: + description: Fake endpoint to test group parameters (optional) + operationId: testGroupParameters + parameters: + - description: Required String in group parameters + in: query + name: required_string_group + required: true + schema: + type: integer + - description: Required Boolean in group parameters + in: header + name: required_boolean_group + required: true + schema: + type: boolean + - description: Required Integer in group parameters + in: query + name: required_int64_group + required: true + schema: + format: int64 + type: integer + - description: String in group parameters + in: query + name: string_group + schema: + type: integer + - description: Boolean in group parameters + in: header + name: boolean_group + schema: + type: boolean + - description: Integer in group parameters + in: query + name: int64_group + schema: + format: int64 + type: integer + responses: + "400": + content: {} + description: Someting wrong + summary: Fake endpoint to test group parameters (optional) + tags: + - fake + x-group-parameters: true + x-accepts: application/json + x-tags: + - tag: fake + get: + description: To test enum parameters + operationId: testEnumParameters + parameters: + - description: Header parameter enum test (string array) + explode: false + in: header + name: enum_header_string_array + schema: + items: + default: $ + enum: + - '>' + - $ + type: string + type: array + style: simple + - description: Header parameter enum test (string) + in: header + name: enum_header_string + schema: + default: -efg + enum: + - _abc + - -efg + - (xyz) + type: string + - description: Query parameter enum test (string array) + explode: false + in: query + name: enum_query_string_array + schema: + items: + default: $ + enum: + - '>' + - $ + type: string + type: array + style: form + - description: Query parameter enum test (string) + in: query + name: enum_query_string + schema: + default: -efg + enum: + - _abc + - -efg + - (xyz) + type: string + - description: Query parameter enum test (double) + in: query + name: enum_query_integer + schema: + enum: + - 1 + - -2 + format: int32 + type: integer + - description: Query parameter enum test (double) + in: query + name: enum_query_double + schema: + enum: + - 1.1 + - -1.2 + format: double + type: number + requestBody: + content: + application/x-www-form-urlencoded: + schema: + properties: + enum_form_string_array: + description: Form parameter enum test (string array) + items: + default: $ + enum: + - '>' + - $ + type: string + type: array + enum_form_string: + default: -efg + description: Form parameter enum test (string) + enum: + - _abc + - -efg + - (xyz) + type: string + responses: + "400": + content: {} + description: Invalid request + "404": + content: {} + description: Not found + summary: To test enum parameters + tags: + - fake + x-contentType: application/x-www-form-urlencoded + x-accepts: application/json + x-tags: + - tag: fake + patch: + description: To test "client" model + operationId: testClientModel + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: client model + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: successful operation + summary: To test "client" model + tags: + - fake + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: fake + post: + description: |- + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + operationId: testEndpointParameters + requestBody: + content: + application/x-www-form-urlencoded: + schema: + properties: + integer: + description: None + format: int32 + maximum: 100 + minimum: 10 + type: integer + int32: + description: None + format: int32 + maximum: 200 + minimum: 20 + type: integer + int64: + description: None + format: int64 + type: integer + number: + description: None + maximum: 543.2 + minimum: 32.1 + type: number + float: + description: None + format: float + maximum: 987.6 + type: number + double: + description: None + format: double + maximum: 123.4 + minimum: 67.8 + type: number + string: + description: None + pattern: /[a-z]/i + type: string + pattern_without_delimiter: + description: None + pattern: ^[A-Z].* + type: string + byte: + description: None + format: byte + type: string + binary: + description: None + format: binary + type: string + date: + description: None + format: date + type: string + dateTime: + description: None + format: date-time + type: string + password: + description: None + format: password + maxLength: 64 + minLength: 10 + type: string + callback: + description: None + type: string + required: + - byte + - double + - number + - pattern_without_delimiter + required: true + responses: + "400": + content: {} + description: Invalid username supplied + "404": + content: {} + description: User not found + security: + - http_basic_test: [] + summary: |- + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + tags: + - fake + x-contentType: application/x-www-form-urlencoded + x-accepts: application/json + x-tags: + - tag: fake + /fake/outer/number: + post: + description: Test serialization of outer number types + operationId: fakeOuterNumberSerialize + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterNumber' + description: Input number as post body + required: false + responses: + "200": + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterNumber' + description: Output number + tags: + - fake + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: '*/*' + x-tags: + - tag: fake + /fake/outer/string: + post: + description: Test serialization of outer string types + operationId: fakeOuterStringSerialize + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterString' + description: Input string as post body + required: false + responses: + "200": + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterString' + description: Output string + tags: + - fake + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: '*/*' + x-tags: + - tag: fake + /fake/outer/boolean: + post: + description: Test serialization of outer boolean types + operationId: fakeOuterBooleanSerialize + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterBoolean' + description: Input boolean as post body + required: false + responses: + "200": + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterBoolean' + description: Output boolean + tags: + - fake + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: '*/*' + x-tags: + - tag: fake + /fake/outer/composite: + post: + description: Test serialization of object with outer number type + operationId: fakeOuterCompositeSerialize + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterComposite' + description: Input composite as post body + required: false + responses: + "200": + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterComposite' + description: Output composite + tags: + - fake + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: '*/*' + x-tags: + - tag: fake + /fake/jsonFormData: + get: + operationId: testJsonFormData + requestBody: + content: + application/x-www-form-urlencoded: + schema: + properties: + param: + description: field1 + type: string + param2: + description: field2 + type: string + required: + - param + - param2 + required: true + responses: + "200": + content: {} + description: successful operation + summary: test json serialization of form data + tags: + - fake + x-contentType: application/x-www-form-urlencoded + x-accepts: application/json + x-tags: + - tag: fake + /fake/inline-additionalProperties: + post: + operationId: testInlineAdditionalProperties + requestBody: + content: + application/json: + schema: + additionalProperties: + type: string + type: object + description: request body + required: true + responses: + "200": + content: {} + description: successful operation + summary: test inline additionalProperties + tags: + - fake + x-codegen-request-body-name: param + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: fake + /fake/body-with-query-params: + put: + operationId: testBodyWithQueryParams + parameters: + - in: query + name: query + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + required: true + responses: + "200": + content: {} + description: Success + tags: + - fake + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: fake + /fake/create_xml_item: + post: + description: this route creates an XmlItem + operationId: createXmlItem + requestBody: + content: + application/xml: + schema: + $ref: '#/components/schemas/XmlItem' + application/xml; charset=utf-8: + schema: + $ref: '#/components/schemas/XmlItem' + application/xml; charset=utf-16: + schema: + $ref: '#/components/schemas/XmlItem' + text/xml: + schema: + $ref: '#/components/schemas/XmlItem' + text/xml; charset=utf-8: + schema: + $ref: '#/components/schemas/XmlItem' + text/xml; charset=utf-16: + schema: + $ref: '#/components/schemas/XmlItem' + description: XmlItem Body + required: true + responses: + "200": + content: {} + description: successful operation + summary: creates an XmlItem + tags: + - fake + x-codegen-request-body-name: XmlItem + x-contentType: application/xml + x-accepts: application/json + x-tags: + - tag: fake + /another-fake/dummy: + patch: + description: To test special tags and operation ID starting with number + operationId: 123_test_@#$%_special_tags + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: client model + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: successful operation + summary: To test special tags + tags: + - $another-fake? + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: $another-fake? + /fake/body-with-file-schema: + put: + description: For this test, the body for this request much reference a schema + named `File`. + operationId: testBodyWithFileSchema + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/FileSchemaTestClass' + required: true + responses: + "200": + content: {} + description: Success + tags: + - fake + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: fake + /fake/test-query-parameters: + put: + description: To test the collection format in query parameters + operationId: testQueryParameterCollectionFormat + parameters: + - explode: false + in: query + name: pipe + required: true + schema: + items: + type: string + type: array + style: form + - in: query + name: ioutil + required: true + schema: + items: + type: string + type: array + - in: query + name: http + required: true + schema: + items: + type: string + type: array + style: spaceDelimited + - explode: false + in: query + name: url + required: true + schema: + items: + type: string + type: array + style: form + - explode: true + in: query + name: context + required: true + schema: + items: + type: string + type: array + style: form + responses: + "200": + content: {} + description: Success + tags: + - fake + x-accepts: application/json + x-tags: + - tag: fake + /fake/{petId}/uploadImageWithRequiredFile: + post: + operationId: uploadFileWithRequiredFile + parameters: + - description: ID of pet to update + in: path + name: petId + required: true + schema: + format: int64 + type: integer + requestBody: + content: + multipart/form-data: + schema: + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + requiredFile: + description: file to upload + format: binary + type: string + required: + - requiredFile + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an image (required) + tags: + - pet + x-contentType: multipart/form-data + x-accepts: application/json + x-tags: + - tag: pet +components: + schemas: + Order: + 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 + type: object + xml: + name: Order + Category: + example: + name: default-name + id: 6 + properties: + id: + format: int64 + type: integer + name: + default: default-name + type: string + required: + - name + type: object + xml: + name: Category + User: + example: + firstName: firstName + lastName: lastName + password: password + userStatus: 6 + phone: phone + id: 0 + email: email + username: username + properties: + id: + format: int64 + type: integer + x-is-unique: true + 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 + type: object + xml: + name: User + Tag: + example: + name: name + id: 1 + properties: + id: + format: int64 + type: integer + name: + type: string + type: object + xml: + name: Tag + Pet: + example: + photoUrls: + - photoUrls + - photoUrls + name: doggie + id: 0 + category: + name: default-name + id: 6 + tags: + - name: name + id: 1 + - name: name + id: 1 + status: available + properties: + id: + format: int64 + type: integer + x-is-unique: true + category: + $ref: '#/components/schemas/Category' + name: + example: doggie + type: string + photoUrls: + items: + type: string + type: array + uniqueItems: true + xml: + name: photoUrl + wrapped: true + tags: + items: + $ref: '#/components/schemas/Tag' + type: array + xml: + name: tag + wrapped: true + status: + description: pet status in the store + enum: + - available + - pending + - sold + type: string + required: + - name + - photoUrls + type: object + xml: + name: Pet + ApiResponse: + example: + code: 0 + type: type + message: message + properties: + code: + format: int32 + type: integer + type: + type: string + message: + type: string + type: object + $special[model.name]: + properties: + $special[property.name]: + format: int64 + type: integer + type: object + xml: + name: $special[model.name] + Return: + description: Model for testing reserved words + properties: + return: + format: int32 + type: integer + type: object + xml: + name: Return + Name: + description: Model for testing model name same as property name + properties: + name: + format: int32 + type: integer + snake_case: + format: int32 + readOnly: true + type: integer + property: + type: string + "123Number": + readOnly: true + type: integer + required: + - name + type: object + xml: + name: Name + "200_response": + description: Model for testing model name starting with number + properties: + name: + format: int32 + type: integer + class: + type: string + type: object + xml: + name: Name + ClassModel: + description: Model for testing model with "_class" property + properties: + _class: + type: string + type: object + Dog: + allOf: + - $ref: '#/components/schemas/Animal' + - $ref: '#/components/schemas/Dog_allOf' + Cat: + allOf: + - $ref: '#/components/schemas/Animal' + - $ref: '#/components/schemas/Cat_allOf' + BigCat: + allOf: + - $ref: '#/components/schemas/Cat' + - $ref: '#/components/schemas/BigCat_allOf' + Animal: + discriminator: + propertyName: className + properties: + className: + type: string + color: + default: red + type: string + required: + - className + type: object + AnimalFarm: + items: + $ref: '#/components/schemas/Animal' + type: array + format_test: + properties: + integer: + maximum: 1E+2 + minimum: 1E+1 + type: integer + int32: + format: int32 + maximum: 2E+2 + minimum: 2E+1 + type: integer + int64: + format: int64 + type: integer + number: + maximum: 543.2 + minimum: 32.1 + type: number + float: + format: float + maximum: 987.6 + minimum: 54.3 + type: number + double: + format: double + maximum: 123.4 + minimum: 67.8 + type: number + string: + pattern: /[a-z]/i + type: string + byte: + format: byte + pattern: ^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$ + type: string + binary: + format: binary + type: string + date: + format: date + type: string + dateTime: + format: date-time + type: string + uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + type: string + password: + format: password + maxLength: 64 + minLength: 10 + type: string + BigDecimal: + format: number + type: string + required: + - byte + - date + - number + - password + type: object + EnumClass: + default: -efg + enum: + - _abc + - -efg + - (xyz) + type: string + Enum_Test: + properties: + enum_string: + enum: + - UPPER + - lower + - "" + type: string + enum_string_required: + enum: + - UPPER + - lower + - "" + type: string + enum_integer: + enum: + - 1 + - -1 + format: int32 + type: integer + enum_number: + enum: + - 1.1 + - -1.2 + format: double + type: number + outerEnum: + $ref: '#/components/schemas/OuterEnum' + required: + - enum_string_required + type: object + AdditionalPropertiesClass: + properties: + map_string: + additionalProperties: + type: string + type: object + map_number: + additionalProperties: + type: number + type: object + map_integer: + additionalProperties: + type: integer + type: object + map_boolean: + additionalProperties: + type: boolean + type: object + map_array_integer: + additionalProperties: + items: + type: integer + type: array + type: object + map_array_anytype: + additionalProperties: + items: + properties: {} + type: object + type: array + type: object + map_map_string: + additionalProperties: + additionalProperties: + type: string + type: object + type: object + map_map_anytype: + additionalProperties: + additionalProperties: + properties: {} + type: object + type: object + type: object + anytype_1: + properties: {} + type: object + anytype_2: + type: object + anytype_3: + properties: {} + type: object + type: object + AdditionalPropertiesString: + additionalProperties: + type: string + properties: + name: + type: string + type: object + AdditionalPropertiesInteger: + additionalProperties: + type: integer + properties: + name: + type: string + type: object + AdditionalPropertiesNumber: + additionalProperties: + type: number + properties: + name: + type: string + type: object + AdditionalPropertiesBoolean: + additionalProperties: + type: boolean + properties: + name: + type: string + type: object + AdditionalPropertiesArray: + additionalProperties: + items: + properties: {} + type: object + type: array + properties: + name: + type: string + type: object + AdditionalPropertiesObject: + additionalProperties: + additionalProperties: + properties: {} + type: object + type: object + properties: + name: + type: string + type: object + AdditionalPropertiesAnyType: + additionalProperties: + properties: {} + type: object + properties: + name: + type: string + type: object + MixedPropertiesAndAdditionalPropertiesClass: + properties: + uuid: + format: uuid + type: string + dateTime: + format: date-time + type: string + map: + additionalProperties: + $ref: '#/components/schemas/Animal' + type: object + type: object + List: + properties: + "123-list": + type: string + type: object + Client: + example: + client: client + properties: + client: + type: string + type: object + ReadOnlyFirst: + properties: + bar: + readOnly: true + type: string + baz: + type: string + type: object + hasOnlyReadOnly: + properties: + bar: + readOnly: true + type: string + foo: + readOnly: true + type: string + type: object + Capitalization: + properties: + smallCamel: + type: string + CapitalCamel: + type: string + small_Snake: + type: string + Capital_Snake: + type: string + SCA_ETH_Flow_Points: + type: string + ATT_NAME: + description: | + Name of the pet + type: string + type: object + MapTest: + properties: + map_map_of_string: + additionalProperties: + additionalProperties: + type: string + type: object + type: object + map_of_enum_string: + additionalProperties: + enum: + - UPPER + - lower + type: string + type: object + direct_map: + additionalProperties: + type: boolean + type: object + indirect_map: + additionalProperties: + type: boolean + type: object + type: object + ArrayTest: + properties: + array_of_string: + items: + type: string + type: array + array_array_of_integer: + items: + items: + format: int64 + type: integer + type: array + type: array + array_array_of_model: + items: + items: + $ref: '#/components/schemas/ReadOnlyFirst' + type: array + type: array + type: object + NumberOnly: + properties: + JustNumber: + type: number + type: object + ArrayOfNumberOnly: + properties: + ArrayNumber: + items: + type: number + type: array + type: object + ArrayOfArrayOfNumberOnly: + properties: + ArrayArrayNumber: + items: + items: + type: number + type: array + type: array + type: object + EnumArrays: + properties: + just_symbol: + enum: + - '>=' + - $ + type: string + array_enum: + items: + enum: + - fish + - crab + type: string + type: array + type: object + OuterEnum: + enum: + - placed + - approved + - delivered + type: string + OuterComposite: + example: + my_string: my_string + my_number: 0.8008281904610115 + my_boolean: true + properties: + my_number: + type: number + my_string: + type: string + my_boolean: + type: boolean + x-codegen-body-parameter-name: boolean_post_body + type: object + OuterNumber: + type: number + OuterString: + type: string + OuterBoolean: + type: boolean + x-codegen-body-parameter-name: boolean_post_body + StringBooleanMap: + additionalProperties: + type: boolean + type: object + FileSchemaTestClass: + example: + file: + sourceURI: sourceURI + files: + - sourceURI: sourceURI + - sourceURI: sourceURI + properties: + file: + $ref: '#/components/schemas/File' + files: + items: + $ref: '#/components/schemas/File' + type: array + type: object + File: + description: Must be named `File` for test. + example: + sourceURI: sourceURI + properties: + sourceURI: + description: Test capitalization + type: string + type: object + TypeHolderDefault: + properties: + string_item: + default: what + type: string + number_item: + type: number + integer_item: + type: integer + bool_item: + default: true + type: boolean + array_item: + items: + type: integer + type: array + required: + - array_item + - bool_item + - integer_item + - number_item + - string_item + type: object + TypeHolderExample: + properties: + string_item: + example: what + type: string + number_item: + example: 1.234 + type: number + float_item: + example: 1.234 + format: float + type: number + integer_item: + example: -2 + type: integer + bool_item: + example: true + type: boolean + array_item: + example: + - 0 + - 1 + - 2 + - 3 + items: + type: integer + type: array + required: + - array_item + - bool_item + - float_item + - integer_item + - number_item + - string_item + type: object + XmlItem: + properties: + attribute_string: + example: string + type: string + xml: + attribute: true + attribute_number: + example: 1.234 + type: number + xml: + attribute: true + attribute_integer: + example: -2 + type: integer + xml: + attribute: true + attribute_boolean: + example: true + type: boolean + xml: + attribute: true + wrapped_array: + items: + type: integer + type: array + xml: + wrapped: true + name_string: + example: string + type: string + xml: + name: xml_name_string + name_number: + example: 1.234 + type: number + xml: + name: xml_name_number + name_integer: + example: -2 + type: integer + xml: + name: xml_name_integer + name_boolean: + example: true + type: boolean + xml: + name: xml_name_boolean + name_array: + items: + type: integer + xml: + name: xml_name_array_item + type: array + name_wrapped_array: + items: + type: integer + xml: + name: xml_name_wrapped_array_item + type: array + xml: + name: xml_name_wrapped_array + wrapped: true + prefix_string: + example: string + type: string + xml: + prefix: ab + prefix_number: + example: 1.234 + type: number + xml: + prefix: cd + prefix_integer: + example: -2 + type: integer + xml: + prefix: ef + prefix_boolean: + example: true + type: boolean + xml: + prefix: gh + prefix_array: + items: + type: integer + xml: + prefix: ij + type: array + prefix_wrapped_array: + items: + type: integer + xml: + prefix: mn + type: array + xml: + prefix: kl + wrapped: true + namespace_string: + example: string + type: string + xml: + namespace: http://a.com/schema + namespace_number: + example: 1.234 + type: number + xml: + namespace: http://b.com/schema + namespace_integer: + example: -2 + type: integer + xml: + namespace: http://c.com/schema + namespace_boolean: + example: true + type: boolean + xml: + namespace: http://d.com/schema + namespace_array: + items: + type: integer + xml: + namespace: http://e.com/schema + type: array + namespace_wrapped_array: + items: + type: integer + xml: + namespace: http://g.com/schema + type: array + xml: + namespace: http://f.com/schema + wrapped: true + prefix_ns_string: + example: string + type: string + xml: + namespace: http://a.com/schema + prefix: a + prefix_ns_number: + example: 1.234 + type: number + xml: + namespace: http://b.com/schema + prefix: b + prefix_ns_integer: + example: -2 + type: integer + xml: + namespace: http://c.com/schema + prefix: c + prefix_ns_boolean: + example: true + type: boolean + xml: + namespace: http://d.com/schema + prefix: d + prefix_ns_array: + items: + type: integer + xml: + namespace: http://e.com/schema + prefix: e + type: array + prefix_ns_wrapped_array: + items: + type: integer + xml: + namespace: http://g.com/schema + prefix: g + type: array + xml: + namespace: http://f.com/schema + prefix: f + wrapped: true + type: object + xml: + namespace: http://a.com/schema + prefix: pre + Dog_allOf: + properties: + breed: + type: string + type: object + Cat_allOf: + properties: + declawed: + type: boolean + type: object + BigCat_allOf: + properties: + kind: + enum: + - lions + - tigers + - leopards + - jaguars + 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 + api_key_query: + in: query + name: api_key_query + type: apiKey + http_basic_test: + scheme: basic + type: http +x-original-swagger-version: "2.0" diff --git a/samples/openapi3/server/petstore/springboot-delegate/.openapi-generator-ignore b/samples/openapi3/server/petstore/springboot-delegate/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/.openapi-generator-ignore @@ -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 diff --git a/samples/openapi3/server/petstore/springboot-delegate/.openapi-generator/FILES b/samples/openapi3/server/petstore/springboot-delegate/.openapi-generator/FILES new file mode 100644 index 000000000000..9df6c44a3213 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/.openapi-generator/FILES @@ -0,0 +1,72 @@ +README.md +pom.xml +src/main/java/org/openapitools/OpenAPI2SpringBoot.java +src/main/java/org/openapitools/RFC3339DateFormat.java +src/main/java/org/openapitools/api/AnotherFakeApi.java +src/main/java/org/openapitools/api/AnotherFakeApiController.java +src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java +src/main/java/org/openapitools/api/ApiUtil.java +src/main/java/org/openapitools/api/FakeApi.java +src/main/java/org/openapitools/api/FakeApiController.java +src/main/java/org/openapitools/api/FakeApiDelegate.java +src/main/java/org/openapitools/api/FakeClassnameTestApi.java +src/main/java/org/openapitools/api/FakeClassnameTestApiController.java +src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.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/model/AdditionalPropertiesAnyType.java +src/main/java/org/openapitools/model/AdditionalPropertiesArray.java +src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java +src/main/java/org/openapitools/model/AdditionalPropertiesClass.java +src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java +src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java +src/main/java/org/openapitools/model/AdditionalPropertiesObject.java +src/main/java/org/openapitools/model/AdditionalPropertiesString.java +src/main/java/org/openapitools/model/Animal.java +src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java +src/main/java/org/openapitools/model/ArrayOfNumberOnly.java +src/main/java/org/openapitools/model/ArrayTest.java +src/main/java/org/openapitools/model/BigCat.java +src/main/java/org/openapitools/model/BigCatAllOf.java +src/main/java/org/openapitools/model/Capitalization.java +src/main/java/org/openapitools/model/Cat.java +src/main/java/org/openapitools/model/CatAllOf.java +src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ClassModel.java +src/main/java/org/openapitools/model/Client.java +src/main/java/org/openapitools/model/Dog.java +src/main/java/org/openapitools/model/DogAllOf.java +src/main/java/org/openapitools/model/EnumArrays.java +src/main/java/org/openapitools/model/EnumClass.java +src/main/java/org/openapitools/model/EnumTest.java +src/main/java/org/openapitools/model/FileSchemaTestClass.java +src/main/java/org/openapitools/model/FormatTest.java +src/main/java/org/openapitools/model/HasOnlyReadOnly.java +src/main/java/org/openapitools/model/MapTest.java +src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java +src/main/java/org/openapitools/model/Model200Response.java +src/main/java/org/openapitools/model/ModelApiResponse.java +src/main/java/org/openapitools/model/ModelReturn.java +src/main/java/org/openapitools/model/Name.java +src/main/java/org/openapitools/model/NumberOnly.java +src/main/java/org/openapitools/model/Order.java +src/main/java/org/openapitools/model/OuterComposite.java +src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/Pet.java +src/main/java/org/openapitools/model/ReadOnlyFirst.java +src/main/java/org/openapitools/model/SpecialModelName.java +src/main/java/org/openapitools/model/Tag.java +src/main/java/org/openapitools/model/TypeHolderDefault.java +src/main/java/org/openapitools/model/TypeHolderExample.java +src/main/java/org/openapitools/model/User.java +src/main/java/org/openapitools/model/XmlItem.java +src/main/resources/application.properties +src/main/resources/openapi.yaml diff --git a/samples/openapi3/server/petstore/springboot-delegate/.openapi-generator/VERSION b/samples/openapi3/server/petstore/springboot-delegate/.openapi-generator/VERSION new file mode 100644 index 000000000000..0984c4c1ad21 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/.openapi-generator/VERSION @@ -0,0 +1 @@ +5.4.0-SNAPSHOT \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-delegate/README.md b/samples/openapi3/server/petstore/springboot-delegate/README.md new file mode 100644 index 000000000000..befc961488ae --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/README.md @@ -0,0 +1,16 @@ +# 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. + +Start your server as a simple java application + +You can view the api documentation in swagger-ui by pointing to +http://localhost:80/ + +Change default port value in application.properties \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-delegate/pom.xml b/samples/openapi3/server/petstore/springboot-delegate/pom.xml new file mode 100644 index 000000000000..35758ea64964 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/pom.xml @@ -0,0 +1,71 @@ + + 4.0.0 + org.openapitools.openapi3 + springboot-delegate + jar + springboot-delegate + 1.0.0 + + 1.8 + ${java.version} + ${java.version} + 2.1.11 + + + org.springframework.boot + spring-boot-starter-parent + 2.5.8 + + + src/main/java + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.data + spring-data-commons + + + io.swagger.core.v3 + swagger-annotations + ${swagger-core-version} + + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + + + org.openapitools + jackson-databind-nullable + 0.2.2 + + + + org.springframework.boot + spring-boot-starter-validation + + + com.fasterxml.jackson.core + jackson-databind + + + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..cb088f451935 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,63 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.Module; +import org.openapitools.jackson.nullable.JsonNullableModule; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.ExitCodeGenerator; +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.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenAPI2SpringBoot implements CommandLineRunner { + + @Override + public void run(String... arg0) throws Exception { + if (arg0.length > 0 && arg0[0].equals("exitcode")) { + throw new ExitException(); + } + } + + public static void main(String[] args) throws Exception { + new SpringApplication(OpenAPI2SpringBoot.class).run(args); + } + + static class ExitException extends RuntimeException implements ExitCodeGenerator { + private static final long serialVersionUID = 1L; + + @Override + public int getExitCode() { + return 10; + } + + } + + @Bean + public WebMvcConfigurer webConfigurer() { + return new WebMvcConfigurer() { + /*@Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") + .allowedOrigins("*") + .allowedMethods("*") + .allowedHeaders("Content-Type"); + }*/ + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("/swagger-ui/**").addResourceLocations("classpath:/META-INF/resources/webjars/swagger-ui/3.14.2/"); + } + }; + } + + @Bean + public Module jsonNullableModule() { + return new JsonNullableModule(); + } + +} diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/RFC3339DateFormat.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/RFC3339DateFormat.java new file mode 100644 index 000000000000..bcd3936d8b34 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/RFC3339DateFormat.java @@ -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; + } +} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApi.java new file mode 100644 index 000000000000..b36ef3022ad8 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -0,0 +1,61 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.openapitools.api; + +import org.openapitools.model.Client; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.ResponseEntity; +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; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "another-fake", description = "the another-fake API") +public interface AnotherFakeApi { + + default AnotherFakeApiDelegate getDelegate() { + return new AnotherFakeApiDelegate() {}; + } + + /** + * PATCH /another-fake/dummy : To test special tags + * To test special tags and operation ID starting with number + * + * @param body client model (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "To test special tags", + tags = { "$another-fake?" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Client.class))) + } + ) + @RequestMapping( + method = RequestMethod.PATCH, + value = "/another-fake/dummy", + produces = { "application/json" }, + consumes = { "application/json" } + ) + default ResponseEntity call123testSpecialTags( + @Parameter(name = "body", description = "client model", required = true, schema = @Schema(description = "")) @Valid @RequestBody Client body + ) { + return getDelegate().call123testSpecialTags(body); + } + +} diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApiController.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApiController.java new file mode 100644 index 000000000000..df11134c8067 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApiController.java @@ -0,0 +1,22 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class AnotherFakeApiController implements AnotherFakeApi { + + private final AnotherFakeApiDelegate delegate; + + public AnotherFakeApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) AnotherFakeApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new AnotherFakeApiDelegate() {}); + } + + @Override + public AnotherFakeApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java new file mode 100644 index 000000000000..a86542ddf223 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java @@ -0,0 +1,47 @@ +package org.openapitools.api; + +import org.openapitools.model.Client; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +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; + +/** + * A delegate to be called by the {@link AnotherFakeApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public interface AnotherFakeApiDelegate { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * PATCH /another-fake/dummy : To test special tags + * To test special tags and operation ID starting with number + * + * @param body client model (required) + * @return successful operation (status code 200) + * @see AnotherFakeApi#call123testSpecialTags + */ + default ResponseEntity call123testSpecialTags(Client body) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"client\" : \"client\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/ApiUtil.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/ApiUtil.java new file mode 100644 index 000000000000..1245b1dd0ccf --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/ApiUtil.java @@ -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); + } + } +} diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java new file mode 100644 index 000000000000..a1667f68fd91 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java @@ -0,0 +1,505 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.openapitools.api; + +import java.math.BigDecimal; +import org.openapitools.model.Client; +import org.openapitools.model.FileSchemaTestClass; +import java.time.LocalDate; +import java.util.Map; +import org.openapitools.model.ModelApiResponse; +import java.time.OffsetDateTime; +import org.openapitools.model.OuterComposite; +import org.openapitools.model.User; +import org.openapitools.model.XmlItem; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.ResponseEntity; +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; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "fake", description = "the fake API") +public interface FakeApi { + + default FakeApiDelegate getDelegate() { + return new FakeApiDelegate() {}; + } + + /** + * POST /fake/create_xml_item : creates an XmlItem + * this route creates an XmlItem + * + * @param xmlItem XmlItem Body (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "creates an XmlItem", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/create_xml_item", + consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } + ) + default ResponseEntity createXmlItem( + @Parameter(name = "XmlItem", description = "XmlItem Body", required = true, schema = @Schema(description = "")) @Valid @RequestBody XmlItem xmlItem + ) { + return getDelegate().createXmlItem(xmlItem); + } + + + /** + * POST /fake/outer/boolean + * Test serialization of outer boolean types + * + * @param body Input boolean as post body (optional) + * @return Output boolean (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Output boolean", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Boolean.class))) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/outer/boolean", + produces = { "*/*" } + ) + default ResponseEntity fakeOuterBooleanSerialize( + @Parameter(name = "body", description = "Input boolean as post body", schema = @Schema(description = "")) @Valid @RequestBody(required = false) Boolean body + ) { + return getDelegate().fakeOuterBooleanSerialize(body); + } + + + /** + * POST /fake/outer/composite + * Test serialization of object with outer number type + * + * @param body Input composite as post body (optional) + * @return Output composite (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Output composite", content = @Content(mediaType = "application/json", schema = @Schema(implementation = OuterComposite.class))) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/outer/composite", + produces = { "*/*" } + ) + default ResponseEntity fakeOuterCompositeSerialize( + @Parameter(name = "body", description = "Input composite as post body", schema = @Schema(description = "")) @Valid @RequestBody(required = false) OuterComposite body + ) { + return getDelegate().fakeOuterCompositeSerialize(body); + } + + + /** + * POST /fake/outer/number + * Test serialization of outer number types + * + * @param body Input number as post body (optional) + * @return Output number (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Output number", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BigDecimal.class))) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/outer/number", + produces = { "*/*" } + ) + default ResponseEntity fakeOuterNumberSerialize( + @Parameter(name = "body", description = "Input number as post body", schema = @Schema(description = "")) @Valid @RequestBody(required = false) BigDecimal body + ) { + return getDelegate().fakeOuterNumberSerialize(body); + } + + + /** + * POST /fake/outer/string + * Test serialization of outer string types + * + * @param body Input string as post body (optional) + * @return Output string (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Output string", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/outer/string", + produces = { "*/*" } + ) + default ResponseEntity fakeOuterStringSerialize( + @Parameter(name = "body", description = "Input string as post body", schema = @Schema(description = "")) @Valid @RequestBody(required = false) String body + ) { + return getDelegate().fakeOuterStringSerialize(body); + } + + + /** + * PUT /fake/body-with-file-schema + * For this test, the body for this request much reference a schema named `File`. + * + * @param body (required) + * @return Success (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success") + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/fake/body-with-file-schema", + consumes = { "application/json" } + ) + default ResponseEntity testBodyWithFileSchema( + @Parameter(name = "body", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestBody FileSchemaTestClass body + ) { + return getDelegate().testBodyWithFileSchema(body); + } + + + /** + * PUT /fake/body-with-query-params + * + * @param query (required) + * @param body (required) + * @return Success (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success") + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/fake/body-with-query-params", + consumes = { "application/json" } + ) + default ResponseEntity testBodyWithQueryParams( + @NotNull @Parameter(name = "query", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "query", required = true) String query, + @Parameter(name = "body", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestBody User body + ) { + return getDelegate().testBodyWithQueryParams(query, body); + } + + + /** + * PATCH /fake : To test \"client\" model + * To test \"client\" model + * + * @param body client model (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "To test \"client\" model", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Client.class))) + } + ) + @RequestMapping( + method = RequestMethod.PATCH, + value = "/fake", + produces = { "application/json" }, + consumes = { "application/json" } + ) + default ResponseEntity testClientModel( + @Parameter(name = "body", description = "client model", required = true, schema = @Schema(description = "")) @Valid @RequestBody Client body + ) { + return getDelegate().testClientModel(body); + } + + + /** + * POST /fake : Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * + * @param number None (required) + * @param _double None (required) + * @param patternWithoutDelimiter None (required) + * @param _byte None (required) + * @param integer None (optional) + * @param int32 None (optional) + * @param int64 None (optional) + * @param _float None (optional) + * @param string None (optional) + * @param binary None (optional) + * @param date None (optional) + * @param dateTime None (optional) + * @param password None (optional) + * @param paramCallback None (optional) + * @return Invalid username supplied (status code 400) + * or User not found (status code 404) + */ + @Operation( + summary = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + }, + security = { + @SecurityRequirement(name = "http_basic_test") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) + default ResponseEntity testEndpointParameters( + @Parameter(name = "number", description = "None", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "number", required = true) BigDecimal number, + @Parameter(name = "double", description = "None", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "double", required = true) Double _double, + @Parameter(name = "pattern_without_delimiter", description = "None", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, + @Parameter(name = "byte", description = "None", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, + @Parameter(name = "integer", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "integer", required = false) Integer integer, + @Parameter(name = "int32", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "int32", required = false) Integer int32, + @Parameter(name = "int64", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "int64", required = false) Long int64, + @Parameter(name = "float", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "float", required = false) Float _float, + @Parameter(name = "string", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "string", required = false) String string, + @Parameter(name = "binary", description = "None", schema = @Schema(description = "")) @RequestPart(value = "binary", required = false) MultipartFile binary, + @Parameter(name = "date", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "date", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @Parameter(name = "dateTime", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "dateTime", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @Parameter(name = "password", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "password", required = false) String password, + @Parameter(name = "callback", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "callback", required = false) String paramCallback + ) { + return getDelegate().testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback); + } + + + /** + * GET /fake : To test enum parameters + * To test enum parameters + * + * @param enumHeaderStringArray Header parameter enum test (string array) (optional) + * @param enumHeaderString Header parameter enum test (string) (optional, default to -efg) + * @param enumQueryStringArray Query parameter enum test (string array) (optional) + * @param enumQueryString Query parameter enum test (string) (optional, default to -efg) + * @param enumQueryInteger Query parameter enum test (double) (optional) + * @param enumQueryDouble Query parameter enum test (double) (optional) + * @param enumFormStringArray Form parameter enum test (string array) (optional, default to $) + * @param enumFormString Form parameter enum test (string) (optional, default to -efg) + * @return Invalid request (status code 400) + * or Not found (status code 404) + */ + @Operation( + summary = "To test enum parameters", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid request"), + @ApiResponse(responseCode = "404", description = "Not found") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) + default ResponseEntity testEnumParameters( + @Parameter(name = "enum_header_string_array", description = "Header parameter enum test (string array)", schema = @Schema(description = "", allowableValues = { ">", "$" })) @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray, + @Parameter(name = "enum_header_string", description = "Header parameter enum test (string)", schema = @Schema(description = "", allowableValues = { "_abc", "-efg", "(xyz)" }, defaultValue = "-efg")) @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString, + @Parameter(name = "enum_query_string_array", description = "Query parameter enum test (string array)", schema = @Schema(description = "", allowableValues = { ">", "$" })) @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, + @Parameter(name = "enum_query_string", description = "Query parameter enum test (string)", schema = @Schema(description = "", allowableValues = { "_abc", "-efg", "(xyz)" }, defaultValue = "-efg")) @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString, + @Parameter(name = "enum_query_integer", description = "Query parameter enum test (double)", schema = @Schema(description = "", allowableValues = { "1", "-2" })) @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, + @Parameter(name = "enum_query_double", description = "Query parameter enum test (double)", schema = @Schema(description = "", allowableValues = { "1.1", "-1.2" })) @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble, + @Parameter(name = "enum_form_string_array", description = "Form parameter enum test (string array)", schema = @Schema(description = "", allowableValues = { ">", "$" })) @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, + @Parameter(name = "enum_form_string", description = "Form parameter enum test (string)", schema = @Schema(description = "", allowableValues = { "_abc", "-efg", "(xyz)" }, defaultValue = "-efg")) @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString + ) { + return getDelegate().testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString); + } + + + /** + * DELETE /fake : Fake endpoint to test group parameters (optional) + * Fake endpoint to test group parameters (optional) + * + * @param requiredStringGroup Required String in group parameters (required) + * @param requiredBooleanGroup Required Boolean in group parameters (required) + * @param requiredInt64Group Required Integer in group parameters (required) + * @param stringGroup String in group parameters (optional) + * @param booleanGroup Boolean in group parameters (optional) + * @param int64Group Integer in group parameters (optional) + * @return Someting wrong (status code 400) + */ + @Operation( + summary = "Fake endpoint to test group parameters (optional)", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "400", description = "Someting wrong") + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/fake" + ) + default ResponseEntity testGroupParameters( + @NotNull @Parameter(name = "required_string_group", description = "Required String in group parameters", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup, + @Parameter(name = "required_boolean_group", description = "Required Boolean in group parameters", required = true, schema = @Schema(description = "")) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup, + @NotNull @Parameter(name = "required_int64_group", description = "Required Integer in group parameters", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group, + @Parameter(name = "string_group", description = "String in group parameters", schema = @Schema(description = "")) @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup, + @Parameter(name = "boolean_group", description = "Boolean in group parameters", schema = @Schema(description = "")) @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup, + @Parameter(name = "int64_group", description = "Integer in group parameters", schema = @Schema(description = "")) @Valid @RequestParam(value = "int64_group", required = false) Long int64Group + ) { + return getDelegate().testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group); + } + + + /** + * POST /fake/inline-additionalProperties : test inline additionalProperties + * + * @param param request body (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "test inline additionalProperties", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/inline-additionalProperties", + consumes = { "application/json" } + ) + default ResponseEntity testInlineAdditionalProperties( + @Parameter(name = "param", description = "request body", required = true, schema = @Schema(description = "")) @Valid @RequestBody Map param + ) { + return getDelegate().testInlineAdditionalProperties(param); + } + + + /** + * GET /fake/jsonFormData : test json serialization of form data + * + * @param param field1 (required) + * @param param2 field2 (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "test json serialization of form data", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/fake/jsonFormData", + consumes = { "application/x-www-form-urlencoded" } + ) + default ResponseEntity testJsonFormData( + @Parameter(name = "param", description = "field1", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "param", required = true) String param, + @Parameter(name = "param2", description = "field2", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "param2", required = true) String param2 + ) { + return getDelegate().testJsonFormData(param, param2); + } + + + /** + * PUT /fake/test-query-parameters + * To test the collection format in query parameters + * + * @param pipe (required) + * @param ioutil (required) + * @param http (required) + * @param url (required) + * @param context (required) + * @return Success (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success") + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/fake/test-query-parameters" + ) + default ResponseEntity testQueryParameterCollectionFormat( + @NotNull @Parameter(name = "pipe", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "pipe", required = true) List pipe, + @NotNull @Parameter(name = "ioutil", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "ioutil", required = true) List ioutil, + @NotNull @Parameter(name = "http", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "http", required = true) List http, + @NotNull @Parameter(name = "url", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "url", required = true) List url, + @NotNull @Parameter(name = "context", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "context", required = true) List context + ) { + return getDelegate().testQueryParameterCollectionFormat(pipe, ioutil, http, url, context); + } + + + /** + * POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required) + * + * @param petId ID of pet to update (required) + * @param requiredFile file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @return successful operation (status code 200) + */ + @Operation( + summary = "uploads an image (required)", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ModelApiResponse.class))) + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/{petId}/uploadImageWithRequiredFile", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) + default ResponseEntity uploadFileWithRequiredFile( + @Parameter(name = "petId", description = "ID of pet to update", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "requiredFile", description = "file to upload", required = true, schema = @Schema(description = "")) @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, + @Parameter(name = "additionalMetadata", description = "Additional data to pass to server", schema = @Schema(description = "")) @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata + ) { + return getDelegate().uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata); + } + +} diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiController.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiController.java new file mode 100644 index 000000000000..6b22c1aba661 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiController.java @@ -0,0 +1,22 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class FakeApiController implements FakeApi { + + private final FakeApiDelegate delegate; + + public FakeApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) FakeApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new FakeApiDelegate() {}); + } + + @Override + public FakeApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiDelegate.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiDelegate.java new file mode 100644 index 000000000000..d3a949e65d81 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiDelegate.java @@ -0,0 +1,320 @@ +package org.openapitools.api; + +import java.math.BigDecimal; +import org.openapitools.model.Client; +import org.openapitools.model.FileSchemaTestClass; +import java.time.LocalDate; +import java.util.Map; +import org.openapitools.model.ModelApiResponse; +import java.time.OffsetDateTime; +import org.openapitools.model.OuterComposite; +import org.openapitools.model.User; +import org.openapitools.model.XmlItem; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +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; + +/** + * A delegate to be called by the {@link FakeApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public interface FakeApiDelegate { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * POST /fake/create_xml_item : creates an XmlItem + * this route creates an XmlItem + * + * @param xmlItem XmlItem Body (required) + * @return successful operation (status code 200) + * @see FakeApi#createXmlItem + */ + default ResponseEntity createXmlItem(XmlItem xmlItem) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * POST /fake/outer/boolean + * Test serialization of outer boolean types + * + * @param body Input boolean as post body (optional) + * @return Output boolean (status code 200) + * @see FakeApi#fakeOuterBooleanSerialize + */ + default ResponseEntity fakeOuterBooleanSerialize(Boolean body) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * POST /fake/outer/composite + * Test serialization of object with outer number type + * + * @param body Input composite as post body (optional) + * @return Output composite (status code 200) + * @see FakeApi#fakeOuterCompositeSerialize + */ + default ResponseEntity fakeOuterCompositeSerialize(OuterComposite body) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) { + String exampleString = "{ \"my_string\" : \"my_string\", \"my_number\" : 0.8008281904610115, \"my_boolean\" : true }"; + ApiUtil.setExampleResponse(request, "*/*", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * POST /fake/outer/number + * Test serialization of outer number types + * + * @param body Input number as post body (optional) + * @return Output number (status code 200) + * @see FakeApi#fakeOuterNumberSerialize + */ + default ResponseEntity fakeOuterNumberSerialize(BigDecimal body) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * POST /fake/outer/string + * Test serialization of outer string types + * + * @param body Input string as post body (optional) + * @return Output string (status code 200) + * @see FakeApi#fakeOuterStringSerialize + */ + default ResponseEntity fakeOuterStringSerialize(String body) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * PUT /fake/body-with-file-schema + * For this test, the body for this request much reference a schema named `File`. + * + * @param body (required) + * @return Success (status code 200) + * @see FakeApi#testBodyWithFileSchema + */ + default ResponseEntity testBodyWithFileSchema(FileSchemaTestClass body) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * PUT /fake/body-with-query-params + * + * @param query (required) + * @param body (required) + * @return Success (status code 200) + * @see FakeApi#testBodyWithQueryParams + */ + default ResponseEntity testBodyWithQueryParams(String query, + User body) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * PATCH /fake : To test \"client\" model + * To test \"client\" model + * + * @param body client model (required) + * @return successful operation (status code 200) + * @see FakeApi#testClientModel + */ + default ResponseEntity testClientModel(Client body) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"client\" : \"client\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * POST /fake : Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * + * @param number None (required) + * @param _double None (required) + * @param patternWithoutDelimiter None (required) + * @param _byte None (required) + * @param integer None (optional) + * @param int32 None (optional) + * @param int64 None (optional) + * @param _float None (optional) + * @param string None (optional) + * @param binary None (optional) + * @param date None (optional) + * @param dateTime None (optional) + * @param password None (optional) + * @param paramCallback None (optional) + * @return Invalid username supplied (status code 400) + * or User not found (status code 404) + * @see FakeApi#testEndpointParameters + */ + default ResponseEntity testEndpointParameters(BigDecimal number, + Double _double, + String patternWithoutDelimiter, + byte[] _byte, + Integer integer, + Integer int32, + Long int64, + Float _float, + String string, + MultipartFile binary, + LocalDate date, + OffsetDateTime dateTime, + String password, + String paramCallback) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * GET /fake : To test enum parameters + * To test enum parameters + * + * @param enumHeaderStringArray Header parameter enum test (string array) (optional) + * @param enumHeaderString Header parameter enum test (string) (optional, default to -efg) + * @param enumQueryStringArray Query parameter enum test (string array) (optional) + * @param enumQueryString Query parameter enum test (string) (optional, default to -efg) + * @param enumQueryInteger Query parameter enum test (double) (optional) + * @param enumQueryDouble Query parameter enum test (double) (optional) + * @param enumFormStringArray Form parameter enum test (string array) (optional, default to $) + * @param enumFormString Form parameter enum test (string) (optional, default to -efg) + * @return Invalid request (status code 400) + * or Not found (status code 404) + * @see FakeApi#testEnumParameters + */ + default ResponseEntity testEnumParameters(List enumHeaderStringArray, + String enumHeaderString, + List enumQueryStringArray, + String enumQueryString, + Integer enumQueryInteger, + Double enumQueryDouble, + List enumFormStringArray, + String enumFormString) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * DELETE /fake : Fake endpoint to test group parameters (optional) + * Fake endpoint to test group parameters (optional) + * + * @param requiredStringGroup Required String in group parameters (required) + * @param requiredBooleanGroup Required Boolean in group parameters (required) + * @param requiredInt64Group Required Integer in group parameters (required) + * @param stringGroup String in group parameters (optional) + * @param booleanGroup Boolean in group parameters (optional) + * @param int64Group Integer in group parameters (optional) + * @return Someting wrong (status code 400) + * @see FakeApi#testGroupParameters + */ + default ResponseEntity testGroupParameters(Integer requiredStringGroup, + Boolean requiredBooleanGroup, + Long requiredInt64Group, + Integer stringGroup, + Boolean booleanGroup, + Long int64Group) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * POST /fake/inline-additionalProperties : test inline additionalProperties + * + * @param param request body (required) + * @return successful operation (status code 200) + * @see FakeApi#testInlineAdditionalProperties + */ + default ResponseEntity testInlineAdditionalProperties(Map param) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * GET /fake/jsonFormData : test json serialization of form data + * + * @param param field1 (required) + * @param param2 field2 (required) + * @return successful operation (status code 200) + * @see FakeApi#testJsonFormData + */ + default ResponseEntity testJsonFormData(String param, + String param2) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * PUT /fake/test-query-parameters + * To test the collection format in query parameters + * + * @param pipe (required) + * @param ioutil (required) + * @param http (required) + * @param url (required) + * @param context (required) + * @return Success (status code 200) + * @see FakeApi#testQueryParameterCollectionFormat + */ + default ResponseEntity testQueryParameterCollectionFormat(List pipe, + List ioutil, + List http, + List url, + List context) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required) + * + * @param petId ID of pet to update (required) + * @param requiredFile file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @return successful operation (status code 200) + * @see FakeApi#uploadFileWithRequiredFile + */ + default ResponseEntity uploadFileWithRequiredFile(Long petId, + MultipartFile requiredFile, + String additionalMetadata) { + 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; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeClassnameTestApi.java new file mode 100644 index 000000000000..52e3ba4f096d --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -0,0 +1,64 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.openapitools.api; + +import org.openapitools.model.Client; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.ResponseEntity; +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; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "fake_classname_test", description = "the fake_classname_test API") +public interface FakeClassnameTestApi { + + default FakeClassnameTestApiDelegate getDelegate() { + return new FakeClassnameTestApiDelegate() {}; + } + + /** + * PATCH /fake_classname_test : To test class name in snake case + * To test class name in snake case + * + * @param body client model (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "To test class name in snake case", + tags = { "fake_classname_tags 123#$%^" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Client.class))) + }, + security = { + @SecurityRequirement(name = "api_key_query") + } + ) + @RequestMapping( + method = RequestMethod.PATCH, + value = "/fake_classname_test", + produces = { "application/json" }, + consumes = { "application/json" } + ) + default ResponseEntity testClassname( + @Parameter(name = "body", description = "client model", required = true, schema = @Schema(description = "")) @Valid @RequestBody Client body + ) { + return getDelegate().testClassname(body); + } + +} diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java new file mode 100644 index 000000000000..58497641e4c5 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java @@ -0,0 +1,22 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class FakeClassnameTestApiController implements FakeClassnameTestApi { + + private final FakeClassnameTestApiDelegate delegate; + + public FakeClassnameTestApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) FakeClassnameTestApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new FakeClassnameTestApiDelegate() {}); + } + + @Override + public FakeClassnameTestApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java new file mode 100644 index 000000000000..ed5a6bfc09a0 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java @@ -0,0 +1,47 @@ +package org.openapitools.api; + +import org.openapitools.model.Client; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +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; + +/** + * A delegate to be called by the {@link FakeClassnameTestApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public interface FakeClassnameTestApiDelegate { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * PATCH /fake_classname_test : To test class name in snake case + * To test class name in snake case + * + * @param body client model (required) + * @return successful operation (status code 200) + * @see FakeClassnameTestApi#testClassname + */ + default ResponseEntity testClassname(Client body) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"client\" : \"client\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApi.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApi.java new file mode 100644 index 000000000000..7ddf343bfc3a --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApi.java @@ -0,0 +1,292 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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 java.util.Set; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.ResponseEntity; +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; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "pet", description = "the pet API") +public interface PetApi { + + default PetApiDelegate getDelegate() { + return new PetApiDelegate() {}; + } + + /** + * POST /pet : Add a new pet to the store + * + * @param body Pet object that needs to be added to the store (required) + * @return successful operation (status code 200) + * or Invalid input (status code 405) + */ + @Operation( + summary = "Add a new pet to the store", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation"), + @ApiResponse(responseCode = "405", description = "Invalid input") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet", + consumes = { "application/json", "application/xml" } + ) + default ResponseEntity addPet( + @Parameter(name = "body", description = "Pet object that needs to be added to the store", required = true, schema = @Schema(description = "")) @Valid @RequestBody Pet body + ) { + return getDelegate().addPet(body); + } + + + /** + * DELETE /pet/{petId} : Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @return successful operation (status code 200) + * or Invalid pet value (status code 400) + */ + @Operation( + summary = "Deletes a pet", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation"), + @ApiResponse(responseCode = "400", description = "Invalid pet value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/pet/{petId}" + ) + default ResponseEntity deletePet( + @Parameter(name = "petId", description = "Pet id to delete", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "api_key", description = "", schema = @Schema(description = "")) @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) + */ + @Operation( + summary = "Finds Pets by status", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid status value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/findByStatus", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity> findPetsByStatus( + @NotNull @Parameter(name = "status", description = "Status values that need to be considered for filter", required = true, schema = @Schema(description = "", allowableValues = { "available", "pending", "sold" })) @Valid @RequestParam(value = "status", required = true) List 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 + */ + @Operation( + summary = "Finds Pets by tags", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid tag value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/findByTags", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity> findPetsByTags( + @NotNull @Parameter(name = "tags", description = "Tags to filter by", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "tags", required = true) Set 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) + */ + @Operation( + summary = "Find pet by ID", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/{petId}", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity getPetById( + @Parameter(name = "petId", description = "ID of pet to return", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId + ) { + return getDelegate().getPetById(petId); + } + + + /** + * PUT /pet : Update an existing pet + * + * @param body 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) + */ + @Operation( + summary = "Update an existing pet", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation"), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found"), + @ApiResponse(responseCode = "405", description = "Validation exception") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/pet", + consumes = { "application/json", "application/xml" } + ) + default ResponseEntity updatePet( + @Parameter(name = "body", description = "Pet object that needs to be added to the store", required = true, schema = @Schema(description = "")) @Valid @RequestBody Pet body + ) { + return getDelegate().updatePet(body); + } + + + /** + * 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) + */ + @Operation( + summary = "Updates a pet in the store with form data", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "405", description = "Invalid input") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet/{petId}", + consumes = { "application/x-www-form-urlencoded" } + ) + default ResponseEntity updatePetWithForm( + @Parameter(name = "petId", description = "ID of pet that needs to be updated", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "name", description = "Updated name of the pet", schema = @Schema(description = "")) @Valid @RequestPart(value = "name", required = false) String name, + @Parameter(name = "status", description = "Updated status of the pet", schema = @Schema(description = "")) @Valid @RequestPart(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) + */ + @Operation( + summary = "uploads an image", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ModelApiResponse.class))) + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet/{petId}/uploadImage", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) + default ResponseEntity uploadFile( + @Parameter(name = "petId", description = "ID of pet to update", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "additionalMetadata", description = "Additional data to pass to server", schema = @Schema(description = "")) @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @Parameter(name = "file", description = "file to upload", schema = @Schema(description = "")) @RequestPart(value = "file", required = false) MultipartFile file + ) { + return getDelegate().uploadFile(petId, additionalMetadata, file); + } + +} diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApiController.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApiController.java new file mode 100644 index 000000000000..5fa088c6f10b --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApiController.java @@ -0,0 +1,22 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import java.util.Optional; +@javax.annotation.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(@org.springframework.beans.factory.annotation.Autowired(required = false) PetApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new PetApiDelegate() {}); + } + + @Override + public PetApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApiDelegate.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApiDelegate.java new file mode 100644 index 000000000000..e3adc7d4bca7 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApiDelegate.java @@ -0,0 +1,197 @@ +package org.openapitools.api; + +import org.openapitools.model.ModelApiResponse; +import org.openapitools.model.Pet; +import java.util.Set; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +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; + +/** + * A delegate to be called by the {@link PetApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public interface PetApiDelegate { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * POST /pet : Add a new pet to the store + * + * @param body 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 ResponseEntity addPet(Pet body) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * DELETE /pet/{petId} : Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @return successful operation (status code 200) + * or Invalid pet value (status code 400) + * @see PetApi#deletePet + */ + default ResponseEntity deletePet(Long petId, + String apiKey) { + return new ResponseEntity<>(HttpStatus.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 ResponseEntity> findPetsByStatus(List 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\" : \"default-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 = " 123456789 doggie aeiou aeiou "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.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 + */ + default ResponseEntity> findPetsByTags(Set 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\" : \"default-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 = " 123456789 doggie aeiou aeiou "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.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 ResponseEntity 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\" : \"default-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 = " 123456789 doggie aeiou aeiou "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * PUT /pet : Update an existing pet + * + * @param body 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) + * @see PetApi#updatePet + */ + default ResponseEntity updatePet(Pet body) { + return new ResponseEntity<>(HttpStatus.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 ResponseEntity updatePetWithForm(Long petId, + String name, + String status) { + return new ResponseEntity<>(HttpStatus.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 ResponseEntity 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; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/StoreApi.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/StoreApi.java new file mode 100644 index 000000000000..de9cf4c59e2a --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/StoreApi.java @@ -0,0 +1,147 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.ResponseEntity; +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; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "store", description = "the store API") +public interface StoreApi { + + default StoreApiDelegate getDelegate() { + return new StoreApiDelegate() {}; + } + + /** + * DELETE /store/order/{order_id} : 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) + */ + @Operation( + summary = "Delete purchase order by ID", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/store/order/{order_id}" + ) + default ResponseEntity deleteOrder( + @Parameter(name = "order_id", description = "ID of the order that needs to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("order_id") 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) + */ + @Operation( + summary = "Returns pet inventories by status", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Map.class))) + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/store/inventory", + produces = { "application/json" } + ) + default ResponseEntity> getInventory( + + ) { + return getDelegate().getInventory(); + } + + + /** + * GET /store/order/{order_id} : Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated 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) + */ + @Operation( + summary = "Find purchase order by ID", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/store/order/{order_id}", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity getOrderById( + @Min(1L) @Max(5L) @Parameter(name = "order_id", description = "ID of pet that needs to be fetched", required = true, schema = @Schema(description = "")) @PathVariable("order_id") Long orderId + ) { + return getDelegate().getOrderById(orderId); + } + + + /** + * POST /store/order : Place an order for a pet + * + * @param body order placed for purchasing the pet (required) + * @return successful operation (status code 200) + * or Invalid Order (status code 400) + */ + @Operation( + summary = "Place an order for a pet", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid Order") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/store/order", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity placeOrder( + @Parameter(name = "body", description = "order placed for purchasing the pet", required = true, schema = @Schema(description = "")) @Valid @RequestBody Order body + ) { + return getDelegate().placeOrder(body); + } + +} diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/StoreApiController.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/StoreApiController.java new file mode 100644 index 000000000000..9e08c646ae92 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/StoreApiController.java @@ -0,0 +1,22 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import java.util.Optional; +@javax.annotation.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(@org.springframework.beans.factory.annotation.Autowired(required = false) StoreApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new StoreApiDelegate() {}); + } + + @Override + public StoreApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/StoreApiDelegate.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/StoreApiDelegate.java new file mode 100644 index 000000000000..dfe4bb314961 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/StoreApiDelegate.java @@ -0,0 +1,108 @@ +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.http.ResponseEntity; +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; + +/** + * A delegate to be called by the {@link StoreApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public interface StoreApiDelegate { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * DELETE /store/order/{order_id} : 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 ResponseEntity deleteOrder(String orderId) { + return new ResponseEntity<>(HttpStatus.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 ResponseEntity> getInventory() { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * GET /store/order/{order_id} : Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated 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 ResponseEntity 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 = " 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * POST /store/order : Place an order for a pet + * + * @param body order placed for purchasing the pet (required) + * @return successful operation (status code 200) + * or Invalid Order (status code 400) + * @see StoreApi#placeOrder + */ + default ResponseEntity placeOrder(Order body) { + 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 = " 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/UserApi.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/UserApi.java new file mode 100644 index 000000000000..e7dd25c6b5db --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/UserApi.java @@ -0,0 +1,246 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.ResponseEntity; +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; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "user", description = "the user API") +public interface UserApi { + + default UserApiDelegate getDelegate() { + return new UserApiDelegate() {}; + } + + /** + * POST /user : Create user + * This can only be done by the logged in user. + * + * @param body Created user object (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "Create user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user" + ) + default ResponseEntity createUser( + @Parameter(name = "body", description = "Created user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody User body + ) { + return getDelegate().createUser(body); + } + + + /** + * POST /user/createWithArray : Creates list of users with given input array + * + * @param body List of user object (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "Creates list of users with given input array", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user/createWithArray" + ) + default ResponseEntity createUsersWithArrayInput( + @Parameter(name = "body", description = "List of user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody List body + ) { + return getDelegate().createUsersWithArrayInput(body); + } + + + /** + * POST /user/createWithList : Creates list of users with given input array + * + * @param body List of user object (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "Creates list of users with given input array", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user/createWithList" + ) + default ResponseEntity createUsersWithListInput( + @Parameter(name = "body", description = "List of user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody List body + ) { + return getDelegate().createUsersWithListInput(body); + } + + + /** + * 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) + */ + @Operation( + summary = "Delete user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/user/{username}" + ) + default ResponseEntity deleteUser( + @Parameter(name = "username", description = "The name that needs to be deleted", required = true, schema = @Schema(description = "")) @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) + */ + @Operation( + summary = "Get user by user name", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = User.class))), + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/{username}", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity getUserByName( + @Parameter(name = "username", description = "The name that needs to be fetched. Use user1 for testing.", required = true, schema = @Schema(description = "")) @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) + */ + @Operation( + summary = "Logs user into the system", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "400", description = "Invalid username/password supplied") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/login", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity loginUser( + @NotNull @Parameter(name = "username", description = "The user name for login", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "username", required = true) String username, + @NotNull @Parameter(name = "password", description = "The password for login in clear text", required = true, schema = @Schema(description = "")) @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) + */ + @Operation( + summary = "Logs out current logged in user session", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/logout" + ) + default ResponseEntity 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 body Updated user object (required) + * @return Invalid user supplied (status code 400) + * or User not found (status code 404) + */ + @Operation( + summary = "Updated user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid user supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/user/{username}" + ) + default ResponseEntity updateUser( + @Parameter(name = "username", description = "name that need to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("username") String username, + @Parameter(name = "body", description = "Updated user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody User body + ) { + return getDelegate().updateUser(username, body); + } + +} diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/UserApiController.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/UserApiController.java new file mode 100644 index 000000000000..bc2d33598fd9 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/UserApiController.java @@ -0,0 +1,22 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import java.util.Optional; +@javax.annotation.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(@org.springframework.beans.factory.annotation.Autowired(required = false) UserApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new UserApiDelegate() {}); + } + + @Override + public UserApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/UserApiDelegate.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/UserApiDelegate.java new file mode 100644 index 000000000000..2efbd71c9dc9 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/UserApiDelegate.java @@ -0,0 +1,148 @@ +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.http.ResponseEntity; +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; + +/** + * A delegate to be called by the {@link UserApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public interface UserApiDelegate { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * POST /user : Create user + * This can only be done by the logged in user. + * + * @param body Created user object (required) + * @return successful operation (status code 200) + * @see UserApi#createUser + */ + default ResponseEntity createUser(User body) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * POST /user/createWithArray : Creates list of users with given input array + * + * @param body List of user object (required) + * @return successful operation (status code 200) + * @see UserApi#createUsersWithArrayInput + */ + default ResponseEntity createUsersWithArrayInput(List body) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * POST /user/createWithList : Creates list of users with given input array + * + * @param body List of user object (required) + * @return successful operation (status code 200) + * @see UserApi#createUsersWithListInput + */ + default ResponseEntity createUsersWithListInput(List body) { + return new ResponseEntity<>(HttpStatus.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 ResponseEntity deleteUser(String username) { + return new ResponseEntity<>(HttpStatus.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 ResponseEntity 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 = " 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123 "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.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 ResponseEntity loginUser(String username, + String password) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * GET /user/logout : Logs out current logged in user session + * + * @return successful operation (status code 200) + * @see UserApi#logoutUser + */ + default ResponseEntity logoutUser() { + return new ResponseEntity<>(HttpStatus.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 body Updated user object (required) + * @return Invalid user supplied (status code 400) + * or User not found (status code 404) + * @see UserApi#updateUser + */ + default ResponseEntity updateUser(String username, + User body) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/HomeController.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/HomeController.java new file mode 100644 index 000000000000..34bae16b8986 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/HomeController.java @@ -0,0 +1,53 @@ +package org.openapitools.configuration; + +import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.core.io.Resource; +import org.springframework.stereotype.Controller; +import org.springframework.util.StreamUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.Charset; + +/** + * Home redirection to OpenAPI api documentation + */ +@Controller +public class HomeController { + + private static YAMLMapper yamlMapper = new YAMLMapper(); + + @Value("classpath:/openapi.yaml") + private Resource openapi; + + @Bean + public String openapiContent() throws IOException { + try(InputStream is = openapi.getInputStream()) { + return StreamUtils.copyToString(is, Charset.defaultCharset()); + } + } + + @GetMapping(value = "/openapi.yaml", produces = "application/vnd.oai.openapi") + @ResponseBody + public String openapiYaml() throws IOException { + return openapiContent(); + } + + @GetMapping(value = "/openapi.json", produces = "application/json") + @ResponseBody + public Object openapiJson() throws IOException { + return yamlMapper.readValue(openapiContent(), Object.class); + } + + @RequestMapping("/") + public String index() { + return "redirect:swagger-ui/index.html?url=../openapi.json"; + } + + +} diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java new file mode 100644 index 000000000000..0c57ae7dd14c --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java @@ -0,0 +1,86 @@ +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 java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesAnyType + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesAnyType extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesAnyType name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesAnyType additionalPropertiesAnyType = (AdditionalPropertiesAnyType) o; + return Objects.equals(this.name, additionalPropertiesAnyType.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesAnyType {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesArray.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesArray.java new file mode 100644 index 000000000000..b5285ec2f29b --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesArray.java @@ -0,0 +1,87 @@ +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 java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesArray + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesArray extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesArray name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesArray additionalPropertiesArray = (AdditionalPropertiesArray) o; + return Objects.equals(this.name, additionalPropertiesArray.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesArray {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java new file mode 100644 index 000000000000..f8ca38c286d5 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java @@ -0,0 +1,86 @@ +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 java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesBoolean + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesBoolean extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesBoolean name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesBoolean additionalPropertiesBoolean = (AdditionalPropertiesBoolean) o; + return Objects.equals(this.name, additionalPropertiesBoolean.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesBoolean {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java new file mode 100644 index 000000000000..dfd28ccb9963 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java @@ -0,0 +1,414 @@ +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 java.math.BigDecimal; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesClass + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesClass { + @JsonProperty("map_string") + @Valid + private Map mapString = null; + + @JsonProperty("map_number") + @Valid + private Map mapNumber = null; + + @JsonProperty("map_integer") + @Valid + private Map mapInteger = null; + + @JsonProperty("map_boolean") + @Valid + private Map mapBoolean = null; + + @JsonProperty("map_array_integer") + @Valid + private Map> mapArrayInteger = null; + + @JsonProperty("map_array_anytype") + @Valid + private Map> mapArrayAnytype = null; + + @JsonProperty("map_map_string") + @Valid + private Map> mapMapString = null; + + @JsonProperty("map_map_anytype") + @Valid + private Map> mapMapAnytype = null; + + @JsonProperty("anytype_1") + private Object anytype1; + + @JsonProperty("anytype_2") + private Object anytype2; + + @JsonProperty("anytype_3") + private Object anytype3; + + public AdditionalPropertiesClass mapString(Map mapString) { + this.mapString = mapString; + return this; + } + + public AdditionalPropertiesClass putMapStringItem(String key, String mapStringItem) { + if (this.mapString == null) { + this.mapString = new HashMap<>(); + } + this.mapString.put(key, mapStringItem); + return this; + } + + /** + * Get mapString + * @return mapString + */ + @Schema(name = "mapString", defaultValue = "") + + + public Map getMapString() { + return mapString; + } + + public void setMapString(Map mapString) { + this.mapString = mapString; + } + + public AdditionalPropertiesClass mapNumber(Map mapNumber) { + this.mapNumber = mapNumber; + return this; + } + + public AdditionalPropertiesClass putMapNumberItem(String key, BigDecimal mapNumberItem) { + if (this.mapNumber == null) { + this.mapNumber = new HashMap<>(); + } + this.mapNumber.put(key, mapNumberItem); + return this; + } + + /** + * Get mapNumber + * @return mapNumber + */ + @Schema(name = "mapNumber", defaultValue = "") + + @Valid + + public Map getMapNumber() { + return mapNumber; + } + + public void setMapNumber(Map mapNumber) { + this.mapNumber = mapNumber; + } + + public AdditionalPropertiesClass mapInteger(Map mapInteger) { + this.mapInteger = mapInteger; + return this; + } + + public AdditionalPropertiesClass putMapIntegerItem(String key, Integer mapIntegerItem) { + if (this.mapInteger == null) { + this.mapInteger = new HashMap<>(); + } + this.mapInteger.put(key, mapIntegerItem); + return this; + } + + /** + * Get mapInteger + * @return mapInteger + */ + @Schema(name = "mapInteger", defaultValue = "") + + + public Map getMapInteger() { + return mapInteger; + } + + public void setMapInteger(Map mapInteger) { + this.mapInteger = mapInteger; + } + + public AdditionalPropertiesClass mapBoolean(Map mapBoolean) { + this.mapBoolean = mapBoolean; + return this; + } + + public AdditionalPropertiesClass putMapBooleanItem(String key, Boolean mapBooleanItem) { + if (this.mapBoolean == null) { + this.mapBoolean = new HashMap<>(); + } + this.mapBoolean.put(key, mapBooleanItem); + return this; + } + + /** + * Get mapBoolean + * @return mapBoolean + */ + @Schema(name = "mapBoolean", defaultValue = "") + + + public Map getMapBoolean() { + return mapBoolean; + } + + public void setMapBoolean(Map mapBoolean) { + this.mapBoolean = mapBoolean; + } + + public AdditionalPropertiesClass mapArrayInteger(Map> mapArrayInteger) { + this.mapArrayInteger = mapArrayInteger; + return this; + } + + public AdditionalPropertiesClass putMapArrayIntegerItem(String key, List mapArrayIntegerItem) { + if (this.mapArrayInteger == null) { + this.mapArrayInteger = new HashMap<>(); + } + this.mapArrayInteger.put(key, mapArrayIntegerItem); + return this; + } + + /** + * Get mapArrayInteger + * @return mapArrayInteger + */ + @Schema(name = "mapArrayInteger", defaultValue = "") + + @Valid + + public Map> getMapArrayInteger() { + return mapArrayInteger; + } + + public void setMapArrayInteger(Map> mapArrayInteger) { + this.mapArrayInteger = mapArrayInteger; + } + + public AdditionalPropertiesClass mapArrayAnytype(Map> mapArrayAnytype) { + this.mapArrayAnytype = mapArrayAnytype; + return this; + } + + public AdditionalPropertiesClass putMapArrayAnytypeItem(String key, List mapArrayAnytypeItem) { + if (this.mapArrayAnytype == null) { + this.mapArrayAnytype = new HashMap<>(); + } + this.mapArrayAnytype.put(key, mapArrayAnytypeItem); + return this; + } + + /** + * Get mapArrayAnytype + * @return mapArrayAnytype + */ + @Schema(name = "mapArrayAnytype", defaultValue = "") + + @Valid + + public Map> getMapArrayAnytype() { + return mapArrayAnytype; + } + + public void setMapArrayAnytype(Map> mapArrayAnytype) { + this.mapArrayAnytype = mapArrayAnytype; + } + + public AdditionalPropertiesClass mapMapString(Map> mapMapString) { + this.mapMapString = mapMapString; + return this; + } + + public AdditionalPropertiesClass putMapMapStringItem(String key, Map mapMapStringItem) { + if (this.mapMapString == null) { + this.mapMapString = new HashMap<>(); + } + this.mapMapString.put(key, mapMapStringItem); + return this; + } + + /** + * Get mapMapString + * @return mapMapString + */ + @Schema(name = "mapMapString", defaultValue = "") + + @Valid + + public Map> getMapMapString() { + return mapMapString; + } + + public void setMapMapString(Map> mapMapString) { + this.mapMapString = mapMapString; + } + + public AdditionalPropertiesClass mapMapAnytype(Map> mapMapAnytype) { + this.mapMapAnytype = mapMapAnytype; + return this; + } + + public AdditionalPropertiesClass putMapMapAnytypeItem(String key, Map mapMapAnytypeItem) { + if (this.mapMapAnytype == null) { + this.mapMapAnytype = new HashMap<>(); + } + this.mapMapAnytype.put(key, mapMapAnytypeItem); + return this; + } + + /** + * Get mapMapAnytype + * @return mapMapAnytype + */ + @Schema(name = "mapMapAnytype", defaultValue = "") + + @Valid + + public Map> getMapMapAnytype() { + return mapMapAnytype; + } + + public void setMapMapAnytype(Map> mapMapAnytype) { + this.mapMapAnytype = mapMapAnytype; + } + + public AdditionalPropertiesClass anytype1(Object anytype1) { + this.anytype1 = anytype1; + return this; + } + + /** + * Get anytype1 + * @return anytype1 + */ + @Schema(name = "anytype1", defaultValue = "") + + + public Object getAnytype1() { + return anytype1; + } + + public void setAnytype1(Object anytype1) { + this.anytype1 = anytype1; + } + + public AdditionalPropertiesClass anytype2(Object anytype2) { + this.anytype2 = anytype2; + return this; + } + + /** + * Get anytype2 + * @return anytype2 + */ + @Schema(name = "anytype2", defaultValue = "") + + + public Object getAnytype2() { + return anytype2; + } + + public void setAnytype2(Object anytype2) { + this.anytype2 = anytype2; + } + + public AdditionalPropertiesClass anytype3(Object anytype3) { + this.anytype3 = anytype3; + return this; + } + + /** + * Get anytype3 + * @return anytype3 + */ + @Schema(name = "anytype3", defaultValue = "") + + + public Object getAnytype3() { + return anytype3; + } + + public void setAnytype3(Object anytype3) { + this.anytype3 = anytype3; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AdditionalPropertiesClass additionalPropertiesClass = (AdditionalPropertiesClass) o; + return Objects.equals(this.mapString, additionalPropertiesClass.mapString) && + Objects.equals(this.mapNumber, additionalPropertiesClass.mapNumber) && + Objects.equals(this.mapInteger, additionalPropertiesClass.mapInteger) && + Objects.equals(this.mapBoolean, additionalPropertiesClass.mapBoolean) && + Objects.equals(this.mapArrayInteger, additionalPropertiesClass.mapArrayInteger) && + Objects.equals(this.mapArrayAnytype, additionalPropertiesClass.mapArrayAnytype) && + Objects.equals(this.mapMapString, additionalPropertiesClass.mapMapString) && + Objects.equals(this.mapMapAnytype, additionalPropertiesClass.mapMapAnytype) && + Objects.equals(this.anytype1, additionalPropertiesClass.anytype1) && + Objects.equals(this.anytype2, additionalPropertiesClass.anytype2) && + Objects.equals(this.anytype3, additionalPropertiesClass.anytype3); + } + + @Override + public int hashCode() { + return Objects.hash(mapString, mapNumber, mapInteger, mapBoolean, mapArrayInteger, mapArrayAnytype, mapMapString, mapMapAnytype, anytype1, anytype2, anytype3); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesClass {\n"); + + sb.append(" mapString: ").append(toIndentedString(mapString)).append("\n"); + sb.append(" mapNumber: ").append(toIndentedString(mapNumber)).append("\n"); + sb.append(" mapInteger: ").append(toIndentedString(mapInteger)).append("\n"); + sb.append(" mapBoolean: ").append(toIndentedString(mapBoolean)).append("\n"); + sb.append(" mapArrayInteger: ").append(toIndentedString(mapArrayInteger)).append("\n"); + sb.append(" mapArrayAnytype: ").append(toIndentedString(mapArrayAnytype)).append("\n"); + sb.append(" mapMapString: ").append(toIndentedString(mapMapString)).append("\n"); + sb.append(" mapMapAnytype: ").append(toIndentedString(mapMapAnytype)).append("\n"); + sb.append(" anytype1: ").append(toIndentedString(anytype1)).append("\n"); + sb.append(" anytype2: ").append(toIndentedString(anytype2)).append("\n"); + sb.append(" anytype3: ").append(toIndentedString(anytype3)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java new file mode 100644 index 000000000000..5fea577ab44b --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java @@ -0,0 +1,86 @@ +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 java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesInteger + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesInteger extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesInteger name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesInteger additionalPropertiesInteger = (AdditionalPropertiesInteger) o; + return Objects.equals(this.name, additionalPropertiesInteger.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesInteger {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java new file mode 100644 index 000000000000..e6eee612a24f --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java @@ -0,0 +1,87 @@ +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 java.math.BigDecimal; +import java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesNumber + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesNumber extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesNumber name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesNumber additionalPropertiesNumber = (AdditionalPropertiesNumber) o; + return Objects.equals(this.name, additionalPropertiesNumber.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesNumber {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesObject.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesObject.java new file mode 100644 index 000000000000..d7116bd7572c --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesObject.java @@ -0,0 +1,86 @@ +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 java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesObject + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesObject extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesObject name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesObject additionalPropertiesObject = (AdditionalPropertiesObject) o; + return Objects.equals(this.name, additionalPropertiesObject.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesObject {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesString.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesString.java new file mode 100644 index 000000000000..d2022be266fb --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesString.java @@ -0,0 +1,86 @@ +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 java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesString + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesString extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesString name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesString additionalPropertiesString = (AdditionalPropertiesString) o; + return Objects.equals(this.name, additionalPropertiesString.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesString {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Animal.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Animal.java new file mode 100644 index 000000000000..6f096d5069ed --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Animal.java @@ -0,0 +1,118 @@ +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.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Animal + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "className", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = BigCat.class, name = "BigCat"), + @JsonSubTypes.Type(value = Cat.class, name = "Cat"), + @JsonSubTypes.Type(value = Dog.class, name = "Dog"), +}) + +public class Animal { + @JsonProperty("className") + private String className; + + @JsonProperty("color") + private String color = "red"; + + public Animal className(String className) { + this.className = className; + return this; + } + + /** + * Get className + * @return className + */ + @Schema(name = "className", required = true, defaultValue = "") + @NotNull + + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public Animal color(String color) { + this.color = color; + return this; + } + + /** + * Get color + * @return color + */ + @Schema(name = "color", defaultValue = "") + + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Animal animal = (Animal) o; + return Objects.equals(this.className, animal.className) && + Objects.equals(this.color, animal.color); + } + + @Override + public int hashCode() { + return Objects.hash(className, color); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Animal {\n"); + + sb.append(" className: ").append(toIndentedString(className)).append("\n"); + sb.append(" color: ").append(toIndentedString(color)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java new file mode 100644 index 000000000000..ebe36ad761a9 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java @@ -0,0 +1,96 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ArrayOfArrayOfNumberOnly + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ArrayOfArrayOfNumberOnly { + @JsonProperty("ArrayArrayNumber") + @Valid + private List> arrayArrayNumber = null; + + public ArrayOfArrayOfNumberOnly arrayArrayNumber(List> arrayArrayNumber) { + this.arrayArrayNumber = arrayArrayNumber; + return this; + } + + public ArrayOfArrayOfNumberOnly addArrayArrayNumberItem(List arrayArrayNumberItem) { + if (this.arrayArrayNumber == null) { + this.arrayArrayNumber = new ArrayList<>(); + } + this.arrayArrayNumber.add(arrayArrayNumberItem); + return this; + } + + /** + * Get arrayArrayNumber + * @return arrayArrayNumber + */ + @Schema(name = "arrayArrayNumber", defaultValue = "") + + @Valid + + public List> getArrayArrayNumber() { + return arrayArrayNumber; + } + + public void setArrayArrayNumber(List> arrayArrayNumber) { + this.arrayArrayNumber = arrayArrayNumber; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly = (ArrayOfArrayOfNumberOnly) o; + return Objects.equals(this.arrayArrayNumber, arrayOfArrayOfNumberOnly.arrayArrayNumber); + } + + @Override + public int hashCode() { + return Objects.hash(arrayArrayNumber); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayOfArrayOfNumberOnly {\n"); + + sb.append(" arrayArrayNumber: ").append(toIndentedString(arrayArrayNumber)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ArrayOfNumberOnly.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ArrayOfNumberOnly.java new file mode 100644 index 000000000000..8158dd44ab88 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ArrayOfNumberOnly.java @@ -0,0 +1,96 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ArrayOfNumberOnly + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ArrayOfNumberOnly { + @JsonProperty("ArrayNumber") + @Valid + private List arrayNumber = null; + + public ArrayOfNumberOnly arrayNumber(List arrayNumber) { + this.arrayNumber = arrayNumber; + return this; + } + + public ArrayOfNumberOnly addArrayNumberItem(BigDecimal arrayNumberItem) { + if (this.arrayNumber == null) { + this.arrayNumber = new ArrayList<>(); + } + this.arrayNumber.add(arrayNumberItem); + return this; + } + + /** + * Get arrayNumber + * @return arrayNumber + */ + @Schema(name = "arrayNumber", defaultValue = "") + + @Valid + + public List getArrayNumber() { + return arrayNumber; + } + + public void setArrayNumber(List arrayNumber) { + this.arrayNumber = arrayNumber; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayOfNumberOnly arrayOfNumberOnly = (ArrayOfNumberOnly) o; + return Objects.equals(this.arrayNumber, arrayOfNumberOnly.arrayNumber); + } + + @Override + public int hashCode() { + return Objects.hash(arrayNumber); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayOfNumberOnly {\n"); + + sb.append(" arrayNumber: ").append(toIndentedString(arrayNumber)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ArrayTest.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ArrayTest.java new file mode 100644 index 000000000000..420010561bcd --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ArrayTest.java @@ -0,0 +1,165 @@ +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 java.util.ArrayList; +import java.util.List; +import org.openapitools.model.ReadOnlyFirst; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ArrayTest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ArrayTest { + @JsonProperty("array_of_string") + @Valid + private List arrayOfString = null; + + @JsonProperty("array_array_of_integer") + @Valid + private List> arrayArrayOfInteger = null; + + @JsonProperty("array_array_of_model") + @Valid + private List> arrayArrayOfModel = null; + + public ArrayTest arrayOfString(List arrayOfString) { + this.arrayOfString = arrayOfString; + return this; + } + + public ArrayTest addArrayOfStringItem(String arrayOfStringItem) { + if (this.arrayOfString == null) { + this.arrayOfString = new ArrayList<>(); + } + this.arrayOfString.add(arrayOfStringItem); + return this; + } + + /** + * Get arrayOfString + * @return arrayOfString + */ + @Schema(name = "arrayOfString", defaultValue = "") + + + public List getArrayOfString() { + return arrayOfString; + } + + public void setArrayOfString(List arrayOfString) { + this.arrayOfString = arrayOfString; + } + + public ArrayTest arrayArrayOfInteger(List> arrayArrayOfInteger) { + this.arrayArrayOfInteger = arrayArrayOfInteger; + return this; + } + + public ArrayTest addArrayArrayOfIntegerItem(List arrayArrayOfIntegerItem) { + if (this.arrayArrayOfInteger == null) { + this.arrayArrayOfInteger = new ArrayList<>(); + } + this.arrayArrayOfInteger.add(arrayArrayOfIntegerItem); + return this; + } + + /** + * Get arrayArrayOfInteger + * @return arrayArrayOfInteger + */ + @Schema(name = "arrayArrayOfInteger", defaultValue = "") + + @Valid + + public List> getArrayArrayOfInteger() { + return arrayArrayOfInteger; + } + + public void setArrayArrayOfInteger(List> arrayArrayOfInteger) { + this.arrayArrayOfInteger = arrayArrayOfInteger; + } + + public ArrayTest arrayArrayOfModel(List> arrayArrayOfModel) { + this.arrayArrayOfModel = arrayArrayOfModel; + return this; + } + + public ArrayTest addArrayArrayOfModelItem(List arrayArrayOfModelItem) { + if (this.arrayArrayOfModel == null) { + this.arrayArrayOfModel = new ArrayList<>(); + } + this.arrayArrayOfModel.add(arrayArrayOfModelItem); + return this; + } + + /** + * Get arrayArrayOfModel + * @return arrayArrayOfModel + */ + @Schema(name = "arrayArrayOfModel", defaultValue = "") + + @Valid + + public List> getArrayArrayOfModel() { + return arrayArrayOfModel; + } + + public void setArrayArrayOfModel(List> arrayArrayOfModel) { + this.arrayArrayOfModel = arrayArrayOfModel; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayTest arrayTest = (ArrayTest) o; + return Objects.equals(this.arrayOfString, arrayTest.arrayOfString) && + Objects.equals(this.arrayArrayOfInteger, arrayTest.arrayArrayOfInteger) && + Objects.equals(this.arrayArrayOfModel, arrayTest.arrayArrayOfModel); + } + + @Override + public int hashCode() { + return Objects.hash(arrayOfString, arrayArrayOfInteger, arrayArrayOfModel); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayTest {\n"); + + sb.append(" arrayOfString: ").append(toIndentedString(arrayOfString)).append("\n"); + sb.append(" arrayArrayOfInteger: ").append(toIndentedString(arrayArrayOfInteger)).append("\n"); + sb.append(" arrayArrayOfModel: ").append(toIndentedString(arrayArrayOfModel)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/BigCat.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/BigCat.java new file mode 100644 index 000000000000..7f4a080ad8d2 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/BigCat.java @@ -0,0 +1,126 @@ +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 org.openapitools.model.BigCatAllOf; +import org.openapitools.model.Cat; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * BigCat + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class BigCat extends Cat { + /** + * Gets or Sets kind + */ + public enum KindEnum { + LIONS("lions"), + + TIGERS("tigers"), + + LEOPARDS("leopards"), + + JAGUARS("jaguars"); + + private String value; + + KindEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static KindEnum fromValue(String value) { + for (KindEnum b : KindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("kind") + private KindEnum kind; + + public BigCat kind(KindEnum kind) { + this.kind = kind; + return this; + } + + /** + * Get kind + * @return kind + */ + @Schema(name = "kind", defaultValue = "") + + + public KindEnum getKind() { + return kind; + } + + public void setKind(KindEnum kind) { + this.kind = kind; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BigCat bigCat = (BigCat) o; + return Objects.equals(this.kind, bigCat.kind) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(kind, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BigCat {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/BigCatAllOf.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/BigCatAllOf.java new file mode 100644 index 000000000000..d0a47ab5127c --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/BigCatAllOf.java @@ -0,0 +1,123 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * BigCatAllOf + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class BigCatAllOf { + /** + * Gets or Sets kind + */ + public enum KindEnum { + LIONS("lions"), + + TIGERS("tigers"), + + LEOPARDS("leopards"), + + JAGUARS("jaguars"); + + private String value; + + KindEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static KindEnum fromValue(String value) { + for (KindEnum b : KindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("kind") + private KindEnum kind; + + public BigCatAllOf kind(KindEnum kind) { + this.kind = kind; + return this; + } + + /** + * Get kind + * @return kind + */ + @Schema(name = "kind", defaultValue = "") + + + public KindEnum getKind() { + return kind; + } + + public void setKind(KindEnum kind) { + this.kind = kind; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BigCatAllOf bigCatAllOf = (BigCatAllOf) o; + return Objects.equals(this.kind, bigCatAllOf.kind); + } + + @Override + public int hashCode() { + return Objects.hash(kind); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BigCatAllOf {\n"); + + sb.append(" kind: ").append(toIndentedString(kind)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Capitalization.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Capitalization.java new file mode 100644 index 000000000000..92d9a7245f16 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Capitalization.java @@ -0,0 +1,208 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Capitalization + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Capitalization { + @JsonProperty("smallCamel") + private String smallCamel; + + @JsonProperty("CapitalCamel") + private String capitalCamel; + + @JsonProperty("small_Snake") + private String smallSnake; + + @JsonProperty("Capital_Snake") + private String capitalSnake; + + @JsonProperty("SCA_ETH_Flow_Points") + private String scAETHFlowPoints; + + @JsonProperty("ATT_NAME") + private String ATT_NAME; + + public Capitalization smallCamel(String smallCamel) { + this.smallCamel = smallCamel; + return this; + } + + /** + * Get smallCamel + * @return smallCamel + */ + @Schema(name = "smallCamel", defaultValue = "") + + + public String getSmallCamel() { + return smallCamel; + } + + public void setSmallCamel(String smallCamel) { + this.smallCamel = smallCamel; + } + + public Capitalization capitalCamel(String capitalCamel) { + this.capitalCamel = capitalCamel; + return this; + } + + /** + * Get capitalCamel + * @return capitalCamel + */ + @Schema(name = "capitalCamel", defaultValue = "") + + + public String getCapitalCamel() { + return capitalCamel; + } + + public void setCapitalCamel(String capitalCamel) { + this.capitalCamel = capitalCamel; + } + + public Capitalization smallSnake(String smallSnake) { + this.smallSnake = smallSnake; + return this; + } + + /** + * Get smallSnake + * @return smallSnake + */ + @Schema(name = "smallSnake", defaultValue = "") + + + public String getSmallSnake() { + return smallSnake; + } + + public void setSmallSnake(String smallSnake) { + this.smallSnake = smallSnake; + } + + public Capitalization capitalSnake(String capitalSnake) { + this.capitalSnake = capitalSnake; + return this; + } + + /** + * Get capitalSnake + * @return capitalSnake + */ + @Schema(name = "capitalSnake", defaultValue = "") + + + public String getCapitalSnake() { + return capitalSnake; + } + + public void setCapitalSnake(String capitalSnake) { + this.capitalSnake = capitalSnake; + } + + public Capitalization scAETHFlowPoints(String scAETHFlowPoints) { + this.scAETHFlowPoints = scAETHFlowPoints; + return this; + } + + /** + * Get scAETHFlowPoints + * @return scAETHFlowPoints + */ + @Schema(name = "scAETHFlowPoints", defaultValue = "") + + + public String getScAETHFlowPoints() { + return scAETHFlowPoints; + } + + public void setScAETHFlowPoints(String scAETHFlowPoints) { + this.scAETHFlowPoints = scAETHFlowPoints; + } + + public Capitalization ATT_NAME(String ATT_NAME) { + this.ATT_NAME = ATT_NAME; + return this; + } + + /** + * Name of the pet + * @return ATT_NAME + */ + @Schema(name = "ATT_NAME", defaultValue = "Name of the pet ") + + + public String getATTNAME() { + return ATT_NAME; + } + + public void setATTNAME(String ATT_NAME) { + this.ATT_NAME = ATT_NAME; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Capitalization capitalization = (Capitalization) o; + return Objects.equals(this.smallCamel, capitalization.smallCamel) && + Objects.equals(this.capitalCamel, capitalization.capitalCamel) && + Objects.equals(this.smallSnake, capitalization.smallSnake) && + Objects.equals(this.capitalSnake, capitalization.capitalSnake) && + Objects.equals(this.scAETHFlowPoints, capitalization.scAETHFlowPoints) && + Objects.equals(this.ATT_NAME, capitalization.ATT_NAME); + } + + @Override + public int hashCode() { + return Objects.hash(smallCamel, capitalCamel, smallSnake, capitalSnake, scAETHFlowPoints, ATT_NAME); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Capitalization {\n"); + + sb.append(" smallCamel: ").append(toIndentedString(smallCamel)).append("\n"); + sb.append(" capitalCamel: ").append(toIndentedString(capitalCamel)).append("\n"); + sb.append(" smallSnake: ").append(toIndentedString(smallSnake)).append("\n"); + sb.append(" capitalSnake: ").append(toIndentedString(capitalSnake)).append("\n"); + sb.append(" scAETHFlowPoints: ").append(toIndentedString(scAETHFlowPoints)).append("\n"); + sb.append(" ATT_NAME: ").append(toIndentedString(ATT_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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Cat.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Cat.java new file mode 100644 index 000000000000..2e496fb4accd --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Cat.java @@ -0,0 +1,86 @@ +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 org.openapitools.model.Animal; +import org.openapitools.model.CatAllOf; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Cat + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Cat extends Animal { + @JsonProperty("declawed") + private Boolean declawed; + + public Cat declawed(Boolean declawed) { + this.declawed = declawed; + return this; + } + + /** + * Get declawed + * @return declawed + */ + @Schema(name = "declawed", defaultValue = "") + + + public Boolean getDeclawed() { + return declawed; + } + + public void setDeclawed(Boolean declawed) { + this.declawed = declawed; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Cat cat = (Cat) o; + return Objects.equals(this.declawed, cat.declawed) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(declawed, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Cat {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" declawed: ").append(toIndentedString(declawed)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/CatAllOf.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/CatAllOf.java new file mode 100644 index 000000000000..b732a62b1bc3 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/CatAllOf.java @@ -0,0 +1,83 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * CatAllOf + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class CatAllOf { + @JsonProperty("declawed") + private Boolean declawed; + + public CatAllOf declawed(Boolean declawed) { + this.declawed = declawed; + return this; + } + + /** + * Get declawed + * @return declawed + */ + @Schema(name = "declawed", defaultValue = "") + + + public Boolean getDeclawed() { + return declawed; + } + + public void setDeclawed(Boolean declawed) { + this.declawed = declawed; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CatAllOf catAllOf = (CatAllOf) o; + return Objects.equals(this.declawed, catAllOf.declawed); + } + + @Override + public int hashCode() { + return Objects.hash(declawed); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CatAllOf {\n"); + + sb.append(" declawed: ").append(toIndentedString(declawed)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Category.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Category.java new file mode 100644 index 000000000000..038fc8df3afd --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Category.java @@ -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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Category + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Category { + @JsonProperty("id") + private Long id; + + @JsonProperty("name") + private String name = "default-name"; + + public Category id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "name", required = true, defaultValue = "") + @NotNull + + + 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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ClassModel.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ClassModel.java new file mode 100644 index 000000000000..fa2a736f4fb5 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ClassModel.java @@ -0,0 +1,84 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Model for testing model with \"_class\" property + */ +@Schema(name = "ClassModel",description = "Model for testing model with \"_class\" property") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ClassModel { + @JsonProperty("_class") + private String propertyClass; + + public ClassModel propertyClass(String propertyClass) { + this.propertyClass = propertyClass; + return this; + } + + /** + * Get propertyClass + * @return propertyClass + */ + @Schema(name = "propertyClass", defaultValue = "") + + + public String getPropertyClass() { + return propertyClass; + } + + public void setPropertyClass(String propertyClass) { + this.propertyClass = propertyClass; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClassModel classModel = (ClassModel) o; + return Objects.equals(this.propertyClass, classModel.propertyClass); + } + + @Override + public int hashCode() { + return Objects.hash(propertyClass); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ClassModel {\n"); + + sb.append(" propertyClass: ").append(toIndentedString(propertyClass)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Client.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Client.java new file mode 100644 index 000000000000..e11bd4ff1b13 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Client.java @@ -0,0 +1,83 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Client + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Client { + @JsonProperty("client") + private String client; + + public Client client(String client) { + this.client = client; + return this; + } + + /** + * Get client + * @return client + */ + @Schema(name = "client", defaultValue = "") + + + public String getClient() { + return client; + } + + public void setClient(String client) { + this.client = client; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Client client = (Client) o; + return Objects.equals(this.client, client.client); + } + + @Override + public int hashCode() { + return Objects.hash(client); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Client {\n"); + + sb.append(" client: ").append(toIndentedString(client)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Dog.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Dog.java new file mode 100644 index 000000000000..ed5dc71a4ba2 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Dog.java @@ -0,0 +1,86 @@ +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 org.openapitools.model.Animal; +import org.openapitools.model.DogAllOf; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Dog + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Dog extends Animal { + @JsonProperty("breed") + private String breed; + + public Dog breed(String breed) { + this.breed = breed; + return this; + } + + /** + * Get breed + * @return breed + */ + @Schema(name = "breed", defaultValue = "") + + + public String getBreed() { + return breed; + } + + public void setBreed(String breed) { + this.breed = breed; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Dog dog = (Dog) o; + return Objects.equals(this.breed, dog.breed) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(breed, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Dog {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" breed: ").append(toIndentedString(breed)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/DogAllOf.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/DogAllOf.java new file mode 100644 index 000000000000..2c99bc376c34 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/DogAllOf.java @@ -0,0 +1,83 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * DogAllOf + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class DogAllOf { + @JsonProperty("breed") + private String breed; + + public DogAllOf breed(String breed) { + this.breed = breed; + return this; + } + + /** + * Get breed + * @return breed + */ + @Schema(name = "breed", defaultValue = "") + + + public String getBreed() { + return breed; + } + + public void setBreed(String breed) { + this.breed = breed; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DogAllOf dogAllOf = (DogAllOf) o; + return Objects.equals(this.breed, dogAllOf.breed); + } + + @Override + public int hashCode() { + return Objects.hash(breed); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DogAllOf {\n"); + + sb.append(" breed: ").append(toIndentedString(breed)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/EnumArrays.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/EnumArrays.java new file mode 100644 index 000000000000..e1b2df0716a2 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/EnumArrays.java @@ -0,0 +1,190 @@ +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 java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * EnumArrays + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class EnumArrays { + /** + * Gets or Sets justSymbol + */ + public enum JustSymbolEnum { + GREATER_THAN_OR_EQUAL_TO(">="), + + DOLLAR("$"); + + private String value; + + JustSymbolEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static JustSymbolEnum fromValue(String value) { + for (JustSymbolEnum b : JustSymbolEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("just_symbol") + private JustSymbolEnum justSymbol; + + /** + * Gets or Sets arrayEnum + */ + public enum ArrayEnumEnum { + FISH("fish"), + + CRAB("crab"); + + private String value; + + ArrayEnumEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static ArrayEnumEnum fromValue(String value) { + for (ArrayEnumEnum b : ArrayEnumEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("array_enum") + @Valid + private List arrayEnum = null; + + public EnumArrays justSymbol(JustSymbolEnum justSymbol) { + this.justSymbol = justSymbol; + return this; + } + + /** + * Get justSymbol + * @return justSymbol + */ + @Schema(name = "justSymbol", defaultValue = "") + + + public JustSymbolEnum getJustSymbol() { + return justSymbol; + } + + public void setJustSymbol(JustSymbolEnum justSymbol) { + this.justSymbol = justSymbol; + } + + public EnumArrays arrayEnum(List arrayEnum) { + this.arrayEnum = arrayEnum; + return this; + } + + public EnumArrays addArrayEnumItem(ArrayEnumEnum arrayEnumItem) { + if (this.arrayEnum == null) { + this.arrayEnum = new ArrayList<>(); + } + this.arrayEnum.add(arrayEnumItem); + return this; + } + + /** + * Get arrayEnum + * @return arrayEnum + */ + @Schema(name = "arrayEnum", defaultValue = "") + + + public List getArrayEnum() { + return arrayEnum; + } + + public void setArrayEnum(List arrayEnum) { + this.arrayEnum = arrayEnum; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EnumArrays enumArrays = (EnumArrays) o; + return Objects.equals(this.justSymbol, enumArrays.justSymbol) && + Objects.equals(this.arrayEnum, enumArrays.arrayEnum); + } + + @Override + public int hashCode() { + return Objects.hash(justSymbol, arrayEnum); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EnumArrays {\n"); + + sb.append(" justSymbol: ").append(toIndentedString(justSymbol)).append("\n"); + sb.append(" arrayEnum: ").append(toIndentedString(arrayEnum)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/EnumClass.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/EnumClass.java new file mode 100644 index 000000000000..e3d30c1ad453 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/EnumClass.java @@ -0,0 +1,55 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Gets or Sets EnumClass + */ +public enum EnumClass { + + _ABC("_abc"), + + _EFG("-efg"), + + _XYZ_("(xyz)"); + + private String value; + + EnumClass(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumClass fromValue(String value) { + for (EnumClass b : EnumClass.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/EnumTest.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/EnumTest.java new file mode 100644 index 000000000000..938af53e2b81 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/EnumTest.java @@ -0,0 +1,331 @@ +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 org.openapitools.model.OuterEnum; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * EnumTest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class EnumTest { + /** + * Gets or Sets enumString + */ + public enum EnumStringEnum { + UPPER("UPPER"), + + LOWER("lower"), + + EMPTY(""); + + private String value; + + EnumStringEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumStringEnum fromValue(String value) { + for (EnumStringEnum b : EnumStringEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("enum_string") + private EnumStringEnum enumString; + + /** + * Gets or Sets enumStringRequired + */ + public enum EnumStringRequiredEnum { + UPPER("UPPER"), + + LOWER("lower"), + + EMPTY(""); + + private String value; + + EnumStringRequiredEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumStringRequiredEnum fromValue(String value) { + for (EnumStringRequiredEnum b : EnumStringRequiredEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("enum_string_required") + private EnumStringRequiredEnum enumStringRequired; + + /** + * Gets or Sets enumInteger + */ + public enum EnumIntegerEnum { + NUMBER_1(1), + + NUMBER_MINUS_1(-1); + + private Integer value; + + EnumIntegerEnum(Integer value) { + this.value = value; + } + + @JsonValue + public Integer getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumIntegerEnum fromValue(Integer value) { + for (EnumIntegerEnum b : EnumIntegerEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("enum_integer") + private EnumIntegerEnum enumInteger; + + /** + * Gets or Sets enumNumber + */ + public enum EnumNumberEnum { + NUMBER_1_DOT_1(1.1), + + NUMBER_MINUS_1_DOT_2(-1.2); + + private Double value; + + EnumNumberEnum(Double value) { + this.value = value; + } + + @JsonValue + public Double getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumNumberEnum fromValue(Double value) { + for (EnumNumberEnum b : EnumNumberEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("enum_number") + private EnumNumberEnum enumNumber; + + @JsonProperty("outerEnum") + private OuterEnum outerEnum; + + public EnumTest enumString(EnumStringEnum enumString) { + this.enumString = enumString; + return this; + } + + /** + * Get enumString + * @return enumString + */ + @Schema(name = "enumString", defaultValue = "") + + + public EnumStringEnum getEnumString() { + return enumString; + } + + public void setEnumString(EnumStringEnum enumString) { + this.enumString = enumString; + } + + public EnumTest enumStringRequired(EnumStringRequiredEnum enumStringRequired) { + this.enumStringRequired = enumStringRequired; + return this; + } + + /** + * Get enumStringRequired + * @return enumStringRequired + */ + @Schema(name = "enumStringRequired", required = true, defaultValue = "") + @NotNull + + + public EnumStringRequiredEnum getEnumStringRequired() { + return enumStringRequired; + } + + public void setEnumStringRequired(EnumStringRequiredEnum enumStringRequired) { + this.enumStringRequired = enumStringRequired; + } + + public EnumTest enumInteger(EnumIntegerEnum enumInteger) { + this.enumInteger = enumInteger; + return this; + } + + /** + * Get enumInteger + * @return enumInteger + */ + @Schema(name = "enumInteger", defaultValue = "") + + + public EnumIntegerEnum getEnumInteger() { + return enumInteger; + } + + public void setEnumInteger(EnumIntegerEnum enumInteger) { + this.enumInteger = enumInteger; + } + + public EnumTest enumNumber(EnumNumberEnum enumNumber) { + this.enumNumber = enumNumber; + return this; + } + + /** + * Get enumNumber + * @return enumNumber + */ + @Schema(name = "enumNumber", defaultValue = "") + + + public EnumNumberEnum getEnumNumber() { + return enumNumber; + } + + public void setEnumNumber(EnumNumberEnum enumNumber) { + this.enumNumber = enumNumber; + } + + public EnumTest outerEnum(OuterEnum outerEnum) { + this.outerEnum = outerEnum; + return this; + } + + /** + * Get outerEnum + * @return outerEnum + */ + @Schema(name = "outerEnum", defaultValue = "") + + @Valid + + public OuterEnum getOuterEnum() { + return outerEnum; + } + + public void setOuterEnum(OuterEnum outerEnum) { + this.outerEnum = outerEnum; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EnumTest enumTest = (EnumTest) o; + return Objects.equals(this.enumString, enumTest.enumString) && + Objects.equals(this.enumStringRequired, enumTest.enumStringRequired) && + Objects.equals(this.enumInteger, enumTest.enumInteger) && + Objects.equals(this.enumNumber, enumTest.enumNumber) && + Objects.equals(this.outerEnum, enumTest.outerEnum); + } + + @Override + public int hashCode() { + return Objects.hash(enumString, enumStringRequired, enumInteger, enumNumber, outerEnum); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EnumTest {\n"); + + sb.append(" enumString: ").append(toIndentedString(enumString)).append("\n"); + sb.append(" enumStringRequired: ").append(toIndentedString(enumStringRequired)).append("\n"); + sb.append(" enumInteger: ").append(toIndentedString(enumInteger)).append("\n"); + sb.append(" enumNumber: ").append(toIndentedString(enumNumber)).append("\n"); + sb.append(" outerEnum: ").append(toIndentedString(outerEnum)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/FileSchemaTestClass.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/FileSchemaTestClass.java new file mode 100644 index 000000000000..0d1e9ca8495c --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/FileSchemaTestClass.java @@ -0,0 +1,121 @@ +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 java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * FileSchemaTestClass + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class FileSchemaTestClass { + @JsonProperty("file") + private java.io.File file; + + @JsonProperty("files") + @Valid + private List files = null; + + public FileSchemaTestClass file(java.io.File file) { + this.file = file; + return this; + } + + /** + * Get file + * @return file + */ + @Schema(name = "file", defaultValue = "") + + @Valid + + public java.io.File getFile() { + return file; + } + + public void setFile(java.io.File file) { + this.file = file; + } + + public FileSchemaTestClass files(List files) { + this.files = files; + return this; + } + + public FileSchemaTestClass addFilesItem(java.io.File filesItem) { + if (this.files == null) { + this.files = new ArrayList<>(); + } + this.files.add(filesItem); + return this; + } + + /** + * Get files + * @return files + */ + @Schema(name = "files", defaultValue = "") + + @Valid + + public List getFiles() { + return files; + } + + public void setFiles(List files) { + this.files = files; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FileSchemaTestClass fileSchemaTestClass = (FileSchemaTestClass) o; + return Objects.equals(this.file, fileSchemaTestClass.file) && + Objects.equals(this.files, fileSchemaTestClass.files); + } + + @Override + public int hashCode() { + return Objects.hash(file, files); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FileSchemaTestClass {\n"); + + sb.append(" file: ").append(toIndentedString(file)).append("\n"); + sb.append(" files: ").append(toIndentedString(files)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/FormatTest.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/FormatTest.java new file mode 100644 index 000000000000..6546370cd329 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/FormatTest.java @@ -0,0 +1,435 @@ +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 java.math.BigDecimal; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.UUID; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * FormatTest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class FormatTest { + @JsonProperty("integer") + private Integer integer; + + @JsonProperty("int32") + private Integer int32; + + @JsonProperty("int64") + private Long int64; + + @JsonProperty("number") + private BigDecimal number; + + @JsonProperty("float") + private Float _float; + + @JsonProperty("double") + private Double _double; + + @JsonProperty("string") + private String string; + + @JsonProperty("byte") + private byte[] _byte; + + @JsonProperty("binary") + private org.springframework.core.io.Resource binary; + + @JsonProperty("date") + @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) + private LocalDate date; + + @JsonProperty("dateTime") + @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) + private OffsetDateTime dateTime; + + @JsonProperty("uuid") + private UUID uuid; + + @JsonProperty("password") + private String password; + + @JsonProperty("BigDecimal") + private BigDecimal bigDecimal; + + public FormatTest integer(Integer integer) { + this.integer = integer; + return this; + } + + /** + * Get integer + * minimum: 10 + * maximum: 100 + * @return integer + */ + @Schema(name = "integer", defaultValue = "") + +@Min(10) @Max(100) + public Integer getInteger() { + return integer; + } + + public void setInteger(Integer integer) { + this.integer = integer; + } + + public FormatTest int32(Integer int32) { + this.int32 = int32; + return this; + } + + /** + * Get int32 + * minimum: 20 + * maximum: 200 + * @return int32 + */ + @Schema(name = "int32", defaultValue = "") + +@Min(20) @Max(200) + public Integer getInt32() { + return int32; + } + + public void setInt32(Integer int32) { + this.int32 = int32; + } + + public FormatTest int64(Long int64) { + this.int64 = int64; + return this; + } + + /** + * Get int64 + * @return int64 + */ + @Schema(name = "int64", defaultValue = "") + + + public Long getInt64() { + return int64; + } + + public void setInt64(Long int64) { + this.int64 = int64; + } + + public FormatTest number(BigDecimal number) { + this.number = number; + return this; + } + + /** + * Get number + * minimum: 32.1 + * maximum: 543.2 + * @return number + */ + @Schema(name = "number", required = true, defaultValue = "") + @NotNull + + @Valid +@DecimalMin("32.1") @DecimalMax("543.2") + public BigDecimal getNumber() { + return number; + } + + public void setNumber(BigDecimal number) { + this.number = number; + } + + public FormatTest _float(Float _float) { + this._float = _float; + return this; + } + + /** + * Get _float + * minimum: 54.3 + * maximum: 987.6 + * @return _float + */ + @Schema(name = "_float", defaultValue = "") + +@DecimalMin("54.3") @DecimalMax("987.6") + public Float getFloat() { + return _float; + } + + public void setFloat(Float _float) { + this._float = _float; + } + + public FormatTest _double(Double _double) { + this._double = _double; + return this; + } + + /** + * Get _double + * minimum: 67.8 + * maximum: 123.4 + * @return _double + */ + @Schema(name = "_double", defaultValue = "") + +@DecimalMin("67.8") @DecimalMax("123.4") + public Double getDouble() { + return _double; + } + + public void setDouble(Double _double) { + this._double = _double; + } + + public FormatTest string(String string) { + this.string = string; + return this; + } + + /** + * Get string + * @return string + */ + @Schema(name = "string", defaultValue = "") + +@Pattern(regexp = "/[a-z]/i") + public String getString() { + return string; + } + + public void setString(String string) { + this.string = string; + } + + public FormatTest _byte(byte[] _byte) { + this._byte = _byte; + return this; + } + + /** + * Get _byte + * @return _byte + */ + @Schema(name = "_byte", required = true, defaultValue = "") + @NotNull + + + public byte[] getByte() { + return _byte; + } + + public void setByte(byte[] _byte) { + this._byte = _byte; + } + + public FormatTest binary(org.springframework.core.io.Resource binary) { + this.binary = binary; + return this; + } + + /** + * Get binary + * @return binary + */ + @Schema(name = "binary", defaultValue = "") + + @Valid + + public org.springframework.core.io.Resource getBinary() { + return binary; + } + + public void setBinary(org.springframework.core.io.Resource binary) { + this.binary = binary; + } + + public FormatTest date(LocalDate date) { + this.date = date; + return this; + } + + /** + * Get date + * @return date + */ + @Schema(name = "date", required = true, defaultValue = "") + @NotNull + + @Valid + + public LocalDate getDate() { + return date; + } + + public void setDate(LocalDate date) { + this.date = date; + } + + public FormatTest dateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + return this; + } + + /** + * Get dateTime + * @return dateTime + */ + @Schema(name = "dateTime", defaultValue = "") + + @Valid + + public OffsetDateTime getDateTime() { + return dateTime; + } + + public void setDateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + } + + public FormatTest uuid(UUID uuid) { + this.uuid = uuid; + return this; + } + + /** + * Get uuid + * @return uuid + */ + @Schema(name = "uuid", example = "72f98069-206d-4f12-9f12-3d1e525a8e84", defaultValue = "") + + @Valid + + public UUID getUuid() { + return uuid; + } + + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + public FormatTest password(String password) { + this.password = password; + return this; + } + + /** + * Get password + * @return password + */ + @Schema(name = "password", required = true, defaultValue = "") + @NotNull + +@Size(min = 10, max = 64) + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public FormatTest bigDecimal(BigDecimal bigDecimal) { + this.bigDecimal = bigDecimal; + return this; + } + + /** + * Get bigDecimal + * @return bigDecimal + */ + @Schema(name = "bigDecimal", defaultValue = "") + + @Valid + + public BigDecimal getBigDecimal() { + return bigDecimal; + } + + public void setBigDecimal(BigDecimal bigDecimal) { + this.bigDecimal = bigDecimal; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FormatTest formatTest = (FormatTest) o; + return Objects.equals(this.integer, formatTest.integer) && + Objects.equals(this.int32, formatTest.int32) && + Objects.equals(this.int64, formatTest.int64) && + Objects.equals(this.number, formatTest.number) && + Objects.equals(this._float, formatTest._float) && + Objects.equals(this._double, formatTest._double) && + Objects.equals(this.string, formatTest.string) && + Arrays.equals(this._byte, formatTest._byte) && + Objects.equals(this.binary, formatTest.binary) && + Objects.equals(this.date, formatTest.date) && + Objects.equals(this.dateTime, formatTest.dateTime) && + Objects.equals(this.uuid, formatTest.uuid) && + Objects.equals(this.password, formatTest.password) && + Objects.equals(this.bigDecimal, formatTest.bigDecimal); + } + + @Override + public int hashCode() { + return Objects.hash(integer, int32, int64, number, _float, _double, string, Arrays.hashCode(_byte), binary, date, dateTime, uuid, password, bigDecimal); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FormatTest {\n"); + + sb.append(" integer: ").append(toIndentedString(integer)).append("\n"); + sb.append(" int32: ").append(toIndentedString(int32)).append("\n"); + sb.append(" int64: ").append(toIndentedString(int64)).append("\n"); + sb.append(" number: ").append(toIndentedString(number)).append("\n"); + sb.append(" _float: ").append(toIndentedString(_float)).append("\n"); + sb.append(" _double: ").append(toIndentedString(_double)).append("\n"); + sb.append(" string: ").append(toIndentedString(string)).append("\n"); + sb.append(" _byte: ").append(toIndentedString(_byte)).append("\n"); + sb.append(" binary: ").append(toIndentedString(binary)).append("\n"); + sb.append(" date: ").append(toIndentedString(date)).append("\n"); + sb.append(" dateTime: ").append(toIndentedString(dateTime)).append("\n"); + sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" bigDecimal: ").append(toIndentedString(bigDecimal)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/HasOnlyReadOnly.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/HasOnlyReadOnly.java new file mode 100644 index 000000000000..dfb615a529fc --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/HasOnlyReadOnly.java @@ -0,0 +1,108 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * HasOnlyReadOnly + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class HasOnlyReadOnly { + @JsonProperty("bar") + private String bar; + + @JsonProperty("foo") + private String foo; + + public HasOnlyReadOnly bar(String bar) { + this.bar = bar; + return this; + } + + /** + * Get bar + * @return bar + */ + @Schema(name = "bar", readOnly = true, defaultValue = "") + + + public String getBar() { + return bar; + } + + public void setBar(String bar) { + this.bar = bar; + } + + public HasOnlyReadOnly foo(String foo) { + this.foo = foo; + return this; + } + + /** + * Get foo + * @return foo + */ + @Schema(name = "foo", readOnly = true, defaultValue = "") + + + public String getFoo() { + return foo; + } + + public void setFoo(String foo) { + this.foo = foo; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HasOnlyReadOnly hasOnlyReadOnly = (HasOnlyReadOnly) o; + return Objects.equals(this.bar, hasOnlyReadOnly.bar) && + Objects.equals(this.foo, hasOnlyReadOnly.foo); + } + + @Override + public int hashCode() { + return Objects.hash(bar, foo); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class HasOnlyReadOnly {\n"); + + sb.append(" bar: ").append(toIndentedString(bar)).append("\n"); + sb.append(" foo: ").append(toIndentedString(foo)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/MapTest.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/MapTest.java new file mode 100644 index 000000000000..3ff73062758f --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/MapTest.java @@ -0,0 +1,234 @@ +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 java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * MapTest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class MapTest { + @JsonProperty("map_map_of_string") + @Valid + private Map> mapMapOfString = null; + + /** + * Gets or Sets inner + */ + public enum InnerEnum { + UPPER("UPPER"), + + LOWER("lower"); + + private String value; + + InnerEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static InnerEnum fromValue(String value) { + for (InnerEnum b : InnerEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("map_of_enum_string") + @Valid + private Map mapOfEnumString = null; + + @JsonProperty("direct_map") + @Valid + private Map directMap = null; + + @JsonProperty("indirect_map") + @Valid + private Map indirectMap = null; + + public MapTest mapMapOfString(Map> mapMapOfString) { + this.mapMapOfString = mapMapOfString; + return this; + } + + public MapTest putMapMapOfStringItem(String key, Map mapMapOfStringItem) { + if (this.mapMapOfString == null) { + this.mapMapOfString = new HashMap<>(); + } + this.mapMapOfString.put(key, mapMapOfStringItem); + return this; + } + + /** + * Get mapMapOfString + * @return mapMapOfString + */ + @Schema(name = "mapMapOfString", defaultValue = "") + + @Valid + + public Map> getMapMapOfString() { + return mapMapOfString; + } + + public void setMapMapOfString(Map> mapMapOfString) { + this.mapMapOfString = mapMapOfString; + } + + public MapTest mapOfEnumString(Map mapOfEnumString) { + this.mapOfEnumString = mapOfEnumString; + return this; + } + + public MapTest putMapOfEnumStringItem(String key, InnerEnum mapOfEnumStringItem) { + if (this.mapOfEnumString == null) { + this.mapOfEnumString = new HashMap<>(); + } + this.mapOfEnumString.put(key, mapOfEnumStringItem); + return this; + } + + /** + * Get mapOfEnumString + * @return mapOfEnumString + */ + @Schema(name = "mapOfEnumString", defaultValue = "") + + + public Map getMapOfEnumString() { + return mapOfEnumString; + } + + public void setMapOfEnumString(Map mapOfEnumString) { + this.mapOfEnumString = mapOfEnumString; + } + + public MapTest directMap(Map directMap) { + this.directMap = directMap; + return this; + } + + public MapTest putDirectMapItem(String key, Boolean directMapItem) { + if (this.directMap == null) { + this.directMap = new HashMap<>(); + } + this.directMap.put(key, directMapItem); + return this; + } + + /** + * Get directMap + * @return directMap + */ + @Schema(name = "directMap", defaultValue = "") + + + public Map getDirectMap() { + return directMap; + } + + public void setDirectMap(Map directMap) { + this.directMap = directMap; + } + + public MapTest indirectMap(Map indirectMap) { + this.indirectMap = indirectMap; + return this; + } + + public MapTest putIndirectMapItem(String key, Boolean indirectMapItem) { + if (this.indirectMap == null) { + this.indirectMap = new HashMap<>(); + } + this.indirectMap.put(key, indirectMapItem); + return this; + } + + /** + * Get indirectMap + * @return indirectMap + */ + @Schema(name = "indirectMap", defaultValue = "") + + + public Map getIndirectMap() { + return indirectMap; + } + + public void setIndirectMap(Map indirectMap) { + this.indirectMap = indirectMap; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MapTest mapTest = (MapTest) o; + return Objects.equals(this.mapMapOfString, mapTest.mapMapOfString) && + Objects.equals(this.mapOfEnumString, mapTest.mapOfEnumString) && + Objects.equals(this.directMap, mapTest.directMap) && + Objects.equals(this.indirectMap, mapTest.indirectMap); + } + + @Override + public int hashCode() { + return Objects.hash(mapMapOfString, mapOfEnumString, directMap, indirectMap); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MapTest {\n"); + + sb.append(" mapMapOfString: ").append(toIndentedString(mapMapOfString)).append("\n"); + sb.append(" mapOfEnumString: ").append(toIndentedString(mapOfEnumString)).append("\n"); + sb.append(" directMap: ").append(toIndentedString(directMap)).append("\n"); + sb.append(" indirectMap: ").append(toIndentedString(indirectMap)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java new file mode 100644 index 000000000000..03a7be43cc4a --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java @@ -0,0 +1,152 @@ +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 java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import org.openapitools.model.Animal; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * MixedPropertiesAndAdditionalPropertiesClass + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class MixedPropertiesAndAdditionalPropertiesClass { + @JsonProperty("uuid") + private UUID uuid; + + @JsonProperty("dateTime") + @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) + private OffsetDateTime dateTime; + + @JsonProperty("map") + @Valid + private Map map = null; + + public MixedPropertiesAndAdditionalPropertiesClass uuid(UUID uuid) { + this.uuid = uuid; + return this; + } + + /** + * Get uuid + * @return uuid + */ + @Schema(name = "uuid", defaultValue = "") + + @Valid + + public UUID getUuid() { + return uuid; + } + + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + public MixedPropertiesAndAdditionalPropertiesClass dateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + return this; + } + + /** + * Get dateTime + * @return dateTime + */ + @Schema(name = "dateTime", defaultValue = "") + + @Valid + + public OffsetDateTime getDateTime() { + return dateTime; + } + + public void setDateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + } + + public MixedPropertiesAndAdditionalPropertiesClass map(Map map) { + this.map = map; + return this; + } + + public MixedPropertiesAndAdditionalPropertiesClass putMapItem(String key, Animal mapItem) { + if (this.map == null) { + this.map = new HashMap<>(); + } + this.map.put(key, mapItem); + return this; + } + + /** + * Get map + * @return map + */ + @Schema(name = "map", defaultValue = "") + + @Valid + + public Map getMap() { + return map; + } + + public void setMap(Map map) { + this.map = map; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass = (MixedPropertiesAndAdditionalPropertiesClass) o; + return Objects.equals(this.uuid, mixedPropertiesAndAdditionalPropertiesClass.uuid) && + Objects.equals(this.dateTime, mixedPropertiesAndAdditionalPropertiesClass.dateTime) && + Objects.equals(this.map, mixedPropertiesAndAdditionalPropertiesClass.map); + } + + @Override + public int hashCode() { + return Objects.hash(uuid, dateTime, map); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MixedPropertiesAndAdditionalPropertiesClass {\n"); + + sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); + sb.append(" dateTime: ").append(toIndentedString(dateTime)).append("\n"); + sb.append(" map: ").append(toIndentedString(map)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Model200Response.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Model200Response.java new file mode 100644 index 000000000000..77bf91649b08 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Model200Response.java @@ -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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Model for testing model name starting with number + */ +@Schema(name = "200_response",description = "Model for testing model name starting with number") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Model200Response { + @JsonProperty("name") + private Integer name; + + @JsonProperty("class") + private String propertyClass; + + public Model200Response name(Integer name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + public Integer getName() { + return name; + } + + public void setName(Integer name) { + this.name = name; + } + + public Model200Response propertyClass(String propertyClass) { + this.propertyClass = propertyClass; + return this; + } + + /** + * Get propertyClass + * @return propertyClass + */ + @Schema(name = "propertyClass", defaultValue = "") + + + public String getPropertyClass() { + return propertyClass; + } + + public void setPropertyClass(String propertyClass) { + this.propertyClass = propertyClass; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Model200Response _200response = (Model200Response) o; + return Objects.equals(this.name, _200response.name) && + Objects.equals(this.propertyClass, _200response.propertyClass); + } + + @Override + public int hashCode() { + return Objects.hash(name, propertyClass); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Model200Response {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" propertyClass: ").append(toIndentedString(propertyClass)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ModelApiResponse.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ModelApiResponse.java new file mode 100644 index 000000000000..2443600df226 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ModelApiResponse.java @@ -0,0 +1,133 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ModelApiResponse + */ +@javax.annotation.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 + */ + @Schema(name = "code", defaultValue = "") + + + 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 + */ + @Schema(name = "type", defaultValue = "") + + + 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 + */ + @Schema(name = "message", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ModelReturn.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ModelReturn.java new file mode 100644 index 000000000000..0301a47e9f3e --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ModelReturn.java @@ -0,0 +1,84 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Model for testing reserved words + */ +@Schema(name = "Return",description = "Model for testing reserved words") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ModelReturn { + @JsonProperty("return") + private Integer _return; + + public ModelReturn _return(Integer _return) { + this._return = _return; + return this; + } + + /** + * Get _return + * @return _return + */ + @Schema(name = "_return", defaultValue = "") + + + public Integer getReturn() { + return _return; + } + + public void setReturn(Integer _return) { + this._return = _return; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelReturn _return = (ModelReturn) o; + return Objects.equals(this._return, _return._return); + } + + @Override + public int hashCode() { + return Objects.hash(_return); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelReturn {\n"); + + sb.append(" _return: ").append(toIndentedString(_return)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Name.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Name.java new file mode 100644 index 000000000000..62a16f80ee07 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Name.java @@ -0,0 +1,160 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Model for testing model name same as property name + */ +@Schema(name = "Name",description = "Model for testing model name same as property name") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Name { + @JsonProperty("name") + private Integer name; + + @JsonProperty("snake_case") + private Integer snakeCase; + + @JsonProperty("property") + private String property; + + @JsonProperty("123Number") + private Integer _123number; + + public Name name(Integer name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", required = true, defaultValue = "") + @NotNull + + + public Integer getName() { + return name; + } + + public void setName(Integer name) { + this.name = name; + } + + public Name snakeCase(Integer snakeCase) { + this.snakeCase = snakeCase; + return this; + } + + /** + * Get snakeCase + * @return snakeCase + */ + @Schema(name = "snakeCase", readOnly = true, defaultValue = "") + + + public Integer getSnakeCase() { + return snakeCase; + } + + public void setSnakeCase(Integer snakeCase) { + this.snakeCase = snakeCase; + } + + public Name property(String property) { + this.property = property; + return this; + } + + /** + * Get property + * @return property + */ + @Schema(name = "property", defaultValue = "") + + + public String getProperty() { + return property; + } + + public void setProperty(String property) { + this.property = property; + } + + public Name _123number(Integer _123number) { + this._123number = _123number; + return this; + } + + /** + * Get _123number + * @return _123number + */ + @Schema(name = "_123number", readOnly = true, defaultValue = "") + + + public Integer get123number() { + return _123number; + } + + public void set123number(Integer _123number) { + this._123number = _123number; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Name name = (Name) o; + return Objects.equals(this.name, name.name) && + Objects.equals(this.snakeCase, name.snakeCase) && + Objects.equals(this.property, name.property) && + Objects.equals(this._123number, name._123number); + } + + @Override + public int hashCode() { + return Objects.hash(name, snakeCase, property, _123number); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Name {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n"); + sb.append(" property: ").append(toIndentedString(property)).append("\n"); + sb.append(" _123number: ").append(toIndentedString(_123number)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/NumberOnly.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/NumberOnly.java new file mode 100644 index 000000000000..521fad80d5a7 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/NumberOnly.java @@ -0,0 +1,85 @@ +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 java.math.BigDecimal; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * NumberOnly + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class NumberOnly { + @JsonProperty("JustNumber") + private BigDecimal justNumber; + + public NumberOnly justNumber(BigDecimal justNumber) { + this.justNumber = justNumber; + return this; + } + + /** + * Get justNumber + * @return justNumber + */ + @Schema(name = "justNumber", defaultValue = "") + + @Valid + + public BigDecimal getJustNumber() { + return justNumber; + } + + public void setJustNumber(BigDecimal justNumber) { + this.justNumber = justNumber; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NumberOnly numberOnly = (NumberOnly) o; + return Objects.equals(this.justNumber, numberOnly.justNumber); + } + + @Override + public int hashCode() { + return Objects.hash(justNumber); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NumberOnly {\n"); + + sb.append(" justNumber: ").append(toIndentedString(justNumber)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Order.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Order.java new file mode 100644 index 000000000000..05071bdfe2bf --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Order.java @@ -0,0 +1,249 @@ +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 java.time.OffsetDateTime; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Order + */ +@javax.annotation.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") + @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "petId", defaultValue = "") + + + 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 + */ + @Schema(name = "quantity", defaultValue = "") + + + 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 + */ + @Schema(name = "shipDate", defaultValue = "") + + @Valid + + 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 + */ + @Schema(name = "status", defaultValue = "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 + */ + @Schema(name = "complete", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/OuterComposite.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/OuterComposite.java new file mode 100644 index 000000000000..a721a3dde6a0 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/OuterComposite.java @@ -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 java.math.BigDecimal; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * OuterComposite + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class OuterComposite { + @JsonProperty("my_number") + private BigDecimal myNumber; + + @JsonProperty("my_string") + private String myString; + + @JsonProperty("my_boolean") + private Boolean myBoolean; + + public OuterComposite myNumber(BigDecimal myNumber) { + this.myNumber = myNumber; + return this; + } + + /** + * Get myNumber + * @return myNumber + */ + @Schema(name = "myNumber", defaultValue = "") + + @Valid + + public BigDecimal getMyNumber() { + return myNumber; + } + + public void setMyNumber(BigDecimal myNumber) { + this.myNumber = myNumber; + } + + public OuterComposite myString(String myString) { + this.myString = myString; + return this; + } + + /** + * Get myString + * @return myString + */ + @Schema(name = "myString", defaultValue = "") + + + public String getMyString() { + return myString; + } + + public void setMyString(String myString) { + this.myString = myString; + } + + public OuterComposite myBoolean(Boolean myBoolean) { + this.myBoolean = myBoolean; + return this; + } + + /** + * Get myBoolean + * @return myBoolean + */ + @Schema(name = "myBoolean", defaultValue = "") + + + public Boolean getMyBoolean() { + return myBoolean; + } + + public void setMyBoolean(Boolean myBoolean) { + this.myBoolean = myBoolean; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OuterComposite outerComposite = (OuterComposite) o; + return Objects.equals(this.myNumber, outerComposite.myNumber) && + Objects.equals(this.myString, outerComposite.myString) && + Objects.equals(this.myBoolean, outerComposite.myBoolean); + } + + @Override + public int hashCode() { + return Objects.hash(myNumber, myString, myBoolean); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OuterComposite {\n"); + + sb.append(" myNumber: ").append(toIndentedString(myNumber)).append("\n"); + sb.append(" myString: ").append(toIndentedString(myString)).append("\n"); + sb.append(" myBoolean: ").append(toIndentedString(myBoolean)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/OuterEnum.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/OuterEnum.java new file mode 100644 index 000000000000..ba0cca8a5e81 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/OuterEnum.java @@ -0,0 +1,55 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Gets or Sets OuterEnum + */ +public enum OuterEnum { + + PLACED("placed"), + + APPROVED("approved"), + + DELIVERED("delivered"); + + private String value; + + OuterEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static OuterEnum fromValue(String value) { + for (OuterEnum b : OuterEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Pet.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Pet.java new file mode 100644 index 000000000000..988eb317134d --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Pet.java @@ -0,0 +1,273 @@ +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 com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +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 io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Pet + */ +@javax.annotation.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 Set photoUrls = new LinkedHashSet<>(); + + @JsonProperty("tags") + @Valid + private List 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; + + public Pet id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "category", defaultValue = "") + + @Valid + + 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 + */ + @Schema(name = "name", example = "doggie", required = true, defaultValue = "") + @NotNull + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Pet photoUrls(Set photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + public Pet addPhotoUrlsItem(String photoUrlsItem) { + this.photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get photoUrls + * @return photoUrls + */ + @Schema(name = "photoUrls", required = true, defaultValue = "") + @NotNull + + + public Set getPhotoUrls() { + return photoUrls; + } + + @JsonDeserialize(as = LinkedHashSet.class) + public void setPhotoUrls(Set photoUrls) { + this.photoUrls = photoUrls; + } + + public Pet tags(List 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 + */ + @Schema(name = "tags", defaultValue = "") + + @Valid + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * pet status in the store + * @return status + */ + @Schema(name = "status", defaultValue = "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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ReadOnlyFirst.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ReadOnlyFirst.java new file mode 100644 index 000000000000..1c51770a8e66 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ReadOnlyFirst.java @@ -0,0 +1,108 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ReadOnlyFirst + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ReadOnlyFirst { + @JsonProperty("bar") + private String bar; + + @JsonProperty("baz") + private String baz; + + public ReadOnlyFirst bar(String bar) { + this.bar = bar; + return this; + } + + /** + * Get bar + * @return bar + */ + @Schema(name = "bar", readOnly = true, defaultValue = "") + + + public String getBar() { + return bar; + } + + public void setBar(String bar) { + this.bar = bar; + } + + public ReadOnlyFirst baz(String baz) { + this.baz = baz; + return this; + } + + /** + * Get baz + * @return baz + */ + @Schema(name = "baz", defaultValue = "") + + + public String getBaz() { + return baz; + } + + public void setBaz(String baz) { + this.baz = baz; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReadOnlyFirst readOnlyFirst = (ReadOnlyFirst) o; + return Objects.equals(this.bar, readOnlyFirst.bar) && + Objects.equals(this.baz, readOnlyFirst.baz); + } + + @Override + public int hashCode() { + return Objects.hash(bar, baz); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ReadOnlyFirst {\n"); + + sb.append(" bar: ").append(toIndentedString(bar)).append("\n"); + sb.append(" baz: ").append(toIndentedString(baz)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/SpecialModelName.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/SpecialModelName.java new file mode 100644 index 000000000000..75f4be4e9f8f --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/SpecialModelName.java @@ -0,0 +1,83 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * SpecialModelName + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class SpecialModelName { + @JsonProperty("$special[property.name]") + private Long $specialPropertyName; + + public SpecialModelName $specialPropertyName(Long $specialPropertyName) { + this.$specialPropertyName = $specialPropertyName; + return this; + } + + /** + * Get $specialPropertyName + * @return $specialPropertyName + */ + @Schema(name = "$specialPropertyName", defaultValue = "") + + + public Long get$SpecialPropertyName() { + return $specialPropertyName; + } + + public void set$SpecialPropertyName(Long $specialPropertyName) { + this.$specialPropertyName = $specialPropertyName; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SpecialModelName $specialModelName = (SpecialModelName) o; + return Objects.equals(this.$specialPropertyName, $specialModelName.$specialPropertyName); + } + + @Override + public int hashCode() { + return Objects.hash($specialPropertyName); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SpecialModelName {\n"); + + sb.append(" $specialPropertyName: ").append(toIndentedString($specialPropertyName)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Tag.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Tag.java new file mode 100644 index 000000000000..8722df999bfc --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Tag.java @@ -0,0 +1,108 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Tag + */ +@javax.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "name", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/TypeHolderDefault.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/TypeHolderDefault.java new file mode 100644 index 000000000000..19e9bf310f76 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/TypeHolderDefault.java @@ -0,0 +1,198 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * TypeHolderDefault + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class TypeHolderDefault { + @JsonProperty("string_item") + private String stringItem = "what"; + + @JsonProperty("number_item") + private BigDecimal numberItem; + + @JsonProperty("integer_item") + private Integer integerItem; + + @JsonProperty("bool_item") + private Boolean boolItem = true; + + @JsonProperty("array_item") + @Valid + private List arrayItem = new ArrayList<>(); + + public TypeHolderDefault stringItem(String stringItem) { + this.stringItem = stringItem; + return this; + } + + /** + * Get stringItem + * @return stringItem + */ + @Schema(name = "stringItem", required = true, defaultValue = "") + @NotNull + + + public String getStringItem() { + return stringItem; + } + + public void setStringItem(String stringItem) { + this.stringItem = stringItem; + } + + public TypeHolderDefault numberItem(BigDecimal numberItem) { + this.numberItem = numberItem; + return this; + } + + /** + * Get numberItem + * @return numberItem + */ + @Schema(name = "numberItem", required = true, defaultValue = "") + @NotNull + + @Valid + + public BigDecimal getNumberItem() { + return numberItem; + } + + public void setNumberItem(BigDecimal numberItem) { + this.numberItem = numberItem; + } + + public TypeHolderDefault integerItem(Integer integerItem) { + this.integerItem = integerItem; + return this; + } + + /** + * Get integerItem + * @return integerItem + */ + @Schema(name = "integerItem", required = true, defaultValue = "") + @NotNull + + + public Integer getIntegerItem() { + return integerItem; + } + + public void setIntegerItem(Integer integerItem) { + this.integerItem = integerItem; + } + + public TypeHolderDefault boolItem(Boolean boolItem) { + this.boolItem = boolItem; + return this; + } + + /** + * Get boolItem + * @return boolItem + */ + @Schema(name = "boolItem", required = true, defaultValue = "") + @NotNull + + + public Boolean getBoolItem() { + return boolItem; + } + + public void setBoolItem(Boolean boolItem) { + this.boolItem = boolItem; + } + + public TypeHolderDefault arrayItem(List arrayItem) { + this.arrayItem = arrayItem; + return this; + } + + public TypeHolderDefault addArrayItemItem(Integer arrayItemItem) { + this.arrayItem.add(arrayItemItem); + return this; + } + + /** + * Get arrayItem + * @return arrayItem + */ + @Schema(name = "arrayItem", required = true, defaultValue = "") + @NotNull + + + public List getArrayItem() { + return arrayItem; + } + + public void setArrayItem(List arrayItem) { + this.arrayItem = arrayItem; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TypeHolderDefault typeHolderDefault = (TypeHolderDefault) o; + return Objects.equals(this.stringItem, typeHolderDefault.stringItem) && + Objects.equals(this.numberItem, typeHolderDefault.numberItem) && + Objects.equals(this.integerItem, typeHolderDefault.integerItem) && + Objects.equals(this.boolItem, typeHolderDefault.boolItem) && + Objects.equals(this.arrayItem, typeHolderDefault.arrayItem); + } + + @Override + public int hashCode() { + return Objects.hash(stringItem, numberItem, integerItem, boolItem, arrayItem); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TypeHolderDefault {\n"); + + sb.append(" stringItem: ").append(toIndentedString(stringItem)).append("\n"); + sb.append(" numberItem: ").append(toIndentedString(numberItem)).append("\n"); + sb.append(" integerItem: ").append(toIndentedString(integerItem)).append("\n"); + sb.append(" boolItem: ").append(toIndentedString(boolItem)).append("\n"); + sb.append(" arrayItem: ").append(toIndentedString(arrayItem)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/TypeHolderExample.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/TypeHolderExample.java new file mode 100644 index 000000000000..c9a3762bc74b --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/TypeHolderExample.java @@ -0,0 +1,224 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * TypeHolderExample + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class TypeHolderExample { + @JsonProperty("string_item") + private String stringItem; + + @JsonProperty("number_item") + private BigDecimal numberItem; + + @JsonProperty("float_item") + private Float floatItem; + + @JsonProperty("integer_item") + private Integer integerItem; + + @JsonProperty("bool_item") + private Boolean boolItem; + + @JsonProperty("array_item") + @Valid + private List arrayItem = new ArrayList<>(); + + public TypeHolderExample stringItem(String stringItem) { + this.stringItem = stringItem; + return this; + } + + /** + * Get stringItem + * @return stringItem + */ + @Schema(name = "stringItem", example = "what", required = true, defaultValue = "") + @NotNull + + + public String getStringItem() { + return stringItem; + } + + public void setStringItem(String stringItem) { + this.stringItem = stringItem; + } + + public TypeHolderExample numberItem(BigDecimal numberItem) { + this.numberItem = numberItem; + return this; + } + + /** + * Get numberItem + * @return numberItem + */ + @Schema(name = "numberItem", example = "1.234", required = true, defaultValue = "") + @NotNull + + @Valid + + public BigDecimal getNumberItem() { + return numberItem; + } + + public void setNumberItem(BigDecimal numberItem) { + this.numberItem = numberItem; + } + + public TypeHolderExample floatItem(Float floatItem) { + this.floatItem = floatItem; + return this; + } + + /** + * Get floatItem + * @return floatItem + */ + @Schema(name = "floatItem", example = "1.234", required = true, defaultValue = "") + @NotNull + + + public Float getFloatItem() { + return floatItem; + } + + public void setFloatItem(Float floatItem) { + this.floatItem = floatItem; + } + + public TypeHolderExample integerItem(Integer integerItem) { + this.integerItem = integerItem; + return this; + } + + /** + * Get integerItem + * @return integerItem + */ + @Schema(name = "integerItem", example = "-2", required = true, defaultValue = "") + @NotNull + + + public Integer getIntegerItem() { + return integerItem; + } + + public void setIntegerItem(Integer integerItem) { + this.integerItem = integerItem; + } + + public TypeHolderExample boolItem(Boolean boolItem) { + this.boolItem = boolItem; + return this; + } + + /** + * Get boolItem + * @return boolItem + */ + @Schema(name = "boolItem", example = "true", required = true, defaultValue = "") + @NotNull + + + public Boolean getBoolItem() { + return boolItem; + } + + public void setBoolItem(Boolean boolItem) { + this.boolItem = boolItem; + } + + public TypeHolderExample arrayItem(List arrayItem) { + this.arrayItem = arrayItem; + return this; + } + + public TypeHolderExample addArrayItemItem(Integer arrayItemItem) { + this.arrayItem.add(arrayItemItem); + return this; + } + + /** + * Get arrayItem + * @return arrayItem + */ + @Schema(name = "arrayItem", example = "[0, 1, 2, 3]", required = true, defaultValue = "") + @NotNull + + + public List getArrayItem() { + return arrayItem; + } + + public void setArrayItem(List arrayItem) { + this.arrayItem = arrayItem; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TypeHolderExample typeHolderExample = (TypeHolderExample) o; + return Objects.equals(this.stringItem, typeHolderExample.stringItem) && + Objects.equals(this.numberItem, typeHolderExample.numberItem) && + Objects.equals(this.floatItem, typeHolderExample.floatItem) && + Objects.equals(this.integerItem, typeHolderExample.integerItem) && + Objects.equals(this.boolItem, typeHolderExample.boolItem) && + Objects.equals(this.arrayItem, typeHolderExample.arrayItem); + } + + @Override + public int hashCode() { + return Objects.hash(stringItem, numberItem, floatItem, integerItem, boolItem, arrayItem); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TypeHolderExample {\n"); + + sb.append(" stringItem: ").append(toIndentedString(stringItem)).append("\n"); + sb.append(" numberItem: ").append(toIndentedString(numberItem)).append("\n"); + sb.append(" floatItem: ").append(toIndentedString(floatItem)).append("\n"); + sb.append(" integerItem: ").append(toIndentedString(integerItem)).append("\n"); + sb.append(" boolItem: ").append(toIndentedString(boolItem)).append("\n"); + sb.append(" arrayItem: ").append(toIndentedString(arrayItem)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/User.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/User.java new file mode 100644 index 000000000000..83152a155535 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/User.java @@ -0,0 +1,258 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * User + */ +@javax.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "username", defaultValue = "") + + + 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 + */ + @Schema(name = "firstName", defaultValue = "") + + + 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 + */ + @Schema(name = "lastName", defaultValue = "") + + + 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 + */ + @Schema(name = "email", defaultValue = "") + + + 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 + */ + @Schema(name = "password", defaultValue = "") + + + 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 + */ + @Schema(name = "phone", defaultValue = "") + + + 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 + */ + @Schema(name = "userStatus", defaultValue = "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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/XmlItem.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/XmlItem.java new file mode 100644 index 000000000000..59a183db0f62 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/XmlItem.java @@ -0,0 +1,872 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * XmlItem + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class XmlItem { + @JsonProperty("attribute_string") + private String attributeString; + + @JsonProperty("attribute_number") + private BigDecimal attributeNumber; + + @JsonProperty("attribute_integer") + private Integer attributeInteger; + + @JsonProperty("attribute_boolean") + private Boolean attributeBoolean; + + @JsonProperty("wrapped_array") + @Valid + private List wrappedArray = null; + + @JsonProperty("name_string") + private String nameString; + + @JsonProperty("name_number") + private BigDecimal nameNumber; + + @JsonProperty("name_integer") + private Integer nameInteger; + + @JsonProperty("name_boolean") + private Boolean nameBoolean; + + @JsonProperty("name_array") + @Valid + private List nameArray = null; + + @JsonProperty("name_wrapped_array") + @Valid + private List nameWrappedArray = null; + + @JsonProperty("prefix_string") + private String prefixString; + + @JsonProperty("prefix_number") + private BigDecimal prefixNumber; + + @JsonProperty("prefix_integer") + private Integer prefixInteger; + + @JsonProperty("prefix_boolean") + private Boolean prefixBoolean; + + @JsonProperty("prefix_array") + @Valid + private List prefixArray = null; + + @JsonProperty("prefix_wrapped_array") + @Valid + private List prefixWrappedArray = null; + + @JsonProperty("namespace_string") + private String namespaceString; + + @JsonProperty("namespace_number") + private BigDecimal namespaceNumber; + + @JsonProperty("namespace_integer") + private Integer namespaceInteger; + + @JsonProperty("namespace_boolean") + private Boolean namespaceBoolean; + + @JsonProperty("namespace_array") + @Valid + private List namespaceArray = null; + + @JsonProperty("namespace_wrapped_array") + @Valid + private List namespaceWrappedArray = null; + + @JsonProperty("prefix_ns_string") + private String prefixNsString; + + @JsonProperty("prefix_ns_number") + private BigDecimal prefixNsNumber; + + @JsonProperty("prefix_ns_integer") + private Integer prefixNsInteger; + + @JsonProperty("prefix_ns_boolean") + private Boolean prefixNsBoolean; + + @JsonProperty("prefix_ns_array") + @Valid + private List prefixNsArray = null; + + @JsonProperty("prefix_ns_wrapped_array") + @Valid + private List prefixNsWrappedArray = null; + + public XmlItem attributeString(String attributeString) { + this.attributeString = attributeString; + return this; + } + + /** + * Get attributeString + * @return attributeString + */ + @Schema(name = "attributeString", example = "string", defaultValue = "") + + + public String getAttributeString() { + return attributeString; + } + + public void setAttributeString(String attributeString) { + this.attributeString = attributeString; + } + + public XmlItem attributeNumber(BigDecimal attributeNumber) { + this.attributeNumber = attributeNumber; + return this; + } + + /** + * Get attributeNumber + * @return attributeNumber + */ + @Schema(name = "attributeNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getAttributeNumber() { + return attributeNumber; + } + + public void setAttributeNumber(BigDecimal attributeNumber) { + this.attributeNumber = attributeNumber; + } + + public XmlItem attributeInteger(Integer attributeInteger) { + this.attributeInteger = attributeInteger; + return this; + } + + /** + * Get attributeInteger + * @return attributeInteger + */ + @Schema(name = "attributeInteger", example = "-2", defaultValue = "") + + + public Integer getAttributeInteger() { + return attributeInteger; + } + + public void setAttributeInteger(Integer attributeInteger) { + this.attributeInteger = attributeInteger; + } + + public XmlItem attributeBoolean(Boolean attributeBoolean) { + this.attributeBoolean = attributeBoolean; + return this; + } + + /** + * Get attributeBoolean + * @return attributeBoolean + */ + @Schema(name = "attributeBoolean", example = "true", defaultValue = "") + + + public Boolean getAttributeBoolean() { + return attributeBoolean; + } + + public void setAttributeBoolean(Boolean attributeBoolean) { + this.attributeBoolean = attributeBoolean; + } + + public XmlItem wrappedArray(List wrappedArray) { + this.wrappedArray = wrappedArray; + return this; + } + + public XmlItem addWrappedArrayItem(Integer wrappedArrayItem) { + if (this.wrappedArray == null) { + this.wrappedArray = new ArrayList<>(); + } + this.wrappedArray.add(wrappedArrayItem); + return this; + } + + /** + * Get wrappedArray + * @return wrappedArray + */ + @Schema(name = "wrappedArray", defaultValue = "") + + + public List getWrappedArray() { + return wrappedArray; + } + + public void setWrappedArray(List wrappedArray) { + this.wrappedArray = wrappedArray; + } + + public XmlItem nameString(String nameString) { + this.nameString = nameString; + return this; + } + + /** + * Get nameString + * @return nameString + */ + @Schema(name = "nameString", example = "string", defaultValue = "") + + + public String getNameString() { + return nameString; + } + + public void setNameString(String nameString) { + this.nameString = nameString; + } + + public XmlItem nameNumber(BigDecimal nameNumber) { + this.nameNumber = nameNumber; + return this; + } + + /** + * Get nameNumber + * @return nameNumber + */ + @Schema(name = "nameNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getNameNumber() { + return nameNumber; + } + + public void setNameNumber(BigDecimal nameNumber) { + this.nameNumber = nameNumber; + } + + public XmlItem nameInteger(Integer nameInteger) { + this.nameInteger = nameInteger; + return this; + } + + /** + * Get nameInteger + * @return nameInteger + */ + @Schema(name = "nameInteger", example = "-2", defaultValue = "") + + + public Integer getNameInteger() { + return nameInteger; + } + + public void setNameInteger(Integer nameInteger) { + this.nameInteger = nameInteger; + } + + public XmlItem nameBoolean(Boolean nameBoolean) { + this.nameBoolean = nameBoolean; + return this; + } + + /** + * Get nameBoolean + * @return nameBoolean + */ + @Schema(name = "nameBoolean", example = "true", defaultValue = "") + + + public Boolean getNameBoolean() { + return nameBoolean; + } + + public void setNameBoolean(Boolean nameBoolean) { + this.nameBoolean = nameBoolean; + } + + public XmlItem nameArray(List nameArray) { + this.nameArray = nameArray; + return this; + } + + public XmlItem addNameArrayItem(Integer nameArrayItem) { + if (this.nameArray == null) { + this.nameArray = new ArrayList<>(); + } + this.nameArray.add(nameArrayItem); + return this; + } + + /** + * Get nameArray + * @return nameArray + */ + @Schema(name = "nameArray", defaultValue = "") + + + public List getNameArray() { + return nameArray; + } + + public void setNameArray(List nameArray) { + this.nameArray = nameArray; + } + + public XmlItem nameWrappedArray(List nameWrappedArray) { + this.nameWrappedArray = nameWrappedArray; + return this; + } + + public XmlItem addNameWrappedArrayItem(Integer nameWrappedArrayItem) { + if (this.nameWrappedArray == null) { + this.nameWrappedArray = new ArrayList<>(); + } + this.nameWrappedArray.add(nameWrappedArrayItem); + return this; + } + + /** + * Get nameWrappedArray + * @return nameWrappedArray + */ + @Schema(name = "nameWrappedArray", defaultValue = "") + + + public List getNameWrappedArray() { + return nameWrappedArray; + } + + public void setNameWrappedArray(List nameWrappedArray) { + this.nameWrappedArray = nameWrappedArray; + } + + public XmlItem prefixString(String prefixString) { + this.prefixString = prefixString; + return this; + } + + /** + * Get prefixString + * @return prefixString + */ + @Schema(name = "prefixString", example = "string", defaultValue = "") + + + public String getPrefixString() { + return prefixString; + } + + public void setPrefixString(String prefixString) { + this.prefixString = prefixString; + } + + public XmlItem prefixNumber(BigDecimal prefixNumber) { + this.prefixNumber = prefixNumber; + return this; + } + + /** + * Get prefixNumber + * @return prefixNumber + */ + @Schema(name = "prefixNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getPrefixNumber() { + return prefixNumber; + } + + public void setPrefixNumber(BigDecimal prefixNumber) { + this.prefixNumber = prefixNumber; + } + + public XmlItem prefixInteger(Integer prefixInteger) { + this.prefixInteger = prefixInteger; + return this; + } + + /** + * Get prefixInteger + * @return prefixInteger + */ + @Schema(name = "prefixInteger", example = "-2", defaultValue = "") + + + public Integer getPrefixInteger() { + return prefixInteger; + } + + public void setPrefixInteger(Integer prefixInteger) { + this.prefixInteger = prefixInteger; + } + + public XmlItem prefixBoolean(Boolean prefixBoolean) { + this.prefixBoolean = prefixBoolean; + return this; + } + + /** + * Get prefixBoolean + * @return prefixBoolean + */ + @Schema(name = "prefixBoolean", example = "true", defaultValue = "") + + + public Boolean getPrefixBoolean() { + return prefixBoolean; + } + + public void setPrefixBoolean(Boolean prefixBoolean) { + this.prefixBoolean = prefixBoolean; + } + + public XmlItem prefixArray(List prefixArray) { + this.prefixArray = prefixArray; + return this; + } + + public XmlItem addPrefixArrayItem(Integer prefixArrayItem) { + if (this.prefixArray == null) { + this.prefixArray = new ArrayList<>(); + } + this.prefixArray.add(prefixArrayItem); + return this; + } + + /** + * Get prefixArray + * @return prefixArray + */ + @Schema(name = "prefixArray", defaultValue = "") + + + public List getPrefixArray() { + return prefixArray; + } + + public void setPrefixArray(List prefixArray) { + this.prefixArray = prefixArray; + } + + public XmlItem prefixWrappedArray(List prefixWrappedArray) { + this.prefixWrappedArray = prefixWrappedArray; + return this; + } + + public XmlItem addPrefixWrappedArrayItem(Integer prefixWrappedArrayItem) { + if (this.prefixWrappedArray == null) { + this.prefixWrappedArray = new ArrayList<>(); + } + this.prefixWrappedArray.add(prefixWrappedArrayItem); + return this; + } + + /** + * Get prefixWrappedArray + * @return prefixWrappedArray + */ + @Schema(name = "prefixWrappedArray", defaultValue = "") + + + public List getPrefixWrappedArray() { + return prefixWrappedArray; + } + + public void setPrefixWrappedArray(List prefixWrappedArray) { + this.prefixWrappedArray = prefixWrappedArray; + } + + public XmlItem namespaceString(String namespaceString) { + this.namespaceString = namespaceString; + return this; + } + + /** + * Get namespaceString + * @return namespaceString + */ + @Schema(name = "namespaceString", example = "string", defaultValue = "") + + + public String getNamespaceString() { + return namespaceString; + } + + public void setNamespaceString(String namespaceString) { + this.namespaceString = namespaceString; + } + + public XmlItem namespaceNumber(BigDecimal namespaceNumber) { + this.namespaceNumber = namespaceNumber; + return this; + } + + /** + * Get namespaceNumber + * @return namespaceNumber + */ + @Schema(name = "namespaceNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getNamespaceNumber() { + return namespaceNumber; + } + + public void setNamespaceNumber(BigDecimal namespaceNumber) { + this.namespaceNumber = namespaceNumber; + } + + public XmlItem namespaceInteger(Integer namespaceInteger) { + this.namespaceInteger = namespaceInteger; + return this; + } + + /** + * Get namespaceInteger + * @return namespaceInteger + */ + @Schema(name = "namespaceInteger", example = "-2", defaultValue = "") + + + public Integer getNamespaceInteger() { + return namespaceInteger; + } + + public void setNamespaceInteger(Integer namespaceInteger) { + this.namespaceInteger = namespaceInteger; + } + + public XmlItem namespaceBoolean(Boolean namespaceBoolean) { + this.namespaceBoolean = namespaceBoolean; + return this; + } + + /** + * Get namespaceBoolean + * @return namespaceBoolean + */ + @Schema(name = "namespaceBoolean", example = "true", defaultValue = "") + + + public Boolean getNamespaceBoolean() { + return namespaceBoolean; + } + + public void setNamespaceBoolean(Boolean namespaceBoolean) { + this.namespaceBoolean = namespaceBoolean; + } + + public XmlItem namespaceArray(List namespaceArray) { + this.namespaceArray = namespaceArray; + return this; + } + + public XmlItem addNamespaceArrayItem(Integer namespaceArrayItem) { + if (this.namespaceArray == null) { + this.namespaceArray = new ArrayList<>(); + } + this.namespaceArray.add(namespaceArrayItem); + return this; + } + + /** + * Get namespaceArray + * @return namespaceArray + */ + @Schema(name = "namespaceArray", defaultValue = "") + + + public List getNamespaceArray() { + return namespaceArray; + } + + public void setNamespaceArray(List namespaceArray) { + this.namespaceArray = namespaceArray; + } + + public XmlItem namespaceWrappedArray(List namespaceWrappedArray) { + this.namespaceWrappedArray = namespaceWrappedArray; + return this; + } + + public XmlItem addNamespaceWrappedArrayItem(Integer namespaceWrappedArrayItem) { + if (this.namespaceWrappedArray == null) { + this.namespaceWrappedArray = new ArrayList<>(); + } + this.namespaceWrappedArray.add(namespaceWrappedArrayItem); + return this; + } + + /** + * Get namespaceWrappedArray + * @return namespaceWrappedArray + */ + @Schema(name = "namespaceWrappedArray", defaultValue = "") + + + public List getNamespaceWrappedArray() { + return namespaceWrappedArray; + } + + public void setNamespaceWrappedArray(List namespaceWrappedArray) { + this.namespaceWrappedArray = namespaceWrappedArray; + } + + public XmlItem prefixNsString(String prefixNsString) { + this.prefixNsString = prefixNsString; + return this; + } + + /** + * Get prefixNsString + * @return prefixNsString + */ + @Schema(name = "prefixNsString", example = "string", defaultValue = "") + + + public String getPrefixNsString() { + return prefixNsString; + } + + public void setPrefixNsString(String prefixNsString) { + this.prefixNsString = prefixNsString; + } + + public XmlItem prefixNsNumber(BigDecimal prefixNsNumber) { + this.prefixNsNumber = prefixNsNumber; + return this; + } + + /** + * Get prefixNsNumber + * @return prefixNsNumber + */ + @Schema(name = "prefixNsNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getPrefixNsNumber() { + return prefixNsNumber; + } + + public void setPrefixNsNumber(BigDecimal prefixNsNumber) { + this.prefixNsNumber = prefixNsNumber; + } + + public XmlItem prefixNsInteger(Integer prefixNsInteger) { + this.prefixNsInteger = prefixNsInteger; + return this; + } + + /** + * Get prefixNsInteger + * @return prefixNsInteger + */ + @Schema(name = "prefixNsInteger", example = "-2", defaultValue = "") + + + public Integer getPrefixNsInteger() { + return prefixNsInteger; + } + + public void setPrefixNsInteger(Integer prefixNsInteger) { + this.prefixNsInteger = prefixNsInteger; + } + + public XmlItem prefixNsBoolean(Boolean prefixNsBoolean) { + this.prefixNsBoolean = prefixNsBoolean; + return this; + } + + /** + * Get prefixNsBoolean + * @return prefixNsBoolean + */ + @Schema(name = "prefixNsBoolean", example = "true", defaultValue = "") + + + public Boolean getPrefixNsBoolean() { + return prefixNsBoolean; + } + + public void setPrefixNsBoolean(Boolean prefixNsBoolean) { + this.prefixNsBoolean = prefixNsBoolean; + } + + public XmlItem prefixNsArray(List prefixNsArray) { + this.prefixNsArray = prefixNsArray; + return this; + } + + public XmlItem addPrefixNsArrayItem(Integer prefixNsArrayItem) { + if (this.prefixNsArray == null) { + this.prefixNsArray = new ArrayList<>(); + } + this.prefixNsArray.add(prefixNsArrayItem); + return this; + } + + /** + * Get prefixNsArray + * @return prefixNsArray + */ + @Schema(name = "prefixNsArray", defaultValue = "") + + + public List getPrefixNsArray() { + return prefixNsArray; + } + + public void setPrefixNsArray(List prefixNsArray) { + this.prefixNsArray = prefixNsArray; + } + + public XmlItem prefixNsWrappedArray(List prefixNsWrappedArray) { + this.prefixNsWrappedArray = prefixNsWrappedArray; + return this; + } + + public XmlItem addPrefixNsWrappedArrayItem(Integer prefixNsWrappedArrayItem) { + if (this.prefixNsWrappedArray == null) { + this.prefixNsWrappedArray = new ArrayList<>(); + } + this.prefixNsWrappedArray.add(prefixNsWrappedArrayItem); + return this; + } + + /** + * Get prefixNsWrappedArray + * @return prefixNsWrappedArray + */ + @Schema(name = "prefixNsWrappedArray", defaultValue = "") + + + public List getPrefixNsWrappedArray() { + return prefixNsWrappedArray; + } + + public void setPrefixNsWrappedArray(List prefixNsWrappedArray) { + this.prefixNsWrappedArray = prefixNsWrappedArray; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + XmlItem xmlItem = (XmlItem) o; + return Objects.equals(this.attributeString, xmlItem.attributeString) && + Objects.equals(this.attributeNumber, xmlItem.attributeNumber) && + Objects.equals(this.attributeInteger, xmlItem.attributeInteger) && + Objects.equals(this.attributeBoolean, xmlItem.attributeBoolean) && + Objects.equals(this.wrappedArray, xmlItem.wrappedArray) && + Objects.equals(this.nameString, xmlItem.nameString) && + Objects.equals(this.nameNumber, xmlItem.nameNumber) && + Objects.equals(this.nameInteger, xmlItem.nameInteger) && + Objects.equals(this.nameBoolean, xmlItem.nameBoolean) && + Objects.equals(this.nameArray, xmlItem.nameArray) && + Objects.equals(this.nameWrappedArray, xmlItem.nameWrappedArray) && + Objects.equals(this.prefixString, xmlItem.prefixString) && + Objects.equals(this.prefixNumber, xmlItem.prefixNumber) && + Objects.equals(this.prefixInteger, xmlItem.prefixInteger) && + Objects.equals(this.prefixBoolean, xmlItem.prefixBoolean) && + Objects.equals(this.prefixArray, xmlItem.prefixArray) && + Objects.equals(this.prefixWrappedArray, xmlItem.prefixWrappedArray) && + Objects.equals(this.namespaceString, xmlItem.namespaceString) && + Objects.equals(this.namespaceNumber, xmlItem.namespaceNumber) && + Objects.equals(this.namespaceInteger, xmlItem.namespaceInteger) && + Objects.equals(this.namespaceBoolean, xmlItem.namespaceBoolean) && + Objects.equals(this.namespaceArray, xmlItem.namespaceArray) && + Objects.equals(this.namespaceWrappedArray, xmlItem.namespaceWrappedArray) && + Objects.equals(this.prefixNsString, xmlItem.prefixNsString) && + Objects.equals(this.prefixNsNumber, xmlItem.prefixNsNumber) && + Objects.equals(this.prefixNsInteger, xmlItem.prefixNsInteger) && + Objects.equals(this.prefixNsBoolean, xmlItem.prefixNsBoolean) && + Objects.equals(this.prefixNsArray, xmlItem.prefixNsArray) && + Objects.equals(this.prefixNsWrappedArray, xmlItem.prefixNsWrappedArray); + } + + @Override + public int hashCode() { + return Objects.hash(attributeString, attributeNumber, attributeInteger, attributeBoolean, wrappedArray, nameString, nameNumber, nameInteger, nameBoolean, nameArray, nameWrappedArray, prefixString, prefixNumber, prefixInteger, prefixBoolean, prefixArray, prefixWrappedArray, namespaceString, namespaceNumber, namespaceInteger, namespaceBoolean, namespaceArray, namespaceWrappedArray, prefixNsString, prefixNsNumber, prefixNsInteger, prefixNsBoolean, prefixNsArray, prefixNsWrappedArray); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class XmlItem {\n"); + + sb.append(" attributeString: ").append(toIndentedString(attributeString)).append("\n"); + sb.append(" attributeNumber: ").append(toIndentedString(attributeNumber)).append("\n"); + sb.append(" attributeInteger: ").append(toIndentedString(attributeInteger)).append("\n"); + sb.append(" attributeBoolean: ").append(toIndentedString(attributeBoolean)).append("\n"); + sb.append(" wrappedArray: ").append(toIndentedString(wrappedArray)).append("\n"); + sb.append(" nameString: ").append(toIndentedString(nameString)).append("\n"); + sb.append(" nameNumber: ").append(toIndentedString(nameNumber)).append("\n"); + sb.append(" nameInteger: ").append(toIndentedString(nameInteger)).append("\n"); + sb.append(" nameBoolean: ").append(toIndentedString(nameBoolean)).append("\n"); + sb.append(" nameArray: ").append(toIndentedString(nameArray)).append("\n"); + sb.append(" nameWrappedArray: ").append(toIndentedString(nameWrappedArray)).append("\n"); + sb.append(" prefixString: ").append(toIndentedString(prefixString)).append("\n"); + sb.append(" prefixNumber: ").append(toIndentedString(prefixNumber)).append("\n"); + sb.append(" prefixInteger: ").append(toIndentedString(prefixInteger)).append("\n"); + sb.append(" prefixBoolean: ").append(toIndentedString(prefixBoolean)).append("\n"); + sb.append(" prefixArray: ").append(toIndentedString(prefixArray)).append("\n"); + sb.append(" prefixWrappedArray: ").append(toIndentedString(prefixWrappedArray)).append("\n"); + sb.append(" namespaceString: ").append(toIndentedString(namespaceString)).append("\n"); + sb.append(" namespaceNumber: ").append(toIndentedString(namespaceNumber)).append("\n"); + sb.append(" namespaceInteger: ").append(toIndentedString(namespaceInteger)).append("\n"); + sb.append(" namespaceBoolean: ").append(toIndentedString(namespaceBoolean)).append("\n"); + sb.append(" namespaceArray: ").append(toIndentedString(namespaceArray)).append("\n"); + sb.append(" namespaceWrappedArray: ").append(toIndentedString(namespaceWrappedArray)).append("\n"); + sb.append(" prefixNsString: ").append(toIndentedString(prefixNsString)).append("\n"); + sb.append(" prefixNsNumber: ").append(toIndentedString(prefixNsNumber)).append("\n"); + sb.append(" prefixNsInteger: ").append(toIndentedString(prefixNsInteger)).append("\n"); + sb.append(" prefixNsBoolean: ").append(toIndentedString(prefixNsBoolean)).append("\n"); + sb.append(" prefixNsArray: ").append(toIndentedString(prefixNsArray)).append("\n"); + sb.append(" prefixNsWrappedArray: ").append(toIndentedString(prefixNsWrappedArray)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/resources/application.properties b/samples/openapi3/server/petstore/springboot-delegate/src/main/resources/application.properties new file mode 100644 index 000000000000..9d06609db665 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/resources/application.properties @@ -0,0 +1,3 @@ +server.port=80 +spring.jackson.date-format=org.openapitools.RFC3339DateFormat +spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/resources/openapi.yaml b/samples/openapi3/server/petstore/springboot-delegate/src/main/resources/openapi.yaml new file mode 100644 index 000000000000..d6386dc39bf4 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/resources/openapi.yaml @@ -0,0 +1,2264 @@ +openapi: 3.0.1 +info: + description: 'This spec is mainly for testing Petstore server and contains fake + endpoints, models. Please do not use this for any other purpose. Special characters: + " \' + license: + name: Apache-2.0 + url: https://www.apache.org/licenses/LICENSE-2.0.html + title: OpenAPI Petstore + version: 1.0.0 +servers: +- url: http://petstore.swagger.io:80/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: + operationId: addPet + requestBody: + 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 + responses: + "200": + content: {} + description: successful operation + "405": + content: {} + description: Invalid input + security: + - petstore_auth: + - write:pets + - read:pets + summary: Add a new pet to the store + tags: + - pet + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: pet + put: + operationId: updatePet + requestBody: + 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 + responses: + "200": + content: {} + description: successful operation + "400": + content: {} + description: Invalid ID supplied + "404": + content: {} + description: Pet not found + "405": + content: {} + description: Validation exception + security: + - petstore_auth: + - write:pets + - read:pets + summary: Update an existing pet + tags: + - pet + x-codegen-request-body-name: body + x-contentType: 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: + - 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": + content: {} + description: Invalid status value + security: + - petstore_auth: + - write:pets + - 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 + uniqueItems: true + style: form + responses: + "200": + content: + application/xml: + schema: + items: + $ref: '#/components/schemas/Pet' + type: array + uniqueItems: true + application/json: + schema: + items: + $ref: '#/components/schemas/Pet' + type: array + uniqueItems: true + description: successful operation + "400": + content: {} + description: Invalid tag value + security: + - petstore_auth: + - write:pets + - read:pets + summary: Finds Pets by tags + tags: + - pet + x-accepts: application/json + x-tags: + - tag: pet + /pet/{petId}: + delete: + operationId: deletePet + parameters: + - in: header + name: api_key + schema: + type: string + - description: Pet id to delete + in: path + name: petId + required: true + schema: + format: int64 + type: integer + responses: + "200": + content: {} + description: successful operation + "400": + content: {} + 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 + in: path + name: petId + required: true + schema: + format: int64 + type: integer + responses: + "200": + content: + application/xml: + schema: + $ref: '#/components/schemas/Pet' + application/json: + schema: + $ref: '#/components/schemas/Pet' + description: successful operation + "400": + content: {} + description: Invalid ID supplied + "404": + content: {} + description: Pet not found + security: + - api_key: [] + summary: Find pet by ID + tags: + - pet + x-accepts: application/json + x-tags: + - tag: pet + post: + operationId: updatePetWithForm + parameters: + - description: ID of pet that needs to be updated + in: path + name: petId + required: true + schema: + format: int64 + type: integer + requestBody: + content: + application/x-www-form-urlencoded: + schema: + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string + responses: + "405": + content: {} + description: Invalid input + security: + - petstore_auth: + - write:pets + - read:pets + summary: Updates a pet in the store with form data + tags: + - pet + x-contentType: application/x-www-form-urlencoded + x-accepts: application/json + x-tags: + - tag: pet + /pet/{petId}/uploadImage: + post: + operationId: uploadFile + parameters: + - description: ID of pet to update + in: path + name: petId + required: true + schema: + format: int64 + type: integer + requestBody: + content: + multipart/form-data: + schema: + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + format: binary + type: string + 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-contentType: 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: + operationId: placeOrder + requestBody: + content: + '*/*': + 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": + content: {} + description: Invalid Order + summary: Place an order for a pet + tags: + - store + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: application/json + x-tags: + - tag: store + /store/order/{order_id}: + 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 + in: path + name: order_id + required: true + schema: + type: string + responses: + "400": + content: {} + description: Invalid ID supplied + "404": + content: {} + 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 generated exceptions + operationId: getOrderById + parameters: + - description: ID of pet that needs to be fetched + in: path + name: order_id + required: true + schema: + format: int64 + maximum: 5 + minimum: 1 + type: integer + responses: + "200": + content: + application/xml: + schema: + $ref: '#/components/schemas/Order' + application/json: + schema: + $ref: '#/components/schemas/Order' + description: successful operation + "400": + content: {} + description: Invalid ID supplied + "404": + content: {} + 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: + '*/*': + schema: + $ref: '#/components/schemas/User' + description: Created user object + required: true + responses: + default: + content: {} + description: successful operation + summary: Create user + tags: + - user + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: application/json + x-tags: + - tag: user + /user/createWithArray: + post: + operationId: createUsersWithArrayInput + requestBody: + content: + '*/*': + schema: + items: + $ref: '#/components/schemas/User' + type: array + description: List of user object + required: true + responses: + default: + content: {} + description: successful operation + summary: Creates list of users with given input array + tags: + - user + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: application/json + x-tags: + - tag: user + /user/createWithList: + post: + operationId: createUsersWithListInput + requestBody: + content: + '*/*': + schema: + items: + $ref: '#/components/schemas/User' + type: array + description: List of user object + required: true + responses: + default: + content: {} + description: successful operation + summary: Creates list of users with given input array + tags: + - user + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: application/json + x-tags: + - tag: user + /user/login: + get: + operationId: loginUser + parameters: + - description: The user name for login + in: query + name: username + required: true + schema: + type: string + - description: The password for login in clear text + in: query + name: password + required: true + schema: + type: string + responses: + "200": + content: + application/xml: + schema: + type: string + application/json: + schema: + type: string + description: successful operation + headers: + X-Rate-Limit: + description: calls per hour allowed by the user + schema: + format: int32 + type: integer + X-Expires-After: + description: date in UTC when token expires + schema: + format: date-time + type: string + "400": + content: {} + description: Invalid username/password supplied + summary: Logs user into the system + tags: + - user + x-accepts: application/json + x-tags: + - tag: user + /user/logout: + get: + operationId: logoutUser + responses: + default: + content: {} + description: successful operation + 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 + in: path + name: username + required: true + schema: + type: string + responses: + "400": + content: {} + description: Invalid username supplied + "404": + content: {} + description: User not found + summary: Delete user + tags: + - user + x-accepts: application/json + x-tags: + - tag: user + get: + operationId: getUserByName + parameters: + - description: The name that needs to be fetched. Use user1 for testing. + in: path + name: username + required: true + schema: + type: string + responses: + "200": + content: + application/xml: + schema: + $ref: '#/components/schemas/User' + application/json: + schema: + $ref: '#/components/schemas/User' + description: successful operation + "400": + content: {} + description: Invalid username supplied + "404": + content: {} + 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 + in: path + name: username + required: true + schema: + type: string + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/User' + description: Updated user object + required: true + responses: + "400": + content: {} + description: Invalid user supplied + "404": + content: {} + description: User not found + summary: Updated user + tags: + - user + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: application/json + x-tags: + - tag: user + /fake_classname_test: + patch: + description: To test class name in snake case + operationId: testClassname + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: client model + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: successful operation + security: + - api_key_query: [] + summary: To test class name in snake case + tags: + - fake_classname_tags 123#$%^ + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: fake_classname_tags 123#$%^ + /fake: + delete: + description: Fake endpoint to test group parameters (optional) + operationId: testGroupParameters + parameters: + - description: Required String in group parameters + in: query + name: required_string_group + required: true + schema: + type: integer + - description: Required Boolean in group parameters + in: header + name: required_boolean_group + required: true + schema: + type: boolean + - description: Required Integer in group parameters + in: query + name: required_int64_group + required: true + schema: + format: int64 + type: integer + - description: String in group parameters + in: query + name: string_group + schema: + type: integer + - description: Boolean in group parameters + in: header + name: boolean_group + schema: + type: boolean + - description: Integer in group parameters + in: query + name: int64_group + schema: + format: int64 + type: integer + responses: + "400": + content: {} + description: Someting wrong + summary: Fake endpoint to test group parameters (optional) + tags: + - fake + x-group-parameters: true + x-accepts: application/json + x-tags: + - tag: fake + get: + description: To test enum parameters + operationId: testEnumParameters + parameters: + - description: Header parameter enum test (string array) + explode: false + in: header + name: enum_header_string_array + schema: + items: + default: $ + enum: + - '>' + - $ + type: string + type: array + style: simple + - description: Header parameter enum test (string) + in: header + name: enum_header_string + schema: + default: -efg + enum: + - _abc + - -efg + - (xyz) + type: string + - description: Query parameter enum test (string array) + explode: false + in: query + name: enum_query_string_array + schema: + items: + default: $ + enum: + - '>' + - $ + type: string + type: array + style: form + - description: Query parameter enum test (string) + in: query + name: enum_query_string + schema: + default: -efg + enum: + - _abc + - -efg + - (xyz) + type: string + - description: Query parameter enum test (double) + in: query + name: enum_query_integer + schema: + enum: + - 1 + - -2 + format: int32 + type: integer + - description: Query parameter enum test (double) + in: query + name: enum_query_double + schema: + enum: + - 1.1 + - -1.2 + format: double + type: number + requestBody: + content: + application/x-www-form-urlencoded: + schema: + properties: + enum_form_string_array: + description: Form parameter enum test (string array) + items: + default: $ + enum: + - '>' + - $ + type: string + type: array + enum_form_string: + default: -efg + description: Form parameter enum test (string) + enum: + - _abc + - -efg + - (xyz) + type: string + responses: + "400": + content: {} + description: Invalid request + "404": + content: {} + description: Not found + summary: To test enum parameters + tags: + - fake + x-contentType: application/x-www-form-urlencoded + x-accepts: application/json + x-tags: + - tag: fake + patch: + description: To test "client" model + operationId: testClientModel + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: client model + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: successful operation + summary: To test "client" model + tags: + - fake + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: fake + post: + description: |- + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + operationId: testEndpointParameters + requestBody: + content: + application/x-www-form-urlencoded: + schema: + properties: + integer: + description: None + format: int32 + maximum: 100 + minimum: 10 + type: integer + int32: + description: None + format: int32 + maximum: 200 + minimum: 20 + type: integer + int64: + description: None + format: int64 + type: integer + number: + description: None + maximum: 543.2 + minimum: 32.1 + type: number + float: + description: None + format: float + maximum: 987.6 + type: number + double: + description: None + format: double + maximum: 123.4 + minimum: 67.8 + type: number + string: + description: None + pattern: /[a-z]/i + type: string + pattern_without_delimiter: + description: None + pattern: ^[A-Z].* + type: string + byte: + description: None + format: byte + type: string + binary: + description: None + format: binary + type: string + date: + description: None + format: date + type: string + dateTime: + description: None + format: date-time + type: string + password: + description: None + format: password + maxLength: 64 + minLength: 10 + type: string + callback: + description: None + type: string + required: + - byte + - double + - number + - pattern_without_delimiter + required: true + responses: + "400": + content: {} + description: Invalid username supplied + "404": + content: {} + description: User not found + security: + - http_basic_test: [] + summary: |- + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + tags: + - fake + x-contentType: application/x-www-form-urlencoded + x-accepts: application/json + x-tags: + - tag: fake + /fake/outer/number: + post: + description: Test serialization of outer number types + operationId: fakeOuterNumberSerialize + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterNumber' + description: Input number as post body + required: false + responses: + "200": + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterNumber' + description: Output number + tags: + - fake + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: '*/*' + x-tags: + - tag: fake + /fake/outer/string: + post: + description: Test serialization of outer string types + operationId: fakeOuterStringSerialize + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterString' + description: Input string as post body + required: false + responses: + "200": + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterString' + description: Output string + tags: + - fake + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: '*/*' + x-tags: + - tag: fake + /fake/outer/boolean: + post: + description: Test serialization of outer boolean types + operationId: fakeOuterBooleanSerialize + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterBoolean' + description: Input boolean as post body + required: false + responses: + "200": + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterBoolean' + description: Output boolean + tags: + - fake + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: '*/*' + x-tags: + - tag: fake + /fake/outer/composite: + post: + description: Test serialization of object with outer number type + operationId: fakeOuterCompositeSerialize + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterComposite' + description: Input composite as post body + required: false + responses: + "200": + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterComposite' + description: Output composite + tags: + - fake + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: '*/*' + x-tags: + - tag: fake + /fake/jsonFormData: + get: + operationId: testJsonFormData + requestBody: + content: + application/x-www-form-urlencoded: + schema: + properties: + param: + description: field1 + type: string + param2: + description: field2 + type: string + required: + - param + - param2 + required: true + responses: + "200": + content: {} + description: successful operation + summary: test json serialization of form data + tags: + - fake + x-contentType: application/x-www-form-urlencoded + x-accepts: application/json + x-tags: + - tag: fake + /fake/inline-additionalProperties: + post: + operationId: testInlineAdditionalProperties + requestBody: + content: + application/json: + schema: + additionalProperties: + type: string + type: object + description: request body + required: true + responses: + "200": + content: {} + description: successful operation + summary: test inline additionalProperties + tags: + - fake + x-codegen-request-body-name: param + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: fake + /fake/body-with-query-params: + put: + operationId: testBodyWithQueryParams + parameters: + - in: query + name: query + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + required: true + responses: + "200": + content: {} + description: Success + tags: + - fake + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: fake + /fake/create_xml_item: + post: + description: this route creates an XmlItem + operationId: createXmlItem + requestBody: + content: + application/xml: + schema: + $ref: '#/components/schemas/XmlItem' + application/xml; charset=utf-8: + schema: + $ref: '#/components/schemas/XmlItem' + application/xml; charset=utf-16: + schema: + $ref: '#/components/schemas/XmlItem' + text/xml: + schema: + $ref: '#/components/schemas/XmlItem' + text/xml; charset=utf-8: + schema: + $ref: '#/components/schemas/XmlItem' + text/xml; charset=utf-16: + schema: + $ref: '#/components/schemas/XmlItem' + description: XmlItem Body + required: true + responses: + "200": + content: {} + description: successful operation + summary: creates an XmlItem + tags: + - fake + x-codegen-request-body-name: XmlItem + x-contentType: application/xml + x-accepts: application/json + x-tags: + - tag: fake + /another-fake/dummy: + patch: + description: To test special tags and operation ID starting with number + operationId: 123_test_@#$%_special_tags + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: client model + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: successful operation + summary: To test special tags + tags: + - $another-fake? + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: $another-fake? + /fake/body-with-file-schema: + put: + description: For this test, the body for this request much reference a schema + named `File`. + operationId: testBodyWithFileSchema + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/FileSchemaTestClass' + required: true + responses: + "200": + content: {} + description: Success + tags: + - fake + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: fake + /fake/test-query-parameters: + put: + description: To test the collection format in query parameters + operationId: testQueryParameterCollectionFormat + parameters: + - explode: false + in: query + name: pipe + required: true + schema: + items: + type: string + type: array + style: form + - in: query + name: ioutil + required: true + schema: + items: + type: string + type: array + - in: query + name: http + required: true + schema: + items: + type: string + type: array + style: spaceDelimited + - explode: false + in: query + name: url + required: true + schema: + items: + type: string + type: array + style: form + - explode: true + in: query + name: context + required: true + schema: + items: + type: string + type: array + style: form + responses: + "200": + content: {} + description: Success + tags: + - fake + x-accepts: application/json + x-tags: + - tag: fake + /fake/{petId}/uploadImageWithRequiredFile: + post: + operationId: uploadFileWithRequiredFile + parameters: + - description: ID of pet to update + in: path + name: petId + required: true + schema: + format: int64 + type: integer + requestBody: + content: + multipart/form-data: + schema: + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + requiredFile: + description: file to upload + format: binary + type: string + required: + - requiredFile + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an image (required) + tags: + - pet + x-contentType: multipart/form-data + x-accepts: application/json + x-tags: + - tag: pet +components: + schemas: + Order: + 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 + type: object + xml: + name: Order + Category: + example: + name: default-name + id: 6 + properties: + id: + format: int64 + type: integer + name: + default: default-name + type: string + required: + - name + type: object + xml: + name: Category + User: + example: + firstName: firstName + lastName: lastName + password: password + userStatus: 6 + phone: phone + id: 0 + email: email + username: username + properties: + id: + format: int64 + type: integer + x-is-unique: true + 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 + type: object + xml: + name: User + Tag: + example: + name: name + id: 1 + properties: + id: + format: int64 + type: integer + name: + type: string + type: object + xml: + name: Tag + Pet: + example: + photoUrls: + - photoUrls + - photoUrls + name: doggie + id: 0 + category: + name: default-name + id: 6 + tags: + - name: name + id: 1 + - name: name + id: 1 + status: available + properties: + id: + format: int64 + type: integer + x-is-unique: true + category: + $ref: '#/components/schemas/Category' + name: + example: doggie + type: string + photoUrls: + items: + type: string + type: array + uniqueItems: true + xml: + name: photoUrl + wrapped: true + tags: + items: + $ref: '#/components/schemas/Tag' + type: array + xml: + name: tag + wrapped: true + status: + description: pet status in the store + enum: + - available + - pending + - sold + type: string + required: + - name + - photoUrls + type: object + xml: + name: Pet + ApiResponse: + example: + code: 0 + type: type + message: message + properties: + code: + format: int32 + type: integer + type: + type: string + message: + type: string + type: object + $special[model.name]: + properties: + $special[property.name]: + format: int64 + type: integer + type: object + xml: + name: $special[model.name] + Return: + description: Model for testing reserved words + properties: + return: + format: int32 + type: integer + type: object + xml: + name: Return + Name: + description: Model for testing model name same as property name + properties: + name: + format: int32 + type: integer + snake_case: + format: int32 + readOnly: true + type: integer + property: + type: string + "123Number": + readOnly: true + type: integer + required: + - name + type: object + xml: + name: Name + "200_response": + description: Model for testing model name starting with number + properties: + name: + format: int32 + type: integer + class: + type: string + type: object + xml: + name: Name + ClassModel: + description: Model for testing model with "_class" property + properties: + _class: + type: string + type: object + Dog: + allOf: + - $ref: '#/components/schemas/Animal' + - $ref: '#/components/schemas/Dog_allOf' + Cat: + allOf: + - $ref: '#/components/schemas/Animal' + - $ref: '#/components/schemas/Cat_allOf' + BigCat: + allOf: + - $ref: '#/components/schemas/Cat' + - $ref: '#/components/schemas/BigCat_allOf' + Animal: + discriminator: + propertyName: className + properties: + className: + type: string + color: + default: red + type: string + required: + - className + type: object + AnimalFarm: + items: + $ref: '#/components/schemas/Animal' + type: array + format_test: + properties: + integer: + maximum: 1E+2 + minimum: 1E+1 + type: integer + int32: + format: int32 + maximum: 2E+2 + minimum: 2E+1 + type: integer + int64: + format: int64 + type: integer + number: + maximum: 543.2 + minimum: 32.1 + type: number + float: + format: float + maximum: 987.6 + minimum: 54.3 + type: number + double: + format: double + maximum: 123.4 + minimum: 67.8 + type: number + string: + pattern: /[a-z]/i + type: string + byte: + format: byte + pattern: ^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$ + type: string + binary: + format: binary + type: string + date: + format: date + type: string + dateTime: + format: date-time + type: string + uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + type: string + password: + format: password + maxLength: 64 + minLength: 10 + type: string + BigDecimal: + format: number + type: string + required: + - byte + - date + - number + - password + type: object + EnumClass: + default: -efg + enum: + - _abc + - -efg + - (xyz) + type: string + Enum_Test: + properties: + enum_string: + enum: + - UPPER + - lower + - "" + type: string + enum_string_required: + enum: + - UPPER + - lower + - "" + type: string + enum_integer: + enum: + - 1 + - -1 + format: int32 + type: integer + enum_number: + enum: + - 1.1 + - -1.2 + format: double + type: number + outerEnum: + $ref: '#/components/schemas/OuterEnum' + required: + - enum_string_required + type: object + AdditionalPropertiesClass: + properties: + map_string: + additionalProperties: + type: string + type: object + map_number: + additionalProperties: + type: number + type: object + map_integer: + additionalProperties: + type: integer + type: object + map_boolean: + additionalProperties: + type: boolean + type: object + map_array_integer: + additionalProperties: + items: + type: integer + type: array + type: object + map_array_anytype: + additionalProperties: + items: + properties: {} + type: object + type: array + type: object + map_map_string: + additionalProperties: + additionalProperties: + type: string + type: object + type: object + map_map_anytype: + additionalProperties: + additionalProperties: + properties: {} + type: object + type: object + type: object + anytype_1: + properties: {} + type: object + anytype_2: + type: object + anytype_3: + properties: {} + type: object + type: object + AdditionalPropertiesString: + additionalProperties: + type: string + properties: + name: + type: string + type: object + AdditionalPropertiesInteger: + additionalProperties: + type: integer + properties: + name: + type: string + type: object + AdditionalPropertiesNumber: + additionalProperties: + type: number + properties: + name: + type: string + type: object + AdditionalPropertiesBoolean: + additionalProperties: + type: boolean + properties: + name: + type: string + type: object + AdditionalPropertiesArray: + additionalProperties: + items: + properties: {} + type: object + type: array + properties: + name: + type: string + type: object + AdditionalPropertiesObject: + additionalProperties: + additionalProperties: + properties: {} + type: object + type: object + properties: + name: + type: string + type: object + AdditionalPropertiesAnyType: + additionalProperties: + properties: {} + type: object + properties: + name: + type: string + type: object + MixedPropertiesAndAdditionalPropertiesClass: + properties: + uuid: + format: uuid + type: string + dateTime: + format: date-time + type: string + map: + additionalProperties: + $ref: '#/components/schemas/Animal' + type: object + type: object + List: + properties: + "123-list": + type: string + type: object + Client: + example: + client: client + properties: + client: + type: string + type: object + ReadOnlyFirst: + properties: + bar: + readOnly: true + type: string + baz: + type: string + type: object + hasOnlyReadOnly: + properties: + bar: + readOnly: true + type: string + foo: + readOnly: true + type: string + type: object + Capitalization: + properties: + smallCamel: + type: string + CapitalCamel: + type: string + small_Snake: + type: string + Capital_Snake: + type: string + SCA_ETH_Flow_Points: + type: string + ATT_NAME: + description: | + Name of the pet + type: string + type: object + MapTest: + properties: + map_map_of_string: + additionalProperties: + additionalProperties: + type: string + type: object + type: object + map_of_enum_string: + additionalProperties: + enum: + - UPPER + - lower + type: string + type: object + direct_map: + additionalProperties: + type: boolean + type: object + indirect_map: + additionalProperties: + type: boolean + type: object + type: object + ArrayTest: + properties: + array_of_string: + items: + type: string + type: array + array_array_of_integer: + items: + items: + format: int64 + type: integer + type: array + type: array + array_array_of_model: + items: + items: + $ref: '#/components/schemas/ReadOnlyFirst' + type: array + type: array + type: object + NumberOnly: + properties: + JustNumber: + type: number + type: object + ArrayOfNumberOnly: + properties: + ArrayNumber: + items: + type: number + type: array + type: object + ArrayOfArrayOfNumberOnly: + properties: + ArrayArrayNumber: + items: + items: + type: number + type: array + type: array + type: object + EnumArrays: + properties: + just_symbol: + enum: + - '>=' + - $ + type: string + array_enum: + items: + enum: + - fish + - crab + type: string + type: array + type: object + OuterEnum: + enum: + - placed + - approved + - delivered + type: string + OuterComposite: + example: + my_string: my_string + my_number: 0.8008281904610115 + my_boolean: true + properties: + my_number: + type: number + my_string: + type: string + my_boolean: + type: boolean + x-codegen-body-parameter-name: boolean_post_body + type: object + OuterNumber: + type: number + OuterString: + type: string + OuterBoolean: + type: boolean + x-codegen-body-parameter-name: boolean_post_body + StringBooleanMap: + additionalProperties: + type: boolean + type: object + FileSchemaTestClass: + example: + file: + sourceURI: sourceURI + files: + - sourceURI: sourceURI + - sourceURI: sourceURI + properties: + file: + $ref: '#/components/schemas/File' + files: + items: + $ref: '#/components/schemas/File' + type: array + type: object + File: + description: Must be named `File` for test. + example: + sourceURI: sourceURI + properties: + sourceURI: + description: Test capitalization + type: string + type: object + TypeHolderDefault: + properties: + string_item: + default: what + type: string + number_item: + type: number + integer_item: + type: integer + bool_item: + default: true + type: boolean + array_item: + items: + type: integer + type: array + required: + - array_item + - bool_item + - integer_item + - number_item + - string_item + type: object + TypeHolderExample: + properties: + string_item: + example: what + type: string + number_item: + example: 1.234 + type: number + float_item: + example: 1.234 + format: float + type: number + integer_item: + example: -2 + type: integer + bool_item: + example: true + type: boolean + array_item: + example: + - 0 + - 1 + - 2 + - 3 + items: + type: integer + type: array + required: + - array_item + - bool_item + - float_item + - integer_item + - number_item + - string_item + type: object + XmlItem: + properties: + attribute_string: + example: string + type: string + xml: + attribute: true + attribute_number: + example: 1.234 + type: number + xml: + attribute: true + attribute_integer: + example: -2 + type: integer + xml: + attribute: true + attribute_boolean: + example: true + type: boolean + xml: + attribute: true + wrapped_array: + items: + type: integer + type: array + xml: + wrapped: true + name_string: + example: string + type: string + xml: + name: xml_name_string + name_number: + example: 1.234 + type: number + xml: + name: xml_name_number + name_integer: + example: -2 + type: integer + xml: + name: xml_name_integer + name_boolean: + example: true + type: boolean + xml: + name: xml_name_boolean + name_array: + items: + type: integer + xml: + name: xml_name_array_item + type: array + name_wrapped_array: + items: + type: integer + xml: + name: xml_name_wrapped_array_item + type: array + xml: + name: xml_name_wrapped_array + wrapped: true + prefix_string: + example: string + type: string + xml: + prefix: ab + prefix_number: + example: 1.234 + type: number + xml: + prefix: cd + prefix_integer: + example: -2 + type: integer + xml: + prefix: ef + prefix_boolean: + example: true + type: boolean + xml: + prefix: gh + prefix_array: + items: + type: integer + xml: + prefix: ij + type: array + prefix_wrapped_array: + items: + type: integer + xml: + prefix: mn + type: array + xml: + prefix: kl + wrapped: true + namespace_string: + example: string + type: string + xml: + namespace: http://a.com/schema + namespace_number: + example: 1.234 + type: number + xml: + namespace: http://b.com/schema + namespace_integer: + example: -2 + type: integer + xml: + namespace: http://c.com/schema + namespace_boolean: + example: true + type: boolean + xml: + namespace: http://d.com/schema + namespace_array: + items: + type: integer + xml: + namespace: http://e.com/schema + type: array + namespace_wrapped_array: + items: + type: integer + xml: + namespace: http://g.com/schema + type: array + xml: + namespace: http://f.com/schema + wrapped: true + prefix_ns_string: + example: string + type: string + xml: + namespace: http://a.com/schema + prefix: a + prefix_ns_number: + example: 1.234 + type: number + xml: + namespace: http://b.com/schema + prefix: b + prefix_ns_integer: + example: -2 + type: integer + xml: + namespace: http://c.com/schema + prefix: c + prefix_ns_boolean: + example: true + type: boolean + xml: + namespace: http://d.com/schema + prefix: d + prefix_ns_array: + items: + type: integer + xml: + namespace: http://e.com/schema + prefix: e + type: array + prefix_ns_wrapped_array: + items: + type: integer + xml: + namespace: http://g.com/schema + prefix: g + type: array + xml: + namespace: http://f.com/schema + prefix: f + wrapped: true + type: object + xml: + namespace: http://a.com/schema + prefix: pre + Dog_allOf: + properties: + breed: + type: string + type: object + Cat_allOf: + properties: + declawed: + type: boolean + type: object + BigCat_allOf: + properties: + kind: + enum: + - lions + - tigers + - leopards + - jaguars + 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 + api_key_query: + in: query + name: api_key_query + type: apiKey + http_basic_test: + scheme: basic + type: http +x-original-swagger-version: "2.0" diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/.openapi-generator-ignore b/samples/openapi3/server/petstore/springboot-implicitHeaders/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/.openapi-generator-ignore @@ -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 diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/.openapi-generator/FILES b/samples/openapi3/server/petstore/springboot-implicitHeaders/.openapi-generator/FILES new file mode 100644 index 000000000000..e4c32719b541 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/.openapi-generator/FILES @@ -0,0 +1,66 @@ +README.md +pom.xml +src/main/java/org/openapitools/OpenAPI2SpringBoot.java +src/main/java/org/openapitools/RFC3339DateFormat.java +src/main/java/org/openapitools/api/AnotherFakeApi.java +src/main/java/org/openapitools/api/AnotherFakeApiController.java +src/main/java/org/openapitools/api/ApiUtil.java +src/main/java/org/openapitools/api/FakeApi.java +src/main/java/org/openapitools/api/FakeApiController.java +src/main/java/org/openapitools/api/FakeClassnameTestApi.java +src/main/java/org/openapitools/api/FakeClassnameTestApiController.java +src/main/java/org/openapitools/api/PetApi.java +src/main/java/org/openapitools/api/PetApiController.java +src/main/java/org/openapitools/api/StoreApi.java +src/main/java/org/openapitools/api/StoreApiController.java +src/main/java/org/openapitools/api/UserApi.java +src/main/java/org/openapitools/api/UserApiController.java +src/main/java/org/openapitools/configuration/HomeController.java +src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java +src/main/java/org/openapitools/model/AdditionalPropertiesArray.java +src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java +src/main/java/org/openapitools/model/AdditionalPropertiesClass.java +src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java +src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java +src/main/java/org/openapitools/model/AdditionalPropertiesObject.java +src/main/java/org/openapitools/model/AdditionalPropertiesString.java +src/main/java/org/openapitools/model/Animal.java +src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java +src/main/java/org/openapitools/model/ArrayOfNumberOnly.java +src/main/java/org/openapitools/model/ArrayTest.java +src/main/java/org/openapitools/model/BigCat.java +src/main/java/org/openapitools/model/BigCatAllOf.java +src/main/java/org/openapitools/model/Capitalization.java +src/main/java/org/openapitools/model/Cat.java +src/main/java/org/openapitools/model/CatAllOf.java +src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ClassModel.java +src/main/java/org/openapitools/model/Client.java +src/main/java/org/openapitools/model/Dog.java +src/main/java/org/openapitools/model/DogAllOf.java +src/main/java/org/openapitools/model/EnumArrays.java +src/main/java/org/openapitools/model/EnumClass.java +src/main/java/org/openapitools/model/EnumTest.java +src/main/java/org/openapitools/model/FileSchemaTestClass.java +src/main/java/org/openapitools/model/FormatTest.java +src/main/java/org/openapitools/model/HasOnlyReadOnly.java +src/main/java/org/openapitools/model/MapTest.java +src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java +src/main/java/org/openapitools/model/Model200Response.java +src/main/java/org/openapitools/model/ModelApiResponse.java +src/main/java/org/openapitools/model/ModelReturn.java +src/main/java/org/openapitools/model/Name.java +src/main/java/org/openapitools/model/NumberOnly.java +src/main/java/org/openapitools/model/Order.java +src/main/java/org/openapitools/model/OuterComposite.java +src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/Pet.java +src/main/java/org/openapitools/model/ReadOnlyFirst.java +src/main/java/org/openapitools/model/SpecialModelName.java +src/main/java/org/openapitools/model/Tag.java +src/main/java/org/openapitools/model/TypeHolderDefault.java +src/main/java/org/openapitools/model/TypeHolderExample.java +src/main/java/org/openapitools/model/User.java +src/main/java/org/openapitools/model/XmlItem.java +src/main/resources/application.properties +src/main/resources/openapi.yaml diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/.openapi-generator/VERSION b/samples/openapi3/server/petstore/springboot-implicitHeaders/.openapi-generator/VERSION new file mode 100644 index 000000000000..0984c4c1ad21 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/.openapi-generator/VERSION @@ -0,0 +1 @@ +5.4.0-SNAPSHOT \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/README.md b/samples/openapi3/server/petstore/springboot-implicitHeaders/README.md new file mode 100644 index 000000000000..befc961488ae --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/README.md @@ -0,0 +1,16 @@ +# 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. + +Start your server as a simple java application + +You can view the api documentation in swagger-ui by pointing to +http://localhost:80/ + +Change default port value in application.properties \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/pom.xml b/samples/openapi3/server/petstore/springboot-implicitHeaders/pom.xml new file mode 100644 index 000000000000..1034cd0499da --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/pom.xml @@ -0,0 +1,71 @@ + + 4.0.0 + org.openapitools.openapi3 + springboot-implicitHeaders + jar + springboot-implicitHeaders + 1.0.0 + + 1.8 + ${java.version} + ${java.version} + 2.1.11 + + + org.springframework.boot + spring-boot-starter-parent + 2.5.8 + + + src/main/java + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.data + spring-data-commons + + + io.swagger.core.v3 + swagger-annotations + ${swagger-core-version} + + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + + + org.openapitools + jackson-databind-nullable + 0.2.2 + + + + org.springframework.boot + spring-boot-starter-validation + + + com.fasterxml.jackson.core + jackson-databind + + + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..cb088f451935 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,63 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.Module; +import org.openapitools.jackson.nullable.JsonNullableModule; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.ExitCodeGenerator; +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.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenAPI2SpringBoot implements CommandLineRunner { + + @Override + public void run(String... arg0) throws Exception { + if (arg0.length > 0 && arg0[0].equals("exitcode")) { + throw new ExitException(); + } + } + + public static void main(String[] args) throws Exception { + new SpringApplication(OpenAPI2SpringBoot.class).run(args); + } + + static class ExitException extends RuntimeException implements ExitCodeGenerator { + private static final long serialVersionUID = 1L; + + @Override + public int getExitCode() { + return 10; + } + + } + + @Bean + public WebMvcConfigurer webConfigurer() { + return new WebMvcConfigurer() { + /*@Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") + .allowedOrigins("*") + .allowedMethods("*") + .allowedHeaders("Content-Type"); + }*/ + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("/swagger-ui/**").addResourceLocations("classpath:/META-INF/resources/webjars/swagger-ui/3.14.2/"); + } + }; + } + + @Bean + public Module jsonNullableModule() { + return new JsonNullableModule(); + } + +} diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/RFC3339DateFormat.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/RFC3339DateFormat.java new file mode 100644 index 000000000000..bcd3936d8b34 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/RFC3339DateFormat.java @@ -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; + } +} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/AnotherFakeApi.java new file mode 100644 index 000000000000..82a5df22e20e --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -0,0 +1,77 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.openapitools.api; + +import org.openapitools.model.Client; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "another-fake", description = "the another-fake API") +public interface AnotherFakeApi { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * PATCH /another-fake/dummy : To test special tags + * To test special tags and operation ID starting with number + * + * @param body client model (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "To test special tags", + tags = { "$another-fake?" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Client.class))) + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.PATCH, + value = "/another-fake/dummy", + produces = { "application/json" }, + consumes = { "application/json" } + ) + default ResponseEntity call123testSpecialTags( + @Parameter(name = "body", description = "client model", required = true, schema = @Schema(description = "")) @Valid @RequestBody Client body + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"client\" : \"client\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/AnotherFakeApiController.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/AnotherFakeApiController.java new file mode 100644 index 000000000000..d8efcca7f8a4 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/AnotherFakeApiController.java @@ -0,0 +1,24 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.context.request.NativeWebRequest; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class AnotherFakeApiController implements AnotherFakeApi { + + private final NativeWebRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public AnotherFakeApiController(NativeWebRequest request) { + this.request = request; + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/ApiUtil.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/ApiUtil.java new file mode 100644 index 000000000000..1245b1dd0ccf --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/ApiUtil.java @@ -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); + } + } +} diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java new file mode 100644 index 000000000000..456caa3cf66f --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java @@ -0,0 +1,577 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.openapitools.api; + +import java.math.BigDecimal; +import org.openapitools.model.Client; +import org.openapitools.model.FileSchemaTestClass; +import java.time.LocalDate; +import java.util.Map; +import org.openapitools.model.ModelApiResponse; +import java.time.OffsetDateTime; +import org.openapitools.model.OuterComposite; +import org.openapitools.model.User; +import org.openapitools.model.XmlItem; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "fake", description = "the fake API") +public interface FakeApi { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * POST /fake/create_xml_item : creates an XmlItem + * this route creates an XmlItem + * + * @param xmlItem XmlItem Body (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "creates an XmlItem", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/create_xml_item", + consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } + ) + default ResponseEntity createXmlItem( + @Parameter(name = "XmlItem", description = "XmlItem Body", required = true, schema = @Schema(description = "")) @Valid @RequestBody XmlItem xmlItem + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /fake/outer/boolean + * Test serialization of outer boolean types + * + * @param body Input boolean as post body (optional) + * @return Output boolean (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Output boolean", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Boolean.class))) + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/outer/boolean", + produces = { "*/*" } + ) + default ResponseEntity fakeOuterBooleanSerialize( + @Parameter(name = "body", description = "Input boolean as post body", schema = @Schema(description = "")) @Valid @RequestBody(required = false) Boolean body + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /fake/outer/composite + * Test serialization of object with outer number type + * + * @param body Input composite as post body (optional) + * @return Output composite (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Output composite", content = @Content(mediaType = "application/json", schema = @Schema(implementation = OuterComposite.class))) + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/outer/composite", + produces = { "*/*" } + ) + default ResponseEntity fakeOuterCompositeSerialize( + @Parameter(name = "body", description = "Input composite as post body", schema = @Schema(description = "")) @Valid @RequestBody(required = false) OuterComposite body + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) { + String exampleString = "{ \"my_string\" : \"my_string\", \"my_number\" : 0.8008281904610115, \"my_boolean\" : true }"; + ApiUtil.setExampleResponse(request, "*/*", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /fake/outer/number + * Test serialization of outer number types + * + * @param body Input number as post body (optional) + * @return Output number (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Output number", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BigDecimal.class))) + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/outer/number", + produces = { "*/*" } + ) + default ResponseEntity fakeOuterNumberSerialize( + @Parameter(name = "body", description = "Input number as post body", schema = @Schema(description = "")) @Valid @RequestBody(required = false) BigDecimal body + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /fake/outer/string + * Test serialization of outer string types + * + * @param body Input string as post body (optional) + * @return Output string (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Output string", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))) + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/outer/string", + produces = { "*/*" } + ) + default ResponseEntity fakeOuterStringSerialize( + @Parameter(name = "body", description = "Input string as post body", schema = @Schema(description = "")) @Valid @RequestBody(required = false) String body + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * PUT /fake/body-with-file-schema + * For this test, the body for this request much reference a schema named `File`. + * + * @param body (required) + * @return Success (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success") + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.PUT, + value = "/fake/body-with-file-schema", + consumes = { "application/json" } + ) + default ResponseEntity testBodyWithFileSchema( + @Parameter(name = "body", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestBody FileSchemaTestClass body + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * PUT /fake/body-with-query-params + * + * @param query (required) + * @param body (required) + * @return Success (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success") + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.PUT, + value = "/fake/body-with-query-params", + consumes = { "application/json" } + ) + default ResponseEntity testBodyWithQueryParams( + @NotNull @Parameter(name = "query", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "query", required = true) String query, + @Parameter(name = "body", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestBody User body + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * PATCH /fake : To test \"client\" model + * To test \"client\" model + * + * @param body client model (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "To test \"client\" model", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Client.class))) + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.PATCH, + value = "/fake", + produces = { "application/json" }, + consumes = { "application/json" } + ) + default ResponseEntity testClientModel( + @Parameter(name = "body", description = "client model", required = true, schema = @Schema(description = "")) @Valid @RequestBody Client body + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"client\" : \"client\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /fake : Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * + * @param number None (required) + * @param _double None (required) + * @param patternWithoutDelimiter None (required) + * @param _byte None (required) + * @param integer None (optional) + * @param int32 None (optional) + * @param int64 None (optional) + * @param _float None (optional) + * @param string None (optional) + * @param binary None (optional) + * @param date None (optional) + * @param dateTime None (optional) + * @param password None (optional) + * @param paramCallback None (optional) + * @return Invalid username supplied (status code 400) + * or User not found (status code 404) + */ + @Operation( + summary = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + }, + security = { + @SecurityRequirement(name = "http_basic_test") + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) + default ResponseEntity testEndpointParameters( + @Parameter(name = "number", description = "None", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "number", required = true) BigDecimal number, + @Parameter(name = "double", description = "None", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "double", required = true) Double _double, + @Parameter(name = "pattern_without_delimiter", description = "None", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, + @Parameter(name = "byte", description = "None", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, + @Parameter(name = "integer", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "integer", required = false) Integer integer, + @Parameter(name = "int32", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "int32", required = false) Integer int32, + @Parameter(name = "int64", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "int64", required = false) Long int64, + @Parameter(name = "float", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "float", required = false) Float _float, + @Parameter(name = "string", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "string", required = false) String string, + @Parameter(name = "binary", description = "None", schema = @Schema(description = "")) @RequestPart(value = "binary", required = false) MultipartFile binary, + @Parameter(name = "date", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "date", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @Parameter(name = "dateTime", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "dateTime", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @Parameter(name = "password", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "password", required = false) String password, + @Parameter(name = "callback", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "callback", required = false) String paramCallback + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * GET /fake : To test enum parameters + * To test enum parameters + * + * @param enumQueryStringArray Query parameter enum test (string array) (optional) + * @param enumQueryString Query parameter enum test (string) (optional, default to -efg) + * @param enumQueryInteger Query parameter enum test (double) (optional) + * @param enumQueryDouble Query parameter enum test (double) (optional) + * @param enumFormStringArray Form parameter enum test (string array) (optional, default to $) + * @param enumFormString Form parameter enum test (string) (optional, default to -efg) + * @return Invalid request (status code 400) + * or Not found (status code 404) + */ + @Operation( + summary = "To test enum parameters", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid request"), + @ApiResponse(responseCode = "404", description = "Not found") + } + ) + @Parameters({ + @Parameter(name = "enum_header_string_array", description = "Header parameter enum test (string array)", schema = @Schema(description = "", allowableValues = { ">", "$" })), + @Parameter(name = "enum_header_string", description = "Header parameter enum test (string)", schema = @Schema(description = "", allowableValues = { "_abc", "-efg", "(xyz)" }, defaultValue = "-efg")) + }) + @RequestMapping( + method = RequestMethod.GET, + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) + default ResponseEntity testEnumParameters( + @Parameter(name = "enum_query_string_array", description = "Query parameter enum test (string array)", schema = @Schema(description = "", allowableValues = { ">", "$" })) @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, + @Parameter(name = "enum_query_string", description = "Query parameter enum test (string)", schema = @Schema(description = "", allowableValues = { "_abc", "-efg", "(xyz)" }, defaultValue = "-efg")) @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString, + @Parameter(name = "enum_query_integer", description = "Query parameter enum test (double)", schema = @Schema(description = "", allowableValues = { "1", "-2" })) @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, + @Parameter(name = "enum_query_double", description = "Query parameter enum test (double)", schema = @Schema(description = "", allowableValues = { "1.1", "-1.2" })) @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble, + @Parameter(name = "enum_form_string_array", description = "Form parameter enum test (string array)", schema = @Schema(description = "", allowableValues = { ">", "$" })) @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, + @Parameter(name = "enum_form_string", description = "Form parameter enum test (string)", schema = @Schema(description = "", allowableValues = { "_abc", "-efg", "(xyz)" }, defaultValue = "-efg")) @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * DELETE /fake : Fake endpoint to test group parameters (optional) + * Fake endpoint to test group parameters (optional) + * + * @param requiredStringGroup Required String in group parameters (required) + * @param requiredInt64Group Required Integer in group parameters (required) + * @param stringGroup String in group parameters (optional) + * @param int64Group Integer in group parameters (optional) + * @return Someting wrong (status code 400) + */ + @Operation( + summary = "Fake endpoint to test group parameters (optional)", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "400", description = "Someting wrong") + } + ) + @Parameters({ + @Parameter(name = "required_boolean_group", description = "Required Boolean in group parameters", required = true, schema = @Schema(description = "")), + @Parameter(name = "boolean_group", description = "Boolean in group parameters", schema = @Schema(description = "")) + }) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/fake" + ) + default ResponseEntity testGroupParameters( + @NotNull @Parameter(name = "required_string_group", description = "Required String in group parameters", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup, + @NotNull @Parameter(name = "required_int64_group", description = "Required Integer in group parameters", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group, + @Parameter(name = "string_group", description = "String in group parameters", schema = @Schema(description = "")) @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup, + @Parameter(name = "int64_group", description = "Integer in group parameters", schema = @Schema(description = "")) @Valid @RequestParam(value = "int64_group", required = false) Long int64Group + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /fake/inline-additionalProperties : test inline additionalProperties + * + * @param param request body (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "test inline additionalProperties", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/inline-additionalProperties", + consumes = { "application/json" } + ) + default ResponseEntity testInlineAdditionalProperties( + @Parameter(name = "param", description = "request body", required = true, schema = @Schema(description = "")) @Valid @RequestBody Map param + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * GET /fake/jsonFormData : test json serialization of form data + * + * @param param field1 (required) + * @param param2 field2 (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "test json serialization of form data", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.GET, + value = "/fake/jsonFormData", + consumes = { "application/x-www-form-urlencoded" } + ) + default ResponseEntity testJsonFormData( + @Parameter(name = "param", description = "field1", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "param", required = true) String param, + @Parameter(name = "param2", description = "field2", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "param2", required = true) String param2 + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * PUT /fake/test-query-parameters + * To test the collection format in query parameters + * + * @param pipe (required) + * @param ioutil (required) + * @param http (required) + * @param url (required) + * @param context (required) + * @return Success (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success") + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.PUT, + value = "/fake/test-query-parameters" + ) + default ResponseEntity testQueryParameterCollectionFormat( + @NotNull @Parameter(name = "pipe", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "pipe", required = true) List pipe, + @NotNull @Parameter(name = "ioutil", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "ioutil", required = true) List ioutil, + @NotNull @Parameter(name = "http", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "http", required = true) List http, + @NotNull @Parameter(name = "url", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "url", required = true) List url, + @NotNull @Parameter(name = "context", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "context", required = true) List context + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required) + * + * @param petId ID of pet to update (required) + * @param requiredFile file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @return successful operation (status code 200) + */ + @Operation( + summary = "uploads an image (required)", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ModelApiResponse.class))) + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/{petId}/uploadImageWithRequiredFile", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) + default ResponseEntity uploadFileWithRequiredFile( + @Parameter(name = "petId", description = "ID of pet to update", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "requiredFile", description = "file to upload", required = true, schema = @Schema(description = "")) @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, + @Parameter(name = "additionalMetadata", description = "Additional data to pass to server", schema = @Schema(description = "")) @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata + ) { + 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; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApiController.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApiController.java new file mode 100644 index 000000000000..c4b88419aabe --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApiController.java @@ -0,0 +1,24 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.context.request.NativeWebRequest; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class FakeApiController implements FakeApi { + + private final NativeWebRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public FakeApiController(NativeWebRequest request) { + this.request = request; + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeClassnameTestApi.java new file mode 100644 index 000000000000..8f1db4a34810 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -0,0 +1,80 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.openapitools.api; + +import org.openapitools.model.Client; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "fake_classname_test", description = "the fake_classname_test API") +public interface FakeClassnameTestApi { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * PATCH /fake_classname_test : To test class name in snake case + * To test class name in snake case + * + * @param body client model (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "To test class name in snake case", + tags = { "fake_classname_tags 123#$%^" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Client.class))) + }, + security = { + @SecurityRequirement(name = "api_key_query") + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.PATCH, + value = "/fake_classname_test", + produces = { "application/json" }, + consumes = { "application/json" } + ) + default ResponseEntity testClassname( + @Parameter(name = "body", description = "client model", required = true, schema = @Schema(description = "")) @Valid @RequestBody Client body + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"client\" : \"client\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java new file mode 100644 index 000000000000..85458b255da5 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java @@ -0,0 +1,24 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.context.request.NativeWebRequest; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class FakeClassnameTestApiController implements FakeClassnameTestApi { + + private final NativeWebRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public FakeClassnameTestApiController(NativeWebRequest request) { + this.request = request; + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/PetApi.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/PetApi.java new file mode 100644 index 000000000000..67abf9f8cb5e --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/PetApi.java @@ -0,0 +1,370 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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 java.util.Set; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "pet", description = "the pet API") +public interface PetApi { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * POST /pet : Add a new pet to the store + * + * @param body Pet object that needs to be added to the store (required) + * @return successful operation (status code 200) + * or Invalid input (status code 405) + */ + @Operation( + summary = "Add a new pet to the store", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation"), + @ApiResponse(responseCode = "405", description = "Invalid input") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet", + consumes = { "application/json", "application/xml" } + ) + default ResponseEntity addPet( + @Parameter(name = "body", description = "Pet object that needs to be added to the store", required = true, schema = @Schema(description = "")) @Valid @RequestBody Pet body + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * DELETE /pet/{petId} : Deletes a pet + * + * @param petId Pet id to delete (required) + * @return successful operation (status code 200) + * or Invalid pet value (status code 400) + */ + @Operation( + summary = "Deletes a pet", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation"), + @ApiResponse(responseCode = "400", description = "Invalid pet value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @Parameters({ + @Parameter(name = "api_key", description = "", schema = @Schema(description = "")) + }) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/pet/{petId}" + ) + default ResponseEntity deletePet( + @Parameter(name = "petId", description = "Pet id to delete", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId + ) { + return new ResponseEntity<>(HttpStatus.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) + */ + @Operation( + summary = "Finds Pets by status", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid status value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/findByStatus", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity> findPetsByStatus( + @NotNull @Parameter(name = "status", description = "Status values that need to be considered for filter", required = true, schema = @Schema(description = "", allowableValues = { "available", "pending", "sold" })) @Valid @RequestParam(value = "status", required = true) List 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\" : \"default-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 = " 123456789 doggie aeiou aeiou "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.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 + */ + @Operation( + summary = "Finds Pets by tags", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid tag value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/findByTags", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity> findPetsByTags( + @NotNull @Parameter(name = "tags", description = "Tags to filter by", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "tags", required = true) Set 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\" : \"default-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 = " 123456789 doggie aeiou aeiou "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.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) + */ + @Operation( + summary = "Find pet by ID", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/{petId}", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity getPetById( + @Parameter(name = "petId", description = "ID of pet to return", required = true, schema = @Schema(description = "")) @PathVariable("petId") 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\" : \"default-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 = " 123456789 doggie aeiou aeiou "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * PUT /pet : Update an existing pet + * + * @param body 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) + */ + @Operation( + summary = "Update an existing pet", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation"), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found"), + @ApiResponse(responseCode = "405", description = "Validation exception") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.PUT, + value = "/pet", + consumes = { "application/json", "application/xml" } + ) + default ResponseEntity updatePet( + @Parameter(name = "body", description = "Pet object that needs to be added to the store", required = true, schema = @Schema(description = "")) @Valid @RequestBody Pet body + ) { + return new ResponseEntity<>(HttpStatus.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) + */ + @Operation( + summary = "Updates a pet in the store with form data", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "405", description = "Invalid input") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet/{petId}", + consumes = { "application/x-www-form-urlencoded" } + ) + default ResponseEntity updatePetWithForm( + @Parameter(name = "petId", description = "ID of pet that needs to be updated", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "name", description = "Updated name of the pet", schema = @Schema(description = "")) @Valid @RequestPart(value = "name", required = false) String name, + @Parameter(name = "status", description = "Updated status of the pet", schema = @Schema(description = "")) @Valid @RequestPart(value = "status", required = false) String status + ) { + return new ResponseEntity<>(HttpStatus.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) + */ + @Operation( + summary = "uploads an image", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ModelApiResponse.class))) + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet/{petId}/uploadImage", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) + default ResponseEntity uploadFile( + @Parameter(name = "petId", description = "ID of pet to update", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "additionalMetadata", description = "Additional data to pass to server", schema = @Schema(description = "")) @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @Parameter(name = "file", description = "file to upload", schema = @Schema(description = "")) @RequestPart(value = "file", required = false) 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; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/PetApiController.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/PetApiController.java new file mode 100644 index 000000000000..e72c57e3cbec --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/PetApiController.java @@ -0,0 +1,24 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.context.request.NativeWebRequest; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class PetApiController implements PetApi { + + private final NativeWebRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public PetApiController(NativeWebRequest request) { + this.request = request; + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/StoreApi.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/StoreApi.java new file mode 100644 index 000000000000..ce360c31059f --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/StoreApi.java @@ -0,0 +1,191 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "store", description = "the store API") +public interface StoreApi { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * DELETE /store/order/{order_id} : 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) + */ + @Operation( + summary = "Delete purchase order by ID", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/store/order/{order_id}" + ) + default ResponseEntity deleteOrder( + @Parameter(name = "order_id", description = "ID of the order that needs to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("order_id") String orderId + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * GET /store/inventory : Returns pet inventories by status + * Returns a map of status codes to quantities + * + * @return successful operation (status code 200) + */ + @Operation( + summary = "Returns pet inventories by status", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Map.class))) + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.GET, + value = "/store/inventory", + produces = { "application/json" } + ) + default ResponseEntity> getInventory( + + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * GET /store/order/{order_id} : Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated 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) + */ + @Operation( + summary = "Find purchase order by ID", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.GET, + value = "/store/order/{order_id}", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity getOrderById( + @Min(1L) @Max(5L) @Parameter(name = "order_id", description = "ID of pet that needs to be fetched", required = true, schema = @Schema(description = "")) @PathVariable("order_id") 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 = " 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /store/order : Place an order for a pet + * + * @param body order placed for purchasing the pet (required) + * @return successful operation (status code 200) + * or Invalid Order (status code 400) + */ + @Operation( + summary = "Place an order for a pet", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid Order") + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/store/order", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity placeOrder( + @Parameter(name = "body", description = "order placed for purchasing the pet", required = true, schema = @Schema(description = "")) @Valid @RequestBody Order body + ) { + 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 = " 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/StoreApiController.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/StoreApiController.java new file mode 100644 index 000000000000..1293b5c8f6e4 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/StoreApiController.java @@ -0,0 +1,24 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.context.request.NativeWebRequest; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class StoreApiController implements StoreApi { + + private final NativeWebRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public StoreApiController(NativeWebRequest request) { + this.request = request; + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/UserApi.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/UserApi.java new file mode 100644 index 000000000000..3f0113d6d1ad --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/UserApi.java @@ -0,0 +1,288 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "user", description = "the user API") +public interface UserApi { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * POST /user : Create user + * This can only be done by the logged in user. + * + * @param body Created user object (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "Create user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/user" + ) + default ResponseEntity createUser( + @Parameter(name = "body", description = "Created user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody User body + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /user/createWithArray : Creates list of users with given input array + * + * @param body List of user object (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "Creates list of users with given input array", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/user/createWithArray" + ) + default ResponseEntity createUsersWithArrayInput( + @Parameter(name = "body", description = "List of user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody List body + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /user/createWithList : Creates list of users with given input array + * + * @param body List of user object (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "Creates list of users with given input array", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/user/createWithList" + ) + default ResponseEntity createUsersWithListInput( + @Parameter(name = "body", description = "List of user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody List body + ) { + return new ResponseEntity<>(HttpStatus.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) + */ + @Operation( + summary = "Delete user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/user/{username}" + ) + default ResponseEntity deleteUser( + @Parameter(name = "username", description = "The name that needs to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("username") String username + ) { + return new ResponseEntity<>(HttpStatus.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) + */ + @Operation( + summary = "Get user by user name", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = User.class))), + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/{username}", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity getUserByName( + @Parameter(name = "username", description = "The name that needs to be fetched. Use user1 for testing.", required = true, schema = @Schema(description = "")) @PathVariable("username") 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 = " 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123 "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.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) + */ + @Operation( + summary = "Logs user into the system", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "400", description = "Invalid username/password supplied") + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/login", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity loginUser( + @NotNull @Parameter(name = "username", description = "The user name for login", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "username", required = true) String username, + @NotNull @Parameter(name = "password", description = "The password for login in clear text", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "password", required = true) String password + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * GET /user/logout : Logs out current logged in user session + * + * @return successful operation (status code 200) + */ + @Operation( + summary = "Logs out current logged in user session", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/logout" + ) + default ResponseEntity logoutUser( + + ) { + return new ResponseEntity<>(HttpStatus.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 body Updated user object (required) + * @return Invalid user supplied (status code 400) + * or User not found (status code 404) + */ + @Operation( + summary = "Updated user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid user supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + } + ) + @Parameters({ + }) + @RequestMapping( + method = RequestMethod.PUT, + value = "/user/{username}" + ) + default ResponseEntity updateUser( + @Parameter(name = "username", description = "name that need to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("username") String username, + @Parameter(name = "body", description = "Updated user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody User body + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/UserApiController.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/UserApiController.java new file mode 100644 index 000000000000..3f6c4d9a2d6f --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/UserApiController.java @@ -0,0 +1,24 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.context.request.NativeWebRequest; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class UserApiController implements UserApi { + + private final NativeWebRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public UserApiController(NativeWebRequest request) { + this.request = request; + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/configuration/HomeController.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/configuration/HomeController.java new file mode 100644 index 000000000000..34bae16b8986 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/configuration/HomeController.java @@ -0,0 +1,53 @@ +package org.openapitools.configuration; + +import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.core.io.Resource; +import org.springframework.stereotype.Controller; +import org.springframework.util.StreamUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.Charset; + +/** + * Home redirection to OpenAPI api documentation + */ +@Controller +public class HomeController { + + private static YAMLMapper yamlMapper = new YAMLMapper(); + + @Value("classpath:/openapi.yaml") + private Resource openapi; + + @Bean + public String openapiContent() throws IOException { + try(InputStream is = openapi.getInputStream()) { + return StreamUtils.copyToString(is, Charset.defaultCharset()); + } + } + + @GetMapping(value = "/openapi.yaml", produces = "application/vnd.oai.openapi") + @ResponseBody + public String openapiYaml() throws IOException { + return openapiContent(); + } + + @GetMapping(value = "/openapi.json", produces = "application/json") + @ResponseBody + public Object openapiJson() throws IOException { + return yamlMapper.readValue(openapiContent(), Object.class); + } + + @RequestMapping("/") + public String index() { + return "redirect:swagger-ui/index.html?url=../openapi.json"; + } + + +} diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java new file mode 100644 index 000000000000..0c57ae7dd14c --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java @@ -0,0 +1,86 @@ +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 java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesAnyType + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesAnyType extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesAnyType name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesAnyType additionalPropertiesAnyType = (AdditionalPropertiesAnyType) o; + return Objects.equals(this.name, additionalPropertiesAnyType.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesAnyType {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesArray.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesArray.java new file mode 100644 index 000000000000..b5285ec2f29b --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesArray.java @@ -0,0 +1,87 @@ +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 java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesArray + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesArray extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesArray name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesArray additionalPropertiesArray = (AdditionalPropertiesArray) o; + return Objects.equals(this.name, additionalPropertiesArray.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesArray {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java new file mode 100644 index 000000000000..f8ca38c286d5 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java @@ -0,0 +1,86 @@ +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 java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesBoolean + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesBoolean extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesBoolean name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesBoolean additionalPropertiesBoolean = (AdditionalPropertiesBoolean) o; + return Objects.equals(this.name, additionalPropertiesBoolean.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesBoolean {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java new file mode 100644 index 000000000000..dfd28ccb9963 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java @@ -0,0 +1,414 @@ +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 java.math.BigDecimal; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesClass + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesClass { + @JsonProperty("map_string") + @Valid + private Map mapString = null; + + @JsonProperty("map_number") + @Valid + private Map mapNumber = null; + + @JsonProperty("map_integer") + @Valid + private Map mapInteger = null; + + @JsonProperty("map_boolean") + @Valid + private Map mapBoolean = null; + + @JsonProperty("map_array_integer") + @Valid + private Map> mapArrayInteger = null; + + @JsonProperty("map_array_anytype") + @Valid + private Map> mapArrayAnytype = null; + + @JsonProperty("map_map_string") + @Valid + private Map> mapMapString = null; + + @JsonProperty("map_map_anytype") + @Valid + private Map> mapMapAnytype = null; + + @JsonProperty("anytype_1") + private Object anytype1; + + @JsonProperty("anytype_2") + private Object anytype2; + + @JsonProperty("anytype_3") + private Object anytype3; + + public AdditionalPropertiesClass mapString(Map mapString) { + this.mapString = mapString; + return this; + } + + public AdditionalPropertiesClass putMapStringItem(String key, String mapStringItem) { + if (this.mapString == null) { + this.mapString = new HashMap<>(); + } + this.mapString.put(key, mapStringItem); + return this; + } + + /** + * Get mapString + * @return mapString + */ + @Schema(name = "mapString", defaultValue = "") + + + public Map getMapString() { + return mapString; + } + + public void setMapString(Map mapString) { + this.mapString = mapString; + } + + public AdditionalPropertiesClass mapNumber(Map mapNumber) { + this.mapNumber = mapNumber; + return this; + } + + public AdditionalPropertiesClass putMapNumberItem(String key, BigDecimal mapNumberItem) { + if (this.mapNumber == null) { + this.mapNumber = new HashMap<>(); + } + this.mapNumber.put(key, mapNumberItem); + return this; + } + + /** + * Get mapNumber + * @return mapNumber + */ + @Schema(name = "mapNumber", defaultValue = "") + + @Valid + + public Map getMapNumber() { + return mapNumber; + } + + public void setMapNumber(Map mapNumber) { + this.mapNumber = mapNumber; + } + + public AdditionalPropertiesClass mapInteger(Map mapInteger) { + this.mapInteger = mapInteger; + return this; + } + + public AdditionalPropertiesClass putMapIntegerItem(String key, Integer mapIntegerItem) { + if (this.mapInteger == null) { + this.mapInteger = new HashMap<>(); + } + this.mapInteger.put(key, mapIntegerItem); + return this; + } + + /** + * Get mapInteger + * @return mapInteger + */ + @Schema(name = "mapInteger", defaultValue = "") + + + public Map getMapInteger() { + return mapInteger; + } + + public void setMapInteger(Map mapInteger) { + this.mapInteger = mapInteger; + } + + public AdditionalPropertiesClass mapBoolean(Map mapBoolean) { + this.mapBoolean = mapBoolean; + return this; + } + + public AdditionalPropertiesClass putMapBooleanItem(String key, Boolean mapBooleanItem) { + if (this.mapBoolean == null) { + this.mapBoolean = new HashMap<>(); + } + this.mapBoolean.put(key, mapBooleanItem); + return this; + } + + /** + * Get mapBoolean + * @return mapBoolean + */ + @Schema(name = "mapBoolean", defaultValue = "") + + + public Map getMapBoolean() { + return mapBoolean; + } + + public void setMapBoolean(Map mapBoolean) { + this.mapBoolean = mapBoolean; + } + + public AdditionalPropertiesClass mapArrayInteger(Map> mapArrayInteger) { + this.mapArrayInteger = mapArrayInteger; + return this; + } + + public AdditionalPropertiesClass putMapArrayIntegerItem(String key, List mapArrayIntegerItem) { + if (this.mapArrayInteger == null) { + this.mapArrayInteger = new HashMap<>(); + } + this.mapArrayInteger.put(key, mapArrayIntegerItem); + return this; + } + + /** + * Get mapArrayInteger + * @return mapArrayInteger + */ + @Schema(name = "mapArrayInteger", defaultValue = "") + + @Valid + + public Map> getMapArrayInteger() { + return mapArrayInteger; + } + + public void setMapArrayInteger(Map> mapArrayInteger) { + this.mapArrayInteger = mapArrayInteger; + } + + public AdditionalPropertiesClass mapArrayAnytype(Map> mapArrayAnytype) { + this.mapArrayAnytype = mapArrayAnytype; + return this; + } + + public AdditionalPropertiesClass putMapArrayAnytypeItem(String key, List mapArrayAnytypeItem) { + if (this.mapArrayAnytype == null) { + this.mapArrayAnytype = new HashMap<>(); + } + this.mapArrayAnytype.put(key, mapArrayAnytypeItem); + return this; + } + + /** + * Get mapArrayAnytype + * @return mapArrayAnytype + */ + @Schema(name = "mapArrayAnytype", defaultValue = "") + + @Valid + + public Map> getMapArrayAnytype() { + return mapArrayAnytype; + } + + public void setMapArrayAnytype(Map> mapArrayAnytype) { + this.mapArrayAnytype = mapArrayAnytype; + } + + public AdditionalPropertiesClass mapMapString(Map> mapMapString) { + this.mapMapString = mapMapString; + return this; + } + + public AdditionalPropertiesClass putMapMapStringItem(String key, Map mapMapStringItem) { + if (this.mapMapString == null) { + this.mapMapString = new HashMap<>(); + } + this.mapMapString.put(key, mapMapStringItem); + return this; + } + + /** + * Get mapMapString + * @return mapMapString + */ + @Schema(name = "mapMapString", defaultValue = "") + + @Valid + + public Map> getMapMapString() { + return mapMapString; + } + + public void setMapMapString(Map> mapMapString) { + this.mapMapString = mapMapString; + } + + public AdditionalPropertiesClass mapMapAnytype(Map> mapMapAnytype) { + this.mapMapAnytype = mapMapAnytype; + return this; + } + + public AdditionalPropertiesClass putMapMapAnytypeItem(String key, Map mapMapAnytypeItem) { + if (this.mapMapAnytype == null) { + this.mapMapAnytype = new HashMap<>(); + } + this.mapMapAnytype.put(key, mapMapAnytypeItem); + return this; + } + + /** + * Get mapMapAnytype + * @return mapMapAnytype + */ + @Schema(name = "mapMapAnytype", defaultValue = "") + + @Valid + + public Map> getMapMapAnytype() { + return mapMapAnytype; + } + + public void setMapMapAnytype(Map> mapMapAnytype) { + this.mapMapAnytype = mapMapAnytype; + } + + public AdditionalPropertiesClass anytype1(Object anytype1) { + this.anytype1 = anytype1; + return this; + } + + /** + * Get anytype1 + * @return anytype1 + */ + @Schema(name = "anytype1", defaultValue = "") + + + public Object getAnytype1() { + return anytype1; + } + + public void setAnytype1(Object anytype1) { + this.anytype1 = anytype1; + } + + public AdditionalPropertiesClass anytype2(Object anytype2) { + this.anytype2 = anytype2; + return this; + } + + /** + * Get anytype2 + * @return anytype2 + */ + @Schema(name = "anytype2", defaultValue = "") + + + public Object getAnytype2() { + return anytype2; + } + + public void setAnytype2(Object anytype2) { + this.anytype2 = anytype2; + } + + public AdditionalPropertiesClass anytype3(Object anytype3) { + this.anytype3 = anytype3; + return this; + } + + /** + * Get anytype3 + * @return anytype3 + */ + @Schema(name = "anytype3", defaultValue = "") + + + public Object getAnytype3() { + return anytype3; + } + + public void setAnytype3(Object anytype3) { + this.anytype3 = anytype3; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AdditionalPropertiesClass additionalPropertiesClass = (AdditionalPropertiesClass) o; + return Objects.equals(this.mapString, additionalPropertiesClass.mapString) && + Objects.equals(this.mapNumber, additionalPropertiesClass.mapNumber) && + Objects.equals(this.mapInteger, additionalPropertiesClass.mapInteger) && + Objects.equals(this.mapBoolean, additionalPropertiesClass.mapBoolean) && + Objects.equals(this.mapArrayInteger, additionalPropertiesClass.mapArrayInteger) && + Objects.equals(this.mapArrayAnytype, additionalPropertiesClass.mapArrayAnytype) && + Objects.equals(this.mapMapString, additionalPropertiesClass.mapMapString) && + Objects.equals(this.mapMapAnytype, additionalPropertiesClass.mapMapAnytype) && + Objects.equals(this.anytype1, additionalPropertiesClass.anytype1) && + Objects.equals(this.anytype2, additionalPropertiesClass.anytype2) && + Objects.equals(this.anytype3, additionalPropertiesClass.anytype3); + } + + @Override + public int hashCode() { + return Objects.hash(mapString, mapNumber, mapInteger, mapBoolean, mapArrayInteger, mapArrayAnytype, mapMapString, mapMapAnytype, anytype1, anytype2, anytype3); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesClass {\n"); + + sb.append(" mapString: ").append(toIndentedString(mapString)).append("\n"); + sb.append(" mapNumber: ").append(toIndentedString(mapNumber)).append("\n"); + sb.append(" mapInteger: ").append(toIndentedString(mapInteger)).append("\n"); + sb.append(" mapBoolean: ").append(toIndentedString(mapBoolean)).append("\n"); + sb.append(" mapArrayInteger: ").append(toIndentedString(mapArrayInteger)).append("\n"); + sb.append(" mapArrayAnytype: ").append(toIndentedString(mapArrayAnytype)).append("\n"); + sb.append(" mapMapString: ").append(toIndentedString(mapMapString)).append("\n"); + sb.append(" mapMapAnytype: ").append(toIndentedString(mapMapAnytype)).append("\n"); + sb.append(" anytype1: ").append(toIndentedString(anytype1)).append("\n"); + sb.append(" anytype2: ").append(toIndentedString(anytype2)).append("\n"); + sb.append(" anytype3: ").append(toIndentedString(anytype3)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java new file mode 100644 index 000000000000..5fea577ab44b --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java @@ -0,0 +1,86 @@ +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 java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesInteger + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesInteger extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesInteger name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesInteger additionalPropertiesInteger = (AdditionalPropertiesInteger) o; + return Objects.equals(this.name, additionalPropertiesInteger.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesInteger {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java new file mode 100644 index 000000000000..e6eee612a24f --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java @@ -0,0 +1,87 @@ +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 java.math.BigDecimal; +import java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesNumber + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesNumber extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesNumber name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesNumber additionalPropertiesNumber = (AdditionalPropertiesNumber) o; + return Objects.equals(this.name, additionalPropertiesNumber.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesNumber {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesObject.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesObject.java new file mode 100644 index 000000000000..d7116bd7572c --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesObject.java @@ -0,0 +1,86 @@ +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 java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesObject + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesObject extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesObject name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesObject additionalPropertiesObject = (AdditionalPropertiesObject) o; + return Objects.equals(this.name, additionalPropertiesObject.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesObject {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesString.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesString.java new file mode 100644 index 000000000000..d2022be266fb --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesString.java @@ -0,0 +1,86 @@ +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 java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesString + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesString extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesString name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesString additionalPropertiesString = (AdditionalPropertiesString) o; + return Objects.equals(this.name, additionalPropertiesString.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesString {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Animal.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Animal.java new file mode 100644 index 000000000000..6f096d5069ed --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Animal.java @@ -0,0 +1,118 @@ +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.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Animal + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "className", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = BigCat.class, name = "BigCat"), + @JsonSubTypes.Type(value = Cat.class, name = "Cat"), + @JsonSubTypes.Type(value = Dog.class, name = "Dog"), +}) + +public class Animal { + @JsonProperty("className") + private String className; + + @JsonProperty("color") + private String color = "red"; + + public Animal className(String className) { + this.className = className; + return this; + } + + /** + * Get className + * @return className + */ + @Schema(name = "className", required = true, defaultValue = "") + @NotNull + + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public Animal color(String color) { + this.color = color; + return this; + } + + /** + * Get color + * @return color + */ + @Schema(name = "color", defaultValue = "") + + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Animal animal = (Animal) o; + return Objects.equals(this.className, animal.className) && + Objects.equals(this.color, animal.color); + } + + @Override + public int hashCode() { + return Objects.hash(className, color); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Animal {\n"); + + sb.append(" className: ").append(toIndentedString(className)).append("\n"); + sb.append(" color: ").append(toIndentedString(color)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java new file mode 100644 index 000000000000..ebe36ad761a9 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java @@ -0,0 +1,96 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ArrayOfArrayOfNumberOnly + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ArrayOfArrayOfNumberOnly { + @JsonProperty("ArrayArrayNumber") + @Valid + private List> arrayArrayNumber = null; + + public ArrayOfArrayOfNumberOnly arrayArrayNumber(List> arrayArrayNumber) { + this.arrayArrayNumber = arrayArrayNumber; + return this; + } + + public ArrayOfArrayOfNumberOnly addArrayArrayNumberItem(List arrayArrayNumberItem) { + if (this.arrayArrayNumber == null) { + this.arrayArrayNumber = new ArrayList<>(); + } + this.arrayArrayNumber.add(arrayArrayNumberItem); + return this; + } + + /** + * Get arrayArrayNumber + * @return arrayArrayNumber + */ + @Schema(name = "arrayArrayNumber", defaultValue = "") + + @Valid + + public List> getArrayArrayNumber() { + return arrayArrayNumber; + } + + public void setArrayArrayNumber(List> arrayArrayNumber) { + this.arrayArrayNumber = arrayArrayNumber; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly = (ArrayOfArrayOfNumberOnly) o; + return Objects.equals(this.arrayArrayNumber, arrayOfArrayOfNumberOnly.arrayArrayNumber); + } + + @Override + public int hashCode() { + return Objects.hash(arrayArrayNumber); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayOfArrayOfNumberOnly {\n"); + + sb.append(" arrayArrayNumber: ").append(toIndentedString(arrayArrayNumber)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ArrayOfNumberOnly.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ArrayOfNumberOnly.java new file mode 100644 index 000000000000..8158dd44ab88 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ArrayOfNumberOnly.java @@ -0,0 +1,96 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ArrayOfNumberOnly + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ArrayOfNumberOnly { + @JsonProperty("ArrayNumber") + @Valid + private List arrayNumber = null; + + public ArrayOfNumberOnly arrayNumber(List arrayNumber) { + this.arrayNumber = arrayNumber; + return this; + } + + public ArrayOfNumberOnly addArrayNumberItem(BigDecimal arrayNumberItem) { + if (this.arrayNumber == null) { + this.arrayNumber = new ArrayList<>(); + } + this.arrayNumber.add(arrayNumberItem); + return this; + } + + /** + * Get arrayNumber + * @return arrayNumber + */ + @Schema(name = "arrayNumber", defaultValue = "") + + @Valid + + public List getArrayNumber() { + return arrayNumber; + } + + public void setArrayNumber(List arrayNumber) { + this.arrayNumber = arrayNumber; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayOfNumberOnly arrayOfNumberOnly = (ArrayOfNumberOnly) o; + return Objects.equals(this.arrayNumber, arrayOfNumberOnly.arrayNumber); + } + + @Override + public int hashCode() { + return Objects.hash(arrayNumber); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayOfNumberOnly {\n"); + + sb.append(" arrayNumber: ").append(toIndentedString(arrayNumber)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ArrayTest.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ArrayTest.java new file mode 100644 index 000000000000..420010561bcd --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ArrayTest.java @@ -0,0 +1,165 @@ +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 java.util.ArrayList; +import java.util.List; +import org.openapitools.model.ReadOnlyFirst; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ArrayTest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ArrayTest { + @JsonProperty("array_of_string") + @Valid + private List arrayOfString = null; + + @JsonProperty("array_array_of_integer") + @Valid + private List> arrayArrayOfInteger = null; + + @JsonProperty("array_array_of_model") + @Valid + private List> arrayArrayOfModel = null; + + public ArrayTest arrayOfString(List arrayOfString) { + this.arrayOfString = arrayOfString; + return this; + } + + public ArrayTest addArrayOfStringItem(String arrayOfStringItem) { + if (this.arrayOfString == null) { + this.arrayOfString = new ArrayList<>(); + } + this.arrayOfString.add(arrayOfStringItem); + return this; + } + + /** + * Get arrayOfString + * @return arrayOfString + */ + @Schema(name = "arrayOfString", defaultValue = "") + + + public List getArrayOfString() { + return arrayOfString; + } + + public void setArrayOfString(List arrayOfString) { + this.arrayOfString = arrayOfString; + } + + public ArrayTest arrayArrayOfInteger(List> arrayArrayOfInteger) { + this.arrayArrayOfInteger = arrayArrayOfInteger; + return this; + } + + public ArrayTest addArrayArrayOfIntegerItem(List arrayArrayOfIntegerItem) { + if (this.arrayArrayOfInteger == null) { + this.arrayArrayOfInteger = new ArrayList<>(); + } + this.arrayArrayOfInteger.add(arrayArrayOfIntegerItem); + return this; + } + + /** + * Get arrayArrayOfInteger + * @return arrayArrayOfInteger + */ + @Schema(name = "arrayArrayOfInteger", defaultValue = "") + + @Valid + + public List> getArrayArrayOfInteger() { + return arrayArrayOfInteger; + } + + public void setArrayArrayOfInteger(List> arrayArrayOfInteger) { + this.arrayArrayOfInteger = arrayArrayOfInteger; + } + + public ArrayTest arrayArrayOfModel(List> arrayArrayOfModel) { + this.arrayArrayOfModel = arrayArrayOfModel; + return this; + } + + public ArrayTest addArrayArrayOfModelItem(List arrayArrayOfModelItem) { + if (this.arrayArrayOfModel == null) { + this.arrayArrayOfModel = new ArrayList<>(); + } + this.arrayArrayOfModel.add(arrayArrayOfModelItem); + return this; + } + + /** + * Get arrayArrayOfModel + * @return arrayArrayOfModel + */ + @Schema(name = "arrayArrayOfModel", defaultValue = "") + + @Valid + + public List> getArrayArrayOfModel() { + return arrayArrayOfModel; + } + + public void setArrayArrayOfModel(List> arrayArrayOfModel) { + this.arrayArrayOfModel = arrayArrayOfModel; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayTest arrayTest = (ArrayTest) o; + return Objects.equals(this.arrayOfString, arrayTest.arrayOfString) && + Objects.equals(this.arrayArrayOfInteger, arrayTest.arrayArrayOfInteger) && + Objects.equals(this.arrayArrayOfModel, arrayTest.arrayArrayOfModel); + } + + @Override + public int hashCode() { + return Objects.hash(arrayOfString, arrayArrayOfInteger, arrayArrayOfModel); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayTest {\n"); + + sb.append(" arrayOfString: ").append(toIndentedString(arrayOfString)).append("\n"); + sb.append(" arrayArrayOfInteger: ").append(toIndentedString(arrayArrayOfInteger)).append("\n"); + sb.append(" arrayArrayOfModel: ").append(toIndentedString(arrayArrayOfModel)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/BigCat.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/BigCat.java new file mode 100644 index 000000000000..7f4a080ad8d2 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/BigCat.java @@ -0,0 +1,126 @@ +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 org.openapitools.model.BigCatAllOf; +import org.openapitools.model.Cat; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * BigCat + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class BigCat extends Cat { + /** + * Gets or Sets kind + */ + public enum KindEnum { + LIONS("lions"), + + TIGERS("tigers"), + + LEOPARDS("leopards"), + + JAGUARS("jaguars"); + + private String value; + + KindEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static KindEnum fromValue(String value) { + for (KindEnum b : KindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("kind") + private KindEnum kind; + + public BigCat kind(KindEnum kind) { + this.kind = kind; + return this; + } + + /** + * Get kind + * @return kind + */ + @Schema(name = "kind", defaultValue = "") + + + public KindEnum getKind() { + return kind; + } + + public void setKind(KindEnum kind) { + this.kind = kind; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BigCat bigCat = (BigCat) o; + return Objects.equals(this.kind, bigCat.kind) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(kind, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BigCat {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/BigCatAllOf.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/BigCatAllOf.java new file mode 100644 index 000000000000..d0a47ab5127c --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/BigCatAllOf.java @@ -0,0 +1,123 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * BigCatAllOf + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class BigCatAllOf { + /** + * Gets or Sets kind + */ + public enum KindEnum { + LIONS("lions"), + + TIGERS("tigers"), + + LEOPARDS("leopards"), + + JAGUARS("jaguars"); + + private String value; + + KindEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static KindEnum fromValue(String value) { + for (KindEnum b : KindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("kind") + private KindEnum kind; + + public BigCatAllOf kind(KindEnum kind) { + this.kind = kind; + return this; + } + + /** + * Get kind + * @return kind + */ + @Schema(name = "kind", defaultValue = "") + + + public KindEnum getKind() { + return kind; + } + + public void setKind(KindEnum kind) { + this.kind = kind; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BigCatAllOf bigCatAllOf = (BigCatAllOf) o; + return Objects.equals(this.kind, bigCatAllOf.kind); + } + + @Override + public int hashCode() { + return Objects.hash(kind); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BigCatAllOf {\n"); + + sb.append(" kind: ").append(toIndentedString(kind)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Capitalization.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Capitalization.java new file mode 100644 index 000000000000..92d9a7245f16 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Capitalization.java @@ -0,0 +1,208 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Capitalization + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Capitalization { + @JsonProperty("smallCamel") + private String smallCamel; + + @JsonProperty("CapitalCamel") + private String capitalCamel; + + @JsonProperty("small_Snake") + private String smallSnake; + + @JsonProperty("Capital_Snake") + private String capitalSnake; + + @JsonProperty("SCA_ETH_Flow_Points") + private String scAETHFlowPoints; + + @JsonProperty("ATT_NAME") + private String ATT_NAME; + + public Capitalization smallCamel(String smallCamel) { + this.smallCamel = smallCamel; + return this; + } + + /** + * Get smallCamel + * @return smallCamel + */ + @Schema(name = "smallCamel", defaultValue = "") + + + public String getSmallCamel() { + return smallCamel; + } + + public void setSmallCamel(String smallCamel) { + this.smallCamel = smallCamel; + } + + public Capitalization capitalCamel(String capitalCamel) { + this.capitalCamel = capitalCamel; + return this; + } + + /** + * Get capitalCamel + * @return capitalCamel + */ + @Schema(name = "capitalCamel", defaultValue = "") + + + public String getCapitalCamel() { + return capitalCamel; + } + + public void setCapitalCamel(String capitalCamel) { + this.capitalCamel = capitalCamel; + } + + public Capitalization smallSnake(String smallSnake) { + this.smallSnake = smallSnake; + return this; + } + + /** + * Get smallSnake + * @return smallSnake + */ + @Schema(name = "smallSnake", defaultValue = "") + + + public String getSmallSnake() { + return smallSnake; + } + + public void setSmallSnake(String smallSnake) { + this.smallSnake = smallSnake; + } + + public Capitalization capitalSnake(String capitalSnake) { + this.capitalSnake = capitalSnake; + return this; + } + + /** + * Get capitalSnake + * @return capitalSnake + */ + @Schema(name = "capitalSnake", defaultValue = "") + + + public String getCapitalSnake() { + return capitalSnake; + } + + public void setCapitalSnake(String capitalSnake) { + this.capitalSnake = capitalSnake; + } + + public Capitalization scAETHFlowPoints(String scAETHFlowPoints) { + this.scAETHFlowPoints = scAETHFlowPoints; + return this; + } + + /** + * Get scAETHFlowPoints + * @return scAETHFlowPoints + */ + @Schema(name = "scAETHFlowPoints", defaultValue = "") + + + public String getScAETHFlowPoints() { + return scAETHFlowPoints; + } + + public void setScAETHFlowPoints(String scAETHFlowPoints) { + this.scAETHFlowPoints = scAETHFlowPoints; + } + + public Capitalization ATT_NAME(String ATT_NAME) { + this.ATT_NAME = ATT_NAME; + return this; + } + + /** + * Name of the pet + * @return ATT_NAME + */ + @Schema(name = "ATT_NAME", defaultValue = "Name of the pet ") + + + public String getATTNAME() { + return ATT_NAME; + } + + public void setATTNAME(String ATT_NAME) { + this.ATT_NAME = ATT_NAME; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Capitalization capitalization = (Capitalization) o; + return Objects.equals(this.smallCamel, capitalization.smallCamel) && + Objects.equals(this.capitalCamel, capitalization.capitalCamel) && + Objects.equals(this.smallSnake, capitalization.smallSnake) && + Objects.equals(this.capitalSnake, capitalization.capitalSnake) && + Objects.equals(this.scAETHFlowPoints, capitalization.scAETHFlowPoints) && + Objects.equals(this.ATT_NAME, capitalization.ATT_NAME); + } + + @Override + public int hashCode() { + return Objects.hash(smallCamel, capitalCamel, smallSnake, capitalSnake, scAETHFlowPoints, ATT_NAME); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Capitalization {\n"); + + sb.append(" smallCamel: ").append(toIndentedString(smallCamel)).append("\n"); + sb.append(" capitalCamel: ").append(toIndentedString(capitalCamel)).append("\n"); + sb.append(" smallSnake: ").append(toIndentedString(smallSnake)).append("\n"); + sb.append(" capitalSnake: ").append(toIndentedString(capitalSnake)).append("\n"); + sb.append(" scAETHFlowPoints: ").append(toIndentedString(scAETHFlowPoints)).append("\n"); + sb.append(" ATT_NAME: ").append(toIndentedString(ATT_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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Cat.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Cat.java new file mode 100644 index 000000000000..2e496fb4accd --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Cat.java @@ -0,0 +1,86 @@ +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 org.openapitools.model.Animal; +import org.openapitools.model.CatAllOf; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Cat + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Cat extends Animal { + @JsonProperty("declawed") + private Boolean declawed; + + public Cat declawed(Boolean declawed) { + this.declawed = declawed; + return this; + } + + /** + * Get declawed + * @return declawed + */ + @Schema(name = "declawed", defaultValue = "") + + + public Boolean getDeclawed() { + return declawed; + } + + public void setDeclawed(Boolean declawed) { + this.declawed = declawed; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Cat cat = (Cat) o; + return Objects.equals(this.declawed, cat.declawed) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(declawed, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Cat {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" declawed: ").append(toIndentedString(declawed)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/CatAllOf.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/CatAllOf.java new file mode 100644 index 000000000000..b732a62b1bc3 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/CatAllOf.java @@ -0,0 +1,83 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * CatAllOf + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class CatAllOf { + @JsonProperty("declawed") + private Boolean declawed; + + public CatAllOf declawed(Boolean declawed) { + this.declawed = declawed; + return this; + } + + /** + * Get declawed + * @return declawed + */ + @Schema(name = "declawed", defaultValue = "") + + + public Boolean getDeclawed() { + return declawed; + } + + public void setDeclawed(Boolean declawed) { + this.declawed = declawed; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CatAllOf catAllOf = (CatAllOf) o; + return Objects.equals(this.declawed, catAllOf.declawed); + } + + @Override + public int hashCode() { + return Objects.hash(declawed); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CatAllOf {\n"); + + sb.append(" declawed: ").append(toIndentedString(declawed)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Category.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Category.java new file mode 100644 index 000000000000..038fc8df3afd --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Category.java @@ -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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Category + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Category { + @JsonProperty("id") + private Long id; + + @JsonProperty("name") + private String name = "default-name"; + + public Category id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "name", required = true, defaultValue = "") + @NotNull + + + 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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ClassModel.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ClassModel.java new file mode 100644 index 000000000000..fa2a736f4fb5 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ClassModel.java @@ -0,0 +1,84 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Model for testing model with \"_class\" property + */ +@Schema(name = "ClassModel",description = "Model for testing model with \"_class\" property") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ClassModel { + @JsonProperty("_class") + private String propertyClass; + + public ClassModel propertyClass(String propertyClass) { + this.propertyClass = propertyClass; + return this; + } + + /** + * Get propertyClass + * @return propertyClass + */ + @Schema(name = "propertyClass", defaultValue = "") + + + public String getPropertyClass() { + return propertyClass; + } + + public void setPropertyClass(String propertyClass) { + this.propertyClass = propertyClass; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClassModel classModel = (ClassModel) o; + return Objects.equals(this.propertyClass, classModel.propertyClass); + } + + @Override + public int hashCode() { + return Objects.hash(propertyClass); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ClassModel {\n"); + + sb.append(" propertyClass: ").append(toIndentedString(propertyClass)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Client.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Client.java new file mode 100644 index 000000000000..e11bd4ff1b13 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Client.java @@ -0,0 +1,83 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Client + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Client { + @JsonProperty("client") + private String client; + + public Client client(String client) { + this.client = client; + return this; + } + + /** + * Get client + * @return client + */ + @Schema(name = "client", defaultValue = "") + + + public String getClient() { + return client; + } + + public void setClient(String client) { + this.client = client; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Client client = (Client) o; + return Objects.equals(this.client, client.client); + } + + @Override + public int hashCode() { + return Objects.hash(client); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Client {\n"); + + sb.append(" client: ").append(toIndentedString(client)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Dog.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Dog.java new file mode 100644 index 000000000000..ed5dc71a4ba2 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Dog.java @@ -0,0 +1,86 @@ +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 org.openapitools.model.Animal; +import org.openapitools.model.DogAllOf; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Dog + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Dog extends Animal { + @JsonProperty("breed") + private String breed; + + public Dog breed(String breed) { + this.breed = breed; + return this; + } + + /** + * Get breed + * @return breed + */ + @Schema(name = "breed", defaultValue = "") + + + public String getBreed() { + return breed; + } + + public void setBreed(String breed) { + this.breed = breed; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Dog dog = (Dog) o; + return Objects.equals(this.breed, dog.breed) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(breed, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Dog {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" breed: ").append(toIndentedString(breed)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/DogAllOf.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/DogAllOf.java new file mode 100644 index 000000000000..2c99bc376c34 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/DogAllOf.java @@ -0,0 +1,83 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * DogAllOf + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class DogAllOf { + @JsonProperty("breed") + private String breed; + + public DogAllOf breed(String breed) { + this.breed = breed; + return this; + } + + /** + * Get breed + * @return breed + */ + @Schema(name = "breed", defaultValue = "") + + + public String getBreed() { + return breed; + } + + public void setBreed(String breed) { + this.breed = breed; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DogAllOf dogAllOf = (DogAllOf) o; + return Objects.equals(this.breed, dogAllOf.breed); + } + + @Override + public int hashCode() { + return Objects.hash(breed); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DogAllOf {\n"); + + sb.append(" breed: ").append(toIndentedString(breed)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/EnumArrays.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/EnumArrays.java new file mode 100644 index 000000000000..e1b2df0716a2 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/EnumArrays.java @@ -0,0 +1,190 @@ +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 java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * EnumArrays + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class EnumArrays { + /** + * Gets or Sets justSymbol + */ + public enum JustSymbolEnum { + GREATER_THAN_OR_EQUAL_TO(">="), + + DOLLAR("$"); + + private String value; + + JustSymbolEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static JustSymbolEnum fromValue(String value) { + for (JustSymbolEnum b : JustSymbolEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("just_symbol") + private JustSymbolEnum justSymbol; + + /** + * Gets or Sets arrayEnum + */ + public enum ArrayEnumEnum { + FISH("fish"), + + CRAB("crab"); + + private String value; + + ArrayEnumEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static ArrayEnumEnum fromValue(String value) { + for (ArrayEnumEnum b : ArrayEnumEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("array_enum") + @Valid + private List arrayEnum = null; + + public EnumArrays justSymbol(JustSymbolEnum justSymbol) { + this.justSymbol = justSymbol; + return this; + } + + /** + * Get justSymbol + * @return justSymbol + */ + @Schema(name = "justSymbol", defaultValue = "") + + + public JustSymbolEnum getJustSymbol() { + return justSymbol; + } + + public void setJustSymbol(JustSymbolEnum justSymbol) { + this.justSymbol = justSymbol; + } + + public EnumArrays arrayEnum(List arrayEnum) { + this.arrayEnum = arrayEnum; + return this; + } + + public EnumArrays addArrayEnumItem(ArrayEnumEnum arrayEnumItem) { + if (this.arrayEnum == null) { + this.arrayEnum = new ArrayList<>(); + } + this.arrayEnum.add(arrayEnumItem); + return this; + } + + /** + * Get arrayEnum + * @return arrayEnum + */ + @Schema(name = "arrayEnum", defaultValue = "") + + + public List getArrayEnum() { + return arrayEnum; + } + + public void setArrayEnum(List arrayEnum) { + this.arrayEnum = arrayEnum; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EnumArrays enumArrays = (EnumArrays) o; + return Objects.equals(this.justSymbol, enumArrays.justSymbol) && + Objects.equals(this.arrayEnum, enumArrays.arrayEnum); + } + + @Override + public int hashCode() { + return Objects.hash(justSymbol, arrayEnum); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EnumArrays {\n"); + + sb.append(" justSymbol: ").append(toIndentedString(justSymbol)).append("\n"); + sb.append(" arrayEnum: ").append(toIndentedString(arrayEnum)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/EnumClass.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/EnumClass.java new file mode 100644 index 000000000000..e3d30c1ad453 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/EnumClass.java @@ -0,0 +1,55 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Gets or Sets EnumClass + */ +public enum EnumClass { + + _ABC("_abc"), + + _EFG("-efg"), + + _XYZ_("(xyz)"); + + private String value; + + EnumClass(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumClass fromValue(String value) { + for (EnumClass b : EnumClass.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/EnumTest.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/EnumTest.java new file mode 100644 index 000000000000..938af53e2b81 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/EnumTest.java @@ -0,0 +1,331 @@ +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 org.openapitools.model.OuterEnum; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * EnumTest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class EnumTest { + /** + * Gets or Sets enumString + */ + public enum EnumStringEnum { + UPPER("UPPER"), + + LOWER("lower"), + + EMPTY(""); + + private String value; + + EnumStringEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumStringEnum fromValue(String value) { + for (EnumStringEnum b : EnumStringEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("enum_string") + private EnumStringEnum enumString; + + /** + * Gets or Sets enumStringRequired + */ + public enum EnumStringRequiredEnum { + UPPER("UPPER"), + + LOWER("lower"), + + EMPTY(""); + + private String value; + + EnumStringRequiredEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumStringRequiredEnum fromValue(String value) { + for (EnumStringRequiredEnum b : EnumStringRequiredEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("enum_string_required") + private EnumStringRequiredEnum enumStringRequired; + + /** + * Gets or Sets enumInteger + */ + public enum EnumIntegerEnum { + NUMBER_1(1), + + NUMBER_MINUS_1(-1); + + private Integer value; + + EnumIntegerEnum(Integer value) { + this.value = value; + } + + @JsonValue + public Integer getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumIntegerEnum fromValue(Integer value) { + for (EnumIntegerEnum b : EnumIntegerEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("enum_integer") + private EnumIntegerEnum enumInteger; + + /** + * Gets or Sets enumNumber + */ + public enum EnumNumberEnum { + NUMBER_1_DOT_1(1.1), + + NUMBER_MINUS_1_DOT_2(-1.2); + + private Double value; + + EnumNumberEnum(Double value) { + this.value = value; + } + + @JsonValue + public Double getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumNumberEnum fromValue(Double value) { + for (EnumNumberEnum b : EnumNumberEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("enum_number") + private EnumNumberEnum enumNumber; + + @JsonProperty("outerEnum") + private OuterEnum outerEnum; + + public EnumTest enumString(EnumStringEnum enumString) { + this.enumString = enumString; + return this; + } + + /** + * Get enumString + * @return enumString + */ + @Schema(name = "enumString", defaultValue = "") + + + public EnumStringEnum getEnumString() { + return enumString; + } + + public void setEnumString(EnumStringEnum enumString) { + this.enumString = enumString; + } + + public EnumTest enumStringRequired(EnumStringRequiredEnum enumStringRequired) { + this.enumStringRequired = enumStringRequired; + return this; + } + + /** + * Get enumStringRequired + * @return enumStringRequired + */ + @Schema(name = "enumStringRequired", required = true, defaultValue = "") + @NotNull + + + public EnumStringRequiredEnum getEnumStringRequired() { + return enumStringRequired; + } + + public void setEnumStringRequired(EnumStringRequiredEnum enumStringRequired) { + this.enumStringRequired = enumStringRequired; + } + + public EnumTest enumInteger(EnumIntegerEnum enumInteger) { + this.enumInteger = enumInteger; + return this; + } + + /** + * Get enumInteger + * @return enumInteger + */ + @Schema(name = "enumInteger", defaultValue = "") + + + public EnumIntegerEnum getEnumInteger() { + return enumInteger; + } + + public void setEnumInteger(EnumIntegerEnum enumInteger) { + this.enumInteger = enumInteger; + } + + public EnumTest enumNumber(EnumNumberEnum enumNumber) { + this.enumNumber = enumNumber; + return this; + } + + /** + * Get enumNumber + * @return enumNumber + */ + @Schema(name = "enumNumber", defaultValue = "") + + + public EnumNumberEnum getEnumNumber() { + return enumNumber; + } + + public void setEnumNumber(EnumNumberEnum enumNumber) { + this.enumNumber = enumNumber; + } + + public EnumTest outerEnum(OuterEnum outerEnum) { + this.outerEnum = outerEnum; + return this; + } + + /** + * Get outerEnum + * @return outerEnum + */ + @Schema(name = "outerEnum", defaultValue = "") + + @Valid + + public OuterEnum getOuterEnum() { + return outerEnum; + } + + public void setOuterEnum(OuterEnum outerEnum) { + this.outerEnum = outerEnum; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EnumTest enumTest = (EnumTest) o; + return Objects.equals(this.enumString, enumTest.enumString) && + Objects.equals(this.enumStringRequired, enumTest.enumStringRequired) && + Objects.equals(this.enumInteger, enumTest.enumInteger) && + Objects.equals(this.enumNumber, enumTest.enumNumber) && + Objects.equals(this.outerEnum, enumTest.outerEnum); + } + + @Override + public int hashCode() { + return Objects.hash(enumString, enumStringRequired, enumInteger, enumNumber, outerEnum); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EnumTest {\n"); + + sb.append(" enumString: ").append(toIndentedString(enumString)).append("\n"); + sb.append(" enumStringRequired: ").append(toIndentedString(enumStringRequired)).append("\n"); + sb.append(" enumInteger: ").append(toIndentedString(enumInteger)).append("\n"); + sb.append(" enumNumber: ").append(toIndentedString(enumNumber)).append("\n"); + sb.append(" outerEnum: ").append(toIndentedString(outerEnum)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/FileSchemaTestClass.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/FileSchemaTestClass.java new file mode 100644 index 000000000000..0d1e9ca8495c --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/FileSchemaTestClass.java @@ -0,0 +1,121 @@ +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 java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * FileSchemaTestClass + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class FileSchemaTestClass { + @JsonProperty("file") + private java.io.File file; + + @JsonProperty("files") + @Valid + private List files = null; + + public FileSchemaTestClass file(java.io.File file) { + this.file = file; + return this; + } + + /** + * Get file + * @return file + */ + @Schema(name = "file", defaultValue = "") + + @Valid + + public java.io.File getFile() { + return file; + } + + public void setFile(java.io.File file) { + this.file = file; + } + + public FileSchemaTestClass files(List files) { + this.files = files; + return this; + } + + public FileSchemaTestClass addFilesItem(java.io.File filesItem) { + if (this.files == null) { + this.files = new ArrayList<>(); + } + this.files.add(filesItem); + return this; + } + + /** + * Get files + * @return files + */ + @Schema(name = "files", defaultValue = "") + + @Valid + + public List getFiles() { + return files; + } + + public void setFiles(List files) { + this.files = files; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FileSchemaTestClass fileSchemaTestClass = (FileSchemaTestClass) o; + return Objects.equals(this.file, fileSchemaTestClass.file) && + Objects.equals(this.files, fileSchemaTestClass.files); + } + + @Override + public int hashCode() { + return Objects.hash(file, files); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FileSchemaTestClass {\n"); + + sb.append(" file: ").append(toIndentedString(file)).append("\n"); + sb.append(" files: ").append(toIndentedString(files)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/FormatTest.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/FormatTest.java new file mode 100644 index 000000000000..6546370cd329 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/FormatTest.java @@ -0,0 +1,435 @@ +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 java.math.BigDecimal; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.UUID; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * FormatTest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class FormatTest { + @JsonProperty("integer") + private Integer integer; + + @JsonProperty("int32") + private Integer int32; + + @JsonProperty("int64") + private Long int64; + + @JsonProperty("number") + private BigDecimal number; + + @JsonProperty("float") + private Float _float; + + @JsonProperty("double") + private Double _double; + + @JsonProperty("string") + private String string; + + @JsonProperty("byte") + private byte[] _byte; + + @JsonProperty("binary") + private org.springframework.core.io.Resource binary; + + @JsonProperty("date") + @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) + private LocalDate date; + + @JsonProperty("dateTime") + @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) + private OffsetDateTime dateTime; + + @JsonProperty("uuid") + private UUID uuid; + + @JsonProperty("password") + private String password; + + @JsonProperty("BigDecimal") + private BigDecimal bigDecimal; + + public FormatTest integer(Integer integer) { + this.integer = integer; + return this; + } + + /** + * Get integer + * minimum: 10 + * maximum: 100 + * @return integer + */ + @Schema(name = "integer", defaultValue = "") + +@Min(10) @Max(100) + public Integer getInteger() { + return integer; + } + + public void setInteger(Integer integer) { + this.integer = integer; + } + + public FormatTest int32(Integer int32) { + this.int32 = int32; + return this; + } + + /** + * Get int32 + * minimum: 20 + * maximum: 200 + * @return int32 + */ + @Schema(name = "int32", defaultValue = "") + +@Min(20) @Max(200) + public Integer getInt32() { + return int32; + } + + public void setInt32(Integer int32) { + this.int32 = int32; + } + + public FormatTest int64(Long int64) { + this.int64 = int64; + return this; + } + + /** + * Get int64 + * @return int64 + */ + @Schema(name = "int64", defaultValue = "") + + + public Long getInt64() { + return int64; + } + + public void setInt64(Long int64) { + this.int64 = int64; + } + + public FormatTest number(BigDecimal number) { + this.number = number; + return this; + } + + /** + * Get number + * minimum: 32.1 + * maximum: 543.2 + * @return number + */ + @Schema(name = "number", required = true, defaultValue = "") + @NotNull + + @Valid +@DecimalMin("32.1") @DecimalMax("543.2") + public BigDecimal getNumber() { + return number; + } + + public void setNumber(BigDecimal number) { + this.number = number; + } + + public FormatTest _float(Float _float) { + this._float = _float; + return this; + } + + /** + * Get _float + * minimum: 54.3 + * maximum: 987.6 + * @return _float + */ + @Schema(name = "_float", defaultValue = "") + +@DecimalMin("54.3") @DecimalMax("987.6") + public Float getFloat() { + return _float; + } + + public void setFloat(Float _float) { + this._float = _float; + } + + public FormatTest _double(Double _double) { + this._double = _double; + return this; + } + + /** + * Get _double + * minimum: 67.8 + * maximum: 123.4 + * @return _double + */ + @Schema(name = "_double", defaultValue = "") + +@DecimalMin("67.8") @DecimalMax("123.4") + public Double getDouble() { + return _double; + } + + public void setDouble(Double _double) { + this._double = _double; + } + + public FormatTest string(String string) { + this.string = string; + return this; + } + + /** + * Get string + * @return string + */ + @Schema(name = "string", defaultValue = "") + +@Pattern(regexp = "/[a-z]/i") + public String getString() { + return string; + } + + public void setString(String string) { + this.string = string; + } + + public FormatTest _byte(byte[] _byte) { + this._byte = _byte; + return this; + } + + /** + * Get _byte + * @return _byte + */ + @Schema(name = "_byte", required = true, defaultValue = "") + @NotNull + + + public byte[] getByte() { + return _byte; + } + + public void setByte(byte[] _byte) { + this._byte = _byte; + } + + public FormatTest binary(org.springframework.core.io.Resource binary) { + this.binary = binary; + return this; + } + + /** + * Get binary + * @return binary + */ + @Schema(name = "binary", defaultValue = "") + + @Valid + + public org.springframework.core.io.Resource getBinary() { + return binary; + } + + public void setBinary(org.springframework.core.io.Resource binary) { + this.binary = binary; + } + + public FormatTest date(LocalDate date) { + this.date = date; + return this; + } + + /** + * Get date + * @return date + */ + @Schema(name = "date", required = true, defaultValue = "") + @NotNull + + @Valid + + public LocalDate getDate() { + return date; + } + + public void setDate(LocalDate date) { + this.date = date; + } + + public FormatTest dateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + return this; + } + + /** + * Get dateTime + * @return dateTime + */ + @Schema(name = "dateTime", defaultValue = "") + + @Valid + + public OffsetDateTime getDateTime() { + return dateTime; + } + + public void setDateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + } + + public FormatTest uuid(UUID uuid) { + this.uuid = uuid; + return this; + } + + /** + * Get uuid + * @return uuid + */ + @Schema(name = "uuid", example = "72f98069-206d-4f12-9f12-3d1e525a8e84", defaultValue = "") + + @Valid + + public UUID getUuid() { + return uuid; + } + + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + public FormatTest password(String password) { + this.password = password; + return this; + } + + /** + * Get password + * @return password + */ + @Schema(name = "password", required = true, defaultValue = "") + @NotNull + +@Size(min = 10, max = 64) + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public FormatTest bigDecimal(BigDecimal bigDecimal) { + this.bigDecimal = bigDecimal; + return this; + } + + /** + * Get bigDecimal + * @return bigDecimal + */ + @Schema(name = "bigDecimal", defaultValue = "") + + @Valid + + public BigDecimal getBigDecimal() { + return bigDecimal; + } + + public void setBigDecimal(BigDecimal bigDecimal) { + this.bigDecimal = bigDecimal; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FormatTest formatTest = (FormatTest) o; + return Objects.equals(this.integer, formatTest.integer) && + Objects.equals(this.int32, formatTest.int32) && + Objects.equals(this.int64, formatTest.int64) && + Objects.equals(this.number, formatTest.number) && + Objects.equals(this._float, formatTest._float) && + Objects.equals(this._double, formatTest._double) && + Objects.equals(this.string, formatTest.string) && + Arrays.equals(this._byte, formatTest._byte) && + Objects.equals(this.binary, formatTest.binary) && + Objects.equals(this.date, formatTest.date) && + Objects.equals(this.dateTime, formatTest.dateTime) && + Objects.equals(this.uuid, formatTest.uuid) && + Objects.equals(this.password, formatTest.password) && + Objects.equals(this.bigDecimal, formatTest.bigDecimal); + } + + @Override + public int hashCode() { + return Objects.hash(integer, int32, int64, number, _float, _double, string, Arrays.hashCode(_byte), binary, date, dateTime, uuid, password, bigDecimal); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FormatTest {\n"); + + sb.append(" integer: ").append(toIndentedString(integer)).append("\n"); + sb.append(" int32: ").append(toIndentedString(int32)).append("\n"); + sb.append(" int64: ").append(toIndentedString(int64)).append("\n"); + sb.append(" number: ").append(toIndentedString(number)).append("\n"); + sb.append(" _float: ").append(toIndentedString(_float)).append("\n"); + sb.append(" _double: ").append(toIndentedString(_double)).append("\n"); + sb.append(" string: ").append(toIndentedString(string)).append("\n"); + sb.append(" _byte: ").append(toIndentedString(_byte)).append("\n"); + sb.append(" binary: ").append(toIndentedString(binary)).append("\n"); + sb.append(" date: ").append(toIndentedString(date)).append("\n"); + sb.append(" dateTime: ").append(toIndentedString(dateTime)).append("\n"); + sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" bigDecimal: ").append(toIndentedString(bigDecimal)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/HasOnlyReadOnly.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/HasOnlyReadOnly.java new file mode 100644 index 000000000000..dfb615a529fc --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/HasOnlyReadOnly.java @@ -0,0 +1,108 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * HasOnlyReadOnly + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class HasOnlyReadOnly { + @JsonProperty("bar") + private String bar; + + @JsonProperty("foo") + private String foo; + + public HasOnlyReadOnly bar(String bar) { + this.bar = bar; + return this; + } + + /** + * Get bar + * @return bar + */ + @Schema(name = "bar", readOnly = true, defaultValue = "") + + + public String getBar() { + return bar; + } + + public void setBar(String bar) { + this.bar = bar; + } + + public HasOnlyReadOnly foo(String foo) { + this.foo = foo; + return this; + } + + /** + * Get foo + * @return foo + */ + @Schema(name = "foo", readOnly = true, defaultValue = "") + + + public String getFoo() { + return foo; + } + + public void setFoo(String foo) { + this.foo = foo; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HasOnlyReadOnly hasOnlyReadOnly = (HasOnlyReadOnly) o; + return Objects.equals(this.bar, hasOnlyReadOnly.bar) && + Objects.equals(this.foo, hasOnlyReadOnly.foo); + } + + @Override + public int hashCode() { + return Objects.hash(bar, foo); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class HasOnlyReadOnly {\n"); + + sb.append(" bar: ").append(toIndentedString(bar)).append("\n"); + sb.append(" foo: ").append(toIndentedString(foo)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/MapTest.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/MapTest.java new file mode 100644 index 000000000000..3ff73062758f --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/MapTest.java @@ -0,0 +1,234 @@ +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 java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * MapTest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class MapTest { + @JsonProperty("map_map_of_string") + @Valid + private Map> mapMapOfString = null; + + /** + * Gets or Sets inner + */ + public enum InnerEnum { + UPPER("UPPER"), + + LOWER("lower"); + + private String value; + + InnerEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static InnerEnum fromValue(String value) { + for (InnerEnum b : InnerEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("map_of_enum_string") + @Valid + private Map mapOfEnumString = null; + + @JsonProperty("direct_map") + @Valid + private Map directMap = null; + + @JsonProperty("indirect_map") + @Valid + private Map indirectMap = null; + + public MapTest mapMapOfString(Map> mapMapOfString) { + this.mapMapOfString = mapMapOfString; + return this; + } + + public MapTest putMapMapOfStringItem(String key, Map mapMapOfStringItem) { + if (this.mapMapOfString == null) { + this.mapMapOfString = new HashMap<>(); + } + this.mapMapOfString.put(key, mapMapOfStringItem); + return this; + } + + /** + * Get mapMapOfString + * @return mapMapOfString + */ + @Schema(name = "mapMapOfString", defaultValue = "") + + @Valid + + public Map> getMapMapOfString() { + return mapMapOfString; + } + + public void setMapMapOfString(Map> mapMapOfString) { + this.mapMapOfString = mapMapOfString; + } + + public MapTest mapOfEnumString(Map mapOfEnumString) { + this.mapOfEnumString = mapOfEnumString; + return this; + } + + public MapTest putMapOfEnumStringItem(String key, InnerEnum mapOfEnumStringItem) { + if (this.mapOfEnumString == null) { + this.mapOfEnumString = new HashMap<>(); + } + this.mapOfEnumString.put(key, mapOfEnumStringItem); + return this; + } + + /** + * Get mapOfEnumString + * @return mapOfEnumString + */ + @Schema(name = "mapOfEnumString", defaultValue = "") + + + public Map getMapOfEnumString() { + return mapOfEnumString; + } + + public void setMapOfEnumString(Map mapOfEnumString) { + this.mapOfEnumString = mapOfEnumString; + } + + public MapTest directMap(Map directMap) { + this.directMap = directMap; + return this; + } + + public MapTest putDirectMapItem(String key, Boolean directMapItem) { + if (this.directMap == null) { + this.directMap = new HashMap<>(); + } + this.directMap.put(key, directMapItem); + return this; + } + + /** + * Get directMap + * @return directMap + */ + @Schema(name = "directMap", defaultValue = "") + + + public Map getDirectMap() { + return directMap; + } + + public void setDirectMap(Map directMap) { + this.directMap = directMap; + } + + public MapTest indirectMap(Map indirectMap) { + this.indirectMap = indirectMap; + return this; + } + + public MapTest putIndirectMapItem(String key, Boolean indirectMapItem) { + if (this.indirectMap == null) { + this.indirectMap = new HashMap<>(); + } + this.indirectMap.put(key, indirectMapItem); + return this; + } + + /** + * Get indirectMap + * @return indirectMap + */ + @Schema(name = "indirectMap", defaultValue = "") + + + public Map getIndirectMap() { + return indirectMap; + } + + public void setIndirectMap(Map indirectMap) { + this.indirectMap = indirectMap; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MapTest mapTest = (MapTest) o; + return Objects.equals(this.mapMapOfString, mapTest.mapMapOfString) && + Objects.equals(this.mapOfEnumString, mapTest.mapOfEnumString) && + Objects.equals(this.directMap, mapTest.directMap) && + Objects.equals(this.indirectMap, mapTest.indirectMap); + } + + @Override + public int hashCode() { + return Objects.hash(mapMapOfString, mapOfEnumString, directMap, indirectMap); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MapTest {\n"); + + sb.append(" mapMapOfString: ").append(toIndentedString(mapMapOfString)).append("\n"); + sb.append(" mapOfEnumString: ").append(toIndentedString(mapOfEnumString)).append("\n"); + sb.append(" directMap: ").append(toIndentedString(directMap)).append("\n"); + sb.append(" indirectMap: ").append(toIndentedString(indirectMap)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java new file mode 100644 index 000000000000..03a7be43cc4a --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java @@ -0,0 +1,152 @@ +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 java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import org.openapitools.model.Animal; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * MixedPropertiesAndAdditionalPropertiesClass + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class MixedPropertiesAndAdditionalPropertiesClass { + @JsonProperty("uuid") + private UUID uuid; + + @JsonProperty("dateTime") + @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) + private OffsetDateTime dateTime; + + @JsonProperty("map") + @Valid + private Map map = null; + + public MixedPropertiesAndAdditionalPropertiesClass uuid(UUID uuid) { + this.uuid = uuid; + return this; + } + + /** + * Get uuid + * @return uuid + */ + @Schema(name = "uuid", defaultValue = "") + + @Valid + + public UUID getUuid() { + return uuid; + } + + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + public MixedPropertiesAndAdditionalPropertiesClass dateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + return this; + } + + /** + * Get dateTime + * @return dateTime + */ + @Schema(name = "dateTime", defaultValue = "") + + @Valid + + public OffsetDateTime getDateTime() { + return dateTime; + } + + public void setDateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + } + + public MixedPropertiesAndAdditionalPropertiesClass map(Map map) { + this.map = map; + return this; + } + + public MixedPropertiesAndAdditionalPropertiesClass putMapItem(String key, Animal mapItem) { + if (this.map == null) { + this.map = new HashMap<>(); + } + this.map.put(key, mapItem); + return this; + } + + /** + * Get map + * @return map + */ + @Schema(name = "map", defaultValue = "") + + @Valid + + public Map getMap() { + return map; + } + + public void setMap(Map map) { + this.map = map; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass = (MixedPropertiesAndAdditionalPropertiesClass) o; + return Objects.equals(this.uuid, mixedPropertiesAndAdditionalPropertiesClass.uuid) && + Objects.equals(this.dateTime, mixedPropertiesAndAdditionalPropertiesClass.dateTime) && + Objects.equals(this.map, mixedPropertiesAndAdditionalPropertiesClass.map); + } + + @Override + public int hashCode() { + return Objects.hash(uuid, dateTime, map); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MixedPropertiesAndAdditionalPropertiesClass {\n"); + + sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); + sb.append(" dateTime: ").append(toIndentedString(dateTime)).append("\n"); + sb.append(" map: ").append(toIndentedString(map)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Model200Response.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Model200Response.java new file mode 100644 index 000000000000..77bf91649b08 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Model200Response.java @@ -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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Model for testing model name starting with number + */ +@Schema(name = "200_response",description = "Model for testing model name starting with number") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Model200Response { + @JsonProperty("name") + private Integer name; + + @JsonProperty("class") + private String propertyClass; + + public Model200Response name(Integer name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + public Integer getName() { + return name; + } + + public void setName(Integer name) { + this.name = name; + } + + public Model200Response propertyClass(String propertyClass) { + this.propertyClass = propertyClass; + return this; + } + + /** + * Get propertyClass + * @return propertyClass + */ + @Schema(name = "propertyClass", defaultValue = "") + + + public String getPropertyClass() { + return propertyClass; + } + + public void setPropertyClass(String propertyClass) { + this.propertyClass = propertyClass; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Model200Response _200response = (Model200Response) o; + return Objects.equals(this.name, _200response.name) && + Objects.equals(this.propertyClass, _200response.propertyClass); + } + + @Override + public int hashCode() { + return Objects.hash(name, propertyClass); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Model200Response {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" propertyClass: ").append(toIndentedString(propertyClass)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ModelApiResponse.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ModelApiResponse.java new file mode 100644 index 000000000000..2443600df226 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ModelApiResponse.java @@ -0,0 +1,133 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ModelApiResponse + */ +@javax.annotation.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 + */ + @Schema(name = "code", defaultValue = "") + + + 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 + */ + @Schema(name = "type", defaultValue = "") + + + 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 + */ + @Schema(name = "message", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ModelReturn.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ModelReturn.java new file mode 100644 index 000000000000..0301a47e9f3e --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ModelReturn.java @@ -0,0 +1,84 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Model for testing reserved words + */ +@Schema(name = "Return",description = "Model for testing reserved words") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ModelReturn { + @JsonProperty("return") + private Integer _return; + + public ModelReturn _return(Integer _return) { + this._return = _return; + return this; + } + + /** + * Get _return + * @return _return + */ + @Schema(name = "_return", defaultValue = "") + + + public Integer getReturn() { + return _return; + } + + public void setReturn(Integer _return) { + this._return = _return; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelReturn _return = (ModelReturn) o; + return Objects.equals(this._return, _return._return); + } + + @Override + public int hashCode() { + return Objects.hash(_return); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelReturn {\n"); + + sb.append(" _return: ").append(toIndentedString(_return)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Name.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Name.java new file mode 100644 index 000000000000..62a16f80ee07 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Name.java @@ -0,0 +1,160 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Model for testing model name same as property name + */ +@Schema(name = "Name",description = "Model for testing model name same as property name") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Name { + @JsonProperty("name") + private Integer name; + + @JsonProperty("snake_case") + private Integer snakeCase; + + @JsonProperty("property") + private String property; + + @JsonProperty("123Number") + private Integer _123number; + + public Name name(Integer name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", required = true, defaultValue = "") + @NotNull + + + public Integer getName() { + return name; + } + + public void setName(Integer name) { + this.name = name; + } + + public Name snakeCase(Integer snakeCase) { + this.snakeCase = snakeCase; + return this; + } + + /** + * Get snakeCase + * @return snakeCase + */ + @Schema(name = "snakeCase", readOnly = true, defaultValue = "") + + + public Integer getSnakeCase() { + return snakeCase; + } + + public void setSnakeCase(Integer snakeCase) { + this.snakeCase = snakeCase; + } + + public Name property(String property) { + this.property = property; + return this; + } + + /** + * Get property + * @return property + */ + @Schema(name = "property", defaultValue = "") + + + public String getProperty() { + return property; + } + + public void setProperty(String property) { + this.property = property; + } + + public Name _123number(Integer _123number) { + this._123number = _123number; + return this; + } + + /** + * Get _123number + * @return _123number + */ + @Schema(name = "_123number", readOnly = true, defaultValue = "") + + + public Integer get123number() { + return _123number; + } + + public void set123number(Integer _123number) { + this._123number = _123number; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Name name = (Name) o; + return Objects.equals(this.name, name.name) && + Objects.equals(this.snakeCase, name.snakeCase) && + Objects.equals(this.property, name.property) && + Objects.equals(this._123number, name._123number); + } + + @Override + public int hashCode() { + return Objects.hash(name, snakeCase, property, _123number); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Name {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n"); + sb.append(" property: ").append(toIndentedString(property)).append("\n"); + sb.append(" _123number: ").append(toIndentedString(_123number)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/NumberOnly.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/NumberOnly.java new file mode 100644 index 000000000000..521fad80d5a7 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/NumberOnly.java @@ -0,0 +1,85 @@ +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 java.math.BigDecimal; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * NumberOnly + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class NumberOnly { + @JsonProperty("JustNumber") + private BigDecimal justNumber; + + public NumberOnly justNumber(BigDecimal justNumber) { + this.justNumber = justNumber; + return this; + } + + /** + * Get justNumber + * @return justNumber + */ + @Schema(name = "justNumber", defaultValue = "") + + @Valid + + public BigDecimal getJustNumber() { + return justNumber; + } + + public void setJustNumber(BigDecimal justNumber) { + this.justNumber = justNumber; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NumberOnly numberOnly = (NumberOnly) o; + return Objects.equals(this.justNumber, numberOnly.justNumber); + } + + @Override + public int hashCode() { + return Objects.hash(justNumber); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NumberOnly {\n"); + + sb.append(" justNumber: ").append(toIndentedString(justNumber)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Order.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Order.java new file mode 100644 index 000000000000..05071bdfe2bf --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Order.java @@ -0,0 +1,249 @@ +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 java.time.OffsetDateTime; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Order + */ +@javax.annotation.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") + @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "petId", defaultValue = "") + + + 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 + */ + @Schema(name = "quantity", defaultValue = "") + + + 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 + */ + @Schema(name = "shipDate", defaultValue = "") + + @Valid + + 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 + */ + @Schema(name = "status", defaultValue = "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 + */ + @Schema(name = "complete", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/OuterComposite.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/OuterComposite.java new file mode 100644 index 000000000000..a721a3dde6a0 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/OuterComposite.java @@ -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 java.math.BigDecimal; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * OuterComposite + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class OuterComposite { + @JsonProperty("my_number") + private BigDecimal myNumber; + + @JsonProperty("my_string") + private String myString; + + @JsonProperty("my_boolean") + private Boolean myBoolean; + + public OuterComposite myNumber(BigDecimal myNumber) { + this.myNumber = myNumber; + return this; + } + + /** + * Get myNumber + * @return myNumber + */ + @Schema(name = "myNumber", defaultValue = "") + + @Valid + + public BigDecimal getMyNumber() { + return myNumber; + } + + public void setMyNumber(BigDecimal myNumber) { + this.myNumber = myNumber; + } + + public OuterComposite myString(String myString) { + this.myString = myString; + return this; + } + + /** + * Get myString + * @return myString + */ + @Schema(name = "myString", defaultValue = "") + + + public String getMyString() { + return myString; + } + + public void setMyString(String myString) { + this.myString = myString; + } + + public OuterComposite myBoolean(Boolean myBoolean) { + this.myBoolean = myBoolean; + return this; + } + + /** + * Get myBoolean + * @return myBoolean + */ + @Schema(name = "myBoolean", defaultValue = "") + + + public Boolean getMyBoolean() { + return myBoolean; + } + + public void setMyBoolean(Boolean myBoolean) { + this.myBoolean = myBoolean; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OuterComposite outerComposite = (OuterComposite) o; + return Objects.equals(this.myNumber, outerComposite.myNumber) && + Objects.equals(this.myString, outerComposite.myString) && + Objects.equals(this.myBoolean, outerComposite.myBoolean); + } + + @Override + public int hashCode() { + return Objects.hash(myNumber, myString, myBoolean); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OuterComposite {\n"); + + sb.append(" myNumber: ").append(toIndentedString(myNumber)).append("\n"); + sb.append(" myString: ").append(toIndentedString(myString)).append("\n"); + sb.append(" myBoolean: ").append(toIndentedString(myBoolean)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/OuterEnum.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/OuterEnum.java new file mode 100644 index 000000000000..ba0cca8a5e81 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/OuterEnum.java @@ -0,0 +1,55 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Gets or Sets OuterEnum + */ +public enum OuterEnum { + + PLACED("placed"), + + APPROVED("approved"), + + DELIVERED("delivered"); + + private String value; + + OuterEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static OuterEnum fromValue(String value) { + for (OuterEnum b : OuterEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Pet.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Pet.java new file mode 100644 index 000000000000..988eb317134d --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Pet.java @@ -0,0 +1,273 @@ +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 com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +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 io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Pet + */ +@javax.annotation.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 Set photoUrls = new LinkedHashSet<>(); + + @JsonProperty("tags") + @Valid + private List 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; + + public Pet id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "category", defaultValue = "") + + @Valid + + 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 + */ + @Schema(name = "name", example = "doggie", required = true, defaultValue = "") + @NotNull + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Pet photoUrls(Set photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + public Pet addPhotoUrlsItem(String photoUrlsItem) { + this.photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get photoUrls + * @return photoUrls + */ + @Schema(name = "photoUrls", required = true, defaultValue = "") + @NotNull + + + public Set getPhotoUrls() { + return photoUrls; + } + + @JsonDeserialize(as = LinkedHashSet.class) + public void setPhotoUrls(Set photoUrls) { + this.photoUrls = photoUrls; + } + + public Pet tags(List 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 + */ + @Schema(name = "tags", defaultValue = "") + + @Valid + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * pet status in the store + * @return status + */ + @Schema(name = "status", defaultValue = "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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ReadOnlyFirst.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ReadOnlyFirst.java new file mode 100644 index 000000000000..1c51770a8e66 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ReadOnlyFirst.java @@ -0,0 +1,108 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ReadOnlyFirst + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ReadOnlyFirst { + @JsonProperty("bar") + private String bar; + + @JsonProperty("baz") + private String baz; + + public ReadOnlyFirst bar(String bar) { + this.bar = bar; + return this; + } + + /** + * Get bar + * @return bar + */ + @Schema(name = "bar", readOnly = true, defaultValue = "") + + + public String getBar() { + return bar; + } + + public void setBar(String bar) { + this.bar = bar; + } + + public ReadOnlyFirst baz(String baz) { + this.baz = baz; + return this; + } + + /** + * Get baz + * @return baz + */ + @Schema(name = "baz", defaultValue = "") + + + public String getBaz() { + return baz; + } + + public void setBaz(String baz) { + this.baz = baz; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReadOnlyFirst readOnlyFirst = (ReadOnlyFirst) o; + return Objects.equals(this.bar, readOnlyFirst.bar) && + Objects.equals(this.baz, readOnlyFirst.baz); + } + + @Override + public int hashCode() { + return Objects.hash(bar, baz); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ReadOnlyFirst {\n"); + + sb.append(" bar: ").append(toIndentedString(bar)).append("\n"); + sb.append(" baz: ").append(toIndentedString(baz)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/SpecialModelName.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/SpecialModelName.java new file mode 100644 index 000000000000..75f4be4e9f8f --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/SpecialModelName.java @@ -0,0 +1,83 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * SpecialModelName + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class SpecialModelName { + @JsonProperty("$special[property.name]") + private Long $specialPropertyName; + + public SpecialModelName $specialPropertyName(Long $specialPropertyName) { + this.$specialPropertyName = $specialPropertyName; + return this; + } + + /** + * Get $specialPropertyName + * @return $specialPropertyName + */ + @Schema(name = "$specialPropertyName", defaultValue = "") + + + public Long get$SpecialPropertyName() { + return $specialPropertyName; + } + + public void set$SpecialPropertyName(Long $specialPropertyName) { + this.$specialPropertyName = $specialPropertyName; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SpecialModelName $specialModelName = (SpecialModelName) o; + return Objects.equals(this.$specialPropertyName, $specialModelName.$specialPropertyName); + } + + @Override + public int hashCode() { + return Objects.hash($specialPropertyName); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SpecialModelName {\n"); + + sb.append(" $specialPropertyName: ").append(toIndentedString($specialPropertyName)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Tag.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Tag.java new file mode 100644 index 000000000000..8722df999bfc --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/Tag.java @@ -0,0 +1,108 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Tag + */ +@javax.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "name", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/TypeHolderDefault.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/TypeHolderDefault.java new file mode 100644 index 000000000000..19e9bf310f76 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/TypeHolderDefault.java @@ -0,0 +1,198 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * TypeHolderDefault + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class TypeHolderDefault { + @JsonProperty("string_item") + private String stringItem = "what"; + + @JsonProperty("number_item") + private BigDecimal numberItem; + + @JsonProperty("integer_item") + private Integer integerItem; + + @JsonProperty("bool_item") + private Boolean boolItem = true; + + @JsonProperty("array_item") + @Valid + private List arrayItem = new ArrayList<>(); + + public TypeHolderDefault stringItem(String stringItem) { + this.stringItem = stringItem; + return this; + } + + /** + * Get stringItem + * @return stringItem + */ + @Schema(name = "stringItem", required = true, defaultValue = "") + @NotNull + + + public String getStringItem() { + return stringItem; + } + + public void setStringItem(String stringItem) { + this.stringItem = stringItem; + } + + public TypeHolderDefault numberItem(BigDecimal numberItem) { + this.numberItem = numberItem; + return this; + } + + /** + * Get numberItem + * @return numberItem + */ + @Schema(name = "numberItem", required = true, defaultValue = "") + @NotNull + + @Valid + + public BigDecimal getNumberItem() { + return numberItem; + } + + public void setNumberItem(BigDecimal numberItem) { + this.numberItem = numberItem; + } + + public TypeHolderDefault integerItem(Integer integerItem) { + this.integerItem = integerItem; + return this; + } + + /** + * Get integerItem + * @return integerItem + */ + @Schema(name = "integerItem", required = true, defaultValue = "") + @NotNull + + + public Integer getIntegerItem() { + return integerItem; + } + + public void setIntegerItem(Integer integerItem) { + this.integerItem = integerItem; + } + + public TypeHolderDefault boolItem(Boolean boolItem) { + this.boolItem = boolItem; + return this; + } + + /** + * Get boolItem + * @return boolItem + */ + @Schema(name = "boolItem", required = true, defaultValue = "") + @NotNull + + + public Boolean getBoolItem() { + return boolItem; + } + + public void setBoolItem(Boolean boolItem) { + this.boolItem = boolItem; + } + + public TypeHolderDefault arrayItem(List arrayItem) { + this.arrayItem = arrayItem; + return this; + } + + public TypeHolderDefault addArrayItemItem(Integer arrayItemItem) { + this.arrayItem.add(arrayItemItem); + return this; + } + + /** + * Get arrayItem + * @return arrayItem + */ + @Schema(name = "arrayItem", required = true, defaultValue = "") + @NotNull + + + public List getArrayItem() { + return arrayItem; + } + + public void setArrayItem(List arrayItem) { + this.arrayItem = arrayItem; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TypeHolderDefault typeHolderDefault = (TypeHolderDefault) o; + return Objects.equals(this.stringItem, typeHolderDefault.stringItem) && + Objects.equals(this.numberItem, typeHolderDefault.numberItem) && + Objects.equals(this.integerItem, typeHolderDefault.integerItem) && + Objects.equals(this.boolItem, typeHolderDefault.boolItem) && + Objects.equals(this.arrayItem, typeHolderDefault.arrayItem); + } + + @Override + public int hashCode() { + return Objects.hash(stringItem, numberItem, integerItem, boolItem, arrayItem); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TypeHolderDefault {\n"); + + sb.append(" stringItem: ").append(toIndentedString(stringItem)).append("\n"); + sb.append(" numberItem: ").append(toIndentedString(numberItem)).append("\n"); + sb.append(" integerItem: ").append(toIndentedString(integerItem)).append("\n"); + sb.append(" boolItem: ").append(toIndentedString(boolItem)).append("\n"); + sb.append(" arrayItem: ").append(toIndentedString(arrayItem)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/TypeHolderExample.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/TypeHolderExample.java new file mode 100644 index 000000000000..c9a3762bc74b --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/TypeHolderExample.java @@ -0,0 +1,224 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * TypeHolderExample + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class TypeHolderExample { + @JsonProperty("string_item") + private String stringItem; + + @JsonProperty("number_item") + private BigDecimal numberItem; + + @JsonProperty("float_item") + private Float floatItem; + + @JsonProperty("integer_item") + private Integer integerItem; + + @JsonProperty("bool_item") + private Boolean boolItem; + + @JsonProperty("array_item") + @Valid + private List arrayItem = new ArrayList<>(); + + public TypeHolderExample stringItem(String stringItem) { + this.stringItem = stringItem; + return this; + } + + /** + * Get stringItem + * @return stringItem + */ + @Schema(name = "stringItem", example = "what", required = true, defaultValue = "") + @NotNull + + + public String getStringItem() { + return stringItem; + } + + public void setStringItem(String stringItem) { + this.stringItem = stringItem; + } + + public TypeHolderExample numberItem(BigDecimal numberItem) { + this.numberItem = numberItem; + return this; + } + + /** + * Get numberItem + * @return numberItem + */ + @Schema(name = "numberItem", example = "1.234", required = true, defaultValue = "") + @NotNull + + @Valid + + public BigDecimal getNumberItem() { + return numberItem; + } + + public void setNumberItem(BigDecimal numberItem) { + this.numberItem = numberItem; + } + + public TypeHolderExample floatItem(Float floatItem) { + this.floatItem = floatItem; + return this; + } + + /** + * Get floatItem + * @return floatItem + */ + @Schema(name = "floatItem", example = "1.234", required = true, defaultValue = "") + @NotNull + + + public Float getFloatItem() { + return floatItem; + } + + public void setFloatItem(Float floatItem) { + this.floatItem = floatItem; + } + + public TypeHolderExample integerItem(Integer integerItem) { + this.integerItem = integerItem; + return this; + } + + /** + * Get integerItem + * @return integerItem + */ + @Schema(name = "integerItem", example = "-2", required = true, defaultValue = "") + @NotNull + + + public Integer getIntegerItem() { + return integerItem; + } + + public void setIntegerItem(Integer integerItem) { + this.integerItem = integerItem; + } + + public TypeHolderExample boolItem(Boolean boolItem) { + this.boolItem = boolItem; + return this; + } + + /** + * Get boolItem + * @return boolItem + */ + @Schema(name = "boolItem", example = "true", required = true, defaultValue = "") + @NotNull + + + public Boolean getBoolItem() { + return boolItem; + } + + public void setBoolItem(Boolean boolItem) { + this.boolItem = boolItem; + } + + public TypeHolderExample arrayItem(List arrayItem) { + this.arrayItem = arrayItem; + return this; + } + + public TypeHolderExample addArrayItemItem(Integer arrayItemItem) { + this.arrayItem.add(arrayItemItem); + return this; + } + + /** + * Get arrayItem + * @return arrayItem + */ + @Schema(name = "arrayItem", example = "[0, 1, 2, 3]", required = true, defaultValue = "") + @NotNull + + + public List getArrayItem() { + return arrayItem; + } + + public void setArrayItem(List arrayItem) { + this.arrayItem = arrayItem; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TypeHolderExample typeHolderExample = (TypeHolderExample) o; + return Objects.equals(this.stringItem, typeHolderExample.stringItem) && + Objects.equals(this.numberItem, typeHolderExample.numberItem) && + Objects.equals(this.floatItem, typeHolderExample.floatItem) && + Objects.equals(this.integerItem, typeHolderExample.integerItem) && + Objects.equals(this.boolItem, typeHolderExample.boolItem) && + Objects.equals(this.arrayItem, typeHolderExample.arrayItem); + } + + @Override + public int hashCode() { + return Objects.hash(stringItem, numberItem, floatItem, integerItem, boolItem, arrayItem); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TypeHolderExample {\n"); + + sb.append(" stringItem: ").append(toIndentedString(stringItem)).append("\n"); + sb.append(" numberItem: ").append(toIndentedString(numberItem)).append("\n"); + sb.append(" floatItem: ").append(toIndentedString(floatItem)).append("\n"); + sb.append(" integerItem: ").append(toIndentedString(integerItem)).append("\n"); + sb.append(" boolItem: ").append(toIndentedString(boolItem)).append("\n"); + sb.append(" arrayItem: ").append(toIndentedString(arrayItem)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/User.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/User.java new file mode 100644 index 000000000000..83152a155535 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/User.java @@ -0,0 +1,258 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * User + */ +@javax.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "username", defaultValue = "") + + + 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 + */ + @Schema(name = "firstName", defaultValue = "") + + + 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 + */ + @Schema(name = "lastName", defaultValue = "") + + + 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 + */ + @Schema(name = "email", defaultValue = "") + + + 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 + */ + @Schema(name = "password", defaultValue = "") + + + 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 + */ + @Schema(name = "phone", defaultValue = "") + + + 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 + */ + @Schema(name = "userStatus", defaultValue = "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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/XmlItem.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/XmlItem.java new file mode 100644 index 000000000000..59a183db0f62 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/XmlItem.java @@ -0,0 +1,872 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * XmlItem + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class XmlItem { + @JsonProperty("attribute_string") + private String attributeString; + + @JsonProperty("attribute_number") + private BigDecimal attributeNumber; + + @JsonProperty("attribute_integer") + private Integer attributeInteger; + + @JsonProperty("attribute_boolean") + private Boolean attributeBoolean; + + @JsonProperty("wrapped_array") + @Valid + private List wrappedArray = null; + + @JsonProperty("name_string") + private String nameString; + + @JsonProperty("name_number") + private BigDecimal nameNumber; + + @JsonProperty("name_integer") + private Integer nameInteger; + + @JsonProperty("name_boolean") + private Boolean nameBoolean; + + @JsonProperty("name_array") + @Valid + private List nameArray = null; + + @JsonProperty("name_wrapped_array") + @Valid + private List nameWrappedArray = null; + + @JsonProperty("prefix_string") + private String prefixString; + + @JsonProperty("prefix_number") + private BigDecimal prefixNumber; + + @JsonProperty("prefix_integer") + private Integer prefixInteger; + + @JsonProperty("prefix_boolean") + private Boolean prefixBoolean; + + @JsonProperty("prefix_array") + @Valid + private List prefixArray = null; + + @JsonProperty("prefix_wrapped_array") + @Valid + private List prefixWrappedArray = null; + + @JsonProperty("namespace_string") + private String namespaceString; + + @JsonProperty("namespace_number") + private BigDecimal namespaceNumber; + + @JsonProperty("namespace_integer") + private Integer namespaceInteger; + + @JsonProperty("namespace_boolean") + private Boolean namespaceBoolean; + + @JsonProperty("namespace_array") + @Valid + private List namespaceArray = null; + + @JsonProperty("namespace_wrapped_array") + @Valid + private List namespaceWrappedArray = null; + + @JsonProperty("prefix_ns_string") + private String prefixNsString; + + @JsonProperty("prefix_ns_number") + private BigDecimal prefixNsNumber; + + @JsonProperty("prefix_ns_integer") + private Integer prefixNsInteger; + + @JsonProperty("prefix_ns_boolean") + private Boolean prefixNsBoolean; + + @JsonProperty("prefix_ns_array") + @Valid + private List prefixNsArray = null; + + @JsonProperty("prefix_ns_wrapped_array") + @Valid + private List prefixNsWrappedArray = null; + + public XmlItem attributeString(String attributeString) { + this.attributeString = attributeString; + return this; + } + + /** + * Get attributeString + * @return attributeString + */ + @Schema(name = "attributeString", example = "string", defaultValue = "") + + + public String getAttributeString() { + return attributeString; + } + + public void setAttributeString(String attributeString) { + this.attributeString = attributeString; + } + + public XmlItem attributeNumber(BigDecimal attributeNumber) { + this.attributeNumber = attributeNumber; + return this; + } + + /** + * Get attributeNumber + * @return attributeNumber + */ + @Schema(name = "attributeNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getAttributeNumber() { + return attributeNumber; + } + + public void setAttributeNumber(BigDecimal attributeNumber) { + this.attributeNumber = attributeNumber; + } + + public XmlItem attributeInteger(Integer attributeInteger) { + this.attributeInteger = attributeInteger; + return this; + } + + /** + * Get attributeInteger + * @return attributeInteger + */ + @Schema(name = "attributeInteger", example = "-2", defaultValue = "") + + + public Integer getAttributeInteger() { + return attributeInteger; + } + + public void setAttributeInteger(Integer attributeInteger) { + this.attributeInteger = attributeInteger; + } + + public XmlItem attributeBoolean(Boolean attributeBoolean) { + this.attributeBoolean = attributeBoolean; + return this; + } + + /** + * Get attributeBoolean + * @return attributeBoolean + */ + @Schema(name = "attributeBoolean", example = "true", defaultValue = "") + + + public Boolean getAttributeBoolean() { + return attributeBoolean; + } + + public void setAttributeBoolean(Boolean attributeBoolean) { + this.attributeBoolean = attributeBoolean; + } + + public XmlItem wrappedArray(List wrappedArray) { + this.wrappedArray = wrappedArray; + return this; + } + + public XmlItem addWrappedArrayItem(Integer wrappedArrayItem) { + if (this.wrappedArray == null) { + this.wrappedArray = new ArrayList<>(); + } + this.wrappedArray.add(wrappedArrayItem); + return this; + } + + /** + * Get wrappedArray + * @return wrappedArray + */ + @Schema(name = "wrappedArray", defaultValue = "") + + + public List getWrappedArray() { + return wrappedArray; + } + + public void setWrappedArray(List wrappedArray) { + this.wrappedArray = wrappedArray; + } + + public XmlItem nameString(String nameString) { + this.nameString = nameString; + return this; + } + + /** + * Get nameString + * @return nameString + */ + @Schema(name = "nameString", example = "string", defaultValue = "") + + + public String getNameString() { + return nameString; + } + + public void setNameString(String nameString) { + this.nameString = nameString; + } + + public XmlItem nameNumber(BigDecimal nameNumber) { + this.nameNumber = nameNumber; + return this; + } + + /** + * Get nameNumber + * @return nameNumber + */ + @Schema(name = "nameNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getNameNumber() { + return nameNumber; + } + + public void setNameNumber(BigDecimal nameNumber) { + this.nameNumber = nameNumber; + } + + public XmlItem nameInteger(Integer nameInteger) { + this.nameInteger = nameInteger; + return this; + } + + /** + * Get nameInteger + * @return nameInteger + */ + @Schema(name = "nameInteger", example = "-2", defaultValue = "") + + + public Integer getNameInteger() { + return nameInteger; + } + + public void setNameInteger(Integer nameInteger) { + this.nameInteger = nameInteger; + } + + public XmlItem nameBoolean(Boolean nameBoolean) { + this.nameBoolean = nameBoolean; + return this; + } + + /** + * Get nameBoolean + * @return nameBoolean + */ + @Schema(name = "nameBoolean", example = "true", defaultValue = "") + + + public Boolean getNameBoolean() { + return nameBoolean; + } + + public void setNameBoolean(Boolean nameBoolean) { + this.nameBoolean = nameBoolean; + } + + public XmlItem nameArray(List nameArray) { + this.nameArray = nameArray; + return this; + } + + public XmlItem addNameArrayItem(Integer nameArrayItem) { + if (this.nameArray == null) { + this.nameArray = new ArrayList<>(); + } + this.nameArray.add(nameArrayItem); + return this; + } + + /** + * Get nameArray + * @return nameArray + */ + @Schema(name = "nameArray", defaultValue = "") + + + public List getNameArray() { + return nameArray; + } + + public void setNameArray(List nameArray) { + this.nameArray = nameArray; + } + + public XmlItem nameWrappedArray(List nameWrappedArray) { + this.nameWrappedArray = nameWrappedArray; + return this; + } + + public XmlItem addNameWrappedArrayItem(Integer nameWrappedArrayItem) { + if (this.nameWrappedArray == null) { + this.nameWrappedArray = new ArrayList<>(); + } + this.nameWrappedArray.add(nameWrappedArrayItem); + return this; + } + + /** + * Get nameWrappedArray + * @return nameWrappedArray + */ + @Schema(name = "nameWrappedArray", defaultValue = "") + + + public List getNameWrappedArray() { + return nameWrappedArray; + } + + public void setNameWrappedArray(List nameWrappedArray) { + this.nameWrappedArray = nameWrappedArray; + } + + public XmlItem prefixString(String prefixString) { + this.prefixString = prefixString; + return this; + } + + /** + * Get prefixString + * @return prefixString + */ + @Schema(name = "prefixString", example = "string", defaultValue = "") + + + public String getPrefixString() { + return prefixString; + } + + public void setPrefixString(String prefixString) { + this.prefixString = prefixString; + } + + public XmlItem prefixNumber(BigDecimal prefixNumber) { + this.prefixNumber = prefixNumber; + return this; + } + + /** + * Get prefixNumber + * @return prefixNumber + */ + @Schema(name = "prefixNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getPrefixNumber() { + return prefixNumber; + } + + public void setPrefixNumber(BigDecimal prefixNumber) { + this.prefixNumber = prefixNumber; + } + + public XmlItem prefixInteger(Integer prefixInteger) { + this.prefixInteger = prefixInteger; + return this; + } + + /** + * Get prefixInteger + * @return prefixInteger + */ + @Schema(name = "prefixInteger", example = "-2", defaultValue = "") + + + public Integer getPrefixInteger() { + return prefixInteger; + } + + public void setPrefixInteger(Integer prefixInteger) { + this.prefixInteger = prefixInteger; + } + + public XmlItem prefixBoolean(Boolean prefixBoolean) { + this.prefixBoolean = prefixBoolean; + return this; + } + + /** + * Get prefixBoolean + * @return prefixBoolean + */ + @Schema(name = "prefixBoolean", example = "true", defaultValue = "") + + + public Boolean getPrefixBoolean() { + return prefixBoolean; + } + + public void setPrefixBoolean(Boolean prefixBoolean) { + this.prefixBoolean = prefixBoolean; + } + + public XmlItem prefixArray(List prefixArray) { + this.prefixArray = prefixArray; + return this; + } + + public XmlItem addPrefixArrayItem(Integer prefixArrayItem) { + if (this.prefixArray == null) { + this.prefixArray = new ArrayList<>(); + } + this.prefixArray.add(prefixArrayItem); + return this; + } + + /** + * Get prefixArray + * @return prefixArray + */ + @Schema(name = "prefixArray", defaultValue = "") + + + public List getPrefixArray() { + return prefixArray; + } + + public void setPrefixArray(List prefixArray) { + this.prefixArray = prefixArray; + } + + public XmlItem prefixWrappedArray(List prefixWrappedArray) { + this.prefixWrappedArray = prefixWrappedArray; + return this; + } + + public XmlItem addPrefixWrappedArrayItem(Integer prefixWrappedArrayItem) { + if (this.prefixWrappedArray == null) { + this.prefixWrappedArray = new ArrayList<>(); + } + this.prefixWrappedArray.add(prefixWrappedArrayItem); + return this; + } + + /** + * Get prefixWrappedArray + * @return prefixWrappedArray + */ + @Schema(name = "prefixWrappedArray", defaultValue = "") + + + public List getPrefixWrappedArray() { + return prefixWrappedArray; + } + + public void setPrefixWrappedArray(List prefixWrappedArray) { + this.prefixWrappedArray = prefixWrappedArray; + } + + public XmlItem namespaceString(String namespaceString) { + this.namespaceString = namespaceString; + return this; + } + + /** + * Get namespaceString + * @return namespaceString + */ + @Schema(name = "namespaceString", example = "string", defaultValue = "") + + + public String getNamespaceString() { + return namespaceString; + } + + public void setNamespaceString(String namespaceString) { + this.namespaceString = namespaceString; + } + + public XmlItem namespaceNumber(BigDecimal namespaceNumber) { + this.namespaceNumber = namespaceNumber; + return this; + } + + /** + * Get namespaceNumber + * @return namespaceNumber + */ + @Schema(name = "namespaceNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getNamespaceNumber() { + return namespaceNumber; + } + + public void setNamespaceNumber(BigDecimal namespaceNumber) { + this.namespaceNumber = namespaceNumber; + } + + public XmlItem namespaceInteger(Integer namespaceInteger) { + this.namespaceInteger = namespaceInteger; + return this; + } + + /** + * Get namespaceInteger + * @return namespaceInteger + */ + @Schema(name = "namespaceInteger", example = "-2", defaultValue = "") + + + public Integer getNamespaceInteger() { + return namespaceInteger; + } + + public void setNamespaceInteger(Integer namespaceInteger) { + this.namespaceInteger = namespaceInteger; + } + + public XmlItem namespaceBoolean(Boolean namespaceBoolean) { + this.namespaceBoolean = namespaceBoolean; + return this; + } + + /** + * Get namespaceBoolean + * @return namespaceBoolean + */ + @Schema(name = "namespaceBoolean", example = "true", defaultValue = "") + + + public Boolean getNamespaceBoolean() { + return namespaceBoolean; + } + + public void setNamespaceBoolean(Boolean namespaceBoolean) { + this.namespaceBoolean = namespaceBoolean; + } + + public XmlItem namespaceArray(List namespaceArray) { + this.namespaceArray = namespaceArray; + return this; + } + + public XmlItem addNamespaceArrayItem(Integer namespaceArrayItem) { + if (this.namespaceArray == null) { + this.namespaceArray = new ArrayList<>(); + } + this.namespaceArray.add(namespaceArrayItem); + return this; + } + + /** + * Get namespaceArray + * @return namespaceArray + */ + @Schema(name = "namespaceArray", defaultValue = "") + + + public List getNamespaceArray() { + return namespaceArray; + } + + public void setNamespaceArray(List namespaceArray) { + this.namespaceArray = namespaceArray; + } + + public XmlItem namespaceWrappedArray(List namespaceWrappedArray) { + this.namespaceWrappedArray = namespaceWrappedArray; + return this; + } + + public XmlItem addNamespaceWrappedArrayItem(Integer namespaceWrappedArrayItem) { + if (this.namespaceWrappedArray == null) { + this.namespaceWrappedArray = new ArrayList<>(); + } + this.namespaceWrappedArray.add(namespaceWrappedArrayItem); + return this; + } + + /** + * Get namespaceWrappedArray + * @return namespaceWrappedArray + */ + @Schema(name = "namespaceWrappedArray", defaultValue = "") + + + public List getNamespaceWrappedArray() { + return namespaceWrappedArray; + } + + public void setNamespaceWrappedArray(List namespaceWrappedArray) { + this.namespaceWrappedArray = namespaceWrappedArray; + } + + public XmlItem prefixNsString(String prefixNsString) { + this.prefixNsString = prefixNsString; + return this; + } + + /** + * Get prefixNsString + * @return prefixNsString + */ + @Schema(name = "prefixNsString", example = "string", defaultValue = "") + + + public String getPrefixNsString() { + return prefixNsString; + } + + public void setPrefixNsString(String prefixNsString) { + this.prefixNsString = prefixNsString; + } + + public XmlItem prefixNsNumber(BigDecimal prefixNsNumber) { + this.prefixNsNumber = prefixNsNumber; + return this; + } + + /** + * Get prefixNsNumber + * @return prefixNsNumber + */ + @Schema(name = "prefixNsNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getPrefixNsNumber() { + return prefixNsNumber; + } + + public void setPrefixNsNumber(BigDecimal prefixNsNumber) { + this.prefixNsNumber = prefixNsNumber; + } + + public XmlItem prefixNsInteger(Integer prefixNsInteger) { + this.prefixNsInteger = prefixNsInteger; + return this; + } + + /** + * Get prefixNsInteger + * @return prefixNsInteger + */ + @Schema(name = "prefixNsInteger", example = "-2", defaultValue = "") + + + public Integer getPrefixNsInteger() { + return prefixNsInteger; + } + + public void setPrefixNsInteger(Integer prefixNsInteger) { + this.prefixNsInteger = prefixNsInteger; + } + + public XmlItem prefixNsBoolean(Boolean prefixNsBoolean) { + this.prefixNsBoolean = prefixNsBoolean; + return this; + } + + /** + * Get prefixNsBoolean + * @return prefixNsBoolean + */ + @Schema(name = "prefixNsBoolean", example = "true", defaultValue = "") + + + public Boolean getPrefixNsBoolean() { + return prefixNsBoolean; + } + + public void setPrefixNsBoolean(Boolean prefixNsBoolean) { + this.prefixNsBoolean = prefixNsBoolean; + } + + public XmlItem prefixNsArray(List prefixNsArray) { + this.prefixNsArray = prefixNsArray; + return this; + } + + public XmlItem addPrefixNsArrayItem(Integer prefixNsArrayItem) { + if (this.prefixNsArray == null) { + this.prefixNsArray = new ArrayList<>(); + } + this.prefixNsArray.add(prefixNsArrayItem); + return this; + } + + /** + * Get prefixNsArray + * @return prefixNsArray + */ + @Schema(name = "prefixNsArray", defaultValue = "") + + + public List getPrefixNsArray() { + return prefixNsArray; + } + + public void setPrefixNsArray(List prefixNsArray) { + this.prefixNsArray = prefixNsArray; + } + + public XmlItem prefixNsWrappedArray(List prefixNsWrappedArray) { + this.prefixNsWrappedArray = prefixNsWrappedArray; + return this; + } + + public XmlItem addPrefixNsWrappedArrayItem(Integer prefixNsWrappedArrayItem) { + if (this.prefixNsWrappedArray == null) { + this.prefixNsWrappedArray = new ArrayList<>(); + } + this.prefixNsWrappedArray.add(prefixNsWrappedArrayItem); + return this; + } + + /** + * Get prefixNsWrappedArray + * @return prefixNsWrappedArray + */ + @Schema(name = "prefixNsWrappedArray", defaultValue = "") + + + public List getPrefixNsWrappedArray() { + return prefixNsWrappedArray; + } + + public void setPrefixNsWrappedArray(List prefixNsWrappedArray) { + this.prefixNsWrappedArray = prefixNsWrappedArray; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + XmlItem xmlItem = (XmlItem) o; + return Objects.equals(this.attributeString, xmlItem.attributeString) && + Objects.equals(this.attributeNumber, xmlItem.attributeNumber) && + Objects.equals(this.attributeInteger, xmlItem.attributeInteger) && + Objects.equals(this.attributeBoolean, xmlItem.attributeBoolean) && + Objects.equals(this.wrappedArray, xmlItem.wrappedArray) && + Objects.equals(this.nameString, xmlItem.nameString) && + Objects.equals(this.nameNumber, xmlItem.nameNumber) && + Objects.equals(this.nameInteger, xmlItem.nameInteger) && + Objects.equals(this.nameBoolean, xmlItem.nameBoolean) && + Objects.equals(this.nameArray, xmlItem.nameArray) && + Objects.equals(this.nameWrappedArray, xmlItem.nameWrappedArray) && + Objects.equals(this.prefixString, xmlItem.prefixString) && + Objects.equals(this.prefixNumber, xmlItem.prefixNumber) && + Objects.equals(this.prefixInteger, xmlItem.prefixInteger) && + Objects.equals(this.prefixBoolean, xmlItem.prefixBoolean) && + Objects.equals(this.prefixArray, xmlItem.prefixArray) && + Objects.equals(this.prefixWrappedArray, xmlItem.prefixWrappedArray) && + Objects.equals(this.namespaceString, xmlItem.namespaceString) && + Objects.equals(this.namespaceNumber, xmlItem.namespaceNumber) && + Objects.equals(this.namespaceInteger, xmlItem.namespaceInteger) && + Objects.equals(this.namespaceBoolean, xmlItem.namespaceBoolean) && + Objects.equals(this.namespaceArray, xmlItem.namespaceArray) && + Objects.equals(this.namespaceWrappedArray, xmlItem.namespaceWrappedArray) && + Objects.equals(this.prefixNsString, xmlItem.prefixNsString) && + Objects.equals(this.prefixNsNumber, xmlItem.prefixNsNumber) && + Objects.equals(this.prefixNsInteger, xmlItem.prefixNsInteger) && + Objects.equals(this.prefixNsBoolean, xmlItem.prefixNsBoolean) && + Objects.equals(this.prefixNsArray, xmlItem.prefixNsArray) && + Objects.equals(this.prefixNsWrappedArray, xmlItem.prefixNsWrappedArray); + } + + @Override + public int hashCode() { + return Objects.hash(attributeString, attributeNumber, attributeInteger, attributeBoolean, wrappedArray, nameString, nameNumber, nameInteger, nameBoolean, nameArray, nameWrappedArray, prefixString, prefixNumber, prefixInteger, prefixBoolean, prefixArray, prefixWrappedArray, namespaceString, namespaceNumber, namespaceInteger, namespaceBoolean, namespaceArray, namespaceWrappedArray, prefixNsString, prefixNsNumber, prefixNsInteger, prefixNsBoolean, prefixNsArray, prefixNsWrappedArray); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class XmlItem {\n"); + + sb.append(" attributeString: ").append(toIndentedString(attributeString)).append("\n"); + sb.append(" attributeNumber: ").append(toIndentedString(attributeNumber)).append("\n"); + sb.append(" attributeInteger: ").append(toIndentedString(attributeInteger)).append("\n"); + sb.append(" attributeBoolean: ").append(toIndentedString(attributeBoolean)).append("\n"); + sb.append(" wrappedArray: ").append(toIndentedString(wrappedArray)).append("\n"); + sb.append(" nameString: ").append(toIndentedString(nameString)).append("\n"); + sb.append(" nameNumber: ").append(toIndentedString(nameNumber)).append("\n"); + sb.append(" nameInteger: ").append(toIndentedString(nameInteger)).append("\n"); + sb.append(" nameBoolean: ").append(toIndentedString(nameBoolean)).append("\n"); + sb.append(" nameArray: ").append(toIndentedString(nameArray)).append("\n"); + sb.append(" nameWrappedArray: ").append(toIndentedString(nameWrappedArray)).append("\n"); + sb.append(" prefixString: ").append(toIndentedString(prefixString)).append("\n"); + sb.append(" prefixNumber: ").append(toIndentedString(prefixNumber)).append("\n"); + sb.append(" prefixInteger: ").append(toIndentedString(prefixInteger)).append("\n"); + sb.append(" prefixBoolean: ").append(toIndentedString(prefixBoolean)).append("\n"); + sb.append(" prefixArray: ").append(toIndentedString(prefixArray)).append("\n"); + sb.append(" prefixWrappedArray: ").append(toIndentedString(prefixWrappedArray)).append("\n"); + sb.append(" namespaceString: ").append(toIndentedString(namespaceString)).append("\n"); + sb.append(" namespaceNumber: ").append(toIndentedString(namespaceNumber)).append("\n"); + sb.append(" namespaceInteger: ").append(toIndentedString(namespaceInteger)).append("\n"); + sb.append(" namespaceBoolean: ").append(toIndentedString(namespaceBoolean)).append("\n"); + sb.append(" namespaceArray: ").append(toIndentedString(namespaceArray)).append("\n"); + sb.append(" namespaceWrappedArray: ").append(toIndentedString(namespaceWrappedArray)).append("\n"); + sb.append(" prefixNsString: ").append(toIndentedString(prefixNsString)).append("\n"); + sb.append(" prefixNsNumber: ").append(toIndentedString(prefixNsNumber)).append("\n"); + sb.append(" prefixNsInteger: ").append(toIndentedString(prefixNsInteger)).append("\n"); + sb.append(" prefixNsBoolean: ").append(toIndentedString(prefixNsBoolean)).append("\n"); + sb.append(" prefixNsArray: ").append(toIndentedString(prefixNsArray)).append("\n"); + sb.append(" prefixNsWrappedArray: ").append(toIndentedString(prefixNsWrappedArray)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/resources/application.properties b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/resources/application.properties new file mode 100644 index 000000000000..9d06609db665 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/resources/application.properties @@ -0,0 +1,3 @@ +server.port=80 +spring.jackson.date-format=org.openapitools.RFC3339DateFormat +spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/resources/openapi.yaml b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/resources/openapi.yaml new file mode 100644 index 000000000000..d6386dc39bf4 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/resources/openapi.yaml @@ -0,0 +1,2264 @@ +openapi: 3.0.1 +info: + description: 'This spec is mainly for testing Petstore server and contains fake + endpoints, models. Please do not use this for any other purpose. Special characters: + " \' + license: + name: Apache-2.0 + url: https://www.apache.org/licenses/LICENSE-2.0.html + title: OpenAPI Petstore + version: 1.0.0 +servers: +- url: http://petstore.swagger.io:80/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: + operationId: addPet + requestBody: + 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 + responses: + "200": + content: {} + description: successful operation + "405": + content: {} + description: Invalid input + security: + - petstore_auth: + - write:pets + - read:pets + summary: Add a new pet to the store + tags: + - pet + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: pet + put: + operationId: updatePet + requestBody: + 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 + responses: + "200": + content: {} + description: successful operation + "400": + content: {} + description: Invalid ID supplied + "404": + content: {} + description: Pet not found + "405": + content: {} + description: Validation exception + security: + - petstore_auth: + - write:pets + - read:pets + summary: Update an existing pet + tags: + - pet + x-codegen-request-body-name: body + x-contentType: 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: + - 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": + content: {} + description: Invalid status value + security: + - petstore_auth: + - write:pets + - 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 + uniqueItems: true + style: form + responses: + "200": + content: + application/xml: + schema: + items: + $ref: '#/components/schemas/Pet' + type: array + uniqueItems: true + application/json: + schema: + items: + $ref: '#/components/schemas/Pet' + type: array + uniqueItems: true + description: successful operation + "400": + content: {} + description: Invalid tag value + security: + - petstore_auth: + - write:pets + - read:pets + summary: Finds Pets by tags + tags: + - pet + x-accepts: application/json + x-tags: + - tag: pet + /pet/{petId}: + delete: + operationId: deletePet + parameters: + - in: header + name: api_key + schema: + type: string + - description: Pet id to delete + in: path + name: petId + required: true + schema: + format: int64 + type: integer + responses: + "200": + content: {} + description: successful operation + "400": + content: {} + 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 + in: path + name: petId + required: true + schema: + format: int64 + type: integer + responses: + "200": + content: + application/xml: + schema: + $ref: '#/components/schemas/Pet' + application/json: + schema: + $ref: '#/components/schemas/Pet' + description: successful operation + "400": + content: {} + description: Invalid ID supplied + "404": + content: {} + description: Pet not found + security: + - api_key: [] + summary: Find pet by ID + tags: + - pet + x-accepts: application/json + x-tags: + - tag: pet + post: + operationId: updatePetWithForm + parameters: + - description: ID of pet that needs to be updated + in: path + name: petId + required: true + schema: + format: int64 + type: integer + requestBody: + content: + application/x-www-form-urlencoded: + schema: + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string + responses: + "405": + content: {} + description: Invalid input + security: + - petstore_auth: + - write:pets + - read:pets + summary: Updates a pet in the store with form data + tags: + - pet + x-contentType: application/x-www-form-urlencoded + x-accepts: application/json + x-tags: + - tag: pet + /pet/{petId}/uploadImage: + post: + operationId: uploadFile + parameters: + - description: ID of pet to update + in: path + name: petId + required: true + schema: + format: int64 + type: integer + requestBody: + content: + multipart/form-data: + schema: + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + format: binary + type: string + 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-contentType: 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: + operationId: placeOrder + requestBody: + content: + '*/*': + 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": + content: {} + description: Invalid Order + summary: Place an order for a pet + tags: + - store + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: application/json + x-tags: + - tag: store + /store/order/{order_id}: + 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 + in: path + name: order_id + required: true + schema: + type: string + responses: + "400": + content: {} + description: Invalid ID supplied + "404": + content: {} + 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 generated exceptions + operationId: getOrderById + parameters: + - description: ID of pet that needs to be fetched + in: path + name: order_id + required: true + schema: + format: int64 + maximum: 5 + minimum: 1 + type: integer + responses: + "200": + content: + application/xml: + schema: + $ref: '#/components/schemas/Order' + application/json: + schema: + $ref: '#/components/schemas/Order' + description: successful operation + "400": + content: {} + description: Invalid ID supplied + "404": + content: {} + 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: + '*/*': + schema: + $ref: '#/components/schemas/User' + description: Created user object + required: true + responses: + default: + content: {} + description: successful operation + summary: Create user + tags: + - user + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: application/json + x-tags: + - tag: user + /user/createWithArray: + post: + operationId: createUsersWithArrayInput + requestBody: + content: + '*/*': + schema: + items: + $ref: '#/components/schemas/User' + type: array + description: List of user object + required: true + responses: + default: + content: {} + description: successful operation + summary: Creates list of users with given input array + tags: + - user + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: application/json + x-tags: + - tag: user + /user/createWithList: + post: + operationId: createUsersWithListInput + requestBody: + content: + '*/*': + schema: + items: + $ref: '#/components/schemas/User' + type: array + description: List of user object + required: true + responses: + default: + content: {} + description: successful operation + summary: Creates list of users with given input array + tags: + - user + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: application/json + x-tags: + - tag: user + /user/login: + get: + operationId: loginUser + parameters: + - description: The user name for login + in: query + name: username + required: true + schema: + type: string + - description: The password for login in clear text + in: query + name: password + required: true + schema: + type: string + responses: + "200": + content: + application/xml: + schema: + type: string + application/json: + schema: + type: string + description: successful operation + headers: + X-Rate-Limit: + description: calls per hour allowed by the user + schema: + format: int32 + type: integer + X-Expires-After: + description: date in UTC when token expires + schema: + format: date-time + type: string + "400": + content: {} + description: Invalid username/password supplied + summary: Logs user into the system + tags: + - user + x-accepts: application/json + x-tags: + - tag: user + /user/logout: + get: + operationId: logoutUser + responses: + default: + content: {} + description: successful operation + 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 + in: path + name: username + required: true + schema: + type: string + responses: + "400": + content: {} + description: Invalid username supplied + "404": + content: {} + description: User not found + summary: Delete user + tags: + - user + x-accepts: application/json + x-tags: + - tag: user + get: + operationId: getUserByName + parameters: + - description: The name that needs to be fetched. Use user1 for testing. + in: path + name: username + required: true + schema: + type: string + responses: + "200": + content: + application/xml: + schema: + $ref: '#/components/schemas/User' + application/json: + schema: + $ref: '#/components/schemas/User' + description: successful operation + "400": + content: {} + description: Invalid username supplied + "404": + content: {} + 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 + in: path + name: username + required: true + schema: + type: string + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/User' + description: Updated user object + required: true + responses: + "400": + content: {} + description: Invalid user supplied + "404": + content: {} + description: User not found + summary: Updated user + tags: + - user + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: application/json + x-tags: + - tag: user + /fake_classname_test: + patch: + description: To test class name in snake case + operationId: testClassname + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: client model + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: successful operation + security: + - api_key_query: [] + summary: To test class name in snake case + tags: + - fake_classname_tags 123#$%^ + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: fake_classname_tags 123#$%^ + /fake: + delete: + description: Fake endpoint to test group parameters (optional) + operationId: testGroupParameters + parameters: + - description: Required String in group parameters + in: query + name: required_string_group + required: true + schema: + type: integer + - description: Required Boolean in group parameters + in: header + name: required_boolean_group + required: true + schema: + type: boolean + - description: Required Integer in group parameters + in: query + name: required_int64_group + required: true + schema: + format: int64 + type: integer + - description: String in group parameters + in: query + name: string_group + schema: + type: integer + - description: Boolean in group parameters + in: header + name: boolean_group + schema: + type: boolean + - description: Integer in group parameters + in: query + name: int64_group + schema: + format: int64 + type: integer + responses: + "400": + content: {} + description: Someting wrong + summary: Fake endpoint to test group parameters (optional) + tags: + - fake + x-group-parameters: true + x-accepts: application/json + x-tags: + - tag: fake + get: + description: To test enum parameters + operationId: testEnumParameters + parameters: + - description: Header parameter enum test (string array) + explode: false + in: header + name: enum_header_string_array + schema: + items: + default: $ + enum: + - '>' + - $ + type: string + type: array + style: simple + - description: Header parameter enum test (string) + in: header + name: enum_header_string + schema: + default: -efg + enum: + - _abc + - -efg + - (xyz) + type: string + - description: Query parameter enum test (string array) + explode: false + in: query + name: enum_query_string_array + schema: + items: + default: $ + enum: + - '>' + - $ + type: string + type: array + style: form + - description: Query parameter enum test (string) + in: query + name: enum_query_string + schema: + default: -efg + enum: + - _abc + - -efg + - (xyz) + type: string + - description: Query parameter enum test (double) + in: query + name: enum_query_integer + schema: + enum: + - 1 + - -2 + format: int32 + type: integer + - description: Query parameter enum test (double) + in: query + name: enum_query_double + schema: + enum: + - 1.1 + - -1.2 + format: double + type: number + requestBody: + content: + application/x-www-form-urlencoded: + schema: + properties: + enum_form_string_array: + description: Form parameter enum test (string array) + items: + default: $ + enum: + - '>' + - $ + type: string + type: array + enum_form_string: + default: -efg + description: Form parameter enum test (string) + enum: + - _abc + - -efg + - (xyz) + type: string + responses: + "400": + content: {} + description: Invalid request + "404": + content: {} + description: Not found + summary: To test enum parameters + tags: + - fake + x-contentType: application/x-www-form-urlencoded + x-accepts: application/json + x-tags: + - tag: fake + patch: + description: To test "client" model + operationId: testClientModel + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: client model + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: successful operation + summary: To test "client" model + tags: + - fake + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: fake + post: + description: |- + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + operationId: testEndpointParameters + requestBody: + content: + application/x-www-form-urlencoded: + schema: + properties: + integer: + description: None + format: int32 + maximum: 100 + minimum: 10 + type: integer + int32: + description: None + format: int32 + maximum: 200 + minimum: 20 + type: integer + int64: + description: None + format: int64 + type: integer + number: + description: None + maximum: 543.2 + minimum: 32.1 + type: number + float: + description: None + format: float + maximum: 987.6 + type: number + double: + description: None + format: double + maximum: 123.4 + minimum: 67.8 + type: number + string: + description: None + pattern: /[a-z]/i + type: string + pattern_without_delimiter: + description: None + pattern: ^[A-Z].* + type: string + byte: + description: None + format: byte + type: string + binary: + description: None + format: binary + type: string + date: + description: None + format: date + type: string + dateTime: + description: None + format: date-time + type: string + password: + description: None + format: password + maxLength: 64 + minLength: 10 + type: string + callback: + description: None + type: string + required: + - byte + - double + - number + - pattern_without_delimiter + required: true + responses: + "400": + content: {} + description: Invalid username supplied + "404": + content: {} + description: User not found + security: + - http_basic_test: [] + summary: |- + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + tags: + - fake + x-contentType: application/x-www-form-urlencoded + x-accepts: application/json + x-tags: + - tag: fake + /fake/outer/number: + post: + description: Test serialization of outer number types + operationId: fakeOuterNumberSerialize + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterNumber' + description: Input number as post body + required: false + responses: + "200": + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterNumber' + description: Output number + tags: + - fake + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: '*/*' + x-tags: + - tag: fake + /fake/outer/string: + post: + description: Test serialization of outer string types + operationId: fakeOuterStringSerialize + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterString' + description: Input string as post body + required: false + responses: + "200": + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterString' + description: Output string + tags: + - fake + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: '*/*' + x-tags: + - tag: fake + /fake/outer/boolean: + post: + description: Test serialization of outer boolean types + operationId: fakeOuterBooleanSerialize + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterBoolean' + description: Input boolean as post body + required: false + responses: + "200": + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterBoolean' + description: Output boolean + tags: + - fake + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: '*/*' + x-tags: + - tag: fake + /fake/outer/composite: + post: + description: Test serialization of object with outer number type + operationId: fakeOuterCompositeSerialize + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterComposite' + description: Input composite as post body + required: false + responses: + "200": + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterComposite' + description: Output composite + tags: + - fake + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: '*/*' + x-tags: + - tag: fake + /fake/jsonFormData: + get: + operationId: testJsonFormData + requestBody: + content: + application/x-www-form-urlencoded: + schema: + properties: + param: + description: field1 + type: string + param2: + description: field2 + type: string + required: + - param + - param2 + required: true + responses: + "200": + content: {} + description: successful operation + summary: test json serialization of form data + tags: + - fake + x-contentType: application/x-www-form-urlencoded + x-accepts: application/json + x-tags: + - tag: fake + /fake/inline-additionalProperties: + post: + operationId: testInlineAdditionalProperties + requestBody: + content: + application/json: + schema: + additionalProperties: + type: string + type: object + description: request body + required: true + responses: + "200": + content: {} + description: successful operation + summary: test inline additionalProperties + tags: + - fake + x-codegen-request-body-name: param + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: fake + /fake/body-with-query-params: + put: + operationId: testBodyWithQueryParams + parameters: + - in: query + name: query + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + required: true + responses: + "200": + content: {} + description: Success + tags: + - fake + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: fake + /fake/create_xml_item: + post: + description: this route creates an XmlItem + operationId: createXmlItem + requestBody: + content: + application/xml: + schema: + $ref: '#/components/schemas/XmlItem' + application/xml; charset=utf-8: + schema: + $ref: '#/components/schemas/XmlItem' + application/xml; charset=utf-16: + schema: + $ref: '#/components/schemas/XmlItem' + text/xml: + schema: + $ref: '#/components/schemas/XmlItem' + text/xml; charset=utf-8: + schema: + $ref: '#/components/schemas/XmlItem' + text/xml; charset=utf-16: + schema: + $ref: '#/components/schemas/XmlItem' + description: XmlItem Body + required: true + responses: + "200": + content: {} + description: successful operation + summary: creates an XmlItem + tags: + - fake + x-codegen-request-body-name: XmlItem + x-contentType: application/xml + x-accepts: application/json + x-tags: + - tag: fake + /another-fake/dummy: + patch: + description: To test special tags and operation ID starting with number + operationId: 123_test_@#$%_special_tags + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: client model + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: successful operation + summary: To test special tags + tags: + - $another-fake? + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: $another-fake? + /fake/body-with-file-schema: + put: + description: For this test, the body for this request much reference a schema + named `File`. + operationId: testBodyWithFileSchema + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/FileSchemaTestClass' + required: true + responses: + "200": + content: {} + description: Success + tags: + - fake + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: fake + /fake/test-query-parameters: + put: + description: To test the collection format in query parameters + operationId: testQueryParameterCollectionFormat + parameters: + - explode: false + in: query + name: pipe + required: true + schema: + items: + type: string + type: array + style: form + - in: query + name: ioutil + required: true + schema: + items: + type: string + type: array + - in: query + name: http + required: true + schema: + items: + type: string + type: array + style: spaceDelimited + - explode: false + in: query + name: url + required: true + schema: + items: + type: string + type: array + style: form + - explode: true + in: query + name: context + required: true + schema: + items: + type: string + type: array + style: form + responses: + "200": + content: {} + description: Success + tags: + - fake + x-accepts: application/json + x-tags: + - tag: fake + /fake/{petId}/uploadImageWithRequiredFile: + post: + operationId: uploadFileWithRequiredFile + parameters: + - description: ID of pet to update + in: path + name: petId + required: true + schema: + format: int64 + type: integer + requestBody: + content: + multipart/form-data: + schema: + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + requiredFile: + description: file to upload + format: binary + type: string + required: + - requiredFile + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an image (required) + tags: + - pet + x-contentType: multipart/form-data + x-accepts: application/json + x-tags: + - tag: pet +components: + schemas: + Order: + 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 + type: object + xml: + name: Order + Category: + example: + name: default-name + id: 6 + properties: + id: + format: int64 + type: integer + name: + default: default-name + type: string + required: + - name + type: object + xml: + name: Category + User: + example: + firstName: firstName + lastName: lastName + password: password + userStatus: 6 + phone: phone + id: 0 + email: email + username: username + properties: + id: + format: int64 + type: integer + x-is-unique: true + 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 + type: object + xml: + name: User + Tag: + example: + name: name + id: 1 + properties: + id: + format: int64 + type: integer + name: + type: string + type: object + xml: + name: Tag + Pet: + example: + photoUrls: + - photoUrls + - photoUrls + name: doggie + id: 0 + category: + name: default-name + id: 6 + tags: + - name: name + id: 1 + - name: name + id: 1 + status: available + properties: + id: + format: int64 + type: integer + x-is-unique: true + category: + $ref: '#/components/schemas/Category' + name: + example: doggie + type: string + photoUrls: + items: + type: string + type: array + uniqueItems: true + xml: + name: photoUrl + wrapped: true + tags: + items: + $ref: '#/components/schemas/Tag' + type: array + xml: + name: tag + wrapped: true + status: + description: pet status in the store + enum: + - available + - pending + - sold + type: string + required: + - name + - photoUrls + type: object + xml: + name: Pet + ApiResponse: + example: + code: 0 + type: type + message: message + properties: + code: + format: int32 + type: integer + type: + type: string + message: + type: string + type: object + $special[model.name]: + properties: + $special[property.name]: + format: int64 + type: integer + type: object + xml: + name: $special[model.name] + Return: + description: Model for testing reserved words + properties: + return: + format: int32 + type: integer + type: object + xml: + name: Return + Name: + description: Model for testing model name same as property name + properties: + name: + format: int32 + type: integer + snake_case: + format: int32 + readOnly: true + type: integer + property: + type: string + "123Number": + readOnly: true + type: integer + required: + - name + type: object + xml: + name: Name + "200_response": + description: Model for testing model name starting with number + properties: + name: + format: int32 + type: integer + class: + type: string + type: object + xml: + name: Name + ClassModel: + description: Model for testing model with "_class" property + properties: + _class: + type: string + type: object + Dog: + allOf: + - $ref: '#/components/schemas/Animal' + - $ref: '#/components/schemas/Dog_allOf' + Cat: + allOf: + - $ref: '#/components/schemas/Animal' + - $ref: '#/components/schemas/Cat_allOf' + BigCat: + allOf: + - $ref: '#/components/schemas/Cat' + - $ref: '#/components/schemas/BigCat_allOf' + Animal: + discriminator: + propertyName: className + properties: + className: + type: string + color: + default: red + type: string + required: + - className + type: object + AnimalFarm: + items: + $ref: '#/components/schemas/Animal' + type: array + format_test: + properties: + integer: + maximum: 1E+2 + minimum: 1E+1 + type: integer + int32: + format: int32 + maximum: 2E+2 + minimum: 2E+1 + type: integer + int64: + format: int64 + type: integer + number: + maximum: 543.2 + minimum: 32.1 + type: number + float: + format: float + maximum: 987.6 + minimum: 54.3 + type: number + double: + format: double + maximum: 123.4 + minimum: 67.8 + type: number + string: + pattern: /[a-z]/i + type: string + byte: + format: byte + pattern: ^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$ + type: string + binary: + format: binary + type: string + date: + format: date + type: string + dateTime: + format: date-time + type: string + uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + type: string + password: + format: password + maxLength: 64 + minLength: 10 + type: string + BigDecimal: + format: number + type: string + required: + - byte + - date + - number + - password + type: object + EnumClass: + default: -efg + enum: + - _abc + - -efg + - (xyz) + type: string + Enum_Test: + properties: + enum_string: + enum: + - UPPER + - lower + - "" + type: string + enum_string_required: + enum: + - UPPER + - lower + - "" + type: string + enum_integer: + enum: + - 1 + - -1 + format: int32 + type: integer + enum_number: + enum: + - 1.1 + - -1.2 + format: double + type: number + outerEnum: + $ref: '#/components/schemas/OuterEnum' + required: + - enum_string_required + type: object + AdditionalPropertiesClass: + properties: + map_string: + additionalProperties: + type: string + type: object + map_number: + additionalProperties: + type: number + type: object + map_integer: + additionalProperties: + type: integer + type: object + map_boolean: + additionalProperties: + type: boolean + type: object + map_array_integer: + additionalProperties: + items: + type: integer + type: array + type: object + map_array_anytype: + additionalProperties: + items: + properties: {} + type: object + type: array + type: object + map_map_string: + additionalProperties: + additionalProperties: + type: string + type: object + type: object + map_map_anytype: + additionalProperties: + additionalProperties: + properties: {} + type: object + type: object + type: object + anytype_1: + properties: {} + type: object + anytype_2: + type: object + anytype_3: + properties: {} + type: object + type: object + AdditionalPropertiesString: + additionalProperties: + type: string + properties: + name: + type: string + type: object + AdditionalPropertiesInteger: + additionalProperties: + type: integer + properties: + name: + type: string + type: object + AdditionalPropertiesNumber: + additionalProperties: + type: number + properties: + name: + type: string + type: object + AdditionalPropertiesBoolean: + additionalProperties: + type: boolean + properties: + name: + type: string + type: object + AdditionalPropertiesArray: + additionalProperties: + items: + properties: {} + type: object + type: array + properties: + name: + type: string + type: object + AdditionalPropertiesObject: + additionalProperties: + additionalProperties: + properties: {} + type: object + type: object + properties: + name: + type: string + type: object + AdditionalPropertiesAnyType: + additionalProperties: + properties: {} + type: object + properties: + name: + type: string + type: object + MixedPropertiesAndAdditionalPropertiesClass: + properties: + uuid: + format: uuid + type: string + dateTime: + format: date-time + type: string + map: + additionalProperties: + $ref: '#/components/schemas/Animal' + type: object + type: object + List: + properties: + "123-list": + type: string + type: object + Client: + example: + client: client + properties: + client: + type: string + type: object + ReadOnlyFirst: + properties: + bar: + readOnly: true + type: string + baz: + type: string + type: object + hasOnlyReadOnly: + properties: + bar: + readOnly: true + type: string + foo: + readOnly: true + type: string + type: object + Capitalization: + properties: + smallCamel: + type: string + CapitalCamel: + type: string + small_Snake: + type: string + Capital_Snake: + type: string + SCA_ETH_Flow_Points: + type: string + ATT_NAME: + description: | + Name of the pet + type: string + type: object + MapTest: + properties: + map_map_of_string: + additionalProperties: + additionalProperties: + type: string + type: object + type: object + map_of_enum_string: + additionalProperties: + enum: + - UPPER + - lower + type: string + type: object + direct_map: + additionalProperties: + type: boolean + type: object + indirect_map: + additionalProperties: + type: boolean + type: object + type: object + ArrayTest: + properties: + array_of_string: + items: + type: string + type: array + array_array_of_integer: + items: + items: + format: int64 + type: integer + type: array + type: array + array_array_of_model: + items: + items: + $ref: '#/components/schemas/ReadOnlyFirst' + type: array + type: array + type: object + NumberOnly: + properties: + JustNumber: + type: number + type: object + ArrayOfNumberOnly: + properties: + ArrayNumber: + items: + type: number + type: array + type: object + ArrayOfArrayOfNumberOnly: + properties: + ArrayArrayNumber: + items: + items: + type: number + type: array + type: array + type: object + EnumArrays: + properties: + just_symbol: + enum: + - '>=' + - $ + type: string + array_enum: + items: + enum: + - fish + - crab + type: string + type: array + type: object + OuterEnum: + enum: + - placed + - approved + - delivered + type: string + OuterComposite: + example: + my_string: my_string + my_number: 0.8008281904610115 + my_boolean: true + properties: + my_number: + type: number + my_string: + type: string + my_boolean: + type: boolean + x-codegen-body-parameter-name: boolean_post_body + type: object + OuterNumber: + type: number + OuterString: + type: string + OuterBoolean: + type: boolean + x-codegen-body-parameter-name: boolean_post_body + StringBooleanMap: + additionalProperties: + type: boolean + type: object + FileSchemaTestClass: + example: + file: + sourceURI: sourceURI + files: + - sourceURI: sourceURI + - sourceURI: sourceURI + properties: + file: + $ref: '#/components/schemas/File' + files: + items: + $ref: '#/components/schemas/File' + type: array + type: object + File: + description: Must be named `File` for test. + example: + sourceURI: sourceURI + properties: + sourceURI: + description: Test capitalization + type: string + type: object + TypeHolderDefault: + properties: + string_item: + default: what + type: string + number_item: + type: number + integer_item: + type: integer + bool_item: + default: true + type: boolean + array_item: + items: + type: integer + type: array + required: + - array_item + - bool_item + - integer_item + - number_item + - string_item + type: object + TypeHolderExample: + properties: + string_item: + example: what + type: string + number_item: + example: 1.234 + type: number + float_item: + example: 1.234 + format: float + type: number + integer_item: + example: -2 + type: integer + bool_item: + example: true + type: boolean + array_item: + example: + - 0 + - 1 + - 2 + - 3 + items: + type: integer + type: array + required: + - array_item + - bool_item + - float_item + - integer_item + - number_item + - string_item + type: object + XmlItem: + properties: + attribute_string: + example: string + type: string + xml: + attribute: true + attribute_number: + example: 1.234 + type: number + xml: + attribute: true + attribute_integer: + example: -2 + type: integer + xml: + attribute: true + attribute_boolean: + example: true + type: boolean + xml: + attribute: true + wrapped_array: + items: + type: integer + type: array + xml: + wrapped: true + name_string: + example: string + type: string + xml: + name: xml_name_string + name_number: + example: 1.234 + type: number + xml: + name: xml_name_number + name_integer: + example: -2 + type: integer + xml: + name: xml_name_integer + name_boolean: + example: true + type: boolean + xml: + name: xml_name_boolean + name_array: + items: + type: integer + xml: + name: xml_name_array_item + type: array + name_wrapped_array: + items: + type: integer + xml: + name: xml_name_wrapped_array_item + type: array + xml: + name: xml_name_wrapped_array + wrapped: true + prefix_string: + example: string + type: string + xml: + prefix: ab + prefix_number: + example: 1.234 + type: number + xml: + prefix: cd + prefix_integer: + example: -2 + type: integer + xml: + prefix: ef + prefix_boolean: + example: true + type: boolean + xml: + prefix: gh + prefix_array: + items: + type: integer + xml: + prefix: ij + type: array + prefix_wrapped_array: + items: + type: integer + xml: + prefix: mn + type: array + xml: + prefix: kl + wrapped: true + namespace_string: + example: string + type: string + xml: + namespace: http://a.com/schema + namespace_number: + example: 1.234 + type: number + xml: + namespace: http://b.com/schema + namespace_integer: + example: -2 + type: integer + xml: + namespace: http://c.com/schema + namespace_boolean: + example: true + type: boolean + xml: + namespace: http://d.com/schema + namespace_array: + items: + type: integer + xml: + namespace: http://e.com/schema + type: array + namespace_wrapped_array: + items: + type: integer + xml: + namespace: http://g.com/schema + type: array + xml: + namespace: http://f.com/schema + wrapped: true + prefix_ns_string: + example: string + type: string + xml: + namespace: http://a.com/schema + prefix: a + prefix_ns_number: + example: 1.234 + type: number + xml: + namespace: http://b.com/schema + prefix: b + prefix_ns_integer: + example: -2 + type: integer + xml: + namespace: http://c.com/schema + prefix: c + prefix_ns_boolean: + example: true + type: boolean + xml: + namespace: http://d.com/schema + prefix: d + prefix_ns_array: + items: + type: integer + xml: + namespace: http://e.com/schema + prefix: e + type: array + prefix_ns_wrapped_array: + items: + type: integer + xml: + namespace: http://g.com/schema + prefix: g + type: array + xml: + namespace: http://f.com/schema + prefix: f + wrapped: true + type: object + xml: + namespace: http://a.com/schema + prefix: pre + Dog_allOf: + properties: + breed: + type: string + type: object + Cat_allOf: + properties: + declawed: + type: boolean + type: object + BigCat_allOf: + properties: + kind: + enum: + - lions + - tigers + - leopards + - jaguars + 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 + api_key_query: + in: query + name: api_key_query + type: apiKey + http_basic_test: + scheme: basic + type: http +x-original-swagger-version: "2.0" diff --git a/samples/openapi3/server/petstore/springboot-reactive/.openapi-generator-ignore b/samples/openapi3/server/petstore/springboot-reactive/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/.openapi-generator-ignore @@ -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 diff --git a/samples/openapi3/server/petstore/springboot-reactive/.openapi-generator/FILES b/samples/openapi3/server/petstore/springboot-reactive/.openapi-generator/FILES new file mode 100644 index 000000000000..9df6c44a3213 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/.openapi-generator/FILES @@ -0,0 +1,72 @@ +README.md +pom.xml +src/main/java/org/openapitools/OpenAPI2SpringBoot.java +src/main/java/org/openapitools/RFC3339DateFormat.java +src/main/java/org/openapitools/api/AnotherFakeApi.java +src/main/java/org/openapitools/api/AnotherFakeApiController.java +src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java +src/main/java/org/openapitools/api/ApiUtil.java +src/main/java/org/openapitools/api/FakeApi.java +src/main/java/org/openapitools/api/FakeApiController.java +src/main/java/org/openapitools/api/FakeApiDelegate.java +src/main/java/org/openapitools/api/FakeClassnameTestApi.java +src/main/java/org/openapitools/api/FakeClassnameTestApiController.java +src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.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/model/AdditionalPropertiesAnyType.java +src/main/java/org/openapitools/model/AdditionalPropertiesArray.java +src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java +src/main/java/org/openapitools/model/AdditionalPropertiesClass.java +src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java +src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java +src/main/java/org/openapitools/model/AdditionalPropertiesObject.java +src/main/java/org/openapitools/model/AdditionalPropertiesString.java +src/main/java/org/openapitools/model/Animal.java +src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java +src/main/java/org/openapitools/model/ArrayOfNumberOnly.java +src/main/java/org/openapitools/model/ArrayTest.java +src/main/java/org/openapitools/model/BigCat.java +src/main/java/org/openapitools/model/BigCatAllOf.java +src/main/java/org/openapitools/model/Capitalization.java +src/main/java/org/openapitools/model/Cat.java +src/main/java/org/openapitools/model/CatAllOf.java +src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ClassModel.java +src/main/java/org/openapitools/model/Client.java +src/main/java/org/openapitools/model/Dog.java +src/main/java/org/openapitools/model/DogAllOf.java +src/main/java/org/openapitools/model/EnumArrays.java +src/main/java/org/openapitools/model/EnumClass.java +src/main/java/org/openapitools/model/EnumTest.java +src/main/java/org/openapitools/model/FileSchemaTestClass.java +src/main/java/org/openapitools/model/FormatTest.java +src/main/java/org/openapitools/model/HasOnlyReadOnly.java +src/main/java/org/openapitools/model/MapTest.java +src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java +src/main/java/org/openapitools/model/Model200Response.java +src/main/java/org/openapitools/model/ModelApiResponse.java +src/main/java/org/openapitools/model/ModelReturn.java +src/main/java/org/openapitools/model/Name.java +src/main/java/org/openapitools/model/NumberOnly.java +src/main/java/org/openapitools/model/Order.java +src/main/java/org/openapitools/model/OuterComposite.java +src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/Pet.java +src/main/java/org/openapitools/model/ReadOnlyFirst.java +src/main/java/org/openapitools/model/SpecialModelName.java +src/main/java/org/openapitools/model/Tag.java +src/main/java/org/openapitools/model/TypeHolderDefault.java +src/main/java/org/openapitools/model/TypeHolderExample.java +src/main/java/org/openapitools/model/User.java +src/main/java/org/openapitools/model/XmlItem.java +src/main/resources/application.properties +src/main/resources/openapi.yaml diff --git a/samples/openapi3/server/petstore/springboot-reactive/.openapi-generator/VERSION b/samples/openapi3/server/petstore/springboot-reactive/.openapi-generator/VERSION new file mode 100644 index 000000000000..0984c4c1ad21 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/.openapi-generator/VERSION @@ -0,0 +1 @@ +5.4.0-SNAPSHOT \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-reactive/README.md b/samples/openapi3/server/petstore/springboot-reactive/README.md new file mode 100644 index 000000000000..55dc732c1b00 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/README.md @@ -0,0 +1,13 @@ +# 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. + +Start your server as a simple java application + +Change default port value in application.properties \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-reactive/pom.xml b/samples/openapi3/server/petstore/springboot-reactive/pom.xml new file mode 100644 index 000000000000..a6268c2794f7 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/pom.xml @@ -0,0 +1,71 @@ + + 4.0.0 + org.openapitools.openapi3 + springboot-reactive + jar + springboot-reactive + 1.0.0 + + 1.8 + ${java.version} + ${java.version} + 2.1.11 + + + org.springframework.boot + spring-boot-starter-parent + 2.5.8 + + + src/main/java + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + org.springframework.boot + spring-boot-starter-webflux + + + org.springframework.data + spring-data-commons + + + io.swagger.core.v3 + swagger-annotations + ${swagger-core-version} + + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + + + org.openapitools + jackson-databind-nullable + 0.2.2 + + + + org.springframework.boot + spring-boot-starter-validation + + + com.fasterxml.jackson.core + jackson-databind + + + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..254af0225142 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,63 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.Module; +import org.openapitools.jackson.nullable.JsonNullableModule; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.ExitCodeGenerator; +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.web.reactive.config.CorsRegistry; +import org.springframework.web.reactive.config.ResourceHandlerRegistry; +import org.springframework.web.reactive.config.WebFluxConfigurer; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenAPI2SpringBoot implements CommandLineRunner { + + @Override + public void run(String... arg0) throws Exception { + if (arg0.length > 0 && arg0[0].equals("exitcode")) { + throw new ExitException(); + } + } + + public static void main(String[] args) throws Exception { + new SpringApplication(OpenAPI2SpringBoot.class).run(args); + } + + static class ExitException extends RuntimeException implements ExitCodeGenerator { + private static final long serialVersionUID = 1L; + + @Override + public int getExitCode() { + return 10; + } + + } + + @Bean + public WebFluxConfigurer webConfigurer() { + return new WebFluxConfigurer() { + /*@Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") + .allowedOrigins("*") + .allowedMethods("*") + .allowedHeaders("Content-Type"); + }*/ + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("/swagger-ui/**").addResourceLocations("classpath:/META-INF/resources/webjars/swagger-ui/3.14.2/"); + } + }; + } + + @Bean + public Module jsonNullableModule() { + return new JsonNullableModule(); + } + +} diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/RFC3339DateFormat.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/RFC3339DateFormat.java new file mode 100644 index 000000000000..bcd3936d8b34 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/RFC3339DateFormat.java @@ -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; + } +} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApi.java new file mode 100644 index 000000000000..c7e2bb2b25a2 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -0,0 +1,66 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.openapitools.api; + +import org.openapitools.model.Client; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import org.springframework.http.codec.multipart.Part; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "another-fake", description = "the another-fake API") +public interface AnotherFakeApi { + + default AnotherFakeApiDelegate getDelegate() { + return new AnotherFakeApiDelegate() {}; + } + + /** + * PATCH /another-fake/dummy : To test special tags + * To test special tags and operation ID starting with number + * + * @param body client model (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "To test special tags", + tags = { "$another-fake?" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Client.class))) + } + ) + @RequestMapping( + method = RequestMethod.PATCH, + value = "/another-fake/dummy", + produces = { "application/json" }, + consumes = { "application/json" } + ) + default Mono> call123testSpecialTags( + @Parameter(name = "body", description = "client model", required = true, schema = @Schema(description = "")) @Valid @RequestBody Mono body, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().call123testSpecialTags(body, exchange); + } + +} diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApiController.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApiController.java new file mode 100644 index 000000000000..df11134c8067 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApiController.java @@ -0,0 +1,22 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class AnotherFakeApiController implements AnotherFakeApi { + + private final AnotherFakeApiDelegate delegate; + + public AnotherFakeApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) AnotherFakeApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new AnotherFakeApiDelegate() {}); + } + + @Override + public AnotherFakeApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java new file mode 100644 index 000000000000..2ef11c811c11 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java @@ -0,0 +1,52 @@ +package org.openapitools.api; + +import org.openapitools.model.Client; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import org.springframework.http.codec.multipart.Part; + +import java.util.List; +import java.util.Map; +import java.util.Optional; + +/** + * A delegate to be called by the {@link AnotherFakeApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public interface AnotherFakeApiDelegate { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * PATCH /another-fake/dummy : To test special tags + * To test special tags and operation ID starting with number + * + * @param body client model (required) + * @return successful operation (status code 200) + * @see AnotherFakeApi#call123testSpecialTags + */ + default Mono> call123testSpecialTags(Mono body, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"client\" : \"client\" }"; + result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString); + break; + } + } + return result.then(Mono.empty()); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/ApiUtil.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/ApiUtil.java new file mode 100644 index 000000000000..7ed3b0ab28d9 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/ApiUtil.java @@ -0,0 +1,20 @@ +package org.openapitools.api; + +import java.nio.charset.StandardCharsets; +import org.springframework.core.io.buffer.DefaultDataBuffer; +import org.springframework.core.io.buffer.DefaultDataBufferFactory; +import org.springframework.http.MediaType; +import org.springframework.http.server.reactive.ServerHttpResponse; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Mono; + +public class ApiUtil { + public static Mono getExampleResponse(ServerWebExchange exchange, MediaType mediaType, String example) { + ServerHttpResponse response = exchange.getResponse(); + response.getHeaders().setContentType(mediaType); + + byte[] exampleBytes = example.getBytes(StandardCharsets.UTF_8); + DefaultDataBuffer data = new DefaultDataBufferFactory().wrap(exampleBytes); + return response.writeWith(Mono.just(data)); + } +} diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApi.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApi.java new file mode 100644 index 000000000000..729f78eb8246 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApi.java @@ -0,0 +1,524 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.openapitools.api; + +import java.math.BigDecimal; +import org.openapitools.model.Client; +import org.openapitools.model.FileSchemaTestClass; +import java.time.LocalDate; +import java.util.Map; +import org.openapitools.model.ModelApiResponse; +import java.time.OffsetDateTime; +import org.openapitools.model.OuterComposite; +import org.openapitools.model.User; +import org.openapitools.model.XmlItem; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import org.springframework.http.codec.multipart.Part; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "fake", description = "the fake API") +public interface FakeApi { + + default FakeApiDelegate getDelegate() { + return new FakeApiDelegate() {}; + } + + /** + * POST /fake/create_xml_item : creates an XmlItem + * this route creates an XmlItem + * + * @param xmlItem XmlItem Body (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "creates an XmlItem", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/create_xml_item", + consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } + ) + default Mono> createXmlItem( + @Parameter(name = "XmlItem", description = "XmlItem Body", required = true, schema = @Schema(description = "")) @Valid @RequestBody Mono xmlItem, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().createXmlItem(xmlItem, exchange); + } + + + /** + * POST /fake/outer/boolean + * Test serialization of outer boolean types + * + * @param body Input boolean as post body (optional) + * @return Output boolean (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Output boolean", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Boolean.class))) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/outer/boolean", + produces = { "*/*" } + ) + default Mono> fakeOuterBooleanSerialize( + @Parameter(name = "body", description = "Input boolean as post body", schema = @Schema(description = "")) @Valid @RequestBody(required = false) Mono body, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().fakeOuterBooleanSerialize(body, exchange); + } + + + /** + * POST /fake/outer/composite + * Test serialization of object with outer number type + * + * @param body Input composite as post body (optional) + * @return Output composite (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Output composite", content = @Content(mediaType = "application/json", schema = @Schema(implementation = OuterComposite.class))) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/outer/composite", + produces = { "*/*" } + ) + default Mono> fakeOuterCompositeSerialize( + @Parameter(name = "body", description = "Input composite as post body", schema = @Schema(description = "")) @Valid @RequestBody(required = false) Mono body, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().fakeOuterCompositeSerialize(body, exchange); + } + + + /** + * POST /fake/outer/number + * Test serialization of outer number types + * + * @param body Input number as post body (optional) + * @return Output number (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Output number", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BigDecimal.class))) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/outer/number", + produces = { "*/*" } + ) + default Mono> fakeOuterNumberSerialize( + @Parameter(name = "body", description = "Input number as post body", schema = @Schema(description = "")) @Valid @RequestBody(required = false) Mono body, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().fakeOuterNumberSerialize(body, exchange); + } + + + /** + * POST /fake/outer/string + * Test serialization of outer string types + * + * @param body Input string as post body (optional) + * @return Output string (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Output string", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/outer/string", + produces = { "*/*" } + ) + default Mono> fakeOuterStringSerialize( + @Parameter(name = "body", description = "Input string as post body", schema = @Schema(description = "")) @Valid @RequestBody(required = false) Mono body, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().fakeOuterStringSerialize(body, exchange); + } + + + /** + * PUT /fake/body-with-file-schema + * For this test, the body for this request much reference a schema named `File`. + * + * @param body (required) + * @return Success (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success") + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/fake/body-with-file-schema", + consumes = { "application/json" } + ) + default Mono> testBodyWithFileSchema( + @Parameter(name = "body", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestBody Mono body, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().testBodyWithFileSchema(body, exchange); + } + + + /** + * PUT /fake/body-with-query-params + * + * @param query (required) + * @param body (required) + * @return Success (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success") + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/fake/body-with-query-params", + consumes = { "application/json" } + ) + default Mono> testBodyWithQueryParams( + @NotNull @Parameter(name = "query", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "query", required = true) String query, + @Parameter(name = "body", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestBody Mono body, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().testBodyWithQueryParams(query, body, exchange); + } + + + /** + * PATCH /fake : To test \"client\" model + * To test \"client\" model + * + * @param body client model (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "To test \"client\" model", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Client.class))) + } + ) + @RequestMapping( + method = RequestMethod.PATCH, + value = "/fake", + produces = { "application/json" }, + consumes = { "application/json" } + ) + default Mono> testClientModel( + @Parameter(name = "body", description = "client model", required = true, schema = @Schema(description = "")) @Valid @RequestBody Mono body, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().testClientModel(body, exchange); + } + + + /** + * POST /fake : Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * + * @param number None (required) + * @param _double None (required) + * @param patternWithoutDelimiter None (required) + * @param _byte None (required) + * @param integer None (optional) + * @param int32 None (optional) + * @param int64 None (optional) + * @param _float None (optional) + * @param string None (optional) + * @param binary None (optional) + * @param date None (optional) + * @param dateTime None (optional) + * @param password None (optional) + * @param paramCallback None (optional) + * @return Invalid username supplied (status code 400) + * or User not found (status code 404) + */ + @Operation( + summary = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + }, + security = { + @SecurityRequirement(name = "http_basic_test") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) + default Mono> testEndpointParameters( + @Parameter(name = "number", description = "None", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "number", required = true) BigDecimal number, + @Parameter(name = "double", description = "None", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "double", required = true) Double _double, + @Parameter(name = "pattern_without_delimiter", description = "None", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, + @Parameter(name = "byte", description = "None", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, + @Parameter(name = "integer", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "integer", required = false) Integer integer, + @Parameter(name = "int32", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "int32", required = false) Integer int32, + @Parameter(name = "int64", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "int64", required = false) Long int64, + @Parameter(name = "float", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "float", required = false) Float _float, + @Parameter(name = "string", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "string", required = false) String string, + @Parameter(name = "binary", description = "None", schema = @Schema(description = "")) @RequestPart(value = "binary", required = false) Flux binary, + @Parameter(name = "date", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "date", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @Parameter(name = "dateTime", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "dateTime", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @Parameter(name = "password", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "password", required = false) String password, + @Parameter(name = "callback", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "callback", required = false) String paramCallback, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback, exchange); + } + + + /** + * GET /fake : To test enum parameters + * To test enum parameters + * + * @param enumHeaderStringArray Header parameter enum test (string array) (optional) + * @param enumHeaderString Header parameter enum test (string) (optional, default to -efg) + * @param enumQueryStringArray Query parameter enum test (string array) (optional) + * @param enumQueryString Query parameter enum test (string) (optional, default to -efg) + * @param enumQueryInteger Query parameter enum test (double) (optional) + * @param enumQueryDouble Query parameter enum test (double) (optional) + * @param enumFormStringArray Form parameter enum test (string array) (optional, default to $) + * @param enumFormString Form parameter enum test (string) (optional, default to -efg) + * @return Invalid request (status code 400) + * or Not found (status code 404) + */ + @Operation( + summary = "To test enum parameters", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid request"), + @ApiResponse(responseCode = "404", description = "Not found") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) + default Mono> testEnumParameters( + @Parameter(name = "enum_header_string_array", description = "Header parameter enum test (string array)", schema = @Schema(description = "", allowableValues = { ">", "$" })) @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray, + @Parameter(name = "enum_header_string", description = "Header parameter enum test (string)", schema = @Schema(description = "", allowableValues = { "_abc", "-efg", "(xyz)" }, defaultValue = "-efg")) @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString, + @Parameter(name = "enum_query_string_array", description = "Query parameter enum test (string array)", schema = @Schema(description = "", allowableValues = { ">", "$" })) @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, + @Parameter(name = "enum_query_string", description = "Query parameter enum test (string)", schema = @Schema(description = "", allowableValues = { "_abc", "-efg", "(xyz)" }, defaultValue = "-efg")) @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString, + @Parameter(name = "enum_query_integer", description = "Query parameter enum test (double)", schema = @Schema(description = "", allowableValues = { "1", "-2" })) @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, + @Parameter(name = "enum_query_double", description = "Query parameter enum test (double)", schema = @Schema(description = "", allowableValues = { "1.1", "-1.2" })) @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble, + @Parameter(name = "enum_form_string_array", description = "Form parameter enum test (string array)", schema = @Schema(description = "", allowableValues = { ">", "$" })) @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, + @Parameter(name = "enum_form_string", description = "Form parameter enum test (string)", schema = @Schema(description = "", allowableValues = { "_abc", "-efg", "(xyz)" }, defaultValue = "-efg")) @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, exchange); + } + + + /** + * DELETE /fake : Fake endpoint to test group parameters (optional) + * Fake endpoint to test group parameters (optional) + * + * @param requiredStringGroup Required String in group parameters (required) + * @param requiredBooleanGroup Required Boolean in group parameters (required) + * @param requiredInt64Group Required Integer in group parameters (required) + * @param stringGroup String in group parameters (optional) + * @param booleanGroup Boolean in group parameters (optional) + * @param int64Group Integer in group parameters (optional) + * @return Someting wrong (status code 400) + */ + @Operation( + summary = "Fake endpoint to test group parameters (optional)", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "400", description = "Someting wrong") + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/fake" + ) + default Mono> testGroupParameters( + @NotNull @Parameter(name = "required_string_group", description = "Required String in group parameters", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup, + @Parameter(name = "required_boolean_group", description = "Required Boolean in group parameters", required = true, schema = @Schema(description = "")) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup, + @NotNull @Parameter(name = "required_int64_group", description = "Required Integer in group parameters", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group, + @Parameter(name = "string_group", description = "String in group parameters", schema = @Schema(description = "")) @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup, + @Parameter(name = "boolean_group", description = "Boolean in group parameters", schema = @Schema(description = "")) @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup, + @Parameter(name = "int64_group", description = "Integer in group parameters", schema = @Schema(description = "")) @Valid @RequestParam(value = "int64_group", required = false) Long int64Group, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, exchange); + } + + + /** + * POST /fake/inline-additionalProperties : test inline additionalProperties + * + * @param param request body (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "test inline additionalProperties", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/inline-additionalProperties", + consumes = { "application/json" } + ) + default Mono> testInlineAdditionalProperties( + @Parameter(name = "param", description = "request body", required = true, schema = @Schema(description = "")) @Valid @RequestBody Mono> param, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().testInlineAdditionalProperties(param, exchange); + } + + + /** + * GET /fake/jsonFormData : test json serialization of form data + * + * @param param field1 (required) + * @param param2 field2 (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "test json serialization of form data", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/fake/jsonFormData", + consumes = { "application/x-www-form-urlencoded" } + ) + default Mono> testJsonFormData( + @Parameter(name = "param", description = "field1", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "param", required = true) String param, + @Parameter(name = "param2", description = "field2", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "param2", required = true) String param2, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().testJsonFormData(param, param2, exchange); + } + + + /** + * PUT /fake/test-query-parameters + * To test the collection format in query parameters + * + * @param pipe (required) + * @param ioutil (required) + * @param http (required) + * @param url (required) + * @param context (required) + * @return Success (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success") + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/fake/test-query-parameters" + ) + default Mono> testQueryParameterCollectionFormat( + @NotNull @Parameter(name = "pipe", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "pipe", required = true) List pipe, + @NotNull @Parameter(name = "ioutil", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "ioutil", required = true) List ioutil, + @NotNull @Parameter(name = "http", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "http", required = true) List http, + @NotNull @Parameter(name = "url", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "url", required = true) List url, + @NotNull @Parameter(name = "context", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "context", required = true) List context, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, exchange); + } + + + /** + * POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required) + * + * @param petId ID of pet to update (required) + * @param requiredFile file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @return successful operation (status code 200) + */ + @Operation( + summary = "uploads an image (required)", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ModelApiResponse.class))) + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/{petId}/uploadImageWithRequiredFile", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) + default Mono> uploadFileWithRequiredFile( + @Parameter(name = "petId", description = "ID of pet to update", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "requiredFile", description = "file to upload", required = true, schema = @Schema(description = "")) @RequestPart(value = "requiredFile", required = true) Flux requiredFile, + @Parameter(name = "additionalMetadata", description = "Additional data to pass to server", schema = @Schema(description = "")) @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata, exchange); + } + +} diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiController.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiController.java new file mode 100644 index 000000000000..6b22c1aba661 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiController.java @@ -0,0 +1,22 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class FakeApiController implements FakeApi { + + private final FakeApiDelegate delegate; + + public FakeApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) FakeApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new FakeApiDelegate() {}); + } + + @Override + public FakeApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiDelegate.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiDelegate.java new file mode 100644 index 000000000000..dbe78fa1c7f9 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiDelegate.java @@ -0,0 +1,363 @@ +package org.openapitools.api; + +import java.math.BigDecimal; +import org.openapitools.model.Client; +import org.openapitools.model.FileSchemaTestClass; +import java.time.LocalDate; +import java.util.Map; +import org.openapitools.model.ModelApiResponse; +import java.time.OffsetDateTime; +import org.openapitools.model.OuterComposite; +import org.openapitools.model.User; +import org.openapitools.model.XmlItem; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import org.springframework.http.codec.multipart.Part; + +import java.util.List; +import java.util.Map; +import java.util.Optional; + +/** + * A delegate to be called by the {@link FakeApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public interface FakeApiDelegate { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * POST /fake/create_xml_item : creates an XmlItem + * this route creates an XmlItem + * + * @param xmlItem XmlItem Body (required) + * @return successful operation (status code 200) + * @see FakeApi#createXmlItem + */ + default Mono> createXmlItem(Mono xmlItem, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(Mono.empty()); + + } + + /** + * POST /fake/outer/boolean + * Test serialization of outer boolean types + * + * @param body Input boolean as post body (optional) + * @return Output boolean (status code 200) + * @see FakeApi#fakeOuterBooleanSerialize + */ + default Mono> fakeOuterBooleanSerialize(Mono body, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(Mono.empty()); + + } + + /** + * POST /fake/outer/composite + * Test serialization of object with outer number type + * + * @param body Input composite as post body (optional) + * @return Output composite (status code 200) + * @see FakeApi#fakeOuterCompositeSerialize + */ + default Mono> fakeOuterCompositeSerialize(Mono body, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) { + if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) { + String exampleString = "{ \"my_string\" : \"my_string\", \"my_number\" : 0.8008281904610115, \"my_boolean\" : true }"; + result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString); + break; + } + } + return result.then(Mono.empty()); + + } + + /** + * POST /fake/outer/number + * Test serialization of outer number types + * + * @param body Input number as post body (optional) + * @return Output number (status code 200) + * @see FakeApi#fakeOuterNumberSerialize + */ + default Mono> fakeOuterNumberSerialize(Mono body, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(Mono.empty()); + + } + + /** + * POST /fake/outer/string + * Test serialization of outer string types + * + * @param body Input string as post body (optional) + * @return Output string (status code 200) + * @see FakeApi#fakeOuterStringSerialize + */ + default Mono> fakeOuterStringSerialize(Mono body, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(Mono.empty()); + + } + + /** + * PUT /fake/body-with-file-schema + * For this test, the body for this request much reference a schema named `File`. + * + * @param body (required) + * @return Success (status code 200) + * @see FakeApi#testBodyWithFileSchema + */ + default Mono> testBodyWithFileSchema(Mono body, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(Mono.empty()); + + } + + /** + * PUT /fake/body-with-query-params + * + * @param query (required) + * @param body (required) + * @return Success (status code 200) + * @see FakeApi#testBodyWithQueryParams + */ + default Mono> testBodyWithQueryParams(String query, + Mono body, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(Mono.empty()); + + } + + /** + * PATCH /fake : To test \"client\" model + * To test \"client\" model + * + * @param body client model (required) + * @return successful operation (status code 200) + * @see FakeApi#testClientModel + */ + default Mono> testClientModel(Mono body, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"client\" : \"client\" }"; + result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString); + break; + } + } + return result.then(Mono.empty()); + + } + + /** + * POST /fake : Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * + * @param number None (required) + * @param _double None (required) + * @param patternWithoutDelimiter None (required) + * @param _byte None (required) + * @param integer None (optional) + * @param int32 None (optional) + * @param int64 None (optional) + * @param _float None (optional) + * @param string None (optional) + * @param binary None (optional) + * @param date None (optional) + * @param dateTime None (optional) + * @param password None (optional) + * @param paramCallback None (optional) + * @return Invalid username supplied (status code 400) + * or User not found (status code 404) + * @see FakeApi#testEndpointParameters + */ + default Mono> testEndpointParameters(BigDecimal number, + Double _double, + String patternWithoutDelimiter, + byte[] _byte, + Integer integer, + Integer int32, + Long int64, + Float _float, + String string, + Flux binary, + LocalDate date, + OffsetDateTime dateTime, + String password, + String paramCallback, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(Mono.empty()); + + } + + /** + * GET /fake : To test enum parameters + * To test enum parameters + * + * @param enumHeaderStringArray Header parameter enum test (string array) (optional) + * @param enumHeaderString Header parameter enum test (string) (optional, default to -efg) + * @param enumQueryStringArray Query parameter enum test (string array) (optional) + * @param enumQueryString Query parameter enum test (string) (optional, default to -efg) + * @param enumQueryInteger Query parameter enum test (double) (optional) + * @param enumQueryDouble Query parameter enum test (double) (optional) + * @param enumFormStringArray Form parameter enum test (string array) (optional, default to $) + * @param enumFormString Form parameter enum test (string) (optional, default to -efg) + * @return Invalid request (status code 400) + * or Not found (status code 404) + * @see FakeApi#testEnumParameters + */ + default Mono> testEnumParameters(List enumHeaderStringArray, + String enumHeaderString, + List enumQueryStringArray, + String enumQueryString, + Integer enumQueryInteger, + Double enumQueryDouble, + List enumFormStringArray, + String enumFormString, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(Mono.empty()); + + } + + /** + * DELETE /fake : Fake endpoint to test group parameters (optional) + * Fake endpoint to test group parameters (optional) + * + * @param requiredStringGroup Required String in group parameters (required) + * @param requiredBooleanGroup Required Boolean in group parameters (required) + * @param requiredInt64Group Required Integer in group parameters (required) + * @param stringGroup String in group parameters (optional) + * @param booleanGroup Boolean in group parameters (optional) + * @param int64Group Integer in group parameters (optional) + * @return Someting wrong (status code 400) + * @see FakeApi#testGroupParameters + */ + default Mono> testGroupParameters(Integer requiredStringGroup, + Boolean requiredBooleanGroup, + Long requiredInt64Group, + Integer stringGroup, + Boolean booleanGroup, + Long int64Group, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(Mono.empty()); + + } + + /** + * POST /fake/inline-additionalProperties : test inline additionalProperties + * + * @param param request body (required) + * @return successful operation (status code 200) + * @see FakeApi#testInlineAdditionalProperties + */ + default Mono> testInlineAdditionalProperties(Mono> param, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(Mono.empty()); + + } + + /** + * GET /fake/jsonFormData : test json serialization of form data + * + * @param param field1 (required) + * @param param2 field2 (required) + * @return successful operation (status code 200) + * @see FakeApi#testJsonFormData + */ + default Mono> testJsonFormData(String param, + String param2, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(Mono.empty()); + + } + + /** + * PUT /fake/test-query-parameters + * To test the collection format in query parameters + * + * @param pipe (required) + * @param ioutil (required) + * @param http (required) + * @param url (required) + * @param context (required) + * @return Success (status code 200) + * @see FakeApi#testQueryParameterCollectionFormat + */ + default Mono> testQueryParameterCollectionFormat(List pipe, + List ioutil, + List http, + List url, + List context, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(Mono.empty()); + + } + + /** + * POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required) + * + * @param petId ID of pet to update (required) + * @param requiredFile file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @return successful operation (status code 200) + * @see FakeApi#uploadFileWithRequiredFile + */ + default Mono> uploadFileWithRequiredFile(Long petId, + Flux requiredFile, + String additionalMetadata, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\" }"; + result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString); + break; + } + } + return result.then(Mono.empty()); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApi.java new file mode 100644 index 000000000000..229cba518a2a --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -0,0 +1,69 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.openapitools.api; + +import org.openapitools.model.Client; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import org.springframework.http.codec.multipart.Part; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "fake_classname_test", description = "the fake_classname_test API") +public interface FakeClassnameTestApi { + + default FakeClassnameTestApiDelegate getDelegate() { + return new FakeClassnameTestApiDelegate() {}; + } + + /** + * PATCH /fake_classname_test : To test class name in snake case + * To test class name in snake case + * + * @param body client model (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "To test class name in snake case", + tags = { "fake_classname_tags 123#$%^" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Client.class))) + }, + security = { + @SecurityRequirement(name = "api_key_query") + } + ) + @RequestMapping( + method = RequestMethod.PATCH, + value = "/fake_classname_test", + produces = { "application/json" }, + consumes = { "application/json" } + ) + default Mono> testClassname( + @Parameter(name = "body", description = "client model", required = true, schema = @Schema(description = "")) @Valid @RequestBody Mono body, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().testClassname(body, exchange); + } + +} diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java new file mode 100644 index 000000000000..58497641e4c5 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java @@ -0,0 +1,22 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class FakeClassnameTestApiController implements FakeClassnameTestApi { + + private final FakeClassnameTestApiDelegate delegate; + + public FakeClassnameTestApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) FakeClassnameTestApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new FakeClassnameTestApiDelegate() {}); + } + + @Override + public FakeClassnameTestApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java new file mode 100644 index 000000000000..4127d96d9e3e --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java @@ -0,0 +1,52 @@ +package org.openapitools.api; + +import org.openapitools.model.Client; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import org.springframework.http.codec.multipart.Part; + +import java.util.List; +import java.util.Map; +import java.util.Optional; + +/** + * A delegate to be called by the {@link FakeClassnameTestApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public interface FakeClassnameTestApiDelegate { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * PATCH /fake_classname_test : To test class name in snake case + * To test class name in snake case + * + * @param body client model (required) + * @return successful operation (status code 200) + * @see FakeClassnameTestApi#testClassname + */ + default Mono> testClassname(Mono body, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"client\" : \"client\" }"; + result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString); + break; + } + } + return result.then(Mono.empty()); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApi.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApi.java new file mode 100644 index 000000000000..150f20d9401e --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApi.java @@ -0,0 +1,304 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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 java.util.Set; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import org.springframework.http.codec.multipart.Part; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "pet", description = "the pet API") +public interface PetApi { + + default PetApiDelegate getDelegate() { + return new PetApiDelegate() {}; + } + + /** + * POST /pet : Add a new pet to the store + * + * @param body Pet object that needs to be added to the store (required) + * @return successful operation (status code 200) + * or Invalid input (status code 405) + */ + @Operation( + summary = "Add a new pet to the store", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation"), + @ApiResponse(responseCode = "405", description = "Invalid input") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet", + consumes = { "application/json", "application/xml" } + ) + default Mono> addPet( + @Parameter(name = "body", description = "Pet object that needs to be added to the store", required = true, schema = @Schema(description = "")) @Valid @RequestBody Mono body, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().addPet(body, exchange); + } + + + /** + * DELETE /pet/{petId} : Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @return successful operation (status code 200) + * or Invalid pet value (status code 400) + */ + @Operation( + summary = "Deletes a pet", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation"), + @ApiResponse(responseCode = "400", description = "Invalid pet value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/pet/{petId}" + ) + default Mono> deletePet( + @Parameter(name = "petId", description = "Pet id to delete", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "api_key", description = "", schema = @Schema(description = "")) @RequestHeader(value = "api_key", required = false) String apiKey, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().deletePet(petId, apiKey, exchange); + } + + + /** + * 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) + */ + @Operation( + summary = "Finds Pets by status", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid status value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/findByStatus", + produces = { "application/xml", "application/json" } + ) + default Mono>> findPetsByStatus( + @NotNull @Parameter(name = "status", description = "Status values that need to be considered for filter", required = true, schema = @Schema(description = "", allowableValues = { "available", "pending", "sold" })) @Valid @RequestParam(value = "status", required = true) List status, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().findPetsByStatus(status, exchange); + } + + + /** + * 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 + */ + @Operation( + summary = "Finds Pets by tags", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid tag value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/findByTags", + produces = { "application/xml", "application/json" } + ) + default Mono>> findPetsByTags( + @NotNull @Parameter(name = "tags", description = "Tags to filter by", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "tags", required = true) Set tags, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().findPetsByTags(tags, exchange); + } + + + /** + * 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) + */ + @Operation( + summary = "Find pet by ID", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/{petId}", + produces = { "application/xml", "application/json" } + ) + default Mono> getPetById( + @Parameter(name = "petId", description = "ID of pet to return", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().getPetById(petId, exchange); + } + + + /** + * PUT /pet : Update an existing pet + * + * @param body 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) + */ + @Operation( + summary = "Update an existing pet", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation"), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found"), + @ApiResponse(responseCode = "405", description = "Validation exception") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/pet", + consumes = { "application/json", "application/xml" } + ) + default Mono> updatePet( + @Parameter(name = "body", description = "Pet object that needs to be added to the store", required = true, schema = @Schema(description = "")) @Valid @RequestBody Mono body, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().updatePet(body, exchange); + } + + + /** + * 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) + */ + @Operation( + summary = "Updates a pet in the store with form data", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "405", description = "Invalid input") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet/{petId}", + consumes = { "application/x-www-form-urlencoded" } + ) + default Mono> updatePetWithForm( + @Parameter(name = "petId", description = "ID of pet that needs to be updated", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "name", description = "Updated name of the pet", schema = @Schema(description = "")) @Valid @RequestPart(value = "name", required = false) String name, + @Parameter(name = "status", description = "Updated status of the pet", schema = @Schema(description = "")) @Valid @RequestPart(value = "status", required = false) String status, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().updatePetWithForm(petId, name, status, exchange); + } + + + /** + * 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) + */ + @Operation( + summary = "uploads an image", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ModelApiResponse.class))) + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet/{petId}/uploadImage", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) + default Mono> uploadFile( + @Parameter(name = "petId", description = "ID of pet to update", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "additionalMetadata", description = "Additional data to pass to server", schema = @Schema(description = "")) @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @Parameter(name = "file", description = "file to upload", schema = @Schema(description = "")) @RequestPart(value = "file", required = false) Flux file, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().uploadFile(petId, additionalMetadata, file, exchange); + } + +} diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApiController.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApiController.java new file mode 100644 index 000000000000..5fa088c6f10b --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApiController.java @@ -0,0 +1,22 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import java.util.Optional; +@javax.annotation.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(@org.springframework.beans.factory.annotation.Autowired(required = false) PetApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new PetApiDelegate() {}); + } + + @Override + public PetApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApiDelegate.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApiDelegate.java new file mode 100644 index 000000000000..8dc1be776ea0 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApiDelegate.java @@ -0,0 +1,217 @@ +package org.openapitools.api; + +import org.openapitools.model.ModelApiResponse; +import org.openapitools.model.Pet; +import java.util.Set; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import org.springframework.http.codec.multipart.Part; + +import java.util.List; +import java.util.Map; +import java.util.Optional; + +/** + * A delegate to be called by the {@link PetApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public interface PetApiDelegate { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * POST /pet : Add a new pet to the store + * + * @param body 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 Mono> addPet(Mono body, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(Mono.empty()); + + } + + /** + * DELETE /pet/{petId} : Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @return successful operation (status code 200) + * or Invalid pet value (status code 400) + * @see PetApi#deletePet + */ + default Mono> deletePet(Long petId, + String apiKey, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(Mono.empty()); + + } + + /** + * 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 Mono>> findPetsByStatus(List status, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }"; + result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + String exampleString = " 123456789 doggie aeiou aeiou "; + result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString); + break; + } + } + return result.then(Mono.empty()); + + } + + /** + * 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 + */ + default Mono>> findPetsByTags(Set tags, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }"; + result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + String exampleString = " 123456789 doggie aeiou aeiou "; + result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString); + break; + } + } + return result.then(Mono.empty()); + + } + + /** + * 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 Mono> getPetById(Long petId, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }"; + result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + String exampleString = " 123456789 doggie aeiou aeiou "; + result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString); + break; + } + } + return result.then(Mono.empty()); + + } + + /** + * PUT /pet : Update an existing pet + * + * @param body 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) + * @see PetApi#updatePet + */ + default Mono> updatePet(Mono body, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(Mono.empty()); + + } + + /** + * 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 Mono> updatePetWithForm(Long petId, + String name, + String status, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(Mono.empty()); + + } + + /** + * 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 Mono> uploadFile(Long petId, + String additionalMetadata, + Flux file, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\" }"; + result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString); + break; + } + } + return result.then(Mono.empty()); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApi.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApi.java new file mode 100644 index 000000000000..056bfb145d45 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApi.java @@ -0,0 +1,154 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import org.springframework.http.codec.multipart.Part; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "store", description = "the store API") +public interface StoreApi { + + default StoreApiDelegate getDelegate() { + return new StoreApiDelegate() {}; + } + + /** + * DELETE /store/order/{order_id} : 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) + */ + @Operation( + summary = "Delete purchase order by ID", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/store/order/{order_id}" + ) + default Mono> deleteOrder( + @Parameter(name = "order_id", description = "ID of the order that needs to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("order_id") String orderId, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().deleteOrder(orderId, exchange); + } + + + /** + * GET /store/inventory : Returns pet inventories by status + * Returns a map of status codes to quantities + * + * @return successful operation (status code 200) + */ + @Operation( + summary = "Returns pet inventories by status", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Map.class))) + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/store/inventory", + produces = { "application/json" } + ) + default Mono>> getInventory( + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().getInventory(exchange); + } + + + /** + * GET /store/order/{order_id} : Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated 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) + */ + @Operation( + summary = "Find purchase order by ID", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/store/order/{order_id}", + produces = { "application/xml", "application/json" } + ) + default Mono> getOrderById( + @Min(1L) @Max(5L) @Parameter(name = "order_id", description = "ID of pet that needs to be fetched", required = true, schema = @Schema(description = "")) @PathVariable("order_id") Long orderId, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().getOrderById(orderId, exchange); + } + + + /** + * POST /store/order : Place an order for a pet + * + * @param body order placed for purchasing the pet (required) + * @return successful operation (status code 200) + * or Invalid Order (status code 400) + */ + @Operation( + summary = "Place an order for a pet", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid Order") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/store/order", + produces = { "application/xml", "application/json" } + ) + default Mono> placeOrder( + @Parameter(name = "body", description = "order placed for purchasing the pet", required = true, schema = @Schema(description = "")) @Valid @RequestBody Mono body, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().placeOrder(body, exchange); + } + +} diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApiController.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApiController.java new file mode 100644 index 000000000000..9e08c646ae92 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApiController.java @@ -0,0 +1,22 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import java.util.Optional; +@javax.annotation.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(@org.springframework.beans.factory.annotation.Autowired(required = false) StoreApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new StoreApiDelegate() {}); + } + + @Override + public StoreApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApiDelegate.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApiDelegate.java new file mode 100644 index 000000000000..02daadf024a1 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApiDelegate.java @@ -0,0 +1,119 @@ +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.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import org.springframework.http.codec.multipart.Part; + +import java.util.List; +import java.util.Map; +import java.util.Optional; + +/** + * A delegate to be called by the {@link StoreApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public interface StoreApiDelegate { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * DELETE /store/order/{order_id} : 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 Mono> deleteOrder(String orderId, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(Mono.empty()); + + } + + /** + * 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 Mono>> getInventory(ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(Mono.empty()); + + } + + /** + * GET /store/order/{order_id} : Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated 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 Mono> getOrderById(Long orderId, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) { + 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\" }"; + result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + String exampleString = " 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true "; + result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString); + break; + } + } + return result.then(Mono.empty()); + + } + + /** + * POST /store/order : Place an order for a pet + * + * @param body order placed for purchasing the pet (required) + * @return successful operation (status code 200) + * or Invalid Order (status code 400) + * @see StoreApi#placeOrder + */ + default Mono> placeOrder(Mono body, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) { + 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\" }"; + result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + String exampleString = " 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true "; + result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString); + break; + } + } + return result.then(Mono.empty()); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApi.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApi.java new file mode 100644 index 000000000000..1bdbac92e64c --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApi.java @@ -0,0 +1,257 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import org.springframework.http.codec.multipart.Part; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "user", description = "the user API") +public interface UserApi { + + default UserApiDelegate getDelegate() { + return new UserApiDelegate() {}; + } + + /** + * POST /user : Create user + * This can only be done by the logged in user. + * + * @param body Created user object (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "Create user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user" + ) + default Mono> createUser( + @Parameter(name = "body", description = "Created user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody Mono body, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().createUser(body, exchange); + } + + + /** + * POST /user/createWithArray : Creates list of users with given input array + * + * @param body List of user object (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "Creates list of users with given input array", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user/createWithArray" + ) + default Mono> createUsersWithArrayInput( + @Parameter(name = "body", description = "List of user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody Flux body, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().createUsersWithArrayInput(body, exchange); + } + + + /** + * POST /user/createWithList : Creates list of users with given input array + * + * @param body List of user object (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "Creates list of users with given input array", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user/createWithList" + ) + default Mono> createUsersWithListInput( + @Parameter(name = "body", description = "List of user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody Flux body, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().createUsersWithListInput(body, exchange); + } + + + /** + * 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) + */ + @Operation( + summary = "Delete user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/user/{username}" + ) + default Mono> deleteUser( + @Parameter(name = "username", description = "The name that needs to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("username") String username, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().deleteUser(username, exchange); + } + + + /** + * 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) + */ + @Operation( + summary = "Get user by user name", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = User.class))), + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/{username}", + produces = { "application/xml", "application/json" } + ) + default Mono> getUserByName( + @Parameter(name = "username", description = "The name that needs to be fetched. Use user1 for testing.", required = true, schema = @Schema(description = "")) @PathVariable("username") String username, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().getUserByName(username, exchange); + } + + + /** + * 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) + */ + @Operation( + summary = "Logs user into the system", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "400", description = "Invalid username/password supplied") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/login", + produces = { "application/xml", "application/json" } + ) + default Mono> loginUser( + @NotNull @Parameter(name = "username", description = "The user name for login", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "username", required = true) String username, + @NotNull @Parameter(name = "password", description = "The password for login in clear text", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "password", required = true) String password, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().loginUser(username, password, exchange); + } + + + /** + * GET /user/logout : Logs out current logged in user session + * + * @return successful operation (status code 200) + */ + @Operation( + summary = "Logs out current logged in user session", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/logout" + ) + default Mono> logoutUser( + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().logoutUser(exchange); + } + + + /** + * 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 body Updated user object (required) + * @return Invalid user supplied (status code 400) + * or User not found (status code 404) + */ + @Operation( + summary = "Updated user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid user supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/user/{username}" + ) + default Mono> updateUser( + @Parameter(name = "username", description = "name that need to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("username") String username, + @Parameter(name = "body", description = "Updated user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody Mono body, + @Parameter(hidden = true) final ServerWebExchange exchange + ) { + return getDelegate().updateUser(username, body, exchange); + } + +} diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApiController.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApiController.java new file mode 100644 index 000000000000..bc2d33598fd9 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApiController.java @@ -0,0 +1,22 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import java.util.Optional; +@javax.annotation.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(@org.springframework.beans.factory.annotation.Autowired(required = false) UserApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new UserApiDelegate() {}); + } + + @Override + public UserApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApiDelegate.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApiDelegate.java new file mode 100644 index 000000000000..3985dd30ecdf --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApiDelegate.java @@ -0,0 +1,173 @@ +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.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import org.springframework.http.codec.multipart.Part; + +import java.util.List; +import java.util.Map; +import java.util.Optional; + +/** + * A delegate to be called by the {@link UserApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public interface UserApiDelegate { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * POST /user : Create user + * This can only be done by the logged in user. + * + * @param body Created user object (required) + * @return successful operation (status code 200) + * @see UserApi#createUser + */ + default Mono> createUser(Mono body, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(Mono.empty()); + + } + + /** + * POST /user/createWithArray : Creates list of users with given input array + * + * @param body List of user object (required) + * @return successful operation (status code 200) + * @see UserApi#createUsersWithArrayInput + */ + default Mono> createUsersWithArrayInput(Flux body, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(Mono.empty()); + + } + + /** + * POST /user/createWithList : Creates list of users with given input array + * + * @param body List of user object (required) + * @return successful operation (status code 200) + * @see UserApi#createUsersWithListInput + */ + default Mono> createUsersWithListInput(Flux body, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(Mono.empty()); + + } + + /** + * 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 Mono> deleteUser(String username, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(Mono.empty()); + + } + + /** + * 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 Mono> getUserByName(String username, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) { + 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\" }"; + result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + String exampleString = " 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123 "; + result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString); + break; + } + } + return result.then(Mono.empty()); + + } + + /** + * 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 Mono> loginUser(String username, + String password, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(Mono.empty()); + + } + + /** + * GET /user/logout : Logs out current logged in user session + * + * @return successful operation (status code 200) + * @see UserApi#logoutUser + */ + default Mono> logoutUser(ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(Mono.empty()); + + } + + /** + * 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 body Updated user object (required) + * @return Invalid user supplied (status code 400) + * or User not found (status code 404) + * @see UserApi#updateUser + */ + default Mono> updateUser(String username, + Mono body, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(Mono.empty()); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/configuration/HomeController.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/configuration/HomeController.java new file mode 100644 index 000000000000..b1e5bfc21ee5 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/configuration/HomeController.java @@ -0,0 +1,62 @@ +package org.openapitools.configuration; + +import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.core.io.Resource; +import org.springframework.stereotype.Controller; +import org.springframework.util.StreamUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerResponse; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.nio.charset.Charset; + +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; + +/** + * Home redirection to OpenAPI api documentation + */ +@Controller +public class HomeController { + + private static YAMLMapper yamlMapper = new YAMLMapper(); + + @Value("classpath:/openapi.yaml") + private Resource openapi; + + @Bean + public String openapiContent() throws IOException { + try(InputStream is = openapi.getInputStream()) { + return StreamUtils.copyToString(is, Charset.defaultCharset()); + } + } + + @GetMapping(value = "/openapi.yaml", produces = "application/vnd.oai.openapi") + @ResponseBody + public String openapiYaml() throws IOException { + return openapiContent(); + } + + @GetMapping(value = "/openapi.json", produces = "application/json") + @ResponseBody + public Object openapiJson() throws IOException { + return yamlMapper.readValue(openapiContent(), Object.class); + } + + @Bean + RouterFunction index() { + return route( + GET("/"), + req -> ServerResponse.temporaryRedirect(URI.create("swagger-ui/index.html?url=../openapi.json")).build() + ); + } + + +} diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java new file mode 100644 index 000000000000..0c57ae7dd14c --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java @@ -0,0 +1,86 @@ +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 java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesAnyType + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesAnyType extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesAnyType name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesAnyType additionalPropertiesAnyType = (AdditionalPropertiesAnyType) o; + return Objects.equals(this.name, additionalPropertiesAnyType.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesAnyType {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/AdditionalPropertiesArray.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/AdditionalPropertiesArray.java new file mode 100644 index 000000000000..b5285ec2f29b --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/AdditionalPropertiesArray.java @@ -0,0 +1,87 @@ +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 java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesArray + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesArray extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesArray name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesArray additionalPropertiesArray = (AdditionalPropertiesArray) o; + return Objects.equals(this.name, additionalPropertiesArray.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesArray {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java new file mode 100644 index 000000000000..f8ca38c286d5 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java @@ -0,0 +1,86 @@ +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 java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesBoolean + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesBoolean extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesBoolean name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesBoolean additionalPropertiesBoolean = (AdditionalPropertiesBoolean) o; + return Objects.equals(this.name, additionalPropertiesBoolean.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesBoolean {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java new file mode 100644 index 000000000000..dfd28ccb9963 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java @@ -0,0 +1,414 @@ +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 java.math.BigDecimal; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesClass + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesClass { + @JsonProperty("map_string") + @Valid + private Map mapString = null; + + @JsonProperty("map_number") + @Valid + private Map mapNumber = null; + + @JsonProperty("map_integer") + @Valid + private Map mapInteger = null; + + @JsonProperty("map_boolean") + @Valid + private Map mapBoolean = null; + + @JsonProperty("map_array_integer") + @Valid + private Map> mapArrayInteger = null; + + @JsonProperty("map_array_anytype") + @Valid + private Map> mapArrayAnytype = null; + + @JsonProperty("map_map_string") + @Valid + private Map> mapMapString = null; + + @JsonProperty("map_map_anytype") + @Valid + private Map> mapMapAnytype = null; + + @JsonProperty("anytype_1") + private Object anytype1; + + @JsonProperty("anytype_2") + private Object anytype2; + + @JsonProperty("anytype_3") + private Object anytype3; + + public AdditionalPropertiesClass mapString(Map mapString) { + this.mapString = mapString; + return this; + } + + public AdditionalPropertiesClass putMapStringItem(String key, String mapStringItem) { + if (this.mapString == null) { + this.mapString = new HashMap<>(); + } + this.mapString.put(key, mapStringItem); + return this; + } + + /** + * Get mapString + * @return mapString + */ + @Schema(name = "mapString", defaultValue = "") + + + public Map getMapString() { + return mapString; + } + + public void setMapString(Map mapString) { + this.mapString = mapString; + } + + public AdditionalPropertiesClass mapNumber(Map mapNumber) { + this.mapNumber = mapNumber; + return this; + } + + public AdditionalPropertiesClass putMapNumberItem(String key, BigDecimal mapNumberItem) { + if (this.mapNumber == null) { + this.mapNumber = new HashMap<>(); + } + this.mapNumber.put(key, mapNumberItem); + return this; + } + + /** + * Get mapNumber + * @return mapNumber + */ + @Schema(name = "mapNumber", defaultValue = "") + + @Valid + + public Map getMapNumber() { + return mapNumber; + } + + public void setMapNumber(Map mapNumber) { + this.mapNumber = mapNumber; + } + + public AdditionalPropertiesClass mapInteger(Map mapInteger) { + this.mapInteger = mapInteger; + return this; + } + + public AdditionalPropertiesClass putMapIntegerItem(String key, Integer mapIntegerItem) { + if (this.mapInteger == null) { + this.mapInteger = new HashMap<>(); + } + this.mapInteger.put(key, mapIntegerItem); + return this; + } + + /** + * Get mapInteger + * @return mapInteger + */ + @Schema(name = "mapInteger", defaultValue = "") + + + public Map getMapInteger() { + return mapInteger; + } + + public void setMapInteger(Map mapInteger) { + this.mapInteger = mapInteger; + } + + public AdditionalPropertiesClass mapBoolean(Map mapBoolean) { + this.mapBoolean = mapBoolean; + return this; + } + + public AdditionalPropertiesClass putMapBooleanItem(String key, Boolean mapBooleanItem) { + if (this.mapBoolean == null) { + this.mapBoolean = new HashMap<>(); + } + this.mapBoolean.put(key, mapBooleanItem); + return this; + } + + /** + * Get mapBoolean + * @return mapBoolean + */ + @Schema(name = "mapBoolean", defaultValue = "") + + + public Map getMapBoolean() { + return mapBoolean; + } + + public void setMapBoolean(Map mapBoolean) { + this.mapBoolean = mapBoolean; + } + + public AdditionalPropertiesClass mapArrayInteger(Map> mapArrayInteger) { + this.mapArrayInteger = mapArrayInteger; + return this; + } + + public AdditionalPropertiesClass putMapArrayIntegerItem(String key, List mapArrayIntegerItem) { + if (this.mapArrayInteger == null) { + this.mapArrayInteger = new HashMap<>(); + } + this.mapArrayInteger.put(key, mapArrayIntegerItem); + return this; + } + + /** + * Get mapArrayInteger + * @return mapArrayInteger + */ + @Schema(name = "mapArrayInteger", defaultValue = "") + + @Valid + + public Map> getMapArrayInteger() { + return mapArrayInteger; + } + + public void setMapArrayInteger(Map> mapArrayInteger) { + this.mapArrayInteger = mapArrayInteger; + } + + public AdditionalPropertiesClass mapArrayAnytype(Map> mapArrayAnytype) { + this.mapArrayAnytype = mapArrayAnytype; + return this; + } + + public AdditionalPropertiesClass putMapArrayAnytypeItem(String key, List mapArrayAnytypeItem) { + if (this.mapArrayAnytype == null) { + this.mapArrayAnytype = new HashMap<>(); + } + this.mapArrayAnytype.put(key, mapArrayAnytypeItem); + return this; + } + + /** + * Get mapArrayAnytype + * @return mapArrayAnytype + */ + @Schema(name = "mapArrayAnytype", defaultValue = "") + + @Valid + + public Map> getMapArrayAnytype() { + return mapArrayAnytype; + } + + public void setMapArrayAnytype(Map> mapArrayAnytype) { + this.mapArrayAnytype = mapArrayAnytype; + } + + public AdditionalPropertiesClass mapMapString(Map> mapMapString) { + this.mapMapString = mapMapString; + return this; + } + + public AdditionalPropertiesClass putMapMapStringItem(String key, Map mapMapStringItem) { + if (this.mapMapString == null) { + this.mapMapString = new HashMap<>(); + } + this.mapMapString.put(key, mapMapStringItem); + return this; + } + + /** + * Get mapMapString + * @return mapMapString + */ + @Schema(name = "mapMapString", defaultValue = "") + + @Valid + + public Map> getMapMapString() { + return mapMapString; + } + + public void setMapMapString(Map> mapMapString) { + this.mapMapString = mapMapString; + } + + public AdditionalPropertiesClass mapMapAnytype(Map> mapMapAnytype) { + this.mapMapAnytype = mapMapAnytype; + return this; + } + + public AdditionalPropertiesClass putMapMapAnytypeItem(String key, Map mapMapAnytypeItem) { + if (this.mapMapAnytype == null) { + this.mapMapAnytype = new HashMap<>(); + } + this.mapMapAnytype.put(key, mapMapAnytypeItem); + return this; + } + + /** + * Get mapMapAnytype + * @return mapMapAnytype + */ + @Schema(name = "mapMapAnytype", defaultValue = "") + + @Valid + + public Map> getMapMapAnytype() { + return mapMapAnytype; + } + + public void setMapMapAnytype(Map> mapMapAnytype) { + this.mapMapAnytype = mapMapAnytype; + } + + public AdditionalPropertiesClass anytype1(Object anytype1) { + this.anytype1 = anytype1; + return this; + } + + /** + * Get anytype1 + * @return anytype1 + */ + @Schema(name = "anytype1", defaultValue = "") + + + public Object getAnytype1() { + return anytype1; + } + + public void setAnytype1(Object anytype1) { + this.anytype1 = anytype1; + } + + public AdditionalPropertiesClass anytype2(Object anytype2) { + this.anytype2 = anytype2; + return this; + } + + /** + * Get anytype2 + * @return anytype2 + */ + @Schema(name = "anytype2", defaultValue = "") + + + public Object getAnytype2() { + return anytype2; + } + + public void setAnytype2(Object anytype2) { + this.anytype2 = anytype2; + } + + public AdditionalPropertiesClass anytype3(Object anytype3) { + this.anytype3 = anytype3; + return this; + } + + /** + * Get anytype3 + * @return anytype3 + */ + @Schema(name = "anytype3", defaultValue = "") + + + public Object getAnytype3() { + return anytype3; + } + + public void setAnytype3(Object anytype3) { + this.anytype3 = anytype3; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AdditionalPropertiesClass additionalPropertiesClass = (AdditionalPropertiesClass) o; + return Objects.equals(this.mapString, additionalPropertiesClass.mapString) && + Objects.equals(this.mapNumber, additionalPropertiesClass.mapNumber) && + Objects.equals(this.mapInteger, additionalPropertiesClass.mapInteger) && + Objects.equals(this.mapBoolean, additionalPropertiesClass.mapBoolean) && + Objects.equals(this.mapArrayInteger, additionalPropertiesClass.mapArrayInteger) && + Objects.equals(this.mapArrayAnytype, additionalPropertiesClass.mapArrayAnytype) && + Objects.equals(this.mapMapString, additionalPropertiesClass.mapMapString) && + Objects.equals(this.mapMapAnytype, additionalPropertiesClass.mapMapAnytype) && + Objects.equals(this.anytype1, additionalPropertiesClass.anytype1) && + Objects.equals(this.anytype2, additionalPropertiesClass.anytype2) && + Objects.equals(this.anytype3, additionalPropertiesClass.anytype3); + } + + @Override + public int hashCode() { + return Objects.hash(mapString, mapNumber, mapInteger, mapBoolean, mapArrayInteger, mapArrayAnytype, mapMapString, mapMapAnytype, anytype1, anytype2, anytype3); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesClass {\n"); + + sb.append(" mapString: ").append(toIndentedString(mapString)).append("\n"); + sb.append(" mapNumber: ").append(toIndentedString(mapNumber)).append("\n"); + sb.append(" mapInteger: ").append(toIndentedString(mapInteger)).append("\n"); + sb.append(" mapBoolean: ").append(toIndentedString(mapBoolean)).append("\n"); + sb.append(" mapArrayInteger: ").append(toIndentedString(mapArrayInteger)).append("\n"); + sb.append(" mapArrayAnytype: ").append(toIndentedString(mapArrayAnytype)).append("\n"); + sb.append(" mapMapString: ").append(toIndentedString(mapMapString)).append("\n"); + sb.append(" mapMapAnytype: ").append(toIndentedString(mapMapAnytype)).append("\n"); + sb.append(" anytype1: ").append(toIndentedString(anytype1)).append("\n"); + sb.append(" anytype2: ").append(toIndentedString(anytype2)).append("\n"); + sb.append(" anytype3: ").append(toIndentedString(anytype3)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java new file mode 100644 index 000000000000..5fea577ab44b --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java @@ -0,0 +1,86 @@ +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 java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesInteger + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesInteger extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesInteger name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesInteger additionalPropertiesInteger = (AdditionalPropertiesInteger) o; + return Objects.equals(this.name, additionalPropertiesInteger.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesInteger {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java new file mode 100644 index 000000000000..e6eee612a24f --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java @@ -0,0 +1,87 @@ +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 java.math.BigDecimal; +import java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesNumber + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesNumber extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesNumber name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesNumber additionalPropertiesNumber = (AdditionalPropertiesNumber) o; + return Objects.equals(this.name, additionalPropertiesNumber.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesNumber {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/AdditionalPropertiesObject.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/AdditionalPropertiesObject.java new file mode 100644 index 000000000000..d7116bd7572c --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/AdditionalPropertiesObject.java @@ -0,0 +1,86 @@ +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 java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesObject + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesObject extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesObject name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesObject additionalPropertiesObject = (AdditionalPropertiesObject) o; + return Objects.equals(this.name, additionalPropertiesObject.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesObject {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/AdditionalPropertiesString.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/AdditionalPropertiesString.java new file mode 100644 index 000000000000..d2022be266fb --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/AdditionalPropertiesString.java @@ -0,0 +1,86 @@ +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 java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesString + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesString extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesString name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesString additionalPropertiesString = (AdditionalPropertiesString) o; + return Objects.equals(this.name, additionalPropertiesString.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesString {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Animal.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Animal.java new file mode 100644 index 000000000000..6f096d5069ed --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Animal.java @@ -0,0 +1,118 @@ +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.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Animal + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "className", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = BigCat.class, name = "BigCat"), + @JsonSubTypes.Type(value = Cat.class, name = "Cat"), + @JsonSubTypes.Type(value = Dog.class, name = "Dog"), +}) + +public class Animal { + @JsonProperty("className") + private String className; + + @JsonProperty("color") + private String color = "red"; + + public Animal className(String className) { + this.className = className; + return this; + } + + /** + * Get className + * @return className + */ + @Schema(name = "className", required = true, defaultValue = "") + @NotNull + + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public Animal color(String color) { + this.color = color; + return this; + } + + /** + * Get color + * @return color + */ + @Schema(name = "color", defaultValue = "") + + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Animal animal = (Animal) o; + return Objects.equals(this.className, animal.className) && + Objects.equals(this.color, animal.color); + } + + @Override + public int hashCode() { + return Objects.hash(className, color); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Animal {\n"); + + sb.append(" className: ").append(toIndentedString(className)).append("\n"); + sb.append(" color: ").append(toIndentedString(color)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java new file mode 100644 index 000000000000..ebe36ad761a9 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java @@ -0,0 +1,96 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ArrayOfArrayOfNumberOnly + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ArrayOfArrayOfNumberOnly { + @JsonProperty("ArrayArrayNumber") + @Valid + private List> arrayArrayNumber = null; + + public ArrayOfArrayOfNumberOnly arrayArrayNumber(List> arrayArrayNumber) { + this.arrayArrayNumber = arrayArrayNumber; + return this; + } + + public ArrayOfArrayOfNumberOnly addArrayArrayNumberItem(List arrayArrayNumberItem) { + if (this.arrayArrayNumber == null) { + this.arrayArrayNumber = new ArrayList<>(); + } + this.arrayArrayNumber.add(arrayArrayNumberItem); + return this; + } + + /** + * Get arrayArrayNumber + * @return arrayArrayNumber + */ + @Schema(name = "arrayArrayNumber", defaultValue = "") + + @Valid + + public List> getArrayArrayNumber() { + return arrayArrayNumber; + } + + public void setArrayArrayNumber(List> arrayArrayNumber) { + this.arrayArrayNumber = arrayArrayNumber; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly = (ArrayOfArrayOfNumberOnly) o; + return Objects.equals(this.arrayArrayNumber, arrayOfArrayOfNumberOnly.arrayArrayNumber); + } + + @Override + public int hashCode() { + return Objects.hash(arrayArrayNumber); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayOfArrayOfNumberOnly {\n"); + + sb.append(" arrayArrayNumber: ").append(toIndentedString(arrayArrayNumber)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ArrayOfNumberOnly.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ArrayOfNumberOnly.java new file mode 100644 index 000000000000..8158dd44ab88 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ArrayOfNumberOnly.java @@ -0,0 +1,96 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ArrayOfNumberOnly + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ArrayOfNumberOnly { + @JsonProperty("ArrayNumber") + @Valid + private List arrayNumber = null; + + public ArrayOfNumberOnly arrayNumber(List arrayNumber) { + this.arrayNumber = arrayNumber; + return this; + } + + public ArrayOfNumberOnly addArrayNumberItem(BigDecimal arrayNumberItem) { + if (this.arrayNumber == null) { + this.arrayNumber = new ArrayList<>(); + } + this.arrayNumber.add(arrayNumberItem); + return this; + } + + /** + * Get arrayNumber + * @return arrayNumber + */ + @Schema(name = "arrayNumber", defaultValue = "") + + @Valid + + public List getArrayNumber() { + return arrayNumber; + } + + public void setArrayNumber(List arrayNumber) { + this.arrayNumber = arrayNumber; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayOfNumberOnly arrayOfNumberOnly = (ArrayOfNumberOnly) o; + return Objects.equals(this.arrayNumber, arrayOfNumberOnly.arrayNumber); + } + + @Override + public int hashCode() { + return Objects.hash(arrayNumber); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayOfNumberOnly {\n"); + + sb.append(" arrayNumber: ").append(toIndentedString(arrayNumber)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ArrayTest.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ArrayTest.java new file mode 100644 index 000000000000..420010561bcd --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ArrayTest.java @@ -0,0 +1,165 @@ +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 java.util.ArrayList; +import java.util.List; +import org.openapitools.model.ReadOnlyFirst; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ArrayTest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ArrayTest { + @JsonProperty("array_of_string") + @Valid + private List arrayOfString = null; + + @JsonProperty("array_array_of_integer") + @Valid + private List> arrayArrayOfInteger = null; + + @JsonProperty("array_array_of_model") + @Valid + private List> arrayArrayOfModel = null; + + public ArrayTest arrayOfString(List arrayOfString) { + this.arrayOfString = arrayOfString; + return this; + } + + public ArrayTest addArrayOfStringItem(String arrayOfStringItem) { + if (this.arrayOfString == null) { + this.arrayOfString = new ArrayList<>(); + } + this.arrayOfString.add(arrayOfStringItem); + return this; + } + + /** + * Get arrayOfString + * @return arrayOfString + */ + @Schema(name = "arrayOfString", defaultValue = "") + + + public List getArrayOfString() { + return arrayOfString; + } + + public void setArrayOfString(List arrayOfString) { + this.arrayOfString = arrayOfString; + } + + public ArrayTest arrayArrayOfInteger(List> arrayArrayOfInteger) { + this.arrayArrayOfInteger = arrayArrayOfInteger; + return this; + } + + public ArrayTest addArrayArrayOfIntegerItem(List arrayArrayOfIntegerItem) { + if (this.arrayArrayOfInteger == null) { + this.arrayArrayOfInteger = new ArrayList<>(); + } + this.arrayArrayOfInteger.add(arrayArrayOfIntegerItem); + return this; + } + + /** + * Get arrayArrayOfInteger + * @return arrayArrayOfInteger + */ + @Schema(name = "arrayArrayOfInteger", defaultValue = "") + + @Valid + + public List> getArrayArrayOfInteger() { + return arrayArrayOfInteger; + } + + public void setArrayArrayOfInteger(List> arrayArrayOfInteger) { + this.arrayArrayOfInteger = arrayArrayOfInteger; + } + + public ArrayTest arrayArrayOfModel(List> arrayArrayOfModel) { + this.arrayArrayOfModel = arrayArrayOfModel; + return this; + } + + public ArrayTest addArrayArrayOfModelItem(List arrayArrayOfModelItem) { + if (this.arrayArrayOfModel == null) { + this.arrayArrayOfModel = new ArrayList<>(); + } + this.arrayArrayOfModel.add(arrayArrayOfModelItem); + return this; + } + + /** + * Get arrayArrayOfModel + * @return arrayArrayOfModel + */ + @Schema(name = "arrayArrayOfModel", defaultValue = "") + + @Valid + + public List> getArrayArrayOfModel() { + return arrayArrayOfModel; + } + + public void setArrayArrayOfModel(List> arrayArrayOfModel) { + this.arrayArrayOfModel = arrayArrayOfModel; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayTest arrayTest = (ArrayTest) o; + return Objects.equals(this.arrayOfString, arrayTest.arrayOfString) && + Objects.equals(this.arrayArrayOfInteger, arrayTest.arrayArrayOfInteger) && + Objects.equals(this.arrayArrayOfModel, arrayTest.arrayArrayOfModel); + } + + @Override + public int hashCode() { + return Objects.hash(arrayOfString, arrayArrayOfInteger, arrayArrayOfModel); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayTest {\n"); + + sb.append(" arrayOfString: ").append(toIndentedString(arrayOfString)).append("\n"); + sb.append(" arrayArrayOfInteger: ").append(toIndentedString(arrayArrayOfInteger)).append("\n"); + sb.append(" arrayArrayOfModel: ").append(toIndentedString(arrayArrayOfModel)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/BigCat.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/BigCat.java new file mode 100644 index 000000000000..7f4a080ad8d2 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/BigCat.java @@ -0,0 +1,126 @@ +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 org.openapitools.model.BigCatAllOf; +import org.openapitools.model.Cat; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * BigCat + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class BigCat extends Cat { + /** + * Gets or Sets kind + */ + public enum KindEnum { + LIONS("lions"), + + TIGERS("tigers"), + + LEOPARDS("leopards"), + + JAGUARS("jaguars"); + + private String value; + + KindEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static KindEnum fromValue(String value) { + for (KindEnum b : KindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("kind") + private KindEnum kind; + + public BigCat kind(KindEnum kind) { + this.kind = kind; + return this; + } + + /** + * Get kind + * @return kind + */ + @Schema(name = "kind", defaultValue = "") + + + public KindEnum getKind() { + return kind; + } + + public void setKind(KindEnum kind) { + this.kind = kind; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BigCat bigCat = (BigCat) o; + return Objects.equals(this.kind, bigCat.kind) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(kind, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BigCat {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/BigCatAllOf.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/BigCatAllOf.java new file mode 100644 index 000000000000..d0a47ab5127c --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/BigCatAllOf.java @@ -0,0 +1,123 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * BigCatAllOf + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class BigCatAllOf { + /** + * Gets or Sets kind + */ + public enum KindEnum { + LIONS("lions"), + + TIGERS("tigers"), + + LEOPARDS("leopards"), + + JAGUARS("jaguars"); + + private String value; + + KindEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static KindEnum fromValue(String value) { + for (KindEnum b : KindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("kind") + private KindEnum kind; + + public BigCatAllOf kind(KindEnum kind) { + this.kind = kind; + return this; + } + + /** + * Get kind + * @return kind + */ + @Schema(name = "kind", defaultValue = "") + + + public KindEnum getKind() { + return kind; + } + + public void setKind(KindEnum kind) { + this.kind = kind; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BigCatAllOf bigCatAllOf = (BigCatAllOf) o; + return Objects.equals(this.kind, bigCatAllOf.kind); + } + + @Override + public int hashCode() { + return Objects.hash(kind); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BigCatAllOf {\n"); + + sb.append(" kind: ").append(toIndentedString(kind)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Capitalization.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Capitalization.java new file mode 100644 index 000000000000..92d9a7245f16 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Capitalization.java @@ -0,0 +1,208 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Capitalization + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Capitalization { + @JsonProperty("smallCamel") + private String smallCamel; + + @JsonProperty("CapitalCamel") + private String capitalCamel; + + @JsonProperty("small_Snake") + private String smallSnake; + + @JsonProperty("Capital_Snake") + private String capitalSnake; + + @JsonProperty("SCA_ETH_Flow_Points") + private String scAETHFlowPoints; + + @JsonProperty("ATT_NAME") + private String ATT_NAME; + + public Capitalization smallCamel(String smallCamel) { + this.smallCamel = smallCamel; + return this; + } + + /** + * Get smallCamel + * @return smallCamel + */ + @Schema(name = "smallCamel", defaultValue = "") + + + public String getSmallCamel() { + return smallCamel; + } + + public void setSmallCamel(String smallCamel) { + this.smallCamel = smallCamel; + } + + public Capitalization capitalCamel(String capitalCamel) { + this.capitalCamel = capitalCamel; + return this; + } + + /** + * Get capitalCamel + * @return capitalCamel + */ + @Schema(name = "capitalCamel", defaultValue = "") + + + public String getCapitalCamel() { + return capitalCamel; + } + + public void setCapitalCamel(String capitalCamel) { + this.capitalCamel = capitalCamel; + } + + public Capitalization smallSnake(String smallSnake) { + this.smallSnake = smallSnake; + return this; + } + + /** + * Get smallSnake + * @return smallSnake + */ + @Schema(name = "smallSnake", defaultValue = "") + + + public String getSmallSnake() { + return smallSnake; + } + + public void setSmallSnake(String smallSnake) { + this.smallSnake = smallSnake; + } + + public Capitalization capitalSnake(String capitalSnake) { + this.capitalSnake = capitalSnake; + return this; + } + + /** + * Get capitalSnake + * @return capitalSnake + */ + @Schema(name = "capitalSnake", defaultValue = "") + + + public String getCapitalSnake() { + return capitalSnake; + } + + public void setCapitalSnake(String capitalSnake) { + this.capitalSnake = capitalSnake; + } + + public Capitalization scAETHFlowPoints(String scAETHFlowPoints) { + this.scAETHFlowPoints = scAETHFlowPoints; + return this; + } + + /** + * Get scAETHFlowPoints + * @return scAETHFlowPoints + */ + @Schema(name = "scAETHFlowPoints", defaultValue = "") + + + public String getScAETHFlowPoints() { + return scAETHFlowPoints; + } + + public void setScAETHFlowPoints(String scAETHFlowPoints) { + this.scAETHFlowPoints = scAETHFlowPoints; + } + + public Capitalization ATT_NAME(String ATT_NAME) { + this.ATT_NAME = ATT_NAME; + return this; + } + + /** + * Name of the pet + * @return ATT_NAME + */ + @Schema(name = "ATT_NAME", defaultValue = "Name of the pet ") + + + public String getATTNAME() { + return ATT_NAME; + } + + public void setATTNAME(String ATT_NAME) { + this.ATT_NAME = ATT_NAME; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Capitalization capitalization = (Capitalization) o; + return Objects.equals(this.smallCamel, capitalization.smallCamel) && + Objects.equals(this.capitalCamel, capitalization.capitalCamel) && + Objects.equals(this.smallSnake, capitalization.smallSnake) && + Objects.equals(this.capitalSnake, capitalization.capitalSnake) && + Objects.equals(this.scAETHFlowPoints, capitalization.scAETHFlowPoints) && + Objects.equals(this.ATT_NAME, capitalization.ATT_NAME); + } + + @Override + public int hashCode() { + return Objects.hash(smallCamel, capitalCamel, smallSnake, capitalSnake, scAETHFlowPoints, ATT_NAME); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Capitalization {\n"); + + sb.append(" smallCamel: ").append(toIndentedString(smallCamel)).append("\n"); + sb.append(" capitalCamel: ").append(toIndentedString(capitalCamel)).append("\n"); + sb.append(" smallSnake: ").append(toIndentedString(smallSnake)).append("\n"); + sb.append(" capitalSnake: ").append(toIndentedString(capitalSnake)).append("\n"); + sb.append(" scAETHFlowPoints: ").append(toIndentedString(scAETHFlowPoints)).append("\n"); + sb.append(" ATT_NAME: ").append(toIndentedString(ATT_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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Cat.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Cat.java new file mode 100644 index 000000000000..2e496fb4accd --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Cat.java @@ -0,0 +1,86 @@ +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 org.openapitools.model.Animal; +import org.openapitools.model.CatAllOf; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Cat + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Cat extends Animal { + @JsonProperty("declawed") + private Boolean declawed; + + public Cat declawed(Boolean declawed) { + this.declawed = declawed; + return this; + } + + /** + * Get declawed + * @return declawed + */ + @Schema(name = "declawed", defaultValue = "") + + + public Boolean getDeclawed() { + return declawed; + } + + public void setDeclawed(Boolean declawed) { + this.declawed = declawed; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Cat cat = (Cat) o; + return Objects.equals(this.declawed, cat.declawed) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(declawed, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Cat {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" declawed: ").append(toIndentedString(declawed)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/CatAllOf.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/CatAllOf.java new file mode 100644 index 000000000000..b732a62b1bc3 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/CatAllOf.java @@ -0,0 +1,83 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * CatAllOf + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class CatAllOf { + @JsonProperty("declawed") + private Boolean declawed; + + public CatAllOf declawed(Boolean declawed) { + this.declawed = declawed; + return this; + } + + /** + * Get declawed + * @return declawed + */ + @Schema(name = "declawed", defaultValue = "") + + + public Boolean getDeclawed() { + return declawed; + } + + public void setDeclawed(Boolean declawed) { + this.declawed = declawed; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CatAllOf catAllOf = (CatAllOf) o; + return Objects.equals(this.declawed, catAllOf.declawed); + } + + @Override + public int hashCode() { + return Objects.hash(declawed); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CatAllOf {\n"); + + sb.append(" declawed: ").append(toIndentedString(declawed)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Category.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Category.java new file mode 100644 index 000000000000..038fc8df3afd --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Category.java @@ -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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Category + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Category { + @JsonProperty("id") + private Long id; + + @JsonProperty("name") + private String name = "default-name"; + + public Category id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "name", required = true, defaultValue = "") + @NotNull + + + 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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ClassModel.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ClassModel.java new file mode 100644 index 000000000000..fa2a736f4fb5 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ClassModel.java @@ -0,0 +1,84 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Model for testing model with \"_class\" property + */ +@Schema(name = "ClassModel",description = "Model for testing model with \"_class\" property") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ClassModel { + @JsonProperty("_class") + private String propertyClass; + + public ClassModel propertyClass(String propertyClass) { + this.propertyClass = propertyClass; + return this; + } + + /** + * Get propertyClass + * @return propertyClass + */ + @Schema(name = "propertyClass", defaultValue = "") + + + public String getPropertyClass() { + return propertyClass; + } + + public void setPropertyClass(String propertyClass) { + this.propertyClass = propertyClass; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClassModel classModel = (ClassModel) o; + return Objects.equals(this.propertyClass, classModel.propertyClass); + } + + @Override + public int hashCode() { + return Objects.hash(propertyClass); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ClassModel {\n"); + + sb.append(" propertyClass: ").append(toIndentedString(propertyClass)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Client.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Client.java new file mode 100644 index 000000000000..e11bd4ff1b13 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Client.java @@ -0,0 +1,83 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Client + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Client { + @JsonProperty("client") + private String client; + + public Client client(String client) { + this.client = client; + return this; + } + + /** + * Get client + * @return client + */ + @Schema(name = "client", defaultValue = "") + + + public String getClient() { + return client; + } + + public void setClient(String client) { + this.client = client; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Client client = (Client) o; + return Objects.equals(this.client, client.client); + } + + @Override + public int hashCode() { + return Objects.hash(client); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Client {\n"); + + sb.append(" client: ").append(toIndentedString(client)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Dog.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Dog.java new file mode 100644 index 000000000000..ed5dc71a4ba2 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Dog.java @@ -0,0 +1,86 @@ +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 org.openapitools.model.Animal; +import org.openapitools.model.DogAllOf; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Dog + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Dog extends Animal { + @JsonProperty("breed") + private String breed; + + public Dog breed(String breed) { + this.breed = breed; + return this; + } + + /** + * Get breed + * @return breed + */ + @Schema(name = "breed", defaultValue = "") + + + public String getBreed() { + return breed; + } + + public void setBreed(String breed) { + this.breed = breed; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Dog dog = (Dog) o; + return Objects.equals(this.breed, dog.breed) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(breed, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Dog {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" breed: ").append(toIndentedString(breed)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/DogAllOf.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/DogAllOf.java new file mode 100644 index 000000000000..2c99bc376c34 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/DogAllOf.java @@ -0,0 +1,83 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * DogAllOf + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class DogAllOf { + @JsonProperty("breed") + private String breed; + + public DogAllOf breed(String breed) { + this.breed = breed; + return this; + } + + /** + * Get breed + * @return breed + */ + @Schema(name = "breed", defaultValue = "") + + + public String getBreed() { + return breed; + } + + public void setBreed(String breed) { + this.breed = breed; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DogAllOf dogAllOf = (DogAllOf) o; + return Objects.equals(this.breed, dogAllOf.breed); + } + + @Override + public int hashCode() { + return Objects.hash(breed); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DogAllOf {\n"); + + sb.append(" breed: ").append(toIndentedString(breed)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/EnumArrays.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/EnumArrays.java new file mode 100644 index 000000000000..e1b2df0716a2 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/EnumArrays.java @@ -0,0 +1,190 @@ +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 java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * EnumArrays + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class EnumArrays { + /** + * Gets or Sets justSymbol + */ + public enum JustSymbolEnum { + GREATER_THAN_OR_EQUAL_TO(">="), + + DOLLAR("$"); + + private String value; + + JustSymbolEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static JustSymbolEnum fromValue(String value) { + for (JustSymbolEnum b : JustSymbolEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("just_symbol") + private JustSymbolEnum justSymbol; + + /** + * Gets or Sets arrayEnum + */ + public enum ArrayEnumEnum { + FISH("fish"), + + CRAB("crab"); + + private String value; + + ArrayEnumEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static ArrayEnumEnum fromValue(String value) { + for (ArrayEnumEnum b : ArrayEnumEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("array_enum") + @Valid + private List arrayEnum = null; + + public EnumArrays justSymbol(JustSymbolEnum justSymbol) { + this.justSymbol = justSymbol; + return this; + } + + /** + * Get justSymbol + * @return justSymbol + */ + @Schema(name = "justSymbol", defaultValue = "") + + + public JustSymbolEnum getJustSymbol() { + return justSymbol; + } + + public void setJustSymbol(JustSymbolEnum justSymbol) { + this.justSymbol = justSymbol; + } + + public EnumArrays arrayEnum(List arrayEnum) { + this.arrayEnum = arrayEnum; + return this; + } + + public EnumArrays addArrayEnumItem(ArrayEnumEnum arrayEnumItem) { + if (this.arrayEnum == null) { + this.arrayEnum = new ArrayList<>(); + } + this.arrayEnum.add(arrayEnumItem); + return this; + } + + /** + * Get arrayEnum + * @return arrayEnum + */ + @Schema(name = "arrayEnum", defaultValue = "") + + + public List getArrayEnum() { + return arrayEnum; + } + + public void setArrayEnum(List arrayEnum) { + this.arrayEnum = arrayEnum; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EnumArrays enumArrays = (EnumArrays) o; + return Objects.equals(this.justSymbol, enumArrays.justSymbol) && + Objects.equals(this.arrayEnum, enumArrays.arrayEnum); + } + + @Override + public int hashCode() { + return Objects.hash(justSymbol, arrayEnum); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EnumArrays {\n"); + + sb.append(" justSymbol: ").append(toIndentedString(justSymbol)).append("\n"); + sb.append(" arrayEnum: ").append(toIndentedString(arrayEnum)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/EnumClass.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/EnumClass.java new file mode 100644 index 000000000000..e3d30c1ad453 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/EnumClass.java @@ -0,0 +1,55 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Gets or Sets EnumClass + */ +public enum EnumClass { + + _ABC("_abc"), + + _EFG("-efg"), + + _XYZ_("(xyz)"); + + private String value; + + EnumClass(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumClass fromValue(String value) { + for (EnumClass b : EnumClass.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/EnumTest.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/EnumTest.java new file mode 100644 index 000000000000..938af53e2b81 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/EnumTest.java @@ -0,0 +1,331 @@ +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 org.openapitools.model.OuterEnum; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * EnumTest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class EnumTest { + /** + * Gets or Sets enumString + */ + public enum EnumStringEnum { + UPPER("UPPER"), + + LOWER("lower"), + + EMPTY(""); + + private String value; + + EnumStringEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumStringEnum fromValue(String value) { + for (EnumStringEnum b : EnumStringEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("enum_string") + private EnumStringEnum enumString; + + /** + * Gets or Sets enumStringRequired + */ + public enum EnumStringRequiredEnum { + UPPER("UPPER"), + + LOWER("lower"), + + EMPTY(""); + + private String value; + + EnumStringRequiredEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumStringRequiredEnum fromValue(String value) { + for (EnumStringRequiredEnum b : EnumStringRequiredEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("enum_string_required") + private EnumStringRequiredEnum enumStringRequired; + + /** + * Gets or Sets enumInteger + */ + public enum EnumIntegerEnum { + NUMBER_1(1), + + NUMBER_MINUS_1(-1); + + private Integer value; + + EnumIntegerEnum(Integer value) { + this.value = value; + } + + @JsonValue + public Integer getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumIntegerEnum fromValue(Integer value) { + for (EnumIntegerEnum b : EnumIntegerEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("enum_integer") + private EnumIntegerEnum enumInteger; + + /** + * Gets or Sets enumNumber + */ + public enum EnumNumberEnum { + NUMBER_1_DOT_1(1.1), + + NUMBER_MINUS_1_DOT_2(-1.2); + + private Double value; + + EnumNumberEnum(Double value) { + this.value = value; + } + + @JsonValue + public Double getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumNumberEnum fromValue(Double value) { + for (EnumNumberEnum b : EnumNumberEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("enum_number") + private EnumNumberEnum enumNumber; + + @JsonProperty("outerEnum") + private OuterEnum outerEnum; + + public EnumTest enumString(EnumStringEnum enumString) { + this.enumString = enumString; + return this; + } + + /** + * Get enumString + * @return enumString + */ + @Schema(name = "enumString", defaultValue = "") + + + public EnumStringEnum getEnumString() { + return enumString; + } + + public void setEnumString(EnumStringEnum enumString) { + this.enumString = enumString; + } + + public EnumTest enumStringRequired(EnumStringRequiredEnum enumStringRequired) { + this.enumStringRequired = enumStringRequired; + return this; + } + + /** + * Get enumStringRequired + * @return enumStringRequired + */ + @Schema(name = "enumStringRequired", required = true, defaultValue = "") + @NotNull + + + public EnumStringRequiredEnum getEnumStringRequired() { + return enumStringRequired; + } + + public void setEnumStringRequired(EnumStringRequiredEnum enumStringRequired) { + this.enumStringRequired = enumStringRequired; + } + + public EnumTest enumInteger(EnumIntegerEnum enumInteger) { + this.enumInteger = enumInteger; + return this; + } + + /** + * Get enumInteger + * @return enumInteger + */ + @Schema(name = "enumInteger", defaultValue = "") + + + public EnumIntegerEnum getEnumInteger() { + return enumInteger; + } + + public void setEnumInteger(EnumIntegerEnum enumInteger) { + this.enumInteger = enumInteger; + } + + public EnumTest enumNumber(EnumNumberEnum enumNumber) { + this.enumNumber = enumNumber; + return this; + } + + /** + * Get enumNumber + * @return enumNumber + */ + @Schema(name = "enumNumber", defaultValue = "") + + + public EnumNumberEnum getEnumNumber() { + return enumNumber; + } + + public void setEnumNumber(EnumNumberEnum enumNumber) { + this.enumNumber = enumNumber; + } + + public EnumTest outerEnum(OuterEnum outerEnum) { + this.outerEnum = outerEnum; + return this; + } + + /** + * Get outerEnum + * @return outerEnum + */ + @Schema(name = "outerEnum", defaultValue = "") + + @Valid + + public OuterEnum getOuterEnum() { + return outerEnum; + } + + public void setOuterEnum(OuterEnum outerEnum) { + this.outerEnum = outerEnum; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EnumTest enumTest = (EnumTest) o; + return Objects.equals(this.enumString, enumTest.enumString) && + Objects.equals(this.enumStringRequired, enumTest.enumStringRequired) && + Objects.equals(this.enumInteger, enumTest.enumInteger) && + Objects.equals(this.enumNumber, enumTest.enumNumber) && + Objects.equals(this.outerEnum, enumTest.outerEnum); + } + + @Override + public int hashCode() { + return Objects.hash(enumString, enumStringRequired, enumInteger, enumNumber, outerEnum); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EnumTest {\n"); + + sb.append(" enumString: ").append(toIndentedString(enumString)).append("\n"); + sb.append(" enumStringRequired: ").append(toIndentedString(enumStringRequired)).append("\n"); + sb.append(" enumInteger: ").append(toIndentedString(enumInteger)).append("\n"); + sb.append(" enumNumber: ").append(toIndentedString(enumNumber)).append("\n"); + sb.append(" outerEnum: ").append(toIndentedString(outerEnum)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/FileSchemaTestClass.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/FileSchemaTestClass.java new file mode 100644 index 000000000000..0d1e9ca8495c --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/FileSchemaTestClass.java @@ -0,0 +1,121 @@ +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 java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * FileSchemaTestClass + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class FileSchemaTestClass { + @JsonProperty("file") + private java.io.File file; + + @JsonProperty("files") + @Valid + private List files = null; + + public FileSchemaTestClass file(java.io.File file) { + this.file = file; + return this; + } + + /** + * Get file + * @return file + */ + @Schema(name = "file", defaultValue = "") + + @Valid + + public java.io.File getFile() { + return file; + } + + public void setFile(java.io.File file) { + this.file = file; + } + + public FileSchemaTestClass files(List files) { + this.files = files; + return this; + } + + public FileSchemaTestClass addFilesItem(java.io.File filesItem) { + if (this.files == null) { + this.files = new ArrayList<>(); + } + this.files.add(filesItem); + return this; + } + + /** + * Get files + * @return files + */ + @Schema(name = "files", defaultValue = "") + + @Valid + + public List getFiles() { + return files; + } + + public void setFiles(List files) { + this.files = files; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FileSchemaTestClass fileSchemaTestClass = (FileSchemaTestClass) o; + return Objects.equals(this.file, fileSchemaTestClass.file) && + Objects.equals(this.files, fileSchemaTestClass.files); + } + + @Override + public int hashCode() { + return Objects.hash(file, files); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FileSchemaTestClass {\n"); + + sb.append(" file: ").append(toIndentedString(file)).append("\n"); + sb.append(" files: ").append(toIndentedString(files)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/FormatTest.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/FormatTest.java new file mode 100644 index 000000000000..6546370cd329 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/FormatTest.java @@ -0,0 +1,435 @@ +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 java.math.BigDecimal; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.UUID; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * FormatTest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class FormatTest { + @JsonProperty("integer") + private Integer integer; + + @JsonProperty("int32") + private Integer int32; + + @JsonProperty("int64") + private Long int64; + + @JsonProperty("number") + private BigDecimal number; + + @JsonProperty("float") + private Float _float; + + @JsonProperty("double") + private Double _double; + + @JsonProperty("string") + private String string; + + @JsonProperty("byte") + private byte[] _byte; + + @JsonProperty("binary") + private org.springframework.core.io.Resource binary; + + @JsonProperty("date") + @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) + private LocalDate date; + + @JsonProperty("dateTime") + @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) + private OffsetDateTime dateTime; + + @JsonProperty("uuid") + private UUID uuid; + + @JsonProperty("password") + private String password; + + @JsonProperty("BigDecimal") + private BigDecimal bigDecimal; + + public FormatTest integer(Integer integer) { + this.integer = integer; + return this; + } + + /** + * Get integer + * minimum: 10 + * maximum: 100 + * @return integer + */ + @Schema(name = "integer", defaultValue = "") + +@Min(10) @Max(100) + public Integer getInteger() { + return integer; + } + + public void setInteger(Integer integer) { + this.integer = integer; + } + + public FormatTest int32(Integer int32) { + this.int32 = int32; + return this; + } + + /** + * Get int32 + * minimum: 20 + * maximum: 200 + * @return int32 + */ + @Schema(name = "int32", defaultValue = "") + +@Min(20) @Max(200) + public Integer getInt32() { + return int32; + } + + public void setInt32(Integer int32) { + this.int32 = int32; + } + + public FormatTest int64(Long int64) { + this.int64 = int64; + return this; + } + + /** + * Get int64 + * @return int64 + */ + @Schema(name = "int64", defaultValue = "") + + + public Long getInt64() { + return int64; + } + + public void setInt64(Long int64) { + this.int64 = int64; + } + + public FormatTest number(BigDecimal number) { + this.number = number; + return this; + } + + /** + * Get number + * minimum: 32.1 + * maximum: 543.2 + * @return number + */ + @Schema(name = "number", required = true, defaultValue = "") + @NotNull + + @Valid +@DecimalMin("32.1") @DecimalMax("543.2") + public BigDecimal getNumber() { + return number; + } + + public void setNumber(BigDecimal number) { + this.number = number; + } + + public FormatTest _float(Float _float) { + this._float = _float; + return this; + } + + /** + * Get _float + * minimum: 54.3 + * maximum: 987.6 + * @return _float + */ + @Schema(name = "_float", defaultValue = "") + +@DecimalMin("54.3") @DecimalMax("987.6") + public Float getFloat() { + return _float; + } + + public void setFloat(Float _float) { + this._float = _float; + } + + public FormatTest _double(Double _double) { + this._double = _double; + return this; + } + + /** + * Get _double + * minimum: 67.8 + * maximum: 123.4 + * @return _double + */ + @Schema(name = "_double", defaultValue = "") + +@DecimalMin("67.8") @DecimalMax("123.4") + public Double getDouble() { + return _double; + } + + public void setDouble(Double _double) { + this._double = _double; + } + + public FormatTest string(String string) { + this.string = string; + return this; + } + + /** + * Get string + * @return string + */ + @Schema(name = "string", defaultValue = "") + +@Pattern(regexp = "/[a-z]/i") + public String getString() { + return string; + } + + public void setString(String string) { + this.string = string; + } + + public FormatTest _byte(byte[] _byte) { + this._byte = _byte; + return this; + } + + /** + * Get _byte + * @return _byte + */ + @Schema(name = "_byte", required = true, defaultValue = "") + @NotNull + + + public byte[] getByte() { + return _byte; + } + + public void setByte(byte[] _byte) { + this._byte = _byte; + } + + public FormatTest binary(org.springframework.core.io.Resource binary) { + this.binary = binary; + return this; + } + + /** + * Get binary + * @return binary + */ + @Schema(name = "binary", defaultValue = "") + + @Valid + + public org.springframework.core.io.Resource getBinary() { + return binary; + } + + public void setBinary(org.springframework.core.io.Resource binary) { + this.binary = binary; + } + + public FormatTest date(LocalDate date) { + this.date = date; + return this; + } + + /** + * Get date + * @return date + */ + @Schema(name = "date", required = true, defaultValue = "") + @NotNull + + @Valid + + public LocalDate getDate() { + return date; + } + + public void setDate(LocalDate date) { + this.date = date; + } + + public FormatTest dateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + return this; + } + + /** + * Get dateTime + * @return dateTime + */ + @Schema(name = "dateTime", defaultValue = "") + + @Valid + + public OffsetDateTime getDateTime() { + return dateTime; + } + + public void setDateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + } + + public FormatTest uuid(UUID uuid) { + this.uuid = uuid; + return this; + } + + /** + * Get uuid + * @return uuid + */ + @Schema(name = "uuid", example = "72f98069-206d-4f12-9f12-3d1e525a8e84", defaultValue = "") + + @Valid + + public UUID getUuid() { + return uuid; + } + + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + public FormatTest password(String password) { + this.password = password; + return this; + } + + /** + * Get password + * @return password + */ + @Schema(name = "password", required = true, defaultValue = "") + @NotNull + +@Size(min = 10, max = 64) + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public FormatTest bigDecimal(BigDecimal bigDecimal) { + this.bigDecimal = bigDecimal; + return this; + } + + /** + * Get bigDecimal + * @return bigDecimal + */ + @Schema(name = "bigDecimal", defaultValue = "") + + @Valid + + public BigDecimal getBigDecimal() { + return bigDecimal; + } + + public void setBigDecimal(BigDecimal bigDecimal) { + this.bigDecimal = bigDecimal; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FormatTest formatTest = (FormatTest) o; + return Objects.equals(this.integer, formatTest.integer) && + Objects.equals(this.int32, formatTest.int32) && + Objects.equals(this.int64, formatTest.int64) && + Objects.equals(this.number, formatTest.number) && + Objects.equals(this._float, formatTest._float) && + Objects.equals(this._double, formatTest._double) && + Objects.equals(this.string, formatTest.string) && + Arrays.equals(this._byte, formatTest._byte) && + Objects.equals(this.binary, formatTest.binary) && + Objects.equals(this.date, formatTest.date) && + Objects.equals(this.dateTime, formatTest.dateTime) && + Objects.equals(this.uuid, formatTest.uuid) && + Objects.equals(this.password, formatTest.password) && + Objects.equals(this.bigDecimal, formatTest.bigDecimal); + } + + @Override + public int hashCode() { + return Objects.hash(integer, int32, int64, number, _float, _double, string, Arrays.hashCode(_byte), binary, date, dateTime, uuid, password, bigDecimal); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FormatTest {\n"); + + sb.append(" integer: ").append(toIndentedString(integer)).append("\n"); + sb.append(" int32: ").append(toIndentedString(int32)).append("\n"); + sb.append(" int64: ").append(toIndentedString(int64)).append("\n"); + sb.append(" number: ").append(toIndentedString(number)).append("\n"); + sb.append(" _float: ").append(toIndentedString(_float)).append("\n"); + sb.append(" _double: ").append(toIndentedString(_double)).append("\n"); + sb.append(" string: ").append(toIndentedString(string)).append("\n"); + sb.append(" _byte: ").append(toIndentedString(_byte)).append("\n"); + sb.append(" binary: ").append(toIndentedString(binary)).append("\n"); + sb.append(" date: ").append(toIndentedString(date)).append("\n"); + sb.append(" dateTime: ").append(toIndentedString(dateTime)).append("\n"); + sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" bigDecimal: ").append(toIndentedString(bigDecimal)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/HasOnlyReadOnly.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/HasOnlyReadOnly.java new file mode 100644 index 000000000000..dfb615a529fc --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/HasOnlyReadOnly.java @@ -0,0 +1,108 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * HasOnlyReadOnly + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class HasOnlyReadOnly { + @JsonProperty("bar") + private String bar; + + @JsonProperty("foo") + private String foo; + + public HasOnlyReadOnly bar(String bar) { + this.bar = bar; + return this; + } + + /** + * Get bar + * @return bar + */ + @Schema(name = "bar", readOnly = true, defaultValue = "") + + + public String getBar() { + return bar; + } + + public void setBar(String bar) { + this.bar = bar; + } + + public HasOnlyReadOnly foo(String foo) { + this.foo = foo; + return this; + } + + /** + * Get foo + * @return foo + */ + @Schema(name = "foo", readOnly = true, defaultValue = "") + + + public String getFoo() { + return foo; + } + + public void setFoo(String foo) { + this.foo = foo; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HasOnlyReadOnly hasOnlyReadOnly = (HasOnlyReadOnly) o; + return Objects.equals(this.bar, hasOnlyReadOnly.bar) && + Objects.equals(this.foo, hasOnlyReadOnly.foo); + } + + @Override + public int hashCode() { + return Objects.hash(bar, foo); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class HasOnlyReadOnly {\n"); + + sb.append(" bar: ").append(toIndentedString(bar)).append("\n"); + sb.append(" foo: ").append(toIndentedString(foo)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/MapTest.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/MapTest.java new file mode 100644 index 000000000000..3ff73062758f --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/MapTest.java @@ -0,0 +1,234 @@ +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 java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * MapTest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class MapTest { + @JsonProperty("map_map_of_string") + @Valid + private Map> mapMapOfString = null; + + /** + * Gets or Sets inner + */ + public enum InnerEnum { + UPPER("UPPER"), + + LOWER("lower"); + + private String value; + + InnerEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static InnerEnum fromValue(String value) { + for (InnerEnum b : InnerEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("map_of_enum_string") + @Valid + private Map mapOfEnumString = null; + + @JsonProperty("direct_map") + @Valid + private Map directMap = null; + + @JsonProperty("indirect_map") + @Valid + private Map indirectMap = null; + + public MapTest mapMapOfString(Map> mapMapOfString) { + this.mapMapOfString = mapMapOfString; + return this; + } + + public MapTest putMapMapOfStringItem(String key, Map mapMapOfStringItem) { + if (this.mapMapOfString == null) { + this.mapMapOfString = new HashMap<>(); + } + this.mapMapOfString.put(key, mapMapOfStringItem); + return this; + } + + /** + * Get mapMapOfString + * @return mapMapOfString + */ + @Schema(name = "mapMapOfString", defaultValue = "") + + @Valid + + public Map> getMapMapOfString() { + return mapMapOfString; + } + + public void setMapMapOfString(Map> mapMapOfString) { + this.mapMapOfString = mapMapOfString; + } + + public MapTest mapOfEnumString(Map mapOfEnumString) { + this.mapOfEnumString = mapOfEnumString; + return this; + } + + public MapTest putMapOfEnumStringItem(String key, InnerEnum mapOfEnumStringItem) { + if (this.mapOfEnumString == null) { + this.mapOfEnumString = new HashMap<>(); + } + this.mapOfEnumString.put(key, mapOfEnumStringItem); + return this; + } + + /** + * Get mapOfEnumString + * @return mapOfEnumString + */ + @Schema(name = "mapOfEnumString", defaultValue = "") + + + public Map getMapOfEnumString() { + return mapOfEnumString; + } + + public void setMapOfEnumString(Map mapOfEnumString) { + this.mapOfEnumString = mapOfEnumString; + } + + public MapTest directMap(Map directMap) { + this.directMap = directMap; + return this; + } + + public MapTest putDirectMapItem(String key, Boolean directMapItem) { + if (this.directMap == null) { + this.directMap = new HashMap<>(); + } + this.directMap.put(key, directMapItem); + return this; + } + + /** + * Get directMap + * @return directMap + */ + @Schema(name = "directMap", defaultValue = "") + + + public Map getDirectMap() { + return directMap; + } + + public void setDirectMap(Map directMap) { + this.directMap = directMap; + } + + public MapTest indirectMap(Map indirectMap) { + this.indirectMap = indirectMap; + return this; + } + + public MapTest putIndirectMapItem(String key, Boolean indirectMapItem) { + if (this.indirectMap == null) { + this.indirectMap = new HashMap<>(); + } + this.indirectMap.put(key, indirectMapItem); + return this; + } + + /** + * Get indirectMap + * @return indirectMap + */ + @Schema(name = "indirectMap", defaultValue = "") + + + public Map getIndirectMap() { + return indirectMap; + } + + public void setIndirectMap(Map indirectMap) { + this.indirectMap = indirectMap; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MapTest mapTest = (MapTest) o; + return Objects.equals(this.mapMapOfString, mapTest.mapMapOfString) && + Objects.equals(this.mapOfEnumString, mapTest.mapOfEnumString) && + Objects.equals(this.directMap, mapTest.directMap) && + Objects.equals(this.indirectMap, mapTest.indirectMap); + } + + @Override + public int hashCode() { + return Objects.hash(mapMapOfString, mapOfEnumString, directMap, indirectMap); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MapTest {\n"); + + sb.append(" mapMapOfString: ").append(toIndentedString(mapMapOfString)).append("\n"); + sb.append(" mapOfEnumString: ").append(toIndentedString(mapOfEnumString)).append("\n"); + sb.append(" directMap: ").append(toIndentedString(directMap)).append("\n"); + sb.append(" indirectMap: ").append(toIndentedString(indirectMap)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java new file mode 100644 index 000000000000..03a7be43cc4a --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java @@ -0,0 +1,152 @@ +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 java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import org.openapitools.model.Animal; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * MixedPropertiesAndAdditionalPropertiesClass + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class MixedPropertiesAndAdditionalPropertiesClass { + @JsonProperty("uuid") + private UUID uuid; + + @JsonProperty("dateTime") + @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) + private OffsetDateTime dateTime; + + @JsonProperty("map") + @Valid + private Map map = null; + + public MixedPropertiesAndAdditionalPropertiesClass uuid(UUID uuid) { + this.uuid = uuid; + return this; + } + + /** + * Get uuid + * @return uuid + */ + @Schema(name = "uuid", defaultValue = "") + + @Valid + + public UUID getUuid() { + return uuid; + } + + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + public MixedPropertiesAndAdditionalPropertiesClass dateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + return this; + } + + /** + * Get dateTime + * @return dateTime + */ + @Schema(name = "dateTime", defaultValue = "") + + @Valid + + public OffsetDateTime getDateTime() { + return dateTime; + } + + public void setDateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + } + + public MixedPropertiesAndAdditionalPropertiesClass map(Map map) { + this.map = map; + return this; + } + + public MixedPropertiesAndAdditionalPropertiesClass putMapItem(String key, Animal mapItem) { + if (this.map == null) { + this.map = new HashMap<>(); + } + this.map.put(key, mapItem); + return this; + } + + /** + * Get map + * @return map + */ + @Schema(name = "map", defaultValue = "") + + @Valid + + public Map getMap() { + return map; + } + + public void setMap(Map map) { + this.map = map; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass = (MixedPropertiesAndAdditionalPropertiesClass) o; + return Objects.equals(this.uuid, mixedPropertiesAndAdditionalPropertiesClass.uuid) && + Objects.equals(this.dateTime, mixedPropertiesAndAdditionalPropertiesClass.dateTime) && + Objects.equals(this.map, mixedPropertiesAndAdditionalPropertiesClass.map); + } + + @Override + public int hashCode() { + return Objects.hash(uuid, dateTime, map); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MixedPropertiesAndAdditionalPropertiesClass {\n"); + + sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); + sb.append(" dateTime: ").append(toIndentedString(dateTime)).append("\n"); + sb.append(" map: ").append(toIndentedString(map)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Model200Response.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Model200Response.java new file mode 100644 index 000000000000..77bf91649b08 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Model200Response.java @@ -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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Model for testing model name starting with number + */ +@Schema(name = "200_response",description = "Model for testing model name starting with number") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Model200Response { + @JsonProperty("name") + private Integer name; + + @JsonProperty("class") + private String propertyClass; + + public Model200Response name(Integer name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + public Integer getName() { + return name; + } + + public void setName(Integer name) { + this.name = name; + } + + public Model200Response propertyClass(String propertyClass) { + this.propertyClass = propertyClass; + return this; + } + + /** + * Get propertyClass + * @return propertyClass + */ + @Schema(name = "propertyClass", defaultValue = "") + + + public String getPropertyClass() { + return propertyClass; + } + + public void setPropertyClass(String propertyClass) { + this.propertyClass = propertyClass; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Model200Response _200response = (Model200Response) o; + return Objects.equals(this.name, _200response.name) && + Objects.equals(this.propertyClass, _200response.propertyClass); + } + + @Override + public int hashCode() { + return Objects.hash(name, propertyClass); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Model200Response {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" propertyClass: ").append(toIndentedString(propertyClass)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ModelApiResponse.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ModelApiResponse.java new file mode 100644 index 000000000000..2443600df226 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ModelApiResponse.java @@ -0,0 +1,133 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ModelApiResponse + */ +@javax.annotation.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 + */ + @Schema(name = "code", defaultValue = "") + + + 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 + */ + @Schema(name = "type", defaultValue = "") + + + 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 + */ + @Schema(name = "message", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ModelReturn.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ModelReturn.java new file mode 100644 index 000000000000..0301a47e9f3e --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ModelReturn.java @@ -0,0 +1,84 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Model for testing reserved words + */ +@Schema(name = "Return",description = "Model for testing reserved words") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ModelReturn { + @JsonProperty("return") + private Integer _return; + + public ModelReturn _return(Integer _return) { + this._return = _return; + return this; + } + + /** + * Get _return + * @return _return + */ + @Schema(name = "_return", defaultValue = "") + + + public Integer getReturn() { + return _return; + } + + public void setReturn(Integer _return) { + this._return = _return; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelReturn _return = (ModelReturn) o; + return Objects.equals(this._return, _return._return); + } + + @Override + public int hashCode() { + return Objects.hash(_return); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelReturn {\n"); + + sb.append(" _return: ").append(toIndentedString(_return)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Name.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Name.java new file mode 100644 index 000000000000..62a16f80ee07 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Name.java @@ -0,0 +1,160 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Model for testing model name same as property name + */ +@Schema(name = "Name",description = "Model for testing model name same as property name") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Name { + @JsonProperty("name") + private Integer name; + + @JsonProperty("snake_case") + private Integer snakeCase; + + @JsonProperty("property") + private String property; + + @JsonProperty("123Number") + private Integer _123number; + + public Name name(Integer name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", required = true, defaultValue = "") + @NotNull + + + public Integer getName() { + return name; + } + + public void setName(Integer name) { + this.name = name; + } + + public Name snakeCase(Integer snakeCase) { + this.snakeCase = snakeCase; + return this; + } + + /** + * Get snakeCase + * @return snakeCase + */ + @Schema(name = "snakeCase", readOnly = true, defaultValue = "") + + + public Integer getSnakeCase() { + return snakeCase; + } + + public void setSnakeCase(Integer snakeCase) { + this.snakeCase = snakeCase; + } + + public Name property(String property) { + this.property = property; + return this; + } + + /** + * Get property + * @return property + */ + @Schema(name = "property", defaultValue = "") + + + public String getProperty() { + return property; + } + + public void setProperty(String property) { + this.property = property; + } + + public Name _123number(Integer _123number) { + this._123number = _123number; + return this; + } + + /** + * Get _123number + * @return _123number + */ + @Schema(name = "_123number", readOnly = true, defaultValue = "") + + + public Integer get123number() { + return _123number; + } + + public void set123number(Integer _123number) { + this._123number = _123number; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Name name = (Name) o; + return Objects.equals(this.name, name.name) && + Objects.equals(this.snakeCase, name.snakeCase) && + Objects.equals(this.property, name.property) && + Objects.equals(this._123number, name._123number); + } + + @Override + public int hashCode() { + return Objects.hash(name, snakeCase, property, _123number); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Name {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n"); + sb.append(" property: ").append(toIndentedString(property)).append("\n"); + sb.append(" _123number: ").append(toIndentedString(_123number)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/NumberOnly.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/NumberOnly.java new file mode 100644 index 000000000000..521fad80d5a7 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/NumberOnly.java @@ -0,0 +1,85 @@ +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 java.math.BigDecimal; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * NumberOnly + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class NumberOnly { + @JsonProperty("JustNumber") + private BigDecimal justNumber; + + public NumberOnly justNumber(BigDecimal justNumber) { + this.justNumber = justNumber; + return this; + } + + /** + * Get justNumber + * @return justNumber + */ + @Schema(name = "justNumber", defaultValue = "") + + @Valid + + public BigDecimal getJustNumber() { + return justNumber; + } + + public void setJustNumber(BigDecimal justNumber) { + this.justNumber = justNumber; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NumberOnly numberOnly = (NumberOnly) o; + return Objects.equals(this.justNumber, numberOnly.justNumber); + } + + @Override + public int hashCode() { + return Objects.hash(justNumber); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NumberOnly {\n"); + + sb.append(" justNumber: ").append(toIndentedString(justNumber)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Order.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Order.java new file mode 100644 index 000000000000..05071bdfe2bf --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Order.java @@ -0,0 +1,249 @@ +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 java.time.OffsetDateTime; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Order + */ +@javax.annotation.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") + @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "petId", defaultValue = "") + + + 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 + */ + @Schema(name = "quantity", defaultValue = "") + + + 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 + */ + @Schema(name = "shipDate", defaultValue = "") + + @Valid + + 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 + */ + @Schema(name = "status", defaultValue = "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 + */ + @Schema(name = "complete", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/OuterComposite.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/OuterComposite.java new file mode 100644 index 000000000000..a721a3dde6a0 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/OuterComposite.java @@ -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 java.math.BigDecimal; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * OuterComposite + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class OuterComposite { + @JsonProperty("my_number") + private BigDecimal myNumber; + + @JsonProperty("my_string") + private String myString; + + @JsonProperty("my_boolean") + private Boolean myBoolean; + + public OuterComposite myNumber(BigDecimal myNumber) { + this.myNumber = myNumber; + return this; + } + + /** + * Get myNumber + * @return myNumber + */ + @Schema(name = "myNumber", defaultValue = "") + + @Valid + + public BigDecimal getMyNumber() { + return myNumber; + } + + public void setMyNumber(BigDecimal myNumber) { + this.myNumber = myNumber; + } + + public OuterComposite myString(String myString) { + this.myString = myString; + return this; + } + + /** + * Get myString + * @return myString + */ + @Schema(name = "myString", defaultValue = "") + + + public String getMyString() { + return myString; + } + + public void setMyString(String myString) { + this.myString = myString; + } + + public OuterComposite myBoolean(Boolean myBoolean) { + this.myBoolean = myBoolean; + return this; + } + + /** + * Get myBoolean + * @return myBoolean + */ + @Schema(name = "myBoolean", defaultValue = "") + + + public Boolean getMyBoolean() { + return myBoolean; + } + + public void setMyBoolean(Boolean myBoolean) { + this.myBoolean = myBoolean; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OuterComposite outerComposite = (OuterComposite) o; + return Objects.equals(this.myNumber, outerComposite.myNumber) && + Objects.equals(this.myString, outerComposite.myString) && + Objects.equals(this.myBoolean, outerComposite.myBoolean); + } + + @Override + public int hashCode() { + return Objects.hash(myNumber, myString, myBoolean); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OuterComposite {\n"); + + sb.append(" myNumber: ").append(toIndentedString(myNumber)).append("\n"); + sb.append(" myString: ").append(toIndentedString(myString)).append("\n"); + sb.append(" myBoolean: ").append(toIndentedString(myBoolean)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/OuterEnum.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/OuterEnum.java new file mode 100644 index 000000000000..ba0cca8a5e81 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/OuterEnum.java @@ -0,0 +1,55 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Gets or Sets OuterEnum + */ +public enum OuterEnum { + + PLACED("placed"), + + APPROVED("approved"), + + DELIVERED("delivered"); + + private String value; + + OuterEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static OuterEnum fromValue(String value) { + for (OuterEnum b : OuterEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Pet.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Pet.java new file mode 100644 index 000000000000..988eb317134d --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Pet.java @@ -0,0 +1,273 @@ +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 com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +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 io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Pet + */ +@javax.annotation.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 Set photoUrls = new LinkedHashSet<>(); + + @JsonProperty("tags") + @Valid + private List 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; + + public Pet id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "category", defaultValue = "") + + @Valid + + 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 + */ + @Schema(name = "name", example = "doggie", required = true, defaultValue = "") + @NotNull + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Pet photoUrls(Set photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + public Pet addPhotoUrlsItem(String photoUrlsItem) { + this.photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get photoUrls + * @return photoUrls + */ + @Schema(name = "photoUrls", required = true, defaultValue = "") + @NotNull + + + public Set getPhotoUrls() { + return photoUrls; + } + + @JsonDeserialize(as = LinkedHashSet.class) + public void setPhotoUrls(Set photoUrls) { + this.photoUrls = photoUrls; + } + + public Pet tags(List 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 + */ + @Schema(name = "tags", defaultValue = "") + + @Valid + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * pet status in the store + * @return status + */ + @Schema(name = "status", defaultValue = "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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ReadOnlyFirst.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ReadOnlyFirst.java new file mode 100644 index 000000000000..1c51770a8e66 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ReadOnlyFirst.java @@ -0,0 +1,108 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ReadOnlyFirst + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ReadOnlyFirst { + @JsonProperty("bar") + private String bar; + + @JsonProperty("baz") + private String baz; + + public ReadOnlyFirst bar(String bar) { + this.bar = bar; + return this; + } + + /** + * Get bar + * @return bar + */ + @Schema(name = "bar", readOnly = true, defaultValue = "") + + + public String getBar() { + return bar; + } + + public void setBar(String bar) { + this.bar = bar; + } + + public ReadOnlyFirst baz(String baz) { + this.baz = baz; + return this; + } + + /** + * Get baz + * @return baz + */ + @Schema(name = "baz", defaultValue = "") + + + public String getBaz() { + return baz; + } + + public void setBaz(String baz) { + this.baz = baz; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReadOnlyFirst readOnlyFirst = (ReadOnlyFirst) o; + return Objects.equals(this.bar, readOnlyFirst.bar) && + Objects.equals(this.baz, readOnlyFirst.baz); + } + + @Override + public int hashCode() { + return Objects.hash(bar, baz); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ReadOnlyFirst {\n"); + + sb.append(" bar: ").append(toIndentedString(bar)).append("\n"); + sb.append(" baz: ").append(toIndentedString(baz)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/SpecialModelName.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/SpecialModelName.java new file mode 100644 index 000000000000..75f4be4e9f8f --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/SpecialModelName.java @@ -0,0 +1,83 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * SpecialModelName + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class SpecialModelName { + @JsonProperty("$special[property.name]") + private Long $specialPropertyName; + + public SpecialModelName $specialPropertyName(Long $specialPropertyName) { + this.$specialPropertyName = $specialPropertyName; + return this; + } + + /** + * Get $specialPropertyName + * @return $specialPropertyName + */ + @Schema(name = "$specialPropertyName", defaultValue = "") + + + public Long get$SpecialPropertyName() { + return $specialPropertyName; + } + + public void set$SpecialPropertyName(Long $specialPropertyName) { + this.$specialPropertyName = $specialPropertyName; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SpecialModelName $specialModelName = (SpecialModelName) o; + return Objects.equals(this.$specialPropertyName, $specialModelName.$specialPropertyName); + } + + @Override + public int hashCode() { + return Objects.hash($specialPropertyName); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SpecialModelName {\n"); + + sb.append(" $specialPropertyName: ").append(toIndentedString($specialPropertyName)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Tag.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Tag.java new file mode 100644 index 000000000000..8722df999bfc --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/Tag.java @@ -0,0 +1,108 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Tag + */ +@javax.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "name", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/TypeHolderDefault.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/TypeHolderDefault.java new file mode 100644 index 000000000000..19e9bf310f76 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/TypeHolderDefault.java @@ -0,0 +1,198 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * TypeHolderDefault + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class TypeHolderDefault { + @JsonProperty("string_item") + private String stringItem = "what"; + + @JsonProperty("number_item") + private BigDecimal numberItem; + + @JsonProperty("integer_item") + private Integer integerItem; + + @JsonProperty("bool_item") + private Boolean boolItem = true; + + @JsonProperty("array_item") + @Valid + private List arrayItem = new ArrayList<>(); + + public TypeHolderDefault stringItem(String stringItem) { + this.stringItem = stringItem; + return this; + } + + /** + * Get stringItem + * @return stringItem + */ + @Schema(name = "stringItem", required = true, defaultValue = "") + @NotNull + + + public String getStringItem() { + return stringItem; + } + + public void setStringItem(String stringItem) { + this.stringItem = stringItem; + } + + public TypeHolderDefault numberItem(BigDecimal numberItem) { + this.numberItem = numberItem; + return this; + } + + /** + * Get numberItem + * @return numberItem + */ + @Schema(name = "numberItem", required = true, defaultValue = "") + @NotNull + + @Valid + + public BigDecimal getNumberItem() { + return numberItem; + } + + public void setNumberItem(BigDecimal numberItem) { + this.numberItem = numberItem; + } + + public TypeHolderDefault integerItem(Integer integerItem) { + this.integerItem = integerItem; + return this; + } + + /** + * Get integerItem + * @return integerItem + */ + @Schema(name = "integerItem", required = true, defaultValue = "") + @NotNull + + + public Integer getIntegerItem() { + return integerItem; + } + + public void setIntegerItem(Integer integerItem) { + this.integerItem = integerItem; + } + + public TypeHolderDefault boolItem(Boolean boolItem) { + this.boolItem = boolItem; + return this; + } + + /** + * Get boolItem + * @return boolItem + */ + @Schema(name = "boolItem", required = true, defaultValue = "") + @NotNull + + + public Boolean getBoolItem() { + return boolItem; + } + + public void setBoolItem(Boolean boolItem) { + this.boolItem = boolItem; + } + + public TypeHolderDefault arrayItem(List arrayItem) { + this.arrayItem = arrayItem; + return this; + } + + public TypeHolderDefault addArrayItemItem(Integer arrayItemItem) { + this.arrayItem.add(arrayItemItem); + return this; + } + + /** + * Get arrayItem + * @return arrayItem + */ + @Schema(name = "arrayItem", required = true, defaultValue = "") + @NotNull + + + public List getArrayItem() { + return arrayItem; + } + + public void setArrayItem(List arrayItem) { + this.arrayItem = arrayItem; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TypeHolderDefault typeHolderDefault = (TypeHolderDefault) o; + return Objects.equals(this.stringItem, typeHolderDefault.stringItem) && + Objects.equals(this.numberItem, typeHolderDefault.numberItem) && + Objects.equals(this.integerItem, typeHolderDefault.integerItem) && + Objects.equals(this.boolItem, typeHolderDefault.boolItem) && + Objects.equals(this.arrayItem, typeHolderDefault.arrayItem); + } + + @Override + public int hashCode() { + return Objects.hash(stringItem, numberItem, integerItem, boolItem, arrayItem); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TypeHolderDefault {\n"); + + sb.append(" stringItem: ").append(toIndentedString(stringItem)).append("\n"); + sb.append(" numberItem: ").append(toIndentedString(numberItem)).append("\n"); + sb.append(" integerItem: ").append(toIndentedString(integerItem)).append("\n"); + sb.append(" boolItem: ").append(toIndentedString(boolItem)).append("\n"); + sb.append(" arrayItem: ").append(toIndentedString(arrayItem)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/TypeHolderExample.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/TypeHolderExample.java new file mode 100644 index 000000000000..c9a3762bc74b --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/TypeHolderExample.java @@ -0,0 +1,224 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * TypeHolderExample + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class TypeHolderExample { + @JsonProperty("string_item") + private String stringItem; + + @JsonProperty("number_item") + private BigDecimal numberItem; + + @JsonProperty("float_item") + private Float floatItem; + + @JsonProperty("integer_item") + private Integer integerItem; + + @JsonProperty("bool_item") + private Boolean boolItem; + + @JsonProperty("array_item") + @Valid + private List arrayItem = new ArrayList<>(); + + public TypeHolderExample stringItem(String stringItem) { + this.stringItem = stringItem; + return this; + } + + /** + * Get stringItem + * @return stringItem + */ + @Schema(name = "stringItem", example = "what", required = true, defaultValue = "") + @NotNull + + + public String getStringItem() { + return stringItem; + } + + public void setStringItem(String stringItem) { + this.stringItem = stringItem; + } + + public TypeHolderExample numberItem(BigDecimal numberItem) { + this.numberItem = numberItem; + return this; + } + + /** + * Get numberItem + * @return numberItem + */ + @Schema(name = "numberItem", example = "1.234", required = true, defaultValue = "") + @NotNull + + @Valid + + public BigDecimal getNumberItem() { + return numberItem; + } + + public void setNumberItem(BigDecimal numberItem) { + this.numberItem = numberItem; + } + + public TypeHolderExample floatItem(Float floatItem) { + this.floatItem = floatItem; + return this; + } + + /** + * Get floatItem + * @return floatItem + */ + @Schema(name = "floatItem", example = "1.234", required = true, defaultValue = "") + @NotNull + + + public Float getFloatItem() { + return floatItem; + } + + public void setFloatItem(Float floatItem) { + this.floatItem = floatItem; + } + + public TypeHolderExample integerItem(Integer integerItem) { + this.integerItem = integerItem; + return this; + } + + /** + * Get integerItem + * @return integerItem + */ + @Schema(name = "integerItem", example = "-2", required = true, defaultValue = "") + @NotNull + + + public Integer getIntegerItem() { + return integerItem; + } + + public void setIntegerItem(Integer integerItem) { + this.integerItem = integerItem; + } + + public TypeHolderExample boolItem(Boolean boolItem) { + this.boolItem = boolItem; + return this; + } + + /** + * Get boolItem + * @return boolItem + */ + @Schema(name = "boolItem", example = "true", required = true, defaultValue = "") + @NotNull + + + public Boolean getBoolItem() { + return boolItem; + } + + public void setBoolItem(Boolean boolItem) { + this.boolItem = boolItem; + } + + public TypeHolderExample arrayItem(List arrayItem) { + this.arrayItem = arrayItem; + return this; + } + + public TypeHolderExample addArrayItemItem(Integer arrayItemItem) { + this.arrayItem.add(arrayItemItem); + return this; + } + + /** + * Get arrayItem + * @return arrayItem + */ + @Schema(name = "arrayItem", example = "[0, 1, 2, 3]", required = true, defaultValue = "") + @NotNull + + + public List getArrayItem() { + return arrayItem; + } + + public void setArrayItem(List arrayItem) { + this.arrayItem = arrayItem; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TypeHolderExample typeHolderExample = (TypeHolderExample) o; + return Objects.equals(this.stringItem, typeHolderExample.stringItem) && + Objects.equals(this.numberItem, typeHolderExample.numberItem) && + Objects.equals(this.floatItem, typeHolderExample.floatItem) && + Objects.equals(this.integerItem, typeHolderExample.integerItem) && + Objects.equals(this.boolItem, typeHolderExample.boolItem) && + Objects.equals(this.arrayItem, typeHolderExample.arrayItem); + } + + @Override + public int hashCode() { + return Objects.hash(stringItem, numberItem, floatItem, integerItem, boolItem, arrayItem); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TypeHolderExample {\n"); + + sb.append(" stringItem: ").append(toIndentedString(stringItem)).append("\n"); + sb.append(" numberItem: ").append(toIndentedString(numberItem)).append("\n"); + sb.append(" floatItem: ").append(toIndentedString(floatItem)).append("\n"); + sb.append(" integerItem: ").append(toIndentedString(integerItem)).append("\n"); + sb.append(" boolItem: ").append(toIndentedString(boolItem)).append("\n"); + sb.append(" arrayItem: ").append(toIndentedString(arrayItem)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/User.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/User.java new file mode 100644 index 000000000000..83152a155535 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/User.java @@ -0,0 +1,258 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * User + */ +@javax.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "username", defaultValue = "") + + + 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 + */ + @Schema(name = "firstName", defaultValue = "") + + + 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 + */ + @Schema(name = "lastName", defaultValue = "") + + + 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 + */ + @Schema(name = "email", defaultValue = "") + + + 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 + */ + @Schema(name = "password", defaultValue = "") + + + 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 + */ + @Schema(name = "phone", defaultValue = "") + + + 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 + */ + @Schema(name = "userStatus", defaultValue = "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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/XmlItem.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/XmlItem.java new file mode 100644 index 000000000000..59a183db0f62 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/XmlItem.java @@ -0,0 +1,872 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * XmlItem + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class XmlItem { + @JsonProperty("attribute_string") + private String attributeString; + + @JsonProperty("attribute_number") + private BigDecimal attributeNumber; + + @JsonProperty("attribute_integer") + private Integer attributeInteger; + + @JsonProperty("attribute_boolean") + private Boolean attributeBoolean; + + @JsonProperty("wrapped_array") + @Valid + private List wrappedArray = null; + + @JsonProperty("name_string") + private String nameString; + + @JsonProperty("name_number") + private BigDecimal nameNumber; + + @JsonProperty("name_integer") + private Integer nameInteger; + + @JsonProperty("name_boolean") + private Boolean nameBoolean; + + @JsonProperty("name_array") + @Valid + private List nameArray = null; + + @JsonProperty("name_wrapped_array") + @Valid + private List nameWrappedArray = null; + + @JsonProperty("prefix_string") + private String prefixString; + + @JsonProperty("prefix_number") + private BigDecimal prefixNumber; + + @JsonProperty("prefix_integer") + private Integer prefixInteger; + + @JsonProperty("prefix_boolean") + private Boolean prefixBoolean; + + @JsonProperty("prefix_array") + @Valid + private List prefixArray = null; + + @JsonProperty("prefix_wrapped_array") + @Valid + private List prefixWrappedArray = null; + + @JsonProperty("namespace_string") + private String namespaceString; + + @JsonProperty("namespace_number") + private BigDecimal namespaceNumber; + + @JsonProperty("namespace_integer") + private Integer namespaceInteger; + + @JsonProperty("namespace_boolean") + private Boolean namespaceBoolean; + + @JsonProperty("namespace_array") + @Valid + private List namespaceArray = null; + + @JsonProperty("namespace_wrapped_array") + @Valid + private List namespaceWrappedArray = null; + + @JsonProperty("prefix_ns_string") + private String prefixNsString; + + @JsonProperty("prefix_ns_number") + private BigDecimal prefixNsNumber; + + @JsonProperty("prefix_ns_integer") + private Integer prefixNsInteger; + + @JsonProperty("prefix_ns_boolean") + private Boolean prefixNsBoolean; + + @JsonProperty("prefix_ns_array") + @Valid + private List prefixNsArray = null; + + @JsonProperty("prefix_ns_wrapped_array") + @Valid + private List prefixNsWrappedArray = null; + + public XmlItem attributeString(String attributeString) { + this.attributeString = attributeString; + return this; + } + + /** + * Get attributeString + * @return attributeString + */ + @Schema(name = "attributeString", example = "string", defaultValue = "") + + + public String getAttributeString() { + return attributeString; + } + + public void setAttributeString(String attributeString) { + this.attributeString = attributeString; + } + + public XmlItem attributeNumber(BigDecimal attributeNumber) { + this.attributeNumber = attributeNumber; + return this; + } + + /** + * Get attributeNumber + * @return attributeNumber + */ + @Schema(name = "attributeNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getAttributeNumber() { + return attributeNumber; + } + + public void setAttributeNumber(BigDecimal attributeNumber) { + this.attributeNumber = attributeNumber; + } + + public XmlItem attributeInteger(Integer attributeInteger) { + this.attributeInteger = attributeInteger; + return this; + } + + /** + * Get attributeInteger + * @return attributeInteger + */ + @Schema(name = "attributeInteger", example = "-2", defaultValue = "") + + + public Integer getAttributeInteger() { + return attributeInteger; + } + + public void setAttributeInteger(Integer attributeInteger) { + this.attributeInteger = attributeInteger; + } + + public XmlItem attributeBoolean(Boolean attributeBoolean) { + this.attributeBoolean = attributeBoolean; + return this; + } + + /** + * Get attributeBoolean + * @return attributeBoolean + */ + @Schema(name = "attributeBoolean", example = "true", defaultValue = "") + + + public Boolean getAttributeBoolean() { + return attributeBoolean; + } + + public void setAttributeBoolean(Boolean attributeBoolean) { + this.attributeBoolean = attributeBoolean; + } + + public XmlItem wrappedArray(List wrappedArray) { + this.wrappedArray = wrappedArray; + return this; + } + + public XmlItem addWrappedArrayItem(Integer wrappedArrayItem) { + if (this.wrappedArray == null) { + this.wrappedArray = new ArrayList<>(); + } + this.wrappedArray.add(wrappedArrayItem); + return this; + } + + /** + * Get wrappedArray + * @return wrappedArray + */ + @Schema(name = "wrappedArray", defaultValue = "") + + + public List getWrappedArray() { + return wrappedArray; + } + + public void setWrappedArray(List wrappedArray) { + this.wrappedArray = wrappedArray; + } + + public XmlItem nameString(String nameString) { + this.nameString = nameString; + return this; + } + + /** + * Get nameString + * @return nameString + */ + @Schema(name = "nameString", example = "string", defaultValue = "") + + + public String getNameString() { + return nameString; + } + + public void setNameString(String nameString) { + this.nameString = nameString; + } + + public XmlItem nameNumber(BigDecimal nameNumber) { + this.nameNumber = nameNumber; + return this; + } + + /** + * Get nameNumber + * @return nameNumber + */ + @Schema(name = "nameNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getNameNumber() { + return nameNumber; + } + + public void setNameNumber(BigDecimal nameNumber) { + this.nameNumber = nameNumber; + } + + public XmlItem nameInteger(Integer nameInteger) { + this.nameInteger = nameInteger; + return this; + } + + /** + * Get nameInteger + * @return nameInteger + */ + @Schema(name = "nameInteger", example = "-2", defaultValue = "") + + + public Integer getNameInteger() { + return nameInteger; + } + + public void setNameInteger(Integer nameInteger) { + this.nameInteger = nameInteger; + } + + public XmlItem nameBoolean(Boolean nameBoolean) { + this.nameBoolean = nameBoolean; + return this; + } + + /** + * Get nameBoolean + * @return nameBoolean + */ + @Schema(name = "nameBoolean", example = "true", defaultValue = "") + + + public Boolean getNameBoolean() { + return nameBoolean; + } + + public void setNameBoolean(Boolean nameBoolean) { + this.nameBoolean = nameBoolean; + } + + public XmlItem nameArray(List nameArray) { + this.nameArray = nameArray; + return this; + } + + public XmlItem addNameArrayItem(Integer nameArrayItem) { + if (this.nameArray == null) { + this.nameArray = new ArrayList<>(); + } + this.nameArray.add(nameArrayItem); + return this; + } + + /** + * Get nameArray + * @return nameArray + */ + @Schema(name = "nameArray", defaultValue = "") + + + public List getNameArray() { + return nameArray; + } + + public void setNameArray(List nameArray) { + this.nameArray = nameArray; + } + + public XmlItem nameWrappedArray(List nameWrappedArray) { + this.nameWrappedArray = nameWrappedArray; + return this; + } + + public XmlItem addNameWrappedArrayItem(Integer nameWrappedArrayItem) { + if (this.nameWrappedArray == null) { + this.nameWrappedArray = new ArrayList<>(); + } + this.nameWrappedArray.add(nameWrappedArrayItem); + return this; + } + + /** + * Get nameWrappedArray + * @return nameWrappedArray + */ + @Schema(name = "nameWrappedArray", defaultValue = "") + + + public List getNameWrappedArray() { + return nameWrappedArray; + } + + public void setNameWrappedArray(List nameWrappedArray) { + this.nameWrappedArray = nameWrappedArray; + } + + public XmlItem prefixString(String prefixString) { + this.prefixString = prefixString; + return this; + } + + /** + * Get prefixString + * @return prefixString + */ + @Schema(name = "prefixString", example = "string", defaultValue = "") + + + public String getPrefixString() { + return prefixString; + } + + public void setPrefixString(String prefixString) { + this.prefixString = prefixString; + } + + public XmlItem prefixNumber(BigDecimal prefixNumber) { + this.prefixNumber = prefixNumber; + return this; + } + + /** + * Get prefixNumber + * @return prefixNumber + */ + @Schema(name = "prefixNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getPrefixNumber() { + return prefixNumber; + } + + public void setPrefixNumber(BigDecimal prefixNumber) { + this.prefixNumber = prefixNumber; + } + + public XmlItem prefixInteger(Integer prefixInteger) { + this.prefixInteger = prefixInteger; + return this; + } + + /** + * Get prefixInteger + * @return prefixInteger + */ + @Schema(name = "prefixInteger", example = "-2", defaultValue = "") + + + public Integer getPrefixInteger() { + return prefixInteger; + } + + public void setPrefixInteger(Integer prefixInteger) { + this.prefixInteger = prefixInteger; + } + + public XmlItem prefixBoolean(Boolean prefixBoolean) { + this.prefixBoolean = prefixBoolean; + return this; + } + + /** + * Get prefixBoolean + * @return prefixBoolean + */ + @Schema(name = "prefixBoolean", example = "true", defaultValue = "") + + + public Boolean getPrefixBoolean() { + return prefixBoolean; + } + + public void setPrefixBoolean(Boolean prefixBoolean) { + this.prefixBoolean = prefixBoolean; + } + + public XmlItem prefixArray(List prefixArray) { + this.prefixArray = prefixArray; + return this; + } + + public XmlItem addPrefixArrayItem(Integer prefixArrayItem) { + if (this.prefixArray == null) { + this.prefixArray = new ArrayList<>(); + } + this.prefixArray.add(prefixArrayItem); + return this; + } + + /** + * Get prefixArray + * @return prefixArray + */ + @Schema(name = "prefixArray", defaultValue = "") + + + public List getPrefixArray() { + return prefixArray; + } + + public void setPrefixArray(List prefixArray) { + this.prefixArray = prefixArray; + } + + public XmlItem prefixWrappedArray(List prefixWrappedArray) { + this.prefixWrappedArray = prefixWrappedArray; + return this; + } + + public XmlItem addPrefixWrappedArrayItem(Integer prefixWrappedArrayItem) { + if (this.prefixWrappedArray == null) { + this.prefixWrappedArray = new ArrayList<>(); + } + this.prefixWrappedArray.add(prefixWrappedArrayItem); + return this; + } + + /** + * Get prefixWrappedArray + * @return prefixWrappedArray + */ + @Schema(name = "prefixWrappedArray", defaultValue = "") + + + public List getPrefixWrappedArray() { + return prefixWrappedArray; + } + + public void setPrefixWrappedArray(List prefixWrappedArray) { + this.prefixWrappedArray = prefixWrappedArray; + } + + public XmlItem namespaceString(String namespaceString) { + this.namespaceString = namespaceString; + return this; + } + + /** + * Get namespaceString + * @return namespaceString + */ + @Schema(name = "namespaceString", example = "string", defaultValue = "") + + + public String getNamespaceString() { + return namespaceString; + } + + public void setNamespaceString(String namespaceString) { + this.namespaceString = namespaceString; + } + + public XmlItem namespaceNumber(BigDecimal namespaceNumber) { + this.namespaceNumber = namespaceNumber; + return this; + } + + /** + * Get namespaceNumber + * @return namespaceNumber + */ + @Schema(name = "namespaceNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getNamespaceNumber() { + return namespaceNumber; + } + + public void setNamespaceNumber(BigDecimal namespaceNumber) { + this.namespaceNumber = namespaceNumber; + } + + public XmlItem namespaceInteger(Integer namespaceInteger) { + this.namespaceInteger = namespaceInteger; + return this; + } + + /** + * Get namespaceInteger + * @return namespaceInteger + */ + @Schema(name = "namespaceInteger", example = "-2", defaultValue = "") + + + public Integer getNamespaceInteger() { + return namespaceInteger; + } + + public void setNamespaceInteger(Integer namespaceInteger) { + this.namespaceInteger = namespaceInteger; + } + + public XmlItem namespaceBoolean(Boolean namespaceBoolean) { + this.namespaceBoolean = namespaceBoolean; + return this; + } + + /** + * Get namespaceBoolean + * @return namespaceBoolean + */ + @Schema(name = "namespaceBoolean", example = "true", defaultValue = "") + + + public Boolean getNamespaceBoolean() { + return namespaceBoolean; + } + + public void setNamespaceBoolean(Boolean namespaceBoolean) { + this.namespaceBoolean = namespaceBoolean; + } + + public XmlItem namespaceArray(List namespaceArray) { + this.namespaceArray = namespaceArray; + return this; + } + + public XmlItem addNamespaceArrayItem(Integer namespaceArrayItem) { + if (this.namespaceArray == null) { + this.namespaceArray = new ArrayList<>(); + } + this.namespaceArray.add(namespaceArrayItem); + return this; + } + + /** + * Get namespaceArray + * @return namespaceArray + */ + @Schema(name = "namespaceArray", defaultValue = "") + + + public List getNamespaceArray() { + return namespaceArray; + } + + public void setNamespaceArray(List namespaceArray) { + this.namespaceArray = namespaceArray; + } + + public XmlItem namespaceWrappedArray(List namespaceWrappedArray) { + this.namespaceWrappedArray = namespaceWrappedArray; + return this; + } + + public XmlItem addNamespaceWrappedArrayItem(Integer namespaceWrappedArrayItem) { + if (this.namespaceWrappedArray == null) { + this.namespaceWrappedArray = new ArrayList<>(); + } + this.namespaceWrappedArray.add(namespaceWrappedArrayItem); + return this; + } + + /** + * Get namespaceWrappedArray + * @return namespaceWrappedArray + */ + @Schema(name = "namespaceWrappedArray", defaultValue = "") + + + public List getNamespaceWrappedArray() { + return namespaceWrappedArray; + } + + public void setNamespaceWrappedArray(List namespaceWrappedArray) { + this.namespaceWrappedArray = namespaceWrappedArray; + } + + public XmlItem prefixNsString(String prefixNsString) { + this.prefixNsString = prefixNsString; + return this; + } + + /** + * Get prefixNsString + * @return prefixNsString + */ + @Schema(name = "prefixNsString", example = "string", defaultValue = "") + + + public String getPrefixNsString() { + return prefixNsString; + } + + public void setPrefixNsString(String prefixNsString) { + this.prefixNsString = prefixNsString; + } + + public XmlItem prefixNsNumber(BigDecimal prefixNsNumber) { + this.prefixNsNumber = prefixNsNumber; + return this; + } + + /** + * Get prefixNsNumber + * @return prefixNsNumber + */ + @Schema(name = "prefixNsNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getPrefixNsNumber() { + return prefixNsNumber; + } + + public void setPrefixNsNumber(BigDecimal prefixNsNumber) { + this.prefixNsNumber = prefixNsNumber; + } + + public XmlItem prefixNsInteger(Integer prefixNsInteger) { + this.prefixNsInteger = prefixNsInteger; + return this; + } + + /** + * Get prefixNsInteger + * @return prefixNsInteger + */ + @Schema(name = "prefixNsInteger", example = "-2", defaultValue = "") + + + public Integer getPrefixNsInteger() { + return prefixNsInteger; + } + + public void setPrefixNsInteger(Integer prefixNsInteger) { + this.prefixNsInteger = prefixNsInteger; + } + + public XmlItem prefixNsBoolean(Boolean prefixNsBoolean) { + this.prefixNsBoolean = prefixNsBoolean; + return this; + } + + /** + * Get prefixNsBoolean + * @return prefixNsBoolean + */ + @Schema(name = "prefixNsBoolean", example = "true", defaultValue = "") + + + public Boolean getPrefixNsBoolean() { + return prefixNsBoolean; + } + + public void setPrefixNsBoolean(Boolean prefixNsBoolean) { + this.prefixNsBoolean = prefixNsBoolean; + } + + public XmlItem prefixNsArray(List prefixNsArray) { + this.prefixNsArray = prefixNsArray; + return this; + } + + public XmlItem addPrefixNsArrayItem(Integer prefixNsArrayItem) { + if (this.prefixNsArray == null) { + this.prefixNsArray = new ArrayList<>(); + } + this.prefixNsArray.add(prefixNsArrayItem); + return this; + } + + /** + * Get prefixNsArray + * @return prefixNsArray + */ + @Schema(name = "prefixNsArray", defaultValue = "") + + + public List getPrefixNsArray() { + return prefixNsArray; + } + + public void setPrefixNsArray(List prefixNsArray) { + this.prefixNsArray = prefixNsArray; + } + + public XmlItem prefixNsWrappedArray(List prefixNsWrappedArray) { + this.prefixNsWrappedArray = prefixNsWrappedArray; + return this; + } + + public XmlItem addPrefixNsWrappedArrayItem(Integer prefixNsWrappedArrayItem) { + if (this.prefixNsWrappedArray == null) { + this.prefixNsWrappedArray = new ArrayList<>(); + } + this.prefixNsWrappedArray.add(prefixNsWrappedArrayItem); + return this; + } + + /** + * Get prefixNsWrappedArray + * @return prefixNsWrappedArray + */ + @Schema(name = "prefixNsWrappedArray", defaultValue = "") + + + public List getPrefixNsWrappedArray() { + return prefixNsWrappedArray; + } + + public void setPrefixNsWrappedArray(List prefixNsWrappedArray) { + this.prefixNsWrappedArray = prefixNsWrappedArray; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + XmlItem xmlItem = (XmlItem) o; + return Objects.equals(this.attributeString, xmlItem.attributeString) && + Objects.equals(this.attributeNumber, xmlItem.attributeNumber) && + Objects.equals(this.attributeInteger, xmlItem.attributeInteger) && + Objects.equals(this.attributeBoolean, xmlItem.attributeBoolean) && + Objects.equals(this.wrappedArray, xmlItem.wrappedArray) && + Objects.equals(this.nameString, xmlItem.nameString) && + Objects.equals(this.nameNumber, xmlItem.nameNumber) && + Objects.equals(this.nameInteger, xmlItem.nameInteger) && + Objects.equals(this.nameBoolean, xmlItem.nameBoolean) && + Objects.equals(this.nameArray, xmlItem.nameArray) && + Objects.equals(this.nameWrappedArray, xmlItem.nameWrappedArray) && + Objects.equals(this.prefixString, xmlItem.prefixString) && + Objects.equals(this.prefixNumber, xmlItem.prefixNumber) && + Objects.equals(this.prefixInteger, xmlItem.prefixInteger) && + Objects.equals(this.prefixBoolean, xmlItem.prefixBoolean) && + Objects.equals(this.prefixArray, xmlItem.prefixArray) && + Objects.equals(this.prefixWrappedArray, xmlItem.prefixWrappedArray) && + Objects.equals(this.namespaceString, xmlItem.namespaceString) && + Objects.equals(this.namespaceNumber, xmlItem.namespaceNumber) && + Objects.equals(this.namespaceInteger, xmlItem.namespaceInteger) && + Objects.equals(this.namespaceBoolean, xmlItem.namespaceBoolean) && + Objects.equals(this.namespaceArray, xmlItem.namespaceArray) && + Objects.equals(this.namespaceWrappedArray, xmlItem.namespaceWrappedArray) && + Objects.equals(this.prefixNsString, xmlItem.prefixNsString) && + Objects.equals(this.prefixNsNumber, xmlItem.prefixNsNumber) && + Objects.equals(this.prefixNsInteger, xmlItem.prefixNsInteger) && + Objects.equals(this.prefixNsBoolean, xmlItem.prefixNsBoolean) && + Objects.equals(this.prefixNsArray, xmlItem.prefixNsArray) && + Objects.equals(this.prefixNsWrappedArray, xmlItem.prefixNsWrappedArray); + } + + @Override + public int hashCode() { + return Objects.hash(attributeString, attributeNumber, attributeInteger, attributeBoolean, wrappedArray, nameString, nameNumber, nameInteger, nameBoolean, nameArray, nameWrappedArray, prefixString, prefixNumber, prefixInteger, prefixBoolean, prefixArray, prefixWrappedArray, namespaceString, namespaceNumber, namespaceInteger, namespaceBoolean, namespaceArray, namespaceWrappedArray, prefixNsString, prefixNsNumber, prefixNsInteger, prefixNsBoolean, prefixNsArray, prefixNsWrappedArray); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class XmlItem {\n"); + + sb.append(" attributeString: ").append(toIndentedString(attributeString)).append("\n"); + sb.append(" attributeNumber: ").append(toIndentedString(attributeNumber)).append("\n"); + sb.append(" attributeInteger: ").append(toIndentedString(attributeInteger)).append("\n"); + sb.append(" attributeBoolean: ").append(toIndentedString(attributeBoolean)).append("\n"); + sb.append(" wrappedArray: ").append(toIndentedString(wrappedArray)).append("\n"); + sb.append(" nameString: ").append(toIndentedString(nameString)).append("\n"); + sb.append(" nameNumber: ").append(toIndentedString(nameNumber)).append("\n"); + sb.append(" nameInteger: ").append(toIndentedString(nameInteger)).append("\n"); + sb.append(" nameBoolean: ").append(toIndentedString(nameBoolean)).append("\n"); + sb.append(" nameArray: ").append(toIndentedString(nameArray)).append("\n"); + sb.append(" nameWrappedArray: ").append(toIndentedString(nameWrappedArray)).append("\n"); + sb.append(" prefixString: ").append(toIndentedString(prefixString)).append("\n"); + sb.append(" prefixNumber: ").append(toIndentedString(prefixNumber)).append("\n"); + sb.append(" prefixInteger: ").append(toIndentedString(prefixInteger)).append("\n"); + sb.append(" prefixBoolean: ").append(toIndentedString(prefixBoolean)).append("\n"); + sb.append(" prefixArray: ").append(toIndentedString(prefixArray)).append("\n"); + sb.append(" prefixWrappedArray: ").append(toIndentedString(prefixWrappedArray)).append("\n"); + sb.append(" namespaceString: ").append(toIndentedString(namespaceString)).append("\n"); + sb.append(" namespaceNumber: ").append(toIndentedString(namespaceNumber)).append("\n"); + sb.append(" namespaceInteger: ").append(toIndentedString(namespaceInteger)).append("\n"); + sb.append(" namespaceBoolean: ").append(toIndentedString(namespaceBoolean)).append("\n"); + sb.append(" namespaceArray: ").append(toIndentedString(namespaceArray)).append("\n"); + sb.append(" namespaceWrappedArray: ").append(toIndentedString(namespaceWrappedArray)).append("\n"); + sb.append(" prefixNsString: ").append(toIndentedString(prefixNsString)).append("\n"); + sb.append(" prefixNsNumber: ").append(toIndentedString(prefixNsNumber)).append("\n"); + sb.append(" prefixNsInteger: ").append(toIndentedString(prefixNsInteger)).append("\n"); + sb.append(" prefixNsBoolean: ").append(toIndentedString(prefixNsBoolean)).append("\n"); + sb.append(" prefixNsArray: ").append(toIndentedString(prefixNsArray)).append("\n"); + sb.append(" prefixNsWrappedArray: ").append(toIndentedString(prefixNsWrappedArray)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/resources/application.properties b/samples/openapi3/server/petstore/springboot-reactive/src/main/resources/application.properties new file mode 100644 index 000000000000..9d06609db665 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/resources/application.properties @@ -0,0 +1,3 @@ +server.port=80 +spring.jackson.date-format=org.openapitools.RFC3339DateFormat +spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/resources/openapi.yaml b/samples/openapi3/server/petstore/springboot-reactive/src/main/resources/openapi.yaml new file mode 100644 index 000000000000..d6386dc39bf4 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/resources/openapi.yaml @@ -0,0 +1,2264 @@ +openapi: 3.0.1 +info: + description: 'This spec is mainly for testing Petstore server and contains fake + endpoints, models. Please do not use this for any other purpose. Special characters: + " \' + license: + name: Apache-2.0 + url: https://www.apache.org/licenses/LICENSE-2.0.html + title: OpenAPI Petstore + version: 1.0.0 +servers: +- url: http://petstore.swagger.io:80/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: + operationId: addPet + requestBody: + 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 + responses: + "200": + content: {} + description: successful operation + "405": + content: {} + description: Invalid input + security: + - petstore_auth: + - write:pets + - read:pets + summary: Add a new pet to the store + tags: + - pet + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: pet + put: + operationId: updatePet + requestBody: + 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 + responses: + "200": + content: {} + description: successful operation + "400": + content: {} + description: Invalid ID supplied + "404": + content: {} + description: Pet not found + "405": + content: {} + description: Validation exception + security: + - petstore_auth: + - write:pets + - read:pets + summary: Update an existing pet + tags: + - pet + x-codegen-request-body-name: body + x-contentType: 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: + - 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": + content: {} + description: Invalid status value + security: + - petstore_auth: + - write:pets + - 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 + uniqueItems: true + style: form + responses: + "200": + content: + application/xml: + schema: + items: + $ref: '#/components/schemas/Pet' + type: array + uniqueItems: true + application/json: + schema: + items: + $ref: '#/components/schemas/Pet' + type: array + uniqueItems: true + description: successful operation + "400": + content: {} + description: Invalid tag value + security: + - petstore_auth: + - write:pets + - read:pets + summary: Finds Pets by tags + tags: + - pet + x-accepts: application/json + x-tags: + - tag: pet + /pet/{petId}: + delete: + operationId: deletePet + parameters: + - in: header + name: api_key + schema: + type: string + - description: Pet id to delete + in: path + name: petId + required: true + schema: + format: int64 + type: integer + responses: + "200": + content: {} + description: successful operation + "400": + content: {} + 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 + in: path + name: petId + required: true + schema: + format: int64 + type: integer + responses: + "200": + content: + application/xml: + schema: + $ref: '#/components/schemas/Pet' + application/json: + schema: + $ref: '#/components/schemas/Pet' + description: successful operation + "400": + content: {} + description: Invalid ID supplied + "404": + content: {} + description: Pet not found + security: + - api_key: [] + summary: Find pet by ID + tags: + - pet + x-accepts: application/json + x-tags: + - tag: pet + post: + operationId: updatePetWithForm + parameters: + - description: ID of pet that needs to be updated + in: path + name: petId + required: true + schema: + format: int64 + type: integer + requestBody: + content: + application/x-www-form-urlencoded: + schema: + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string + responses: + "405": + content: {} + description: Invalid input + security: + - petstore_auth: + - write:pets + - read:pets + summary: Updates a pet in the store with form data + tags: + - pet + x-contentType: application/x-www-form-urlencoded + x-accepts: application/json + x-tags: + - tag: pet + /pet/{petId}/uploadImage: + post: + operationId: uploadFile + parameters: + - description: ID of pet to update + in: path + name: petId + required: true + schema: + format: int64 + type: integer + requestBody: + content: + multipart/form-data: + schema: + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + format: binary + type: string + 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-contentType: 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: + operationId: placeOrder + requestBody: + content: + '*/*': + 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": + content: {} + description: Invalid Order + summary: Place an order for a pet + tags: + - store + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: application/json + x-tags: + - tag: store + /store/order/{order_id}: + 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 + in: path + name: order_id + required: true + schema: + type: string + responses: + "400": + content: {} + description: Invalid ID supplied + "404": + content: {} + 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 generated exceptions + operationId: getOrderById + parameters: + - description: ID of pet that needs to be fetched + in: path + name: order_id + required: true + schema: + format: int64 + maximum: 5 + minimum: 1 + type: integer + responses: + "200": + content: + application/xml: + schema: + $ref: '#/components/schemas/Order' + application/json: + schema: + $ref: '#/components/schemas/Order' + description: successful operation + "400": + content: {} + description: Invalid ID supplied + "404": + content: {} + 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: + '*/*': + schema: + $ref: '#/components/schemas/User' + description: Created user object + required: true + responses: + default: + content: {} + description: successful operation + summary: Create user + tags: + - user + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: application/json + x-tags: + - tag: user + /user/createWithArray: + post: + operationId: createUsersWithArrayInput + requestBody: + content: + '*/*': + schema: + items: + $ref: '#/components/schemas/User' + type: array + description: List of user object + required: true + responses: + default: + content: {} + description: successful operation + summary: Creates list of users with given input array + tags: + - user + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: application/json + x-tags: + - tag: user + /user/createWithList: + post: + operationId: createUsersWithListInput + requestBody: + content: + '*/*': + schema: + items: + $ref: '#/components/schemas/User' + type: array + description: List of user object + required: true + responses: + default: + content: {} + description: successful operation + summary: Creates list of users with given input array + tags: + - user + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: application/json + x-tags: + - tag: user + /user/login: + get: + operationId: loginUser + parameters: + - description: The user name for login + in: query + name: username + required: true + schema: + type: string + - description: The password for login in clear text + in: query + name: password + required: true + schema: + type: string + responses: + "200": + content: + application/xml: + schema: + type: string + application/json: + schema: + type: string + description: successful operation + headers: + X-Rate-Limit: + description: calls per hour allowed by the user + schema: + format: int32 + type: integer + X-Expires-After: + description: date in UTC when token expires + schema: + format: date-time + type: string + "400": + content: {} + description: Invalid username/password supplied + summary: Logs user into the system + tags: + - user + x-accepts: application/json + x-tags: + - tag: user + /user/logout: + get: + operationId: logoutUser + responses: + default: + content: {} + description: successful operation + 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 + in: path + name: username + required: true + schema: + type: string + responses: + "400": + content: {} + description: Invalid username supplied + "404": + content: {} + description: User not found + summary: Delete user + tags: + - user + x-accepts: application/json + x-tags: + - tag: user + get: + operationId: getUserByName + parameters: + - description: The name that needs to be fetched. Use user1 for testing. + in: path + name: username + required: true + schema: + type: string + responses: + "200": + content: + application/xml: + schema: + $ref: '#/components/schemas/User' + application/json: + schema: + $ref: '#/components/schemas/User' + description: successful operation + "400": + content: {} + description: Invalid username supplied + "404": + content: {} + 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 + in: path + name: username + required: true + schema: + type: string + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/User' + description: Updated user object + required: true + responses: + "400": + content: {} + description: Invalid user supplied + "404": + content: {} + description: User not found + summary: Updated user + tags: + - user + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: application/json + x-tags: + - tag: user + /fake_classname_test: + patch: + description: To test class name in snake case + operationId: testClassname + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: client model + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: successful operation + security: + - api_key_query: [] + summary: To test class name in snake case + tags: + - fake_classname_tags 123#$%^ + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: fake_classname_tags 123#$%^ + /fake: + delete: + description: Fake endpoint to test group parameters (optional) + operationId: testGroupParameters + parameters: + - description: Required String in group parameters + in: query + name: required_string_group + required: true + schema: + type: integer + - description: Required Boolean in group parameters + in: header + name: required_boolean_group + required: true + schema: + type: boolean + - description: Required Integer in group parameters + in: query + name: required_int64_group + required: true + schema: + format: int64 + type: integer + - description: String in group parameters + in: query + name: string_group + schema: + type: integer + - description: Boolean in group parameters + in: header + name: boolean_group + schema: + type: boolean + - description: Integer in group parameters + in: query + name: int64_group + schema: + format: int64 + type: integer + responses: + "400": + content: {} + description: Someting wrong + summary: Fake endpoint to test group parameters (optional) + tags: + - fake + x-group-parameters: true + x-accepts: application/json + x-tags: + - tag: fake + get: + description: To test enum parameters + operationId: testEnumParameters + parameters: + - description: Header parameter enum test (string array) + explode: false + in: header + name: enum_header_string_array + schema: + items: + default: $ + enum: + - '>' + - $ + type: string + type: array + style: simple + - description: Header parameter enum test (string) + in: header + name: enum_header_string + schema: + default: -efg + enum: + - _abc + - -efg + - (xyz) + type: string + - description: Query parameter enum test (string array) + explode: false + in: query + name: enum_query_string_array + schema: + items: + default: $ + enum: + - '>' + - $ + type: string + type: array + style: form + - description: Query parameter enum test (string) + in: query + name: enum_query_string + schema: + default: -efg + enum: + - _abc + - -efg + - (xyz) + type: string + - description: Query parameter enum test (double) + in: query + name: enum_query_integer + schema: + enum: + - 1 + - -2 + format: int32 + type: integer + - description: Query parameter enum test (double) + in: query + name: enum_query_double + schema: + enum: + - 1.1 + - -1.2 + format: double + type: number + requestBody: + content: + application/x-www-form-urlencoded: + schema: + properties: + enum_form_string_array: + description: Form parameter enum test (string array) + items: + default: $ + enum: + - '>' + - $ + type: string + type: array + enum_form_string: + default: -efg + description: Form parameter enum test (string) + enum: + - _abc + - -efg + - (xyz) + type: string + responses: + "400": + content: {} + description: Invalid request + "404": + content: {} + description: Not found + summary: To test enum parameters + tags: + - fake + x-contentType: application/x-www-form-urlencoded + x-accepts: application/json + x-tags: + - tag: fake + patch: + description: To test "client" model + operationId: testClientModel + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: client model + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: successful operation + summary: To test "client" model + tags: + - fake + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: fake + post: + description: |- + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + operationId: testEndpointParameters + requestBody: + content: + application/x-www-form-urlencoded: + schema: + properties: + integer: + description: None + format: int32 + maximum: 100 + minimum: 10 + type: integer + int32: + description: None + format: int32 + maximum: 200 + minimum: 20 + type: integer + int64: + description: None + format: int64 + type: integer + number: + description: None + maximum: 543.2 + minimum: 32.1 + type: number + float: + description: None + format: float + maximum: 987.6 + type: number + double: + description: None + format: double + maximum: 123.4 + minimum: 67.8 + type: number + string: + description: None + pattern: /[a-z]/i + type: string + pattern_without_delimiter: + description: None + pattern: ^[A-Z].* + type: string + byte: + description: None + format: byte + type: string + binary: + description: None + format: binary + type: string + date: + description: None + format: date + type: string + dateTime: + description: None + format: date-time + type: string + password: + description: None + format: password + maxLength: 64 + minLength: 10 + type: string + callback: + description: None + type: string + required: + - byte + - double + - number + - pattern_without_delimiter + required: true + responses: + "400": + content: {} + description: Invalid username supplied + "404": + content: {} + description: User not found + security: + - http_basic_test: [] + summary: |- + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + tags: + - fake + x-contentType: application/x-www-form-urlencoded + x-accepts: application/json + x-tags: + - tag: fake + /fake/outer/number: + post: + description: Test serialization of outer number types + operationId: fakeOuterNumberSerialize + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterNumber' + description: Input number as post body + required: false + responses: + "200": + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterNumber' + description: Output number + tags: + - fake + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: '*/*' + x-tags: + - tag: fake + /fake/outer/string: + post: + description: Test serialization of outer string types + operationId: fakeOuterStringSerialize + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterString' + description: Input string as post body + required: false + responses: + "200": + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterString' + description: Output string + tags: + - fake + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: '*/*' + x-tags: + - tag: fake + /fake/outer/boolean: + post: + description: Test serialization of outer boolean types + operationId: fakeOuterBooleanSerialize + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterBoolean' + description: Input boolean as post body + required: false + responses: + "200": + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterBoolean' + description: Output boolean + tags: + - fake + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: '*/*' + x-tags: + - tag: fake + /fake/outer/composite: + post: + description: Test serialization of object with outer number type + operationId: fakeOuterCompositeSerialize + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterComposite' + description: Input composite as post body + required: false + responses: + "200": + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterComposite' + description: Output composite + tags: + - fake + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: '*/*' + x-tags: + - tag: fake + /fake/jsonFormData: + get: + operationId: testJsonFormData + requestBody: + content: + application/x-www-form-urlencoded: + schema: + properties: + param: + description: field1 + type: string + param2: + description: field2 + type: string + required: + - param + - param2 + required: true + responses: + "200": + content: {} + description: successful operation + summary: test json serialization of form data + tags: + - fake + x-contentType: application/x-www-form-urlencoded + x-accepts: application/json + x-tags: + - tag: fake + /fake/inline-additionalProperties: + post: + operationId: testInlineAdditionalProperties + requestBody: + content: + application/json: + schema: + additionalProperties: + type: string + type: object + description: request body + required: true + responses: + "200": + content: {} + description: successful operation + summary: test inline additionalProperties + tags: + - fake + x-codegen-request-body-name: param + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: fake + /fake/body-with-query-params: + put: + operationId: testBodyWithQueryParams + parameters: + - in: query + name: query + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + required: true + responses: + "200": + content: {} + description: Success + tags: + - fake + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: fake + /fake/create_xml_item: + post: + description: this route creates an XmlItem + operationId: createXmlItem + requestBody: + content: + application/xml: + schema: + $ref: '#/components/schemas/XmlItem' + application/xml; charset=utf-8: + schema: + $ref: '#/components/schemas/XmlItem' + application/xml; charset=utf-16: + schema: + $ref: '#/components/schemas/XmlItem' + text/xml: + schema: + $ref: '#/components/schemas/XmlItem' + text/xml; charset=utf-8: + schema: + $ref: '#/components/schemas/XmlItem' + text/xml; charset=utf-16: + schema: + $ref: '#/components/schemas/XmlItem' + description: XmlItem Body + required: true + responses: + "200": + content: {} + description: successful operation + summary: creates an XmlItem + tags: + - fake + x-codegen-request-body-name: XmlItem + x-contentType: application/xml + x-accepts: application/json + x-tags: + - tag: fake + /another-fake/dummy: + patch: + description: To test special tags and operation ID starting with number + operationId: 123_test_@#$%_special_tags + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: client model + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: successful operation + summary: To test special tags + tags: + - $another-fake? + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: $another-fake? + /fake/body-with-file-schema: + put: + description: For this test, the body for this request much reference a schema + named `File`. + operationId: testBodyWithFileSchema + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/FileSchemaTestClass' + required: true + responses: + "200": + content: {} + description: Success + tags: + - fake + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: fake + /fake/test-query-parameters: + put: + description: To test the collection format in query parameters + operationId: testQueryParameterCollectionFormat + parameters: + - explode: false + in: query + name: pipe + required: true + schema: + items: + type: string + type: array + style: form + - in: query + name: ioutil + required: true + schema: + items: + type: string + type: array + - in: query + name: http + required: true + schema: + items: + type: string + type: array + style: spaceDelimited + - explode: false + in: query + name: url + required: true + schema: + items: + type: string + type: array + style: form + - explode: true + in: query + name: context + required: true + schema: + items: + type: string + type: array + style: form + responses: + "200": + content: {} + description: Success + tags: + - fake + x-accepts: application/json + x-tags: + - tag: fake + /fake/{petId}/uploadImageWithRequiredFile: + post: + operationId: uploadFileWithRequiredFile + parameters: + - description: ID of pet to update + in: path + name: petId + required: true + schema: + format: int64 + type: integer + requestBody: + content: + multipart/form-data: + schema: + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + requiredFile: + description: file to upload + format: binary + type: string + required: + - requiredFile + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an image (required) + tags: + - pet + x-contentType: multipart/form-data + x-accepts: application/json + x-tags: + - tag: pet +components: + schemas: + Order: + 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 + type: object + xml: + name: Order + Category: + example: + name: default-name + id: 6 + properties: + id: + format: int64 + type: integer + name: + default: default-name + type: string + required: + - name + type: object + xml: + name: Category + User: + example: + firstName: firstName + lastName: lastName + password: password + userStatus: 6 + phone: phone + id: 0 + email: email + username: username + properties: + id: + format: int64 + type: integer + x-is-unique: true + 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 + type: object + xml: + name: User + Tag: + example: + name: name + id: 1 + properties: + id: + format: int64 + type: integer + name: + type: string + type: object + xml: + name: Tag + Pet: + example: + photoUrls: + - photoUrls + - photoUrls + name: doggie + id: 0 + category: + name: default-name + id: 6 + tags: + - name: name + id: 1 + - name: name + id: 1 + status: available + properties: + id: + format: int64 + type: integer + x-is-unique: true + category: + $ref: '#/components/schemas/Category' + name: + example: doggie + type: string + photoUrls: + items: + type: string + type: array + uniqueItems: true + xml: + name: photoUrl + wrapped: true + tags: + items: + $ref: '#/components/schemas/Tag' + type: array + xml: + name: tag + wrapped: true + status: + description: pet status in the store + enum: + - available + - pending + - sold + type: string + required: + - name + - photoUrls + type: object + xml: + name: Pet + ApiResponse: + example: + code: 0 + type: type + message: message + properties: + code: + format: int32 + type: integer + type: + type: string + message: + type: string + type: object + $special[model.name]: + properties: + $special[property.name]: + format: int64 + type: integer + type: object + xml: + name: $special[model.name] + Return: + description: Model for testing reserved words + properties: + return: + format: int32 + type: integer + type: object + xml: + name: Return + Name: + description: Model for testing model name same as property name + properties: + name: + format: int32 + type: integer + snake_case: + format: int32 + readOnly: true + type: integer + property: + type: string + "123Number": + readOnly: true + type: integer + required: + - name + type: object + xml: + name: Name + "200_response": + description: Model for testing model name starting with number + properties: + name: + format: int32 + type: integer + class: + type: string + type: object + xml: + name: Name + ClassModel: + description: Model for testing model with "_class" property + properties: + _class: + type: string + type: object + Dog: + allOf: + - $ref: '#/components/schemas/Animal' + - $ref: '#/components/schemas/Dog_allOf' + Cat: + allOf: + - $ref: '#/components/schemas/Animal' + - $ref: '#/components/schemas/Cat_allOf' + BigCat: + allOf: + - $ref: '#/components/schemas/Cat' + - $ref: '#/components/schemas/BigCat_allOf' + Animal: + discriminator: + propertyName: className + properties: + className: + type: string + color: + default: red + type: string + required: + - className + type: object + AnimalFarm: + items: + $ref: '#/components/schemas/Animal' + type: array + format_test: + properties: + integer: + maximum: 1E+2 + minimum: 1E+1 + type: integer + int32: + format: int32 + maximum: 2E+2 + minimum: 2E+1 + type: integer + int64: + format: int64 + type: integer + number: + maximum: 543.2 + minimum: 32.1 + type: number + float: + format: float + maximum: 987.6 + minimum: 54.3 + type: number + double: + format: double + maximum: 123.4 + minimum: 67.8 + type: number + string: + pattern: /[a-z]/i + type: string + byte: + format: byte + pattern: ^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$ + type: string + binary: + format: binary + type: string + date: + format: date + type: string + dateTime: + format: date-time + type: string + uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + type: string + password: + format: password + maxLength: 64 + minLength: 10 + type: string + BigDecimal: + format: number + type: string + required: + - byte + - date + - number + - password + type: object + EnumClass: + default: -efg + enum: + - _abc + - -efg + - (xyz) + type: string + Enum_Test: + properties: + enum_string: + enum: + - UPPER + - lower + - "" + type: string + enum_string_required: + enum: + - UPPER + - lower + - "" + type: string + enum_integer: + enum: + - 1 + - -1 + format: int32 + type: integer + enum_number: + enum: + - 1.1 + - -1.2 + format: double + type: number + outerEnum: + $ref: '#/components/schemas/OuterEnum' + required: + - enum_string_required + type: object + AdditionalPropertiesClass: + properties: + map_string: + additionalProperties: + type: string + type: object + map_number: + additionalProperties: + type: number + type: object + map_integer: + additionalProperties: + type: integer + type: object + map_boolean: + additionalProperties: + type: boolean + type: object + map_array_integer: + additionalProperties: + items: + type: integer + type: array + type: object + map_array_anytype: + additionalProperties: + items: + properties: {} + type: object + type: array + type: object + map_map_string: + additionalProperties: + additionalProperties: + type: string + type: object + type: object + map_map_anytype: + additionalProperties: + additionalProperties: + properties: {} + type: object + type: object + type: object + anytype_1: + properties: {} + type: object + anytype_2: + type: object + anytype_3: + properties: {} + type: object + type: object + AdditionalPropertiesString: + additionalProperties: + type: string + properties: + name: + type: string + type: object + AdditionalPropertiesInteger: + additionalProperties: + type: integer + properties: + name: + type: string + type: object + AdditionalPropertiesNumber: + additionalProperties: + type: number + properties: + name: + type: string + type: object + AdditionalPropertiesBoolean: + additionalProperties: + type: boolean + properties: + name: + type: string + type: object + AdditionalPropertiesArray: + additionalProperties: + items: + properties: {} + type: object + type: array + properties: + name: + type: string + type: object + AdditionalPropertiesObject: + additionalProperties: + additionalProperties: + properties: {} + type: object + type: object + properties: + name: + type: string + type: object + AdditionalPropertiesAnyType: + additionalProperties: + properties: {} + type: object + properties: + name: + type: string + type: object + MixedPropertiesAndAdditionalPropertiesClass: + properties: + uuid: + format: uuid + type: string + dateTime: + format: date-time + type: string + map: + additionalProperties: + $ref: '#/components/schemas/Animal' + type: object + type: object + List: + properties: + "123-list": + type: string + type: object + Client: + example: + client: client + properties: + client: + type: string + type: object + ReadOnlyFirst: + properties: + bar: + readOnly: true + type: string + baz: + type: string + type: object + hasOnlyReadOnly: + properties: + bar: + readOnly: true + type: string + foo: + readOnly: true + type: string + type: object + Capitalization: + properties: + smallCamel: + type: string + CapitalCamel: + type: string + small_Snake: + type: string + Capital_Snake: + type: string + SCA_ETH_Flow_Points: + type: string + ATT_NAME: + description: | + Name of the pet + type: string + type: object + MapTest: + properties: + map_map_of_string: + additionalProperties: + additionalProperties: + type: string + type: object + type: object + map_of_enum_string: + additionalProperties: + enum: + - UPPER + - lower + type: string + type: object + direct_map: + additionalProperties: + type: boolean + type: object + indirect_map: + additionalProperties: + type: boolean + type: object + type: object + ArrayTest: + properties: + array_of_string: + items: + type: string + type: array + array_array_of_integer: + items: + items: + format: int64 + type: integer + type: array + type: array + array_array_of_model: + items: + items: + $ref: '#/components/schemas/ReadOnlyFirst' + type: array + type: array + type: object + NumberOnly: + properties: + JustNumber: + type: number + type: object + ArrayOfNumberOnly: + properties: + ArrayNumber: + items: + type: number + type: array + type: object + ArrayOfArrayOfNumberOnly: + properties: + ArrayArrayNumber: + items: + items: + type: number + type: array + type: array + type: object + EnumArrays: + properties: + just_symbol: + enum: + - '>=' + - $ + type: string + array_enum: + items: + enum: + - fish + - crab + type: string + type: array + type: object + OuterEnum: + enum: + - placed + - approved + - delivered + type: string + OuterComposite: + example: + my_string: my_string + my_number: 0.8008281904610115 + my_boolean: true + properties: + my_number: + type: number + my_string: + type: string + my_boolean: + type: boolean + x-codegen-body-parameter-name: boolean_post_body + type: object + OuterNumber: + type: number + OuterString: + type: string + OuterBoolean: + type: boolean + x-codegen-body-parameter-name: boolean_post_body + StringBooleanMap: + additionalProperties: + type: boolean + type: object + FileSchemaTestClass: + example: + file: + sourceURI: sourceURI + files: + - sourceURI: sourceURI + - sourceURI: sourceURI + properties: + file: + $ref: '#/components/schemas/File' + files: + items: + $ref: '#/components/schemas/File' + type: array + type: object + File: + description: Must be named `File` for test. + example: + sourceURI: sourceURI + properties: + sourceURI: + description: Test capitalization + type: string + type: object + TypeHolderDefault: + properties: + string_item: + default: what + type: string + number_item: + type: number + integer_item: + type: integer + bool_item: + default: true + type: boolean + array_item: + items: + type: integer + type: array + required: + - array_item + - bool_item + - integer_item + - number_item + - string_item + type: object + TypeHolderExample: + properties: + string_item: + example: what + type: string + number_item: + example: 1.234 + type: number + float_item: + example: 1.234 + format: float + type: number + integer_item: + example: -2 + type: integer + bool_item: + example: true + type: boolean + array_item: + example: + - 0 + - 1 + - 2 + - 3 + items: + type: integer + type: array + required: + - array_item + - bool_item + - float_item + - integer_item + - number_item + - string_item + type: object + XmlItem: + properties: + attribute_string: + example: string + type: string + xml: + attribute: true + attribute_number: + example: 1.234 + type: number + xml: + attribute: true + attribute_integer: + example: -2 + type: integer + xml: + attribute: true + attribute_boolean: + example: true + type: boolean + xml: + attribute: true + wrapped_array: + items: + type: integer + type: array + xml: + wrapped: true + name_string: + example: string + type: string + xml: + name: xml_name_string + name_number: + example: 1.234 + type: number + xml: + name: xml_name_number + name_integer: + example: -2 + type: integer + xml: + name: xml_name_integer + name_boolean: + example: true + type: boolean + xml: + name: xml_name_boolean + name_array: + items: + type: integer + xml: + name: xml_name_array_item + type: array + name_wrapped_array: + items: + type: integer + xml: + name: xml_name_wrapped_array_item + type: array + xml: + name: xml_name_wrapped_array + wrapped: true + prefix_string: + example: string + type: string + xml: + prefix: ab + prefix_number: + example: 1.234 + type: number + xml: + prefix: cd + prefix_integer: + example: -2 + type: integer + xml: + prefix: ef + prefix_boolean: + example: true + type: boolean + xml: + prefix: gh + prefix_array: + items: + type: integer + xml: + prefix: ij + type: array + prefix_wrapped_array: + items: + type: integer + xml: + prefix: mn + type: array + xml: + prefix: kl + wrapped: true + namespace_string: + example: string + type: string + xml: + namespace: http://a.com/schema + namespace_number: + example: 1.234 + type: number + xml: + namespace: http://b.com/schema + namespace_integer: + example: -2 + type: integer + xml: + namespace: http://c.com/schema + namespace_boolean: + example: true + type: boolean + xml: + namespace: http://d.com/schema + namespace_array: + items: + type: integer + xml: + namespace: http://e.com/schema + type: array + namespace_wrapped_array: + items: + type: integer + xml: + namespace: http://g.com/schema + type: array + xml: + namespace: http://f.com/schema + wrapped: true + prefix_ns_string: + example: string + type: string + xml: + namespace: http://a.com/schema + prefix: a + prefix_ns_number: + example: 1.234 + type: number + xml: + namespace: http://b.com/schema + prefix: b + prefix_ns_integer: + example: -2 + type: integer + xml: + namespace: http://c.com/schema + prefix: c + prefix_ns_boolean: + example: true + type: boolean + xml: + namespace: http://d.com/schema + prefix: d + prefix_ns_array: + items: + type: integer + xml: + namespace: http://e.com/schema + prefix: e + type: array + prefix_ns_wrapped_array: + items: + type: integer + xml: + namespace: http://g.com/schema + prefix: g + type: array + xml: + namespace: http://f.com/schema + prefix: f + wrapped: true + type: object + xml: + namespace: http://a.com/schema + prefix: pre + Dog_allOf: + properties: + breed: + type: string + type: object + Cat_allOf: + properties: + declawed: + type: boolean + type: object + BigCat_allOf: + properties: + kind: + enum: + - lions + - tigers + - leopards + - jaguars + 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 + api_key_query: + in: query + name: api_key_query + type: apiKey + http_basic_test: + scheme: basic + type: http +x-original-swagger-version: "2.0" diff --git a/samples/openapi3/server/petstore/springboot-useoptional/.openapi-generator-ignore b/samples/openapi3/server/petstore/springboot-useoptional/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/.openapi-generator-ignore @@ -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 diff --git a/samples/openapi3/server/petstore/springboot-useoptional/.openapi-generator/FILES b/samples/openapi3/server/petstore/springboot-useoptional/.openapi-generator/FILES new file mode 100644 index 000000000000..e4c32719b541 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/.openapi-generator/FILES @@ -0,0 +1,66 @@ +README.md +pom.xml +src/main/java/org/openapitools/OpenAPI2SpringBoot.java +src/main/java/org/openapitools/RFC3339DateFormat.java +src/main/java/org/openapitools/api/AnotherFakeApi.java +src/main/java/org/openapitools/api/AnotherFakeApiController.java +src/main/java/org/openapitools/api/ApiUtil.java +src/main/java/org/openapitools/api/FakeApi.java +src/main/java/org/openapitools/api/FakeApiController.java +src/main/java/org/openapitools/api/FakeClassnameTestApi.java +src/main/java/org/openapitools/api/FakeClassnameTestApiController.java +src/main/java/org/openapitools/api/PetApi.java +src/main/java/org/openapitools/api/PetApiController.java +src/main/java/org/openapitools/api/StoreApi.java +src/main/java/org/openapitools/api/StoreApiController.java +src/main/java/org/openapitools/api/UserApi.java +src/main/java/org/openapitools/api/UserApiController.java +src/main/java/org/openapitools/configuration/HomeController.java +src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java +src/main/java/org/openapitools/model/AdditionalPropertiesArray.java +src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java +src/main/java/org/openapitools/model/AdditionalPropertiesClass.java +src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java +src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java +src/main/java/org/openapitools/model/AdditionalPropertiesObject.java +src/main/java/org/openapitools/model/AdditionalPropertiesString.java +src/main/java/org/openapitools/model/Animal.java +src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java +src/main/java/org/openapitools/model/ArrayOfNumberOnly.java +src/main/java/org/openapitools/model/ArrayTest.java +src/main/java/org/openapitools/model/BigCat.java +src/main/java/org/openapitools/model/BigCatAllOf.java +src/main/java/org/openapitools/model/Capitalization.java +src/main/java/org/openapitools/model/Cat.java +src/main/java/org/openapitools/model/CatAllOf.java +src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ClassModel.java +src/main/java/org/openapitools/model/Client.java +src/main/java/org/openapitools/model/Dog.java +src/main/java/org/openapitools/model/DogAllOf.java +src/main/java/org/openapitools/model/EnumArrays.java +src/main/java/org/openapitools/model/EnumClass.java +src/main/java/org/openapitools/model/EnumTest.java +src/main/java/org/openapitools/model/FileSchemaTestClass.java +src/main/java/org/openapitools/model/FormatTest.java +src/main/java/org/openapitools/model/HasOnlyReadOnly.java +src/main/java/org/openapitools/model/MapTest.java +src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java +src/main/java/org/openapitools/model/Model200Response.java +src/main/java/org/openapitools/model/ModelApiResponse.java +src/main/java/org/openapitools/model/ModelReturn.java +src/main/java/org/openapitools/model/Name.java +src/main/java/org/openapitools/model/NumberOnly.java +src/main/java/org/openapitools/model/Order.java +src/main/java/org/openapitools/model/OuterComposite.java +src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/Pet.java +src/main/java/org/openapitools/model/ReadOnlyFirst.java +src/main/java/org/openapitools/model/SpecialModelName.java +src/main/java/org/openapitools/model/Tag.java +src/main/java/org/openapitools/model/TypeHolderDefault.java +src/main/java/org/openapitools/model/TypeHolderExample.java +src/main/java/org/openapitools/model/User.java +src/main/java/org/openapitools/model/XmlItem.java +src/main/resources/application.properties +src/main/resources/openapi.yaml diff --git a/samples/openapi3/server/petstore/springboot-useoptional/.openapi-generator/VERSION b/samples/openapi3/server/petstore/springboot-useoptional/.openapi-generator/VERSION new file mode 100644 index 000000000000..0984c4c1ad21 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/.openapi-generator/VERSION @@ -0,0 +1 @@ +5.4.0-SNAPSHOT \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-useoptional/README.md b/samples/openapi3/server/petstore/springboot-useoptional/README.md new file mode 100644 index 000000000000..befc961488ae --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/README.md @@ -0,0 +1,16 @@ +# 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. + +Start your server as a simple java application + +You can view the api documentation in swagger-ui by pointing to +http://localhost:80/ + +Change default port value in application.properties \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-useoptional/pom.xml b/samples/openapi3/server/petstore/springboot-useoptional/pom.xml new file mode 100644 index 000000000000..800e0576cb50 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/pom.xml @@ -0,0 +1,71 @@ + + 4.0.0 + org.openapitools.openapi3 + spring-boot-useoptional + jar + spring-boot-useoptional + 1.0.0 + + 1.8 + ${java.version} + ${java.version} + 2.1.11 + + + org.springframework.boot + spring-boot-starter-parent + 2.5.8 + + + src/main/java + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.data + spring-data-commons + + + io.swagger.core.v3 + swagger-annotations + ${swagger-core-version} + + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + + + org.openapitools + jackson-databind-nullable + 0.2.2 + + + + org.springframework.boot + spring-boot-starter-validation + + + com.fasterxml.jackson.core + jackson-databind + + + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..cb088f451935 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,63 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.Module; +import org.openapitools.jackson.nullable.JsonNullableModule; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.ExitCodeGenerator; +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.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenAPI2SpringBoot implements CommandLineRunner { + + @Override + public void run(String... arg0) throws Exception { + if (arg0.length > 0 && arg0[0].equals("exitcode")) { + throw new ExitException(); + } + } + + public static void main(String[] args) throws Exception { + new SpringApplication(OpenAPI2SpringBoot.class).run(args); + } + + static class ExitException extends RuntimeException implements ExitCodeGenerator { + private static final long serialVersionUID = 1L; + + @Override + public int getExitCode() { + return 10; + } + + } + + @Bean + public WebMvcConfigurer webConfigurer() { + return new WebMvcConfigurer() { + /*@Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") + .allowedOrigins("*") + .allowedMethods("*") + .allowedHeaders("Content-Type"); + }*/ + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("/swagger-ui/**").addResourceLocations("classpath:/META-INF/resources/webjars/swagger-ui/3.14.2/"); + } + }; + } + + @Bean + public Module jsonNullableModule() { + return new JsonNullableModule(); + } + +} diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/RFC3339DateFormat.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/RFC3339DateFormat.java new file mode 100644 index 000000000000..bcd3936d8b34 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/RFC3339DateFormat.java @@ -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; + } +} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/AnotherFakeApi.java new file mode 100644 index 000000000000..ccd404fbf320 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -0,0 +1,75 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.openapitools.api; + +import org.openapitools.model.Client; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "another-fake", description = "the another-fake API") +public interface AnotherFakeApi { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * PATCH /another-fake/dummy : To test special tags + * To test special tags and operation ID starting with number + * + * @param body client model (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "To test special tags", + tags = { "$another-fake?" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Client.class))) + } + ) + @RequestMapping( + method = RequestMethod.PATCH, + value = "/another-fake/dummy", + produces = { "application/json" }, + consumes = { "application/json" } + ) + default ResponseEntity call123testSpecialTags( + @Parameter(name = "body", description = "client model", required = true, schema = @Schema(description = "")) @Valid @RequestBody Client body + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"client\" : \"client\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/AnotherFakeApiController.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/AnotherFakeApiController.java new file mode 100644 index 000000000000..d8efcca7f8a4 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/AnotherFakeApiController.java @@ -0,0 +1,24 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.context.request.NativeWebRequest; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class AnotherFakeApiController implements AnotherFakeApi { + + private final NativeWebRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public AnotherFakeApiController(NativeWebRequest request) { + this.request = request; + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/ApiUtil.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/ApiUtil.java new file mode 100644 index 000000000000..1245b1dd0ccf --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/ApiUtil.java @@ -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); + } + } +} diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApi.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApi.java new file mode 100644 index 000000000000..720457848da9 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApi.java @@ -0,0 +1,551 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.openapitools.api; + +import java.math.BigDecimal; +import org.openapitools.model.Client; +import org.openapitools.model.FileSchemaTestClass; +import java.time.LocalDate; +import java.util.Map; +import org.openapitools.model.ModelApiResponse; +import java.time.OffsetDateTime; +import org.openapitools.model.OuterComposite; +import org.openapitools.model.User; +import org.openapitools.model.XmlItem; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "fake", description = "the fake API") +public interface FakeApi { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * POST /fake/create_xml_item : creates an XmlItem + * this route creates an XmlItem + * + * @param xmlItem XmlItem Body (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "creates an XmlItem", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/create_xml_item", + consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } + ) + default ResponseEntity createXmlItem( + @Parameter(name = "XmlItem", description = "XmlItem Body", required = true, schema = @Schema(description = "")) @Valid @RequestBody XmlItem xmlItem + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /fake/outer/boolean + * Test serialization of outer boolean types + * + * @param body Input boolean as post body (optional) + * @return Output boolean (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Output boolean", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Boolean.class))) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/outer/boolean", + produces = { "*/*" } + ) + default ResponseEntity fakeOuterBooleanSerialize( + @Parameter(name = "body", description = "Input boolean as post body", schema = @Schema(description = "")) @Valid @RequestBody(required = false) Boolean body + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /fake/outer/composite + * Test serialization of object with outer number type + * + * @param body Input composite as post body (optional) + * @return Output composite (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Output composite", content = @Content(mediaType = "application/json", schema = @Schema(implementation = OuterComposite.class))) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/outer/composite", + produces = { "*/*" } + ) + default ResponseEntity fakeOuterCompositeSerialize( + @Parameter(name = "body", description = "Input composite as post body", schema = @Schema(description = "")) @Valid @RequestBody(required = false) OuterComposite body + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) { + String exampleString = "{ \"my_string\" : \"my_string\", \"my_number\" : 0.8008281904610115, \"my_boolean\" : true }"; + ApiUtil.setExampleResponse(request, "*/*", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /fake/outer/number + * Test serialization of outer number types + * + * @param body Input number as post body (optional) + * @return Output number (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Output number", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BigDecimal.class))) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/outer/number", + produces = { "*/*" } + ) + default ResponseEntity fakeOuterNumberSerialize( + @Parameter(name = "body", description = "Input number as post body", schema = @Schema(description = "")) @Valid @RequestBody(required = false) BigDecimal body + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /fake/outer/string + * Test serialization of outer string types + * + * @param body Input string as post body (optional) + * @return Output string (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Output string", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/outer/string", + produces = { "*/*" } + ) + default ResponseEntity fakeOuterStringSerialize( + @Parameter(name = "body", description = "Input string as post body", schema = @Schema(description = "")) @Valid @RequestBody(required = false) String body + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * PUT /fake/body-with-file-schema + * For this test, the body for this request much reference a schema named `File`. + * + * @param body (required) + * @return Success (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success") + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/fake/body-with-file-schema", + consumes = { "application/json" } + ) + default ResponseEntity testBodyWithFileSchema( + @Parameter(name = "body", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestBody FileSchemaTestClass body + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * PUT /fake/body-with-query-params + * + * @param query (required) + * @param body (required) + * @return Success (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success") + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/fake/body-with-query-params", + consumes = { "application/json" } + ) + default ResponseEntity testBodyWithQueryParams( + @NotNull @Parameter(name = "query", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "query", required = true) String query, + @Parameter(name = "body", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestBody User body + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * PATCH /fake : To test \"client\" model + * To test \"client\" model + * + * @param body client model (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "To test \"client\" model", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Client.class))) + } + ) + @RequestMapping( + method = RequestMethod.PATCH, + value = "/fake", + produces = { "application/json" }, + consumes = { "application/json" } + ) + default ResponseEntity testClientModel( + @Parameter(name = "body", description = "client model", required = true, schema = @Schema(description = "")) @Valid @RequestBody Client body + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"client\" : \"client\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /fake : Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * + * @param number None (required) + * @param _double None (required) + * @param patternWithoutDelimiter None (required) + * @param _byte None (required) + * @param integer None (optional) + * @param int32 None (optional) + * @param int64 None (optional) + * @param _float None (optional) + * @param string None (optional) + * @param binary None (optional) + * @param date None (optional) + * @param dateTime None (optional) + * @param password None (optional) + * @param paramCallback None (optional) + * @return Invalid username supplied (status code 400) + * or User not found (status code 404) + */ + @Operation( + summary = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + }, + security = { + @SecurityRequirement(name = "http_basic_test") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) + default ResponseEntity testEndpointParameters( + @Parameter(name = "number", description = "None", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "number", required = true) BigDecimal number, + @Parameter(name = "double", description = "None", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "double", required = true) Double _double, + @Parameter(name = "pattern_without_delimiter", description = "None", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, + @Parameter(name = "byte", description = "None", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, + @Parameter(name = "integer", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "integer", required = false) Integer integer, + @Parameter(name = "int32", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "int32", required = false) Integer int32, + @Parameter(name = "int64", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "int64", required = false) Long int64, + @Parameter(name = "float", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "float", required = false) Float _float, + @Parameter(name = "string", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "string", required = false) String string, + @Parameter(name = "binary", description = "None", schema = @Schema(description = "")) @RequestPart(value = "binary", required = false) MultipartFile binary, + @Parameter(name = "date", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "date", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @Parameter(name = "dateTime", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "dateTime", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @Parameter(name = "password", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "password", required = false) String password, + @Parameter(name = "callback", description = "None", schema = @Schema(description = "")) @Valid @RequestPart(value = "callback", required = false) String paramCallback + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * GET /fake : To test enum parameters + * To test enum parameters + * + * @param enumHeaderStringArray Header parameter enum test (string array) (optional) + * @param enumHeaderString Header parameter enum test (string) (optional, default to -efg) + * @param enumQueryStringArray Query parameter enum test (string array) (optional) + * @param enumQueryString Query parameter enum test (string) (optional, default to -efg) + * @param enumQueryInteger Query parameter enum test (double) (optional) + * @param enumQueryDouble Query parameter enum test (double) (optional) + * @param enumFormStringArray Form parameter enum test (string array) (optional, default to $) + * @param enumFormString Form parameter enum test (string) (optional, default to -efg) + * @return Invalid request (status code 400) + * or Not found (status code 404) + */ + @Operation( + summary = "To test enum parameters", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid request"), + @ApiResponse(responseCode = "404", description = "Not found") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) + default ResponseEntity testEnumParameters( + @Parameter(name = "enum_header_string_array", description = "Header parameter enum test (string array)", schema = @Schema(description = "", allowableValues = { ">", "$" })) @RequestHeader(value = "enum_header_string_array", required = false) Optional> enumHeaderStringArray, + @Parameter(name = "enum_header_string", description = "Header parameter enum test (string)", schema = @Schema(description = "", allowableValues = { "_abc", "-efg", "(xyz)" }, defaultValue = "-efg")) @RequestHeader(value = "enum_header_string", required = false) Optional enumHeaderString, + @Parameter(name = "enum_query_string_array", description = "Query parameter enum test (string array)", schema = @Schema(description = "", allowableValues = { ">", "$" })) @Valid @RequestParam(value = "enum_query_string_array", required = false) Optional> enumQueryStringArray, + @Parameter(name = "enum_query_string", description = "Query parameter enum test (string)", schema = @Schema(description = "", allowableValues = { "_abc", "-efg", "(xyz)" }, defaultValue = "-efg")) @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") Optional enumQueryString, + @Parameter(name = "enum_query_integer", description = "Query parameter enum test (double)", schema = @Schema(description = "", allowableValues = { "1", "-2" })) @Valid @RequestParam(value = "enum_query_integer", required = false) Optional enumQueryInteger, + @Parameter(name = "enum_query_double", description = "Query parameter enum test (double)", schema = @Schema(description = "", allowableValues = { "1.1", "-1.2" })) @Valid @RequestParam(value = "enum_query_double", required = false) Optional enumQueryDouble, + @Parameter(name = "enum_form_string_array", description = "Form parameter enum test (string array)", schema = @Schema(description = "", allowableValues = { ">", "$" })) @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, + @Parameter(name = "enum_form_string", description = "Form parameter enum test (string)", schema = @Schema(description = "", allowableValues = { "_abc", "-efg", "(xyz)" }, defaultValue = "-efg")) @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * DELETE /fake : Fake endpoint to test group parameters (optional) + * Fake endpoint to test group parameters (optional) + * + * @param requiredStringGroup Required String in group parameters (required) + * @param requiredBooleanGroup Required Boolean in group parameters (required) + * @param requiredInt64Group Required Integer in group parameters (required) + * @param stringGroup String in group parameters (optional) + * @param booleanGroup Boolean in group parameters (optional) + * @param int64Group Integer in group parameters (optional) + * @return Someting wrong (status code 400) + */ + @Operation( + summary = "Fake endpoint to test group parameters (optional)", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "400", description = "Someting wrong") + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/fake" + ) + default ResponseEntity testGroupParameters( + @NotNull @Parameter(name = "required_string_group", description = "Required String in group parameters", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup, + @Parameter(name = "required_boolean_group", description = "Required Boolean in group parameters", required = true, schema = @Schema(description = "")) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup, + @NotNull @Parameter(name = "required_int64_group", description = "Required Integer in group parameters", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group, + @Parameter(name = "string_group", description = "String in group parameters", schema = @Schema(description = "")) @Valid @RequestParam(value = "string_group", required = false) Optional stringGroup, + @Parameter(name = "boolean_group", description = "Boolean in group parameters", schema = @Schema(description = "")) @RequestHeader(value = "boolean_group", required = false) Optional booleanGroup, + @Parameter(name = "int64_group", description = "Integer in group parameters", schema = @Schema(description = "")) @Valid @RequestParam(value = "int64_group", required = false) Optional int64Group + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /fake/inline-additionalProperties : test inline additionalProperties + * + * @param param request body (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "test inline additionalProperties", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/inline-additionalProperties", + consumes = { "application/json" } + ) + default ResponseEntity testInlineAdditionalProperties( + @Parameter(name = "param", description = "request body", required = true, schema = @Schema(description = "")) @Valid @RequestBody Map param + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * GET /fake/jsonFormData : test json serialization of form data + * + * @param param field1 (required) + * @param param2 field2 (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "test json serialization of form data", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/fake/jsonFormData", + consumes = { "application/x-www-form-urlencoded" } + ) + default ResponseEntity testJsonFormData( + @Parameter(name = "param", description = "field1", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "param", required = true) String param, + @Parameter(name = "param2", description = "field2", required = true, schema = @Schema(description = "")) @Valid @RequestPart(value = "param2", required = true) String param2 + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * PUT /fake/test-query-parameters + * To test the collection format in query parameters + * + * @param pipe (required) + * @param ioutil (required) + * @param http (required) + * @param url (required) + * @param context (required) + * @return Success (status code 200) + */ + @Operation( + summary = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "Success") + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/fake/test-query-parameters" + ) + default ResponseEntity testQueryParameterCollectionFormat( + @NotNull @Parameter(name = "pipe", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "pipe", required = true) List pipe, + @NotNull @Parameter(name = "ioutil", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "ioutil", required = true) List ioutil, + @NotNull @Parameter(name = "http", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "http", required = true) List http, + @NotNull @Parameter(name = "url", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "url", required = true) List url, + @NotNull @Parameter(name = "context", description = "", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "context", required = true) List context + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required) + * + * @param petId ID of pet to update (required) + * @param requiredFile file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @return successful operation (status code 200) + */ + @Operation( + summary = "uploads an image (required)", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ModelApiResponse.class))) + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/{petId}/uploadImageWithRequiredFile", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) + default ResponseEntity uploadFileWithRequiredFile( + @Parameter(name = "petId", description = "ID of pet to update", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "requiredFile", description = "file to upload", required = true, schema = @Schema(description = "")) @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, + @Parameter(name = "additionalMetadata", description = "Additional data to pass to server", schema = @Schema(description = "")) @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata + ) { + 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; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApiController.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApiController.java new file mode 100644 index 000000000000..c4b88419aabe --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApiController.java @@ -0,0 +1,24 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.context.request.NativeWebRequest; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class FakeApiController implements FakeApi { + + private final NativeWebRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public FakeApiController(NativeWebRequest request) { + this.request = request; + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeClassnameTestApi.java new file mode 100644 index 000000000000..62e378597251 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -0,0 +1,78 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.openapitools.api; + +import org.openapitools.model.Client; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "fake_classname_test", description = "the fake_classname_test API") +public interface FakeClassnameTestApi { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * PATCH /fake_classname_test : To test class name in snake case + * To test class name in snake case + * + * @param body client model (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "To test class name in snake case", + tags = { "fake_classname_tags 123#$%^" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Client.class))) + }, + security = { + @SecurityRequirement(name = "api_key_query") + } + ) + @RequestMapping( + method = RequestMethod.PATCH, + value = "/fake_classname_test", + produces = { "application/json" }, + consumes = { "application/json" } + ) + default ResponseEntity testClassname( + @Parameter(name = "body", description = "client model", required = true, schema = @Schema(description = "")) @Valid @RequestBody Client body + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"client\" : \"client\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java new file mode 100644 index 000000000000..85458b255da5 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java @@ -0,0 +1,24 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.context.request.NativeWebRequest; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class FakeClassnameTestApiController implements FakeClassnameTestApi { + + private final NativeWebRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public FakeClassnameTestApiController(NativeWebRequest request) { + this.request = request; + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/PetApi.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/PetApi.java new file mode 100644 index 000000000000..f28b85a83435 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/PetApi.java @@ -0,0 +1,355 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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 java.util.Set; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "pet", description = "the pet API") +public interface PetApi { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * POST /pet : Add a new pet to the store + * + * @param body Pet object that needs to be added to the store (required) + * @return successful operation (status code 200) + * or Invalid input (status code 405) + */ + @Operation( + summary = "Add a new pet to the store", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation"), + @ApiResponse(responseCode = "405", description = "Invalid input") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet", + consumes = { "application/json", "application/xml" } + ) + default ResponseEntity addPet( + @Parameter(name = "body", description = "Pet object that needs to be added to the store", required = true, schema = @Schema(description = "")) @Valid @RequestBody Pet body + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * DELETE /pet/{petId} : Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @return successful operation (status code 200) + * or Invalid pet value (status code 400) + */ + @Operation( + summary = "Deletes a pet", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation"), + @ApiResponse(responseCode = "400", description = "Invalid pet value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/pet/{petId}" + ) + default ResponseEntity deletePet( + @Parameter(name = "petId", description = "Pet id to delete", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "api_key", description = "", schema = @Schema(description = "")) @RequestHeader(value = "api_key", required = false) Optional apiKey + ) { + return new ResponseEntity<>(HttpStatus.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) + */ + @Operation( + summary = "Finds Pets by status", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid status value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/findByStatus", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity> findPetsByStatus( + @NotNull @Parameter(name = "status", description = "Status values that need to be considered for filter", required = true, schema = @Schema(description = "", allowableValues = { "available", "pending", "sold" })) @Valid @RequestParam(value = "status", required = true) List 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\" : \"default-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 = " 123456789 doggie aeiou aeiou "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.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 + */ + @Operation( + summary = "Finds Pets by tags", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid tag value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/findByTags", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity> findPetsByTags( + @NotNull @Parameter(name = "tags", description = "Tags to filter by", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "tags", required = true) Set 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\" : \"default-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 = " 123456789 doggie aeiou aeiou "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.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) + */ + @Operation( + summary = "Find pet by ID", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/{petId}", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity getPetById( + @Parameter(name = "petId", description = "ID of pet to return", required = true, schema = @Schema(description = "")) @PathVariable("petId") 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\" : \"default-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 = " 123456789 doggie aeiou aeiou "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * PUT /pet : Update an existing pet + * + * @param body 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) + */ + @Operation( + summary = "Update an existing pet", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation"), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found"), + @ApiResponse(responseCode = "405", description = "Validation exception") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/pet", + consumes = { "application/json", "application/xml" } + ) + default ResponseEntity updatePet( + @Parameter(name = "body", description = "Pet object that needs to be added to the store", required = true, schema = @Schema(description = "")) @Valid @RequestBody Pet body + ) { + return new ResponseEntity<>(HttpStatus.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) + */ + @Operation( + summary = "Updates a pet in the store with form data", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "405", description = "Invalid input") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet/{petId}", + consumes = { "application/x-www-form-urlencoded" } + ) + default ResponseEntity updatePetWithForm( + @Parameter(name = "petId", description = "ID of pet that needs to be updated", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "name", description = "Updated name of the pet", schema = @Schema(description = "")) @Valid @RequestPart(value = "name", required = false) String name, + @Parameter(name = "status", description = "Updated status of the pet", schema = @Schema(description = "")) @Valid @RequestPart(value = "status", required = false) String status + ) { + return new ResponseEntity<>(HttpStatus.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) + */ + @Operation( + summary = "uploads an image", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ModelApiResponse.class))) + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet/{petId}/uploadImage", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) + default ResponseEntity uploadFile( + @Parameter(name = "petId", description = "ID of pet to update", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "additionalMetadata", description = "Additional data to pass to server", schema = @Schema(description = "")) @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @Parameter(name = "file", description = "file to upload", schema = @Schema(description = "")) @RequestPart(value = "file", required = false) 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; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/PetApiController.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/PetApiController.java new file mode 100644 index 000000000000..e72c57e3cbec --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/PetApiController.java @@ -0,0 +1,24 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.context.request.NativeWebRequest; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class PetApiController implements PetApi { + + private final NativeWebRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public PetApiController(NativeWebRequest request) { + this.request = request; + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/StoreApi.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/StoreApi.java new file mode 100644 index 000000000000..de9b9d16f830 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/StoreApi.java @@ -0,0 +1,183 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "store", description = "the store API") +public interface StoreApi { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * DELETE /store/order/{order_id} : 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) + */ + @Operation( + summary = "Delete purchase order by ID", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/store/order/{order_id}" + ) + default ResponseEntity deleteOrder( + @Parameter(name = "order_id", description = "ID of the order that needs to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("order_id") String orderId + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * GET /store/inventory : Returns pet inventories by status + * Returns a map of status codes to quantities + * + * @return successful operation (status code 200) + */ + @Operation( + summary = "Returns pet inventories by status", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Map.class))) + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/store/inventory", + produces = { "application/json" } + ) + default ResponseEntity> getInventory( + + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * GET /store/order/{order_id} : Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated 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) + */ + @Operation( + summary = "Find purchase order by ID", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/store/order/{order_id}", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity getOrderById( + @Min(1L) @Max(5L) @Parameter(name = "order_id", description = "ID of pet that needs to be fetched", required = true, schema = @Schema(description = "")) @PathVariable("order_id") 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 = " 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /store/order : Place an order for a pet + * + * @param body order placed for purchasing the pet (required) + * @return successful operation (status code 200) + * or Invalid Order (status code 400) + */ + @Operation( + summary = "Place an order for a pet", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid Order") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/store/order", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity placeOrder( + @Parameter(name = "body", description = "order placed for purchasing the pet", required = true, schema = @Schema(description = "")) @Valid @RequestBody Order body + ) { + 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 = " 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/StoreApiController.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/StoreApiController.java new file mode 100644 index 000000000000..1293b5c8f6e4 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/StoreApiController.java @@ -0,0 +1,24 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.context.request.NativeWebRequest; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class StoreApiController implements StoreApi { + + private final NativeWebRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public StoreApiController(NativeWebRequest request) { + this.request = request; + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/UserApi.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/UserApi.java new file mode 100644 index 000000000000..5a85648b515c --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/UserApi.java @@ -0,0 +1,272 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "user", description = "the user API") +public interface UserApi { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * POST /user : Create user + * This can only be done by the logged in user. + * + * @param body Created user object (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "Create user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user" + ) + default ResponseEntity createUser( + @Parameter(name = "body", description = "Created user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody User body + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /user/createWithArray : Creates list of users with given input array + * + * @param body List of user object (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "Creates list of users with given input array", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user/createWithArray" + ) + default ResponseEntity createUsersWithArrayInput( + @Parameter(name = "body", description = "List of user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody List body + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /user/createWithList : Creates list of users with given input array + * + * @param body List of user object (required) + * @return successful operation (status code 200) + */ + @Operation( + summary = "Creates list of users with given input array", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user/createWithList" + ) + default ResponseEntity createUsersWithListInput( + @Parameter(name = "body", description = "List of user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody List body + ) { + return new ResponseEntity<>(HttpStatus.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) + */ + @Operation( + summary = "Delete user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/user/{username}" + ) + default ResponseEntity deleteUser( + @Parameter(name = "username", description = "The name that needs to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("username") String username + ) { + return new ResponseEntity<>(HttpStatus.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) + */ + @Operation( + summary = "Get user by user name", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = User.class))), + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/{username}", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity getUserByName( + @Parameter(name = "username", description = "The name that needs to be fetched. Use user1 for testing.", required = true, schema = @Schema(description = "")) @PathVariable("username") 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 = " 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123 "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.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) + */ + @Operation( + summary = "Logs user into the system", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "400", description = "Invalid username/password supplied") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/login", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity loginUser( + @NotNull @Parameter(name = "username", description = "The user name for login", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "username", required = true) String username, + @NotNull @Parameter(name = "password", description = "The password for login in clear text", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "password", required = true) String password + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * GET /user/logout : Logs out current logged in user session + * + * @return successful operation (status code 200) + */ + @Operation( + summary = "Logs out current logged in user session", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/logout" + ) + default ResponseEntity logoutUser( + + ) { + return new ResponseEntity<>(HttpStatus.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 body Updated user object (required) + * @return Invalid user supplied (status code 400) + * or User not found (status code 404) + */ + @Operation( + summary = "Updated user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid user supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/user/{username}" + ) + default ResponseEntity updateUser( + @Parameter(name = "username", description = "name that need to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("username") String username, + @Parameter(name = "body", description = "Updated user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody User body + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/UserApiController.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/UserApiController.java new file mode 100644 index 000000000000..3f6c4d9a2d6f --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/UserApiController.java @@ -0,0 +1,24 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.context.request.NativeWebRequest; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class UserApiController implements UserApi { + + private final NativeWebRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public UserApiController(NativeWebRequest request) { + this.request = request; + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/configuration/HomeController.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/configuration/HomeController.java new file mode 100644 index 000000000000..34bae16b8986 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/configuration/HomeController.java @@ -0,0 +1,53 @@ +package org.openapitools.configuration; + +import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.core.io.Resource; +import org.springframework.stereotype.Controller; +import org.springframework.util.StreamUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.Charset; + +/** + * Home redirection to OpenAPI api documentation + */ +@Controller +public class HomeController { + + private static YAMLMapper yamlMapper = new YAMLMapper(); + + @Value("classpath:/openapi.yaml") + private Resource openapi; + + @Bean + public String openapiContent() throws IOException { + try(InputStream is = openapi.getInputStream()) { + return StreamUtils.copyToString(is, Charset.defaultCharset()); + } + } + + @GetMapping(value = "/openapi.yaml", produces = "application/vnd.oai.openapi") + @ResponseBody + public String openapiYaml() throws IOException { + return openapiContent(); + } + + @GetMapping(value = "/openapi.json", produces = "application/json") + @ResponseBody + public Object openapiJson() throws IOException { + return yamlMapper.readValue(openapiContent(), Object.class); + } + + @RequestMapping("/") + public String index() { + return "redirect:swagger-ui/index.html?url=../openapi.json"; + } + + +} diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java new file mode 100644 index 000000000000..0c57ae7dd14c --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java @@ -0,0 +1,86 @@ +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 java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesAnyType + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesAnyType extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesAnyType name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesAnyType additionalPropertiesAnyType = (AdditionalPropertiesAnyType) o; + return Objects.equals(this.name, additionalPropertiesAnyType.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesAnyType {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesArray.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesArray.java new file mode 100644 index 000000000000..b5285ec2f29b --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesArray.java @@ -0,0 +1,87 @@ +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 java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesArray + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesArray extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesArray name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesArray additionalPropertiesArray = (AdditionalPropertiesArray) o; + return Objects.equals(this.name, additionalPropertiesArray.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesArray {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java new file mode 100644 index 000000000000..f8ca38c286d5 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java @@ -0,0 +1,86 @@ +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 java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesBoolean + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesBoolean extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesBoolean name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesBoolean additionalPropertiesBoolean = (AdditionalPropertiesBoolean) o; + return Objects.equals(this.name, additionalPropertiesBoolean.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesBoolean {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java new file mode 100644 index 000000000000..dfd28ccb9963 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java @@ -0,0 +1,414 @@ +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 java.math.BigDecimal; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesClass + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesClass { + @JsonProperty("map_string") + @Valid + private Map mapString = null; + + @JsonProperty("map_number") + @Valid + private Map mapNumber = null; + + @JsonProperty("map_integer") + @Valid + private Map mapInteger = null; + + @JsonProperty("map_boolean") + @Valid + private Map mapBoolean = null; + + @JsonProperty("map_array_integer") + @Valid + private Map> mapArrayInteger = null; + + @JsonProperty("map_array_anytype") + @Valid + private Map> mapArrayAnytype = null; + + @JsonProperty("map_map_string") + @Valid + private Map> mapMapString = null; + + @JsonProperty("map_map_anytype") + @Valid + private Map> mapMapAnytype = null; + + @JsonProperty("anytype_1") + private Object anytype1; + + @JsonProperty("anytype_2") + private Object anytype2; + + @JsonProperty("anytype_3") + private Object anytype3; + + public AdditionalPropertiesClass mapString(Map mapString) { + this.mapString = mapString; + return this; + } + + public AdditionalPropertiesClass putMapStringItem(String key, String mapStringItem) { + if (this.mapString == null) { + this.mapString = new HashMap<>(); + } + this.mapString.put(key, mapStringItem); + return this; + } + + /** + * Get mapString + * @return mapString + */ + @Schema(name = "mapString", defaultValue = "") + + + public Map getMapString() { + return mapString; + } + + public void setMapString(Map mapString) { + this.mapString = mapString; + } + + public AdditionalPropertiesClass mapNumber(Map mapNumber) { + this.mapNumber = mapNumber; + return this; + } + + public AdditionalPropertiesClass putMapNumberItem(String key, BigDecimal mapNumberItem) { + if (this.mapNumber == null) { + this.mapNumber = new HashMap<>(); + } + this.mapNumber.put(key, mapNumberItem); + return this; + } + + /** + * Get mapNumber + * @return mapNumber + */ + @Schema(name = "mapNumber", defaultValue = "") + + @Valid + + public Map getMapNumber() { + return mapNumber; + } + + public void setMapNumber(Map mapNumber) { + this.mapNumber = mapNumber; + } + + public AdditionalPropertiesClass mapInteger(Map mapInteger) { + this.mapInteger = mapInteger; + return this; + } + + public AdditionalPropertiesClass putMapIntegerItem(String key, Integer mapIntegerItem) { + if (this.mapInteger == null) { + this.mapInteger = new HashMap<>(); + } + this.mapInteger.put(key, mapIntegerItem); + return this; + } + + /** + * Get mapInteger + * @return mapInteger + */ + @Schema(name = "mapInteger", defaultValue = "") + + + public Map getMapInteger() { + return mapInteger; + } + + public void setMapInteger(Map mapInteger) { + this.mapInteger = mapInteger; + } + + public AdditionalPropertiesClass mapBoolean(Map mapBoolean) { + this.mapBoolean = mapBoolean; + return this; + } + + public AdditionalPropertiesClass putMapBooleanItem(String key, Boolean mapBooleanItem) { + if (this.mapBoolean == null) { + this.mapBoolean = new HashMap<>(); + } + this.mapBoolean.put(key, mapBooleanItem); + return this; + } + + /** + * Get mapBoolean + * @return mapBoolean + */ + @Schema(name = "mapBoolean", defaultValue = "") + + + public Map getMapBoolean() { + return mapBoolean; + } + + public void setMapBoolean(Map mapBoolean) { + this.mapBoolean = mapBoolean; + } + + public AdditionalPropertiesClass mapArrayInteger(Map> mapArrayInteger) { + this.mapArrayInteger = mapArrayInteger; + return this; + } + + public AdditionalPropertiesClass putMapArrayIntegerItem(String key, List mapArrayIntegerItem) { + if (this.mapArrayInteger == null) { + this.mapArrayInteger = new HashMap<>(); + } + this.mapArrayInteger.put(key, mapArrayIntegerItem); + return this; + } + + /** + * Get mapArrayInteger + * @return mapArrayInteger + */ + @Schema(name = "mapArrayInteger", defaultValue = "") + + @Valid + + public Map> getMapArrayInteger() { + return mapArrayInteger; + } + + public void setMapArrayInteger(Map> mapArrayInteger) { + this.mapArrayInteger = mapArrayInteger; + } + + public AdditionalPropertiesClass mapArrayAnytype(Map> mapArrayAnytype) { + this.mapArrayAnytype = mapArrayAnytype; + return this; + } + + public AdditionalPropertiesClass putMapArrayAnytypeItem(String key, List mapArrayAnytypeItem) { + if (this.mapArrayAnytype == null) { + this.mapArrayAnytype = new HashMap<>(); + } + this.mapArrayAnytype.put(key, mapArrayAnytypeItem); + return this; + } + + /** + * Get mapArrayAnytype + * @return mapArrayAnytype + */ + @Schema(name = "mapArrayAnytype", defaultValue = "") + + @Valid + + public Map> getMapArrayAnytype() { + return mapArrayAnytype; + } + + public void setMapArrayAnytype(Map> mapArrayAnytype) { + this.mapArrayAnytype = mapArrayAnytype; + } + + public AdditionalPropertiesClass mapMapString(Map> mapMapString) { + this.mapMapString = mapMapString; + return this; + } + + public AdditionalPropertiesClass putMapMapStringItem(String key, Map mapMapStringItem) { + if (this.mapMapString == null) { + this.mapMapString = new HashMap<>(); + } + this.mapMapString.put(key, mapMapStringItem); + return this; + } + + /** + * Get mapMapString + * @return mapMapString + */ + @Schema(name = "mapMapString", defaultValue = "") + + @Valid + + public Map> getMapMapString() { + return mapMapString; + } + + public void setMapMapString(Map> mapMapString) { + this.mapMapString = mapMapString; + } + + public AdditionalPropertiesClass mapMapAnytype(Map> mapMapAnytype) { + this.mapMapAnytype = mapMapAnytype; + return this; + } + + public AdditionalPropertiesClass putMapMapAnytypeItem(String key, Map mapMapAnytypeItem) { + if (this.mapMapAnytype == null) { + this.mapMapAnytype = new HashMap<>(); + } + this.mapMapAnytype.put(key, mapMapAnytypeItem); + return this; + } + + /** + * Get mapMapAnytype + * @return mapMapAnytype + */ + @Schema(name = "mapMapAnytype", defaultValue = "") + + @Valid + + public Map> getMapMapAnytype() { + return mapMapAnytype; + } + + public void setMapMapAnytype(Map> mapMapAnytype) { + this.mapMapAnytype = mapMapAnytype; + } + + public AdditionalPropertiesClass anytype1(Object anytype1) { + this.anytype1 = anytype1; + return this; + } + + /** + * Get anytype1 + * @return anytype1 + */ + @Schema(name = "anytype1", defaultValue = "") + + + public Object getAnytype1() { + return anytype1; + } + + public void setAnytype1(Object anytype1) { + this.anytype1 = anytype1; + } + + public AdditionalPropertiesClass anytype2(Object anytype2) { + this.anytype2 = anytype2; + return this; + } + + /** + * Get anytype2 + * @return anytype2 + */ + @Schema(name = "anytype2", defaultValue = "") + + + public Object getAnytype2() { + return anytype2; + } + + public void setAnytype2(Object anytype2) { + this.anytype2 = anytype2; + } + + public AdditionalPropertiesClass anytype3(Object anytype3) { + this.anytype3 = anytype3; + return this; + } + + /** + * Get anytype3 + * @return anytype3 + */ + @Schema(name = "anytype3", defaultValue = "") + + + public Object getAnytype3() { + return anytype3; + } + + public void setAnytype3(Object anytype3) { + this.anytype3 = anytype3; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AdditionalPropertiesClass additionalPropertiesClass = (AdditionalPropertiesClass) o; + return Objects.equals(this.mapString, additionalPropertiesClass.mapString) && + Objects.equals(this.mapNumber, additionalPropertiesClass.mapNumber) && + Objects.equals(this.mapInteger, additionalPropertiesClass.mapInteger) && + Objects.equals(this.mapBoolean, additionalPropertiesClass.mapBoolean) && + Objects.equals(this.mapArrayInteger, additionalPropertiesClass.mapArrayInteger) && + Objects.equals(this.mapArrayAnytype, additionalPropertiesClass.mapArrayAnytype) && + Objects.equals(this.mapMapString, additionalPropertiesClass.mapMapString) && + Objects.equals(this.mapMapAnytype, additionalPropertiesClass.mapMapAnytype) && + Objects.equals(this.anytype1, additionalPropertiesClass.anytype1) && + Objects.equals(this.anytype2, additionalPropertiesClass.anytype2) && + Objects.equals(this.anytype3, additionalPropertiesClass.anytype3); + } + + @Override + public int hashCode() { + return Objects.hash(mapString, mapNumber, mapInteger, mapBoolean, mapArrayInteger, mapArrayAnytype, mapMapString, mapMapAnytype, anytype1, anytype2, anytype3); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesClass {\n"); + + sb.append(" mapString: ").append(toIndentedString(mapString)).append("\n"); + sb.append(" mapNumber: ").append(toIndentedString(mapNumber)).append("\n"); + sb.append(" mapInteger: ").append(toIndentedString(mapInteger)).append("\n"); + sb.append(" mapBoolean: ").append(toIndentedString(mapBoolean)).append("\n"); + sb.append(" mapArrayInteger: ").append(toIndentedString(mapArrayInteger)).append("\n"); + sb.append(" mapArrayAnytype: ").append(toIndentedString(mapArrayAnytype)).append("\n"); + sb.append(" mapMapString: ").append(toIndentedString(mapMapString)).append("\n"); + sb.append(" mapMapAnytype: ").append(toIndentedString(mapMapAnytype)).append("\n"); + sb.append(" anytype1: ").append(toIndentedString(anytype1)).append("\n"); + sb.append(" anytype2: ").append(toIndentedString(anytype2)).append("\n"); + sb.append(" anytype3: ").append(toIndentedString(anytype3)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java new file mode 100644 index 000000000000..5fea577ab44b --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java @@ -0,0 +1,86 @@ +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 java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesInteger + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesInteger extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesInteger name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesInteger additionalPropertiesInteger = (AdditionalPropertiesInteger) o; + return Objects.equals(this.name, additionalPropertiesInteger.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesInteger {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java new file mode 100644 index 000000000000..e6eee612a24f --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java @@ -0,0 +1,87 @@ +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 java.math.BigDecimal; +import java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesNumber + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesNumber extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesNumber name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesNumber additionalPropertiesNumber = (AdditionalPropertiesNumber) o; + return Objects.equals(this.name, additionalPropertiesNumber.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesNumber {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesObject.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesObject.java new file mode 100644 index 000000000000..d7116bd7572c --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesObject.java @@ -0,0 +1,86 @@ +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 java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesObject + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesObject extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesObject name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesObject additionalPropertiesObject = (AdditionalPropertiesObject) o; + return Objects.equals(this.name, additionalPropertiesObject.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesObject {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesString.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesString.java new file mode 100644 index 000000000000..d2022be266fb --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesString.java @@ -0,0 +1,86 @@ +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 java.util.HashMap; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * AdditionalPropertiesString + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class AdditionalPropertiesString extends HashMap { + @JsonProperty("name") + private String name; + + public AdditionalPropertiesString name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + 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; + } + AdditionalPropertiesString additionalPropertiesString = (AdditionalPropertiesString) o; + return Objects.equals(this.name, additionalPropertiesString.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesString {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Animal.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Animal.java new file mode 100644 index 000000000000..6f096d5069ed --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Animal.java @@ -0,0 +1,118 @@ +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.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Animal + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "className", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = BigCat.class, name = "BigCat"), + @JsonSubTypes.Type(value = Cat.class, name = "Cat"), + @JsonSubTypes.Type(value = Dog.class, name = "Dog"), +}) + +public class Animal { + @JsonProperty("className") + private String className; + + @JsonProperty("color") + private String color = "red"; + + public Animal className(String className) { + this.className = className; + return this; + } + + /** + * Get className + * @return className + */ + @Schema(name = "className", required = true, defaultValue = "") + @NotNull + + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public Animal color(String color) { + this.color = color; + return this; + } + + /** + * Get color + * @return color + */ + @Schema(name = "color", defaultValue = "") + + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Animal animal = (Animal) o; + return Objects.equals(this.className, animal.className) && + Objects.equals(this.color, animal.color); + } + + @Override + public int hashCode() { + return Objects.hash(className, color); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Animal {\n"); + + sb.append(" className: ").append(toIndentedString(className)).append("\n"); + sb.append(" color: ").append(toIndentedString(color)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java new file mode 100644 index 000000000000..ebe36ad761a9 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java @@ -0,0 +1,96 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ArrayOfArrayOfNumberOnly + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ArrayOfArrayOfNumberOnly { + @JsonProperty("ArrayArrayNumber") + @Valid + private List> arrayArrayNumber = null; + + public ArrayOfArrayOfNumberOnly arrayArrayNumber(List> arrayArrayNumber) { + this.arrayArrayNumber = arrayArrayNumber; + return this; + } + + public ArrayOfArrayOfNumberOnly addArrayArrayNumberItem(List arrayArrayNumberItem) { + if (this.arrayArrayNumber == null) { + this.arrayArrayNumber = new ArrayList<>(); + } + this.arrayArrayNumber.add(arrayArrayNumberItem); + return this; + } + + /** + * Get arrayArrayNumber + * @return arrayArrayNumber + */ + @Schema(name = "arrayArrayNumber", defaultValue = "") + + @Valid + + public List> getArrayArrayNumber() { + return arrayArrayNumber; + } + + public void setArrayArrayNumber(List> arrayArrayNumber) { + this.arrayArrayNumber = arrayArrayNumber; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly = (ArrayOfArrayOfNumberOnly) o; + return Objects.equals(this.arrayArrayNumber, arrayOfArrayOfNumberOnly.arrayArrayNumber); + } + + @Override + public int hashCode() { + return Objects.hash(arrayArrayNumber); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayOfArrayOfNumberOnly {\n"); + + sb.append(" arrayArrayNumber: ").append(toIndentedString(arrayArrayNumber)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ArrayOfNumberOnly.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ArrayOfNumberOnly.java new file mode 100644 index 000000000000..8158dd44ab88 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ArrayOfNumberOnly.java @@ -0,0 +1,96 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ArrayOfNumberOnly + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ArrayOfNumberOnly { + @JsonProperty("ArrayNumber") + @Valid + private List arrayNumber = null; + + public ArrayOfNumberOnly arrayNumber(List arrayNumber) { + this.arrayNumber = arrayNumber; + return this; + } + + public ArrayOfNumberOnly addArrayNumberItem(BigDecimal arrayNumberItem) { + if (this.arrayNumber == null) { + this.arrayNumber = new ArrayList<>(); + } + this.arrayNumber.add(arrayNumberItem); + return this; + } + + /** + * Get arrayNumber + * @return arrayNumber + */ + @Schema(name = "arrayNumber", defaultValue = "") + + @Valid + + public List getArrayNumber() { + return arrayNumber; + } + + public void setArrayNumber(List arrayNumber) { + this.arrayNumber = arrayNumber; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayOfNumberOnly arrayOfNumberOnly = (ArrayOfNumberOnly) o; + return Objects.equals(this.arrayNumber, arrayOfNumberOnly.arrayNumber); + } + + @Override + public int hashCode() { + return Objects.hash(arrayNumber); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayOfNumberOnly {\n"); + + sb.append(" arrayNumber: ").append(toIndentedString(arrayNumber)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ArrayTest.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ArrayTest.java new file mode 100644 index 000000000000..420010561bcd --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ArrayTest.java @@ -0,0 +1,165 @@ +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 java.util.ArrayList; +import java.util.List; +import org.openapitools.model.ReadOnlyFirst; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ArrayTest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ArrayTest { + @JsonProperty("array_of_string") + @Valid + private List arrayOfString = null; + + @JsonProperty("array_array_of_integer") + @Valid + private List> arrayArrayOfInteger = null; + + @JsonProperty("array_array_of_model") + @Valid + private List> arrayArrayOfModel = null; + + public ArrayTest arrayOfString(List arrayOfString) { + this.arrayOfString = arrayOfString; + return this; + } + + public ArrayTest addArrayOfStringItem(String arrayOfStringItem) { + if (this.arrayOfString == null) { + this.arrayOfString = new ArrayList<>(); + } + this.arrayOfString.add(arrayOfStringItem); + return this; + } + + /** + * Get arrayOfString + * @return arrayOfString + */ + @Schema(name = "arrayOfString", defaultValue = "") + + + public List getArrayOfString() { + return arrayOfString; + } + + public void setArrayOfString(List arrayOfString) { + this.arrayOfString = arrayOfString; + } + + public ArrayTest arrayArrayOfInteger(List> arrayArrayOfInteger) { + this.arrayArrayOfInteger = arrayArrayOfInteger; + return this; + } + + public ArrayTest addArrayArrayOfIntegerItem(List arrayArrayOfIntegerItem) { + if (this.arrayArrayOfInteger == null) { + this.arrayArrayOfInteger = new ArrayList<>(); + } + this.arrayArrayOfInteger.add(arrayArrayOfIntegerItem); + return this; + } + + /** + * Get arrayArrayOfInteger + * @return arrayArrayOfInteger + */ + @Schema(name = "arrayArrayOfInteger", defaultValue = "") + + @Valid + + public List> getArrayArrayOfInteger() { + return arrayArrayOfInteger; + } + + public void setArrayArrayOfInteger(List> arrayArrayOfInteger) { + this.arrayArrayOfInteger = arrayArrayOfInteger; + } + + public ArrayTest arrayArrayOfModel(List> arrayArrayOfModel) { + this.arrayArrayOfModel = arrayArrayOfModel; + return this; + } + + public ArrayTest addArrayArrayOfModelItem(List arrayArrayOfModelItem) { + if (this.arrayArrayOfModel == null) { + this.arrayArrayOfModel = new ArrayList<>(); + } + this.arrayArrayOfModel.add(arrayArrayOfModelItem); + return this; + } + + /** + * Get arrayArrayOfModel + * @return arrayArrayOfModel + */ + @Schema(name = "arrayArrayOfModel", defaultValue = "") + + @Valid + + public List> getArrayArrayOfModel() { + return arrayArrayOfModel; + } + + public void setArrayArrayOfModel(List> arrayArrayOfModel) { + this.arrayArrayOfModel = arrayArrayOfModel; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayTest arrayTest = (ArrayTest) o; + return Objects.equals(this.arrayOfString, arrayTest.arrayOfString) && + Objects.equals(this.arrayArrayOfInteger, arrayTest.arrayArrayOfInteger) && + Objects.equals(this.arrayArrayOfModel, arrayTest.arrayArrayOfModel); + } + + @Override + public int hashCode() { + return Objects.hash(arrayOfString, arrayArrayOfInteger, arrayArrayOfModel); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayTest {\n"); + + sb.append(" arrayOfString: ").append(toIndentedString(arrayOfString)).append("\n"); + sb.append(" arrayArrayOfInteger: ").append(toIndentedString(arrayArrayOfInteger)).append("\n"); + sb.append(" arrayArrayOfModel: ").append(toIndentedString(arrayArrayOfModel)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/BigCat.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/BigCat.java new file mode 100644 index 000000000000..7f4a080ad8d2 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/BigCat.java @@ -0,0 +1,126 @@ +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 org.openapitools.model.BigCatAllOf; +import org.openapitools.model.Cat; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * BigCat + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class BigCat extends Cat { + /** + * Gets or Sets kind + */ + public enum KindEnum { + LIONS("lions"), + + TIGERS("tigers"), + + LEOPARDS("leopards"), + + JAGUARS("jaguars"); + + private String value; + + KindEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static KindEnum fromValue(String value) { + for (KindEnum b : KindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("kind") + private KindEnum kind; + + public BigCat kind(KindEnum kind) { + this.kind = kind; + return this; + } + + /** + * Get kind + * @return kind + */ + @Schema(name = "kind", defaultValue = "") + + + public KindEnum getKind() { + return kind; + } + + public void setKind(KindEnum kind) { + this.kind = kind; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BigCat bigCat = (BigCat) o; + return Objects.equals(this.kind, bigCat.kind) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(kind, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BigCat {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/BigCatAllOf.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/BigCatAllOf.java new file mode 100644 index 000000000000..d0a47ab5127c --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/BigCatAllOf.java @@ -0,0 +1,123 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * BigCatAllOf + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class BigCatAllOf { + /** + * Gets or Sets kind + */ + public enum KindEnum { + LIONS("lions"), + + TIGERS("tigers"), + + LEOPARDS("leopards"), + + JAGUARS("jaguars"); + + private String value; + + KindEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static KindEnum fromValue(String value) { + for (KindEnum b : KindEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("kind") + private KindEnum kind; + + public BigCatAllOf kind(KindEnum kind) { + this.kind = kind; + return this; + } + + /** + * Get kind + * @return kind + */ + @Schema(name = "kind", defaultValue = "") + + + public KindEnum getKind() { + return kind; + } + + public void setKind(KindEnum kind) { + this.kind = kind; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BigCatAllOf bigCatAllOf = (BigCatAllOf) o; + return Objects.equals(this.kind, bigCatAllOf.kind); + } + + @Override + public int hashCode() { + return Objects.hash(kind); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BigCatAllOf {\n"); + + sb.append(" kind: ").append(toIndentedString(kind)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Capitalization.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Capitalization.java new file mode 100644 index 000000000000..92d9a7245f16 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Capitalization.java @@ -0,0 +1,208 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Capitalization + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Capitalization { + @JsonProperty("smallCamel") + private String smallCamel; + + @JsonProperty("CapitalCamel") + private String capitalCamel; + + @JsonProperty("small_Snake") + private String smallSnake; + + @JsonProperty("Capital_Snake") + private String capitalSnake; + + @JsonProperty("SCA_ETH_Flow_Points") + private String scAETHFlowPoints; + + @JsonProperty("ATT_NAME") + private String ATT_NAME; + + public Capitalization smallCamel(String smallCamel) { + this.smallCamel = smallCamel; + return this; + } + + /** + * Get smallCamel + * @return smallCamel + */ + @Schema(name = "smallCamel", defaultValue = "") + + + public String getSmallCamel() { + return smallCamel; + } + + public void setSmallCamel(String smallCamel) { + this.smallCamel = smallCamel; + } + + public Capitalization capitalCamel(String capitalCamel) { + this.capitalCamel = capitalCamel; + return this; + } + + /** + * Get capitalCamel + * @return capitalCamel + */ + @Schema(name = "capitalCamel", defaultValue = "") + + + public String getCapitalCamel() { + return capitalCamel; + } + + public void setCapitalCamel(String capitalCamel) { + this.capitalCamel = capitalCamel; + } + + public Capitalization smallSnake(String smallSnake) { + this.smallSnake = smallSnake; + return this; + } + + /** + * Get smallSnake + * @return smallSnake + */ + @Schema(name = "smallSnake", defaultValue = "") + + + public String getSmallSnake() { + return smallSnake; + } + + public void setSmallSnake(String smallSnake) { + this.smallSnake = smallSnake; + } + + public Capitalization capitalSnake(String capitalSnake) { + this.capitalSnake = capitalSnake; + return this; + } + + /** + * Get capitalSnake + * @return capitalSnake + */ + @Schema(name = "capitalSnake", defaultValue = "") + + + public String getCapitalSnake() { + return capitalSnake; + } + + public void setCapitalSnake(String capitalSnake) { + this.capitalSnake = capitalSnake; + } + + public Capitalization scAETHFlowPoints(String scAETHFlowPoints) { + this.scAETHFlowPoints = scAETHFlowPoints; + return this; + } + + /** + * Get scAETHFlowPoints + * @return scAETHFlowPoints + */ + @Schema(name = "scAETHFlowPoints", defaultValue = "") + + + public String getScAETHFlowPoints() { + return scAETHFlowPoints; + } + + public void setScAETHFlowPoints(String scAETHFlowPoints) { + this.scAETHFlowPoints = scAETHFlowPoints; + } + + public Capitalization ATT_NAME(String ATT_NAME) { + this.ATT_NAME = ATT_NAME; + return this; + } + + /** + * Name of the pet + * @return ATT_NAME + */ + @Schema(name = "ATT_NAME", defaultValue = "Name of the pet ") + + + public String getATTNAME() { + return ATT_NAME; + } + + public void setATTNAME(String ATT_NAME) { + this.ATT_NAME = ATT_NAME; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Capitalization capitalization = (Capitalization) o; + return Objects.equals(this.smallCamel, capitalization.smallCamel) && + Objects.equals(this.capitalCamel, capitalization.capitalCamel) && + Objects.equals(this.smallSnake, capitalization.smallSnake) && + Objects.equals(this.capitalSnake, capitalization.capitalSnake) && + Objects.equals(this.scAETHFlowPoints, capitalization.scAETHFlowPoints) && + Objects.equals(this.ATT_NAME, capitalization.ATT_NAME); + } + + @Override + public int hashCode() { + return Objects.hash(smallCamel, capitalCamel, smallSnake, capitalSnake, scAETHFlowPoints, ATT_NAME); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Capitalization {\n"); + + sb.append(" smallCamel: ").append(toIndentedString(smallCamel)).append("\n"); + sb.append(" capitalCamel: ").append(toIndentedString(capitalCamel)).append("\n"); + sb.append(" smallSnake: ").append(toIndentedString(smallSnake)).append("\n"); + sb.append(" capitalSnake: ").append(toIndentedString(capitalSnake)).append("\n"); + sb.append(" scAETHFlowPoints: ").append(toIndentedString(scAETHFlowPoints)).append("\n"); + sb.append(" ATT_NAME: ").append(toIndentedString(ATT_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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Cat.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Cat.java new file mode 100644 index 000000000000..2e496fb4accd --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Cat.java @@ -0,0 +1,86 @@ +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 org.openapitools.model.Animal; +import org.openapitools.model.CatAllOf; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Cat + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Cat extends Animal { + @JsonProperty("declawed") + private Boolean declawed; + + public Cat declawed(Boolean declawed) { + this.declawed = declawed; + return this; + } + + /** + * Get declawed + * @return declawed + */ + @Schema(name = "declawed", defaultValue = "") + + + public Boolean getDeclawed() { + return declawed; + } + + public void setDeclawed(Boolean declawed) { + this.declawed = declawed; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Cat cat = (Cat) o; + return Objects.equals(this.declawed, cat.declawed) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(declawed, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Cat {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" declawed: ").append(toIndentedString(declawed)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/CatAllOf.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/CatAllOf.java new file mode 100644 index 000000000000..b732a62b1bc3 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/CatAllOf.java @@ -0,0 +1,83 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * CatAllOf + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class CatAllOf { + @JsonProperty("declawed") + private Boolean declawed; + + public CatAllOf declawed(Boolean declawed) { + this.declawed = declawed; + return this; + } + + /** + * Get declawed + * @return declawed + */ + @Schema(name = "declawed", defaultValue = "") + + + public Boolean getDeclawed() { + return declawed; + } + + public void setDeclawed(Boolean declawed) { + this.declawed = declawed; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CatAllOf catAllOf = (CatAllOf) o; + return Objects.equals(this.declawed, catAllOf.declawed); + } + + @Override + public int hashCode() { + return Objects.hash(declawed); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CatAllOf {\n"); + + sb.append(" declawed: ").append(toIndentedString(declawed)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Category.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Category.java new file mode 100644 index 000000000000..038fc8df3afd --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Category.java @@ -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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Category + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Category { + @JsonProperty("id") + private Long id; + + @JsonProperty("name") + private String name = "default-name"; + + public Category id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "name", required = true, defaultValue = "") + @NotNull + + + 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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ClassModel.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ClassModel.java new file mode 100644 index 000000000000..fa2a736f4fb5 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ClassModel.java @@ -0,0 +1,84 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Model for testing model with \"_class\" property + */ +@Schema(name = "ClassModel",description = "Model for testing model with \"_class\" property") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ClassModel { + @JsonProperty("_class") + private String propertyClass; + + public ClassModel propertyClass(String propertyClass) { + this.propertyClass = propertyClass; + return this; + } + + /** + * Get propertyClass + * @return propertyClass + */ + @Schema(name = "propertyClass", defaultValue = "") + + + public String getPropertyClass() { + return propertyClass; + } + + public void setPropertyClass(String propertyClass) { + this.propertyClass = propertyClass; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClassModel classModel = (ClassModel) o; + return Objects.equals(this.propertyClass, classModel.propertyClass); + } + + @Override + public int hashCode() { + return Objects.hash(propertyClass); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ClassModel {\n"); + + sb.append(" propertyClass: ").append(toIndentedString(propertyClass)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Client.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Client.java new file mode 100644 index 000000000000..e11bd4ff1b13 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Client.java @@ -0,0 +1,83 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Client + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Client { + @JsonProperty("client") + private String client; + + public Client client(String client) { + this.client = client; + return this; + } + + /** + * Get client + * @return client + */ + @Schema(name = "client", defaultValue = "") + + + public String getClient() { + return client; + } + + public void setClient(String client) { + this.client = client; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Client client = (Client) o; + return Objects.equals(this.client, client.client); + } + + @Override + public int hashCode() { + return Objects.hash(client); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Client {\n"); + + sb.append(" client: ").append(toIndentedString(client)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Dog.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Dog.java new file mode 100644 index 000000000000..ed5dc71a4ba2 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Dog.java @@ -0,0 +1,86 @@ +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 org.openapitools.model.Animal; +import org.openapitools.model.DogAllOf; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Dog + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Dog extends Animal { + @JsonProperty("breed") + private String breed; + + public Dog breed(String breed) { + this.breed = breed; + return this; + } + + /** + * Get breed + * @return breed + */ + @Schema(name = "breed", defaultValue = "") + + + public String getBreed() { + return breed; + } + + public void setBreed(String breed) { + this.breed = breed; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Dog dog = (Dog) o; + return Objects.equals(this.breed, dog.breed) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(breed, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Dog {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" breed: ").append(toIndentedString(breed)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/DogAllOf.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/DogAllOf.java new file mode 100644 index 000000000000..2c99bc376c34 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/DogAllOf.java @@ -0,0 +1,83 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * DogAllOf + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class DogAllOf { + @JsonProperty("breed") + private String breed; + + public DogAllOf breed(String breed) { + this.breed = breed; + return this; + } + + /** + * Get breed + * @return breed + */ + @Schema(name = "breed", defaultValue = "") + + + public String getBreed() { + return breed; + } + + public void setBreed(String breed) { + this.breed = breed; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DogAllOf dogAllOf = (DogAllOf) o; + return Objects.equals(this.breed, dogAllOf.breed); + } + + @Override + public int hashCode() { + return Objects.hash(breed); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DogAllOf {\n"); + + sb.append(" breed: ").append(toIndentedString(breed)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/EnumArrays.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/EnumArrays.java new file mode 100644 index 000000000000..e1b2df0716a2 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/EnumArrays.java @@ -0,0 +1,190 @@ +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 java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * EnumArrays + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class EnumArrays { + /** + * Gets or Sets justSymbol + */ + public enum JustSymbolEnum { + GREATER_THAN_OR_EQUAL_TO(">="), + + DOLLAR("$"); + + private String value; + + JustSymbolEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static JustSymbolEnum fromValue(String value) { + for (JustSymbolEnum b : JustSymbolEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("just_symbol") + private JustSymbolEnum justSymbol; + + /** + * Gets or Sets arrayEnum + */ + public enum ArrayEnumEnum { + FISH("fish"), + + CRAB("crab"); + + private String value; + + ArrayEnumEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static ArrayEnumEnum fromValue(String value) { + for (ArrayEnumEnum b : ArrayEnumEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("array_enum") + @Valid + private List arrayEnum = null; + + public EnumArrays justSymbol(JustSymbolEnum justSymbol) { + this.justSymbol = justSymbol; + return this; + } + + /** + * Get justSymbol + * @return justSymbol + */ + @Schema(name = "justSymbol", defaultValue = "") + + + public JustSymbolEnum getJustSymbol() { + return justSymbol; + } + + public void setJustSymbol(JustSymbolEnum justSymbol) { + this.justSymbol = justSymbol; + } + + public EnumArrays arrayEnum(List arrayEnum) { + this.arrayEnum = arrayEnum; + return this; + } + + public EnumArrays addArrayEnumItem(ArrayEnumEnum arrayEnumItem) { + if (this.arrayEnum == null) { + this.arrayEnum = new ArrayList<>(); + } + this.arrayEnum.add(arrayEnumItem); + return this; + } + + /** + * Get arrayEnum + * @return arrayEnum + */ + @Schema(name = "arrayEnum", defaultValue = "") + + + public List getArrayEnum() { + return arrayEnum; + } + + public void setArrayEnum(List arrayEnum) { + this.arrayEnum = arrayEnum; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EnumArrays enumArrays = (EnumArrays) o; + return Objects.equals(this.justSymbol, enumArrays.justSymbol) && + Objects.equals(this.arrayEnum, enumArrays.arrayEnum); + } + + @Override + public int hashCode() { + return Objects.hash(justSymbol, arrayEnum); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EnumArrays {\n"); + + sb.append(" justSymbol: ").append(toIndentedString(justSymbol)).append("\n"); + sb.append(" arrayEnum: ").append(toIndentedString(arrayEnum)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/EnumClass.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/EnumClass.java new file mode 100644 index 000000000000..e3d30c1ad453 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/EnumClass.java @@ -0,0 +1,55 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Gets or Sets EnumClass + */ +public enum EnumClass { + + _ABC("_abc"), + + _EFG("-efg"), + + _XYZ_("(xyz)"); + + private String value; + + EnumClass(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumClass fromValue(String value) { + for (EnumClass b : EnumClass.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/EnumTest.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/EnumTest.java new file mode 100644 index 000000000000..938af53e2b81 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/EnumTest.java @@ -0,0 +1,331 @@ +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 org.openapitools.model.OuterEnum; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * EnumTest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class EnumTest { + /** + * Gets or Sets enumString + */ + public enum EnumStringEnum { + UPPER("UPPER"), + + LOWER("lower"), + + EMPTY(""); + + private String value; + + EnumStringEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumStringEnum fromValue(String value) { + for (EnumStringEnum b : EnumStringEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("enum_string") + private EnumStringEnum enumString; + + /** + * Gets or Sets enumStringRequired + */ + public enum EnumStringRequiredEnum { + UPPER("UPPER"), + + LOWER("lower"), + + EMPTY(""); + + private String value; + + EnumStringRequiredEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumStringRequiredEnum fromValue(String value) { + for (EnumStringRequiredEnum b : EnumStringRequiredEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("enum_string_required") + private EnumStringRequiredEnum enumStringRequired; + + /** + * Gets or Sets enumInteger + */ + public enum EnumIntegerEnum { + NUMBER_1(1), + + NUMBER_MINUS_1(-1); + + private Integer value; + + EnumIntegerEnum(Integer value) { + this.value = value; + } + + @JsonValue + public Integer getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumIntegerEnum fromValue(Integer value) { + for (EnumIntegerEnum b : EnumIntegerEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("enum_integer") + private EnumIntegerEnum enumInteger; + + /** + * Gets or Sets enumNumber + */ + public enum EnumNumberEnum { + NUMBER_1_DOT_1(1.1), + + NUMBER_MINUS_1_DOT_2(-1.2); + + private Double value; + + EnumNumberEnum(Double value) { + this.value = value; + } + + @JsonValue + public Double getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumNumberEnum fromValue(Double value) { + for (EnumNumberEnum b : EnumNumberEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("enum_number") + private EnumNumberEnum enumNumber; + + @JsonProperty("outerEnum") + private OuterEnum outerEnum; + + public EnumTest enumString(EnumStringEnum enumString) { + this.enumString = enumString; + return this; + } + + /** + * Get enumString + * @return enumString + */ + @Schema(name = "enumString", defaultValue = "") + + + public EnumStringEnum getEnumString() { + return enumString; + } + + public void setEnumString(EnumStringEnum enumString) { + this.enumString = enumString; + } + + public EnumTest enumStringRequired(EnumStringRequiredEnum enumStringRequired) { + this.enumStringRequired = enumStringRequired; + return this; + } + + /** + * Get enumStringRequired + * @return enumStringRequired + */ + @Schema(name = "enumStringRequired", required = true, defaultValue = "") + @NotNull + + + public EnumStringRequiredEnum getEnumStringRequired() { + return enumStringRequired; + } + + public void setEnumStringRequired(EnumStringRequiredEnum enumStringRequired) { + this.enumStringRequired = enumStringRequired; + } + + public EnumTest enumInteger(EnumIntegerEnum enumInteger) { + this.enumInteger = enumInteger; + return this; + } + + /** + * Get enumInteger + * @return enumInteger + */ + @Schema(name = "enumInteger", defaultValue = "") + + + public EnumIntegerEnum getEnumInteger() { + return enumInteger; + } + + public void setEnumInteger(EnumIntegerEnum enumInteger) { + this.enumInteger = enumInteger; + } + + public EnumTest enumNumber(EnumNumberEnum enumNumber) { + this.enumNumber = enumNumber; + return this; + } + + /** + * Get enumNumber + * @return enumNumber + */ + @Schema(name = "enumNumber", defaultValue = "") + + + public EnumNumberEnum getEnumNumber() { + return enumNumber; + } + + public void setEnumNumber(EnumNumberEnum enumNumber) { + this.enumNumber = enumNumber; + } + + public EnumTest outerEnum(OuterEnum outerEnum) { + this.outerEnum = outerEnum; + return this; + } + + /** + * Get outerEnum + * @return outerEnum + */ + @Schema(name = "outerEnum", defaultValue = "") + + @Valid + + public OuterEnum getOuterEnum() { + return outerEnum; + } + + public void setOuterEnum(OuterEnum outerEnum) { + this.outerEnum = outerEnum; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EnumTest enumTest = (EnumTest) o; + return Objects.equals(this.enumString, enumTest.enumString) && + Objects.equals(this.enumStringRequired, enumTest.enumStringRequired) && + Objects.equals(this.enumInteger, enumTest.enumInteger) && + Objects.equals(this.enumNumber, enumTest.enumNumber) && + Objects.equals(this.outerEnum, enumTest.outerEnum); + } + + @Override + public int hashCode() { + return Objects.hash(enumString, enumStringRequired, enumInteger, enumNumber, outerEnum); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EnumTest {\n"); + + sb.append(" enumString: ").append(toIndentedString(enumString)).append("\n"); + sb.append(" enumStringRequired: ").append(toIndentedString(enumStringRequired)).append("\n"); + sb.append(" enumInteger: ").append(toIndentedString(enumInteger)).append("\n"); + sb.append(" enumNumber: ").append(toIndentedString(enumNumber)).append("\n"); + sb.append(" outerEnum: ").append(toIndentedString(outerEnum)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/FileSchemaTestClass.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/FileSchemaTestClass.java new file mode 100644 index 000000000000..0d1e9ca8495c --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/FileSchemaTestClass.java @@ -0,0 +1,121 @@ +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 java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * FileSchemaTestClass + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class FileSchemaTestClass { + @JsonProperty("file") + private java.io.File file; + + @JsonProperty("files") + @Valid + private List files = null; + + public FileSchemaTestClass file(java.io.File file) { + this.file = file; + return this; + } + + /** + * Get file + * @return file + */ + @Schema(name = "file", defaultValue = "") + + @Valid + + public java.io.File getFile() { + return file; + } + + public void setFile(java.io.File file) { + this.file = file; + } + + public FileSchemaTestClass files(List files) { + this.files = files; + return this; + } + + public FileSchemaTestClass addFilesItem(java.io.File filesItem) { + if (this.files == null) { + this.files = new ArrayList<>(); + } + this.files.add(filesItem); + return this; + } + + /** + * Get files + * @return files + */ + @Schema(name = "files", defaultValue = "") + + @Valid + + public List getFiles() { + return files; + } + + public void setFiles(List files) { + this.files = files; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FileSchemaTestClass fileSchemaTestClass = (FileSchemaTestClass) o; + return Objects.equals(this.file, fileSchemaTestClass.file) && + Objects.equals(this.files, fileSchemaTestClass.files); + } + + @Override + public int hashCode() { + return Objects.hash(file, files); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FileSchemaTestClass {\n"); + + sb.append(" file: ").append(toIndentedString(file)).append("\n"); + sb.append(" files: ").append(toIndentedString(files)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/FormatTest.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/FormatTest.java new file mode 100644 index 000000000000..6546370cd329 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/FormatTest.java @@ -0,0 +1,435 @@ +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 java.math.BigDecimal; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.UUID; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * FormatTest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class FormatTest { + @JsonProperty("integer") + private Integer integer; + + @JsonProperty("int32") + private Integer int32; + + @JsonProperty("int64") + private Long int64; + + @JsonProperty("number") + private BigDecimal number; + + @JsonProperty("float") + private Float _float; + + @JsonProperty("double") + private Double _double; + + @JsonProperty("string") + private String string; + + @JsonProperty("byte") + private byte[] _byte; + + @JsonProperty("binary") + private org.springframework.core.io.Resource binary; + + @JsonProperty("date") + @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) + private LocalDate date; + + @JsonProperty("dateTime") + @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) + private OffsetDateTime dateTime; + + @JsonProperty("uuid") + private UUID uuid; + + @JsonProperty("password") + private String password; + + @JsonProperty("BigDecimal") + private BigDecimal bigDecimal; + + public FormatTest integer(Integer integer) { + this.integer = integer; + return this; + } + + /** + * Get integer + * minimum: 10 + * maximum: 100 + * @return integer + */ + @Schema(name = "integer", defaultValue = "") + +@Min(10) @Max(100) + public Integer getInteger() { + return integer; + } + + public void setInteger(Integer integer) { + this.integer = integer; + } + + public FormatTest int32(Integer int32) { + this.int32 = int32; + return this; + } + + /** + * Get int32 + * minimum: 20 + * maximum: 200 + * @return int32 + */ + @Schema(name = "int32", defaultValue = "") + +@Min(20) @Max(200) + public Integer getInt32() { + return int32; + } + + public void setInt32(Integer int32) { + this.int32 = int32; + } + + public FormatTest int64(Long int64) { + this.int64 = int64; + return this; + } + + /** + * Get int64 + * @return int64 + */ + @Schema(name = "int64", defaultValue = "") + + + public Long getInt64() { + return int64; + } + + public void setInt64(Long int64) { + this.int64 = int64; + } + + public FormatTest number(BigDecimal number) { + this.number = number; + return this; + } + + /** + * Get number + * minimum: 32.1 + * maximum: 543.2 + * @return number + */ + @Schema(name = "number", required = true, defaultValue = "") + @NotNull + + @Valid +@DecimalMin("32.1") @DecimalMax("543.2") + public BigDecimal getNumber() { + return number; + } + + public void setNumber(BigDecimal number) { + this.number = number; + } + + public FormatTest _float(Float _float) { + this._float = _float; + return this; + } + + /** + * Get _float + * minimum: 54.3 + * maximum: 987.6 + * @return _float + */ + @Schema(name = "_float", defaultValue = "") + +@DecimalMin("54.3") @DecimalMax("987.6") + public Float getFloat() { + return _float; + } + + public void setFloat(Float _float) { + this._float = _float; + } + + public FormatTest _double(Double _double) { + this._double = _double; + return this; + } + + /** + * Get _double + * minimum: 67.8 + * maximum: 123.4 + * @return _double + */ + @Schema(name = "_double", defaultValue = "") + +@DecimalMin("67.8") @DecimalMax("123.4") + public Double getDouble() { + return _double; + } + + public void setDouble(Double _double) { + this._double = _double; + } + + public FormatTest string(String string) { + this.string = string; + return this; + } + + /** + * Get string + * @return string + */ + @Schema(name = "string", defaultValue = "") + +@Pattern(regexp = "/[a-z]/i") + public String getString() { + return string; + } + + public void setString(String string) { + this.string = string; + } + + public FormatTest _byte(byte[] _byte) { + this._byte = _byte; + return this; + } + + /** + * Get _byte + * @return _byte + */ + @Schema(name = "_byte", required = true, defaultValue = "") + @NotNull + + + public byte[] getByte() { + return _byte; + } + + public void setByte(byte[] _byte) { + this._byte = _byte; + } + + public FormatTest binary(org.springframework.core.io.Resource binary) { + this.binary = binary; + return this; + } + + /** + * Get binary + * @return binary + */ + @Schema(name = "binary", defaultValue = "") + + @Valid + + public org.springframework.core.io.Resource getBinary() { + return binary; + } + + public void setBinary(org.springframework.core.io.Resource binary) { + this.binary = binary; + } + + public FormatTest date(LocalDate date) { + this.date = date; + return this; + } + + /** + * Get date + * @return date + */ + @Schema(name = "date", required = true, defaultValue = "") + @NotNull + + @Valid + + public LocalDate getDate() { + return date; + } + + public void setDate(LocalDate date) { + this.date = date; + } + + public FormatTest dateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + return this; + } + + /** + * Get dateTime + * @return dateTime + */ + @Schema(name = "dateTime", defaultValue = "") + + @Valid + + public OffsetDateTime getDateTime() { + return dateTime; + } + + public void setDateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + } + + public FormatTest uuid(UUID uuid) { + this.uuid = uuid; + return this; + } + + /** + * Get uuid + * @return uuid + */ + @Schema(name = "uuid", example = "72f98069-206d-4f12-9f12-3d1e525a8e84", defaultValue = "") + + @Valid + + public UUID getUuid() { + return uuid; + } + + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + public FormatTest password(String password) { + this.password = password; + return this; + } + + /** + * Get password + * @return password + */ + @Schema(name = "password", required = true, defaultValue = "") + @NotNull + +@Size(min = 10, max = 64) + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public FormatTest bigDecimal(BigDecimal bigDecimal) { + this.bigDecimal = bigDecimal; + return this; + } + + /** + * Get bigDecimal + * @return bigDecimal + */ + @Schema(name = "bigDecimal", defaultValue = "") + + @Valid + + public BigDecimal getBigDecimal() { + return bigDecimal; + } + + public void setBigDecimal(BigDecimal bigDecimal) { + this.bigDecimal = bigDecimal; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FormatTest formatTest = (FormatTest) o; + return Objects.equals(this.integer, formatTest.integer) && + Objects.equals(this.int32, formatTest.int32) && + Objects.equals(this.int64, formatTest.int64) && + Objects.equals(this.number, formatTest.number) && + Objects.equals(this._float, formatTest._float) && + Objects.equals(this._double, formatTest._double) && + Objects.equals(this.string, formatTest.string) && + Arrays.equals(this._byte, formatTest._byte) && + Objects.equals(this.binary, formatTest.binary) && + Objects.equals(this.date, formatTest.date) && + Objects.equals(this.dateTime, formatTest.dateTime) && + Objects.equals(this.uuid, formatTest.uuid) && + Objects.equals(this.password, formatTest.password) && + Objects.equals(this.bigDecimal, formatTest.bigDecimal); + } + + @Override + public int hashCode() { + return Objects.hash(integer, int32, int64, number, _float, _double, string, Arrays.hashCode(_byte), binary, date, dateTime, uuid, password, bigDecimal); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FormatTest {\n"); + + sb.append(" integer: ").append(toIndentedString(integer)).append("\n"); + sb.append(" int32: ").append(toIndentedString(int32)).append("\n"); + sb.append(" int64: ").append(toIndentedString(int64)).append("\n"); + sb.append(" number: ").append(toIndentedString(number)).append("\n"); + sb.append(" _float: ").append(toIndentedString(_float)).append("\n"); + sb.append(" _double: ").append(toIndentedString(_double)).append("\n"); + sb.append(" string: ").append(toIndentedString(string)).append("\n"); + sb.append(" _byte: ").append(toIndentedString(_byte)).append("\n"); + sb.append(" binary: ").append(toIndentedString(binary)).append("\n"); + sb.append(" date: ").append(toIndentedString(date)).append("\n"); + sb.append(" dateTime: ").append(toIndentedString(dateTime)).append("\n"); + sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" bigDecimal: ").append(toIndentedString(bigDecimal)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/HasOnlyReadOnly.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/HasOnlyReadOnly.java new file mode 100644 index 000000000000..dfb615a529fc --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/HasOnlyReadOnly.java @@ -0,0 +1,108 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * HasOnlyReadOnly + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class HasOnlyReadOnly { + @JsonProperty("bar") + private String bar; + + @JsonProperty("foo") + private String foo; + + public HasOnlyReadOnly bar(String bar) { + this.bar = bar; + return this; + } + + /** + * Get bar + * @return bar + */ + @Schema(name = "bar", readOnly = true, defaultValue = "") + + + public String getBar() { + return bar; + } + + public void setBar(String bar) { + this.bar = bar; + } + + public HasOnlyReadOnly foo(String foo) { + this.foo = foo; + return this; + } + + /** + * Get foo + * @return foo + */ + @Schema(name = "foo", readOnly = true, defaultValue = "") + + + public String getFoo() { + return foo; + } + + public void setFoo(String foo) { + this.foo = foo; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HasOnlyReadOnly hasOnlyReadOnly = (HasOnlyReadOnly) o; + return Objects.equals(this.bar, hasOnlyReadOnly.bar) && + Objects.equals(this.foo, hasOnlyReadOnly.foo); + } + + @Override + public int hashCode() { + return Objects.hash(bar, foo); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class HasOnlyReadOnly {\n"); + + sb.append(" bar: ").append(toIndentedString(bar)).append("\n"); + sb.append(" foo: ").append(toIndentedString(foo)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/MapTest.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/MapTest.java new file mode 100644 index 000000000000..3ff73062758f --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/MapTest.java @@ -0,0 +1,234 @@ +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 java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * MapTest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class MapTest { + @JsonProperty("map_map_of_string") + @Valid + private Map> mapMapOfString = null; + + /** + * Gets or Sets inner + */ + public enum InnerEnum { + UPPER("UPPER"), + + LOWER("lower"); + + private String value; + + InnerEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static InnerEnum fromValue(String value) { + for (InnerEnum b : InnerEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("map_of_enum_string") + @Valid + private Map mapOfEnumString = null; + + @JsonProperty("direct_map") + @Valid + private Map directMap = null; + + @JsonProperty("indirect_map") + @Valid + private Map indirectMap = null; + + public MapTest mapMapOfString(Map> mapMapOfString) { + this.mapMapOfString = mapMapOfString; + return this; + } + + public MapTest putMapMapOfStringItem(String key, Map mapMapOfStringItem) { + if (this.mapMapOfString == null) { + this.mapMapOfString = new HashMap<>(); + } + this.mapMapOfString.put(key, mapMapOfStringItem); + return this; + } + + /** + * Get mapMapOfString + * @return mapMapOfString + */ + @Schema(name = "mapMapOfString", defaultValue = "") + + @Valid + + public Map> getMapMapOfString() { + return mapMapOfString; + } + + public void setMapMapOfString(Map> mapMapOfString) { + this.mapMapOfString = mapMapOfString; + } + + public MapTest mapOfEnumString(Map mapOfEnumString) { + this.mapOfEnumString = mapOfEnumString; + return this; + } + + public MapTest putMapOfEnumStringItem(String key, InnerEnum mapOfEnumStringItem) { + if (this.mapOfEnumString == null) { + this.mapOfEnumString = new HashMap<>(); + } + this.mapOfEnumString.put(key, mapOfEnumStringItem); + return this; + } + + /** + * Get mapOfEnumString + * @return mapOfEnumString + */ + @Schema(name = "mapOfEnumString", defaultValue = "") + + + public Map getMapOfEnumString() { + return mapOfEnumString; + } + + public void setMapOfEnumString(Map mapOfEnumString) { + this.mapOfEnumString = mapOfEnumString; + } + + public MapTest directMap(Map directMap) { + this.directMap = directMap; + return this; + } + + public MapTest putDirectMapItem(String key, Boolean directMapItem) { + if (this.directMap == null) { + this.directMap = new HashMap<>(); + } + this.directMap.put(key, directMapItem); + return this; + } + + /** + * Get directMap + * @return directMap + */ + @Schema(name = "directMap", defaultValue = "") + + + public Map getDirectMap() { + return directMap; + } + + public void setDirectMap(Map directMap) { + this.directMap = directMap; + } + + public MapTest indirectMap(Map indirectMap) { + this.indirectMap = indirectMap; + return this; + } + + public MapTest putIndirectMapItem(String key, Boolean indirectMapItem) { + if (this.indirectMap == null) { + this.indirectMap = new HashMap<>(); + } + this.indirectMap.put(key, indirectMapItem); + return this; + } + + /** + * Get indirectMap + * @return indirectMap + */ + @Schema(name = "indirectMap", defaultValue = "") + + + public Map getIndirectMap() { + return indirectMap; + } + + public void setIndirectMap(Map indirectMap) { + this.indirectMap = indirectMap; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MapTest mapTest = (MapTest) o; + return Objects.equals(this.mapMapOfString, mapTest.mapMapOfString) && + Objects.equals(this.mapOfEnumString, mapTest.mapOfEnumString) && + Objects.equals(this.directMap, mapTest.directMap) && + Objects.equals(this.indirectMap, mapTest.indirectMap); + } + + @Override + public int hashCode() { + return Objects.hash(mapMapOfString, mapOfEnumString, directMap, indirectMap); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MapTest {\n"); + + sb.append(" mapMapOfString: ").append(toIndentedString(mapMapOfString)).append("\n"); + sb.append(" mapOfEnumString: ").append(toIndentedString(mapOfEnumString)).append("\n"); + sb.append(" directMap: ").append(toIndentedString(directMap)).append("\n"); + sb.append(" indirectMap: ").append(toIndentedString(indirectMap)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java new file mode 100644 index 000000000000..03a7be43cc4a --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java @@ -0,0 +1,152 @@ +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 java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import org.openapitools.model.Animal; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * MixedPropertiesAndAdditionalPropertiesClass + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class MixedPropertiesAndAdditionalPropertiesClass { + @JsonProperty("uuid") + private UUID uuid; + + @JsonProperty("dateTime") + @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) + private OffsetDateTime dateTime; + + @JsonProperty("map") + @Valid + private Map map = null; + + public MixedPropertiesAndAdditionalPropertiesClass uuid(UUID uuid) { + this.uuid = uuid; + return this; + } + + /** + * Get uuid + * @return uuid + */ + @Schema(name = "uuid", defaultValue = "") + + @Valid + + public UUID getUuid() { + return uuid; + } + + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + public MixedPropertiesAndAdditionalPropertiesClass dateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + return this; + } + + /** + * Get dateTime + * @return dateTime + */ + @Schema(name = "dateTime", defaultValue = "") + + @Valid + + public OffsetDateTime getDateTime() { + return dateTime; + } + + public void setDateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + } + + public MixedPropertiesAndAdditionalPropertiesClass map(Map map) { + this.map = map; + return this; + } + + public MixedPropertiesAndAdditionalPropertiesClass putMapItem(String key, Animal mapItem) { + if (this.map == null) { + this.map = new HashMap<>(); + } + this.map.put(key, mapItem); + return this; + } + + /** + * Get map + * @return map + */ + @Schema(name = "map", defaultValue = "") + + @Valid + + public Map getMap() { + return map; + } + + public void setMap(Map map) { + this.map = map; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass = (MixedPropertiesAndAdditionalPropertiesClass) o; + return Objects.equals(this.uuid, mixedPropertiesAndAdditionalPropertiesClass.uuid) && + Objects.equals(this.dateTime, mixedPropertiesAndAdditionalPropertiesClass.dateTime) && + Objects.equals(this.map, mixedPropertiesAndAdditionalPropertiesClass.map); + } + + @Override + public int hashCode() { + return Objects.hash(uuid, dateTime, map); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MixedPropertiesAndAdditionalPropertiesClass {\n"); + + sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); + sb.append(" dateTime: ").append(toIndentedString(dateTime)).append("\n"); + sb.append(" map: ").append(toIndentedString(map)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Model200Response.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Model200Response.java new file mode 100644 index 000000000000..77bf91649b08 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Model200Response.java @@ -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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Model for testing model name starting with number + */ +@Schema(name = "200_response",description = "Model for testing model name starting with number") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Model200Response { + @JsonProperty("name") + private Integer name; + + @JsonProperty("class") + private String propertyClass; + + public Model200Response name(Integer name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", defaultValue = "") + + + public Integer getName() { + return name; + } + + public void setName(Integer name) { + this.name = name; + } + + public Model200Response propertyClass(String propertyClass) { + this.propertyClass = propertyClass; + return this; + } + + /** + * Get propertyClass + * @return propertyClass + */ + @Schema(name = "propertyClass", defaultValue = "") + + + public String getPropertyClass() { + return propertyClass; + } + + public void setPropertyClass(String propertyClass) { + this.propertyClass = propertyClass; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Model200Response _200response = (Model200Response) o; + return Objects.equals(this.name, _200response.name) && + Objects.equals(this.propertyClass, _200response.propertyClass); + } + + @Override + public int hashCode() { + return Objects.hash(name, propertyClass); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Model200Response {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" propertyClass: ").append(toIndentedString(propertyClass)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ModelApiResponse.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ModelApiResponse.java new file mode 100644 index 000000000000..2443600df226 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ModelApiResponse.java @@ -0,0 +1,133 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ModelApiResponse + */ +@javax.annotation.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 + */ + @Schema(name = "code", defaultValue = "") + + + 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 + */ + @Schema(name = "type", defaultValue = "") + + + 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 + */ + @Schema(name = "message", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ModelReturn.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ModelReturn.java new file mode 100644 index 000000000000..0301a47e9f3e --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ModelReturn.java @@ -0,0 +1,84 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Model for testing reserved words + */ +@Schema(name = "Return",description = "Model for testing reserved words") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ModelReturn { + @JsonProperty("return") + private Integer _return; + + public ModelReturn _return(Integer _return) { + this._return = _return; + return this; + } + + /** + * Get _return + * @return _return + */ + @Schema(name = "_return", defaultValue = "") + + + public Integer getReturn() { + return _return; + } + + public void setReturn(Integer _return) { + this._return = _return; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelReturn _return = (ModelReturn) o; + return Objects.equals(this._return, _return._return); + } + + @Override + public int hashCode() { + return Objects.hash(_return); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelReturn {\n"); + + sb.append(" _return: ").append(toIndentedString(_return)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Name.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Name.java new file mode 100644 index 000000000000..62a16f80ee07 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Name.java @@ -0,0 +1,160 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Model for testing model name same as property name + */ +@Schema(name = "Name",description = "Model for testing model name same as property name") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Name { + @JsonProperty("name") + private Integer name; + + @JsonProperty("snake_case") + private Integer snakeCase; + + @JsonProperty("property") + private String property; + + @JsonProperty("123Number") + private Integer _123number; + + public Name name(Integer name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Schema(name = "name", required = true, defaultValue = "") + @NotNull + + + public Integer getName() { + return name; + } + + public void setName(Integer name) { + this.name = name; + } + + public Name snakeCase(Integer snakeCase) { + this.snakeCase = snakeCase; + return this; + } + + /** + * Get snakeCase + * @return snakeCase + */ + @Schema(name = "snakeCase", readOnly = true, defaultValue = "") + + + public Integer getSnakeCase() { + return snakeCase; + } + + public void setSnakeCase(Integer snakeCase) { + this.snakeCase = snakeCase; + } + + public Name property(String property) { + this.property = property; + return this; + } + + /** + * Get property + * @return property + */ + @Schema(name = "property", defaultValue = "") + + + public String getProperty() { + return property; + } + + public void setProperty(String property) { + this.property = property; + } + + public Name _123number(Integer _123number) { + this._123number = _123number; + return this; + } + + /** + * Get _123number + * @return _123number + */ + @Schema(name = "_123number", readOnly = true, defaultValue = "") + + + public Integer get123number() { + return _123number; + } + + public void set123number(Integer _123number) { + this._123number = _123number; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Name name = (Name) o; + return Objects.equals(this.name, name.name) && + Objects.equals(this.snakeCase, name.snakeCase) && + Objects.equals(this.property, name.property) && + Objects.equals(this._123number, name._123number); + } + + @Override + public int hashCode() { + return Objects.hash(name, snakeCase, property, _123number); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Name {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n"); + sb.append(" property: ").append(toIndentedString(property)).append("\n"); + sb.append(" _123number: ").append(toIndentedString(_123number)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/NumberOnly.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/NumberOnly.java new file mode 100644 index 000000000000..521fad80d5a7 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/NumberOnly.java @@ -0,0 +1,85 @@ +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 java.math.BigDecimal; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * NumberOnly + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class NumberOnly { + @JsonProperty("JustNumber") + private BigDecimal justNumber; + + public NumberOnly justNumber(BigDecimal justNumber) { + this.justNumber = justNumber; + return this; + } + + /** + * Get justNumber + * @return justNumber + */ + @Schema(name = "justNumber", defaultValue = "") + + @Valid + + public BigDecimal getJustNumber() { + return justNumber; + } + + public void setJustNumber(BigDecimal justNumber) { + this.justNumber = justNumber; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NumberOnly numberOnly = (NumberOnly) o; + return Objects.equals(this.justNumber, numberOnly.justNumber); + } + + @Override + public int hashCode() { + return Objects.hash(justNumber); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NumberOnly {\n"); + + sb.append(" justNumber: ").append(toIndentedString(justNumber)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Order.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Order.java new file mode 100644 index 000000000000..05071bdfe2bf --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Order.java @@ -0,0 +1,249 @@ +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 java.time.OffsetDateTime; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Order + */ +@javax.annotation.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") + @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "petId", defaultValue = "") + + + 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 + */ + @Schema(name = "quantity", defaultValue = "") + + + 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 + */ + @Schema(name = "shipDate", defaultValue = "") + + @Valid + + 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 + */ + @Schema(name = "status", defaultValue = "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 + */ + @Schema(name = "complete", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/OuterComposite.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/OuterComposite.java new file mode 100644 index 000000000000..a721a3dde6a0 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/OuterComposite.java @@ -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 java.math.BigDecimal; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * OuterComposite + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class OuterComposite { + @JsonProperty("my_number") + private BigDecimal myNumber; + + @JsonProperty("my_string") + private String myString; + + @JsonProperty("my_boolean") + private Boolean myBoolean; + + public OuterComposite myNumber(BigDecimal myNumber) { + this.myNumber = myNumber; + return this; + } + + /** + * Get myNumber + * @return myNumber + */ + @Schema(name = "myNumber", defaultValue = "") + + @Valid + + public BigDecimal getMyNumber() { + return myNumber; + } + + public void setMyNumber(BigDecimal myNumber) { + this.myNumber = myNumber; + } + + public OuterComposite myString(String myString) { + this.myString = myString; + return this; + } + + /** + * Get myString + * @return myString + */ + @Schema(name = "myString", defaultValue = "") + + + public String getMyString() { + return myString; + } + + public void setMyString(String myString) { + this.myString = myString; + } + + public OuterComposite myBoolean(Boolean myBoolean) { + this.myBoolean = myBoolean; + return this; + } + + /** + * Get myBoolean + * @return myBoolean + */ + @Schema(name = "myBoolean", defaultValue = "") + + + public Boolean getMyBoolean() { + return myBoolean; + } + + public void setMyBoolean(Boolean myBoolean) { + this.myBoolean = myBoolean; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OuterComposite outerComposite = (OuterComposite) o; + return Objects.equals(this.myNumber, outerComposite.myNumber) && + Objects.equals(this.myString, outerComposite.myString) && + Objects.equals(this.myBoolean, outerComposite.myBoolean); + } + + @Override + public int hashCode() { + return Objects.hash(myNumber, myString, myBoolean); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OuterComposite {\n"); + + sb.append(" myNumber: ").append(toIndentedString(myNumber)).append("\n"); + sb.append(" myString: ").append(toIndentedString(myString)).append("\n"); + sb.append(" myBoolean: ").append(toIndentedString(myBoolean)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/OuterEnum.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/OuterEnum.java new file mode 100644 index 000000000000..ba0cca8a5e81 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/OuterEnum.java @@ -0,0 +1,55 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Gets or Sets OuterEnum + */ +public enum OuterEnum { + + PLACED("placed"), + + APPROVED("approved"), + + DELIVERED("delivered"); + + private String value; + + OuterEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static OuterEnum fromValue(String value) { + for (OuterEnum b : OuterEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Pet.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Pet.java new file mode 100644 index 000000000000..988eb317134d --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Pet.java @@ -0,0 +1,273 @@ +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 com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +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 io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Pet + */ +@javax.annotation.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 Set photoUrls = new LinkedHashSet<>(); + + @JsonProperty("tags") + @Valid + private List 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; + + public Pet id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "category", defaultValue = "") + + @Valid + + 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 + */ + @Schema(name = "name", example = "doggie", required = true, defaultValue = "") + @NotNull + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Pet photoUrls(Set photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + public Pet addPhotoUrlsItem(String photoUrlsItem) { + this.photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get photoUrls + * @return photoUrls + */ + @Schema(name = "photoUrls", required = true, defaultValue = "") + @NotNull + + + public Set getPhotoUrls() { + return photoUrls; + } + + @JsonDeserialize(as = LinkedHashSet.class) + public void setPhotoUrls(Set photoUrls) { + this.photoUrls = photoUrls; + } + + public Pet tags(List 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 + */ + @Schema(name = "tags", defaultValue = "") + + @Valid + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * pet status in the store + * @return status + */ + @Schema(name = "status", defaultValue = "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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ReadOnlyFirst.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ReadOnlyFirst.java new file mode 100644 index 000000000000..1c51770a8e66 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ReadOnlyFirst.java @@ -0,0 +1,108 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * ReadOnlyFirst + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ReadOnlyFirst { + @JsonProperty("bar") + private String bar; + + @JsonProperty("baz") + private String baz; + + public ReadOnlyFirst bar(String bar) { + this.bar = bar; + return this; + } + + /** + * Get bar + * @return bar + */ + @Schema(name = "bar", readOnly = true, defaultValue = "") + + + public String getBar() { + return bar; + } + + public void setBar(String bar) { + this.bar = bar; + } + + public ReadOnlyFirst baz(String baz) { + this.baz = baz; + return this; + } + + /** + * Get baz + * @return baz + */ + @Schema(name = "baz", defaultValue = "") + + + public String getBaz() { + return baz; + } + + public void setBaz(String baz) { + this.baz = baz; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReadOnlyFirst readOnlyFirst = (ReadOnlyFirst) o; + return Objects.equals(this.bar, readOnlyFirst.bar) && + Objects.equals(this.baz, readOnlyFirst.baz); + } + + @Override + public int hashCode() { + return Objects.hash(bar, baz); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ReadOnlyFirst {\n"); + + sb.append(" bar: ").append(toIndentedString(bar)).append("\n"); + sb.append(" baz: ").append(toIndentedString(baz)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/SpecialModelName.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/SpecialModelName.java new file mode 100644 index 000000000000..75f4be4e9f8f --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/SpecialModelName.java @@ -0,0 +1,83 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * SpecialModelName + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class SpecialModelName { + @JsonProperty("$special[property.name]") + private Long $specialPropertyName; + + public SpecialModelName $specialPropertyName(Long $specialPropertyName) { + this.$specialPropertyName = $specialPropertyName; + return this; + } + + /** + * Get $specialPropertyName + * @return $specialPropertyName + */ + @Schema(name = "$specialPropertyName", defaultValue = "") + + + public Long get$SpecialPropertyName() { + return $specialPropertyName; + } + + public void set$SpecialPropertyName(Long $specialPropertyName) { + this.$specialPropertyName = $specialPropertyName; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SpecialModelName $specialModelName = (SpecialModelName) o; + return Objects.equals(this.$specialPropertyName, $specialModelName.$specialPropertyName); + } + + @Override + public int hashCode() { + return Objects.hash($specialPropertyName); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SpecialModelName {\n"); + + sb.append(" $specialPropertyName: ").append(toIndentedString($specialPropertyName)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Tag.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Tag.java new file mode 100644 index 000000000000..8722df999bfc --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Tag.java @@ -0,0 +1,108 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Tag + */ +@javax.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "name", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/TypeHolderDefault.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/TypeHolderDefault.java new file mode 100644 index 000000000000..19e9bf310f76 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/TypeHolderDefault.java @@ -0,0 +1,198 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * TypeHolderDefault + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class TypeHolderDefault { + @JsonProperty("string_item") + private String stringItem = "what"; + + @JsonProperty("number_item") + private BigDecimal numberItem; + + @JsonProperty("integer_item") + private Integer integerItem; + + @JsonProperty("bool_item") + private Boolean boolItem = true; + + @JsonProperty("array_item") + @Valid + private List arrayItem = new ArrayList<>(); + + public TypeHolderDefault stringItem(String stringItem) { + this.stringItem = stringItem; + return this; + } + + /** + * Get stringItem + * @return stringItem + */ + @Schema(name = "stringItem", required = true, defaultValue = "") + @NotNull + + + public String getStringItem() { + return stringItem; + } + + public void setStringItem(String stringItem) { + this.stringItem = stringItem; + } + + public TypeHolderDefault numberItem(BigDecimal numberItem) { + this.numberItem = numberItem; + return this; + } + + /** + * Get numberItem + * @return numberItem + */ + @Schema(name = "numberItem", required = true, defaultValue = "") + @NotNull + + @Valid + + public BigDecimal getNumberItem() { + return numberItem; + } + + public void setNumberItem(BigDecimal numberItem) { + this.numberItem = numberItem; + } + + public TypeHolderDefault integerItem(Integer integerItem) { + this.integerItem = integerItem; + return this; + } + + /** + * Get integerItem + * @return integerItem + */ + @Schema(name = "integerItem", required = true, defaultValue = "") + @NotNull + + + public Integer getIntegerItem() { + return integerItem; + } + + public void setIntegerItem(Integer integerItem) { + this.integerItem = integerItem; + } + + public TypeHolderDefault boolItem(Boolean boolItem) { + this.boolItem = boolItem; + return this; + } + + /** + * Get boolItem + * @return boolItem + */ + @Schema(name = "boolItem", required = true, defaultValue = "") + @NotNull + + + public Boolean getBoolItem() { + return boolItem; + } + + public void setBoolItem(Boolean boolItem) { + this.boolItem = boolItem; + } + + public TypeHolderDefault arrayItem(List arrayItem) { + this.arrayItem = arrayItem; + return this; + } + + public TypeHolderDefault addArrayItemItem(Integer arrayItemItem) { + this.arrayItem.add(arrayItemItem); + return this; + } + + /** + * Get arrayItem + * @return arrayItem + */ + @Schema(name = "arrayItem", required = true, defaultValue = "") + @NotNull + + + public List getArrayItem() { + return arrayItem; + } + + public void setArrayItem(List arrayItem) { + this.arrayItem = arrayItem; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TypeHolderDefault typeHolderDefault = (TypeHolderDefault) o; + return Objects.equals(this.stringItem, typeHolderDefault.stringItem) && + Objects.equals(this.numberItem, typeHolderDefault.numberItem) && + Objects.equals(this.integerItem, typeHolderDefault.integerItem) && + Objects.equals(this.boolItem, typeHolderDefault.boolItem) && + Objects.equals(this.arrayItem, typeHolderDefault.arrayItem); + } + + @Override + public int hashCode() { + return Objects.hash(stringItem, numberItem, integerItem, boolItem, arrayItem); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TypeHolderDefault {\n"); + + sb.append(" stringItem: ").append(toIndentedString(stringItem)).append("\n"); + sb.append(" numberItem: ").append(toIndentedString(numberItem)).append("\n"); + sb.append(" integerItem: ").append(toIndentedString(integerItem)).append("\n"); + sb.append(" boolItem: ").append(toIndentedString(boolItem)).append("\n"); + sb.append(" arrayItem: ").append(toIndentedString(arrayItem)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/TypeHolderExample.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/TypeHolderExample.java new file mode 100644 index 000000000000..c9a3762bc74b --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/TypeHolderExample.java @@ -0,0 +1,224 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * TypeHolderExample + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class TypeHolderExample { + @JsonProperty("string_item") + private String stringItem; + + @JsonProperty("number_item") + private BigDecimal numberItem; + + @JsonProperty("float_item") + private Float floatItem; + + @JsonProperty("integer_item") + private Integer integerItem; + + @JsonProperty("bool_item") + private Boolean boolItem; + + @JsonProperty("array_item") + @Valid + private List arrayItem = new ArrayList<>(); + + public TypeHolderExample stringItem(String stringItem) { + this.stringItem = stringItem; + return this; + } + + /** + * Get stringItem + * @return stringItem + */ + @Schema(name = "stringItem", example = "what", required = true, defaultValue = "") + @NotNull + + + public String getStringItem() { + return stringItem; + } + + public void setStringItem(String stringItem) { + this.stringItem = stringItem; + } + + public TypeHolderExample numberItem(BigDecimal numberItem) { + this.numberItem = numberItem; + return this; + } + + /** + * Get numberItem + * @return numberItem + */ + @Schema(name = "numberItem", example = "1.234", required = true, defaultValue = "") + @NotNull + + @Valid + + public BigDecimal getNumberItem() { + return numberItem; + } + + public void setNumberItem(BigDecimal numberItem) { + this.numberItem = numberItem; + } + + public TypeHolderExample floatItem(Float floatItem) { + this.floatItem = floatItem; + return this; + } + + /** + * Get floatItem + * @return floatItem + */ + @Schema(name = "floatItem", example = "1.234", required = true, defaultValue = "") + @NotNull + + + public Float getFloatItem() { + return floatItem; + } + + public void setFloatItem(Float floatItem) { + this.floatItem = floatItem; + } + + public TypeHolderExample integerItem(Integer integerItem) { + this.integerItem = integerItem; + return this; + } + + /** + * Get integerItem + * @return integerItem + */ + @Schema(name = "integerItem", example = "-2", required = true, defaultValue = "") + @NotNull + + + public Integer getIntegerItem() { + return integerItem; + } + + public void setIntegerItem(Integer integerItem) { + this.integerItem = integerItem; + } + + public TypeHolderExample boolItem(Boolean boolItem) { + this.boolItem = boolItem; + return this; + } + + /** + * Get boolItem + * @return boolItem + */ + @Schema(name = "boolItem", example = "true", required = true, defaultValue = "") + @NotNull + + + public Boolean getBoolItem() { + return boolItem; + } + + public void setBoolItem(Boolean boolItem) { + this.boolItem = boolItem; + } + + public TypeHolderExample arrayItem(List arrayItem) { + this.arrayItem = arrayItem; + return this; + } + + public TypeHolderExample addArrayItemItem(Integer arrayItemItem) { + this.arrayItem.add(arrayItemItem); + return this; + } + + /** + * Get arrayItem + * @return arrayItem + */ + @Schema(name = "arrayItem", example = "[0, 1, 2, 3]", required = true, defaultValue = "") + @NotNull + + + public List getArrayItem() { + return arrayItem; + } + + public void setArrayItem(List arrayItem) { + this.arrayItem = arrayItem; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TypeHolderExample typeHolderExample = (TypeHolderExample) o; + return Objects.equals(this.stringItem, typeHolderExample.stringItem) && + Objects.equals(this.numberItem, typeHolderExample.numberItem) && + Objects.equals(this.floatItem, typeHolderExample.floatItem) && + Objects.equals(this.integerItem, typeHolderExample.integerItem) && + Objects.equals(this.boolItem, typeHolderExample.boolItem) && + Objects.equals(this.arrayItem, typeHolderExample.arrayItem); + } + + @Override + public int hashCode() { + return Objects.hash(stringItem, numberItem, floatItem, integerItem, boolItem, arrayItem); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TypeHolderExample {\n"); + + sb.append(" stringItem: ").append(toIndentedString(stringItem)).append("\n"); + sb.append(" numberItem: ").append(toIndentedString(numberItem)).append("\n"); + sb.append(" floatItem: ").append(toIndentedString(floatItem)).append("\n"); + sb.append(" integerItem: ").append(toIndentedString(integerItem)).append("\n"); + sb.append(" boolItem: ").append(toIndentedString(boolItem)).append("\n"); + sb.append(" arrayItem: ").append(toIndentedString(arrayItem)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/User.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/User.java new file mode 100644 index 000000000000..83152a155535 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/User.java @@ -0,0 +1,258 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * User + */ +@javax.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "username", defaultValue = "") + + + 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 + */ + @Schema(name = "firstName", defaultValue = "") + + + 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 + */ + @Schema(name = "lastName", defaultValue = "") + + + 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 + */ + @Schema(name = "email", defaultValue = "") + + + 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 + */ + @Schema(name = "password", defaultValue = "") + + + 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 + */ + @Schema(name = "phone", defaultValue = "") + + + 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 + */ + @Schema(name = "userStatus", defaultValue = "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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/XmlItem.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/XmlItem.java new file mode 100644 index 000000000000..59a183db0f62 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/XmlItem.java @@ -0,0 +1,872 @@ +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 java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * XmlItem + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class XmlItem { + @JsonProperty("attribute_string") + private String attributeString; + + @JsonProperty("attribute_number") + private BigDecimal attributeNumber; + + @JsonProperty("attribute_integer") + private Integer attributeInteger; + + @JsonProperty("attribute_boolean") + private Boolean attributeBoolean; + + @JsonProperty("wrapped_array") + @Valid + private List wrappedArray = null; + + @JsonProperty("name_string") + private String nameString; + + @JsonProperty("name_number") + private BigDecimal nameNumber; + + @JsonProperty("name_integer") + private Integer nameInteger; + + @JsonProperty("name_boolean") + private Boolean nameBoolean; + + @JsonProperty("name_array") + @Valid + private List nameArray = null; + + @JsonProperty("name_wrapped_array") + @Valid + private List nameWrappedArray = null; + + @JsonProperty("prefix_string") + private String prefixString; + + @JsonProperty("prefix_number") + private BigDecimal prefixNumber; + + @JsonProperty("prefix_integer") + private Integer prefixInteger; + + @JsonProperty("prefix_boolean") + private Boolean prefixBoolean; + + @JsonProperty("prefix_array") + @Valid + private List prefixArray = null; + + @JsonProperty("prefix_wrapped_array") + @Valid + private List prefixWrappedArray = null; + + @JsonProperty("namespace_string") + private String namespaceString; + + @JsonProperty("namespace_number") + private BigDecimal namespaceNumber; + + @JsonProperty("namespace_integer") + private Integer namespaceInteger; + + @JsonProperty("namespace_boolean") + private Boolean namespaceBoolean; + + @JsonProperty("namespace_array") + @Valid + private List namespaceArray = null; + + @JsonProperty("namespace_wrapped_array") + @Valid + private List namespaceWrappedArray = null; + + @JsonProperty("prefix_ns_string") + private String prefixNsString; + + @JsonProperty("prefix_ns_number") + private BigDecimal prefixNsNumber; + + @JsonProperty("prefix_ns_integer") + private Integer prefixNsInteger; + + @JsonProperty("prefix_ns_boolean") + private Boolean prefixNsBoolean; + + @JsonProperty("prefix_ns_array") + @Valid + private List prefixNsArray = null; + + @JsonProperty("prefix_ns_wrapped_array") + @Valid + private List prefixNsWrappedArray = null; + + public XmlItem attributeString(String attributeString) { + this.attributeString = attributeString; + return this; + } + + /** + * Get attributeString + * @return attributeString + */ + @Schema(name = "attributeString", example = "string", defaultValue = "") + + + public String getAttributeString() { + return attributeString; + } + + public void setAttributeString(String attributeString) { + this.attributeString = attributeString; + } + + public XmlItem attributeNumber(BigDecimal attributeNumber) { + this.attributeNumber = attributeNumber; + return this; + } + + /** + * Get attributeNumber + * @return attributeNumber + */ + @Schema(name = "attributeNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getAttributeNumber() { + return attributeNumber; + } + + public void setAttributeNumber(BigDecimal attributeNumber) { + this.attributeNumber = attributeNumber; + } + + public XmlItem attributeInteger(Integer attributeInteger) { + this.attributeInteger = attributeInteger; + return this; + } + + /** + * Get attributeInteger + * @return attributeInteger + */ + @Schema(name = "attributeInteger", example = "-2", defaultValue = "") + + + public Integer getAttributeInteger() { + return attributeInteger; + } + + public void setAttributeInteger(Integer attributeInteger) { + this.attributeInteger = attributeInteger; + } + + public XmlItem attributeBoolean(Boolean attributeBoolean) { + this.attributeBoolean = attributeBoolean; + return this; + } + + /** + * Get attributeBoolean + * @return attributeBoolean + */ + @Schema(name = "attributeBoolean", example = "true", defaultValue = "") + + + public Boolean getAttributeBoolean() { + return attributeBoolean; + } + + public void setAttributeBoolean(Boolean attributeBoolean) { + this.attributeBoolean = attributeBoolean; + } + + public XmlItem wrappedArray(List wrappedArray) { + this.wrappedArray = wrappedArray; + return this; + } + + public XmlItem addWrappedArrayItem(Integer wrappedArrayItem) { + if (this.wrappedArray == null) { + this.wrappedArray = new ArrayList<>(); + } + this.wrappedArray.add(wrappedArrayItem); + return this; + } + + /** + * Get wrappedArray + * @return wrappedArray + */ + @Schema(name = "wrappedArray", defaultValue = "") + + + public List getWrappedArray() { + return wrappedArray; + } + + public void setWrappedArray(List wrappedArray) { + this.wrappedArray = wrappedArray; + } + + public XmlItem nameString(String nameString) { + this.nameString = nameString; + return this; + } + + /** + * Get nameString + * @return nameString + */ + @Schema(name = "nameString", example = "string", defaultValue = "") + + + public String getNameString() { + return nameString; + } + + public void setNameString(String nameString) { + this.nameString = nameString; + } + + public XmlItem nameNumber(BigDecimal nameNumber) { + this.nameNumber = nameNumber; + return this; + } + + /** + * Get nameNumber + * @return nameNumber + */ + @Schema(name = "nameNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getNameNumber() { + return nameNumber; + } + + public void setNameNumber(BigDecimal nameNumber) { + this.nameNumber = nameNumber; + } + + public XmlItem nameInteger(Integer nameInteger) { + this.nameInteger = nameInteger; + return this; + } + + /** + * Get nameInteger + * @return nameInteger + */ + @Schema(name = "nameInteger", example = "-2", defaultValue = "") + + + public Integer getNameInteger() { + return nameInteger; + } + + public void setNameInteger(Integer nameInteger) { + this.nameInteger = nameInteger; + } + + public XmlItem nameBoolean(Boolean nameBoolean) { + this.nameBoolean = nameBoolean; + return this; + } + + /** + * Get nameBoolean + * @return nameBoolean + */ + @Schema(name = "nameBoolean", example = "true", defaultValue = "") + + + public Boolean getNameBoolean() { + return nameBoolean; + } + + public void setNameBoolean(Boolean nameBoolean) { + this.nameBoolean = nameBoolean; + } + + public XmlItem nameArray(List nameArray) { + this.nameArray = nameArray; + return this; + } + + public XmlItem addNameArrayItem(Integer nameArrayItem) { + if (this.nameArray == null) { + this.nameArray = new ArrayList<>(); + } + this.nameArray.add(nameArrayItem); + return this; + } + + /** + * Get nameArray + * @return nameArray + */ + @Schema(name = "nameArray", defaultValue = "") + + + public List getNameArray() { + return nameArray; + } + + public void setNameArray(List nameArray) { + this.nameArray = nameArray; + } + + public XmlItem nameWrappedArray(List nameWrappedArray) { + this.nameWrappedArray = nameWrappedArray; + return this; + } + + public XmlItem addNameWrappedArrayItem(Integer nameWrappedArrayItem) { + if (this.nameWrappedArray == null) { + this.nameWrappedArray = new ArrayList<>(); + } + this.nameWrappedArray.add(nameWrappedArrayItem); + return this; + } + + /** + * Get nameWrappedArray + * @return nameWrappedArray + */ + @Schema(name = "nameWrappedArray", defaultValue = "") + + + public List getNameWrappedArray() { + return nameWrappedArray; + } + + public void setNameWrappedArray(List nameWrappedArray) { + this.nameWrappedArray = nameWrappedArray; + } + + public XmlItem prefixString(String prefixString) { + this.prefixString = prefixString; + return this; + } + + /** + * Get prefixString + * @return prefixString + */ + @Schema(name = "prefixString", example = "string", defaultValue = "") + + + public String getPrefixString() { + return prefixString; + } + + public void setPrefixString(String prefixString) { + this.prefixString = prefixString; + } + + public XmlItem prefixNumber(BigDecimal prefixNumber) { + this.prefixNumber = prefixNumber; + return this; + } + + /** + * Get prefixNumber + * @return prefixNumber + */ + @Schema(name = "prefixNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getPrefixNumber() { + return prefixNumber; + } + + public void setPrefixNumber(BigDecimal prefixNumber) { + this.prefixNumber = prefixNumber; + } + + public XmlItem prefixInteger(Integer prefixInteger) { + this.prefixInteger = prefixInteger; + return this; + } + + /** + * Get prefixInteger + * @return prefixInteger + */ + @Schema(name = "prefixInteger", example = "-2", defaultValue = "") + + + public Integer getPrefixInteger() { + return prefixInteger; + } + + public void setPrefixInteger(Integer prefixInteger) { + this.prefixInteger = prefixInteger; + } + + public XmlItem prefixBoolean(Boolean prefixBoolean) { + this.prefixBoolean = prefixBoolean; + return this; + } + + /** + * Get prefixBoolean + * @return prefixBoolean + */ + @Schema(name = "prefixBoolean", example = "true", defaultValue = "") + + + public Boolean getPrefixBoolean() { + return prefixBoolean; + } + + public void setPrefixBoolean(Boolean prefixBoolean) { + this.prefixBoolean = prefixBoolean; + } + + public XmlItem prefixArray(List prefixArray) { + this.prefixArray = prefixArray; + return this; + } + + public XmlItem addPrefixArrayItem(Integer prefixArrayItem) { + if (this.prefixArray == null) { + this.prefixArray = new ArrayList<>(); + } + this.prefixArray.add(prefixArrayItem); + return this; + } + + /** + * Get prefixArray + * @return prefixArray + */ + @Schema(name = "prefixArray", defaultValue = "") + + + public List getPrefixArray() { + return prefixArray; + } + + public void setPrefixArray(List prefixArray) { + this.prefixArray = prefixArray; + } + + public XmlItem prefixWrappedArray(List prefixWrappedArray) { + this.prefixWrappedArray = prefixWrappedArray; + return this; + } + + public XmlItem addPrefixWrappedArrayItem(Integer prefixWrappedArrayItem) { + if (this.prefixWrappedArray == null) { + this.prefixWrappedArray = new ArrayList<>(); + } + this.prefixWrappedArray.add(prefixWrappedArrayItem); + return this; + } + + /** + * Get prefixWrappedArray + * @return prefixWrappedArray + */ + @Schema(name = "prefixWrappedArray", defaultValue = "") + + + public List getPrefixWrappedArray() { + return prefixWrappedArray; + } + + public void setPrefixWrappedArray(List prefixWrappedArray) { + this.prefixWrappedArray = prefixWrappedArray; + } + + public XmlItem namespaceString(String namespaceString) { + this.namespaceString = namespaceString; + return this; + } + + /** + * Get namespaceString + * @return namespaceString + */ + @Schema(name = "namespaceString", example = "string", defaultValue = "") + + + public String getNamespaceString() { + return namespaceString; + } + + public void setNamespaceString(String namespaceString) { + this.namespaceString = namespaceString; + } + + public XmlItem namespaceNumber(BigDecimal namespaceNumber) { + this.namespaceNumber = namespaceNumber; + return this; + } + + /** + * Get namespaceNumber + * @return namespaceNumber + */ + @Schema(name = "namespaceNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getNamespaceNumber() { + return namespaceNumber; + } + + public void setNamespaceNumber(BigDecimal namespaceNumber) { + this.namespaceNumber = namespaceNumber; + } + + public XmlItem namespaceInteger(Integer namespaceInteger) { + this.namespaceInteger = namespaceInteger; + return this; + } + + /** + * Get namespaceInteger + * @return namespaceInteger + */ + @Schema(name = "namespaceInteger", example = "-2", defaultValue = "") + + + public Integer getNamespaceInteger() { + return namespaceInteger; + } + + public void setNamespaceInteger(Integer namespaceInteger) { + this.namespaceInteger = namespaceInteger; + } + + public XmlItem namespaceBoolean(Boolean namespaceBoolean) { + this.namespaceBoolean = namespaceBoolean; + return this; + } + + /** + * Get namespaceBoolean + * @return namespaceBoolean + */ + @Schema(name = "namespaceBoolean", example = "true", defaultValue = "") + + + public Boolean getNamespaceBoolean() { + return namespaceBoolean; + } + + public void setNamespaceBoolean(Boolean namespaceBoolean) { + this.namespaceBoolean = namespaceBoolean; + } + + public XmlItem namespaceArray(List namespaceArray) { + this.namespaceArray = namespaceArray; + return this; + } + + public XmlItem addNamespaceArrayItem(Integer namespaceArrayItem) { + if (this.namespaceArray == null) { + this.namespaceArray = new ArrayList<>(); + } + this.namespaceArray.add(namespaceArrayItem); + return this; + } + + /** + * Get namespaceArray + * @return namespaceArray + */ + @Schema(name = "namespaceArray", defaultValue = "") + + + public List getNamespaceArray() { + return namespaceArray; + } + + public void setNamespaceArray(List namespaceArray) { + this.namespaceArray = namespaceArray; + } + + public XmlItem namespaceWrappedArray(List namespaceWrappedArray) { + this.namespaceWrappedArray = namespaceWrappedArray; + return this; + } + + public XmlItem addNamespaceWrappedArrayItem(Integer namespaceWrappedArrayItem) { + if (this.namespaceWrappedArray == null) { + this.namespaceWrappedArray = new ArrayList<>(); + } + this.namespaceWrappedArray.add(namespaceWrappedArrayItem); + return this; + } + + /** + * Get namespaceWrappedArray + * @return namespaceWrappedArray + */ + @Schema(name = "namespaceWrappedArray", defaultValue = "") + + + public List getNamespaceWrappedArray() { + return namespaceWrappedArray; + } + + public void setNamespaceWrappedArray(List namespaceWrappedArray) { + this.namespaceWrappedArray = namespaceWrappedArray; + } + + public XmlItem prefixNsString(String prefixNsString) { + this.prefixNsString = prefixNsString; + return this; + } + + /** + * Get prefixNsString + * @return prefixNsString + */ + @Schema(name = "prefixNsString", example = "string", defaultValue = "") + + + public String getPrefixNsString() { + return prefixNsString; + } + + public void setPrefixNsString(String prefixNsString) { + this.prefixNsString = prefixNsString; + } + + public XmlItem prefixNsNumber(BigDecimal prefixNsNumber) { + this.prefixNsNumber = prefixNsNumber; + return this; + } + + /** + * Get prefixNsNumber + * @return prefixNsNumber + */ + @Schema(name = "prefixNsNumber", example = "1.234", defaultValue = "") + + @Valid + + public BigDecimal getPrefixNsNumber() { + return prefixNsNumber; + } + + public void setPrefixNsNumber(BigDecimal prefixNsNumber) { + this.prefixNsNumber = prefixNsNumber; + } + + public XmlItem prefixNsInteger(Integer prefixNsInteger) { + this.prefixNsInteger = prefixNsInteger; + return this; + } + + /** + * Get prefixNsInteger + * @return prefixNsInteger + */ + @Schema(name = "prefixNsInteger", example = "-2", defaultValue = "") + + + public Integer getPrefixNsInteger() { + return prefixNsInteger; + } + + public void setPrefixNsInteger(Integer prefixNsInteger) { + this.prefixNsInteger = prefixNsInteger; + } + + public XmlItem prefixNsBoolean(Boolean prefixNsBoolean) { + this.prefixNsBoolean = prefixNsBoolean; + return this; + } + + /** + * Get prefixNsBoolean + * @return prefixNsBoolean + */ + @Schema(name = "prefixNsBoolean", example = "true", defaultValue = "") + + + public Boolean getPrefixNsBoolean() { + return prefixNsBoolean; + } + + public void setPrefixNsBoolean(Boolean prefixNsBoolean) { + this.prefixNsBoolean = prefixNsBoolean; + } + + public XmlItem prefixNsArray(List prefixNsArray) { + this.prefixNsArray = prefixNsArray; + return this; + } + + public XmlItem addPrefixNsArrayItem(Integer prefixNsArrayItem) { + if (this.prefixNsArray == null) { + this.prefixNsArray = new ArrayList<>(); + } + this.prefixNsArray.add(prefixNsArrayItem); + return this; + } + + /** + * Get prefixNsArray + * @return prefixNsArray + */ + @Schema(name = "prefixNsArray", defaultValue = "") + + + public List getPrefixNsArray() { + return prefixNsArray; + } + + public void setPrefixNsArray(List prefixNsArray) { + this.prefixNsArray = prefixNsArray; + } + + public XmlItem prefixNsWrappedArray(List prefixNsWrappedArray) { + this.prefixNsWrappedArray = prefixNsWrappedArray; + return this; + } + + public XmlItem addPrefixNsWrappedArrayItem(Integer prefixNsWrappedArrayItem) { + if (this.prefixNsWrappedArray == null) { + this.prefixNsWrappedArray = new ArrayList<>(); + } + this.prefixNsWrappedArray.add(prefixNsWrappedArrayItem); + return this; + } + + /** + * Get prefixNsWrappedArray + * @return prefixNsWrappedArray + */ + @Schema(name = "prefixNsWrappedArray", defaultValue = "") + + + public List getPrefixNsWrappedArray() { + return prefixNsWrappedArray; + } + + public void setPrefixNsWrappedArray(List prefixNsWrappedArray) { + this.prefixNsWrappedArray = prefixNsWrappedArray; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + XmlItem xmlItem = (XmlItem) o; + return Objects.equals(this.attributeString, xmlItem.attributeString) && + Objects.equals(this.attributeNumber, xmlItem.attributeNumber) && + Objects.equals(this.attributeInteger, xmlItem.attributeInteger) && + Objects.equals(this.attributeBoolean, xmlItem.attributeBoolean) && + Objects.equals(this.wrappedArray, xmlItem.wrappedArray) && + Objects.equals(this.nameString, xmlItem.nameString) && + Objects.equals(this.nameNumber, xmlItem.nameNumber) && + Objects.equals(this.nameInteger, xmlItem.nameInteger) && + Objects.equals(this.nameBoolean, xmlItem.nameBoolean) && + Objects.equals(this.nameArray, xmlItem.nameArray) && + Objects.equals(this.nameWrappedArray, xmlItem.nameWrappedArray) && + Objects.equals(this.prefixString, xmlItem.prefixString) && + Objects.equals(this.prefixNumber, xmlItem.prefixNumber) && + Objects.equals(this.prefixInteger, xmlItem.prefixInteger) && + Objects.equals(this.prefixBoolean, xmlItem.prefixBoolean) && + Objects.equals(this.prefixArray, xmlItem.prefixArray) && + Objects.equals(this.prefixWrappedArray, xmlItem.prefixWrappedArray) && + Objects.equals(this.namespaceString, xmlItem.namespaceString) && + Objects.equals(this.namespaceNumber, xmlItem.namespaceNumber) && + Objects.equals(this.namespaceInteger, xmlItem.namespaceInteger) && + Objects.equals(this.namespaceBoolean, xmlItem.namespaceBoolean) && + Objects.equals(this.namespaceArray, xmlItem.namespaceArray) && + Objects.equals(this.namespaceWrappedArray, xmlItem.namespaceWrappedArray) && + Objects.equals(this.prefixNsString, xmlItem.prefixNsString) && + Objects.equals(this.prefixNsNumber, xmlItem.prefixNsNumber) && + Objects.equals(this.prefixNsInteger, xmlItem.prefixNsInteger) && + Objects.equals(this.prefixNsBoolean, xmlItem.prefixNsBoolean) && + Objects.equals(this.prefixNsArray, xmlItem.prefixNsArray) && + Objects.equals(this.prefixNsWrappedArray, xmlItem.prefixNsWrappedArray); + } + + @Override + public int hashCode() { + return Objects.hash(attributeString, attributeNumber, attributeInteger, attributeBoolean, wrappedArray, nameString, nameNumber, nameInteger, nameBoolean, nameArray, nameWrappedArray, prefixString, prefixNumber, prefixInteger, prefixBoolean, prefixArray, prefixWrappedArray, namespaceString, namespaceNumber, namespaceInteger, namespaceBoolean, namespaceArray, namespaceWrappedArray, prefixNsString, prefixNsNumber, prefixNsInteger, prefixNsBoolean, prefixNsArray, prefixNsWrappedArray); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class XmlItem {\n"); + + sb.append(" attributeString: ").append(toIndentedString(attributeString)).append("\n"); + sb.append(" attributeNumber: ").append(toIndentedString(attributeNumber)).append("\n"); + sb.append(" attributeInteger: ").append(toIndentedString(attributeInteger)).append("\n"); + sb.append(" attributeBoolean: ").append(toIndentedString(attributeBoolean)).append("\n"); + sb.append(" wrappedArray: ").append(toIndentedString(wrappedArray)).append("\n"); + sb.append(" nameString: ").append(toIndentedString(nameString)).append("\n"); + sb.append(" nameNumber: ").append(toIndentedString(nameNumber)).append("\n"); + sb.append(" nameInteger: ").append(toIndentedString(nameInteger)).append("\n"); + sb.append(" nameBoolean: ").append(toIndentedString(nameBoolean)).append("\n"); + sb.append(" nameArray: ").append(toIndentedString(nameArray)).append("\n"); + sb.append(" nameWrappedArray: ").append(toIndentedString(nameWrappedArray)).append("\n"); + sb.append(" prefixString: ").append(toIndentedString(prefixString)).append("\n"); + sb.append(" prefixNumber: ").append(toIndentedString(prefixNumber)).append("\n"); + sb.append(" prefixInteger: ").append(toIndentedString(prefixInteger)).append("\n"); + sb.append(" prefixBoolean: ").append(toIndentedString(prefixBoolean)).append("\n"); + sb.append(" prefixArray: ").append(toIndentedString(prefixArray)).append("\n"); + sb.append(" prefixWrappedArray: ").append(toIndentedString(prefixWrappedArray)).append("\n"); + sb.append(" namespaceString: ").append(toIndentedString(namespaceString)).append("\n"); + sb.append(" namespaceNumber: ").append(toIndentedString(namespaceNumber)).append("\n"); + sb.append(" namespaceInteger: ").append(toIndentedString(namespaceInteger)).append("\n"); + sb.append(" namespaceBoolean: ").append(toIndentedString(namespaceBoolean)).append("\n"); + sb.append(" namespaceArray: ").append(toIndentedString(namespaceArray)).append("\n"); + sb.append(" namespaceWrappedArray: ").append(toIndentedString(namespaceWrappedArray)).append("\n"); + sb.append(" prefixNsString: ").append(toIndentedString(prefixNsString)).append("\n"); + sb.append(" prefixNsNumber: ").append(toIndentedString(prefixNsNumber)).append("\n"); + sb.append(" prefixNsInteger: ").append(toIndentedString(prefixNsInteger)).append("\n"); + sb.append(" prefixNsBoolean: ").append(toIndentedString(prefixNsBoolean)).append("\n"); + sb.append(" prefixNsArray: ").append(toIndentedString(prefixNsArray)).append("\n"); + sb.append(" prefixNsWrappedArray: ").append(toIndentedString(prefixNsWrappedArray)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/resources/application.properties b/samples/openapi3/server/petstore/springboot-useoptional/src/main/resources/application.properties new file mode 100644 index 000000000000..9d06609db665 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/resources/application.properties @@ -0,0 +1,3 @@ +server.port=80 +spring.jackson.date-format=org.openapitools.RFC3339DateFormat +spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/resources/openapi.yaml b/samples/openapi3/server/petstore/springboot-useoptional/src/main/resources/openapi.yaml new file mode 100644 index 000000000000..d6386dc39bf4 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/resources/openapi.yaml @@ -0,0 +1,2264 @@ +openapi: 3.0.1 +info: + description: 'This spec is mainly for testing Petstore server and contains fake + endpoints, models. Please do not use this for any other purpose. Special characters: + " \' + license: + name: Apache-2.0 + url: https://www.apache.org/licenses/LICENSE-2.0.html + title: OpenAPI Petstore + version: 1.0.0 +servers: +- url: http://petstore.swagger.io:80/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: + operationId: addPet + requestBody: + 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 + responses: + "200": + content: {} + description: successful operation + "405": + content: {} + description: Invalid input + security: + - petstore_auth: + - write:pets + - read:pets + summary: Add a new pet to the store + tags: + - pet + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: pet + put: + operationId: updatePet + requestBody: + 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 + responses: + "200": + content: {} + description: successful operation + "400": + content: {} + description: Invalid ID supplied + "404": + content: {} + description: Pet not found + "405": + content: {} + description: Validation exception + security: + - petstore_auth: + - write:pets + - read:pets + summary: Update an existing pet + tags: + - pet + x-codegen-request-body-name: body + x-contentType: 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: + - 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": + content: {} + description: Invalid status value + security: + - petstore_auth: + - write:pets + - 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 + uniqueItems: true + style: form + responses: + "200": + content: + application/xml: + schema: + items: + $ref: '#/components/schemas/Pet' + type: array + uniqueItems: true + application/json: + schema: + items: + $ref: '#/components/schemas/Pet' + type: array + uniqueItems: true + description: successful operation + "400": + content: {} + description: Invalid tag value + security: + - petstore_auth: + - write:pets + - read:pets + summary: Finds Pets by tags + tags: + - pet + x-accepts: application/json + x-tags: + - tag: pet + /pet/{petId}: + delete: + operationId: deletePet + parameters: + - in: header + name: api_key + schema: + type: string + - description: Pet id to delete + in: path + name: petId + required: true + schema: + format: int64 + type: integer + responses: + "200": + content: {} + description: successful operation + "400": + content: {} + 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 + in: path + name: petId + required: true + schema: + format: int64 + type: integer + responses: + "200": + content: + application/xml: + schema: + $ref: '#/components/schemas/Pet' + application/json: + schema: + $ref: '#/components/schemas/Pet' + description: successful operation + "400": + content: {} + description: Invalid ID supplied + "404": + content: {} + description: Pet not found + security: + - api_key: [] + summary: Find pet by ID + tags: + - pet + x-accepts: application/json + x-tags: + - tag: pet + post: + operationId: updatePetWithForm + parameters: + - description: ID of pet that needs to be updated + in: path + name: petId + required: true + schema: + format: int64 + type: integer + requestBody: + content: + application/x-www-form-urlencoded: + schema: + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string + responses: + "405": + content: {} + description: Invalid input + security: + - petstore_auth: + - write:pets + - read:pets + summary: Updates a pet in the store with form data + tags: + - pet + x-contentType: application/x-www-form-urlencoded + x-accepts: application/json + x-tags: + - tag: pet + /pet/{petId}/uploadImage: + post: + operationId: uploadFile + parameters: + - description: ID of pet to update + in: path + name: petId + required: true + schema: + format: int64 + type: integer + requestBody: + content: + multipart/form-data: + schema: + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + format: binary + type: string + 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-contentType: 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: + operationId: placeOrder + requestBody: + content: + '*/*': + 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": + content: {} + description: Invalid Order + summary: Place an order for a pet + tags: + - store + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: application/json + x-tags: + - tag: store + /store/order/{order_id}: + 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 + in: path + name: order_id + required: true + schema: + type: string + responses: + "400": + content: {} + description: Invalid ID supplied + "404": + content: {} + 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 generated exceptions + operationId: getOrderById + parameters: + - description: ID of pet that needs to be fetched + in: path + name: order_id + required: true + schema: + format: int64 + maximum: 5 + minimum: 1 + type: integer + responses: + "200": + content: + application/xml: + schema: + $ref: '#/components/schemas/Order' + application/json: + schema: + $ref: '#/components/schemas/Order' + description: successful operation + "400": + content: {} + description: Invalid ID supplied + "404": + content: {} + 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: + '*/*': + schema: + $ref: '#/components/schemas/User' + description: Created user object + required: true + responses: + default: + content: {} + description: successful operation + summary: Create user + tags: + - user + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: application/json + x-tags: + - tag: user + /user/createWithArray: + post: + operationId: createUsersWithArrayInput + requestBody: + content: + '*/*': + schema: + items: + $ref: '#/components/schemas/User' + type: array + description: List of user object + required: true + responses: + default: + content: {} + description: successful operation + summary: Creates list of users with given input array + tags: + - user + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: application/json + x-tags: + - tag: user + /user/createWithList: + post: + operationId: createUsersWithListInput + requestBody: + content: + '*/*': + schema: + items: + $ref: '#/components/schemas/User' + type: array + description: List of user object + required: true + responses: + default: + content: {} + description: successful operation + summary: Creates list of users with given input array + tags: + - user + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: application/json + x-tags: + - tag: user + /user/login: + get: + operationId: loginUser + parameters: + - description: The user name for login + in: query + name: username + required: true + schema: + type: string + - description: The password for login in clear text + in: query + name: password + required: true + schema: + type: string + responses: + "200": + content: + application/xml: + schema: + type: string + application/json: + schema: + type: string + description: successful operation + headers: + X-Rate-Limit: + description: calls per hour allowed by the user + schema: + format: int32 + type: integer + X-Expires-After: + description: date in UTC when token expires + schema: + format: date-time + type: string + "400": + content: {} + description: Invalid username/password supplied + summary: Logs user into the system + tags: + - user + x-accepts: application/json + x-tags: + - tag: user + /user/logout: + get: + operationId: logoutUser + responses: + default: + content: {} + description: successful operation + 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 + in: path + name: username + required: true + schema: + type: string + responses: + "400": + content: {} + description: Invalid username supplied + "404": + content: {} + description: User not found + summary: Delete user + tags: + - user + x-accepts: application/json + x-tags: + - tag: user + get: + operationId: getUserByName + parameters: + - description: The name that needs to be fetched. Use user1 for testing. + in: path + name: username + required: true + schema: + type: string + responses: + "200": + content: + application/xml: + schema: + $ref: '#/components/schemas/User' + application/json: + schema: + $ref: '#/components/schemas/User' + description: successful operation + "400": + content: {} + description: Invalid username supplied + "404": + content: {} + 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 + in: path + name: username + required: true + schema: + type: string + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/User' + description: Updated user object + required: true + responses: + "400": + content: {} + description: Invalid user supplied + "404": + content: {} + description: User not found + summary: Updated user + tags: + - user + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: application/json + x-tags: + - tag: user + /fake_classname_test: + patch: + description: To test class name in snake case + operationId: testClassname + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: client model + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: successful operation + security: + - api_key_query: [] + summary: To test class name in snake case + tags: + - fake_classname_tags 123#$%^ + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: fake_classname_tags 123#$%^ + /fake: + delete: + description: Fake endpoint to test group parameters (optional) + operationId: testGroupParameters + parameters: + - description: Required String in group parameters + in: query + name: required_string_group + required: true + schema: + type: integer + - description: Required Boolean in group parameters + in: header + name: required_boolean_group + required: true + schema: + type: boolean + - description: Required Integer in group parameters + in: query + name: required_int64_group + required: true + schema: + format: int64 + type: integer + - description: String in group parameters + in: query + name: string_group + schema: + type: integer + - description: Boolean in group parameters + in: header + name: boolean_group + schema: + type: boolean + - description: Integer in group parameters + in: query + name: int64_group + schema: + format: int64 + type: integer + responses: + "400": + content: {} + description: Someting wrong + summary: Fake endpoint to test group parameters (optional) + tags: + - fake + x-group-parameters: true + x-accepts: application/json + x-tags: + - tag: fake + get: + description: To test enum parameters + operationId: testEnumParameters + parameters: + - description: Header parameter enum test (string array) + explode: false + in: header + name: enum_header_string_array + schema: + items: + default: $ + enum: + - '>' + - $ + type: string + type: array + style: simple + - description: Header parameter enum test (string) + in: header + name: enum_header_string + schema: + default: -efg + enum: + - _abc + - -efg + - (xyz) + type: string + - description: Query parameter enum test (string array) + explode: false + in: query + name: enum_query_string_array + schema: + items: + default: $ + enum: + - '>' + - $ + type: string + type: array + style: form + - description: Query parameter enum test (string) + in: query + name: enum_query_string + schema: + default: -efg + enum: + - _abc + - -efg + - (xyz) + type: string + - description: Query parameter enum test (double) + in: query + name: enum_query_integer + schema: + enum: + - 1 + - -2 + format: int32 + type: integer + - description: Query parameter enum test (double) + in: query + name: enum_query_double + schema: + enum: + - 1.1 + - -1.2 + format: double + type: number + requestBody: + content: + application/x-www-form-urlencoded: + schema: + properties: + enum_form_string_array: + description: Form parameter enum test (string array) + items: + default: $ + enum: + - '>' + - $ + type: string + type: array + enum_form_string: + default: -efg + description: Form parameter enum test (string) + enum: + - _abc + - -efg + - (xyz) + type: string + responses: + "400": + content: {} + description: Invalid request + "404": + content: {} + description: Not found + summary: To test enum parameters + tags: + - fake + x-contentType: application/x-www-form-urlencoded + x-accepts: application/json + x-tags: + - tag: fake + patch: + description: To test "client" model + operationId: testClientModel + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: client model + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: successful operation + summary: To test "client" model + tags: + - fake + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: fake + post: + description: |- + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + operationId: testEndpointParameters + requestBody: + content: + application/x-www-form-urlencoded: + schema: + properties: + integer: + description: None + format: int32 + maximum: 100 + minimum: 10 + type: integer + int32: + description: None + format: int32 + maximum: 200 + minimum: 20 + type: integer + int64: + description: None + format: int64 + type: integer + number: + description: None + maximum: 543.2 + minimum: 32.1 + type: number + float: + description: None + format: float + maximum: 987.6 + type: number + double: + description: None + format: double + maximum: 123.4 + minimum: 67.8 + type: number + string: + description: None + pattern: /[a-z]/i + type: string + pattern_without_delimiter: + description: None + pattern: ^[A-Z].* + type: string + byte: + description: None + format: byte + type: string + binary: + description: None + format: binary + type: string + date: + description: None + format: date + type: string + dateTime: + description: None + format: date-time + type: string + password: + description: None + format: password + maxLength: 64 + minLength: 10 + type: string + callback: + description: None + type: string + required: + - byte + - double + - number + - pattern_without_delimiter + required: true + responses: + "400": + content: {} + description: Invalid username supplied + "404": + content: {} + description: User not found + security: + - http_basic_test: [] + summary: |- + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + tags: + - fake + x-contentType: application/x-www-form-urlencoded + x-accepts: application/json + x-tags: + - tag: fake + /fake/outer/number: + post: + description: Test serialization of outer number types + operationId: fakeOuterNumberSerialize + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterNumber' + description: Input number as post body + required: false + responses: + "200": + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterNumber' + description: Output number + tags: + - fake + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: '*/*' + x-tags: + - tag: fake + /fake/outer/string: + post: + description: Test serialization of outer string types + operationId: fakeOuterStringSerialize + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterString' + description: Input string as post body + required: false + responses: + "200": + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterString' + description: Output string + tags: + - fake + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: '*/*' + x-tags: + - tag: fake + /fake/outer/boolean: + post: + description: Test serialization of outer boolean types + operationId: fakeOuterBooleanSerialize + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterBoolean' + description: Input boolean as post body + required: false + responses: + "200": + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterBoolean' + description: Output boolean + tags: + - fake + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: '*/*' + x-tags: + - tag: fake + /fake/outer/composite: + post: + description: Test serialization of object with outer number type + operationId: fakeOuterCompositeSerialize + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterComposite' + description: Input composite as post body + required: false + responses: + "200": + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterComposite' + description: Output composite + tags: + - fake + x-codegen-request-body-name: body + x-contentType: '*/*' + x-accepts: '*/*' + x-tags: + - tag: fake + /fake/jsonFormData: + get: + operationId: testJsonFormData + requestBody: + content: + application/x-www-form-urlencoded: + schema: + properties: + param: + description: field1 + type: string + param2: + description: field2 + type: string + required: + - param + - param2 + required: true + responses: + "200": + content: {} + description: successful operation + summary: test json serialization of form data + tags: + - fake + x-contentType: application/x-www-form-urlencoded + x-accepts: application/json + x-tags: + - tag: fake + /fake/inline-additionalProperties: + post: + operationId: testInlineAdditionalProperties + requestBody: + content: + application/json: + schema: + additionalProperties: + type: string + type: object + description: request body + required: true + responses: + "200": + content: {} + description: successful operation + summary: test inline additionalProperties + tags: + - fake + x-codegen-request-body-name: param + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: fake + /fake/body-with-query-params: + put: + operationId: testBodyWithQueryParams + parameters: + - in: query + name: query + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + required: true + responses: + "200": + content: {} + description: Success + tags: + - fake + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: fake + /fake/create_xml_item: + post: + description: this route creates an XmlItem + operationId: createXmlItem + requestBody: + content: + application/xml: + schema: + $ref: '#/components/schemas/XmlItem' + application/xml; charset=utf-8: + schema: + $ref: '#/components/schemas/XmlItem' + application/xml; charset=utf-16: + schema: + $ref: '#/components/schemas/XmlItem' + text/xml: + schema: + $ref: '#/components/schemas/XmlItem' + text/xml; charset=utf-8: + schema: + $ref: '#/components/schemas/XmlItem' + text/xml; charset=utf-16: + schema: + $ref: '#/components/schemas/XmlItem' + description: XmlItem Body + required: true + responses: + "200": + content: {} + description: successful operation + summary: creates an XmlItem + tags: + - fake + x-codegen-request-body-name: XmlItem + x-contentType: application/xml + x-accepts: application/json + x-tags: + - tag: fake + /another-fake/dummy: + patch: + description: To test special tags and operation ID starting with number + operationId: 123_test_@#$%_special_tags + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: client model + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: successful operation + summary: To test special tags + tags: + - $another-fake? + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: $another-fake? + /fake/body-with-file-schema: + put: + description: For this test, the body for this request much reference a schema + named `File`. + operationId: testBodyWithFileSchema + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/FileSchemaTestClass' + required: true + responses: + "200": + content: {} + description: Success + tags: + - fake + x-codegen-request-body-name: body + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: fake + /fake/test-query-parameters: + put: + description: To test the collection format in query parameters + operationId: testQueryParameterCollectionFormat + parameters: + - explode: false + in: query + name: pipe + required: true + schema: + items: + type: string + type: array + style: form + - in: query + name: ioutil + required: true + schema: + items: + type: string + type: array + - in: query + name: http + required: true + schema: + items: + type: string + type: array + style: spaceDelimited + - explode: false + in: query + name: url + required: true + schema: + items: + type: string + type: array + style: form + - explode: true + in: query + name: context + required: true + schema: + items: + type: string + type: array + style: form + responses: + "200": + content: {} + description: Success + tags: + - fake + x-accepts: application/json + x-tags: + - tag: fake + /fake/{petId}/uploadImageWithRequiredFile: + post: + operationId: uploadFileWithRequiredFile + parameters: + - description: ID of pet to update + in: path + name: petId + required: true + schema: + format: int64 + type: integer + requestBody: + content: + multipart/form-data: + schema: + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + requiredFile: + description: file to upload + format: binary + type: string + required: + - requiredFile + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an image (required) + tags: + - pet + x-contentType: multipart/form-data + x-accepts: application/json + x-tags: + - tag: pet +components: + schemas: + Order: + 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 + type: object + xml: + name: Order + Category: + example: + name: default-name + id: 6 + properties: + id: + format: int64 + type: integer + name: + default: default-name + type: string + required: + - name + type: object + xml: + name: Category + User: + example: + firstName: firstName + lastName: lastName + password: password + userStatus: 6 + phone: phone + id: 0 + email: email + username: username + properties: + id: + format: int64 + type: integer + x-is-unique: true + 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 + type: object + xml: + name: User + Tag: + example: + name: name + id: 1 + properties: + id: + format: int64 + type: integer + name: + type: string + type: object + xml: + name: Tag + Pet: + example: + photoUrls: + - photoUrls + - photoUrls + name: doggie + id: 0 + category: + name: default-name + id: 6 + tags: + - name: name + id: 1 + - name: name + id: 1 + status: available + properties: + id: + format: int64 + type: integer + x-is-unique: true + category: + $ref: '#/components/schemas/Category' + name: + example: doggie + type: string + photoUrls: + items: + type: string + type: array + uniqueItems: true + xml: + name: photoUrl + wrapped: true + tags: + items: + $ref: '#/components/schemas/Tag' + type: array + xml: + name: tag + wrapped: true + status: + description: pet status in the store + enum: + - available + - pending + - sold + type: string + required: + - name + - photoUrls + type: object + xml: + name: Pet + ApiResponse: + example: + code: 0 + type: type + message: message + properties: + code: + format: int32 + type: integer + type: + type: string + message: + type: string + type: object + $special[model.name]: + properties: + $special[property.name]: + format: int64 + type: integer + type: object + xml: + name: $special[model.name] + Return: + description: Model for testing reserved words + properties: + return: + format: int32 + type: integer + type: object + xml: + name: Return + Name: + description: Model for testing model name same as property name + properties: + name: + format: int32 + type: integer + snake_case: + format: int32 + readOnly: true + type: integer + property: + type: string + "123Number": + readOnly: true + type: integer + required: + - name + type: object + xml: + name: Name + "200_response": + description: Model for testing model name starting with number + properties: + name: + format: int32 + type: integer + class: + type: string + type: object + xml: + name: Name + ClassModel: + description: Model for testing model with "_class" property + properties: + _class: + type: string + type: object + Dog: + allOf: + - $ref: '#/components/schemas/Animal' + - $ref: '#/components/schemas/Dog_allOf' + Cat: + allOf: + - $ref: '#/components/schemas/Animal' + - $ref: '#/components/schemas/Cat_allOf' + BigCat: + allOf: + - $ref: '#/components/schemas/Cat' + - $ref: '#/components/schemas/BigCat_allOf' + Animal: + discriminator: + propertyName: className + properties: + className: + type: string + color: + default: red + type: string + required: + - className + type: object + AnimalFarm: + items: + $ref: '#/components/schemas/Animal' + type: array + format_test: + properties: + integer: + maximum: 1E+2 + minimum: 1E+1 + type: integer + int32: + format: int32 + maximum: 2E+2 + minimum: 2E+1 + type: integer + int64: + format: int64 + type: integer + number: + maximum: 543.2 + minimum: 32.1 + type: number + float: + format: float + maximum: 987.6 + minimum: 54.3 + type: number + double: + format: double + maximum: 123.4 + minimum: 67.8 + type: number + string: + pattern: /[a-z]/i + type: string + byte: + format: byte + pattern: ^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$ + type: string + binary: + format: binary + type: string + date: + format: date + type: string + dateTime: + format: date-time + type: string + uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + type: string + password: + format: password + maxLength: 64 + minLength: 10 + type: string + BigDecimal: + format: number + type: string + required: + - byte + - date + - number + - password + type: object + EnumClass: + default: -efg + enum: + - _abc + - -efg + - (xyz) + type: string + Enum_Test: + properties: + enum_string: + enum: + - UPPER + - lower + - "" + type: string + enum_string_required: + enum: + - UPPER + - lower + - "" + type: string + enum_integer: + enum: + - 1 + - -1 + format: int32 + type: integer + enum_number: + enum: + - 1.1 + - -1.2 + format: double + type: number + outerEnum: + $ref: '#/components/schemas/OuterEnum' + required: + - enum_string_required + type: object + AdditionalPropertiesClass: + properties: + map_string: + additionalProperties: + type: string + type: object + map_number: + additionalProperties: + type: number + type: object + map_integer: + additionalProperties: + type: integer + type: object + map_boolean: + additionalProperties: + type: boolean + type: object + map_array_integer: + additionalProperties: + items: + type: integer + type: array + type: object + map_array_anytype: + additionalProperties: + items: + properties: {} + type: object + type: array + type: object + map_map_string: + additionalProperties: + additionalProperties: + type: string + type: object + type: object + map_map_anytype: + additionalProperties: + additionalProperties: + properties: {} + type: object + type: object + type: object + anytype_1: + properties: {} + type: object + anytype_2: + type: object + anytype_3: + properties: {} + type: object + type: object + AdditionalPropertiesString: + additionalProperties: + type: string + properties: + name: + type: string + type: object + AdditionalPropertiesInteger: + additionalProperties: + type: integer + properties: + name: + type: string + type: object + AdditionalPropertiesNumber: + additionalProperties: + type: number + properties: + name: + type: string + type: object + AdditionalPropertiesBoolean: + additionalProperties: + type: boolean + properties: + name: + type: string + type: object + AdditionalPropertiesArray: + additionalProperties: + items: + properties: {} + type: object + type: array + properties: + name: + type: string + type: object + AdditionalPropertiesObject: + additionalProperties: + additionalProperties: + properties: {} + type: object + type: object + properties: + name: + type: string + type: object + AdditionalPropertiesAnyType: + additionalProperties: + properties: {} + type: object + properties: + name: + type: string + type: object + MixedPropertiesAndAdditionalPropertiesClass: + properties: + uuid: + format: uuid + type: string + dateTime: + format: date-time + type: string + map: + additionalProperties: + $ref: '#/components/schemas/Animal' + type: object + type: object + List: + properties: + "123-list": + type: string + type: object + Client: + example: + client: client + properties: + client: + type: string + type: object + ReadOnlyFirst: + properties: + bar: + readOnly: true + type: string + baz: + type: string + type: object + hasOnlyReadOnly: + properties: + bar: + readOnly: true + type: string + foo: + readOnly: true + type: string + type: object + Capitalization: + properties: + smallCamel: + type: string + CapitalCamel: + type: string + small_Snake: + type: string + Capital_Snake: + type: string + SCA_ETH_Flow_Points: + type: string + ATT_NAME: + description: | + Name of the pet + type: string + type: object + MapTest: + properties: + map_map_of_string: + additionalProperties: + additionalProperties: + type: string + type: object + type: object + map_of_enum_string: + additionalProperties: + enum: + - UPPER + - lower + type: string + type: object + direct_map: + additionalProperties: + type: boolean + type: object + indirect_map: + additionalProperties: + type: boolean + type: object + type: object + ArrayTest: + properties: + array_of_string: + items: + type: string + type: array + array_array_of_integer: + items: + items: + format: int64 + type: integer + type: array + type: array + array_array_of_model: + items: + items: + $ref: '#/components/schemas/ReadOnlyFirst' + type: array + type: array + type: object + NumberOnly: + properties: + JustNumber: + type: number + type: object + ArrayOfNumberOnly: + properties: + ArrayNumber: + items: + type: number + type: array + type: object + ArrayOfArrayOfNumberOnly: + properties: + ArrayArrayNumber: + items: + items: + type: number + type: array + type: array + type: object + EnumArrays: + properties: + just_symbol: + enum: + - '>=' + - $ + type: string + array_enum: + items: + enum: + - fish + - crab + type: string + type: array + type: object + OuterEnum: + enum: + - placed + - approved + - delivered + type: string + OuterComposite: + example: + my_string: my_string + my_number: 0.8008281904610115 + my_boolean: true + properties: + my_number: + type: number + my_string: + type: string + my_boolean: + type: boolean + x-codegen-body-parameter-name: boolean_post_body + type: object + OuterNumber: + type: number + OuterString: + type: string + OuterBoolean: + type: boolean + x-codegen-body-parameter-name: boolean_post_body + StringBooleanMap: + additionalProperties: + type: boolean + type: object + FileSchemaTestClass: + example: + file: + sourceURI: sourceURI + files: + - sourceURI: sourceURI + - sourceURI: sourceURI + properties: + file: + $ref: '#/components/schemas/File' + files: + items: + $ref: '#/components/schemas/File' + type: array + type: object + File: + description: Must be named `File` for test. + example: + sourceURI: sourceURI + properties: + sourceURI: + description: Test capitalization + type: string + type: object + TypeHolderDefault: + properties: + string_item: + default: what + type: string + number_item: + type: number + integer_item: + type: integer + bool_item: + default: true + type: boolean + array_item: + items: + type: integer + type: array + required: + - array_item + - bool_item + - integer_item + - number_item + - string_item + type: object + TypeHolderExample: + properties: + string_item: + example: what + type: string + number_item: + example: 1.234 + type: number + float_item: + example: 1.234 + format: float + type: number + integer_item: + example: -2 + type: integer + bool_item: + example: true + type: boolean + array_item: + example: + - 0 + - 1 + - 2 + - 3 + items: + type: integer + type: array + required: + - array_item + - bool_item + - float_item + - integer_item + - number_item + - string_item + type: object + XmlItem: + properties: + attribute_string: + example: string + type: string + xml: + attribute: true + attribute_number: + example: 1.234 + type: number + xml: + attribute: true + attribute_integer: + example: -2 + type: integer + xml: + attribute: true + attribute_boolean: + example: true + type: boolean + xml: + attribute: true + wrapped_array: + items: + type: integer + type: array + xml: + wrapped: true + name_string: + example: string + type: string + xml: + name: xml_name_string + name_number: + example: 1.234 + type: number + xml: + name: xml_name_number + name_integer: + example: -2 + type: integer + xml: + name: xml_name_integer + name_boolean: + example: true + type: boolean + xml: + name: xml_name_boolean + name_array: + items: + type: integer + xml: + name: xml_name_array_item + type: array + name_wrapped_array: + items: + type: integer + xml: + name: xml_name_wrapped_array_item + type: array + xml: + name: xml_name_wrapped_array + wrapped: true + prefix_string: + example: string + type: string + xml: + prefix: ab + prefix_number: + example: 1.234 + type: number + xml: + prefix: cd + prefix_integer: + example: -2 + type: integer + xml: + prefix: ef + prefix_boolean: + example: true + type: boolean + xml: + prefix: gh + prefix_array: + items: + type: integer + xml: + prefix: ij + type: array + prefix_wrapped_array: + items: + type: integer + xml: + prefix: mn + type: array + xml: + prefix: kl + wrapped: true + namespace_string: + example: string + type: string + xml: + namespace: http://a.com/schema + namespace_number: + example: 1.234 + type: number + xml: + namespace: http://b.com/schema + namespace_integer: + example: -2 + type: integer + xml: + namespace: http://c.com/schema + namespace_boolean: + example: true + type: boolean + xml: + namespace: http://d.com/schema + namespace_array: + items: + type: integer + xml: + namespace: http://e.com/schema + type: array + namespace_wrapped_array: + items: + type: integer + xml: + namespace: http://g.com/schema + type: array + xml: + namespace: http://f.com/schema + wrapped: true + prefix_ns_string: + example: string + type: string + xml: + namespace: http://a.com/schema + prefix: a + prefix_ns_number: + example: 1.234 + type: number + xml: + namespace: http://b.com/schema + prefix: b + prefix_ns_integer: + example: -2 + type: integer + xml: + namespace: http://c.com/schema + prefix: c + prefix_ns_boolean: + example: true + type: boolean + xml: + namespace: http://d.com/schema + prefix: d + prefix_ns_array: + items: + type: integer + xml: + namespace: http://e.com/schema + prefix: e + type: array + prefix_ns_wrapped_array: + items: + type: integer + xml: + namespace: http://g.com/schema + prefix: g + type: array + xml: + namespace: http://f.com/schema + prefix: f + wrapped: true + type: object + xml: + namespace: http://a.com/schema + prefix: pre + Dog_allOf: + properties: + breed: + type: string + type: object + Cat_allOf: + properties: + declawed: + type: boolean + type: object + BigCat_allOf: + properties: + kind: + enum: + - lions + - tigers + - leopards + - jaguars + 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 + api_key_query: + in: query + name: api_key_query + type: apiKey + http_basic_test: + scheme: basic + type: http +x-original-swagger-version: "2.0" diff --git a/samples/openapi3/server/petstore/springboot/.openapi-generator-ignore b/samples/openapi3/server/petstore/springboot/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot/.openapi-generator-ignore @@ -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 diff --git a/samples/openapi3/server/petstore/springboot/.openapi-generator/FILES b/samples/openapi3/server/petstore/springboot/.openapi-generator/FILES new file mode 100644 index 000000000000..7de4a0d86c09 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot/.openapi-generator/FILES @@ -0,0 +1,20 @@ +README.md +pom.xml +src/main/java/org/openapitools/OpenAPI2SpringBoot.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/StoreApi.java +src/main/java/org/openapitools/api/StoreApiController.java +src/main/java/org/openapitools/api/UserApi.java +src/main/java/org/openapitools/api/UserApiController.java +src/main/java/org/openapitools/configuration/HomeController.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 diff --git a/samples/openapi3/server/petstore/springboot/.openapi-generator/VERSION b/samples/openapi3/server/petstore/springboot/.openapi-generator/VERSION new file mode 100644 index 000000000000..0984c4c1ad21 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot/.openapi-generator/VERSION @@ -0,0 +1 @@ +5.4.0-SNAPSHOT \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot/README.md b/samples/openapi3/server/petstore/springboot/README.md new file mode 100644 index 000000000000..5bbe4a495d99 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot/README.md @@ -0,0 +1,16 @@ +# 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. + +Start your server as a simple java application + +You can view the api documentation in swagger-ui by pointing to +http://localhost:8080/ + +Change default port value in application.properties \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot/pom.xml b/samples/openapi3/server/petstore/springboot/pom.xml new file mode 100644 index 000000000000..d0efb3028cea --- /dev/null +++ b/samples/openapi3/server/petstore/springboot/pom.xml @@ -0,0 +1,71 @@ + + 4.0.0 + org.openapitools.openapi3 + springboot + jar + springboot + 1.0.0-SNAPSHOT + + 1.8 + ${java.version} + ${java.version} + 2.1.11 + + + org.springframework.boot + spring-boot-starter-parent + 2.5.8 + + + src/main/java + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.data + spring-data-commons + + + io.swagger.core.v3 + swagger-annotations + ${swagger-core-version} + + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + + + org.openapitools + jackson-databind-nullable + 0.2.2 + + + + org.springframework.boot + spring-boot-starter-validation + + + com.fasterxml.jackson.core + jackson-databind + + + diff --git a/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..cb088f451935 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,63 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.Module; +import org.openapitools.jackson.nullable.JsonNullableModule; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.ExitCodeGenerator; +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.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenAPI2SpringBoot implements CommandLineRunner { + + @Override + public void run(String... arg0) throws Exception { + if (arg0.length > 0 && arg0[0].equals("exitcode")) { + throw new ExitException(); + } + } + + public static void main(String[] args) throws Exception { + new SpringApplication(OpenAPI2SpringBoot.class).run(args); + } + + static class ExitException extends RuntimeException implements ExitCodeGenerator { + private static final long serialVersionUID = 1L; + + @Override + public int getExitCode() { + return 10; + } + + } + + @Bean + public WebMvcConfigurer webConfigurer() { + return new WebMvcConfigurer() { + /*@Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") + .allowedOrigins("*") + .allowedMethods("*") + .allowedHeaders("Content-Type"); + }*/ + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("/swagger-ui/**").addResourceLocations("classpath:/META-INF/resources/webjars/swagger-ui/3.14.2/"); + } + }; + } + + @Bean + public Module jsonNullableModule() { + return new JsonNullableModule(); + } + +} diff --git a/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/RFC3339DateFormat.java b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/RFC3339DateFormat.java new file mode 100644 index 000000000000..bcd3936d8b34 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/RFC3339DateFormat.java @@ -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; + } +} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/api/ApiUtil.java b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/api/ApiUtil.java new file mode 100644 index 000000000000..1245b1dd0ccf --- /dev/null +++ b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/api/ApiUtil.java @@ -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); + } + } +} diff --git a/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/api/PetApi.java b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/api/PetApi.java new file mode 100644 index 000000000000..0bec586d6930 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/api/PetApi.java @@ -0,0 +1,382 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "pet", description = "the pet API") +public interface PetApi { + + default Optional 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) + */ + @Operation( + summary = "Add a new pet to the store", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "405", description = "Invalid input") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet", + produces = { "application/xml", "application/json" }, + consumes = { "application/json", "application/xml" } + ) + default ResponseEntity addPet( + @Parameter(name = "Pet", description = "Pet object that needs to be added to the store", required = true, schema = @Schema(description = "")) @Valid @RequestBody 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 = " 123456789 doggie aeiou aeiou "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.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) + */ + @Operation( + summary = "Deletes a pet", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid pet value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/pet/{petId}" + ) + default ResponseEntity deletePet( + @Parameter(name = "petId", description = "Pet id to delete", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "api_key", description = "", schema = @Schema(description = "")) @RequestHeader(value = "api_key", required = false) String apiKey + ) { + return new ResponseEntity<>(HttpStatus.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) + */ + @Operation( + summary = "Finds Pets by status", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid status value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/findByStatus", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity> findPetsByStatus( + @NotNull @Parameter(name = "status", description = "Status values that need to be considered for filter", required = true, schema = @Schema(description = "", allowableValues = { "available", "pending", "sold" })) @Valid @RequestParam(value = "status", required = true) List 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\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + String exampleString = " 123456789 doggie aeiou aeiou "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.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 + */ + @Operation( + summary = "Finds Pets by tags", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid tag value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/findByTags", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity> findPetsByTags( + @NotNull @Parameter(name = "tags", description = "Tags to filter by", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "tags", required = true) List 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\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + String exampleString = " 123456789 doggie aeiou aeiou "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.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) + */ + @Operation( + summary = "Find pet by ID", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/{petId}", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity getPetById( + @Parameter(name = "petId", description = "ID of pet to return", required = true, schema = @Schema(description = "")) @PathVariable("petId") 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 = " 123456789 doggie aeiou aeiou "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.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) + */ + @Operation( + summary = "Update an existing pet", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found"), + @ApiResponse(responseCode = "405", description = "Validation exception") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/pet", + produces = { "application/xml", "application/json" }, + consumes = { "application/json", "application/xml" } + ) + default ResponseEntity updatePet( + @Parameter(name = "Pet", description = "Pet object that needs to be added to the store", required = true, schema = @Schema(description = "")) @Valid @RequestBody 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 = " 123456789 doggie aeiou aeiou "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.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) + */ + @Operation( + summary = "Updates a pet in the store with form data", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "405", description = "Invalid input") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet/{petId}", + consumes = { "application/x-www-form-urlencoded" } + ) + default ResponseEntity updatePetWithForm( + @Parameter(name = "petId", description = "ID of pet that needs to be updated", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "name", description = "Updated name of the pet", schema = @Schema(description = "")) @Valid @RequestPart(value = "name", required = false) String name, + @Parameter(name = "status", description = "Updated status of the pet", schema = @Schema(description = "")) @Valid @RequestPart(value = "status", required = false) String status + ) { + return new ResponseEntity<>(HttpStatus.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) + */ + @Operation( + summary = "uploads an image", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ModelApiResponse.class))) + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet/{petId}/uploadImage", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) + default ResponseEntity uploadFile( + @Parameter(name = "petId", description = "ID of pet to update", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "additionalMetadata", description = "Additional data to pass to server", schema = @Schema(description = "")) @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @Parameter(name = "file", description = "file to upload", schema = @Schema(description = "")) @RequestPart(value = "file", required = false) 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; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/api/PetApiController.java b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/api/PetApiController.java new file mode 100644 index 000000000000..e72c57e3cbec --- /dev/null +++ b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/api/PetApiController.java @@ -0,0 +1,24 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.context.request.NativeWebRequest; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class PetApiController implements PetApi { + + private final NativeWebRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public PetApiController(NativeWebRequest request) { + this.request = request; + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/api/StoreApi.java b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/api/StoreApi.java new file mode 100644 index 000000000000..98cbb475200d --- /dev/null +++ b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/api/StoreApi.java @@ -0,0 +1,184 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "store", description = "the store API") +public interface StoreApi { + + default Optional 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) + */ + @Operation( + summary = "Delete purchase order by ID", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/store/order/{orderId}" + ) + default ResponseEntity deleteOrder( + @Parameter(name = "orderId", description = "ID of the order that needs to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("orderId") String orderId + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * GET /store/inventory : Returns pet inventories by status + * Returns a map of status codes to quantities + * + * @return successful operation (status code 200) + */ + @Operation( + summary = "Returns pet inventories by status", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Map.class))) + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/store/inventory", + produces = { "application/json" } + ) + default ResponseEntity> getInventory( + + ) { + return new ResponseEntity<>(HttpStatus.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 generated 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) + */ + @Operation( + summary = "Find purchase order by ID", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/store/order/{orderId}", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity getOrderById( + @Min(1L) @Max(5L) @Parameter(name = "orderId", description = "ID of pet that needs to be fetched", required = true, schema = @Schema(description = "")) @PathVariable("orderId") 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 = " 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.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) + */ + @Operation( + summary = "Place an order for a pet", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid Order") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/store/order", + produces = { "application/xml", "application/json" }, + consumes = { "application/json" } + ) + default ResponseEntity placeOrder( + @Parameter(name = "Order", description = "order placed for purchasing the pet", required = true, schema = @Schema(description = "")) @Valid @RequestBody 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 = " 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/api/StoreApiController.java b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/api/StoreApiController.java new file mode 100644 index 000000000000..1293b5c8f6e4 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/api/StoreApiController.java @@ -0,0 +1,24 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.context.request.NativeWebRequest; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class StoreApiController implements StoreApi { + + private final NativeWebRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public StoreApiController(NativeWebRequest request) { + this.request = request; + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/api/UserApi.java b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/api/UserApi.java new file mode 100644 index 000000000000..899416135fc5 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/api/UserApi.java @@ -0,0 +1,294 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.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.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "user", description = "the user API") +public interface UserApi { + + default Optional 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) + */ + @Operation( + summary = "Create user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user", + consumes = { "application/json" } + ) + default ResponseEntity createUser( + @Parameter(name = "User", description = "Created user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody User user + ) { + return new ResponseEntity<>(HttpStatus.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) + */ + @Operation( + summary = "Creates list of users with given input array", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user/createWithArray", + consumes = { "application/json" } + ) + default ResponseEntity createUsersWithArrayInput( + @Parameter(name = "User", description = "List of user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody List user + ) { + return new ResponseEntity<>(HttpStatus.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) + */ + @Operation( + summary = "Creates list of users with given input array", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user/createWithList", + consumes = { "application/json" } + ) + default ResponseEntity createUsersWithListInput( + @Parameter(name = "User", description = "List of user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody List user + ) { + return new ResponseEntity<>(HttpStatus.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) + */ + @Operation( + summary = "Delete user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/user/{username}" + ) + default ResponseEntity deleteUser( + @Parameter(name = "username", description = "The name that needs to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("username") String username + ) { + return new ResponseEntity<>(HttpStatus.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) + */ + @Operation( + summary = "Get user by user name", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = User.class))), + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/{username}", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity getUserByName( + @Parameter(name = "username", description = "The name that needs to be fetched. Use user1 for testing.", required = true, schema = @Schema(description = "")) @PathVariable("username") 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 = " 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123 "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.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) + */ + @Operation( + summary = "Logs user into the system", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "400", description = "Invalid username/password supplied") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/login", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity loginUser( + @NotNull @Pattern(regexp = "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") @Parameter(name = "username", description = "The user name for login", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "username", required = true) String username, + @NotNull @Parameter(name = "password", description = "The password for login in clear text", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "password", required = true) String password + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * GET /user/logout : Logs out current logged in user session + * + * @return successful operation (status code 200) + */ + @Operation( + summary = "Logs out current logged in user session", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/logout" + ) + default ResponseEntity logoutUser( + + ) { + return new ResponseEntity<>(HttpStatus.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) + */ + @Operation( + summary = "Updated user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid user supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/user/{username}", + consumes = { "application/json" } + ) + default ResponseEntity updateUser( + @Parameter(name = "username", description = "name that need to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("username") String username, + @Parameter(name = "User", description = "Updated user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody User user + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/api/UserApiController.java b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/api/UserApiController.java new file mode 100644 index 000000000000..3f6c4d9a2d6f --- /dev/null +++ b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/api/UserApiController.java @@ -0,0 +1,24 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.context.request.NativeWebRequest; +import java.util.Optional; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class UserApiController implements UserApi { + + private final NativeWebRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public UserApiController(NativeWebRequest request) { + this.request = request; + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/configuration/HomeController.java b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/configuration/HomeController.java new file mode 100644 index 000000000000..34bae16b8986 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/configuration/HomeController.java @@ -0,0 +1,53 @@ +package org.openapitools.configuration; + +import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.core.io.Resource; +import org.springframework.stereotype.Controller; +import org.springframework.util.StreamUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.Charset; + +/** + * Home redirection to OpenAPI api documentation + */ +@Controller +public class HomeController { + + private static YAMLMapper yamlMapper = new YAMLMapper(); + + @Value("classpath:/openapi.yaml") + private Resource openapi; + + @Bean + public String openapiContent() throws IOException { + try(InputStream is = openapi.getInputStream()) { + return StreamUtils.copyToString(is, Charset.defaultCharset()); + } + } + + @GetMapping(value = "/openapi.yaml", produces = "application/vnd.oai.openapi") + @ResponseBody + public String openapiYaml() throws IOException { + return openapiContent(); + } + + @GetMapping(value = "/openapi.json", produces = "application/json") + @ResponseBody + public Object openapiJson() throws IOException { + return yamlMapper.readValue(openapiContent(), Object.class); + } + + @RequestMapping("/") + public String index() { + return "redirect:swagger-ui/index.html?url=../openapi.json"; + } + + +} diff --git a/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/model/Category.java b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/model/Category.java new file mode 100644 index 000000000000..463de0ed39a3 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/model/Category.java @@ -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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * A category for a pet + */ +@Schema(name = "Category",description = "A category for a pet") +@javax.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "name", defaultValue = "") + +@Pattern(regexp = "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") + 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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/model/ModelApiResponse.java b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/model/ModelApiResponse.java new file mode 100644 index 000000000000..0ef610e38f01 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/model/ModelApiResponse.java @@ -0,0 +1,134 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * Describes the result of uploading an image resource + */ +@Schema(name = "ApiResponse",description = "Describes the result of uploading an image resource") +@javax.annotation.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 + */ + @Schema(name = "code", defaultValue = "") + + + 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 + */ + @Schema(name = "type", defaultValue = "") + + + 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 + */ + @Schema(name = "message", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/model/Order.java b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/model/Order.java new file mode 100644 index 000000000000..528598b79ea7 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/model/Order.java @@ -0,0 +1,250 @@ +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 java.time.OffsetDateTime; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * An order for a pets from the pet store + */ +@Schema(name = "Order",description = "An order for a pets from the pet store") +@javax.annotation.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") + @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "petId", defaultValue = "") + + + 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 + */ + @Schema(name = "quantity", defaultValue = "") + + + 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 + */ + @Schema(name = "shipDate", defaultValue = "") + + @Valid + + 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 + */ + @Schema(name = "status", defaultValue = "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 + */ + @Schema(name = "complete", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/model/Pet.java b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/model/Pet.java new file mode 100644 index 000000000000..7c2986fea846 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/model/Pet.java @@ -0,0 +1,270 @@ +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 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 io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * A pet for sale in the pet store + */ +@Schema(name = "Pet",description = "A pet for sale in the pet store") +@javax.annotation.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 photoUrls = new ArrayList<>(); + + @JsonProperty("tags") + @Valid + private List 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; + + public Pet id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "category", defaultValue = "") + + @Valid + + 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 + */ + @Schema(name = "name", example = "doggie", required = true, defaultValue = "") + @NotNull + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Pet photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + public Pet addPhotoUrlsItem(String photoUrlsItem) { + this.photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get photoUrls + * @return photoUrls + */ + @Schema(name = "photoUrls", required = true, defaultValue = "") + @NotNull + + + public List getPhotoUrls() { + return photoUrls; + } + + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + public Pet tags(List 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 + */ + @Schema(name = "tags", defaultValue = "") + + @Valid + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * pet status in the store + * @return status + */ + @Schema(name = "status", defaultValue = "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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/model/Tag.java b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/model/Tag.java new file mode 100644 index 000000000000..27166f687a27 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/model/Tag.java @@ -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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * A tag for a pet + */ +@Schema(name = "Tag",description = "A tag for a pet") +@javax.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "name", defaultValue = "") + + + 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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/model/User.java b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/model/User.java new file mode 100644 index 000000000000..ba24f681c1df --- /dev/null +++ b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/model/User.java @@ -0,0 +1,259 @@ +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 org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; + +/** + * A User who is purchasing from the pet store + */ +@Schema(name = "User",description = "A User who is purchasing from the pet store") +@javax.annotation.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 + */ + @Schema(name = "id", defaultValue = "") + + + 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 + */ + @Schema(name = "username", defaultValue = "") + + + 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 + */ + @Schema(name = "firstName", defaultValue = "") + + + 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 + */ + @Schema(name = "lastName", defaultValue = "") + + + 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 + */ + @Schema(name = "email", defaultValue = "") + + + 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 + */ + @Schema(name = "password", defaultValue = "") + + + 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 + */ + @Schema(name = "phone", defaultValue = "") + + + 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 + */ + @Schema(name = "userStatus", defaultValue = "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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot/src/main/resources/application.properties b/samples/openapi3/server/petstore/springboot/src/main/resources/application.properties new file mode 100644 index 000000000000..7e90813e59b2 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot/src/main/resources/application.properties @@ -0,0 +1,3 @@ +server.port=8080 +spring.jackson.date-format=org.openapitools.RFC3339DateFormat +spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false diff --git a/samples/openapi3/server/petstore/springboot/src/main/resources/openapi.yaml b/samples/openapi3/server/petstore/springboot/src/main/resources/openapi.yaml new file mode 100644 index 000000000000..56703dfefb56 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot/src/main/resources/openapi.yaml @@ -0,0 +1,893 @@ +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: + 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-contentType: application/json + x-accepts: application/json + x-tags: + - tag: pet + put: + 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-contentType: 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: + 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: + 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: + $ref: '#/components/requestBodies/inline_object' + content: + application/x-www-form-urlencoded: + schema: + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string + type: object + 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-contentType: application/x-www-form-urlencoded + x-accepts: application/json + x-tags: + - tag: pet + /pet/{petId}/uploadImage: + post: + 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: + $ref: '#/components/requestBodies/inline_object_1' + content: + multipart/form-data: + schema: + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + format: binary + type: string + type: object + 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-contentType: 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: + 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-contentType: 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 generated 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-contentType: application/json + x-accepts: application/json + x-tags: + - tag: user + /user/createWithArray: + post: + 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-contentType: application/json + x-accepts: application/json + x-tags: + - tag: user + /user/createWithList: + post: + 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-contentType: application/json + x-accepts: application/json + x-tags: + - tag: user + /user/login: + get: + 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: + 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: + 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-contentType: 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 + inline_object: + content: + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/inline_object' + inline_object_1: + content: + multipart/form-data: + schema: + $ref: '#/components/schemas/inline_object_1' + 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 + inline_object: + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string + type: object + inline_object_1: + 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 diff --git a/samples/server/petstore/java-play-framework-api-package-override/.openapi-generator/FILES b/samples/server/petstore/java-play-framework-api-package-override/.openapi-generator/FILES index e29e689f2db1..8277211b3920 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/.openapi-generator/FILES +++ b/samples/server/petstore/java-play-framework-api-package-override/.openapi-generator/FILES @@ -20,6 +20,7 @@ app/com/puppies/store/apis/UserApiControllerImpInterface.java app/openapitools/ApiCall.java app/openapitools/ErrorHandler.java app/openapitools/OpenAPIUtils.java +app/openapitools/SecurityAPIUtils.java build.sbt conf/application.conf conf/logback.xml diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/Module.java b/samples/server/petstore/java-play-framework-api-package-override/app/Module.java index bc45d3044605..8003efba7b9e 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/Module.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/Module.java @@ -1,6 +1,7 @@ import com.google.inject.AbstractModule; import com.puppies.store.apis.*; +import openapitools.SecurityAPIUtils; public class Module extends AbstractModule { @@ -9,5 +10,6 @@ protected void configure() { bind(PetApiControllerImpInterface.class).to(PetApiControllerImp.class); bind(StoreApiControllerImpInterface.class).to(StoreApiControllerImp.class); bind(UserApiControllerImpInterface.class).to(UserApiControllerImp.class); + bind(SecurityAPIUtils.class); } } \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiControllerImpInterface.java index 440a4f7e1c87..63401e9cc395 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiControllerImpInterface.java @@ -15,7 +15,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; import javax.validation.constraints.*; @@ -23,47 +25,70 @@ @SuppressWarnings("RedundantThrows") public abstract class PetApiControllerImpInterface { @Inject private Config configuration; + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public Result addPetHttp(Http.Request request, Pet body) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + addPet(request, body); -return ok(); + return ok(); } public abstract void addPet(Http.Request request, Pet body) throws Exception; public Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + deletePet(request, petId, apiKey); -return ok(); + return ok(); } public abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; public Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + List obj = findPetsByStatus(request, status); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); + + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } } - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } public abstract List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; public Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + List obj = findPetsByTags(request, tags); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); + + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } } - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -71,39 +96,57 @@ public Result findPetsByTagsHttp(Http.Request request, @NotNull List tag public Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { Pet obj = getPetById(request, petId); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } public abstract Pet getPetById(Http.Request request, Long petId) throws Exception; public Result updatePetHttp(Http.Request request, Pet body) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + updatePet(request, body); -return ok(); + return ok(); } public abstract void updatePet(Http.Request request, Pet body) throws Exception; public Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + updatePetWithForm(request, petId, name, status); -return ok(); + return ok(); } public abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; public Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiControllerImpInterface.java index dd836401626e..b18fcb34cc81 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiControllerImpInterface.java @@ -14,7 +14,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; import javax.validation.constraints.*; @@ -22,11 +24,12 @@ @SuppressWarnings("RedundantThrows") public abstract class StoreApiControllerImpInterface { @Inject private Config configuration; + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { deleteOrder(request, orderId); -return ok(); + return ok(); } @@ -34,8 +37,9 @@ public Result deleteOrderHttp(Http.Request request, String orderId) throws Excep public Result getInventoryHttp(Http.Request request) throws Exception { Map obj = getInventory(request); -JsonNode result = mapper.valueToTree(obj); -return ok(result); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -43,11 +47,14 @@ public Result getInventoryHttp(Http.Request request) throws Exception { public Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { Order obj = getOrderById(request, orderId); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -55,11 +62,14 @@ public Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderI public Result placeOrderHttp(Http.Request request, Order body) throws Exception { Order obj = placeOrder(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiControllerImpInterface.java index adae1c272395..7f64d626d778 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiControllerImpInterface.java @@ -15,7 +15,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; import javax.validation.constraints.*; @@ -23,11 +25,12 @@ @SuppressWarnings("RedundantThrows") public abstract class UserApiControllerImpInterface { @Inject private Config configuration; + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public Result createUserHttp(Http.Request request, User body) throws Exception { createUser(request, body); -return ok(); + return ok(); } @@ -35,7 +38,7 @@ public Result createUserHttp(Http.Request request, User body) throws Exception { public Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { createUsersWithArrayInput(request, body); -return ok(); + return ok(); } @@ -43,7 +46,7 @@ public Result createUsersWithArrayInputHttp(Http.Request request, List bod public Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { createUsersWithListInput(request, body); -return ok(); + return ok(); } @@ -51,7 +54,7 @@ public Result createUsersWithListInputHttp(Http.Request request, List body public Result deleteUserHttp(Http.Request request, String username) throws Exception { deleteUser(request, username); -return ok(); + return ok(); } @@ -59,11 +62,14 @@ public Result deleteUserHttp(Http.Request request, String username) throws Excep public Result getUserByNameHttp(Http.Request request, String username) throws Exception { User obj = getUserByName(request, username); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -71,8 +77,9 @@ public Result getUserByNameHttp(Http.Request request, String username) throws Ex public Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { String obj = loginUser(request, username, password); -JsonNode result = mapper.valueToTree(obj); -return ok(result); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -80,7 +87,7 @@ public Result loginUserHttp(Http.Request request, @NotNull String username, @Not public Result logoutUserHttp(Http.Request request) throws Exception { logoutUser(request); -return ok(); + return ok(); } @@ -88,7 +95,7 @@ public Result logoutUserHttp(Http.Request request) throws Exception { public Result updateUserHttp(Http.Request request, String username, User body) throws Exception { updateUser(request, username, body); -return ok(); + return ok(); } diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/openapitools/SecurityAPIUtils.java b/samples/server/petstore/java-play-framework-api-package-override/app/openapitools/SecurityAPIUtils.java new file mode 100644 index 000000000000..854be87f65a8 --- /dev/null +++ b/samples/server/petstore/java-play-framework-api-package-override/app/openapitools/SecurityAPIUtils.java @@ -0,0 +1,165 @@ +package openapitools; + +import com.auth0.jwk.Jwk; +import com.auth0.jwk.UrlJwkProvider; +import com.auth0.jwt.JWT; +import com.auth0.jwt.JWTVerifier; +import com.auth0.jwt.algorithms.Algorithm; +import com.auth0.jwt.interfaces.DecodedJWT; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import org.apache.http.HttpHeaders; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.NameValuePair; +import org.apache.http.client.HttpClient; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; +import play.mvc.Http; + +import java.net.URL; +import java.security.PublicKey; +import java.security.interfaces.RSAPublicKey; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; + +@Singleton +public class SecurityAPIUtils { + private final String bearerPrefix = "Bearer "; + private final ObjectMapper mapper; + + private boolean useOnlineValidation = false; + + // Online validation + private HashMap tokenIntrospectEndpoints = new HashMap<>(); + private final String clientId; + private final String clientSecret; + + // Offline validation + private HashMap jwksEndpoints = new HashMap<>(); + private String tokenKeyId = ""; + private JWTVerifier tokenVerifier; //Reusable verifier instance until tokenKeyId changes. + + @Inject + SecurityAPIUtils(Config configuration) { + mapper = new ObjectMapper(); + + clientId = configuration.hasPath("oauth.clientId") ? configuration.getString("oauth.clientId") : ""; + clientSecret = configuration.hasPath("oauth.clientSecret") ? configuration.getString("oauth.clientSecret") : ""; + + tokenIntrospectEndpoints.put("petstore_auth", ""); + + jwksEndpoints.put("petstore_auth", ""); + } + + private boolean isRequestTokenValidByOnlineCheck(Http.Request request, String securityMethodName) { + try { + Optional authToken = request.getHeaders().get(HttpHeaders.AUTHORIZATION); + + if (authToken.isPresent()) { + String tokenWithoutBearerPrefix = authToken.get().substring(bearerPrefix.length()); + + HttpClientBuilder builder = HttpClientBuilder.create(); + HttpClient httpClient = builder.build(); + HttpPost httppost = new HttpPost(this.tokenIntrospectEndpoints.get(securityMethodName)); + + List params = new ArrayList<>(); + params.add(new BasicNameValuePair("token", tokenWithoutBearerPrefix)); + params.add(new BasicNameValuePair("client_id", clientId)); + params.add(new BasicNameValuePair("client_secret", clientSecret)); + httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); + + HttpResponse response = httpClient.execute(httppost); + String responseJsonString = EntityUtils.toString(response.getEntity()); + HashMap responseJsonObject = mapper.readValue(responseJsonString, HashMap.class); + + return response.getStatusLine().getStatusCode() == HttpStatus.SC_OK && (boolean) responseJsonObject.get("active"); + } + } catch (Exception exception) { + return false; + } + + return false; + } + + private boolean isRequestTokenValidByOfflineCheck(Http.Request request, String securityMethodName) { + try { + Optional authHeader = request.getHeaders().get(HttpHeaders.AUTHORIZATION); + + if (authHeader.isPresent()) { + String bearerToken = authHeader.get().substring(bearerPrefix.length()); + return isTokenValidByOfflineCheck(bearerToken, securityMethodName); + } + } catch (Exception exception) { + return false; + } + + return false; + } + + public boolean isTokenValidByOfflineCheck(String bearerToken, String securityMethodName) { + try { + DecodedJWT jwt = JWT.decode(bearerToken); + String issuer = jwt.getIssuer(); + String keyId = jwt.getKeyId(); + if (!tokenKeyId.equals(keyId)) { + if (securityMethodName == null) { + securityMethodName = jwksEndpoints.keySet().stream().findFirst().get(); + } + + Jwk jwk = new UrlJwkProvider(new URL(this.jwksEndpoints.get(securityMethodName))).get(keyId); + final PublicKey publicKey = jwk.getPublicKey(); + + if (!(publicKey instanceof RSAPublicKey)) { + throw new IllegalArgumentException(String.format("Key with ID %s was found in JWKS but is not a RSA-key.", keyId)); + } + + Algorithm algorithm = Algorithm.RSA256((RSAPublicKey) publicKey, null); + tokenVerifier = JWT.require(algorithm) + .withIssuer(issuer) + .build(); + tokenKeyId = keyId; + } + + DecodedJWT verifiedJWT = tokenVerifier.verify(bearerToken); + + return true; + } catch (Exception exception) { + return false; + } + } + + public String getOAuthUserIdFromRequestToken(Http.Request requestWithPreviouslyVerifiedToken) { + try { + Optional authHeader = requestWithPreviouslyVerifiedToken.getHeaders().get(HttpHeaders.AUTHORIZATION); + if (authHeader.isPresent()) { + String bearerToken = authHeader.get().substring(bearerPrefix.length()); + return getOAuthUserIdFromToken(bearerToken); + } + } catch (Exception exception) { + return null; + } + + return null; + } + + public String getOAuthUserIdFromToken(String bearerToken) { + try { + DecodedJWT jwt = JWT.decode(bearerToken); + return jwt.getSubject(); + } catch (Exception exception) { + return null; + } + } + + public boolean isRequestTokenValid(Http.Request request, String securityMethodName) { + return useOnlineValidation ? isRequestTokenValidByOnlineCheck(request, securityMethodName) : isRequestTokenValidByOfflineCheck(request, securityMethodName); + } +} diff --git a/samples/server/petstore/java-play-framework-api-package-override/build.sbt b/samples/server/petstore/java-play-framework-api-package-override/build.sbt index b972893fc3f7..69dfa74cd8ad 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/build.sbt +++ b/samples/server/petstore/java-play-framework-api-package-override/build.sbt @@ -9,3 +9,6 @@ scalaVersion := "2.12.6" libraryDependencies += "org.webjars" % "swagger-ui" % "3.32.5" libraryDependencies += "javax.validation" % "validation-api" % "2.0.1.Final" libraryDependencies += guice +libraryDependencies += "com.auth0" % "java-jwt" % "3.18.1" +libraryDependencies += "com.auth0" % "jwks-rsa" % "0.19.0" +libraryDependencies += "org.apache.httpcomponents" % "httpclient" % "4.5.6" diff --git a/samples/server/petstore/java-play-framework-async/.openapi-generator/FILES b/samples/server/petstore/java-play-framework-async/.openapi-generator/FILES index f517461d8913..283bce384731 100644 --- a/samples/server/petstore/java-play-framework-async/.openapi-generator/FILES +++ b/samples/server/petstore/java-play-framework-async/.openapi-generator/FILES @@ -20,6 +20,7 @@ app/controllers/UserApiControllerImpInterface.java app/openapitools/ApiCall.java app/openapitools/ErrorHandler.java app/openapitools/OpenAPIUtils.java +app/openapitools/SecurityAPIUtils.java build.sbt conf/application.conf conf/logback.xml diff --git a/samples/server/petstore/java-play-framework-async/app/Module.java b/samples/server/petstore/java-play-framework-async/app/Module.java index f1b062c29345..1439bbe30c1a 100644 --- a/samples/server/petstore/java-play-framework-async/app/Module.java +++ b/samples/server/petstore/java-play-framework-async/app/Module.java @@ -1,6 +1,7 @@ import com.google.inject.AbstractModule; import controllers.*; +import openapitools.SecurityAPIUtils; public class Module extends AbstractModule { @@ -9,5 +10,6 @@ protected void configure() { bind(PetApiControllerImpInterface.class).to(PetApiControllerImp.class); bind(StoreApiControllerImpInterface.class).to(StoreApiControllerImp.class); bind(UserApiControllerImpInterface.class).to(UserApiControllerImp.class); + bind(SecurityAPIUtils.class); } } \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-async/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-async/app/controllers/PetApiControllerImpInterface.java index cf4e655490a7..7b4e0f356398 100644 --- a/samples/server/petstore/java-play-framework-async/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-async/app/controllers/PetApiControllerImpInterface.java @@ -15,7 +15,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; import java.util.concurrent.CompletionException; import java.util.concurrent.CompletionStage; @@ -26,12 +28,17 @@ @SuppressWarnings("RedundantThrows") public abstract class PetApiControllerImpInterface { @Inject private Config configuration; + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public CompletionStage addPetHttp(Http.Request request, Pet body) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return CompletableFuture.supplyAsync(play.mvc.Results::unauthorized); + } + CompletableFuture result = CompletableFuture.supplyAsync(() -> { try { - addPet(request, body); + addPet(request, body); } catch (Exception e) { throw new CompletionException(e); } @@ -44,9 +51,13 @@ public CompletionStage addPetHttp(Http.Request request, Pet body) throws public abstract void addPet(Http.Request request, Pet body) throws Exception; public CompletionStage deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return CompletableFuture.supplyAsync(play.mvc.Results::unauthorized); + } + CompletableFuture result = CompletableFuture.supplyAsync(() -> { try { - deletePet(request, petId, apiKey); + deletePet(request, petId, apiKey); } catch (Exception e) { throw new CompletionException(e); } @@ -59,36 +70,50 @@ public CompletionStage deletePetHttp(Http.Request request, Long petId, S public abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; public CompletionStage findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return CompletableFuture.supplyAsync(play.mvc.Results::unauthorized); + } + CompletionStage> stage = findPetsByStatus(request, status).thenApply(obj -> { - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); + + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } } - } - return obj; -}); + + return obj; + }); return stage.thenApply(obj -> { - JsonNode result = mapper.valueToTree(obj); - return ok(result); -}); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); + }); } public abstract CompletionStage> findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; public CompletionStage findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return CompletableFuture.supplyAsync(play.mvc.Results::unauthorized); + } + CompletionStage> stage = findPetsByTags(request, tags).thenApply(obj -> { - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); + + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } } - } - return obj; -}); + + return obj; + }); return stage.thenApply(obj -> { - JsonNode result = mapper.valueToTree(obj); - return ok(result); -}); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); + }); } @@ -96,24 +121,31 @@ public CompletionStage findPetsByTagsHttp(Http.Request request, @NotNull public CompletionStage getPetByIdHttp(Http.Request request, Long petId) throws Exception { CompletionStage stage = getPetById(request, petId).thenApply(obj -> { - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - return obj; -}); + + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + + return obj; + }); return stage.thenApply(obj -> { - JsonNode result = mapper.valueToTree(obj); - return ok(result); -}); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); + }); } public abstract CompletionStage getPetById(Http.Request request, Long petId) throws Exception; public CompletionStage updatePetHttp(Http.Request request, Pet body) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return CompletableFuture.supplyAsync(play.mvc.Results::unauthorized); + } + CompletableFuture result = CompletableFuture.supplyAsync(() -> { try { - updatePet(request, body); + updatePet(request, body); } catch (Exception e) { throw new CompletionException(e); } @@ -126,9 +158,13 @@ public CompletionStage updatePetHttp(Http.Request request, Pet body) thr public abstract void updatePet(Http.Request request, Pet body) throws Exception; public CompletionStage updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return CompletableFuture.supplyAsync(play.mvc.Results::unauthorized); + } + CompletableFuture result = CompletableFuture.supplyAsync(() -> { try { - updatePetWithForm(request, petId, name, status); + updatePetWithForm(request, petId, name, status); } catch (Exception e) { throw new CompletionException(e); } @@ -141,16 +177,23 @@ public CompletionStage updatePetWithFormHttp(Http.Request request, Long public abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; public CompletionStage uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return CompletableFuture.supplyAsync(play.mvc.Results::unauthorized); + } + CompletionStage stage = uploadFile(request, petId, additionalMetadata, file).thenApply(obj -> { - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - return obj; -}); + + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + + return obj; + }); return stage.thenApply(obj -> { - JsonNode result = mapper.valueToTree(obj); - return ok(result); -}); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); + }); } diff --git a/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiControllerImpInterface.java index 6e1d80c7d57d..3afa76d31144 100644 --- a/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiControllerImpInterface.java @@ -14,7 +14,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; import java.util.concurrent.CompletionException; import java.util.concurrent.CompletionStage; @@ -25,12 +27,13 @@ @SuppressWarnings("RedundantThrows") public abstract class StoreApiControllerImpInterface { @Inject private Config configuration; + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public CompletionStage deleteOrderHttp(Http.Request request, String orderId) throws Exception { CompletableFuture result = CompletableFuture.supplyAsync(() -> { try { - deleteOrder(request, orderId); + deleteOrder(request, orderId); } catch (Exception e) { throw new CompletionException(e); } @@ -44,12 +47,13 @@ public CompletionStage deleteOrderHttp(Http.Request request, String orde public CompletionStage getInventoryHttp(Http.Request request) throws Exception { CompletionStage> stage = getInventory(request).thenApply(obj -> { - return obj; -}); + return obj; + }); return stage.thenApply(obj -> { - JsonNode result = mapper.valueToTree(obj); - return ok(result); -}); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); + }); } @@ -57,15 +61,18 @@ public CompletionStage getInventoryHttp(Http.Request request) throws Exc public CompletionStage getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { CompletionStage stage = getOrderById(request, orderId).thenApply(obj -> { - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - return obj; -}); + + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + + return obj; + }); return stage.thenApply(obj -> { - JsonNode result = mapper.valueToTree(obj); - return ok(result); -}); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); + }); } @@ -73,15 +80,18 @@ public CompletionStage getOrderByIdHttp(Http.Request request, @Min(1) @ public CompletionStage placeOrderHttp(Http.Request request, Order body) throws Exception { CompletionStage stage = placeOrder(request, body).thenApply(obj -> { - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - return obj; -}); + + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + + return obj; + }); return stage.thenApply(obj -> { - JsonNode result = mapper.valueToTree(obj); - return ok(result); -}); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); + }); } diff --git a/samples/server/petstore/java-play-framework-async/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-async/app/controllers/UserApiControllerImpInterface.java index 2a1a3322b197..59730a669a53 100644 --- a/samples/server/petstore/java-play-framework-async/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-async/app/controllers/UserApiControllerImpInterface.java @@ -15,7 +15,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; import java.util.concurrent.CompletionException; import java.util.concurrent.CompletionStage; @@ -26,12 +28,13 @@ @SuppressWarnings("RedundantThrows") public abstract class UserApiControllerImpInterface { @Inject private Config configuration; + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public CompletionStage createUserHttp(Http.Request request, User body) throws Exception { CompletableFuture result = CompletableFuture.supplyAsync(() -> { try { - createUser(request, body); + createUser(request, body); } catch (Exception e) { throw new CompletionException(e); } @@ -46,7 +49,7 @@ public CompletionStage createUserHttp(Http.Request request, User body) t public CompletionStage createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { CompletableFuture result = CompletableFuture.supplyAsync(() -> { try { - createUsersWithArrayInput(request, body); + createUsersWithArrayInput(request, body); } catch (Exception e) { throw new CompletionException(e); } @@ -61,7 +64,7 @@ public CompletionStage createUsersWithArrayInputHttp(Http.Request reques public CompletionStage createUsersWithListInputHttp(Http.Request request, List body) throws Exception { CompletableFuture result = CompletableFuture.supplyAsync(() -> { try { - createUsersWithListInput(request, body); + createUsersWithListInput(request, body); } catch (Exception e) { throw new CompletionException(e); } @@ -76,7 +79,7 @@ public CompletionStage createUsersWithListInputHttp(Http.Request request public CompletionStage deleteUserHttp(Http.Request request, String username) throws Exception { CompletableFuture result = CompletableFuture.supplyAsync(() -> { try { - deleteUser(request, username); + deleteUser(request, username); } catch (Exception e) { throw new CompletionException(e); } @@ -90,15 +93,18 @@ public CompletionStage deleteUserHttp(Http.Request request, String usern public CompletionStage getUserByNameHttp(Http.Request request, String username) throws Exception { CompletionStage stage = getUserByName(request, username).thenApply(obj -> { - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - return obj; -}); + + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + + return obj; + }); return stage.thenApply(obj -> { - JsonNode result = mapper.valueToTree(obj); - return ok(result); -}); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); + }); } @@ -106,12 +112,13 @@ public CompletionStage getUserByNameHttp(Http.Request request, String us public CompletionStage loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { CompletionStage stage = loginUser(request, username, password).thenApply(obj -> { - return obj; -}); + return obj; + }); return stage.thenApply(obj -> { - JsonNode result = mapper.valueToTree(obj); - return ok(result); -}); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); + }); } @@ -120,7 +127,7 @@ public CompletionStage loginUserHttp(Http.Request request, @NotNull Stri public CompletionStage logoutUserHttp(Http.Request request) throws Exception { CompletableFuture result = CompletableFuture.supplyAsync(() -> { try { - logoutUser(request); + logoutUser(request); } catch (Exception e) { throw new CompletionException(e); } @@ -135,7 +142,7 @@ public CompletionStage logoutUserHttp(Http.Request request) throws Excep public CompletionStage updateUserHttp(Http.Request request, String username, User body) throws Exception { CompletableFuture result = CompletableFuture.supplyAsync(() -> { try { - updateUser(request, username, body); + updateUser(request, username, body); } catch (Exception e) { throw new CompletionException(e); } diff --git a/samples/server/petstore/java-play-framework-async/app/openapitools/SecurityAPIUtils.java b/samples/server/petstore/java-play-framework-async/app/openapitools/SecurityAPIUtils.java new file mode 100644 index 000000000000..854be87f65a8 --- /dev/null +++ b/samples/server/petstore/java-play-framework-async/app/openapitools/SecurityAPIUtils.java @@ -0,0 +1,165 @@ +package openapitools; + +import com.auth0.jwk.Jwk; +import com.auth0.jwk.UrlJwkProvider; +import com.auth0.jwt.JWT; +import com.auth0.jwt.JWTVerifier; +import com.auth0.jwt.algorithms.Algorithm; +import com.auth0.jwt.interfaces.DecodedJWT; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import org.apache.http.HttpHeaders; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.NameValuePair; +import org.apache.http.client.HttpClient; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; +import play.mvc.Http; + +import java.net.URL; +import java.security.PublicKey; +import java.security.interfaces.RSAPublicKey; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; + +@Singleton +public class SecurityAPIUtils { + private final String bearerPrefix = "Bearer "; + private final ObjectMapper mapper; + + private boolean useOnlineValidation = false; + + // Online validation + private HashMap tokenIntrospectEndpoints = new HashMap<>(); + private final String clientId; + private final String clientSecret; + + // Offline validation + private HashMap jwksEndpoints = new HashMap<>(); + private String tokenKeyId = ""; + private JWTVerifier tokenVerifier; //Reusable verifier instance until tokenKeyId changes. + + @Inject + SecurityAPIUtils(Config configuration) { + mapper = new ObjectMapper(); + + clientId = configuration.hasPath("oauth.clientId") ? configuration.getString("oauth.clientId") : ""; + clientSecret = configuration.hasPath("oauth.clientSecret") ? configuration.getString("oauth.clientSecret") : ""; + + tokenIntrospectEndpoints.put("petstore_auth", ""); + + jwksEndpoints.put("petstore_auth", ""); + } + + private boolean isRequestTokenValidByOnlineCheck(Http.Request request, String securityMethodName) { + try { + Optional authToken = request.getHeaders().get(HttpHeaders.AUTHORIZATION); + + if (authToken.isPresent()) { + String tokenWithoutBearerPrefix = authToken.get().substring(bearerPrefix.length()); + + HttpClientBuilder builder = HttpClientBuilder.create(); + HttpClient httpClient = builder.build(); + HttpPost httppost = new HttpPost(this.tokenIntrospectEndpoints.get(securityMethodName)); + + List params = new ArrayList<>(); + params.add(new BasicNameValuePair("token", tokenWithoutBearerPrefix)); + params.add(new BasicNameValuePair("client_id", clientId)); + params.add(new BasicNameValuePair("client_secret", clientSecret)); + httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); + + HttpResponse response = httpClient.execute(httppost); + String responseJsonString = EntityUtils.toString(response.getEntity()); + HashMap responseJsonObject = mapper.readValue(responseJsonString, HashMap.class); + + return response.getStatusLine().getStatusCode() == HttpStatus.SC_OK && (boolean) responseJsonObject.get("active"); + } + } catch (Exception exception) { + return false; + } + + return false; + } + + private boolean isRequestTokenValidByOfflineCheck(Http.Request request, String securityMethodName) { + try { + Optional authHeader = request.getHeaders().get(HttpHeaders.AUTHORIZATION); + + if (authHeader.isPresent()) { + String bearerToken = authHeader.get().substring(bearerPrefix.length()); + return isTokenValidByOfflineCheck(bearerToken, securityMethodName); + } + } catch (Exception exception) { + return false; + } + + return false; + } + + public boolean isTokenValidByOfflineCheck(String bearerToken, String securityMethodName) { + try { + DecodedJWT jwt = JWT.decode(bearerToken); + String issuer = jwt.getIssuer(); + String keyId = jwt.getKeyId(); + if (!tokenKeyId.equals(keyId)) { + if (securityMethodName == null) { + securityMethodName = jwksEndpoints.keySet().stream().findFirst().get(); + } + + Jwk jwk = new UrlJwkProvider(new URL(this.jwksEndpoints.get(securityMethodName))).get(keyId); + final PublicKey publicKey = jwk.getPublicKey(); + + if (!(publicKey instanceof RSAPublicKey)) { + throw new IllegalArgumentException(String.format("Key with ID %s was found in JWKS but is not a RSA-key.", keyId)); + } + + Algorithm algorithm = Algorithm.RSA256((RSAPublicKey) publicKey, null); + tokenVerifier = JWT.require(algorithm) + .withIssuer(issuer) + .build(); + tokenKeyId = keyId; + } + + DecodedJWT verifiedJWT = tokenVerifier.verify(bearerToken); + + return true; + } catch (Exception exception) { + return false; + } + } + + public String getOAuthUserIdFromRequestToken(Http.Request requestWithPreviouslyVerifiedToken) { + try { + Optional authHeader = requestWithPreviouslyVerifiedToken.getHeaders().get(HttpHeaders.AUTHORIZATION); + if (authHeader.isPresent()) { + String bearerToken = authHeader.get().substring(bearerPrefix.length()); + return getOAuthUserIdFromToken(bearerToken); + } + } catch (Exception exception) { + return null; + } + + return null; + } + + public String getOAuthUserIdFromToken(String bearerToken) { + try { + DecodedJWT jwt = JWT.decode(bearerToken); + return jwt.getSubject(); + } catch (Exception exception) { + return null; + } + } + + public boolean isRequestTokenValid(Http.Request request, String securityMethodName) { + return useOnlineValidation ? isRequestTokenValidByOnlineCheck(request, securityMethodName) : isRequestTokenValidByOfflineCheck(request, securityMethodName); + } +} diff --git a/samples/server/petstore/java-play-framework-async/build.sbt b/samples/server/petstore/java-play-framework-async/build.sbt index b972893fc3f7..69dfa74cd8ad 100644 --- a/samples/server/petstore/java-play-framework-async/build.sbt +++ b/samples/server/petstore/java-play-framework-async/build.sbt @@ -9,3 +9,6 @@ scalaVersion := "2.12.6" libraryDependencies += "org.webjars" % "swagger-ui" % "3.32.5" libraryDependencies += "javax.validation" % "validation-api" % "2.0.1.Final" libraryDependencies += guice +libraryDependencies += "com.auth0" % "java-jwt" % "3.18.1" +libraryDependencies += "com.auth0" % "jwks-rsa" % "0.19.0" +libraryDependencies += "org.apache.httpcomponents" % "httpclient" % "4.5.6" diff --git a/samples/server/petstore/java-play-framework-controller-only/.openapi-generator/FILES b/samples/server/petstore/java-play-framework-controller-only/.openapi-generator/FILES index 3a227fc0fcf1..4583f3a6d0ce 100644 --- a/samples/server/petstore/java-play-framework-controller-only/.openapi-generator/FILES +++ b/samples/server/petstore/java-play-framework-controller-only/.openapi-generator/FILES @@ -13,6 +13,7 @@ app/controllers/UserApiController.java app/openapitools/ApiCall.java app/openapitools/ErrorHandler.java app/openapitools/OpenAPIUtils.java +app/openapitools/SecurityAPIUtils.java build.sbt conf/application.conf conf/logback.xml diff --git a/samples/server/petstore/java-play-framework-controller-only/app/openapitools/SecurityAPIUtils.java b/samples/server/petstore/java-play-framework-controller-only/app/openapitools/SecurityAPIUtils.java new file mode 100644 index 000000000000..854be87f65a8 --- /dev/null +++ b/samples/server/petstore/java-play-framework-controller-only/app/openapitools/SecurityAPIUtils.java @@ -0,0 +1,165 @@ +package openapitools; + +import com.auth0.jwk.Jwk; +import com.auth0.jwk.UrlJwkProvider; +import com.auth0.jwt.JWT; +import com.auth0.jwt.JWTVerifier; +import com.auth0.jwt.algorithms.Algorithm; +import com.auth0.jwt.interfaces.DecodedJWT; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import org.apache.http.HttpHeaders; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.NameValuePair; +import org.apache.http.client.HttpClient; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; +import play.mvc.Http; + +import java.net.URL; +import java.security.PublicKey; +import java.security.interfaces.RSAPublicKey; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; + +@Singleton +public class SecurityAPIUtils { + private final String bearerPrefix = "Bearer "; + private final ObjectMapper mapper; + + private boolean useOnlineValidation = false; + + // Online validation + private HashMap tokenIntrospectEndpoints = new HashMap<>(); + private final String clientId; + private final String clientSecret; + + // Offline validation + private HashMap jwksEndpoints = new HashMap<>(); + private String tokenKeyId = ""; + private JWTVerifier tokenVerifier; //Reusable verifier instance until tokenKeyId changes. + + @Inject + SecurityAPIUtils(Config configuration) { + mapper = new ObjectMapper(); + + clientId = configuration.hasPath("oauth.clientId") ? configuration.getString("oauth.clientId") : ""; + clientSecret = configuration.hasPath("oauth.clientSecret") ? configuration.getString("oauth.clientSecret") : ""; + + tokenIntrospectEndpoints.put("petstore_auth", ""); + + jwksEndpoints.put("petstore_auth", ""); + } + + private boolean isRequestTokenValidByOnlineCheck(Http.Request request, String securityMethodName) { + try { + Optional authToken = request.getHeaders().get(HttpHeaders.AUTHORIZATION); + + if (authToken.isPresent()) { + String tokenWithoutBearerPrefix = authToken.get().substring(bearerPrefix.length()); + + HttpClientBuilder builder = HttpClientBuilder.create(); + HttpClient httpClient = builder.build(); + HttpPost httppost = new HttpPost(this.tokenIntrospectEndpoints.get(securityMethodName)); + + List params = new ArrayList<>(); + params.add(new BasicNameValuePair("token", tokenWithoutBearerPrefix)); + params.add(new BasicNameValuePair("client_id", clientId)); + params.add(new BasicNameValuePair("client_secret", clientSecret)); + httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); + + HttpResponse response = httpClient.execute(httppost); + String responseJsonString = EntityUtils.toString(response.getEntity()); + HashMap responseJsonObject = mapper.readValue(responseJsonString, HashMap.class); + + return response.getStatusLine().getStatusCode() == HttpStatus.SC_OK && (boolean) responseJsonObject.get("active"); + } + } catch (Exception exception) { + return false; + } + + return false; + } + + private boolean isRequestTokenValidByOfflineCheck(Http.Request request, String securityMethodName) { + try { + Optional authHeader = request.getHeaders().get(HttpHeaders.AUTHORIZATION); + + if (authHeader.isPresent()) { + String bearerToken = authHeader.get().substring(bearerPrefix.length()); + return isTokenValidByOfflineCheck(bearerToken, securityMethodName); + } + } catch (Exception exception) { + return false; + } + + return false; + } + + public boolean isTokenValidByOfflineCheck(String bearerToken, String securityMethodName) { + try { + DecodedJWT jwt = JWT.decode(bearerToken); + String issuer = jwt.getIssuer(); + String keyId = jwt.getKeyId(); + if (!tokenKeyId.equals(keyId)) { + if (securityMethodName == null) { + securityMethodName = jwksEndpoints.keySet().stream().findFirst().get(); + } + + Jwk jwk = new UrlJwkProvider(new URL(this.jwksEndpoints.get(securityMethodName))).get(keyId); + final PublicKey publicKey = jwk.getPublicKey(); + + if (!(publicKey instanceof RSAPublicKey)) { + throw new IllegalArgumentException(String.format("Key with ID %s was found in JWKS but is not a RSA-key.", keyId)); + } + + Algorithm algorithm = Algorithm.RSA256((RSAPublicKey) publicKey, null); + tokenVerifier = JWT.require(algorithm) + .withIssuer(issuer) + .build(); + tokenKeyId = keyId; + } + + DecodedJWT verifiedJWT = tokenVerifier.verify(bearerToken); + + return true; + } catch (Exception exception) { + return false; + } + } + + public String getOAuthUserIdFromRequestToken(Http.Request requestWithPreviouslyVerifiedToken) { + try { + Optional authHeader = requestWithPreviouslyVerifiedToken.getHeaders().get(HttpHeaders.AUTHORIZATION); + if (authHeader.isPresent()) { + String bearerToken = authHeader.get().substring(bearerPrefix.length()); + return getOAuthUserIdFromToken(bearerToken); + } + } catch (Exception exception) { + return null; + } + + return null; + } + + public String getOAuthUserIdFromToken(String bearerToken) { + try { + DecodedJWT jwt = JWT.decode(bearerToken); + return jwt.getSubject(); + } catch (Exception exception) { + return null; + } + } + + public boolean isRequestTokenValid(Http.Request request, String securityMethodName) { + return useOnlineValidation ? isRequestTokenValidByOnlineCheck(request, securityMethodName) : isRequestTokenValidByOfflineCheck(request, securityMethodName); + } +} diff --git a/samples/server/petstore/java-play-framework-controller-only/build.sbt b/samples/server/petstore/java-play-framework-controller-only/build.sbt index b972893fc3f7..69dfa74cd8ad 100644 --- a/samples/server/petstore/java-play-framework-controller-only/build.sbt +++ b/samples/server/petstore/java-play-framework-controller-only/build.sbt @@ -9,3 +9,6 @@ scalaVersion := "2.12.6" libraryDependencies += "org.webjars" % "swagger-ui" % "3.32.5" libraryDependencies += "javax.validation" % "validation-api" % "2.0.1.Final" libraryDependencies += guice +libraryDependencies += "com.auth0" % "java-jwt" % "3.18.1" +libraryDependencies += "com.auth0" % "jwks-rsa" % "0.19.0" +libraryDependencies += "org.apache.httpcomponents" % "httpclient" % "4.5.6" diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/.openapi-generator-ignore b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/.openapi-generator-ignore @@ -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 diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/.openapi-generator/FILES b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/.openapi-generator/FILES new file mode 100644 index 000000000000..651f0dd34509 --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/.openapi-generator/FILES @@ -0,0 +1,24 @@ +LICENSE +README +app/Module.java +app/apimodels/Category.java +app/apimodels/ModelApiResponse.java +app/apimodels/Order.java +app/apimodels/Pet.java +app/apimodels/Tag.java +app/apimodels/User.java +app/controllers/ApiDocController.java +app/controllers/PetApiController.java +app/controllers/PetApiControllerImp.java +app/controllers/PetApiControllerImpInterface.java +app/openapitools/ApiCall.java +app/openapitools/ErrorHandler.java +app/openapitools/OpenAPIUtils.java +app/openapitools/SecurityAPIUtils.java +build.sbt +conf/application.conf +conf/logback.xml +conf/routes +project/build.properties +project/plugins.sbt +public/openapi.json diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/.openapi-generator/VERSION b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/.openapi-generator/VERSION new file mode 100644 index 000000000000..0984c4c1ad21 --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/.openapi-generator/VERSION @@ -0,0 +1 @@ +5.4.0-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/LICENSE b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/LICENSE new file mode 100644 index 000000000000..19823e1cacc7 --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/LICENSE @@ -0,0 +1,8 @@ +This software is licensed under the Apache 2 license, quoted below. + +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this project except in compliance with +the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0. + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific +language governing permissions and limitations under the License. \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/README b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/README new file mode 100644 index 000000000000..2fce02950d27 --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/README @@ -0,0 +1,4 @@ +This is your new Play application +================================= + +This file will be packaged with your application when using `activator dist`. \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/Module.java b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/Module.java new file mode 100644 index 000000000000..cfa022a4bc4b --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/Module.java @@ -0,0 +1,13 @@ +import com.google.inject.AbstractModule; + +import controllers.*; +import openapitools.SecurityAPIUtils; + +public class Module extends AbstractModule { + + @Override + protected void configure() { + bind(PetApiControllerImpInterface.class).to(PetApiControllerImp.class); + bind(SecurityAPIUtils.class); + } +} \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/apimodels/Category.java b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/apimodels/Category.java new file mode 100644 index 000000000000..afed4d545a99 --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/apimodels/Category.java @@ -0,0 +1,98 @@ +package apimodels; + +import com.fasterxml.jackson.annotation.*; +import java.util.Set; +import javax.validation.*; +import java.util.Objects; +import javax.validation.constraints.*; +/** + * A category for a pet + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") +@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"}) +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 + **/ + 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 + **/ + 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(id, category.id) && + Objects.equals(name, category.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @SuppressWarnings("StringBufferReplaceableByString") + @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 "); + } +} + diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/apimodels/ModelApiResponse.java b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/apimodels/ModelApiResponse.java new file mode 100644 index 000000000000..820779a1cd95 --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/apimodels/ModelApiResponse.java @@ -0,0 +1,121 @@ +package apimodels; + +import com.fasterxml.jackson.annotation.*; +import java.util.Set; +import javax.validation.*; +import java.util.Objects; +import javax.validation.constraints.*; +/** + * Describes the result of uploading an image resource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") +@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"}) +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 + **/ + 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 + **/ + 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 + **/ + 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(code, _apiResponse.code) && + Objects.equals(type, _apiResponse.type) && + Objects.equals(message, _apiResponse.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, type, message); + } + + @SuppressWarnings("StringBufferReplaceableByString") + @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 "); + } +} + diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/apimodels/Order.java b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/apimodels/Order.java new file mode 100644 index 000000000000..d54cba148ad3 --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/apimodels/Order.java @@ -0,0 +1,225 @@ +package apimodels; + +import java.time.OffsetDateTime; +import com.fasterxml.jackson.annotation.*; +import java.util.Set; +import javax.validation.*; +import java.util.Objects; +import javax.validation.constraints.*; +/** + * An order for a pets from the pet store + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") +@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"}) +public class Order { + @JsonProperty("id") + + private Long id; + + @JsonProperty("petId") + + private Long petId; + + @JsonProperty("quantity") + + private Integer quantity; + + @JsonProperty("shipDate") + @Valid + + private OffsetDateTime shipDate; + + /** + * Order Status + */ + public enum StatusEnum { + PLACED("placed"), + + APPROVED("approved"), + + DELIVERED("delivered"); + + private final String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + 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 + **/ + 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 + **/ + 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 + **/ + 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 + **/ + 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 + **/ + 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 + **/ + 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(id, order.id) && + Objects.equals(petId, order.petId) && + Objects.equals(quantity, order.quantity) && + Objects.equals(shipDate, order.shipDate) && + Objects.equals(status, order.status) && + Objects.equals(complete, order.complete); + } + + @Override + public int hashCode() { + return Objects.hash(id, petId, quantity, shipDate, status, complete); + } + + @SuppressWarnings("StringBufferReplaceableByString") + @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 "); + } +} + diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/apimodels/Pet.java b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/apimodels/Pet.java new file mode 100644 index 000000000000..4699f7235ed2 --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/apimodels/Pet.java @@ -0,0 +1,244 @@ +package apimodels; + +import apimodels.Category; +import apimodels.Tag; +import java.util.ArrayList; +import java.util.List; +import com.fasterxml.jackson.annotation.*; +import java.util.Set; +import javax.validation.*; +import java.util.Objects; +import javax.validation.constraints.*; +/** + * A pet for sale in the pet store + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") +@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"}) +public class Pet { + @JsonProperty("id") + + private Long id; + + @JsonProperty("category") + @Valid + + private Category category; + + @JsonProperty("name") + @NotNull + + private String name; + + @JsonProperty("photoUrls") + @NotNull + + private List photoUrls = new ArrayList<>(); + + @JsonProperty("tags") + @Valid + + private List tags = null; + + /** + * pet status in the store + */ + public enum StatusEnum { + AVAILABLE("available"), + + PENDING("pending"), + + SOLD("sold"); + + private final String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + 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; + + public Pet id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + 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 + **/ + 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 + **/ + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Pet photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + public Pet addPhotoUrlsItem(String photoUrlsItem) { + photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get photoUrls + * @return photoUrls + **/ + public List getPhotoUrls() { + return photoUrls; + } + + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + public Pet tags(List tags) { + this.tags = tags; + return this; + } + + public Pet addTagsItem(Tag tagsItem) { + if (tags == null) { + tags = new ArrayList<>(); + } + tags.add(tagsItem); + return this; + } + + /** + * Get tags + * @return tags + **/ + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * pet status in the store + * @return status + **/ + 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(id, pet.id) && + Objects.equals(category, pet.category) && + Objects.equals(name, pet.name) && + Objects.equals(photoUrls, pet.photoUrls) && + Objects.equals(tags, pet.tags) && + Objects.equals(status, pet.status); + } + + @Override + public int hashCode() { + return Objects.hash(id, category, name, photoUrls, tags, status); + } + + @SuppressWarnings("StringBufferReplaceableByString") + @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 "); + } +} + diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/apimodels/Tag.java b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/apimodels/Tag.java new file mode 100644 index 000000000000..adac882cd052 --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/apimodels/Tag.java @@ -0,0 +1,98 @@ +package apimodels; + +import com.fasterxml.jackson.annotation.*; +import java.util.Set; +import javax.validation.*; +import java.util.Objects; +import javax.validation.constraints.*; +/** + * A tag for a pet + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") +@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"}) +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 + **/ + 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 + **/ + 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(id, tag.id) && + Objects.equals(name, tag.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @SuppressWarnings("StringBufferReplaceableByString") + @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 "); + } +} + diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/apimodels/User.java b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/apimodels/User.java new file mode 100644 index 000000000000..4e5d397b990c --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/apimodels/User.java @@ -0,0 +1,236 @@ +package apimodels; + +import com.fasterxml.jackson.annotation.*; +import java.util.Set; +import javax.validation.*; +import java.util.Objects; +import javax.validation.constraints.*; +/** + * A User who is purchasing from the pet store + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") +@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"}) +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 + **/ + 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 + **/ + 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 + **/ + 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 + **/ + 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 + **/ + 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 + **/ + 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 + **/ + 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 + **/ + 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(id, user.id) && + Objects.equals(username, user.username) && + Objects.equals(firstName, user.firstName) && + Objects.equals(lastName, user.lastName) && + Objects.equals(email, user.email) && + Objects.equals(password, user.password) && + Objects.equals(phone, user.phone) && + Objects.equals(userStatus, user.userStatus); + } + + @Override + public int hashCode() { + return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus); + } + + @SuppressWarnings("StringBufferReplaceableByString") + @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 "); + } +} + diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/controllers/ApiDocController.java b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/controllers/ApiDocController.java new file mode 100644 index 000000000000..ac9f699c93f1 --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/controllers/ApiDocController.java @@ -0,0 +1,15 @@ +package controllers; + +import javax.inject.*; +import play.mvc.*; + +public class ApiDocController extends Controller { + + @Inject + private ApiDocController() { + } + + public Result api() { + return redirect("/assets/lib/swagger-ui/index.html?url=/assets/openapi.json"); + } +} diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/controllers/PetApiController.java new file mode 100644 index 000000000000..d66a24f477c3 --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/controllers/PetApiController.java @@ -0,0 +1,86 @@ +package controllers; + +import apimodels.Pet; + +import com.typesafe.config.Config; +import play.mvc.Controller; +import play.mvc.Result; +import play.mvc.Http; +import java.util.List; +import java.util.Map; +import java.util.ArrayList; +import java.util.LinkedHashSet; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import com.google.inject.Inject; +import java.io.File; +import play.libs.Files.TemporaryFile; +import openapitools.OpenAPIUtils; +import com.fasterxml.jackson.core.type.TypeReference; + +import javax.validation.constraints.*; +import com.typesafe.config.Config; + +import openapitools.OpenAPIUtils.ApiAction; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") +public class PetApiController extends Controller { + private final PetApiControllerImpInterface imp; + private final ObjectMapper mapper; + private final Config configuration; + + @Inject + private PetApiController(Config configuration, PetApiControllerImpInterface imp) { + this.imp = imp; + mapper = new ObjectMapper(); + this.configuration = configuration; + } + + @ApiAction + public Result addPet(Http.Request request) throws Exception { + JsonNode nodebody = request.body().asJson(); + Pet body; + if (nodebody != null) { + body = mapper.readValue(nodebody.toString(), Pet.class); + if (configuration.getBoolean("useInputBeanValidation")) { + OpenAPIUtils.validate(body); + } + } else { + throw new IllegalArgumentException("'body' parameter is required"); + } + return imp.addPetHttp(request, body); + } + + @ApiAction + public Result findPetsByStatus(Http.Request request) throws Exception { + String[] statusArray = request.queryString().get("status"); + if (statusArray == null) { + throw new IllegalArgumentException("'status' parameter is required"); + } + List statusList = OpenAPIUtils.parametersToList("csv", statusArray); + List status = new ArrayList<>(); + for (String curParam : statusList) { + if (!curParam.isEmpty()) { + //noinspection UseBulkOperation + status.add(curParam); + } + } + return imp.findPetsByStatusHttp(request, status); + } + + @ApiAction + public Result updatePet(Http.Request request) throws Exception { + JsonNode nodebody = request.body().asJson(); + Pet body; + if (nodebody != null) { + body = mapper.readValue(nodebody.toString(), Pet.class); + if (configuration.getBoolean("useInputBeanValidation")) { + OpenAPIUtils.validate(body); + } + } else { + throw new IllegalArgumentException("'body' parameter is required"); + } + return imp.updatePetHttp(request, body); + } + +} diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/controllers/PetApiControllerImp.java b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/controllers/PetApiControllerImp.java new file mode 100644 index 000000000000..baaedaae78c9 --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/controllers/PetApiControllerImp.java @@ -0,0 +1,31 @@ +package controllers; + +import apimodels.Pet; + +import play.mvc.Http; +import java.util.List; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.io.FileInputStream; +import play.libs.Files.TemporaryFile; +import javax.validation.constraints.*; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") +public class PetApiControllerImp extends PetApiControllerImpInterface { + @Override + public void addPet(Http.Request request, Pet body) throws Exception { + //Do your magic!!! + } + + @Override + public List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception { + //Do your magic!!! + return new ArrayList(); + } + + @Override + public void updatePet(Http.Request request, Pet body) throws Exception { + //Do your magic!!! + } + +} diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/controllers/PetApiControllerImpInterface.java new file mode 100644 index 000000000000..3c05b7bff361 --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/controllers/PetApiControllerImpInterface.java @@ -0,0 +1,66 @@ +package controllers; + +import apimodels.Pet; + +import com.google.inject.Inject; +import com.typesafe.config.Config; +import play.mvc.Controller; +import play.mvc.Http; +import java.util.List; +import java.util.ArrayList; +import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; +import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; +import play.libs.Files.TemporaryFile; + +import javax.validation.constraints.*; + +@SuppressWarnings("RedundantThrows") +public abstract class PetApiControllerImpInterface { + @Inject private Config configuration; + @Inject private SecurityAPIUtils securityAPIUtils; + private ObjectMapper mapper = new ObjectMapper(); + + public Result addPetHttp(Http.Request request, Pet body) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_token")) { + return unauthorized(); + } + + addPet(request, body); + return ok(); + + } + + public abstract void addPet(Http.Request request, Pet body) throws Exception; + + public Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + List obj = findPetsByStatus(request, status); + + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); + + } + + public abstract List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; + + public Result updatePetHttp(Http.Request request, Pet body) throws Exception { + updatePet(request, body); + return ok(); + + } + + public abstract void updatePet(Http.Request request, Pet body) throws Exception; + +} diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/openapitools/ApiCall.java b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/openapitools/ApiCall.java new file mode 100644 index 000000000000..7a74f4e67162 --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/openapitools/ApiCall.java @@ -0,0 +1,27 @@ +package openapitools; + +import com.google.inject.Inject; +import play.mvc.Action; +import play.mvc.Http; +import play.mvc.Result; + +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +public class ApiCall extends Action { + + @Inject + private ApiCall() {} + + public CompletionStage call(Http.Request request) { + try { + //TODO: Do stuff you want to handle with each API call (metrics, logging, etc..) + return delegate.call(request); + } catch (Throwable t) { + //TODO: log the error in your metric + + //We rethrow this error so it will be caught in the ErrorHandler + throw t; + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/openapitools/ErrorHandler.java b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/openapitools/ErrorHandler.java new file mode 100644 index 000000000000..4c2999bc7441 --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/openapitools/ErrorHandler.java @@ -0,0 +1,50 @@ +package openapitools; + + +import com.typesafe.config.Config; +import play.*; +import play.api.OptionalSourceMapper; +import play.api.UsefulException; +import play.api.routing.Router; +import play.http.DefaultHttpErrorHandler; +import play.mvc.Http.*; +import play.mvc.*; + +import javax.inject.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; +import static play.mvc.Results.*; + +@Singleton +public class ErrorHandler extends DefaultHttpErrorHandler { + + @Inject + public ErrorHandler(Config configuration, Environment environment, OptionalSourceMapper sourceMapper, Provider routes) { + super(configuration, environment, sourceMapper, routes); + } + + @Override + protected CompletionStage onDevServerError(RequestHeader request, UsefulException exception) { + return CompletableFuture.completedFuture( + handleExceptions(exception) + ); + } + + @Override + protected CompletionStage onProdServerError(RequestHeader request, UsefulException exception) { + return CompletableFuture.completedFuture( + handleExceptions(exception) + ); + } + + @Override + protected void logServerError(RequestHeader request, UsefulException usefulException) { + //Since the error is already handled, we don't want to print anything on the console + //But if you want to have the error printed in the console, just delete this override + } + + private Result handleExceptions(Throwable t) { + //TODO: Handle exception that need special response (return a special apimodel, notFound(), etc..) + return ok(); + } +} diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/openapitools/OpenAPIUtils.java b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/openapitools/OpenAPIUtils.java new file mode 100644 index 000000000000..e57d887c2ec0 --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/openapitools/OpenAPIUtils.java @@ -0,0 +1,103 @@ +package openapitools; + +import play.mvc.With; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.text.SimpleDateFormat; +import java.util.*; + +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; + +public class OpenAPIUtils { + + @With(ApiCall.class) + @Target({ ElementType.TYPE, ElementType.METHOD }) + @Retention(RetentionPolicy.RUNTIME) + public @interface ApiAction { + } + + public static void validate(T obj) { + ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); + Validator validator = factory.getValidator(); + Set> constraintViolations = validator.validate(obj); + if (constraintViolations.size() > 0) { + StringBuilder errors = new StringBuilder(); + for (ConstraintViolation constraints : constraintViolations) { + errors.append(String.format("%s.%s %s\n", + constraints.getRootBeanClass().getSimpleName(), + constraints.getPropertyPath(), + constraints.getMessage())); + } + throw new RuntimeException("Bean validation : " + errors); + } + } + + public static List parametersToList(String collectionFormat, String[] values){ + List params = new ArrayList<>(); + + if (values == null) { + return params; + } + + if (values.length >= 1 && collectionFormat.equals("multi")) { + params.addAll(Arrays.asList(values)); + } else { + collectionFormat = (collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat); // default: csv + + String delimiter = ","; + + switch(collectionFormat) { + case "csv": { + delimiter = ","; + break; + } + case "ssv": { + delimiter = " "; + break; + } + case "tsv": { + delimiter = "\t"; + break; + } + case "pipes": { + delimiter = "|"; + break; + } + } + + params = Arrays.asList(values[0].split(delimiter)); + } + + return params; + } + + public static String parameterToString(Object param) { + if (param == null) { + return ""; + } else if (param instanceof Date) { + return formatDatetime((Date) param); + } else if (param instanceof Collection) { + StringBuilder b = new StringBuilder(); + for (Object o : (Collection)param) { + if (b.length() > 0) { + b.append(","); + } + b.append(String.valueOf(o)); + } + + return b.toString(); + } else { + return String.valueOf(param); + } + } + + public static String formatDatetime(Date date) { + return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX", Locale.ROOT).format(date); + } +} diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/openapitools/SecurityAPIUtils.java b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/openapitools/SecurityAPIUtils.java new file mode 100644 index 000000000000..6e3cdc69b8d2 --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/app/openapitools/SecurityAPIUtils.java @@ -0,0 +1,165 @@ +package openapitools; + +import com.auth0.jwk.Jwk; +import com.auth0.jwk.UrlJwkProvider; +import com.auth0.jwt.JWT; +import com.auth0.jwt.JWTVerifier; +import com.auth0.jwt.algorithms.Algorithm; +import com.auth0.jwt.interfaces.DecodedJWT; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import org.apache.http.HttpHeaders; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.NameValuePair; +import org.apache.http.client.HttpClient; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; +import play.mvc.Http; + +import java.net.URL; +import java.security.PublicKey; +import java.security.interfaces.RSAPublicKey; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; + +@Singleton +public class SecurityAPIUtils { + private final String bearerPrefix = "Bearer "; + private final ObjectMapper mapper; + + private boolean useOnlineValidation = false; + + // Online validation + private HashMap tokenIntrospectEndpoints = new HashMap<>(); + private final String clientId; + private final String clientSecret; + + // Offline validation + private HashMap jwksEndpoints = new HashMap<>(); + private String tokenKeyId = ""; + private JWTVerifier tokenVerifier; //Reusable verifier instance until tokenKeyId changes. + + @Inject + SecurityAPIUtils(Config configuration) { + mapper = new ObjectMapper(); + + clientId = configuration.hasPath("oauth.clientId") ? configuration.getString("oauth.clientId") : ""; + clientSecret = configuration.hasPath("oauth.clientSecret") ? configuration.getString("oauth.clientSecret") : ""; + + tokenIntrospectEndpoints.put("petstore_token", "https://keycloak-dev.business.stingray.com/auth/realms/CSLocal/protocol/openid-connect/token/introspect"); + + jwksEndpoints.put("petstore_token", "https://keycloak-dev.business.stingray.com/auth/realms/CSLocal/protocol/openid-connect/certs"); + } + + private boolean isRequestTokenValidByOnlineCheck(Http.Request request, String securityMethodName) { + try { + Optional authToken = request.getHeaders().get(HttpHeaders.AUTHORIZATION); + + if (authToken.isPresent()) { + String tokenWithoutBearerPrefix = authToken.get().substring(bearerPrefix.length()); + + HttpClientBuilder builder = HttpClientBuilder.create(); + HttpClient httpClient = builder.build(); + HttpPost httppost = new HttpPost(this.tokenIntrospectEndpoints.get(securityMethodName)); + + List params = new ArrayList<>(); + params.add(new BasicNameValuePair("token", tokenWithoutBearerPrefix)); + params.add(new BasicNameValuePair("client_id", clientId)); + params.add(new BasicNameValuePair("client_secret", clientSecret)); + httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); + + HttpResponse response = httpClient.execute(httppost); + String responseJsonString = EntityUtils.toString(response.getEntity()); + HashMap responseJsonObject = mapper.readValue(responseJsonString, HashMap.class); + + return response.getStatusLine().getStatusCode() == HttpStatus.SC_OK && (boolean) responseJsonObject.get("active"); + } + } catch (Exception exception) { + return false; + } + + return false; + } + + private boolean isRequestTokenValidByOfflineCheck(Http.Request request, String securityMethodName) { + try { + Optional authHeader = request.getHeaders().get(HttpHeaders.AUTHORIZATION); + + if (authHeader.isPresent()) { + String bearerToken = authHeader.get().substring(bearerPrefix.length()); + return isTokenValidByOfflineCheck(bearerToken, securityMethodName); + } + } catch (Exception exception) { + return false; + } + + return false; + } + + public boolean isTokenValidByOfflineCheck(String bearerToken, String securityMethodName) { + try { + DecodedJWT jwt = JWT.decode(bearerToken); + String issuer = jwt.getIssuer(); + String keyId = jwt.getKeyId(); + if (!tokenKeyId.equals(keyId)) { + if (securityMethodName == null) { + securityMethodName = jwksEndpoints.keySet().stream().findFirst().get(); + } + + Jwk jwk = new UrlJwkProvider(new URL(this.jwksEndpoints.get(securityMethodName))).get(keyId); + final PublicKey publicKey = jwk.getPublicKey(); + + if (!(publicKey instanceof RSAPublicKey)) { + throw new IllegalArgumentException(String.format("Key with ID %s was found in JWKS but is not a RSA-key.", keyId)); + } + + Algorithm algorithm = Algorithm.RSA256((RSAPublicKey) publicKey, null); + tokenVerifier = JWT.require(algorithm) + .withIssuer(issuer) + .build(); + tokenKeyId = keyId; + } + + DecodedJWT verifiedJWT = tokenVerifier.verify(bearerToken); + + return true; + } catch (Exception exception) { + return false; + } + } + + public String getOAuthUserIdFromRequestToken(Http.Request requestWithPreviouslyVerifiedToken) { + try { + Optional authHeader = requestWithPreviouslyVerifiedToken.getHeaders().get(HttpHeaders.AUTHORIZATION); + if (authHeader.isPresent()) { + String bearerToken = authHeader.get().substring(bearerPrefix.length()); + return getOAuthUserIdFromToken(bearerToken); + } + } catch (Exception exception) { + return null; + } + + return null; + } + + public String getOAuthUserIdFromToken(String bearerToken) { + try { + DecodedJWT jwt = JWT.decode(bearerToken); + return jwt.getSubject(); + } catch (Exception exception) { + return null; + } + } + + public boolean isRequestTokenValid(Http.Request request, String securityMethodName) { + return useOnlineValidation ? isRequestTokenValidByOnlineCheck(request, securityMethodName) : isRequestTokenValidByOfflineCheck(request, securityMethodName); + } +} diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/build.sbt b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/build.sbt new file mode 100644 index 000000000000..69dfa74cd8ad --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/build.sbt @@ -0,0 +1,14 @@ +name := """openapi-java-playframework""" + +version := "1.0-SNAPSHOT" + +lazy val root = (project in file(".")).enablePlugins(PlayJava) + +scalaVersion := "2.12.6" + +libraryDependencies += "org.webjars" % "swagger-ui" % "3.32.5" +libraryDependencies += "javax.validation" % "validation-api" % "2.0.1.Final" +libraryDependencies += guice +libraryDependencies += "com.auth0" % "java-jwt" % "3.18.1" +libraryDependencies += "com.auth0" % "jwks-rsa" % "0.19.0" +libraryDependencies += "org.apache.httpcomponents" % "httpclient" % "4.5.6" diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/conf/application.conf b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/conf/application.conf new file mode 100644 index 000000000000..60d4bf00b538 --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/conf/application.conf @@ -0,0 +1,374 @@ +# This is the main configuration file for the application. +# https://www.playframework.com/documentation/latest/ConfigFile +# ~~~~~ +# Play uses HOCON as its configuration file format. HOCON has a number +# of advantages over other config formats, but there are two things that +# can be used when modifying settings. +# +# You can include other configuration files in this main application.conf file: +#include "extra-config.conf" +# +# You can declare variables and substitute for them: +#mykey = ${some.value} +# +# And if an environment variable exists when there is no other substitution, then +# HOCON will fall back to substituting environment variable: +#mykey = ${JAVA_HOME} + +play.filters.headers.contentSecurityPolicy=null + +# When using bean validation with the OpenAPI API, the validator will check that every constraint is respected +# This is very useful when testing but could add a lot of overhead if you return a lot of data. Benchmark have +# shown that the time it takes to validate is exponential. +# If this is a concern in your application, or if you don't want to validate the output coming from your API for +# respecting its contract, set the "output" property below to "false". Since there is not a lot of data as input for +# an endpoint, I highly suggest you let the "input" property set to true. +useInputBeanValidation=true +useOutputBeanValidation=true + +play.http.errorHandler="openapitools.ErrorHandler" + +## Akka +# https://www.playframework.com/documentation/latest/ScalaAkka#Configuration +# https://www.playframework.com/documentation/latest/JavaAkka#Configuration +# ~~~~~ +# Play uses Akka internally and exposes Akka Streams and actors in Websockets and +# other streaming HTTP responses. +akka { +# "akka.log-config-on-start" is extraordinarily useful because it log the complete +# configuration at INFO level, including defaults and overrides, so it s worth +# putting at the very top. +# +# Put the following in your conf/logback.xml file: +# +# +# +# And then uncomment this line to debug the configuration. +# +#log-config-on-start = true +} + +## Secret key +# http://www.playframework.com/documentation/latest/ApplicationSecret +# ~~~~~ +# The secret key is used to sign Play's session cookie. +# This must be changed for production, but we don't recommend you change it in this file. +play.http.secret.key = "changeme" + +## Modules +# https://www.playframework.com/documentation/latest/Modules +# ~~~~~ +# Control which modules are loaded when Play starts. Note that modules are +# the replacement for "GlobalSettings", which are deprecated in 2.5.x. +# Please see https://www.playframework.com/documentation/latest/GlobalSettings +# for more information. +# +# You can also extend Play functionality by using one of the publicly available +# Play modules: https://playframework.com/documentation/latest/ModuleDirectory +play.modules { +# By default, Play will load any class called Module that is defined +# in the root package (the "app" directory), or you can define them +# explicitly below. +# If there are any built-in modules that you want to disable, you can list them here. +} + +play.assets { +path = "/public" +urlPrefix = "/assets" +} + +## IDE +# https://www.playframework.com/documentation/latest/IDE +# ~~~~~ +# Depending on your IDE, you can add a hyperlink for errors that will jump you +# directly to the code location in the IDE in dev mode. The following line makes +# use of the IntelliJ IDEA REST interface: +#play.editor="http://localhost:63342/api/file/?file=%s&line=%s" + +## Internationalisation +# https://www.playframework.com/documentation/latest/JavaI18N +# https://www.playframework.com/documentation/latest/ScalaI18N +# ~~~~~ +# Play comes with its own i18n settings, which allow the user's preferred language +# to map through to internal messages, or allow the language to be stored in a cookie. +play.i18n { +# The application languages +langs = [ "en" ] + +# Whether the language cookie should be secure or not +#langCookieSecure = true + +# Whether the HTTP only attribute of the cookie should be set to true +#langCookieHttpOnly = true +} + +## Play HTTP settings +# ~~~~~ +play.http { +## Router +# https://www.playframework.com/documentation/latest/JavaRouting +# https://www.playframework.com/documentation/latest/ScalaRouting +# ~~~~~ +# Define the Router object to use for this application. +# This router will be looked up first when the application is starting up, +# so make sure this is the entry point. +# Furthermore, it's assumed your route file is named properly. +# So for an application router like `my.application.Router`, +# you may need to define a router file `conf/my.application.routes`. +# Default to Routes in the root package (aka "apps" folder) (and conf/routes) +#router = my.application.Router + +## Action Creator +# https://www.playframework.com/documentation/latest/JavaActionCreator +# ~~~~~ +#actionCreator = null + +## ErrorHandler +# https://www.playframework.com/documentation/latest/JavaRouting +# https://www.playframework.com/documentation/latest/ScalaRouting +# ~~~~~ +# If null, will attempt to load a class called ErrorHandler in the root package, +#errorHandler = null + +## Filters +# https://www.playframework.com/documentation/latest/ScalaHttpFilters +# https://www.playframework.com/documentation/latest/JavaHttpFilters +# ~~~~~ +# Filters run code on every request. They can be used to perform +# common logic for all your actions, e.g. adding common headers. +# Defaults to "Filters" in the root package (aka "apps" folder) +# Alternatively you can explicitly register a class here. +#filters = my.application.Filters + +## Session & Flash +# https://www.playframework.com/documentation/latest/JavaSessionFlash +# https://www.playframework.com/documentation/latest/ScalaSessionFlash +# ~~~~~ +session { +# Sets the cookie to be sent only over HTTPS. +#secure = true + +# Sets the cookie to be accessed only by the server. +#httpOnly = true + +# Sets the max-age field of the cookie to 5 minutes. +# NOTE: this only sets when the browser will discard the cookie. Play will consider any +# cookie value with a valid signature to be a valid session forever. To implement a server side session timeout, +# you need to put a timestamp in the session and check it at regular intervals to possibly expire it. +#maxAge = 300 + +# Sets the domain on the session cookie. +#domain = "example.com" +} + +flash { +# Sets the cookie to be sent only over HTTPS. +#secure = true + +# Sets the cookie to be accessed only by the server. +#httpOnly = true +} +} + +## Netty Provider +# https://www.playframework.com/documentation/latest/SettingsNetty +# ~~~~~ +play.server.netty { +# Whether the Netty wire should be logged +#log.wire = true + +# If you run Play on Linux, you can use Netty's native socket transport +# for higher performance with less garbage. +#transport = "native" +} + +## WS (HTTP Client) +# https://www.playframework.com/documentation/latest/ScalaWS#Configuring-WS +# ~~~~~ +# The HTTP client primarily used for REST APIs. The default client can be +# configured directly, but you can also create different client instances +# with customized settings. You must enable this by adding to build.sbt: +# +# libraryDependencies += ws // or javaWs if using java +# +play.ws { +# Sets HTTP requests not to follow 302 requests +#followRedirects = false + +# Sets the maximum number of open HTTP connections for the client. +#ahc.maxConnectionsTotal = 50 + +## WS SSL +# https://www.playframework.com/documentation/latest/WsSSL +# ~~~~~ +ssl { +# Configuring HTTPS with Play WS does not require programming. You can +# set up both trustManager and keyManager for mutual authentication, and +# turn on JSSE debugging in development with a reload. +#debug.handshake = true +#trustManager = { +# stores = [ +# { type = "JKS", path = "exampletrust.jks" } +# ] +#} +} +} + +## Cache +# https://www.playframework.com/documentation/latest/JavaCache +# https://www.playframework.com/documentation/latest/ScalaCache +# ~~~~~ +# Play comes with an integrated cache API that can reduce the operational +# overhead of repeated requests. You must enable this by adding to build.sbt: +# +# libraryDependencies += cache +# +play.cache { +# If you want to bind several caches, you can bind the individually +#bindCaches = ["db-cache", "user-cache", "session-cache"] +} + +## Filters +# https://www.playframework.com/documentation/latest/Filters +# ~~~~~ +# There are a number of built-in filters that can be enabled and configured +# to give Play greater security. You must enable this by adding to build.sbt: +# +# libraryDependencies += filters +# +play.filters { +## CORS filter configuration +# https://www.playframework.com/documentation/latest/CorsFilter +# ~~~~~ +# CORS is a protocol that allows web applications to make requests from the browser +# across different domains. +# NOTE: You MUST apply the CORS configuration before the CSRF filter, as CSRF has +# dependencies on CORS settings. +cors { +# Filter paths by a whitelist of path prefixes +#pathPrefixes = ["/some/path", ...] + +# The allowed origins. If null, all origins are allowed. +#allowedOrigins = ["http://www.example.com"] + +# The allowed HTTP methods. If null, all methods are allowed +#allowedHttpMethods = ["GET", "POST"] +} + +## CSRF Filter +# https://www.playframework.com/documentation/latest/ScalaCsrf#Applying-a-global-CSRF-filter +# https://www.playframework.com/documentation/latest/JavaCsrf#Applying-a-global-CSRF-filter +# ~~~~~ +# Play supports multiple methods for verifying that a request is not a CSRF request. +# The primary mechanism is a CSRF token. This token gets placed either in the query string +# or body of every form submitted, and also gets placed in the users session. +# Play then verifies that both tokens are present and match. +csrf { +# Sets the cookie to be sent only over HTTPS +#cookie.secure = true + +# Defaults to CSRFErrorHandler in the root package. +#errorHandler = MyCSRFErrorHandler +} + +## Security headers filter configuration +# https://www.playframework.com/documentation/latest/SecurityHeaders +# ~~~~~ +# Defines security headers that prevent XSS attacks. +# If enabled, then all options are set to the below configuration by default: +play.filters.headers { + +# The X-Frame-Options header. If null, the header is not set. +#frameOptions = "DENY" + +# The X-XSS-Protection header. If null, the header is not set. +#xssProtection = "1; mode=block" + +# The X-Content-Type-Options header. If null, the header is not set. +#contentTypeOptions = "nosniff" + +# The X-Permitted-Cross-Domain-Policies header. If null, the header is not set. +#permittedCrossDomainPolicies = "master-only" + +# The Content-Security-Policy header. If null, the header is not set. +contentSecurityPolicy = "default-src 'self'" + +# The Referrer-Policy header. If null, the header is not set. +#referrerPolicy = "origin-when-cross-origin, strict-origin-when-cross-origin" + +# If true, allow an action to use .withHeaders to replace one or more of the above headers +#allowActionSpecificHeaders = false +} + +## Allowed hosts filter configuration +# https://www.playframework.com/documentation/latest/AllowedHostsFilter +# ~~~~~ +# Play provides a filter that lets you configure which hosts can access your application. +# This is useful to prevent cache poisoning attacks. +hosts { +# Allow requests to example.com, its subdomains, and localhost:9000. +#allowed = [".example.com", "localhost:9000"] +} +} + +## Evolutions +# https://www.playframework.com/documentation/latest/Evolutions +# ~~~~~ +# Evolutions allows database scripts to be automatically run on startup in dev mode +# for database migrations. You must enable this by adding to build.sbt: +# +# libraryDependencies += evolutions +# +play.evolutions { +# You can disable evolutions for a specific datasource if necessary +#db.default.enabled = false +} + +## Database Connection Pool +# https://www.playframework.com/documentation/latest/SettingsJDBC +# ~~~~~ +# Play doesn't require a JDBC database to run, but you can easily enable one. +# +# libraryDependencies += jdbc +# +play.db { +# The combination of these two settings results in "db.default" as the +# default JDBC pool: +#config = "db" +#default = "default" + +# Play uses HikariCP as the default connection pool. You can override +# settings by changing the prototype: +prototype { +# Sets a fixed JDBC connection pool size of 50 +#hikaricp.minimumIdle = 50 +#hikaricp.maximumPoolSize = 50 +} +} + +## JDBC Datasource +# https://www.playframework.com/documentation/latest/JavaDatabase +# https://www.playframework.com/documentation/latest/ScalaDatabase +# ~~~~~ +# Once JDBC datasource is set up, you can work with several different +# database options: +# +# Slick (Scala preferred option): https://www.playframework.com/documentation/latest/PlaySlick +# JPA (Java preferred option): https://playframework.com/documentation/latest/JavaJPA +# EBean: https://playframework.com/documentation/latest/JavaEbean +# Anorm: https://www.playframework.com/documentation/latest/ScalaAnorm +# +db { +# You can declare as many datasources as you want. +# By convention, the default datasource is named `default` + +# https://www.playframework.com/documentation/latest/Developing-with-the-H2-Database +#default.driver = org.h2.Driver +#default.url = "jdbc:h2:mem:play" +#default.username = sa +#default.password = "" + +# You can turn on SQL logging for any datasource +# https://www.playframework.com/documentation/latest/Highlights25#Logging-SQL-statements +#default.logSql=true +} diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/conf/logback.xml b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/conf/logback.xml new file mode 100644 index 000000000000..01f301ab73a9 --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/conf/logback.xml @@ -0,0 +1,41 @@ + + + + + + + ${application.home:-.}/logs/application.log + + %date [%level] from %logger in %thread - %message%n%xException + + + + + + %coloredLevel %logger{15} - %message%n%xException{10} + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/conf/routes b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/conf/routes new file mode 100644 index 000000000000..eba68941d3bb --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/conf/routes @@ -0,0 +1,15 @@ +# Routes +# This file defines all application routes (Higher priority routes first) +# ~~~~ + +GET /api controllers.ApiDocController.api + + +#Functions for Pet API +POST /v2/pet controllers.PetApiController.addPet(request: Request) +GET /v2/pet/findByStatus controllers.PetApiController.findPetsByStatus(request: Request) +PUT /v2/pet controllers.PetApiController.updatePet(request: Request) + +# Map static resources from the /public folder to the /assets URL path +GET /assets/*file controllers.Assets.at(file) +GET /versionedAssets/*file controllers.Assets.versioned(file) \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/project/build.properties b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/project/build.properties new file mode 100644 index 000000000000..d7ec7acfad24 --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.3.13 \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/project/plugins.sbt b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/project/plugins.sbt new file mode 100644 index 000000000000..318672226e33 --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/project/plugins.sbt @@ -0,0 +1,2 @@ +// The Play plugin +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.3") \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-fake-endpoints-with-security/public/openapi.json b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/public/openapi.json new file mode 100644 index 000000000000..aed3406f2662 --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints-with-security/public/openapi.json @@ -0,0 +1,377 @@ +{ + "openapi" : "3.0.1", + "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" + }, + "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" : { + "operationId" : "addPet", + "requestBody" : { + "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 + }, + "responses" : { + "405" : { + "content" : { }, + "description" : "Invalid input" + } + }, + "security" : [ { + "petstore_token" : [ "base" ] + } ], + "summary" : "Add a new pet to the store", + "tags" : [ "pet" ], + "x-codegen-request-body-name" : "body", + "x-contentType" : "application/json", + "x-accepts" : "application/json" + }, + "put" : { + "operationId" : "updatePet", + "requestBody" : { + "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 + }, + "responses" : { + "400" : { + "content" : { }, + "description" : "Invalid ID supplied" + }, + "404" : { + "content" : { }, + "description" : "Pet not found" + }, + "405" : { + "content" : { }, + "description" : "Validation exception" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Update an existing pet", + "tags" : [ "pet" ], + "x-codegen-request-body-name" : "body", + "x-contentType" : "application/json", + "x-accepts" : "application/json" + } + }, + "/pet/findByStatus" : { + "get" : { + "description" : "Multiple status values can be provided with comma separated strings", + "operationId" : "findPetsByStatus", + "parameters" : [ { + "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" : { + "content" : { }, + "description" : "Invalid status value" + } + }, + "summary" : "Finds Pets by status", + "tags" : [ "pet" ], + "x-accepts" : "application/json" + } + } + }, + "components" : { + "schemas" : { + "Order" : { + "description" : "An order for a pets from the pet store", + "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" : { + "type" : "string" + } + }, + "title" : "Pet category", + "type" : "object", + "xml" : { + "name" : "Category" + } + }, + "User" : { + "description" : "A User who is purchasing from the pet store", + "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" : { + "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", + "properties" : { + "code" : { + "format" : "int32", + "type" : "integer" + }, + "type" : { + "type" : "string" + }, + "message" : { + "type" : "string" + } + }, + "title" : "An uploaded response", + "type" : "object" + } + }, + "securitySchemes" : { + "petstore_token" : { + "description" : "security definition for using keycloak authentification with control site.", + "flows" : { + "authorizationCode" : { + "authorizationUrl" : "https://keycloak-dev.business.stingray.com/auth/realms/CSLocal/protocol/openid-connect/auth", + "scopes" : { + "base" : "not sure if we will be using scopes, at least in the beginning, but since we need to specify one...." + }, + "tokenUrl" : "https://keycloak-dev.business.stingray.com/auth/realms/CSLocal/protocol/openid-connect/token" + } + }, + "type" : "oauth2", + "x-jwksUrl" : "https://keycloak-dev.business.stingray.com/auth/realms/CSLocal/protocol/openid-connect/certs", + "x-tokenIntrospectUrl" : "https://keycloak-dev.business.stingray.com/auth/realms/CSLocal/protocol/openid-connect/token/introspect" + }, + "api_key" : { + "in" : "header", + "name" : "api_key", + "type" : "apiKey" + } + } + }, + "x-original-swagger-version" : "2.0" +} \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/.openapi-generator/FILES b/samples/server/petstore/java-play-framework-fake-endpoints/.openapi-generator/FILES index 93c2a2a954fb..237025d138a3 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/.openapi-generator/FILES +++ b/samples/server/petstore/java-play-framework-fake-endpoints/.openapi-generator/FILES @@ -69,6 +69,7 @@ app/controllers/UserApiControllerImpInterface.java app/openapitools/ApiCall.java app/openapitools/ErrorHandler.java app/openapitools/OpenAPIUtils.java +app/openapitools/SecurityAPIUtils.java build.sbt conf/application.conf conf/logback.xml diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/Module.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/Module.java index eea2541f91c3..10271bf950b7 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/Module.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/Module.java @@ -1,6 +1,7 @@ import com.google.inject.AbstractModule; import controllers.*; +import openapitools.SecurityAPIUtils; public class Module extends AbstractModule { @@ -12,5 +13,6 @@ protected void configure() { bind(PetApiControllerImpInterface.class).to(PetApiControllerImp.class); bind(StoreApiControllerImpInterface.class).to(StoreApiControllerImp.class); bind(UserApiControllerImpInterface.class).to(UserApiControllerImp.class); + bind(SecurityAPIUtils.class); } } \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiControllerImpInterface.java index 98645f472476..b6f4261ee6dd 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiControllerImpInterface.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; import javax.validation.constraints.*; @@ -21,15 +23,19 @@ @SuppressWarnings("RedundantThrows") public abstract class AnotherFakeApiControllerImpInterface { @Inject private Config configuration; + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public Result call123testSpecialTagsHttp(Http.Request request, Client body) throws Exception { Client obj = call123testSpecialTags(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImpInterface.java index ba854ceb3485..b7871b677ac6 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImpInterface.java @@ -22,7 +22,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; import javax.validation.constraints.*; @@ -30,11 +32,12 @@ @SuppressWarnings("RedundantThrows") public abstract class FakeApiControllerImpInterface { @Inject private Config configuration; + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public Result createXmlItemHttp(Http.Request request, XmlItem xmlItem) throws Exception { createXmlItem(request, xmlItem); -return ok(); + return ok(); } @@ -42,8 +45,9 @@ public Result createXmlItemHttp(Http.Request request, XmlItem xmlItem) throws Ex public Result fakeOuterBooleanSerializeHttp(Http.Request request, Boolean body) throws Exception { Boolean obj = fakeOuterBooleanSerialize(request, body); -JsonNode result = mapper.valueToTree(obj); -return ok(result); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -51,11 +55,14 @@ public Result fakeOuterBooleanSerializeHttp(Http.Request request, Boolean body) public Result fakeOuterCompositeSerializeHttp(Http.Request request, OuterComposite body) throws Exception { OuterComposite obj = fakeOuterCompositeSerialize(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -63,11 +70,14 @@ public Result fakeOuterCompositeSerializeHttp(Http.Request request, OuterComposi public Result fakeOuterNumberSerializeHttp(Http.Request request, BigDecimal body) throws Exception { BigDecimal obj = fakeOuterNumberSerialize(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -75,8 +85,9 @@ public Result fakeOuterNumberSerializeHttp(Http.Request request, BigDecimal body public Result fakeOuterStringSerializeHttp(Http.Request request, String body) throws Exception { String obj = fakeOuterStringSerialize(request, body); -JsonNode result = mapper.valueToTree(obj); -return ok(result); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -84,7 +95,7 @@ public Result fakeOuterStringSerializeHttp(Http.Request request, String body) th public Result testBodyWithFileSchemaHttp(Http.Request request, FileSchemaTestClass body) throws Exception { testBodyWithFileSchema(request, body); -return ok(); + return ok(); } @@ -92,7 +103,7 @@ public Result testBodyWithFileSchemaHttp(Http.Request request, FileSchemaTestCla public Result testBodyWithQueryParamsHttp(Http.Request request, @NotNull String query, User body) throws Exception { testBodyWithQueryParams(request, query, body); -return ok(); + return ok(); } @@ -100,11 +111,14 @@ public Result testBodyWithQueryParamsHttp(Http.Request request, @NotNull String public Result testClientModelHttp(Http.Request request, Client body) throws Exception { Client obj = testClientModel(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -112,7 +126,7 @@ public Result testClientModelHttp(Http.Request request, Client body) throws Exce public Result testEndpointParametersHttp(Http.Request request, BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, Http.MultipartFormData.FilePart binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback) throws Exception { testEndpointParameters(request, number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback); -return ok(); + return ok(); } @@ -120,7 +134,7 @@ public Result testEndpointParametersHttp(Http.Request request, BigDecimal number public Result testEnumParametersHttp(Http.Request request, List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString) throws Exception { testEnumParameters(request, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString); -return ok(); + return ok(); } @@ -128,7 +142,7 @@ public Result testEnumParametersHttp(Http.Request request, List enumHead public Result testGroupParametersHttp(Http.Request request, @NotNull Integer requiredStringGroup, Boolean requiredBooleanGroup, @NotNull Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, Long int64Group) throws Exception { testGroupParameters(request, requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group); -return ok(); + return ok(); } @@ -136,7 +150,7 @@ public Result testGroupParametersHttp(Http.Request request, @NotNull Integer req public Result testInlineAdditionalPropertiesHttp(Http.Request request, Map param) throws Exception { testInlineAdditionalProperties(request, param); -return ok(); + return ok(); } @@ -144,7 +158,7 @@ public Result testInlineAdditionalPropertiesHttp(Http.Request request, Map pipe, @NotNull List ioutil, @NotNull List http, @NotNull List url, @NotNull List context) throws Exception { testQueryParameterCollectionFormat(request, pipe, ioutil, http, url, context); -return ok(); + return ok(); } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiControllerImpInterface.java index bc2a36108f83..17286d728b85 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiControllerImpInterface.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; import javax.validation.constraints.*; @@ -21,15 +23,19 @@ @SuppressWarnings("RedundantThrows") public abstract class FakeClassnameTags123ApiControllerImpInterface { @Inject private Config configuration; + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public Result testClassnameHttp(Http.Request request, Client body) throws Exception { Client obj = testClassname(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiControllerImpInterface.java index c68340d59246..2819023e720e 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiControllerImpInterface.java @@ -16,7 +16,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; import javax.validation.constraints.*; @@ -24,47 +26,70 @@ @SuppressWarnings("RedundantThrows") public abstract class PetApiControllerImpInterface { @Inject private Config configuration; + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public Result addPetHttp(Http.Request request, Pet body) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + addPet(request, body); -return ok(); + return ok(); } public abstract void addPet(Http.Request request, Pet body) throws Exception; public Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + deletePet(request, petId, apiKey); -return ok(); + return ok(); } public abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; public Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + List obj = findPetsByStatus(request, status); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); + + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } } - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } public abstract List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; public Result findPetsByTagsHttp(Http.Request request, @NotNull Set tags) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + Set obj = findPetsByTags(request, tags); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); + + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } } - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -72,51 +97,76 @@ public Result findPetsByTagsHttp(Http.Request request, @NotNull Set tags public Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { Pet obj = getPetById(request, petId); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } public abstract Pet getPetById(Http.Request request, Long petId) throws Exception; public Result updatePetHttp(Http.Request request, Pet body) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + updatePet(request, body); -return ok(); + return ok(); } public abstract void updatePet(Http.Request request, Pet body) throws Exception; public Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + updatePetWithForm(request, petId, name, status); -return ok(); + return ok(); } public abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; public Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } public abstract ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; public Result uploadFileWithRequiredFileHttp(Http.Request request, Long petId, Http.MultipartFormData.FilePart requiredFile, String additionalMetadata) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + ModelApiResponse obj = uploadFileWithRequiredFile(request, petId, requiredFile, additionalMetadata); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiControllerImpInterface.java index c2a154007e45..67780d39c1cf 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiControllerImpInterface.java @@ -14,7 +14,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; import javax.validation.constraints.*; @@ -22,11 +24,12 @@ @SuppressWarnings("RedundantThrows") public abstract class StoreApiControllerImpInterface { @Inject private Config configuration; + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { deleteOrder(request, orderId); -return ok(); + return ok(); } @@ -34,8 +37,9 @@ public Result deleteOrderHttp(Http.Request request, String orderId) throws Excep public Result getInventoryHttp(Http.Request request) throws Exception { Map obj = getInventory(request); -JsonNode result = mapper.valueToTree(obj); -return ok(result); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -43,11 +47,14 @@ public Result getInventoryHttp(Http.Request request) throws Exception { public Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { Order obj = getOrderById(request, orderId); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -55,11 +62,14 @@ public Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderI public Result placeOrderHttp(Http.Request request, Order body) throws Exception { Order obj = placeOrder(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiControllerImpInterface.java index 39d422cc1ea4..5ba04804d68a 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiControllerImpInterface.java @@ -15,7 +15,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; import javax.validation.constraints.*; @@ -23,11 +25,12 @@ @SuppressWarnings("RedundantThrows") public abstract class UserApiControllerImpInterface { @Inject private Config configuration; + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public Result createUserHttp(Http.Request request, User body) throws Exception { createUser(request, body); -return ok(); + return ok(); } @@ -35,7 +38,7 @@ public Result createUserHttp(Http.Request request, User body) throws Exception { public Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { createUsersWithArrayInput(request, body); -return ok(); + return ok(); } @@ -43,7 +46,7 @@ public Result createUsersWithArrayInputHttp(Http.Request request, List bod public Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { createUsersWithListInput(request, body); -return ok(); + return ok(); } @@ -51,7 +54,7 @@ public Result createUsersWithListInputHttp(Http.Request request, List body public Result deleteUserHttp(Http.Request request, String username) throws Exception { deleteUser(request, username); -return ok(); + return ok(); } @@ -59,11 +62,14 @@ public Result deleteUserHttp(Http.Request request, String username) throws Excep public Result getUserByNameHttp(Http.Request request, String username) throws Exception { User obj = getUserByName(request, username); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -71,8 +77,9 @@ public Result getUserByNameHttp(Http.Request request, String username) throws Ex public Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { String obj = loginUser(request, username, password); -JsonNode result = mapper.valueToTree(obj); -return ok(result); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -80,7 +87,7 @@ public Result loginUserHttp(Http.Request request, @NotNull String username, @Not public Result logoutUserHttp(Http.Request request) throws Exception { logoutUser(request); -return ok(); + return ok(); } @@ -88,7 +95,7 @@ public Result logoutUserHttp(Http.Request request) throws Exception { public Result updateUserHttp(Http.Request request, String username, User body) throws Exception { updateUser(request, username, body); -return ok(); + return ok(); } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/openapitools/SecurityAPIUtils.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/openapitools/SecurityAPIUtils.java new file mode 100644 index 000000000000..854be87f65a8 --- /dev/null +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/openapitools/SecurityAPIUtils.java @@ -0,0 +1,165 @@ +package openapitools; + +import com.auth0.jwk.Jwk; +import com.auth0.jwk.UrlJwkProvider; +import com.auth0.jwt.JWT; +import com.auth0.jwt.JWTVerifier; +import com.auth0.jwt.algorithms.Algorithm; +import com.auth0.jwt.interfaces.DecodedJWT; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import org.apache.http.HttpHeaders; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.NameValuePair; +import org.apache.http.client.HttpClient; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; +import play.mvc.Http; + +import java.net.URL; +import java.security.PublicKey; +import java.security.interfaces.RSAPublicKey; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; + +@Singleton +public class SecurityAPIUtils { + private final String bearerPrefix = "Bearer "; + private final ObjectMapper mapper; + + private boolean useOnlineValidation = false; + + // Online validation + private HashMap tokenIntrospectEndpoints = new HashMap<>(); + private final String clientId; + private final String clientSecret; + + // Offline validation + private HashMap jwksEndpoints = new HashMap<>(); + private String tokenKeyId = ""; + private JWTVerifier tokenVerifier; //Reusable verifier instance until tokenKeyId changes. + + @Inject + SecurityAPIUtils(Config configuration) { + mapper = new ObjectMapper(); + + clientId = configuration.hasPath("oauth.clientId") ? configuration.getString("oauth.clientId") : ""; + clientSecret = configuration.hasPath("oauth.clientSecret") ? configuration.getString("oauth.clientSecret") : ""; + + tokenIntrospectEndpoints.put("petstore_auth", ""); + + jwksEndpoints.put("petstore_auth", ""); + } + + private boolean isRequestTokenValidByOnlineCheck(Http.Request request, String securityMethodName) { + try { + Optional authToken = request.getHeaders().get(HttpHeaders.AUTHORIZATION); + + if (authToken.isPresent()) { + String tokenWithoutBearerPrefix = authToken.get().substring(bearerPrefix.length()); + + HttpClientBuilder builder = HttpClientBuilder.create(); + HttpClient httpClient = builder.build(); + HttpPost httppost = new HttpPost(this.tokenIntrospectEndpoints.get(securityMethodName)); + + List params = new ArrayList<>(); + params.add(new BasicNameValuePair("token", tokenWithoutBearerPrefix)); + params.add(new BasicNameValuePair("client_id", clientId)); + params.add(new BasicNameValuePair("client_secret", clientSecret)); + httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); + + HttpResponse response = httpClient.execute(httppost); + String responseJsonString = EntityUtils.toString(response.getEntity()); + HashMap responseJsonObject = mapper.readValue(responseJsonString, HashMap.class); + + return response.getStatusLine().getStatusCode() == HttpStatus.SC_OK && (boolean) responseJsonObject.get("active"); + } + } catch (Exception exception) { + return false; + } + + return false; + } + + private boolean isRequestTokenValidByOfflineCheck(Http.Request request, String securityMethodName) { + try { + Optional authHeader = request.getHeaders().get(HttpHeaders.AUTHORIZATION); + + if (authHeader.isPresent()) { + String bearerToken = authHeader.get().substring(bearerPrefix.length()); + return isTokenValidByOfflineCheck(bearerToken, securityMethodName); + } + } catch (Exception exception) { + return false; + } + + return false; + } + + public boolean isTokenValidByOfflineCheck(String bearerToken, String securityMethodName) { + try { + DecodedJWT jwt = JWT.decode(bearerToken); + String issuer = jwt.getIssuer(); + String keyId = jwt.getKeyId(); + if (!tokenKeyId.equals(keyId)) { + if (securityMethodName == null) { + securityMethodName = jwksEndpoints.keySet().stream().findFirst().get(); + } + + Jwk jwk = new UrlJwkProvider(new URL(this.jwksEndpoints.get(securityMethodName))).get(keyId); + final PublicKey publicKey = jwk.getPublicKey(); + + if (!(publicKey instanceof RSAPublicKey)) { + throw new IllegalArgumentException(String.format("Key with ID %s was found in JWKS but is not a RSA-key.", keyId)); + } + + Algorithm algorithm = Algorithm.RSA256((RSAPublicKey) publicKey, null); + tokenVerifier = JWT.require(algorithm) + .withIssuer(issuer) + .build(); + tokenKeyId = keyId; + } + + DecodedJWT verifiedJWT = tokenVerifier.verify(bearerToken); + + return true; + } catch (Exception exception) { + return false; + } + } + + public String getOAuthUserIdFromRequestToken(Http.Request requestWithPreviouslyVerifiedToken) { + try { + Optional authHeader = requestWithPreviouslyVerifiedToken.getHeaders().get(HttpHeaders.AUTHORIZATION); + if (authHeader.isPresent()) { + String bearerToken = authHeader.get().substring(bearerPrefix.length()); + return getOAuthUserIdFromToken(bearerToken); + } + } catch (Exception exception) { + return null; + } + + return null; + } + + public String getOAuthUserIdFromToken(String bearerToken) { + try { + DecodedJWT jwt = JWT.decode(bearerToken); + return jwt.getSubject(); + } catch (Exception exception) { + return null; + } + } + + public boolean isRequestTokenValid(Http.Request request, String securityMethodName) { + return useOnlineValidation ? isRequestTokenValidByOnlineCheck(request, securityMethodName) : isRequestTokenValidByOfflineCheck(request, securityMethodName); + } +} diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/build.sbt b/samples/server/petstore/java-play-framework-fake-endpoints/build.sbt index b972893fc3f7..69dfa74cd8ad 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/build.sbt +++ b/samples/server/petstore/java-play-framework-fake-endpoints/build.sbt @@ -9,3 +9,6 @@ scalaVersion := "2.12.6" libraryDependencies += "org.webjars" % "swagger-ui" % "3.32.5" libraryDependencies += "javax.validation" % "validation-api" % "2.0.1.Final" libraryDependencies += guice +libraryDependencies += "com.auth0" % "java-jwt" % "3.18.1" +libraryDependencies += "com.auth0" % "jwks-rsa" % "0.19.0" +libraryDependencies += "org.apache.httpcomponents" % "httpclient" % "4.5.6" diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/.openapi-generator/FILES b/samples/server/petstore/java-play-framework-no-bean-validation/.openapi-generator/FILES index f517461d8913..283bce384731 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/.openapi-generator/FILES +++ b/samples/server/petstore/java-play-framework-no-bean-validation/.openapi-generator/FILES @@ -20,6 +20,7 @@ app/controllers/UserApiControllerImpInterface.java app/openapitools/ApiCall.java app/openapitools/ErrorHandler.java app/openapitools/OpenAPIUtils.java +app/openapitools/SecurityAPIUtils.java build.sbt conf/application.conf conf/logback.xml diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/Module.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/Module.java index f1b062c29345..1439bbe30c1a 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/Module.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/Module.java @@ -1,6 +1,7 @@ import com.google.inject.AbstractModule; import controllers.*; +import openapitools.SecurityAPIUtils; public class Module extends AbstractModule { @@ -9,5 +10,6 @@ protected void configure() { bind(PetApiControllerImpInterface.class).to(PetApiControllerImp.class); bind(StoreApiControllerImpInterface.class).to(StoreApiControllerImp.class); bind(UserApiControllerImpInterface.class).to(UserApiControllerImp.class); + bind(SecurityAPIUtils.class); } } \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiControllerImpInterface.java index afb1f19802f3..d98f6ae3fd10 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiControllerImpInterface.java @@ -15,43 +15,64 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; @SuppressWarnings("RedundantThrows") public abstract class PetApiControllerImpInterface { + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public Result addPetHttp(Http.Request request, Pet body) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + addPet(request, body); -return ok(); + return ok(); } public abstract void addPet(Http.Request request, Pet body) throws Exception; public Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + deletePet(request, petId, apiKey); -return ok(); + return ok(); } public abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; public Result findPetsByStatusHttp(Http.Request request, List status) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + List obj = findPetsByStatus(request, status); -JsonNode result = mapper.valueToTree(obj); -return ok(result); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } public abstract List findPetsByStatus(Http.Request request, List status) throws Exception; public Result findPetsByTagsHttp(Http.Request request, List tags) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + List obj = findPetsByTags(request, tags); -JsonNode result = mapper.valueToTree(obj); -return ok(result); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -59,33 +80,47 @@ public Result findPetsByTagsHttp(Http.Request request, List tags) throws public Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { Pet obj = getPetById(request, petId); -JsonNode result = mapper.valueToTree(obj); -return ok(result); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } public abstract Pet getPetById(Http.Request request, Long petId) throws Exception; public Result updatePetHttp(Http.Request request, Pet body) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + updatePet(request, body); -return ok(); + return ok(); } public abstract void updatePet(Http.Request request, Pet body) throws Exception; public Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + updatePetWithForm(request, petId, name, status); -return ok(); + return ok(); } public abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; public Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); -JsonNode result = mapper.valueToTree(obj); -return ok(result); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiControllerImpInterface.java index 313dcfd465b7..f846c7ec9c8b 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiControllerImpInterface.java @@ -14,17 +14,20 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; @SuppressWarnings("RedundantThrows") public abstract class StoreApiControllerImpInterface { + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { deleteOrder(request, orderId); -return ok(); + return ok(); } @@ -32,8 +35,9 @@ public Result deleteOrderHttp(Http.Request request, String orderId) throws Excep public Result getInventoryHttp(Http.Request request) throws Exception { Map obj = getInventory(request); -JsonNode result = mapper.valueToTree(obj); -return ok(result); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -41,8 +45,9 @@ public Result getInventoryHttp(Http.Request request) throws Exception { public Result getOrderByIdHttp(Http.Request request, Long orderId) throws Exception { Order obj = getOrderById(request, orderId); -JsonNode result = mapper.valueToTree(obj); -return ok(result); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -50,8 +55,9 @@ public Result getOrderByIdHttp(Http.Request request, Long orderId) throws Except public Result placeOrderHttp(Http.Request request, Order body) throws Exception { Order obj = placeOrder(request, body); -JsonNode result = mapper.valueToTree(obj); -return ok(result); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiControllerImpInterface.java index 722d76055f70..f1590489fdd9 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiControllerImpInterface.java @@ -15,17 +15,20 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; @SuppressWarnings("RedundantThrows") public abstract class UserApiControllerImpInterface { + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public Result createUserHttp(Http.Request request, User body) throws Exception { createUser(request, body); -return ok(); + return ok(); } @@ -33,7 +36,7 @@ public Result createUserHttp(Http.Request request, User body) throws Exception { public Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { createUsersWithArrayInput(request, body); -return ok(); + return ok(); } @@ -41,7 +44,7 @@ public Result createUsersWithArrayInputHttp(Http.Request request, List bod public Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { createUsersWithListInput(request, body); -return ok(); + return ok(); } @@ -49,7 +52,7 @@ public Result createUsersWithListInputHttp(Http.Request request, List body public Result deleteUserHttp(Http.Request request, String username) throws Exception { deleteUser(request, username); -return ok(); + return ok(); } @@ -57,8 +60,9 @@ public Result deleteUserHttp(Http.Request request, String username) throws Excep public Result getUserByNameHttp(Http.Request request, String username) throws Exception { User obj = getUserByName(request, username); -JsonNode result = mapper.valueToTree(obj); -return ok(result); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -66,8 +70,9 @@ public Result getUserByNameHttp(Http.Request request, String username) throws Ex public Result loginUserHttp(Http.Request request, String username, String password) throws Exception { String obj = loginUser(request, username, password); -JsonNode result = mapper.valueToTree(obj); -return ok(result); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -75,7 +80,7 @@ public Result loginUserHttp(Http.Request request, String username, String passwo public Result logoutUserHttp(Http.Request request) throws Exception { logoutUser(request); -return ok(); + return ok(); } @@ -83,7 +88,7 @@ public Result logoutUserHttp(Http.Request request) throws Exception { public Result updateUserHttp(Http.Request request, String username, User body) throws Exception { updateUser(request, username, body); -return ok(); + return ok(); } diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/openapitools/SecurityAPIUtils.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/openapitools/SecurityAPIUtils.java new file mode 100644 index 000000000000..854be87f65a8 --- /dev/null +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/openapitools/SecurityAPIUtils.java @@ -0,0 +1,165 @@ +package openapitools; + +import com.auth0.jwk.Jwk; +import com.auth0.jwk.UrlJwkProvider; +import com.auth0.jwt.JWT; +import com.auth0.jwt.JWTVerifier; +import com.auth0.jwt.algorithms.Algorithm; +import com.auth0.jwt.interfaces.DecodedJWT; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import org.apache.http.HttpHeaders; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.NameValuePair; +import org.apache.http.client.HttpClient; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; +import play.mvc.Http; + +import java.net.URL; +import java.security.PublicKey; +import java.security.interfaces.RSAPublicKey; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; + +@Singleton +public class SecurityAPIUtils { + private final String bearerPrefix = "Bearer "; + private final ObjectMapper mapper; + + private boolean useOnlineValidation = false; + + // Online validation + private HashMap tokenIntrospectEndpoints = new HashMap<>(); + private final String clientId; + private final String clientSecret; + + // Offline validation + private HashMap jwksEndpoints = new HashMap<>(); + private String tokenKeyId = ""; + private JWTVerifier tokenVerifier; //Reusable verifier instance until tokenKeyId changes. + + @Inject + SecurityAPIUtils(Config configuration) { + mapper = new ObjectMapper(); + + clientId = configuration.hasPath("oauth.clientId") ? configuration.getString("oauth.clientId") : ""; + clientSecret = configuration.hasPath("oauth.clientSecret") ? configuration.getString("oauth.clientSecret") : ""; + + tokenIntrospectEndpoints.put("petstore_auth", ""); + + jwksEndpoints.put("petstore_auth", ""); + } + + private boolean isRequestTokenValidByOnlineCheck(Http.Request request, String securityMethodName) { + try { + Optional authToken = request.getHeaders().get(HttpHeaders.AUTHORIZATION); + + if (authToken.isPresent()) { + String tokenWithoutBearerPrefix = authToken.get().substring(bearerPrefix.length()); + + HttpClientBuilder builder = HttpClientBuilder.create(); + HttpClient httpClient = builder.build(); + HttpPost httppost = new HttpPost(this.tokenIntrospectEndpoints.get(securityMethodName)); + + List params = new ArrayList<>(); + params.add(new BasicNameValuePair("token", tokenWithoutBearerPrefix)); + params.add(new BasicNameValuePair("client_id", clientId)); + params.add(new BasicNameValuePair("client_secret", clientSecret)); + httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); + + HttpResponse response = httpClient.execute(httppost); + String responseJsonString = EntityUtils.toString(response.getEntity()); + HashMap responseJsonObject = mapper.readValue(responseJsonString, HashMap.class); + + return response.getStatusLine().getStatusCode() == HttpStatus.SC_OK && (boolean) responseJsonObject.get("active"); + } + } catch (Exception exception) { + return false; + } + + return false; + } + + private boolean isRequestTokenValidByOfflineCheck(Http.Request request, String securityMethodName) { + try { + Optional authHeader = request.getHeaders().get(HttpHeaders.AUTHORIZATION); + + if (authHeader.isPresent()) { + String bearerToken = authHeader.get().substring(bearerPrefix.length()); + return isTokenValidByOfflineCheck(bearerToken, securityMethodName); + } + } catch (Exception exception) { + return false; + } + + return false; + } + + public boolean isTokenValidByOfflineCheck(String bearerToken, String securityMethodName) { + try { + DecodedJWT jwt = JWT.decode(bearerToken); + String issuer = jwt.getIssuer(); + String keyId = jwt.getKeyId(); + if (!tokenKeyId.equals(keyId)) { + if (securityMethodName == null) { + securityMethodName = jwksEndpoints.keySet().stream().findFirst().get(); + } + + Jwk jwk = new UrlJwkProvider(new URL(this.jwksEndpoints.get(securityMethodName))).get(keyId); + final PublicKey publicKey = jwk.getPublicKey(); + + if (!(publicKey instanceof RSAPublicKey)) { + throw new IllegalArgumentException(String.format("Key with ID %s was found in JWKS but is not a RSA-key.", keyId)); + } + + Algorithm algorithm = Algorithm.RSA256((RSAPublicKey) publicKey, null); + tokenVerifier = JWT.require(algorithm) + .withIssuer(issuer) + .build(); + tokenKeyId = keyId; + } + + DecodedJWT verifiedJWT = tokenVerifier.verify(bearerToken); + + return true; + } catch (Exception exception) { + return false; + } + } + + public String getOAuthUserIdFromRequestToken(Http.Request requestWithPreviouslyVerifiedToken) { + try { + Optional authHeader = requestWithPreviouslyVerifiedToken.getHeaders().get(HttpHeaders.AUTHORIZATION); + if (authHeader.isPresent()) { + String bearerToken = authHeader.get().substring(bearerPrefix.length()); + return getOAuthUserIdFromToken(bearerToken); + } + } catch (Exception exception) { + return null; + } + + return null; + } + + public String getOAuthUserIdFromToken(String bearerToken) { + try { + DecodedJWT jwt = JWT.decode(bearerToken); + return jwt.getSubject(); + } catch (Exception exception) { + return null; + } + } + + public boolean isRequestTokenValid(Http.Request request, String securityMethodName) { + return useOnlineValidation ? isRequestTokenValidByOnlineCheck(request, securityMethodName) : isRequestTokenValidByOfflineCheck(request, securityMethodName); + } +} diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/build.sbt b/samples/server/petstore/java-play-framework-no-bean-validation/build.sbt index 2b72c7e17af4..5e356fcab668 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/build.sbt +++ b/samples/server/petstore/java-play-framework-no-bean-validation/build.sbt @@ -8,3 +8,6 @@ scalaVersion := "2.12.6" libraryDependencies += "org.webjars" % "swagger-ui" % "3.32.5" libraryDependencies += guice +libraryDependencies += "com.auth0" % "java-jwt" % "3.18.1" +libraryDependencies += "com.auth0" % "jwks-rsa" % "0.19.0" +libraryDependencies += "org.apache.httpcomponents" % "httpclient" % "4.5.6" diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/.openapi-generator/FILES b/samples/server/petstore/java-play-framework-no-exception-handling/.openapi-generator/FILES index 993e9b26d34d..384973dc5517 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/.openapi-generator/FILES +++ b/samples/server/petstore/java-play-framework-no-exception-handling/.openapi-generator/FILES @@ -19,6 +19,7 @@ app/controllers/UserApiControllerImp.java app/controllers/UserApiControllerImpInterface.java app/openapitools/ApiCall.java app/openapitools/OpenAPIUtils.java +app/openapitools/SecurityAPIUtils.java build.sbt conf/application.conf conf/logback.xml diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/Module.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/Module.java index f1b062c29345..1439bbe30c1a 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/Module.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/Module.java @@ -1,6 +1,7 @@ import com.google.inject.AbstractModule; import controllers.*; +import openapitools.SecurityAPIUtils; public class Module extends AbstractModule { @@ -9,5 +10,6 @@ protected void configure() { bind(PetApiControllerImpInterface.class).to(PetApiControllerImp.class); bind(StoreApiControllerImpInterface.class).to(StoreApiControllerImp.class); bind(UserApiControllerImpInterface.class).to(UserApiControllerImp.class); + bind(SecurityAPIUtils.class); } } \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiControllerImpInterface.java index 956acccf5eba..846514e5ad1e 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiControllerImpInterface.java @@ -15,7 +15,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; import javax.validation.constraints.*; @@ -23,47 +25,70 @@ @SuppressWarnings("RedundantThrows") public abstract class PetApiControllerImpInterface { @Inject private Config configuration; + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public Result addPetHttp(Http.Request request, Pet body) { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + addPet(request, body); -return ok(); + return ok(); } public abstract void addPet(Http.Request request, Pet body) ; public Result deletePetHttp(Http.Request request, Long petId, String apiKey) { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + deletePet(request, petId, apiKey); -return ok(); + return ok(); } public abstract void deletePet(Http.Request request, Long petId, String apiKey) ; public Result findPetsByStatusHttp(Http.Request request, @NotNull List status) { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + List obj = findPetsByStatus(request, status); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); + + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } } - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } public abstract List findPetsByStatus(Http.Request request, @NotNull List status) ; public Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + List obj = findPetsByTags(request, tags); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); + + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } } - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -71,39 +96,57 @@ public Result findPetsByTagsHttp(Http.Request request, @NotNull List tag public Result getPetByIdHttp(Http.Request request, Long petId) { Pet obj = getPetById(request, petId); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } public abstract Pet getPetById(Http.Request request, Long petId) ; public Result updatePetHttp(Http.Request request, Pet body) { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + updatePet(request, body); -return ok(); + return ok(); } public abstract void updatePet(Http.Request request, Pet body) ; public Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + updatePetWithForm(request, petId, name, status); -return ok(); + return ok(); } public abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) ; public Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiControllerImpInterface.java index d0ceb3639bcf..31e5240767ad 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiControllerImpInterface.java @@ -14,7 +14,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; import javax.validation.constraints.*; @@ -22,11 +24,12 @@ @SuppressWarnings("RedundantThrows") public abstract class StoreApiControllerImpInterface { @Inject private Config configuration; + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public Result deleteOrderHttp(Http.Request request, String orderId) { deleteOrder(request, orderId); -return ok(); + return ok(); } @@ -34,8 +37,9 @@ public Result deleteOrderHttp(Http.Request request, String orderId) { public Result getInventoryHttp(Http.Request request) { Map obj = getInventory(request); -JsonNode result = mapper.valueToTree(obj); -return ok(result); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -43,11 +47,14 @@ public Result getInventoryHttp(Http.Request request) { public Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) { Order obj = getOrderById(request, orderId); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -55,11 +62,14 @@ public Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderI public Result placeOrderHttp(Http.Request request, Order body) { Order obj = placeOrder(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiControllerImpInterface.java index 4a83cce61987..f5dc87e54db3 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiControllerImpInterface.java @@ -15,7 +15,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; import javax.validation.constraints.*; @@ -23,11 +25,12 @@ @SuppressWarnings("RedundantThrows") public abstract class UserApiControllerImpInterface { @Inject private Config configuration; + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public Result createUserHttp(Http.Request request, User body) { createUser(request, body); -return ok(); + return ok(); } @@ -35,7 +38,7 @@ public Result createUserHttp(Http.Request request, User body) { public Result createUsersWithArrayInputHttp(Http.Request request, List body) { createUsersWithArrayInput(request, body); -return ok(); + return ok(); } @@ -43,7 +46,7 @@ public Result createUsersWithArrayInputHttp(Http.Request request, List bod public Result createUsersWithListInputHttp(Http.Request request, List body) { createUsersWithListInput(request, body); -return ok(); + return ok(); } @@ -51,7 +54,7 @@ public Result createUsersWithListInputHttp(Http.Request request, List body public Result deleteUserHttp(Http.Request request, String username) { deleteUser(request, username); -return ok(); + return ok(); } @@ -59,11 +62,14 @@ public Result deleteUserHttp(Http.Request request, String username) { public Result getUserByNameHttp(Http.Request request, String username) { User obj = getUserByName(request, username); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -71,8 +77,9 @@ public Result getUserByNameHttp(Http.Request request, String username) { public Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) { String obj = loginUser(request, username, password); -JsonNode result = mapper.valueToTree(obj); -return ok(result); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -80,7 +87,7 @@ public Result loginUserHttp(Http.Request request, @NotNull String username, @Not public Result logoutUserHttp(Http.Request request) { logoutUser(request); -return ok(); + return ok(); } @@ -88,7 +95,7 @@ public Result logoutUserHttp(Http.Request request) { public Result updateUserHttp(Http.Request request, String username, User body) { updateUser(request, username, body); -return ok(); + return ok(); } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/openapitools/SecurityAPIUtils.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/openapitools/SecurityAPIUtils.java new file mode 100644 index 000000000000..854be87f65a8 --- /dev/null +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/openapitools/SecurityAPIUtils.java @@ -0,0 +1,165 @@ +package openapitools; + +import com.auth0.jwk.Jwk; +import com.auth0.jwk.UrlJwkProvider; +import com.auth0.jwt.JWT; +import com.auth0.jwt.JWTVerifier; +import com.auth0.jwt.algorithms.Algorithm; +import com.auth0.jwt.interfaces.DecodedJWT; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import org.apache.http.HttpHeaders; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.NameValuePair; +import org.apache.http.client.HttpClient; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; +import play.mvc.Http; + +import java.net.URL; +import java.security.PublicKey; +import java.security.interfaces.RSAPublicKey; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; + +@Singleton +public class SecurityAPIUtils { + private final String bearerPrefix = "Bearer "; + private final ObjectMapper mapper; + + private boolean useOnlineValidation = false; + + // Online validation + private HashMap tokenIntrospectEndpoints = new HashMap<>(); + private final String clientId; + private final String clientSecret; + + // Offline validation + private HashMap jwksEndpoints = new HashMap<>(); + private String tokenKeyId = ""; + private JWTVerifier tokenVerifier; //Reusable verifier instance until tokenKeyId changes. + + @Inject + SecurityAPIUtils(Config configuration) { + mapper = new ObjectMapper(); + + clientId = configuration.hasPath("oauth.clientId") ? configuration.getString("oauth.clientId") : ""; + clientSecret = configuration.hasPath("oauth.clientSecret") ? configuration.getString("oauth.clientSecret") : ""; + + tokenIntrospectEndpoints.put("petstore_auth", ""); + + jwksEndpoints.put("petstore_auth", ""); + } + + private boolean isRequestTokenValidByOnlineCheck(Http.Request request, String securityMethodName) { + try { + Optional authToken = request.getHeaders().get(HttpHeaders.AUTHORIZATION); + + if (authToken.isPresent()) { + String tokenWithoutBearerPrefix = authToken.get().substring(bearerPrefix.length()); + + HttpClientBuilder builder = HttpClientBuilder.create(); + HttpClient httpClient = builder.build(); + HttpPost httppost = new HttpPost(this.tokenIntrospectEndpoints.get(securityMethodName)); + + List params = new ArrayList<>(); + params.add(new BasicNameValuePair("token", tokenWithoutBearerPrefix)); + params.add(new BasicNameValuePair("client_id", clientId)); + params.add(new BasicNameValuePair("client_secret", clientSecret)); + httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); + + HttpResponse response = httpClient.execute(httppost); + String responseJsonString = EntityUtils.toString(response.getEntity()); + HashMap responseJsonObject = mapper.readValue(responseJsonString, HashMap.class); + + return response.getStatusLine().getStatusCode() == HttpStatus.SC_OK && (boolean) responseJsonObject.get("active"); + } + } catch (Exception exception) { + return false; + } + + return false; + } + + private boolean isRequestTokenValidByOfflineCheck(Http.Request request, String securityMethodName) { + try { + Optional authHeader = request.getHeaders().get(HttpHeaders.AUTHORIZATION); + + if (authHeader.isPresent()) { + String bearerToken = authHeader.get().substring(bearerPrefix.length()); + return isTokenValidByOfflineCheck(bearerToken, securityMethodName); + } + } catch (Exception exception) { + return false; + } + + return false; + } + + public boolean isTokenValidByOfflineCheck(String bearerToken, String securityMethodName) { + try { + DecodedJWT jwt = JWT.decode(bearerToken); + String issuer = jwt.getIssuer(); + String keyId = jwt.getKeyId(); + if (!tokenKeyId.equals(keyId)) { + if (securityMethodName == null) { + securityMethodName = jwksEndpoints.keySet().stream().findFirst().get(); + } + + Jwk jwk = new UrlJwkProvider(new URL(this.jwksEndpoints.get(securityMethodName))).get(keyId); + final PublicKey publicKey = jwk.getPublicKey(); + + if (!(publicKey instanceof RSAPublicKey)) { + throw new IllegalArgumentException(String.format("Key with ID %s was found in JWKS but is not a RSA-key.", keyId)); + } + + Algorithm algorithm = Algorithm.RSA256((RSAPublicKey) publicKey, null); + tokenVerifier = JWT.require(algorithm) + .withIssuer(issuer) + .build(); + tokenKeyId = keyId; + } + + DecodedJWT verifiedJWT = tokenVerifier.verify(bearerToken); + + return true; + } catch (Exception exception) { + return false; + } + } + + public String getOAuthUserIdFromRequestToken(Http.Request requestWithPreviouslyVerifiedToken) { + try { + Optional authHeader = requestWithPreviouslyVerifiedToken.getHeaders().get(HttpHeaders.AUTHORIZATION); + if (authHeader.isPresent()) { + String bearerToken = authHeader.get().substring(bearerPrefix.length()); + return getOAuthUserIdFromToken(bearerToken); + } + } catch (Exception exception) { + return null; + } + + return null; + } + + public String getOAuthUserIdFromToken(String bearerToken) { + try { + DecodedJWT jwt = JWT.decode(bearerToken); + return jwt.getSubject(); + } catch (Exception exception) { + return null; + } + } + + public boolean isRequestTokenValid(Http.Request request, String securityMethodName) { + return useOnlineValidation ? isRequestTokenValidByOnlineCheck(request, securityMethodName) : isRequestTokenValidByOfflineCheck(request, securityMethodName); + } +} diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/build.sbt b/samples/server/petstore/java-play-framework-no-exception-handling/build.sbt index b972893fc3f7..69dfa74cd8ad 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/build.sbt +++ b/samples/server/petstore/java-play-framework-no-exception-handling/build.sbt @@ -9,3 +9,6 @@ scalaVersion := "2.12.6" libraryDependencies += "org.webjars" % "swagger-ui" % "3.32.5" libraryDependencies += "javax.validation" % "validation-api" % "2.0.1.Final" libraryDependencies += guice +libraryDependencies += "com.auth0" % "java-jwt" % "3.18.1" +libraryDependencies += "com.auth0" % "jwks-rsa" % "0.19.0" +libraryDependencies += "org.apache.httpcomponents" % "httpclient" % "4.5.6" diff --git a/samples/server/petstore/java-play-framework-no-interface/.openapi-generator/FILES b/samples/server/petstore/java-play-framework-no-interface/.openapi-generator/FILES index 2dfa912dd9ed..55a72489983f 100644 --- a/samples/server/petstore/java-play-framework-no-interface/.openapi-generator/FILES +++ b/samples/server/petstore/java-play-framework-no-interface/.openapi-generator/FILES @@ -16,6 +16,7 @@ app/controllers/UserApiControllerImp.java app/openapitools/ApiCall.java app/openapitools/ErrorHandler.java app/openapitools/OpenAPIUtils.java +app/openapitools/SecurityAPIUtils.java build.sbt conf/application.conf conf/logback.xml diff --git a/samples/server/petstore/java-play-framework-no-interface/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-interface/app/controllers/PetApiController.java index ee2e9073da8d..c5a43c3bd588 100644 --- a/samples/server/petstore/java-play-framework-no-interface/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-interface/app/controllers/PetApiController.java @@ -18,6 +18,7 @@ import java.io.File; import play.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; @@ -30,12 +31,14 @@ public class PetApiController extends Controller { private final PetApiControllerImp imp; private final ObjectMapper mapper; private final Config configuration; + private final SecurityAPIUtils securityAPIUtils; @Inject - private PetApiController(Config configuration, PetApiControllerImp imp) { + private PetApiController(Config configuration, PetApiControllerImp imp, SecurityAPIUtils securityAPIUtils) { this.imp = imp; mapper = new ObjectMapper(); this.configuration = configuration; + this.securityAPIUtils = securityAPIUtils; } @ApiAction @@ -50,8 +53,12 @@ public Result addPet(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + imp.addPet(request, body); -return ok(); + return ok(); } @@ -64,8 +71,12 @@ public Result deletePet(Http.Request request, Long petId) throws Exception { } else { apiKey = null; } + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + imp.deletePet(request, petId, apiKey); -return ok(); + return ok(); } @@ -83,14 +94,21 @@ public Result findPetsByStatus(Http.Request request) throws Exception { status.add(curParam); } } + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + List obj = imp.findPetsByStatus(request, status); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); + + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } } - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -108,25 +126,35 @@ public Result findPetsByTags(Http.Request request) throws Exception { tags.add(curParam); } } + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + List obj = imp.findPetsByTags(request, tags); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); + + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } } - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @ApiAction public Result getPetById(Http.Request request, Long petId) throws Exception { - Pet obj = imp.getPetById(request, petId); - if (configuration.getBoolean("useOutputBeanValidation")) { + Pet obj = imp.getPetById(request, petId); + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -142,8 +170,12 @@ public Result updatePet(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + imp.updatePet(request, body); -return ok(); + return ok(); } @@ -163,8 +195,12 @@ public Result updatePetWithForm(Http.Request request, Long petId) throws Excepti } else { status = null; } + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + imp.updatePetWithForm(request, petId, name, status); -return ok(); + return ok(); } @@ -179,12 +215,19 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { } Http.MultipartFormData bodyfile = request.body().asMultipartFormData(); Http.MultipartFormData.FilePart file = bodyfile.getFile("file"); + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + ModelApiResponse obj = imp.uploadFile(request, petId, additionalMetadata, file); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } diff --git a/samples/server/petstore/java-play-framework-no-interface/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-no-interface/app/controllers/StoreApiController.java index 43b28fd9728f..67f0cd4e3023 100644 --- a/samples/server/petstore/java-play-framework-no-interface/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-no-interface/app/controllers/StoreApiController.java @@ -17,6 +17,7 @@ import java.io.File; import play.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; @@ -29,37 +30,43 @@ public class StoreApiController extends Controller { private final StoreApiControllerImp imp; private final ObjectMapper mapper; private final Config configuration; + private final SecurityAPIUtils securityAPIUtils; @Inject - private StoreApiController(Config configuration, StoreApiControllerImp imp) { + private StoreApiController(Config configuration, StoreApiControllerImp imp, SecurityAPIUtils securityAPIUtils) { this.imp = imp; mapper = new ObjectMapper(); this.configuration = configuration; + this.securityAPIUtils = securityAPIUtils; } @ApiAction public Result deleteOrder(Http.Request request, String orderId) throws Exception { - imp.deleteOrder(request, orderId); -return ok(); + imp.deleteOrder(request, orderId); + return ok(); } @ApiAction public Result getInventory(Http.Request request) throws Exception { - Map obj = imp.getInventory(request); -JsonNode result = mapper.valueToTree(obj); -return ok(result); + Map obj = imp.getInventory(request); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @ApiAction public Result getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { - Order obj = imp.getOrderById(request, orderId); - if (configuration.getBoolean("useOutputBeanValidation")) { + Order obj = imp.getOrderById(request, orderId); + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -75,12 +82,15 @@ public Result placeOrder(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - Order obj = imp.placeOrder(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { + Order obj = imp.placeOrder(request, body); + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } diff --git a/samples/server/petstore/java-play-framework-no-interface/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-no-interface/app/controllers/UserApiController.java index e8c0a2f4123e..740ead6864cb 100644 --- a/samples/server/petstore/java-play-framework-no-interface/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-no-interface/app/controllers/UserApiController.java @@ -18,6 +18,7 @@ import java.io.File; import play.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; @@ -30,12 +31,14 @@ public class UserApiController extends Controller { private final UserApiControllerImp imp; private final ObjectMapper mapper; private final Config configuration; + private final SecurityAPIUtils securityAPIUtils; @Inject - private UserApiController(Config configuration, UserApiControllerImp imp) { + private UserApiController(Config configuration, UserApiControllerImp imp, SecurityAPIUtils securityAPIUtils) { this.imp = imp; mapper = new ObjectMapper(); this.configuration = configuration; + this.securityAPIUtils = securityAPIUtils; } @ApiAction @@ -50,8 +53,8 @@ public Result createUser(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUser(request, body); -return ok(); + imp.createUser(request, body); + return ok(); } @@ -69,8 +72,8 @@ public Result createUsersWithArrayInput(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUsersWithArrayInput(request, body); -return ok(); + imp.createUsersWithArrayInput(request, body); + return ok(); } @@ -88,26 +91,29 @@ public Result createUsersWithListInput(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUsersWithListInput(request, body); -return ok(); + imp.createUsersWithListInput(request, body); + return ok(); } @ApiAction public Result deleteUser(Http.Request request, String username) throws Exception { - imp.deleteUser(request, username); -return ok(); + imp.deleteUser(request, username); + return ok(); } @ApiAction public Result getUserByName(Http.Request request, String username) throws Exception { - User obj = imp.getUserByName(request, username); - if (configuration.getBoolean("useOutputBeanValidation")) { + User obj = imp.getUserByName(request, username); + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -127,16 +133,17 @@ public Result loginUser(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'password' parameter is required"); } - String obj = imp.loginUser(request, username, password); -JsonNode result = mapper.valueToTree(obj); -return ok(result); + String obj = imp.loginUser(request, username, password); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @ApiAction public Result logoutUser(Http.Request request) throws Exception { - imp.logoutUser(request); -return ok(); + imp.logoutUser(request); + return ok(); } @@ -152,8 +159,8 @@ public Result updateUser(Http.Request request, String username) throws Exception } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.updateUser(request, username, body); -return ok(); + imp.updateUser(request, username, body); + return ok(); } diff --git a/samples/server/petstore/java-play-framework-no-interface/app/openapitools/SecurityAPIUtils.java b/samples/server/petstore/java-play-framework-no-interface/app/openapitools/SecurityAPIUtils.java new file mode 100644 index 000000000000..854be87f65a8 --- /dev/null +++ b/samples/server/petstore/java-play-framework-no-interface/app/openapitools/SecurityAPIUtils.java @@ -0,0 +1,165 @@ +package openapitools; + +import com.auth0.jwk.Jwk; +import com.auth0.jwk.UrlJwkProvider; +import com.auth0.jwt.JWT; +import com.auth0.jwt.JWTVerifier; +import com.auth0.jwt.algorithms.Algorithm; +import com.auth0.jwt.interfaces.DecodedJWT; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import org.apache.http.HttpHeaders; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.NameValuePair; +import org.apache.http.client.HttpClient; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; +import play.mvc.Http; + +import java.net.URL; +import java.security.PublicKey; +import java.security.interfaces.RSAPublicKey; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; + +@Singleton +public class SecurityAPIUtils { + private final String bearerPrefix = "Bearer "; + private final ObjectMapper mapper; + + private boolean useOnlineValidation = false; + + // Online validation + private HashMap tokenIntrospectEndpoints = new HashMap<>(); + private final String clientId; + private final String clientSecret; + + // Offline validation + private HashMap jwksEndpoints = new HashMap<>(); + private String tokenKeyId = ""; + private JWTVerifier tokenVerifier; //Reusable verifier instance until tokenKeyId changes. + + @Inject + SecurityAPIUtils(Config configuration) { + mapper = new ObjectMapper(); + + clientId = configuration.hasPath("oauth.clientId") ? configuration.getString("oauth.clientId") : ""; + clientSecret = configuration.hasPath("oauth.clientSecret") ? configuration.getString("oauth.clientSecret") : ""; + + tokenIntrospectEndpoints.put("petstore_auth", ""); + + jwksEndpoints.put("petstore_auth", ""); + } + + private boolean isRequestTokenValidByOnlineCheck(Http.Request request, String securityMethodName) { + try { + Optional authToken = request.getHeaders().get(HttpHeaders.AUTHORIZATION); + + if (authToken.isPresent()) { + String tokenWithoutBearerPrefix = authToken.get().substring(bearerPrefix.length()); + + HttpClientBuilder builder = HttpClientBuilder.create(); + HttpClient httpClient = builder.build(); + HttpPost httppost = new HttpPost(this.tokenIntrospectEndpoints.get(securityMethodName)); + + List params = new ArrayList<>(); + params.add(new BasicNameValuePair("token", tokenWithoutBearerPrefix)); + params.add(new BasicNameValuePair("client_id", clientId)); + params.add(new BasicNameValuePair("client_secret", clientSecret)); + httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); + + HttpResponse response = httpClient.execute(httppost); + String responseJsonString = EntityUtils.toString(response.getEntity()); + HashMap responseJsonObject = mapper.readValue(responseJsonString, HashMap.class); + + return response.getStatusLine().getStatusCode() == HttpStatus.SC_OK && (boolean) responseJsonObject.get("active"); + } + } catch (Exception exception) { + return false; + } + + return false; + } + + private boolean isRequestTokenValidByOfflineCheck(Http.Request request, String securityMethodName) { + try { + Optional authHeader = request.getHeaders().get(HttpHeaders.AUTHORIZATION); + + if (authHeader.isPresent()) { + String bearerToken = authHeader.get().substring(bearerPrefix.length()); + return isTokenValidByOfflineCheck(bearerToken, securityMethodName); + } + } catch (Exception exception) { + return false; + } + + return false; + } + + public boolean isTokenValidByOfflineCheck(String bearerToken, String securityMethodName) { + try { + DecodedJWT jwt = JWT.decode(bearerToken); + String issuer = jwt.getIssuer(); + String keyId = jwt.getKeyId(); + if (!tokenKeyId.equals(keyId)) { + if (securityMethodName == null) { + securityMethodName = jwksEndpoints.keySet().stream().findFirst().get(); + } + + Jwk jwk = new UrlJwkProvider(new URL(this.jwksEndpoints.get(securityMethodName))).get(keyId); + final PublicKey publicKey = jwk.getPublicKey(); + + if (!(publicKey instanceof RSAPublicKey)) { + throw new IllegalArgumentException(String.format("Key with ID %s was found in JWKS but is not a RSA-key.", keyId)); + } + + Algorithm algorithm = Algorithm.RSA256((RSAPublicKey) publicKey, null); + tokenVerifier = JWT.require(algorithm) + .withIssuer(issuer) + .build(); + tokenKeyId = keyId; + } + + DecodedJWT verifiedJWT = tokenVerifier.verify(bearerToken); + + return true; + } catch (Exception exception) { + return false; + } + } + + public String getOAuthUserIdFromRequestToken(Http.Request requestWithPreviouslyVerifiedToken) { + try { + Optional authHeader = requestWithPreviouslyVerifiedToken.getHeaders().get(HttpHeaders.AUTHORIZATION); + if (authHeader.isPresent()) { + String bearerToken = authHeader.get().substring(bearerPrefix.length()); + return getOAuthUserIdFromToken(bearerToken); + } + } catch (Exception exception) { + return null; + } + + return null; + } + + public String getOAuthUserIdFromToken(String bearerToken) { + try { + DecodedJWT jwt = JWT.decode(bearerToken); + return jwt.getSubject(); + } catch (Exception exception) { + return null; + } + } + + public boolean isRequestTokenValid(Http.Request request, String securityMethodName) { + return useOnlineValidation ? isRequestTokenValidByOnlineCheck(request, securityMethodName) : isRequestTokenValidByOfflineCheck(request, securityMethodName); + } +} diff --git a/samples/server/petstore/java-play-framework-no-interface/build.sbt b/samples/server/petstore/java-play-framework-no-interface/build.sbt index b972893fc3f7..69dfa74cd8ad 100644 --- a/samples/server/petstore/java-play-framework-no-interface/build.sbt +++ b/samples/server/petstore/java-play-framework-no-interface/build.sbt @@ -9,3 +9,6 @@ scalaVersion := "2.12.6" libraryDependencies += "org.webjars" % "swagger-ui" % "3.32.5" libraryDependencies += "javax.validation" % "validation-api" % "2.0.1.Final" libraryDependencies += guice +libraryDependencies += "com.auth0" % "java-jwt" % "3.18.1" +libraryDependencies += "com.auth0" % "jwks-rsa" % "0.19.0" +libraryDependencies += "org.apache.httpcomponents" % "httpclient" % "4.5.6" diff --git a/samples/server/petstore/java-play-framework-no-nullable/.openapi-generator/FILES b/samples/server/petstore/java-play-framework-no-nullable/.openapi-generator/FILES index f517461d8913..283bce384731 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/.openapi-generator/FILES +++ b/samples/server/petstore/java-play-framework-no-nullable/.openapi-generator/FILES @@ -20,6 +20,7 @@ app/controllers/UserApiControllerImpInterface.java app/openapitools/ApiCall.java app/openapitools/ErrorHandler.java app/openapitools/OpenAPIUtils.java +app/openapitools/SecurityAPIUtils.java build.sbt conf/application.conf conf/logback.xml diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/Module.java b/samples/server/petstore/java-play-framework-no-nullable/app/Module.java index f1b062c29345..1439bbe30c1a 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/Module.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/Module.java @@ -1,6 +1,7 @@ import com.google.inject.AbstractModule; import controllers.*; +import openapitools.SecurityAPIUtils; public class Module extends AbstractModule { @@ -9,5 +10,6 @@ protected void configure() { bind(PetApiControllerImpInterface.class).to(PetApiControllerImp.class); bind(StoreApiControllerImpInterface.class).to(StoreApiControllerImp.class); bind(UserApiControllerImpInterface.class).to(UserApiControllerImp.class); + bind(SecurityAPIUtils.class); } } \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiControllerImpInterface.java index 2e03eb9ec401..4ce570904a70 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiControllerImpInterface.java @@ -15,7 +15,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; import javax.validation.constraints.*; @@ -23,47 +25,70 @@ @SuppressWarnings("RedundantThrows") public abstract class PetApiControllerImpInterface { @Inject private Config configuration; + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public Result addPetHttp(Http.Request request, Pet body) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + addPet(request, body); -return ok(); + return ok(); } public abstract void addPet(Http.Request request, Pet body) throws Exception; public Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + deletePet(request, petId, apiKey); -return ok(); + return ok(); } public abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; public Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + List obj = findPetsByStatus(request, status); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); + + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } } - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } public abstract List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; public Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + List obj = findPetsByTags(request, tags); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); + + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } } - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -71,39 +96,57 @@ public Result findPetsByTagsHttp(Http.Request request, @NotNull List tag public Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { Pet obj = getPetById(request, petId); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } public abstract Pet getPetById(Http.Request request, Long petId) throws Exception; public Result updatePetHttp(Http.Request request, Pet body) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + updatePet(request, body); -return ok(); + return ok(); } public abstract void updatePet(Http.Request request, Pet body) throws Exception; public Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + updatePetWithForm(request, petId, name, status); -return ok(); + return ok(); } public abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; public Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiControllerImpInterface.java index c2a154007e45..67780d39c1cf 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiControllerImpInterface.java @@ -14,7 +14,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; import javax.validation.constraints.*; @@ -22,11 +24,12 @@ @SuppressWarnings("RedundantThrows") public abstract class StoreApiControllerImpInterface { @Inject private Config configuration; + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { deleteOrder(request, orderId); -return ok(); + return ok(); } @@ -34,8 +37,9 @@ public Result deleteOrderHttp(Http.Request request, String orderId) throws Excep public Result getInventoryHttp(Http.Request request) throws Exception { Map obj = getInventory(request); -JsonNode result = mapper.valueToTree(obj); -return ok(result); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -43,11 +47,14 @@ public Result getInventoryHttp(Http.Request request) throws Exception { public Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { Order obj = getOrderById(request, orderId); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -55,11 +62,14 @@ public Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderI public Result placeOrderHttp(Http.Request request, Order body) throws Exception { Order obj = placeOrder(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiControllerImpInterface.java index 39d422cc1ea4..5ba04804d68a 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiControllerImpInterface.java @@ -15,7 +15,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; import javax.validation.constraints.*; @@ -23,11 +25,12 @@ @SuppressWarnings("RedundantThrows") public abstract class UserApiControllerImpInterface { @Inject private Config configuration; + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public Result createUserHttp(Http.Request request, User body) throws Exception { createUser(request, body); -return ok(); + return ok(); } @@ -35,7 +38,7 @@ public Result createUserHttp(Http.Request request, User body) throws Exception { public Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { createUsersWithArrayInput(request, body); -return ok(); + return ok(); } @@ -43,7 +46,7 @@ public Result createUsersWithArrayInputHttp(Http.Request request, List bod public Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { createUsersWithListInput(request, body); -return ok(); + return ok(); } @@ -51,7 +54,7 @@ public Result createUsersWithListInputHttp(Http.Request request, List body public Result deleteUserHttp(Http.Request request, String username) throws Exception { deleteUser(request, username); -return ok(); + return ok(); } @@ -59,11 +62,14 @@ public Result deleteUserHttp(Http.Request request, String username) throws Excep public Result getUserByNameHttp(Http.Request request, String username) throws Exception { User obj = getUserByName(request, username); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -71,8 +77,9 @@ public Result getUserByNameHttp(Http.Request request, String username) throws Ex public Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { String obj = loginUser(request, username, password); -JsonNode result = mapper.valueToTree(obj); -return ok(result); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -80,7 +87,7 @@ public Result loginUserHttp(Http.Request request, @NotNull String username, @Not public Result logoutUserHttp(Http.Request request) throws Exception { logoutUser(request); -return ok(); + return ok(); } @@ -88,7 +95,7 @@ public Result logoutUserHttp(Http.Request request) throws Exception { public Result updateUserHttp(Http.Request request, String username, User body) throws Exception { updateUser(request, username, body); -return ok(); + return ok(); } diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/openapitools/SecurityAPIUtils.java b/samples/server/petstore/java-play-framework-no-nullable/app/openapitools/SecurityAPIUtils.java new file mode 100644 index 000000000000..854be87f65a8 --- /dev/null +++ b/samples/server/petstore/java-play-framework-no-nullable/app/openapitools/SecurityAPIUtils.java @@ -0,0 +1,165 @@ +package openapitools; + +import com.auth0.jwk.Jwk; +import com.auth0.jwk.UrlJwkProvider; +import com.auth0.jwt.JWT; +import com.auth0.jwt.JWTVerifier; +import com.auth0.jwt.algorithms.Algorithm; +import com.auth0.jwt.interfaces.DecodedJWT; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import org.apache.http.HttpHeaders; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.NameValuePair; +import org.apache.http.client.HttpClient; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; +import play.mvc.Http; + +import java.net.URL; +import java.security.PublicKey; +import java.security.interfaces.RSAPublicKey; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; + +@Singleton +public class SecurityAPIUtils { + private final String bearerPrefix = "Bearer "; + private final ObjectMapper mapper; + + private boolean useOnlineValidation = false; + + // Online validation + private HashMap tokenIntrospectEndpoints = new HashMap<>(); + private final String clientId; + private final String clientSecret; + + // Offline validation + private HashMap jwksEndpoints = new HashMap<>(); + private String tokenKeyId = ""; + private JWTVerifier tokenVerifier; //Reusable verifier instance until tokenKeyId changes. + + @Inject + SecurityAPIUtils(Config configuration) { + mapper = new ObjectMapper(); + + clientId = configuration.hasPath("oauth.clientId") ? configuration.getString("oauth.clientId") : ""; + clientSecret = configuration.hasPath("oauth.clientSecret") ? configuration.getString("oauth.clientSecret") : ""; + + tokenIntrospectEndpoints.put("petstore_auth", ""); + + jwksEndpoints.put("petstore_auth", ""); + } + + private boolean isRequestTokenValidByOnlineCheck(Http.Request request, String securityMethodName) { + try { + Optional authToken = request.getHeaders().get(HttpHeaders.AUTHORIZATION); + + if (authToken.isPresent()) { + String tokenWithoutBearerPrefix = authToken.get().substring(bearerPrefix.length()); + + HttpClientBuilder builder = HttpClientBuilder.create(); + HttpClient httpClient = builder.build(); + HttpPost httppost = new HttpPost(this.tokenIntrospectEndpoints.get(securityMethodName)); + + List params = new ArrayList<>(); + params.add(new BasicNameValuePair("token", tokenWithoutBearerPrefix)); + params.add(new BasicNameValuePair("client_id", clientId)); + params.add(new BasicNameValuePair("client_secret", clientSecret)); + httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); + + HttpResponse response = httpClient.execute(httppost); + String responseJsonString = EntityUtils.toString(response.getEntity()); + HashMap responseJsonObject = mapper.readValue(responseJsonString, HashMap.class); + + return response.getStatusLine().getStatusCode() == HttpStatus.SC_OK && (boolean) responseJsonObject.get("active"); + } + } catch (Exception exception) { + return false; + } + + return false; + } + + private boolean isRequestTokenValidByOfflineCheck(Http.Request request, String securityMethodName) { + try { + Optional authHeader = request.getHeaders().get(HttpHeaders.AUTHORIZATION); + + if (authHeader.isPresent()) { + String bearerToken = authHeader.get().substring(bearerPrefix.length()); + return isTokenValidByOfflineCheck(bearerToken, securityMethodName); + } + } catch (Exception exception) { + return false; + } + + return false; + } + + public boolean isTokenValidByOfflineCheck(String bearerToken, String securityMethodName) { + try { + DecodedJWT jwt = JWT.decode(bearerToken); + String issuer = jwt.getIssuer(); + String keyId = jwt.getKeyId(); + if (!tokenKeyId.equals(keyId)) { + if (securityMethodName == null) { + securityMethodName = jwksEndpoints.keySet().stream().findFirst().get(); + } + + Jwk jwk = new UrlJwkProvider(new URL(this.jwksEndpoints.get(securityMethodName))).get(keyId); + final PublicKey publicKey = jwk.getPublicKey(); + + if (!(publicKey instanceof RSAPublicKey)) { + throw new IllegalArgumentException(String.format("Key with ID %s was found in JWKS but is not a RSA-key.", keyId)); + } + + Algorithm algorithm = Algorithm.RSA256((RSAPublicKey) publicKey, null); + tokenVerifier = JWT.require(algorithm) + .withIssuer(issuer) + .build(); + tokenKeyId = keyId; + } + + DecodedJWT verifiedJWT = tokenVerifier.verify(bearerToken); + + return true; + } catch (Exception exception) { + return false; + } + } + + public String getOAuthUserIdFromRequestToken(Http.Request requestWithPreviouslyVerifiedToken) { + try { + Optional authHeader = requestWithPreviouslyVerifiedToken.getHeaders().get(HttpHeaders.AUTHORIZATION); + if (authHeader.isPresent()) { + String bearerToken = authHeader.get().substring(bearerPrefix.length()); + return getOAuthUserIdFromToken(bearerToken); + } + } catch (Exception exception) { + return null; + } + + return null; + } + + public String getOAuthUserIdFromToken(String bearerToken) { + try { + DecodedJWT jwt = JWT.decode(bearerToken); + return jwt.getSubject(); + } catch (Exception exception) { + return null; + } + } + + public boolean isRequestTokenValid(Http.Request request, String securityMethodName) { + return useOnlineValidation ? isRequestTokenValidByOnlineCheck(request, securityMethodName) : isRequestTokenValidByOfflineCheck(request, securityMethodName); + } +} diff --git a/samples/server/petstore/java-play-framework-no-nullable/build.sbt b/samples/server/petstore/java-play-framework-no-nullable/build.sbt index b972893fc3f7..69dfa74cd8ad 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/build.sbt +++ b/samples/server/petstore/java-play-framework-no-nullable/build.sbt @@ -9,3 +9,6 @@ scalaVersion := "2.12.6" libraryDependencies += "org.webjars" % "swagger-ui" % "3.32.5" libraryDependencies += "javax.validation" % "validation-api" % "2.0.1.Final" libraryDependencies += guice +libraryDependencies += "com.auth0" % "java-jwt" % "3.18.1" +libraryDependencies += "com.auth0" % "jwks-rsa" % "0.19.0" +libraryDependencies += "org.apache.httpcomponents" % "httpclient" % "4.5.6" diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/.openapi-generator/FILES b/samples/server/petstore/java-play-framework-no-swagger-ui/.openapi-generator/FILES index 6aff32b0988e..f29376c2e653 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/.openapi-generator/FILES +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/.openapi-generator/FILES @@ -19,6 +19,7 @@ app/controllers/UserApiControllerImpInterface.java app/openapitools/ApiCall.java app/openapitools/ErrorHandler.java app/openapitools/OpenAPIUtils.java +app/openapitools/SecurityAPIUtils.java build.sbt conf/application.conf conf/logback.xml diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/Module.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/Module.java index f1b062c29345..1439bbe30c1a 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/Module.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/Module.java @@ -1,6 +1,7 @@ import com.google.inject.AbstractModule; import controllers.*; +import openapitools.SecurityAPIUtils; public class Module extends AbstractModule { @@ -9,5 +10,6 @@ protected void configure() { bind(PetApiControllerImpInterface.class).to(PetApiControllerImp.class); bind(StoreApiControllerImpInterface.class).to(StoreApiControllerImp.class); bind(UserApiControllerImpInterface.class).to(UserApiControllerImp.class); + bind(SecurityAPIUtils.class); } } \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiControllerImpInterface.java index 2e03eb9ec401..4ce570904a70 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiControllerImpInterface.java @@ -15,7 +15,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; import javax.validation.constraints.*; @@ -23,47 +25,70 @@ @SuppressWarnings("RedundantThrows") public abstract class PetApiControllerImpInterface { @Inject private Config configuration; + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public Result addPetHttp(Http.Request request, Pet body) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + addPet(request, body); -return ok(); + return ok(); } public abstract void addPet(Http.Request request, Pet body) throws Exception; public Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + deletePet(request, petId, apiKey); -return ok(); + return ok(); } public abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; public Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + List obj = findPetsByStatus(request, status); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); + + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } } - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } public abstract List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; public Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + List obj = findPetsByTags(request, tags); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); + + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } } - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -71,39 +96,57 @@ public Result findPetsByTagsHttp(Http.Request request, @NotNull List tag public Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { Pet obj = getPetById(request, petId); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } public abstract Pet getPetById(Http.Request request, Long petId) throws Exception; public Result updatePetHttp(Http.Request request, Pet body) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + updatePet(request, body); -return ok(); + return ok(); } public abstract void updatePet(Http.Request request, Pet body) throws Exception; public Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + updatePetWithForm(request, petId, name, status); -return ok(); + return ok(); } public abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; public Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiControllerImpInterface.java index c2a154007e45..67780d39c1cf 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiControllerImpInterface.java @@ -14,7 +14,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; import javax.validation.constraints.*; @@ -22,11 +24,12 @@ @SuppressWarnings("RedundantThrows") public abstract class StoreApiControllerImpInterface { @Inject private Config configuration; + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { deleteOrder(request, orderId); -return ok(); + return ok(); } @@ -34,8 +37,9 @@ public Result deleteOrderHttp(Http.Request request, String orderId) throws Excep public Result getInventoryHttp(Http.Request request) throws Exception { Map obj = getInventory(request); -JsonNode result = mapper.valueToTree(obj); -return ok(result); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -43,11 +47,14 @@ public Result getInventoryHttp(Http.Request request) throws Exception { public Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { Order obj = getOrderById(request, orderId); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -55,11 +62,14 @@ public Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderI public Result placeOrderHttp(Http.Request request, Order body) throws Exception { Order obj = placeOrder(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiControllerImpInterface.java index 39d422cc1ea4..5ba04804d68a 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiControllerImpInterface.java @@ -15,7 +15,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; import javax.validation.constraints.*; @@ -23,11 +25,12 @@ @SuppressWarnings("RedundantThrows") public abstract class UserApiControllerImpInterface { @Inject private Config configuration; + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public Result createUserHttp(Http.Request request, User body) throws Exception { createUser(request, body); -return ok(); + return ok(); } @@ -35,7 +38,7 @@ public Result createUserHttp(Http.Request request, User body) throws Exception { public Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { createUsersWithArrayInput(request, body); -return ok(); + return ok(); } @@ -43,7 +46,7 @@ public Result createUsersWithArrayInputHttp(Http.Request request, List bod public Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { createUsersWithListInput(request, body); -return ok(); + return ok(); } @@ -51,7 +54,7 @@ public Result createUsersWithListInputHttp(Http.Request request, List body public Result deleteUserHttp(Http.Request request, String username) throws Exception { deleteUser(request, username); -return ok(); + return ok(); } @@ -59,11 +62,14 @@ public Result deleteUserHttp(Http.Request request, String username) throws Excep public Result getUserByNameHttp(Http.Request request, String username) throws Exception { User obj = getUserByName(request, username); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -71,8 +77,9 @@ public Result getUserByNameHttp(Http.Request request, String username) throws Ex public Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { String obj = loginUser(request, username, password); -JsonNode result = mapper.valueToTree(obj); -return ok(result); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -80,7 +87,7 @@ public Result loginUserHttp(Http.Request request, @NotNull String username, @Not public Result logoutUserHttp(Http.Request request) throws Exception { logoutUser(request); -return ok(); + return ok(); } @@ -88,7 +95,7 @@ public Result logoutUserHttp(Http.Request request) throws Exception { public Result updateUserHttp(Http.Request request, String username, User body) throws Exception { updateUser(request, username, body); -return ok(); + return ok(); } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/openapitools/SecurityAPIUtils.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/openapitools/SecurityAPIUtils.java new file mode 100644 index 000000000000..854be87f65a8 --- /dev/null +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/openapitools/SecurityAPIUtils.java @@ -0,0 +1,165 @@ +package openapitools; + +import com.auth0.jwk.Jwk; +import com.auth0.jwk.UrlJwkProvider; +import com.auth0.jwt.JWT; +import com.auth0.jwt.JWTVerifier; +import com.auth0.jwt.algorithms.Algorithm; +import com.auth0.jwt.interfaces.DecodedJWT; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import org.apache.http.HttpHeaders; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.NameValuePair; +import org.apache.http.client.HttpClient; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; +import play.mvc.Http; + +import java.net.URL; +import java.security.PublicKey; +import java.security.interfaces.RSAPublicKey; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; + +@Singleton +public class SecurityAPIUtils { + private final String bearerPrefix = "Bearer "; + private final ObjectMapper mapper; + + private boolean useOnlineValidation = false; + + // Online validation + private HashMap tokenIntrospectEndpoints = new HashMap<>(); + private final String clientId; + private final String clientSecret; + + // Offline validation + private HashMap jwksEndpoints = new HashMap<>(); + private String tokenKeyId = ""; + private JWTVerifier tokenVerifier; //Reusable verifier instance until tokenKeyId changes. + + @Inject + SecurityAPIUtils(Config configuration) { + mapper = new ObjectMapper(); + + clientId = configuration.hasPath("oauth.clientId") ? configuration.getString("oauth.clientId") : ""; + clientSecret = configuration.hasPath("oauth.clientSecret") ? configuration.getString("oauth.clientSecret") : ""; + + tokenIntrospectEndpoints.put("petstore_auth", ""); + + jwksEndpoints.put("petstore_auth", ""); + } + + private boolean isRequestTokenValidByOnlineCheck(Http.Request request, String securityMethodName) { + try { + Optional authToken = request.getHeaders().get(HttpHeaders.AUTHORIZATION); + + if (authToken.isPresent()) { + String tokenWithoutBearerPrefix = authToken.get().substring(bearerPrefix.length()); + + HttpClientBuilder builder = HttpClientBuilder.create(); + HttpClient httpClient = builder.build(); + HttpPost httppost = new HttpPost(this.tokenIntrospectEndpoints.get(securityMethodName)); + + List params = new ArrayList<>(); + params.add(new BasicNameValuePair("token", tokenWithoutBearerPrefix)); + params.add(new BasicNameValuePair("client_id", clientId)); + params.add(new BasicNameValuePair("client_secret", clientSecret)); + httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); + + HttpResponse response = httpClient.execute(httppost); + String responseJsonString = EntityUtils.toString(response.getEntity()); + HashMap responseJsonObject = mapper.readValue(responseJsonString, HashMap.class); + + return response.getStatusLine().getStatusCode() == HttpStatus.SC_OK && (boolean) responseJsonObject.get("active"); + } + } catch (Exception exception) { + return false; + } + + return false; + } + + private boolean isRequestTokenValidByOfflineCheck(Http.Request request, String securityMethodName) { + try { + Optional authHeader = request.getHeaders().get(HttpHeaders.AUTHORIZATION); + + if (authHeader.isPresent()) { + String bearerToken = authHeader.get().substring(bearerPrefix.length()); + return isTokenValidByOfflineCheck(bearerToken, securityMethodName); + } + } catch (Exception exception) { + return false; + } + + return false; + } + + public boolean isTokenValidByOfflineCheck(String bearerToken, String securityMethodName) { + try { + DecodedJWT jwt = JWT.decode(bearerToken); + String issuer = jwt.getIssuer(); + String keyId = jwt.getKeyId(); + if (!tokenKeyId.equals(keyId)) { + if (securityMethodName == null) { + securityMethodName = jwksEndpoints.keySet().stream().findFirst().get(); + } + + Jwk jwk = new UrlJwkProvider(new URL(this.jwksEndpoints.get(securityMethodName))).get(keyId); + final PublicKey publicKey = jwk.getPublicKey(); + + if (!(publicKey instanceof RSAPublicKey)) { + throw new IllegalArgumentException(String.format("Key with ID %s was found in JWKS but is not a RSA-key.", keyId)); + } + + Algorithm algorithm = Algorithm.RSA256((RSAPublicKey) publicKey, null); + tokenVerifier = JWT.require(algorithm) + .withIssuer(issuer) + .build(); + tokenKeyId = keyId; + } + + DecodedJWT verifiedJWT = tokenVerifier.verify(bearerToken); + + return true; + } catch (Exception exception) { + return false; + } + } + + public String getOAuthUserIdFromRequestToken(Http.Request requestWithPreviouslyVerifiedToken) { + try { + Optional authHeader = requestWithPreviouslyVerifiedToken.getHeaders().get(HttpHeaders.AUTHORIZATION); + if (authHeader.isPresent()) { + String bearerToken = authHeader.get().substring(bearerPrefix.length()); + return getOAuthUserIdFromToken(bearerToken); + } + } catch (Exception exception) { + return null; + } + + return null; + } + + public String getOAuthUserIdFromToken(String bearerToken) { + try { + DecodedJWT jwt = JWT.decode(bearerToken); + return jwt.getSubject(); + } catch (Exception exception) { + return null; + } + } + + public boolean isRequestTokenValid(Http.Request request, String securityMethodName) { + return useOnlineValidation ? isRequestTokenValidByOnlineCheck(request, securityMethodName) : isRequestTokenValidByOfflineCheck(request, securityMethodName); + } +} diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/build.sbt b/samples/server/petstore/java-play-framework-no-swagger-ui/build.sbt index 45bebc24cf09..fa1b6982eb18 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/build.sbt +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/build.sbt @@ -8,3 +8,6 @@ scalaVersion := "2.12.6" libraryDependencies += "javax.validation" % "validation-api" % "2.0.1.Final" libraryDependencies += guice +libraryDependencies += "com.auth0" % "java-jwt" % "3.18.1" +libraryDependencies += "com.auth0" % "jwks-rsa" % "0.19.0" +libraryDependencies += "org.apache.httpcomponents" % "httpclient" % "4.5.6" diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/.openapi-generator/FILES b/samples/server/petstore/java-play-framework-no-wrap-calls/.openapi-generator/FILES index b77e91cccd0b..4ca86764f42c 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/.openapi-generator/FILES +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/.openapi-generator/FILES @@ -19,6 +19,7 @@ app/controllers/UserApiControllerImp.java app/controllers/UserApiControllerImpInterface.java app/openapitools/ErrorHandler.java app/openapitools/OpenAPIUtils.java +app/openapitools/SecurityAPIUtils.java build.sbt conf/application.conf conf/logback.xml diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/Module.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/Module.java index f1b062c29345..1439bbe30c1a 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/Module.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/Module.java @@ -1,6 +1,7 @@ import com.google.inject.AbstractModule; import controllers.*; +import openapitools.SecurityAPIUtils; public class Module extends AbstractModule { @@ -9,5 +10,6 @@ protected void configure() { bind(PetApiControllerImpInterface.class).to(PetApiControllerImp.class); bind(StoreApiControllerImpInterface.class).to(StoreApiControllerImp.class); bind(UserApiControllerImpInterface.class).to(UserApiControllerImp.class); + bind(SecurityAPIUtils.class); } } \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiControllerImpInterface.java index 2e03eb9ec401..4ce570904a70 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiControllerImpInterface.java @@ -15,7 +15,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; import javax.validation.constraints.*; @@ -23,47 +25,70 @@ @SuppressWarnings("RedundantThrows") public abstract class PetApiControllerImpInterface { @Inject private Config configuration; + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public Result addPetHttp(Http.Request request, Pet body) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + addPet(request, body); -return ok(); + return ok(); } public abstract void addPet(Http.Request request, Pet body) throws Exception; public Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + deletePet(request, petId, apiKey); -return ok(); + return ok(); } public abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; public Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + List obj = findPetsByStatus(request, status); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); + + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } } - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } public abstract List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; public Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + List obj = findPetsByTags(request, tags); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); + + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } } - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -71,39 +96,57 @@ public Result findPetsByTagsHttp(Http.Request request, @NotNull List tag public Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { Pet obj = getPetById(request, petId); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } public abstract Pet getPetById(Http.Request request, Long petId) throws Exception; public Result updatePetHttp(Http.Request request, Pet body) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + updatePet(request, body); -return ok(); + return ok(); } public abstract void updatePet(Http.Request request, Pet body) throws Exception; public Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + updatePetWithForm(request, petId, name, status); -return ok(); + return ok(); } public abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; public Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiControllerImpInterface.java index c2a154007e45..67780d39c1cf 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiControllerImpInterface.java @@ -14,7 +14,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; import javax.validation.constraints.*; @@ -22,11 +24,12 @@ @SuppressWarnings("RedundantThrows") public abstract class StoreApiControllerImpInterface { @Inject private Config configuration; + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { deleteOrder(request, orderId); -return ok(); + return ok(); } @@ -34,8 +37,9 @@ public Result deleteOrderHttp(Http.Request request, String orderId) throws Excep public Result getInventoryHttp(Http.Request request) throws Exception { Map obj = getInventory(request); -JsonNode result = mapper.valueToTree(obj); -return ok(result); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -43,11 +47,14 @@ public Result getInventoryHttp(Http.Request request) throws Exception { public Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { Order obj = getOrderById(request, orderId); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -55,11 +62,14 @@ public Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderI public Result placeOrderHttp(Http.Request request, Order body) throws Exception { Order obj = placeOrder(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiControllerImpInterface.java index 39d422cc1ea4..5ba04804d68a 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiControllerImpInterface.java @@ -15,7 +15,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; import javax.validation.constraints.*; @@ -23,11 +25,12 @@ @SuppressWarnings("RedundantThrows") public abstract class UserApiControllerImpInterface { @Inject private Config configuration; + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public Result createUserHttp(Http.Request request, User body) throws Exception { createUser(request, body); -return ok(); + return ok(); } @@ -35,7 +38,7 @@ public Result createUserHttp(Http.Request request, User body) throws Exception { public Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { createUsersWithArrayInput(request, body); -return ok(); + return ok(); } @@ -43,7 +46,7 @@ public Result createUsersWithArrayInputHttp(Http.Request request, List bod public Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { createUsersWithListInput(request, body); -return ok(); + return ok(); } @@ -51,7 +54,7 @@ public Result createUsersWithListInputHttp(Http.Request request, List body public Result deleteUserHttp(Http.Request request, String username) throws Exception { deleteUser(request, username); -return ok(); + return ok(); } @@ -59,11 +62,14 @@ public Result deleteUserHttp(Http.Request request, String username) throws Excep public Result getUserByNameHttp(Http.Request request, String username) throws Exception { User obj = getUserByName(request, username); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -71,8 +77,9 @@ public Result getUserByNameHttp(Http.Request request, String username) throws Ex public Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { String obj = loginUser(request, username, password); -JsonNode result = mapper.valueToTree(obj); -return ok(result); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -80,7 +87,7 @@ public Result loginUserHttp(Http.Request request, @NotNull String username, @Not public Result logoutUserHttp(Http.Request request) throws Exception { logoutUser(request); -return ok(); + return ok(); } @@ -88,7 +95,7 @@ public Result logoutUserHttp(Http.Request request) throws Exception { public Result updateUserHttp(Http.Request request, String username, User body) throws Exception { updateUser(request, username, body); -return ok(); + return ok(); } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/openapitools/SecurityAPIUtils.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/openapitools/SecurityAPIUtils.java new file mode 100644 index 000000000000..854be87f65a8 --- /dev/null +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/openapitools/SecurityAPIUtils.java @@ -0,0 +1,165 @@ +package openapitools; + +import com.auth0.jwk.Jwk; +import com.auth0.jwk.UrlJwkProvider; +import com.auth0.jwt.JWT; +import com.auth0.jwt.JWTVerifier; +import com.auth0.jwt.algorithms.Algorithm; +import com.auth0.jwt.interfaces.DecodedJWT; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import org.apache.http.HttpHeaders; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.NameValuePair; +import org.apache.http.client.HttpClient; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; +import play.mvc.Http; + +import java.net.URL; +import java.security.PublicKey; +import java.security.interfaces.RSAPublicKey; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; + +@Singleton +public class SecurityAPIUtils { + private final String bearerPrefix = "Bearer "; + private final ObjectMapper mapper; + + private boolean useOnlineValidation = false; + + // Online validation + private HashMap tokenIntrospectEndpoints = new HashMap<>(); + private final String clientId; + private final String clientSecret; + + // Offline validation + private HashMap jwksEndpoints = new HashMap<>(); + private String tokenKeyId = ""; + private JWTVerifier tokenVerifier; //Reusable verifier instance until tokenKeyId changes. + + @Inject + SecurityAPIUtils(Config configuration) { + mapper = new ObjectMapper(); + + clientId = configuration.hasPath("oauth.clientId") ? configuration.getString("oauth.clientId") : ""; + clientSecret = configuration.hasPath("oauth.clientSecret") ? configuration.getString("oauth.clientSecret") : ""; + + tokenIntrospectEndpoints.put("petstore_auth", ""); + + jwksEndpoints.put("petstore_auth", ""); + } + + private boolean isRequestTokenValidByOnlineCheck(Http.Request request, String securityMethodName) { + try { + Optional authToken = request.getHeaders().get(HttpHeaders.AUTHORIZATION); + + if (authToken.isPresent()) { + String tokenWithoutBearerPrefix = authToken.get().substring(bearerPrefix.length()); + + HttpClientBuilder builder = HttpClientBuilder.create(); + HttpClient httpClient = builder.build(); + HttpPost httppost = new HttpPost(this.tokenIntrospectEndpoints.get(securityMethodName)); + + List params = new ArrayList<>(); + params.add(new BasicNameValuePair("token", tokenWithoutBearerPrefix)); + params.add(new BasicNameValuePair("client_id", clientId)); + params.add(new BasicNameValuePair("client_secret", clientSecret)); + httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); + + HttpResponse response = httpClient.execute(httppost); + String responseJsonString = EntityUtils.toString(response.getEntity()); + HashMap responseJsonObject = mapper.readValue(responseJsonString, HashMap.class); + + return response.getStatusLine().getStatusCode() == HttpStatus.SC_OK && (boolean) responseJsonObject.get("active"); + } + } catch (Exception exception) { + return false; + } + + return false; + } + + private boolean isRequestTokenValidByOfflineCheck(Http.Request request, String securityMethodName) { + try { + Optional authHeader = request.getHeaders().get(HttpHeaders.AUTHORIZATION); + + if (authHeader.isPresent()) { + String bearerToken = authHeader.get().substring(bearerPrefix.length()); + return isTokenValidByOfflineCheck(bearerToken, securityMethodName); + } + } catch (Exception exception) { + return false; + } + + return false; + } + + public boolean isTokenValidByOfflineCheck(String bearerToken, String securityMethodName) { + try { + DecodedJWT jwt = JWT.decode(bearerToken); + String issuer = jwt.getIssuer(); + String keyId = jwt.getKeyId(); + if (!tokenKeyId.equals(keyId)) { + if (securityMethodName == null) { + securityMethodName = jwksEndpoints.keySet().stream().findFirst().get(); + } + + Jwk jwk = new UrlJwkProvider(new URL(this.jwksEndpoints.get(securityMethodName))).get(keyId); + final PublicKey publicKey = jwk.getPublicKey(); + + if (!(publicKey instanceof RSAPublicKey)) { + throw new IllegalArgumentException(String.format("Key with ID %s was found in JWKS but is not a RSA-key.", keyId)); + } + + Algorithm algorithm = Algorithm.RSA256((RSAPublicKey) publicKey, null); + tokenVerifier = JWT.require(algorithm) + .withIssuer(issuer) + .build(); + tokenKeyId = keyId; + } + + DecodedJWT verifiedJWT = tokenVerifier.verify(bearerToken); + + return true; + } catch (Exception exception) { + return false; + } + } + + public String getOAuthUserIdFromRequestToken(Http.Request requestWithPreviouslyVerifiedToken) { + try { + Optional authHeader = requestWithPreviouslyVerifiedToken.getHeaders().get(HttpHeaders.AUTHORIZATION); + if (authHeader.isPresent()) { + String bearerToken = authHeader.get().substring(bearerPrefix.length()); + return getOAuthUserIdFromToken(bearerToken); + } + } catch (Exception exception) { + return null; + } + + return null; + } + + public String getOAuthUserIdFromToken(String bearerToken) { + try { + DecodedJWT jwt = JWT.decode(bearerToken); + return jwt.getSubject(); + } catch (Exception exception) { + return null; + } + } + + public boolean isRequestTokenValid(Http.Request request, String securityMethodName) { + return useOnlineValidation ? isRequestTokenValidByOnlineCheck(request, securityMethodName) : isRequestTokenValidByOfflineCheck(request, securityMethodName); + } +} diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/build.sbt b/samples/server/petstore/java-play-framework-no-wrap-calls/build.sbt index b972893fc3f7..69dfa74cd8ad 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/build.sbt +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/build.sbt @@ -9,3 +9,6 @@ scalaVersion := "2.12.6" libraryDependencies += "org.webjars" % "swagger-ui" % "3.32.5" libraryDependencies += "javax.validation" % "validation-api" % "2.0.1.Final" libraryDependencies += guice +libraryDependencies += "com.auth0" % "java-jwt" % "3.18.1" +libraryDependencies += "com.auth0" % "jwks-rsa" % "0.19.0" +libraryDependencies += "org.apache.httpcomponents" % "httpclient" % "4.5.6" diff --git a/samples/server/petstore/java-play-framework/.openapi-generator/FILES b/samples/server/petstore/java-play-framework/.openapi-generator/FILES index f517461d8913..283bce384731 100644 --- a/samples/server/petstore/java-play-framework/.openapi-generator/FILES +++ b/samples/server/petstore/java-play-framework/.openapi-generator/FILES @@ -20,6 +20,7 @@ app/controllers/UserApiControllerImpInterface.java app/openapitools/ApiCall.java app/openapitools/ErrorHandler.java app/openapitools/OpenAPIUtils.java +app/openapitools/SecurityAPIUtils.java build.sbt conf/application.conf conf/logback.xml diff --git a/samples/server/petstore/java-play-framework/app/Module.java b/samples/server/petstore/java-play-framework/app/Module.java index f1b062c29345..1439bbe30c1a 100644 --- a/samples/server/petstore/java-play-framework/app/Module.java +++ b/samples/server/petstore/java-play-framework/app/Module.java @@ -1,6 +1,7 @@ import com.google.inject.AbstractModule; import controllers.*; +import openapitools.SecurityAPIUtils; public class Module extends AbstractModule { @@ -9,5 +10,6 @@ protected void configure() { bind(PetApiControllerImpInterface.class).to(PetApiControllerImp.class); bind(StoreApiControllerImpInterface.class).to(StoreApiControllerImp.class); bind(UserApiControllerImpInterface.class).to(UserApiControllerImp.class); + bind(SecurityAPIUtils.class); } } \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework/app/controllers/PetApiControllerImpInterface.java index 2e03eb9ec401..4ce570904a70 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework/app/controllers/PetApiControllerImpInterface.java @@ -15,7 +15,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; import javax.validation.constraints.*; @@ -23,47 +25,70 @@ @SuppressWarnings("RedundantThrows") public abstract class PetApiControllerImpInterface { @Inject private Config configuration; + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public Result addPetHttp(Http.Request request, Pet body) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + addPet(request, body); -return ok(); + return ok(); } public abstract void addPet(Http.Request request, Pet body) throws Exception; public Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + deletePet(request, petId, apiKey); -return ok(); + return ok(); } public abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; public Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + List obj = findPetsByStatus(request, status); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); + + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } } - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } public abstract List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; public Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + List obj = findPetsByTags(request, tags); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); + + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } } - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -71,39 +96,57 @@ public Result findPetsByTagsHttp(Http.Request request, @NotNull List tag public Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { Pet obj = getPetById(request, petId); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } public abstract Pet getPetById(Http.Request request, Long petId) throws Exception; public Result updatePetHttp(Http.Request request, Pet body) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + updatePet(request, body); -return ok(); + return ok(); } public abstract void updatePet(Http.Request request, Pet body) throws Exception; public Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + updatePetWithForm(request, petId, name, status); -return ok(); + return ok(); } public abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; public Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + if (!securityAPIUtils.isRequestTokenValid(request, "petstore_auth")) { + return unauthorized(); + } + ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } diff --git a/samples/server/petstore/java-play-framework/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework/app/controllers/StoreApiControllerImpInterface.java index c2a154007e45..67780d39c1cf 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework/app/controllers/StoreApiControllerImpInterface.java @@ -14,7 +14,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; import javax.validation.constraints.*; @@ -22,11 +24,12 @@ @SuppressWarnings("RedundantThrows") public abstract class StoreApiControllerImpInterface { @Inject private Config configuration; + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { deleteOrder(request, orderId); -return ok(); + return ok(); } @@ -34,8 +37,9 @@ public Result deleteOrderHttp(Http.Request request, String orderId) throws Excep public Result getInventoryHttp(Http.Request request) throws Exception { Map obj = getInventory(request); -JsonNode result = mapper.valueToTree(obj); -return ok(result); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -43,11 +47,14 @@ public Result getInventoryHttp(Http.Request request) throws Exception { public Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { Order obj = getOrderById(request, orderId); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -55,11 +62,14 @@ public Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderI public Result placeOrderHttp(Http.Request request, Order body) throws Exception { Order obj = placeOrder(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } diff --git a/samples/server/petstore/java-play-framework/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework/app/controllers/UserApiControllerImpInterface.java index 39d422cc1ea4..5ba04804d68a 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework/app/controllers/UserApiControllerImpInterface.java @@ -15,7 +15,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; +import openapitools.SecurityAPIUtils; import static play.mvc.Results.ok; +import static play.mvc.Results.unauthorized; import play.libs.Files.TemporaryFile; import javax.validation.constraints.*; @@ -23,11 +25,12 @@ @SuppressWarnings("RedundantThrows") public abstract class UserApiControllerImpInterface { @Inject private Config configuration; + @Inject private SecurityAPIUtils securityAPIUtils; private ObjectMapper mapper = new ObjectMapper(); public Result createUserHttp(Http.Request request, User body) throws Exception { createUser(request, body); -return ok(); + return ok(); } @@ -35,7 +38,7 @@ public Result createUserHttp(Http.Request request, User body) throws Exception { public Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { createUsersWithArrayInput(request, body); -return ok(); + return ok(); } @@ -43,7 +46,7 @@ public Result createUsersWithArrayInputHttp(Http.Request request, List bod public Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { createUsersWithListInput(request, body); -return ok(); + return ok(); } @@ -51,7 +54,7 @@ public Result createUsersWithListInputHttp(Http.Request request, List body public Result deleteUserHttp(Http.Request request, String username) throws Exception { deleteUser(request, username); -return ok(); + return ok(); } @@ -59,11 +62,14 @@ public Result deleteUserHttp(Http.Request request, String username) throws Excep public Result getUserByNameHttp(Http.Request request, String username) throws Exception { User obj = getUserByName(request, username); - if (configuration.getBoolean("useOutputBeanValidation")) { + + if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); - } -JsonNode result = mapper.valueToTree(obj); -return ok(result); + } + + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -71,8 +77,9 @@ public Result getUserByNameHttp(Http.Request request, String username) throws Ex public Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { String obj = loginUser(request, username, password); -JsonNode result = mapper.valueToTree(obj); -return ok(result); + JsonNode result = mapper.valueToTree(obj); + + return ok(result); } @@ -80,7 +87,7 @@ public Result loginUserHttp(Http.Request request, @NotNull String username, @Not public Result logoutUserHttp(Http.Request request) throws Exception { logoutUser(request); -return ok(); + return ok(); } @@ -88,7 +95,7 @@ public Result logoutUserHttp(Http.Request request) throws Exception { public Result updateUserHttp(Http.Request request, String username, User body) throws Exception { updateUser(request, username, body); -return ok(); + return ok(); } diff --git a/samples/server/petstore/java-play-framework/app/openapitools/SecurityAPIUtils.java b/samples/server/petstore/java-play-framework/app/openapitools/SecurityAPIUtils.java new file mode 100644 index 000000000000..854be87f65a8 --- /dev/null +++ b/samples/server/petstore/java-play-framework/app/openapitools/SecurityAPIUtils.java @@ -0,0 +1,165 @@ +package openapitools; + +import com.auth0.jwk.Jwk; +import com.auth0.jwk.UrlJwkProvider; +import com.auth0.jwt.JWT; +import com.auth0.jwt.JWTVerifier; +import com.auth0.jwt.algorithms.Algorithm; +import com.auth0.jwt.interfaces.DecodedJWT; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import org.apache.http.HttpHeaders; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.NameValuePair; +import org.apache.http.client.HttpClient; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; +import play.mvc.Http; + +import java.net.URL; +import java.security.PublicKey; +import java.security.interfaces.RSAPublicKey; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; + +@Singleton +public class SecurityAPIUtils { + private final String bearerPrefix = "Bearer "; + private final ObjectMapper mapper; + + private boolean useOnlineValidation = false; + + // Online validation + private HashMap tokenIntrospectEndpoints = new HashMap<>(); + private final String clientId; + private final String clientSecret; + + // Offline validation + private HashMap jwksEndpoints = new HashMap<>(); + private String tokenKeyId = ""; + private JWTVerifier tokenVerifier; //Reusable verifier instance until tokenKeyId changes. + + @Inject + SecurityAPIUtils(Config configuration) { + mapper = new ObjectMapper(); + + clientId = configuration.hasPath("oauth.clientId") ? configuration.getString("oauth.clientId") : ""; + clientSecret = configuration.hasPath("oauth.clientSecret") ? configuration.getString("oauth.clientSecret") : ""; + + tokenIntrospectEndpoints.put("petstore_auth", ""); + + jwksEndpoints.put("petstore_auth", ""); + } + + private boolean isRequestTokenValidByOnlineCheck(Http.Request request, String securityMethodName) { + try { + Optional authToken = request.getHeaders().get(HttpHeaders.AUTHORIZATION); + + if (authToken.isPresent()) { + String tokenWithoutBearerPrefix = authToken.get().substring(bearerPrefix.length()); + + HttpClientBuilder builder = HttpClientBuilder.create(); + HttpClient httpClient = builder.build(); + HttpPost httppost = new HttpPost(this.tokenIntrospectEndpoints.get(securityMethodName)); + + List params = new ArrayList<>(); + params.add(new BasicNameValuePair("token", tokenWithoutBearerPrefix)); + params.add(new BasicNameValuePair("client_id", clientId)); + params.add(new BasicNameValuePair("client_secret", clientSecret)); + httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); + + HttpResponse response = httpClient.execute(httppost); + String responseJsonString = EntityUtils.toString(response.getEntity()); + HashMap responseJsonObject = mapper.readValue(responseJsonString, HashMap.class); + + return response.getStatusLine().getStatusCode() == HttpStatus.SC_OK && (boolean) responseJsonObject.get("active"); + } + } catch (Exception exception) { + return false; + } + + return false; + } + + private boolean isRequestTokenValidByOfflineCheck(Http.Request request, String securityMethodName) { + try { + Optional authHeader = request.getHeaders().get(HttpHeaders.AUTHORIZATION); + + if (authHeader.isPresent()) { + String bearerToken = authHeader.get().substring(bearerPrefix.length()); + return isTokenValidByOfflineCheck(bearerToken, securityMethodName); + } + } catch (Exception exception) { + return false; + } + + return false; + } + + public boolean isTokenValidByOfflineCheck(String bearerToken, String securityMethodName) { + try { + DecodedJWT jwt = JWT.decode(bearerToken); + String issuer = jwt.getIssuer(); + String keyId = jwt.getKeyId(); + if (!tokenKeyId.equals(keyId)) { + if (securityMethodName == null) { + securityMethodName = jwksEndpoints.keySet().stream().findFirst().get(); + } + + Jwk jwk = new UrlJwkProvider(new URL(this.jwksEndpoints.get(securityMethodName))).get(keyId); + final PublicKey publicKey = jwk.getPublicKey(); + + if (!(publicKey instanceof RSAPublicKey)) { + throw new IllegalArgumentException(String.format("Key with ID %s was found in JWKS but is not a RSA-key.", keyId)); + } + + Algorithm algorithm = Algorithm.RSA256((RSAPublicKey) publicKey, null); + tokenVerifier = JWT.require(algorithm) + .withIssuer(issuer) + .build(); + tokenKeyId = keyId; + } + + DecodedJWT verifiedJWT = tokenVerifier.verify(bearerToken); + + return true; + } catch (Exception exception) { + return false; + } + } + + public String getOAuthUserIdFromRequestToken(Http.Request requestWithPreviouslyVerifiedToken) { + try { + Optional authHeader = requestWithPreviouslyVerifiedToken.getHeaders().get(HttpHeaders.AUTHORIZATION); + if (authHeader.isPresent()) { + String bearerToken = authHeader.get().substring(bearerPrefix.length()); + return getOAuthUserIdFromToken(bearerToken); + } + } catch (Exception exception) { + return null; + } + + return null; + } + + public String getOAuthUserIdFromToken(String bearerToken) { + try { + DecodedJWT jwt = JWT.decode(bearerToken); + return jwt.getSubject(); + } catch (Exception exception) { + return null; + } + } + + public boolean isRequestTokenValid(Http.Request request, String securityMethodName) { + return useOnlineValidation ? isRequestTokenValidByOnlineCheck(request, securityMethodName) : isRequestTokenValidByOfflineCheck(request, securityMethodName); + } +} diff --git a/samples/server/petstore/java-play-framework/build.sbt b/samples/server/petstore/java-play-framework/build.sbt index b972893fc3f7..69dfa74cd8ad 100644 --- a/samples/server/petstore/java-play-framework/build.sbt +++ b/samples/server/petstore/java-play-framework/build.sbt @@ -9,3 +9,6 @@ scalaVersion := "2.12.6" libraryDependencies += "org.webjars" % "swagger-ui" % "3.32.5" libraryDependencies += "javax.validation" % "validation-api" % "2.0.1.Final" libraryDependencies += guice +libraryDependencies += "com.auth0" % "java-jwt" % "3.18.1" +libraryDependencies += "com.auth0" % "jwks-rsa" % "0.19.0" +libraryDependencies += "org.apache.httpcomponents" % "httpclient" % "4.5.6" diff --git a/samples/server/petstore/spring-mvc-default-value/pom.xml b/samples/server/petstore/spring-mvc-default-value/pom.xml index fa8da51ae2da..dc8d196bfaf2 100644 --- a/samples/server/petstore/spring-mvc-default-value/pom.xml +++ b/samples/server/petstore/spring-mvc-default-value/pom.xml @@ -9,12 +9,12 @@ 1.8 ${java.version} ${java.version} - 2.9.2 + 2.9.2 org.springframework.boot spring-boot-starter-parent - 2.3.3.RELEASE + 2.5.8 src/main/java @@ -22,13 +22,6 @@ org.springframework.boot spring-boot-maven-plugin - - - - repackage - - - @@ -45,16 +38,17 @@ io.springfox springfox-swagger2 - ${springfox-version} + ${springfox.version} + - io.springfox - springfox-swagger-ui - ${springfox-version} + com.google.code.findbugs + jsr305 + 3.0.2 - jakarta.xml.bind - jakarta.xml.bind-api + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml com.fasterxml.jackson.datatype @@ -63,12 +57,12 @@ org.openapitools jackson-databind-nullable - 0.2.1 + 0.2.2 - + - jakarta.validation - jakarta.validation-api + org.springframework.boot + spring-boot-starter-validation com.fasterxml.jackson.core diff --git a/samples/server/petstore/spring-mvc-default-value/src/main/java/org/openapitools/api/TestHeadersApi.java b/samples/server/petstore/spring-mvc-default-value/src/main/java/org/openapitools/api/TestHeadersApi.java index 94feafa1696d..18774a47d12c 100644 --- a/samples/server/petstore/spring-mvc-default-value/src/main/java/org/openapitools/api/TestHeadersApi.java +++ b/samples/server/petstore/spring-mvc-default-value/src/main/java/org/openapitools/api/TestHeadersApi.java @@ -42,29 +42,29 @@ default Optional getRequest() { * @param headerBoolean (optional, default to true) * @return default response (status code 200) */ - - @ApiOperation(value = "test headers", nickname = "headersTest", notes = "desc", response = TestResponse.class, tags={ "verify-default-value", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "default response", response = TestResponse.class) }) + @ApiOperation( + tags = { "verify-default-value" }, + value = "test headers", + nickname = "headersTest", + notes = "desc", + response = TestResponse.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "default response", response = TestResponse.class) + }) @RequestMapping( method = RequestMethod.GET, value = "/test-headers", produces = { "application/json" } ) default ResponseEntity headersTest( -@ApiParam(value = "", defaultValue = "11.2") @RequestHeader(value = "headerNumber", required = false) BigDecimal headerNumber -, -@ApiParam(value = "", defaultValue = "qwerty") @RequestHeader(value = "headerString", required = false) String headerString -, -@ApiParam(value = "", defaultValue = "qwerty") @RequestHeader(value = "headerStringWrapped", required = false) String headerStringWrapped -, -@ApiParam(value = "", defaultValue = "qwerty\"with quotes\" test") @RequestHeader(value = "headerStringQuotes", required = false) String headerStringQuotes -, -@ApiParam(value = "", defaultValue = "qwerty\"with quotes\" test") @RequestHeader(value = "headerStringQuotesWrapped", required = false) String headerStringQuotesWrapped -, -@ApiParam(value = "", defaultValue = "true") @RequestHeader(value = "headerBoolean", required = false) Boolean headerBoolean -) { + @ApiParam(value = "", defaultValue = "11.2") @RequestHeader(value = "headerNumber", required = false) BigDecimal headerNumber, + @ApiParam(value = "", defaultValue = "qwerty") @RequestHeader(value = "headerString", required = false) String headerString, + @ApiParam(value = "", defaultValue = "qwerty") @RequestHeader(value = "headerStringWrapped", required = false) String headerStringWrapped, + @ApiParam(value = "", defaultValue = "qwerty\"with quotes\" test") @RequestHeader(value = "headerStringQuotes", required = false) String headerStringQuotes, + @ApiParam(value = "", defaultValue = "qwerty\"with quotes\" test") @RequestHeader(value = "headerStringQuotesWrapped", required = false) String headerStringQuotesWrapped, + @ApiParam(value = "", defaultValue = "true") @RequestHeader(value = "headerBoolean", required = false) Boolean headerBoolean + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/spring-mvc-default-value/src/main/java/org/openapitools/api/TestQueryParamsApi.java b/samples/server/petstore/spring-mvc-default-value/src/main/java/org/openapitools/api/TestQueryParamsApi.java index 1845ce89532f..2d2d5748df5e 100644 --- a/samples/server/petstore/spring-mvc-default-value/src/main/java/org/openapitools/api/TestQueryParamsApi.java +++ b/samples/server/petstore/spring-mvc-default-value/src/main/java/org/openapitools/api/TestQueryParamsApi.java @@ -42,29 +42,29 @@ default Optional getRequest() { * @param queryBoolean (optional, default to true) * @return default response (status code 200) */ - - @ApiOperation(value = "test query params", nickname = "queryParamsTest", notes = "desc", response = TestResponse.class, tags={ "verify-default-value", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "default response", response = TestResponse.class) }) + @ApiOperation( + tags = { "verify-default-value" }, + value = "test query params", + nickname = "queryParamsTest", + notes = "desc", + response = TestResponse.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "default response", response = TestResponse.class) + }) @RequestMapping( method = RequestMethod.GET, value = "/test-query-params", produces = { "application/json" } ) - default ResponseEntity queryParamsTest(@ApiParam(value = "", defaultValue = "11.2") @Valid @RequestParam(value = "queryNumber", required = false, defaultValue = "11.2") BigDecimal queryNumber - -,@ApiParam(value = "", defaultValue = "qwerty") @Valid @RequestParam(value = "queryString", required = false, defaultValue = "qwerty") String queryString - -,@ApiParam(value = "", defaultValue = "qwerty") @Valid @RequestParam(value = "queryStringWrapped", required = false, defaultValue = "qwerty") String queryStringWrapped - -,@ApiParam(value = "", defaultValue = "qwerty\"with quotes\" test") @Valid @RequestParam(value = "queryStringQuotes", required = false, defaultValue = "qwerty\"with quotes\" test") String queryStringQuotes - -,@ApiParam(value = "", defaultValue = "qwerty\"with quotes\" test") @Valid @RequestParam(value = "queryStringQuotesWrapped", required = false, defaultValue = "qwerty\"with quotes\" test") String queryStringQuotesWrapped - -,@ApiParam(value = "", defaultValue = "true") @Valid @RequestParam(value = "queryBoolean", required = false, defaultValue = "true") Boolean queryBoolean - -) { + default ResponseEntity queryParamsTest( + @ApiParam(value = "", defaultValue = "11.2") @Valid @RequestParam(value = "queryNumber", required = false, defaultValue = "11.2") BigDecimal queryNumber, + @ApiParam(value = "", defaultValue = "qwerty") @Valid @RequestParam(value = "queryString", required = false, defaultValue = "qwerty") String queryString, + @ApiParam(value = "", defaultValue = "qwerty") @Valid @RequestParam(value = "queryStringWrapped", required = false, defaultValue = "qwerty") String queryStringWrapped, + @ApiParam(value = "", defaultValue = "qwerty\"with quotes\" test") @Valid @RequestParam(value = "queryStringQuotes", required = false, defaultValue = "qwerty\"with quotes\" test") String queryStringQuotes, + @ApiParam(value = "", defaultValue = "qwerty\"with quotes\" test") @Valid @RequestParam(value = "queryStringQuotesWrapped", required = false, defaultValue = "qwerty\"with quotes\" test") String queryStringQuotesWrapped, + @ApiParam(value = "", defaultValue = "true") @Valid @RequestParam(value = "queryBoolean", required = false, defaultValue = "true") Boolean queryBoolean + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/spring-mvc-j8-async/pom.xml b/samples/server/petstore/spring-mvc-j8-async/pom.xml index 75642d4fca41..9308a10db9d3 100644 --- a/samples/server/petstore/spring-mvc-j8-async/pom.xml +++ b/samples/server/petstore/spring-mvc-j8-async/pom.xml @@ -166,17 +166,18 @@ ${java.version} ${java.version} 1.3.5 - 2.3.3 + 2.3.3 9.2.15.v20160210 1.7.21 4.13.1 4.0.4 - 2.8.0 + 2.9.2 2.9.9 2.8.4 2.0.2 4.3.20.RELEASE 0.2.2 2.9.8 + 1.6.3 diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/AnotherFakeApi.java index f8587b076026..d21ce1c5b69a 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -37,11 +37,16 @@ default Optional getRequest() { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "$another-fake?" }, + value = "To test special tags", + nickname = "call123testSpecialTags", + notes = "To test special tags and operation ID starting with number", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/another-fake/dummy", @@ -49,8 +54,8 @@ default Optional getRequest() { consumes = { "application/json" } ) default CompletableFuture> call123testSpecialTags( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { return CompletableFuture.supplyAsync(()-> { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/FakeApi.java index 95b281631dea..337b30283261 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/FakeApi.java @@ -46,19 +46,23 @@ default Optional getRequest() { * @param xmlItem XmlItem Body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "creates an XmlItem", nickname = "createXmlItem", notes = "this route creates an XmlItem", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "creates an XmlItem", + nickname = "createXmlItem", + notes = "this route creates an XmlItem" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/create_xml_item", consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } ) default CompletableFuture> createXmlItem( - -@ApiParam(value = "XmlItem Body", required = true ) @Valid @RequestBody XmlItem xmlItem) { + @ApiParam(value = "XmlItem Body", required = true) @Valid @RequestBody XmlItem xmlItem + ) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -71,19 +75,24 @@ default CompletableFuture> createXmlItem( * @param body Input boolean as post body (optional) * @return Output boolean (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterBooleanSerialize", + notes = "Test serialization of outer boolean types", + response = Boolean.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/boolean", produces = { "*/*" } ) default CompletableFuture> fakeOuterBooleanSerialize( - -@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { + @ApiParam(value = "Input boolean as post body") @Valid @RequestBody(required = false) Boolean body + ) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -96,19 +105,24 @@ default CompletableFuture> fakeOuterBooleanSerialize( * @param body Input composite as post body (optional) * @return Output composite (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterCompositeSerialize", + notes = "Test serialization of object with outer number type", + response = OuterComposite.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/composite", produces = { "*/*" } ) default CompletableFuture> fakeOuterCompositeSerialize( - -@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { + @ApiParam(value = "Input composite as post body") @Valid @RequestBody(required = false) OuterComposite body + ) { return CompletableFuture.supplyAsync(()-> { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -132,19 +146,24 @@ default CompletableFuture> fakeOuterCompositeSeri * @param body Input number as post body (optional) * @return Output number (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterNumberSerialize", + notes = "Test serialization of outer number types", + response = BigDecimal.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/number", produces = { "*/*" } ) default CompletableFuture> fakeOuterNumberSerialize( - -@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { + @ApiParam(value = "Input number as post body") @Valid @RequestBody(required = false) BigDecimal body + ) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -157,19 +176,24 @@ default CompletableFuture> fakeOuterNumberSerialize( * @param body Input string as post body (optional) * @return Output string (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output string", response = String.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterStringSerialize", + notes = "Test serialization of outer string types", + response = String.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output string", response = String.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/string", produces = { "*/*" } ) default CompletableFuture> fakeOuterStringSerialize( - -@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { + @ApiParam(value = "Input string as post body") @Valid @RequestBody(required = false) String body + ) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -182,19 +206,23 @@ default CompletableFuture> fakeOuterStringSerialize( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithFileSchema", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithFileSchema", + notes = "For this test, the body for this request much reference a schema named `File`." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-file-schema", consumes = { "application/json" } ) default CompletableFuture> testBodyWithFileSchema( - -@ApiParam(value = "", required = true ) @Valid @RequestBody FileSchemaTestClass body) { + @ApiParam(value = "", required = true) @Valid @RequestBody FileSchemaTestClass body + ) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -207,21 +235,24 @@ default CompletableFuture> testBodyWithFileSchema( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithQueryParams", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithQueryParams", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-query-params", consumes = { "application/json" } ) - default CompletableFuture> testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query - -, - -@ApiParam(value = "", required = true ) @Valid @RequestBody User body) { + default CompletableFuture> testBodyWithQueryParams( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query, + @ApiParam(value = "", required = true) @Valid @RequestBody User body + ) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -234,11 +265,16 @@ default CompletableFuture> testBodyWithQueryParams(@NotNull * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake" }, + value = "To test \"client\" model", + nickname = "testClientModel", + notes = "To test \"client\" model", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake", @@ -246,8 +282,8 @@ default CompletableFuture> testBodyWithQueryParams(@NotNull consumes = { "application/json" } ) default CompletableFuture> testClientModel( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { return CompletableFuture.supplyAsync(()-> { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -285,50 +321,40 @@ default CompletableFuture> testClientModel( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", authorizations = { - - @Authorization(value = "http_basic_test") - }, tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + nickname = "testEndpointParameters", + notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + authorizations = { + @Authorization(value = "http_basic_test") + } + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) default CompletableFuture> testEndpointParameters( - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, - -@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, - -@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, - -@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, - -@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary, - -@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date, - -@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime, - -@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, - -@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback) { + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, + @ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, + @ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, + @ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, + @ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, + @ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, + @ApiParam(value = "None") @RequestPart(value = "binary", required = false) MultipartFile binary, + @ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, + @ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback + ) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -349,35 +375,31 @@ default CompletableFuture> testEndpointParameters( * @return Invalid request (status code 400) * or Not found (status code 404) */ - - @ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "To test enum parameters", + nickname = "testEnumParameters", + notes = "To test enum parameters" + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid request"), - - @ApiResponse(code = 404, message = "Not found") }) + @ApiResponse(code = 404, message = "Not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) default CompletableFuture> testEnumParameters( -@ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray -, -@ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString -,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray - -,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble - -, - -@ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, - -@ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString) { + @ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray, + @ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString, + @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, + @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble, + @ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, + @ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString + ) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -395,28 +417,27 @@ default CompletableFuture> testEnumParameters( * @param int64Group Integer in group parameters (optional) * @return Someting wrong (status code 400) */ - - @ApiOperation(value = "Fake endpoint to test group parameters (optional)", nickname = "testGroupParameters", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 400, message = "Someting wrong") }) + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint to test group parameters (optional)", + nickname = "testGroupParameters", + notes = "Fake endpoint to test group parameters (optional)" + ) + @ApiResponses({ + @ApiResponse(code = 400, message = "Someting wrong") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/fake" ) - default CompletableFuture> testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup - -, -@ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup -,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group - -,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup - -, -@ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup -,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group - -) { + default CompletableFuture> testGroupParameters( + @NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup, + @ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup, + @NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group, + @ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup, + @ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup, + @ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group + ) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -428,19 +449,23 @@ default CompletableFuture> testGroupParameters(@NotNull @Ap * @param param request body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test inline additionalProperties", + nickname = "testInlineAdditionalProperties", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/inline-additionalProperties", consumes = { "application/json" } ) default CompletableFuture> testInlineAdditionalProperties( - -@ApiParam(value = "request body", required = true ) @Valid @RequestBody Map param) { + @ApiParam(value = "request body", required = true) @Valid @RequestBody Map param + ) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -453,21 +478,24 @@ default CompletableFuture> testInlineAdditionalProperties( * @param param2 field2 (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test json serialization of form data", + nickname = "testJsonFormData", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake/jsonFormData", consumes = { "application/x-www-form-urlencoded" } ) default CompletableFuture> testJsonFormData( - -@ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, - -@ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2) { + @ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, + @ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2 + ) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -484,26 +512,26 @@ default CompletableFuture> testJsonFormData( * @param context (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testQueryParameterCollectionFormat", + notes = "To test the collection format in query parameters" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/test-query-parameters" ) - default CompletableFuture> testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context - -) { + default CompletableFuture> testQueryParameterCollectionFormat( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context + ) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -517,28 +545,33 @@ default CompletableFuture> testQueryParameterCollectionForm * @param additionalMetadata Additional data to pass to server (optional) * @return successful operation (status code 200) */ - - @ApiOperation(value = "uploads an image (required)", nickname = "uploadFileWithRequiredFile", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @ApiOperation( + tags = { "pet" }, + value = "uploads an image (required)", + nickname = "uploadFileWithRequiredFile", + 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 = "/fake/{petId}/uploadImageWithRequiredFile", produces = { "application/json" }, consumes = { "multipart/form-data" } ) - default CompletableFuture> uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata) { + default CompletableFuture> uploadFileWithRequiredFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "file to upload", required = true) @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata + ) { return CompletableFuture.supplyAsync(()-> { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/FakeClassnameTestApi.java index 62ea58d9f92e..3bf73e7e3888 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -37,14 +37,19 @@ default Optional getRequest() { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test class name in snake case", nickname = "testClassname", notes = "To test class name in snake case", response = Client.class, authorizations = { - - @Authorization(value = "api_key_query") - }, tags={ "fake_classname_tags 123#$%^", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake_classname_tags 123#$%^" }, + value = "To test class name in snake case", + nickname = "testClassname", + notes = "To test class name in snake case", + response = Client.class, + authorizations = { + @Authorization(value = "api_key_query") + } + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake_classname_test", @@ -52,8 +57,8 @@ default Optional getRequest() { consumes = { "application/json" } ) default CompletableFuture> testClassname( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { return CompletableFuture.supplyAsync(()-> { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/PetApi.java index 8bbd6812a2b8..0e63ddb12aa3 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/PetApi.java @@ -39,25 +39,30 @@ default Optional getRequest() { * @return successful operation (status code 200) * or Invalid input (status code 405) */ - - @ApiOperation(value = "Add a new pet to the store", nickname = "addPet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Add a new pet to the store", + nickname = "addPet", + 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 = 200, message = "successful operation"), - - @ApiResponse(code = 405, message = "Invalid input") }) + @ApiResponse(code = 405, message = "Invalid input") + }) @RequestMapping( method = RequestMethod.POST, value = "/pet", consumes = { "application/json", "application/xml" } ) default CompletableFuture> addPet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -71,26 +76,30 @@ default CompletableFuture> addPet( * @return successful operation (status code 200) * or Invalid pet value (status code 400) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = 200, message = "successful operation"), - - @ApiResponse(code = 400, message = "Invalid pet value") }) + @ApiResponse(code = 400, message = "Invalid pet value") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/pet/{petId}" ) - default CompletableFuture> deletePet(@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId - -, -@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey -) { + default CompletableFuture> deletePet( + @ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey + ) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -104,25 +113,32 @@ default CompletableFuture> deletePet(@ApiParam(value = "Pet * @return successful operation (status code 200) * or Invalid status value (status code 400) */ - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid status value") }) + @ApiResponse(code = 400, message = "Invalid status value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByStatus", produces = { "application/xml", "application/json" } ) - default CompletableFuture>> 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 status - -) { + default CompletableFuture>> 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 status + ) { return CompletableFuture.supplyAsync(()-> { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -153,25 +169,32 @@ default CompletableFuture>> findPetsByStatus(@NotNull @ * or Invalid tag value (status code 400) * @deprecated */ - - @ApiOperation(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 = "Set", authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "Set", + 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, responseContainer = "Set"), - - @ApiResponse(code = 400, message = "Invalid tag value") }) + @ApiResponse(code = 400, message = "Invalid tag value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByTags", produces = { "application/xml", "application/json" } ) - default CompletableFuture>> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags - -) { + default CompletableFuture>> findPetsByTags( + @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags + ) { return CompletableFuture.supplyAsync(()-> { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -202,26 +225,29 @@ default CompletableFuture>> findPetsByTags(@NotNull @Api * or Invalid ID supplied (status code 400) * or Pet not found (status code 404) */ - - @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { - - @Authorization(value = "api_key") - }, tags={ "pet", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Pet not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/{petId}", produces = { "application/xml", "application/json" } ) - default CompletableFuture> getPetById(@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId - -) { + default CompletableFuture> getPetById( + @ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId + ) { return CompletableFuture.supplyAsync(()-> { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -252,29 +278,32 @@ default CompletableFuture> getPetById(@ApiParam(value = "ID * or Pet not found (status code 404) * or Validation exception (status code 405) */ - - @ApiOperation(value = "Update an existing pet", nickname = "updatePet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Update an existing pet", + nickname = "updatePet", + 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 = 200, message = "successful operation"), - @ApiResponse(code = 400, message = "Invalid ID supplied"), - @ApiResponse(code = 404, message = "Pet not found"), - - @ApiResponse(code = 405, message = "Validation exception") }) + @ApiResponse(code = 405, message = "Validation exception") + }) @RequestMapping( method = RequestMethod.PUT, value = "/pet", consumes = { "application/json", "application/xml" } ) default CompletableFuture> updatePet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -288,27 +317,31 @@ default CompletableFuture> updatePet( * @param status Updated status of the pet (optional) * @return Invalid input (status code 405) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 405, message = "Invalid input") }) + @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" } ) - default CompletableFuture> 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 @RequestPart(value = "name", required = false) String name, - -@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status) { + default CompletableFuture> 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 @RequestPart(value = "name", required = false) String name, + @ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status + ) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -322,28 +355,33 @@ default CompletableFuture> updatePetWithForm(@ApiParam(valu * @param file file to upload (optional) * @return successful operation (status code 200) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @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" } ) - default CompletableFuture> uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { + default CompletableFuture> uploadFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @ApiParam(value = "file to upload") @RequestPart(value = "file", required = false) MultipartFile file + ) { return CompletableFuture.supplyAsync(()-> { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/StoreApi.java index 91919782f1f0..54c240645ae9 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/StoreApi.java @@ -39,20 +39,23 @@ default Optional getRequest() { * @return Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(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", tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/store/order/{order_id}" ) - default CompletableFuture> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId - -) { + default CompletableFuture> deleteOrder( + @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId + ) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -64,20 +67,28 @@ default CompletableFuture> deleteOrder(@ApiParam(value = "I * * @return successful operation (status code 200) */ - - @ApiOperation(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") - }, tags={ "store", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) + @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" } ) - default CompletableFuture>> getInventory() { + default CompletableFuture>> getInventory( + + ) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -92,23 +103,26 @@ default CompletableFuture>> getInventory() { * or Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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 generated 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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/store/order/{order_id}", produces = { "application/xml", "application/json" } ) - default CompletableFuture> getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId - -) { + default CompletableFuture> getOrderById( + @Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId + ) { return CompletableFuture.supplyAsync(()-> { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -137,21 +151,25 @@ default CompletableFuture> getOrderById(@Min(1L) @Max(5L) * @return successful operation (status code 200) * or Invalid Order (status code 400) */ - - @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid Order") + }) @RequestMapping( method = RequestMethod.POST, value = "/store/order", produces = { "application/xml", "application/json" } ) default CompletableFuture> placeOrder( - -@ApiParam(value = "order placed for purchasing the pet", required = true ) @Valid @RequestBody Order body) { + @ApiParam(value = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order body + ) { return CompletableFuture.supplyAsync(()-> { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/UserApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/UserApi.java index 36d364b3c8c2..1eac87034c81 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/UserApi.java @@ -39,18 +39,22 @@ default Optional getRequest() { * @param body Created user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Create user", + nickname = "createUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user" ) default CompletableFuture> createUser( - -@ApiParam(value = "Created user object", required = true ) @Valid @RequestBody User body) { + @ApiParam(value = "Created user object", required = true) @Valid @RequestBody User body + ) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -62,18 +66,22 @@ default CompletableFuture> createUser( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithArrayInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithArray" ) default CompletableFuture> createUsersWithArrayInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -85,18 +93,22 @@ default CompletableFuture> createUsersWithArrayInput( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithListInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithList" ) default CompletableFuture> createUsersWithListInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -110,20 +122,23 @@ default CompletableFuture> createUsersWithListInput( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Delete user", + nickname = "deleteUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/user/{username}" ) - default CompletableFuture> deleteUser(@ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username - -) { + default CompletableFuture> deleteUser( + @ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username + ) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -137,23 +152,26 @@ default CompletableFuture> deleteUser(@ApiParam(value = "Th * or Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/{username}", produces = { "application/xml", "application/json" } ) - default CompletableFuture> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username - -) { + default CompletableFuture> getUserByName( + @ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username + ) { return CompletableFuture.supplyAsync(()-> { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -183,23 +201,26 @@ default CompletableFuture> getUserByName(@ApiParam(value = * @return successful operation (status code 200) * or Invalid username/password supplied (status code 400) */ - - @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid username/password supplied") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/login", produces = { "application/xml", "application/json" } ) - default CompletableFuture> loginUser(@NotNull @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 - -) { + default CompletableFuture> loginUser( + @NotNull @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 CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -210,16 +231,22 @@ default CompletableFuture> loginUser(@NotNull @ApiParam(v * * @return successful operation (status code 200) */ - - @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Logs out current logged in user session", + nickname = "logoutUser", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/logout" ) - default CompletableFuture> logoutUser() { + default CompletableFuture> logoutUser( + + ) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -234,22 +261,24 @@ default CompletableFuture> logoutUser() { * @return Invalid user supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Updated user", + nickname = "updateUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid user supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.PUT, value = "/user/{username}" ) - default CompletableFuture> 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 body) { + default CompletableFuture> 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 body + ) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } diff --git a/samples/server/petstore/spring-mvc-j8-localdatetime/pom.xml b/samples/server/petstore/spring-mvc-j8-localdatetime/pom.xml index 869d354af92a..f14a30570c91 100644 --- a/samples/server/petstore/spring-mvc-j8-localdatetime/pom.xml +++ b/samples/server/petstore/spring-mvc-j8-localdatetime/pom.xml @@ -166,17 +166,18 @@ ${java.version} ${java.version} 1.3.5 - 2.3.3 + 2.3.3 9.2.15.v20160210 1.7.21 4.13.1 4.0.4 - 2.8.0 + 2.9.2 2.9.9 2.8.4 2.0.2 4.3.20.RELEASE 0.2.2 2.9.8 + 1.6.3 diff --git a/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/AnotherFakeApi.java index e98182736edd..49d703d71daf 100644 --- a/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -36,11 +36,16 @@ default Optional getRequest() { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "$another-fake?" }, + value = "To test special tags", + nickname = "call123testSpecialTags", + notes = "To test special tags and operation ID starting with number", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/another-fake/dummy", @@ -48,8 +53,8 @@ default Optional getRequest() { consumes = { "application/json" } ) default ResponseEntity call123testSpecialTags( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/FakeApi.java index 11ccddc3d1c9..af0642e799eb 100644 --- a/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/FakeApi.java @@ -45,19 +45,23 @@ default Optional getRequest() { * @param xmlItem XmlItem Body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "creates an XmlItem", nickname = "createXmlItem", notes = "this route creates an XmlItem", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "creates an XmlItem", + nickname = "createXmlItem", + notes = "this route creates an XmlItem" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/create_xml_item", consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } ) default ResponseEntity createXmlItem( - -@ApiParam(value = "XmlItem Body", required = true ) @Valid @RequestBody XmlItem xmlItem) { + @ApiParam(value = "XmlItem Body", required = true) @Valid @RequestBody XmlItem xmlItem + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -70,19 +74,24 @@ default ResponseEntity createXmlItem( * @param body Input boolean as post body (optional) * @return Output boolean (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterBooleanSerialize", + notes = "Test serialization of outer boolean types", + response = Boolean.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/boolean", produces = { "*/*" } ) default ResponseEntity fakeOuterBooleanSerialize( - -@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { + @ApiParam(value = "Input boolean as post body") @Valid @RequestBody(required = false) Boolean body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -95,19 +104,24 @@ default ResponseEntity fakeOuterBooleanSerialize( * @param body Input composite as post body (optional) * @return Output composite (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterCompositeSerialize", + notes = "Test serialization of object with outer number type", + response = OuterComposite.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/composite", produces = { "*/*" } ) default ResponseEntity fakeOuterCompositeSerialize( - -@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { + @ApiParam(value = "Input composite as post body") @Valid @RequestBody(required = false) OuterComposite body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) { @@ -129,19 +143,24 @@ default ResponseEntity fakeOuterCompositeSerialize( * @param body Input number as post body (optional) * @return Output number (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterNumberSerialize", + notes = "Test serialization of outer number types", + response = BigDecimal.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/number", produces = { "*/*" } ) default ResponseEntity fakeOuterNumberSerialize( - -@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { + @ApiParam(value = "Input number as post body") @Valid @RequestBody(required = false) BigDecimal body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -154,19 +173,24 @@ default ResponseEntity fakeOuterNumberSerialize( * @param body Input string as post body (optional) * @return Output string (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output string", response = String.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterStringSerialize", + notes = "Test serialization of outer string types", + response = String.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output string", response = String.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/string", produces = { "*/*" } ) default ResponseEntity fakeOuterStringSerialize( - -@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { + @ApiParam(value = "Input string as post body") @Valid @RequestBody(required = false) String body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -179,19 +203,23 @@ default ResponseEntity fakeOuterStringSerialize( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithFileSchema", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithFileSchema", + notes = "For this test, the body for this request much reference a schema named `File`." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-file-schema", consumes = { "application/json" } ) default ResponseEntity testBodyWithFileSchema( - -@ApiParam(value = "", required = true ) @Valid @RequestBody FileSchemaTestClass body) { + @ApiParam(value = "", required = true) @Valid @RequestBody FileSchemaTestClass body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -204,21 +232,24 @@ default ResponseEntity testBodyWithFileSchema( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithQueryParams", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithQueryParams", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-query-params", consumes = { "application/json" } ) - default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query - -, - -@ApiParam(value = "", required = true ) @Valid @RequestBody User body) { + default ResponseEntity testBodyWithQueryParams( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query, + @ApiParam(value = "", required = true) @Valid @RequestBody User body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -231,11 +262,16 @@ default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake" }, + value = "To test \"client\" model", + nickname = "testClientModel", + notes = "To test \"client\" model", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake", @@ -243,8 +279,8 @@ default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = consumes = { "application/json" } ) default ResponseEntity testClientModel( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -280,50 +316,40 @@ default ResponseEntity testClientModel( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", authorizations = { - - @Authorization(value = "http_basic_test") - }, tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + nickname = "testEndpointParameters", + notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + authorizations = { + @Authorization(value = "http_basic_test") + } + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testEndpointParameters( - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, - -@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, - -@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, - -@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, - -@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary, - -@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date, - -@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) LocalDateTime dateTime, - -@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, - -@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback) { + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, + @ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, + @ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, + @ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, + @ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, + @ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, + @ApiParam(value = "None") @RequestPart(value = "binary", required = false) MultipartFile binary, + @ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) LocalDateTime dateTime, + @ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, + @ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -344,35 +370,31 @@ default ResponseEntity testEndpointParameters( * @return Invalid request (status code 400) * or Not found (status code 404) */ - - @ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "To test enum parameters", + nickname = "testEnumParameters", + notes = "To test enum parameters" + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid request"), - - @ApiResponse(code = 404, message = "Not found") }) + @ApiResponse(code = 404, message = "Not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testEnumParameters( -@ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray -, -@ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString -,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray - -,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble - -, - -@ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, - -@ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString) { + @ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray, + @ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString, + @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, + @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble, + @ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, + @ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -390,28 +412,27 @@ default ResponseEntity testEnumParameters( * @param int64Group Integer in group parameters (optional) * @return Someting wrong (status code 400) */ - - @ApiOperation(value = "Fake endpoint to test group parameters (optional)", nickname = "testGroupParameters", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 400, message = "Someting wrong") }) + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint to test group parameters (optional)", + nickname = "testGroupParameters", + notes = "Fake endpoint to test group parameters (optional)" + ) + @ApiResponses({ + @ApiResponse(code = 400, message = "Someting wrong") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/fake" ) - default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup - -, -@ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup -,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group - -,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup - -, -@ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup -,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group - -) { + default ResponseEntity testGroupParameters( + @NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup, + @ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup, + @NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group, + @ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup, + @ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup, + @ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -423,19 +444,23 @@ default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Req * @param param request body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test inline additionalProperties", + nickname = "testInlineAdditionalProperties", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/inline-additionalProperties", consumes = { "application/json" } ) default ResponseEntity testInlineAdditionalProperties( - -@ApiParam(value = "request body", required = true ) @Valid @RequestBody Map param) { + @ApiParam(value = "request body", required = true) @Valid @RequestBody Map param + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -448,21 +473,24 @@ default ResponseEntity testInlineAdditionalProperties( * @param param2 field2 (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test json serialization of form data", + nickname = "testJsonFormData", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake/jsonFormData", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testJsonFormData( - -@ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, - -@ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2) { + @ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, + @ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2 + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -479,26 +507,26 @@ default ResponseEntity testJsonFormData( * @param context (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testQueryParameterCollectionFormat", + notes = "To test the collection format in query parameters" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/test-query-parameters" ) - default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context - -) { + default ResponseEntity testQueryParameterCollectionFormat( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -512,28 +540,33 @@ default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiPar * @param additionalMetadata Additional data to pass to server (optional) * @return successful operation (status code 200) */ - - @ApiOperation(value = "uploads an image (required)", nickname = "uploadFileWithRequiredFile", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @ApiOperation( + tags = { "pet" }, + value = "uploads an image (required)", + nickname = "uploadFileWithRequiredFile", + 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 = "/fake/{petId}/uploadImageWithRequiredFile", produces = { "application/json" }, consumes = { "multipart/form-data" } ) - default ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata) { + default ResponseEntity uploadFileWithRequiredFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "file to upload", required = true) @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/FakeClassnameTestApi.java index efa3146991d6..8c44f6c0992f 100644 --- a/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -36,14 +36,19 @@ default Optional getRequest() { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test class name in snake case", nickname = "testClassname", notes = "To test class name in snake case", response = Client.class, authorizations = { - - @Authorization(value = "api_key_query") - }, tags={ "fake_classname_tags 123#$%^", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake_classname_tags 123#$%^" }, + value = "To test class name in snake case", + nickname = "testClassname", + notes = "To test class name in snake case", + response = Client.class, + authorizations = { + @Authorization(value = "api_key_query") + } + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake_classname_test", @@ -51,8 +56,8 @@ default Optional getRequest() { consumes = { "application/json" } ) default ResponseEntity testClassname( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/PetApi.java index 30bbc2f6c18a..316f07e44847 100644 --- a/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/PetApi.java @@ -38,25 +38,30 @@ default Optional getRequest() { * @return successful operation (status code 200) * or Invalid input (status code 405) */ - - @ApiOperation(value = "Add a new pet to the store", nickname = "addPet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Add a new pet to the store", + nickname = "addPet", + 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 = 200, message = "successful operation"), - - @ApiResponse(code = 405, message = "Invalid input") }) + @ApiResponse(code = 405, message = "Invalid input") + }) @RequestMapping( method = RequestMethod.POST, value = "/pet", consumes = { "application/json", "application/xml" } ) default ResponseEntity addPet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -70,26 +75,30 @@ default ResponseEntity addPet( * @return successful operation (status code 200) * or Invalid pet value (status code 400) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = 200, message = "successful operation"), - - @ApiResponse(code = 400, message = "Invalid pet value") }) + @ApiResponse(code = 400, message = "Invalid pet value") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/pet/{petId}" ) - default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId - -, -@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey -) { + default ResponseEntity deletePet( + @ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -103,25 +112,32 @@ default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", req * @return successful operation (status code 200) * or Invalid status value (status code 400) */ - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid status value") }) + @ApiResponse(code = 400, message = "Invalid status value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByStatus", produces = { "application/xml", "application/json" } ) - default ResponseEntity> 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 status - -) { + default ResponseEntity> 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 status + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -150,25 +166,32 @@ default ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "S * or Invalid tag value (status code 400) * @deprecated */ - - @ApiOperation(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 = "Set", authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "Set", + 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, responseContainer = "Set"), - - @ApiResponse(code = 400, message = "Invalid tag value") }) + @ApiResponse(code = 400, message = "Invalid tag value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByTags", produces = { "application/xml", "application/json" } ) - default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags - -) { + default ResponseEntity> findPetsByTags( + @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -197,26 +220,29 @@ default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags * or Invalid ID supplied (status code 400) * or Pet not found (status code 404) */ - - @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { - - @Authorization(value = "api_key") - }, tags={ "pet", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Pet not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/{petId}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId - -) { + default ResponseEntity getPetById( + @ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -245,29 +271,32 @@ default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", * or Pet not found (status code 404) * or Validation exception (status code 405) */ - - @ApiOperation(value = "Update an existing pet", nickname = "updatePet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Update an existing pet", + nickname = "updatePet", + 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 = 200, message = "successful operation"), - @ApiResponse(code = 400, message = "Invalid ID supplied"), - @ApiResponse(code = 404, message = "Pet not found"), - - @ApiResponse(code = 405, message = "Validation exception") }) + @ApiResponse(code = 405, message = "Validation exception") + }) @RequestMapping( method = RequestMethod.PUT, value = "/pet", consumes = { "application/json", "application/xml" } ) default ResponseEntity updatePet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -281,27 +310,31 @@ default ResponseEntity updatePet( * @param status Updated status of the pet (optional) * @return Invalid input (status code 405) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 405, message = "Invalid input") }) + @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" } ) - default ResponseEntity 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 @RequestPart(value = "name", required = false) String name, - -@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status) { + default ResponseEntity 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 @RequestPart(value = "name", required = false) String name, + @ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -315,28 +348,33 @@ default ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that * @param file file to upload (optional) * @return successful operation (status code 200) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @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" } ) - default ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { + default ResponseEntity uploadFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @ApiParam(value = "file to upload") @RequestPart(value = "file", required = false) MultipartFile file + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/StoreApi.java index 1d86f2d6fb0a..84abf7191820 100644 --- a/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/StoreApi.java @@ -38,20 +38,23 @@ default Optional getRequest() { * @return Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(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", tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/store/order/{order_id}" ) - default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId - -) { + default ResponseEntity deleteOrder( + @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -63,20 +66,28 @@ default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that * * @return successful operation (status code 200) */ - - @ApiOperation(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") - }, tags={ "store", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) + @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" } ) - default ResponseEntity> getInventory() { + default ResponseEntity> getInventory( + + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -91,23 +102,26 @@ default ResponseEntity> getInventory() { * or Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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 generated 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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/store/order/{order_id}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId - -) { + default ResponseEntity getOrderById( + @Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -134,21 +148,25 @@ default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = " * @return successful operation (status code 200) * or Invalid Order (status code 400) */ - - @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid Order") + }) @RequestMapping( method = RequestMethod.POST, value = "/store/order", produces = { "application/xml", "application/json" } ) default ResponseEntity placeOrder( - -@ApiParam(value = "order placed for purchasing the pet", required = true ) @Valid @RequestBody Order body) { + @ApiParam(value = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/UserApi.java b/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/UserApi.java index 069adca03450..646e9089e6a5 100644 --- a/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/UserApi.java @@ -38,18 +38,22 @@ default Optional getRequest() { * @param body Created user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Create user", + nickname = "createUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user" ) default ResponseEntity createUser( - -@ApiParam(value = "Created user object", required = true ) @Valid @RequestBody User body) { + @ApiParam(value = "Created user object", required = true) @Valid @RequestBody User body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -61,18 +65,22 @@ default ResponseEntity createUser( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithArrayInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithArray" ) default ResponseEntity createUsersWithArrayInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -84,18 +92,22 @@ default ResponseEntity createUsersWithArrayInput( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithListInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithList" ) default ResponseEntity createUsersWithListInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -109,20 +121,23 @@ default ResponseEntity createUsersWithListInput( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Delete user", + nickname = "deleteUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/user/{username}" ) - default ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username - -) { + default ResponseEntity deleteUser( + @ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -136,23 +151,26 @@ default ResponseEntity deleteUser(@ApiParam(value = "The name that needs t * or Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/{username}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username - -) { + default ResponseEntity getUserByName( + @ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -180,23 +198,26 @@ default ResponseEntity getUserByName(@ApiParam(value = "The name that need * @return successful operation (status code 200) * or Invalid username/password supplied (status code 400) */ - - @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid username/password supplied") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/login", produces = { "application/xml", "application/json" } ) - default ResponseEntity loginUser(@NotNull @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 - -) { + default ResponseEntity loginUser( + @NotNull @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 new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -207,16 +228,22 @@ default ResponseEntity loginUser(@NotNull @ApiParam(value = "The user na * * @return successful operation (status code 200) */ - - @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Logs out current logged in user session", + nickname = "logoutUser", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/logout" ) - default ResponseEntity logoutUser() { + default ResponseEntity logoutUser( + + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -231,22 +258,24 @@ default ResponseEntity logoutUser() { * @return Invalid user supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Updated user", + nickname = "updateUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid user supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.PUT, value = "/user/{username}" ) - default ResponseEntity 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 body) { + default ResponseEntity 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 body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } diff --git a/samples/server/petstore/spring-mvc-no-nullable/pom.xml b/samples/server/petstore/spring-mvc-no-nullable/pom.xml index 126e6408ffcb..4c44170eca32 100644 --- a/samples/server/petstore/spring-mvc-no-nullable/pom.xml +++ b/samples/server/petstore/spring-mvc-no-nullable/pom.xml @@ -161,16 +161,17 @@ ${java.version} ${java.version} 1.3.5 - 2.3.3 + 2.3.3 9.2.15.v20160210 1.7.21 4.13.1 4.0.4 - 2.8.0 + 2.9.2 2.9.9 2.8.4 2.0.2 4.3.20.RELEASE 2.9.8 + 1.6.3 diff --git a/samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/AnotherFakeApi.java index e98182736edd..49d703d71daf 100644 --- a/samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -36,11 +36,16 @@ default Optional getRequest() { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "$another-fake?" }, + value = "To test special tags", + nickname = "call123testSpecialTags", + notes = "To test special tags and operation ID starting with number", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/another-fake/dummy", @@ -48,8 +53,8 @@ default Optional getRequest() { consumes = { "application/json" } ) default ResponseEntity call123testSpecialTags( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/FakeApi.java index e17bed0498fc..6f95540156b3 100644 --- a/samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/FakeApi.java @@ -45,19 +45,23 @@ default Optional getRequest() { * @param xmlItem XmlItem Body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "creates an XmlItem", nickname = "createXmlItem", notes = "this route creates an XmlItem", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "creates an XmlItem", + nickname = "createXmlItem", + notes = "this route creates an XmlItem" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/create_xml_item", consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } ) default ResponseEntity createXmlItem( - -@ApiParam(value = "XmlItem Body", required = true ) @Valid @RequestBody XmlItem xmlItem) { + @ApiParam(value = "XmlItem Body", required = true) @Valid @RequestBody XmlItem xmlItem + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -70,19 +74,24 @@ default ResponseEntity createXmlItem( * @param body Input boolean as post body (optional) * @return Output boolean (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterBooleanSerialize", + notes = "Test serialization of outer boolean types", + response = Boolean.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/boolean", produces = { "*/*" } ) default ResponseEntity fakeOuterBooleanSerialize( - -@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { + @ApiParam(value = "Input boolean as post body") @Valid @RequestBody(required = false) Boolean body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -95,19 +104,24 @@ default ResponseEntity fakeOuterBooleanSerialize( * @param body Input composite as post body (optional) * @return Output composite (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterCompositeSerialize", + notes = "Test serialization of object with outer number type", + response = OuterComposite.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/composite", produces = { "*/*" } ) default ResponseEntity fakeOuterCompositeSerialize( - -@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { + @ApiParam(value = "Input composite as post body") @Valid @RequestBody(required = false) OuterComposite body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) { @@ -129,19 +143,24 @@ default ResponseEntity fakeOuterCompositeSerialize( * @param body Input number as post body (optional) * @return Output number (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterNumberSerialize", + notes = "Test serialization of outer number types", + response = BigDecimal.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/number", produces = { "*/*" } ) default ResponseEntity fakeOuterNumberSerialize( - -@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { + @ApiParam(value = "Input number as post body") @Valid @RequestBody(required = false) BigDecimal body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -154,19 +173,24 @@ default ResponseEntity fakeOuterNumberSerialize( * @param body Input string as post body (optional) * @return Output string (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output string", response = String.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterStringSerialize", + notes = "Test serialization of outer string types", + response = String.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output string", response = String.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/string", produces = { "*/*" } ) default ResponseEntity fakeOuterStringSerialize( - -@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { + @ApiParam(value = "Input string as post body") @Valid @RequestBody(required = false) String body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -179,19 +203,23 @@ default ResponseEntity fakeOuterStringSerialize( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithFileSchema", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithFileSchema", + notes = "For this test, the body for this request much reference a schema named `File`." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-file-schema", consumes = { "application/json" } ) default ResponseEntity testBodyWithFileSchema( - -@ApiParam(value = "", required = true ) @Valid @RequestBody FileSchemaTestClass body) { + @ApiParam(value = "", required = true) @Valid @RequestBody FileSchemaTestClass body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -204,21 +232,24 @@ default ResponseEntity testBodyWithFileSchema( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithQueryParams", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithQueryParams", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-query-params", consumes = { "application/json" } ) - default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query - -, - -@ApiParam(value = "", required = true ) @Valid @RequestBody User body) { + default ResponseEntity testBodyWithQueryParams( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query, + @ApiParam(value = "", required = true) @Valid @RequestBody User body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -231,11 +262,16 @@ default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake" }, + value = "To test \"client\" model", + nickname = "testClientModel", + notes = "To test \"client\" model", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake", @@ -243,8 +279,8 @@ default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = consumes = { "application/json" } ) default ResponseEntity testClientModel( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -280,50 +316,40 @@ default ResponseEntity testClientModel( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", authorizations = { - - @Authorization(value = "http_basic_test") - }, tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + nickname = "testEndpointParameters", + notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + authorizations = { + @Authorization(value = "http_basic_test") + } + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testEndpointParameters( - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, - -@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, - -@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, - -@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, - -@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary, - -@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date, - -@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime, - -@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, - -@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback) { + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, + @ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, + @ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, + @ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, + @ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, + @ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, + @ApiParam(value = "None") @RequestPart(value = "binary", required = false) MultipartFile binary, + @ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, + @ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -344,35 +370,31 @@ default ResponseEntity testEndpointParameters( * @return Invalid request (status code 400) * or Not found (status code 404) */ - - @ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "To test enum parameters", + nickname = "testEnumParameters", + notes = "To test enum parameters" + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid request"), - - @ApiResponse(code = 404, message = "Not found") }) + @ApiResponse(code = 404, message = "Not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testEnumParameters( -@ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray -, -@ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString -,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray - -,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble - -, - -@ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, - -@ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString) { + @ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray, + @ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString, + @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, + @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble, + @ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, + @ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -390,28 +412,27 @@ default ResponseEntity testEnumParameters( * @param int64Group Integer in group parameters (optional) * @return Someting wrong (status code 400) */ - - @ApiOperation(value = "Fake endpoint to test group parameters (optional)", nickname = "testGroupParameters", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 400, message = "Someting wrong") }) + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint to test group parameters (optional)", + nickname = "testGroupParameters", + notes = "Fake endpoint to test group parameters (optional)" + ) + @ApiResponses({ + @ApiResponse(code = 400, message = "Someting wrong") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/fake" ) - default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup - -, -@ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup -,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group - -,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup - -, -@ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup -,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group - -) { + default ResponseEntity testGroupParameters( + @NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup, + @ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup, + @NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group, + @ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup, + @ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup, + @ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -423,19 +444,23 @@ default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Req * @param param request body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test inline additionalProperties", + nickname = "testInlineAdditionalProperties", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/inline-additionalProperties", consumes = { "application/json" } ) default ResponseEntity testInlineAdditionalProperties( - -@ApiParam(value = "request body", required = true ) @Valid @RequestBody Map param) { + @ApiParam(value = "request body", required = true) @Valid @RequestBody Map param + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -448,21 +473,24 @@ default ResponseEntity testInlineAdditionalProperties( * @param param2 field2 (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test json serialization of form data", + nickname = "testJsonFormData", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake/jsonFormData", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testJsonFormData( - -@ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, - -@ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2) { + @ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, + @ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2 + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -479,26 +507,26 @@ default ResponseEntity testJsonFormData( * @param context (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testQueryParameterCollectionFormat", + notes = "To test the collection format in query parameters" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/test-query-parameters" ) - default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context - -) { + default ResponseEntity testQueryParameterCollectionFormat( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -512,28 +540,33 @@ default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiPar * @param additionalMetadata Additional data to pass to server (optional) * @return successful operation (status code 200) */ - - @ApiOperation(value = "uploads an image (required)", nickname = "uploadFileWithRequiredFile", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @ApiOperation( + tags = { "pet" }, + value = "uploads an image (required)", + nickname = "uploadFileWithRequiredFile", + 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 = "/fake/{petId}/uploadImageWithRequiredFile", produces = { "application/json" }, consumes = { "multipart/form-data" } ) - default ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata) { + default ResponseEntity uploadFileWithRequiredFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "file to upload", required = true) @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/FakeClassnameTestApi.java index efa3146991d6..8c44f6c0992f 100644 --- a/samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -36,14 +36,19 @@ default Optional getRequest() { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test class name in snake case", nickname = "testClassname", notes = "To test class name in snake case", response = Client.class, authorizations = { - - @Authorization(value = "api_key_query") - }, tags={ "fake_classname_tags 123#$%^", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake_classname_tags 123#$%^" }, + value = "To test class name in snake case", + nickname = "testClassname", + notes = "To test class name in snake case", + response = Client.class, + authorizations = { + @Authorization(value = "api_key_query") + } + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake_classname_test", @@ -51,8 +56,8 @@ default Optional getRequest() { consumes = { "application/json" } ) default ResponseEntity testClassname( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/PetApi.java index 30bbc2f6c18a..316f07e44847 100644 --- a/samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/PetApi.java @@ -38,25 +38,30 @@ default Optional getRequest() { * @return successful operation (status code 200) * or Invalid input (status code 405) */ - - @ApiOperation(value = "Add a new pet to the store", nickname = "addPet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Add a new pet to the store", + nickname = "addPet", + 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 = 200, message = "successful operation"), - - @ApiResponse(code = 405, message = "Invalid input") }) + @ApiResponse(code = 405, message = "Invalid input") + }) @RequestMapping( method = RequestMethod.POST, value = "/pet", consumes = { "application/json", "application/xml" } ) default ResponseEntity addPet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -70,26 +75,30 @@ default ResponseEntity addPet( * @return successful operation (status code 200) * or Invalid pet value (status code 400) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = 200, message = "successful operation"), - - @ApiResponse(code = 400, message = "Invalid pet value") }) + @ApiResponse(code = 400, message = "Invalid pet value") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/pet/{petId}" ) - default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId - -, -@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey -) { + default ResponseEntity deletePet( + @ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -103,25 +112,32 @@ default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", req * @return successful operation (status code 200) * or Invalid status value (status code 400) */ - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid status value") }) + @ApiResponse(code = 400, message = "Invalid status value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByStatus", produces = { "application/xml", "application/json" } ) - default ResponseEntity> 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 status - -) { + default ResponseEntity> 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 status + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -150,25 +166,32 @@ default ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "S * or Invalid tag value (status code 400) * @deprecated */ - - @ApiOperation(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 = "Set", authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "Set", + 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, responseContainer = "Set"), - - @ApiResponse(code = 400, message = "Invalid tag value") }) + @ApiResponse(code = 400, message = "Invalid tag value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByTags", produces = { "application/xml", "application/json" } ) - default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags - -) { + default ResponseEntity> findPetsByTags( + @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -197,26 +220,29 @@ default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags * or Invalid ID supplied (status code 400) * or Pet not found (status code 404) */ - - @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { - - @Authorization(value = "api_key") - }, tags={ "pet", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Pet not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/{petId}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId - -) { + default ResponseEntity getPetById( + @ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -245,29 +271,32 @@ default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", * or Pet not found (status code 404) * or Validation exception (status code 405) */ - - @ApiOperation(value = "Update an existing pet", nickname = "updatePet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Update an existing pet", + nickname = "updatePet", + 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 = 200, message = "successful operation"), - @ApiResponse(code = 400, message = "Invalid ID supplied"), - @ApiResponse(code = 404, message = "Pet not found"), - - @ApiResponse(code = 405, message = "Validation exception") }) + @ApiResponse(code = 405, message = "Validation exception") + }) @RequestMapping( method = RequestMethod.PUT, value = "/pet", consumes = { "application/json", "application/xml" } ) default ResponseEntity updatePet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -281,27 +310,31 @@ default ResponseEntity updatePet( * @param status Updated status of the pet (optional) * @return Invalid input (status code 405) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 405, message = "Invalid input") }) + @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" } ) - default ResponseEntity 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 @RequestPart(value = "name", required = false) String name, - -@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status) { + default ResponseEntity 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 @RequestPart(value = "name", required = false) String name, + @ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -315,28 +348,33 @@ default ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that * @param file file to upload (optional) * @return successful operation (status code 200) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @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" } ) - default ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { + default ResponseEntity uploadFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @ApiParam(value = "file to upload") @RequestPart(value = "file", required = false) MultipartFile file + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/StoreApi.java index 1d86f2d6fb0a..84abf7191820 100644 --- a/samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/StoreApi.java @@ -38,20 +38,23 @@ default Optional getRequest() { * @return Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(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", tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/store/order/{order_id}" ) - default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId - -) { + default ResponseEntity deleteOrder( + @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -63,20 +66,28 @@ default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that * * @return successful operation (status code 200) */ - - @ApiOperation(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") - }, tags={ "store", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) + @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" } ) - default ResponseEntity> getInventory() { + default ResponseEntity> getInventory( + + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -91,23 +102,26 @@ default ResponseEntity> getInventory() { * or Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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 generated 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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/store/order/{order_id}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId - -) { + default ResponseEntity getOrderById( + @Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -134,21 +148,25 @@ default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = " * @return successful operation (status code 200) * or Invalid Order (status code 400) */ - - @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid Order") + }) @RequestMapping( method = RequestMethod.POST, value = "/store/order", produces = { "application/xml", "application/json" } ) default ResponseEntity placeOrder( - -@ApiParam(value = "order placed for purchasing the pet", required = true ) @Valid @RequestBody Order body) { + @ApiParam(value = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/UserApi.java b/samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/UserApi.java index 8454fafb3209..86fcdae11023 100644 --- a/samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/UserApi.java @@ -38,18 +38,22 @@ default Optional getRequest() { * @param body Created user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Create user", + nickname = "createUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user" ) default ResponseEntity createUser( - -@ApiParam(value = "Created user object", required = true ) @Valid @RequestBody User body) { + @ApiParam(value = "Created user object", required = true) @Valid @RequestBody User body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -61,18 +65,22 @@ default ResponseEntity createUser( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithArrayInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithArray" ) default ResponseEntity createUsersWithArrayInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -84,18 +92,22 @@ default ResponseEntity createUsersWithArrayInput( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithListInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithList" ) default ResponseEntity createUsersWithListInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -109,20 +121,23 @@ default ResponseEntity createUsersWithListInput( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Delete user", + nickname = "deleteUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/user/{username}" ) - default ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username - -) { + default ResponseEntity deleteUser( + @ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -136,23 +151,26 @@ default ResponseEntity deleteUser(@ApiParam(value = "The name that needs t * or Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/{username}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username - -) { + default ResponseEntity getUserByName( + @ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -180,23 +198,26 @@ default ResponseEntity getUserByName(@ApiParam(value = "The name that need * @return successful operation (status code 200) * or Invalid username/password supplied (status code 400) */ - - @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid username/password supplied") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/login", produces = { "application/xml", "application/json" } ) - default ResponseEntity loginUser(@NotNull @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 - -) { + default ResponseEntity loginUser( + @NotNull @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 new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -207,16 +228,22 @@ default ResponseEntity loginUser(@NotNull @ApiParam(value = "The user na * * @return successful operation (status code 200) */ - - @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Logs out current logged in user session", + nickname = "logoutUser", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/logout" ) - default ResponseEntity logoutUser() { + default ResponseEntity logoutUser( + + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -231,22 +258,24 @@ default ResponseEntity logoutUser() { * @return Invalid user supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Updated user", + nickname = "updateUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid user supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.PUT, value = "/user/{username}" ) - default ResponseEntity 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 body) { + default ResponseEntity 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 body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } diff --git a/samples/server/petstore/spring-mvc-spring-pageable/pom.xml b/samples/server/petstore/spring-mvc-spring-pageable/pom.xml index 1407e73ebaf0..8e4e24b77ae2 100644 --- a/samples/server/petstore/spring-mvc-spring-pageable/pom.xml +++ b/samples/server/petstore/spring-mvc-spring-pageable/pom.xml @@ -166,17 +166,18 @@ ${java.version} ${java.version} 1.3.5 - 2.3.3 + 2.3.3 9.2.15.v20160210 1.7.21 4.13.1 4.0.4 - 2.8.0 + 2.9.2 2.9.9 2.8.4 2.0.2 4.3.20.RELEASE 0.2.2 2.9.8 + 1.6.3 diff --git a/samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/AnotherFakeApi.java index e98182736edd..49d703d71daf 100644 --- a/samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -36,11 +36,16 @@ default Optional getRequest() { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "$another-fake?" }, + value = "To test special tags", + nickname = "call123testSpecialTags", + notes = "To test special tags and operation ID starting with number", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/another-fake/dummy", @@ -48,8 +53,8 @@ default Optional getRequest() { consumes = { "application/json" } ) default ResponseEntity call123testSpecialTags( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/FakeApi.java index b163efb8b189..8c700d4f0f8e 100644 --- a/samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/FakeApi.java @@ -45,19 +45,23 @@ default Optional getRequest() { * @param xmlItem XmlItem Body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "creates an XmlItem", nickname = "createXmlItem", notes = "this route creates an XmlItem", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "creates an XmlItem", + nickname = "createXmlItem", + notes = "this route creates an XmlItem" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/create_xml_item", consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } ) default ResponseEntity createXmlItem( - -@ApiParam(value = "XmlItem Body", required = true ) @Valid @RequestBody XmlItem xmlItem) { + @ApiParam(value = "XmlItem Body", required = true) @Valid @RequestBody XmlItem xmlItem + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -70,19 +74,24 @@ default ResponseEntity createXmlItem( * @param body Input boolean as post body (optional) * @return Output boolean (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterBooleanSerialize", + notes = "Test serialization of outer boolean types", + response = Boolean.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/boolean", produces = { "*/*" } ) default ResponseEntity fakeOuterBooleanSerialize( - -@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { + @ApiParam(value = "Input boolean as post body") @Valid @RequestBody(required = false) Boolean body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -95,19 +104,24 @@ default ResponseEntity fakeOuterBooleanSerialize( * @param body Input composite as post body (optional) * @return Output composite (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterCompositeSerialize", + notes = "Test serialization of object with outer number type", + response = OuterComposite.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/composite", produces = { "*/*" } ) default ResponseEntity fakeOuterCompositeSerialize( - -@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { + @ApiParam(value = "Input composite as post body") @Valid @RequestBody(required = false) OuterComposite body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) { @@ -129,19 +143,24 @@ default ResponseEntity fakeOuterCompositeSerialize( * @param body Input number as post body (optional) * @return Output number (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterNumberSerialize", + notes = "Test serialization of outer number types", + response = BigDecimal.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/number", produces = { "*/*" } ) default ResponseEntity fakeOuterNumberSerialize( - -@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { + @ApiParam(value = "Input number as post body") @Valid @RequestBody(required = false) BigDecimal body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -154,19 +173,24 @@ default ResponseEntity fakeOuterNumberSerialize( * @param body Input string as post body (optional) * @return Output string (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output string", response = String.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterStringSerialize", + notes = "Test serialization of outer string types", + response = String.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output string", response = String.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/string", produces = { "*/*" } ) default ResponseEntity fakeOuterStringSerialize( - -@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { + @ApiParam(value = "Input string as post body") @Valid @RequestBody(required = false) String body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -179,19 +203,23 @@ default ResponseEntity fakeOuterStringSerialize( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithFileSchema", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithFileSchema", + notes = "For this test, the body for this request much reference a schema named `File`." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-file-schema", consumes = { "application/json" } ) default ResponseEntity testBodyWithFileSchema( - -@ApiParam(value = "", required = true ) @Valid @RequestBody FileSchemaTestClass body) { + @ApiParam(value = "", required = true) @Valid @RequestBody FileSchemaTestClass body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -204,21 +232,24 @@ default ResponseEntity testBodyWithFileSchema( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithQueryParams", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithQueryParams", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-query-params", consumes = { "application/json" } ) - default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query - -, - -@ApiParam(value = "", required = true ) @Valid @RequestBody User body) { + default ResponseEntity testBodyWithQueryParams( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query, + @ApiParam(value = "", required = true) @Valid @RequestBody User body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -231,11 +262,16 @@ default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake" }, + value = "To test \"client\" model", + nickname = "testClientModel", + notes = "To test \"client\" model", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake", @@ -243,8 +279,8 @@ default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = consumes = { "application/json" } ) default ResponseEntity testClientModel( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -280,50 +316,40 @@ default ResponseEntity testClientModel( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", authorizations = { - - @Authorization(value = "http_basic_test") - }, tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", + nickname = "testEndpointParameters", + notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", + authorizations = { + @Authorization(value = "http_basic_test") + } + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testEndpointParameters( - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, - -@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, - -@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, - -@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, - -@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary, - -@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date, - -@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime, - -@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, - -@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback) { + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, + @ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, + @ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, + @ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, + @ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, + @ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, + @ApiParam(value = "None") @RequestPart(value = "binary", required = false) MultipartFile binary, + @ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, + @ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -344,35 +370,31 @@ default ResponseEntity testEndpointParameters( * @return Invalid request (status code 400) * or Not found (status code 404) */ - - @ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "To test enum parameters", + nickname = "testEnumParameters", + notes = "To test enum parameters" + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid request"), - - @ApiResponse(code = 404, message = "Not found") }) + @ApiResponse(code = 404, message = "Not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testEnumParameters( -@ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray -, -@ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString -,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray - -,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble - -, - -@ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, - -@ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString) { + @ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray, + @ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString, + @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, + @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble, + @ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, + @ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -390,28 +412,27 @@ default ResponseEntity testEnumParameters( * @param int64Group Integer in group parameters (optional) * @return Someting wrong (status code 400) */ - - @ApiOperation(value = "Fake endpoint to test group parameters (optional)", nickname = "testGroupParameters", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 400, message = "Someting wrong") }) + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint to test group parameters (optional)", + nickname = "testGroupParameters", + notes = "Fake endpoint to test group parameters (optional)" + ) + @ApiResponses({ + @ApiResponse(code = 400, message = "Someting wrong") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/fake" ) - default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup - -, -@ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup -,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group - -,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup - -, -@ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup -,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group - -) { + default ResponseEntity testGroupParameters( + @NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup, + @ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup, + @NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group, + @ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup, + @ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup, + @ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -423,19 +444,23 @@ default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Req * @param param request body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test inline additionalProperties", + nickname = "testInlineAdditionalProperties", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/inline-additionalProperties", consumes = { "application/json" } ) default ResponseEntity testInlineAdditionalProperties( - -@ApiParam(value = "request body", required = true ) @Valid @RequestBody Map param) { + @ApiParam(value = "request body", required = true) @Valid @RequestBody Map param + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -448,21 +473,24 @@ default ResponseEntity testInlineAdditionalProperties( * @param param2 field2 (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test json serialization of form data", + nickname = "testJsonFormData", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake/jsonFormData", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testJsonFormData( - -@ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, - -@ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2) { + @ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, + @ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2 + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -479,26 +507,26 @@ default ResponseEntity testJsonFormData( * @param context (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testQueryParameterCollectionFormat", + notes = "To test the collection format in query parameters" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/test-query-parameters" ) - default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context - -) { + default ResponseEntity testQueryParameterCollectionFormat( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -512,28 +540,33 @@ default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiPar * @param additionalMetadata Additional data to pass to server (optional) * @return successful operation (status code 200) */ - - @ApiOperation(value = "uploads an image (required)", nickname = "uploadFileWithRequiredFile", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @ApiOperation( + tags = { "pet" }, + value = "uploads an image (required)", + nickname = "uploadFileWithRequiredFile", + 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 = "/fake/{petId}/uploadImageWithRequiredFile", produces = { "application/json" }, consumes = { "multipart/form-data" } ) - default ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata) { + default ResponseEntity uploadFileWithRequiredFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "file to upload", required = true) @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/FakeClassnameTestApi.java index efa3146991d6..8c44f6c0992f 100644 --- a/samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -36,14 +36,19 @@ default Optional getRequest() { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test class name in snake case", nickname = "testClassname", notes = "To test class name in snake case", response = Client.class, authorizations = { - - @Authorization(value = "api_key_query") - }, tags={ "fake_classname_tags 123#$%^", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake_classname_tags 123#$%^" }, + value = "To test class name in snake case", + nickname = "testClassname", + notes = "To test class name in snake case", + response = Client.class, + authorizations = { + @Authorization(value = "api_key_query") + } + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake_classname_test", @@ -51,8 +56,8 @@ default Optional getRequest() { consumes = { "application/json" } ) default ResponseEntity testClassname( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/PetApi.java index f768ce9be9b1..6e46b5c6f9d8 100644 --- a/samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/PetApi.java @@ -37,25 +37,30 @@ default Optional getRequest() { * @return successful operation (status code 200) * or Invalid input (status code 405) */ - - @ApiOperation(value = "Add a new pet to the store", nickname = "addPet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Add a new pet to the store", + nickname = "addPet", + 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 = 200, message = "successful operation"), - - @ApiResponse(code = 405, message = "Invalid input") }) + @ApiResponse(code = 405, message = "Invalid input") + }) @RequestMapping( method = RequestMethod.POST, value = "/pet", consumes = { "application/json", "application/xml" } ) default ResponseEntity addPet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -69,26 +74,30 @@ default ResponseEntity addPet( * @return successful operation (status code 200) * or Invalid pet value (status code 400) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = 200, message = "successful operation"), - - @ApiResponse(code = 400, message = "Invalid pet value") }) + @ApiResponse(code = 400, message = "Invalid pet value") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/pet/{petId}" ) - default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId - -, -@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey -) { + default ResponseEntity deletePet( + @ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -102,25 +111,33 @@ default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", req * @return successful operation (status code 200) * or Invalid status value (status code 400) */ - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid status value") }) + @ApiResponse(code = 400, message = "Invalid status value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByStatus", produces = { "application/xml", "application/json" } ) - default ResponseEntity> 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 status - -, @springfox.documentation.annotations.ApiIgnore final org.springframework.data.domain.Pageable pageable) { + default ResponseEntity> 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 status, + @springfox.documentation.annotations.ApiIgnore final org.springframework.data.domain.Pageable pageable + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -149,25 +166,33 @@ default ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "S * or Invalid tag value (status code 400) * @deprecated */ - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid tag value") }) + @ApiResponse(code = 400, message = "Invalid tag value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByTags", produces = { "application/xml", "application/json" } ) - default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags - -, @springfox.documentation.annotations.ApiIgnore final org.springframework.data.domain.Pageable pageable) { + default ResponseEntity> findPetsByTags( + @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, + @springfox.documentation.annotations.ApiIgnore final org.springframework.data.domain.Pageable pageable + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -196,26 +221,29 @@ default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tag * or Invalid ID supplied (status code 400) * or Pet not found (status code 404) */ - - @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { - - @Authorization(value = "api_key") - }, tags={ "pet", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Pet not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/{petId}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId - -) { + default ResponseEntity getPetById( + @ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -244,29 +272,32 @@ default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", * or Pet not found (status code 404) * or Validation exception (status code 405) */ - - @ApiOperation(value = "Update an existing pet", nickname = "updatePet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Update an existing pet", + nickname = "updatePet", + 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 = 200, message = "successful operation"), - @ApiResponse(code = 400, message = "Invalid ID supplied"), - @ApiResponse(code = 404, message = "Pet not found"), - - @ApiResponse(code = 405, message = "Validation exception") }) + @ApiResponse(code = 405, message = "Validation exception") + }) @RequestMapping( method = RequestMethod.PUT, value = "/pet", consumes = { "application/json", "application/xml" } ) default ResponseEntity updatePet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -280,27 +311,31 @@ default ResponseEntity updatePet( * @param status Updated status of the pet (optional) * @return Invalid input (status code 405) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 405, message = "Invalid input") }) + @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" } ) - default ResponseEntity 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 @RequestPart(value = "name", required = false) String name, - -@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status) { + default ResponseEntity 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 @RequestPart(value = "name", required = false) String name, + @ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -314,28 +349,33 @@ default ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that * @param file file to upload (optional) * @return successful operation (status code 200) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @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" } ) - default ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { + default ResponseEntity uploadFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @ApiParam(value = "file to upload") @RequestPart(value = "file", required = false) MultipartFile file + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/StoreApi.java index 1d86f2d6fb0a..84abf7191820 100644 --- a/samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/StoreApi.java @@ -38,20 +38,23 @@ default Optional getRequest() { * @return Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(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", tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/store/order/{order_id}" ) - default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId - -) { + default ResponseEntity deleteOrder( + @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -63,20 +66,28 @@ default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that * * @return successful operation (status code 200) */ - - @ApiOperation(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") - }, tags={ "store", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) + @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" } ) - default ResponseEntity> getInventory() { + default ResponseEntity> getInventory( + + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -91,23 +102,26 @@ default ResponseEntity> getInventory() { * or Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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 generated 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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/store/order/{order_id}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId - -) { + default ResponseEntity getOrderById( + @Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -134,21 +148,25 @@ default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = " * @return successful operation (status code 200) * or Invalid Order (status code 400) */ - - @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid Order") + }) @RequestMapping( method = RequestMethod.POST, value = "/store/order", produces = { "application/xml", "application/json" } ) default ResponseEntity placeOrder( - -@ApiParam(value = "order placed for purchasing the pet", required = true ) @Valid @RequestBody Order body) { + @ApiParam(value = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/UserApi.java b/samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/UserApi.java index 8454fafb3209..86fcdae11023 100644 --- a/samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/UserApi.java @@ -38,18 +38,22 @@ default Optional getRequest() { * @param body Created user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Create user", + nickname = "createUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user" ) default ResponseEntity createUser( - -@ApiParam(value = "Created user object", required = true ) @Valid @RequestBody User body) { + @ApiParam(value = "Created user object", required = true) @Valid @RequestBody User body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -61,18 +65,22 @@ default ResponseEntity createUser( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithArrayInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithArray" ) default ResponseEntity createUsersWithArrayInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -84,18 +92,22 @@ default ResponseEntity createUsersWithArrayInput( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithListInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithList" ) default ResponseEntity createUsersWithListInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -109,20 +121,23 @@ default ResponseEntity createUsersWithListInput( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Delete user", + nickname = "deleteUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/user/{username}" ) - default ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username - -) { + default ResponseEntity deleteUser( + @ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -136,23 +151,26 @@ default ResponseEntity deleteUser(@ApiParam(value = "The name that needs t * or Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/{username}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username - -) { + default ResponseEntity getUserByName( + @ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -180,23 +198,26 @@ default ResponseEntity getUserByName(@ApiParam(value = "The name that need * @return successful operation (status code 200) * or Invalid username/password supplied (status code 400) */ - - @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid username/password supplied") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/login", produces = { "application/xml", "application/json" } ) - default ResponseEntity loginUser(@NotNull @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 - -) { + default ResponseEntity loginUser( + @NotNull @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 new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -207,16 +228,22 @@ default ResponseEntity loginUser(@NotNull @ApiParam(value = "The user na * * @return successful operation (status code 200) */ - - @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Logs out current logged in user session", + nickname = "logoutUser", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/logout" ) - default ResponseEntity logoutUser() { + default ResponseEntity logoutUser( + + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -231,22 +258,24 @@ default ResponseEntity logoutUser() { * @return Invalid user supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Updated user", + nickname = "updateUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid user supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.PUT, value = "/user/{username}" ) - default ResponseEntity 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 body) { + default ResponseEntity 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 body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } diff --git a/samples/server/petstore/spring-mvc/pom.xml b/samples/server/petstore/spring-mvc/pom.xml index 42dc38e182e7..64dbdca4b957 100644 --- a/samples/server/petstore/spring-mvc/pom.xml +++ b/samples/server/petstore/spring-mvc/pom.xml @@ -166,17 +166,18 @@ ${java.version} ${java.version} 1.3.5 - 2.3.3 + 2.3.3 9.2.15.v20160210 1.7.21 4.13.1 4.0.4 - 2.8.0 + 2.9.2 2.9.9 2.8.4 2.0.2 4.3.20.RELEASE 0.2.2 2.9.8 + 1.6.3 diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/AnotherFakeApi.java index e98182736edd..49d703d71daf 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -36,11 +36,16 @@ default Optional getRequest() { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "$another-fake?" }, + value = "To test special tags", + nickname = "call123testSpecialTags", + notes = "To test special tags and operation ID starting with number", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/another-fake/dummy", @@ -48,8 +53,8 @@ default Optional getRequest() { consumes = { "application/json" } ) default ResponseEntity call123testSpecialTags( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeApi.java index e17bed0498fc..6f95540156b3 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeApi.java @@ -45,19 +45,23 @@ default Optional getRequest() { * @param xmlItem XmlItem Body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "creates an XmlItem", nickname = "createXmlItem", notes = "this route creates an XmlItem", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "creates an XmlItem", + nickname = "createXmlItem", + notes = "this route creates an XmlItem" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/create_xml_item", consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } ) default ResponseEntity createXmlItem( - -@ApiParam(value = "XmlItem Body", required = true ) @Valid @RequestBody XmlItem xmlItem) { + @ApiParam(value = "XmlItem Body", required = true) @Valid @RequestBody XmlItem xmlItem + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -70,19 +74,24 @@ default ResponseEntity createXmlItem( * @param body Input boolean as post body (optional) * @return Output boolean (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterBooleanSerialize", + notes = "Test serialization of outer boolean types", + response = Boolean.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/boolean", produces = { "*/*" } ) default ResponseEntity fakeOuterBooleanSerialize( - -@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { + @ApiParam(value = "Input boolean as post body") @Valid @RequestBody(required = false) Boolean body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -95,19 +104,24 @@ default ResponseEntity fakeOuterBooleanSerialize( * @param body Input composite as post body (optional) * @return Output composite (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterCompositeSerialize", + notes = "Test serialization of object with outer number type", + response = OuterComposite.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/composite", produces = { "*/*" } ) default ResponseEntity fakeOuterCompositeSerialize( - -@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { + @ApiParam(value = "Input composite as post body") @Valid @RequestBody(required = false) OuterComposite body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) { @@ -129,19 +143,24 @@ default ResponseEntity fakeOuterCompositeSerialize( * @param body Input number as post body (optional) * @return Output number (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterNumberSerialize", + notes = "Test serialization of outer number types", + response = BigDecimal.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/number", produces = { "*/*" } ) default ResponseEntity fakeOuterNumberSerialize( - -@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { + @ApiParam(value = "Input number as post body") @Valid @RequestBody(required = false) BigDecimal body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -154,19 +173,24 @@ default ResponseEntity fakeOuterNumberSerialize( * @param body Input string as post body (optional) * @return Output string (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output string", response = String.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterStringSerialize", + notes = "Test serialization of outer string types", + response = String.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output string", response = String.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/string", produces = { "*/*" } ) default ResponseEntity fakeOuterStringSerialize( - -@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { + @ApiParam(value = "Input string as post body") @Valid @RequestBody(required = false) String body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -179,19 +203,23 @@ default ResponseEntity fakeOuterStringSerialize( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithFileSchema", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithFileSchema", + notes = "For this test, the body for this request much reference a schema named `File`." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-file-schema", consumes = { "application/json" } ) default ResponseEntity testBodyWithFileSchema( - -@ApiParam(value = "", required = true ) @Valid @RequestBody FileSchemaTestClass body) { + @ApiParam(value = "", required = true) @Valid @RequestBody FileSchemaTestClass body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -204,21 +232,24 @@ default ResponseEntity testBodyWithFileSchema( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithQueryParams", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithQueryParams", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-query-params", consumes = { "application/json" } ) - default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query - -, - -@ApiParam(value = "", required = true ) @Valid @RequestBody User body) { + default ResponseEntity testBodyWithQueryParams( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query, + @ApiParam(value = "", required = true) @Valid @RequestBody User body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -231,11 +262,16 @@ default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake" }, + value = "To test \"client\" model", + nickname = "testClientModel", + notes = "To test \"client\" model", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake", @@ -243,8 +279,8 @@ default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = consumes = { "application/json" } ) default ResponseEntity testClientModel( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -280,50 +316,40 @@ default ResponseEntity testClientModel( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", authorizations = { - - @Authorization(value = "http_basic_test") - }, tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + nickname = "testEndpointParameters", + notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + authorizations = { + @Authorization(value = "http_basic_test") + } + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testEndpointParameters( - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, - -@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, - -@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, - -@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, - -@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary, - -@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date, - -@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime, - -@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, - -@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback) { + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, + @ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, + @ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, + @ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, + @ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, + @ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, + @ApiParam(value = "None") @RequestPart(value = "binary", required = false) MultipartFile binary, + @ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, + @ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -344,35 +370,31 @@ default ResponseEntity testEndpointParameters( * @return Invalid request (status code 400) * or Not found (status code 404) */ - - @ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "To test enum parameters", + nickname = "testEnumParameters", + notes = "To test enum parameters" + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid request"), - - @ApiResponse(code = 404, message = "Not found") }) + @ApiResponse(code = 404, message = "Not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testEnumParameters( -@ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray -, -@ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString -,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray - -,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble - -, - -@ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, - -@ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString) { + @ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray, + @ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString, + @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, + @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble, + @ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, + @ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -390,28 +412,27 @@ default ResponseEntity testEnumParameters( * @param int64Group Integer in group parameters (optional) * @return Someting wrong (status code 400) */ - - @ApiOperation(value = "Fake endpoint to test group parameters (optional)", nickname = "testGroupParameters", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 400, message = "Someting wrong") }) + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint to test group parameters (optional)", + nickname = "testGroupParameters", + notes = "Fake endpoint to test group parameters (optional)" + ) + @ApiResponses({ + @ApiResponse(code = 400, message = "Someting wrong") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/fake" ) - default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup - -, -@ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup -,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group - -,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup - -, -@ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup -,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group - -) { + default ResponseEntity testGroupParameters( + @NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup, + @ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup, + @NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group, + @ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup, + @ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup, + @ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -423,19 +444,23 @@ default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Req * @param param request body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test inline additionalProperties", + nickname = "testInlineAdditionalProperties", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/inline-additionalProperties", consumes = { "application/json" } ) default ResponseEntity testInlineAdditionalProperties( - -@ApiParam(value = "request body", required = true ) @Valid @RequestBody Map param) { + @ApiParam(value = "request body", required = true) @Valid @RequestBody Map param + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -448,21 +473,24 @@ default ResponseEntity testInlineAdditionalProperties( * @param param2 field2 (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test json serialization of form data", + nickname = "testJsonFormData", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake/jsonFormData", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testJsonFormData( - -@ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, - -@ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2) { + @ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, + @ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2 + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -479,26 +507,26 @@ default ResponseEntity testJsonFormData( * @param context (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testQueryParameterCollectionFormat", + notes = "To test the collection format in query parameters" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/test-query-parameters" ) - default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context - -) { + default ResponseEntity testQueryParameterCollectionFormat( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -512,28 +540,33 @@ default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiPar * @param additionalMetadata Additional data to pass to server (optional) * @return successful operation (status code 200) */ - - @ApiOperation(value = "uploads an image (required)", nickname = "uploadFileWithRequiredFile", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @ApiOperation( + tags = { "pet" }, + value = "uploads an image (required)", + nickname = "uploadFileWithRequiredFile", + 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 = "/fake/{petId}/uploadImageWithRequiredFile", produces = { "application/json" }, consumes = { "multipart/form-data" } ) - default ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata) { + default ResponseEntity uploadFileWithRequiredFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "file to upload", required = true) @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeClassnameTestApi.java index efa3146991d6..8c44f6c0992f 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -36,14 +36,19 @@ default Optional getRequest() { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test class name in snake case", nickname = "testClassname", notes = "To test class name in snake case", response = Client.class, authorizations = { - - @Authorization(value = "api_key_query") - }, tags={ "fake_classname_tags 123#$%^", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake_classname_tags 123#$%^" }, + value = "To test class name in snake case", + nickname = "testClassname", + notes = "To test class name in snake case", + response = Client.class, + authorizations = { + @Authorization(value = "api_key_query") + } + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake_classname_test", @@ -51,8 +56,8 @@ default Optional getRequest() { consumes = { "application/json" } ) default ResponseEntity testClassname( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/PetApi.java index 30bbc2f6c18a..316f07e44847 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/PetApi.java @@ -38,25 +38,30 @@ default Optional getRequest() { * @return successful operation (status code 200) * or Invalid input (status code 405) */ - - @ApiOperation(value = "Add a new pet to the store", nickname = "addPet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Add a new pet to the store", + nickname = "addPet", + 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 = 200, message = "successful operation"), - - @ApiResponse(code = 405, message = "Invalid input") }) + @ApiResponse(code = 405, message = "Invalid input") + }) @RequestMapping( method = RequestMethod.POST, value = "/pet", consumes = { "application/json", "application/xml" } ) default ResponseEntity addPet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -70,26 +75,30 @@ default ResponseEntity addPet( * @return successful operation (status code 200) * or Invalid pet value (status code 400) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = 200, message = "successful operation"), - - @ApiResponse(code = 400, message = "Invalid pet value") }) + @ApiResponse(code = 400, message = "Invalid pet value") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/pet/{petId}" ) - default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId - -, -@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey -) { + default ResponseEntity deletePet( + @ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -103,25 +112,32 @@ default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", req * @return successful operation (status code 200) * or Invalid status value (status code 400) */ - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid status value") }) + @ApiResponse(code = 400, message = "Invalid status value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByStatus", produces = { "application/xml", "application/json" } ) - default ResponseEntity> 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 status - -) { + default ResponseEntity> 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 status + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -150,25 +166,32 @@ default ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "S * or Invalid tag value (status code 400) * @deprecated */ - - @ApiOperation(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 = "Set", authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "Set", + 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, responseContainer = "Set"), - - @ApiResponse(code = 400, message = "Invalid tag value") }) + @ApiResponse(code = 400, message = "Invalid tag value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByTags", produces = { "application/xml", "application/json" } ) - default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags - -) { + default ResponseEntity> findPetsByTags( + @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -197,26 +220,29 @@ default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags * or Invalid ID supplied (status code 400) * or Pet not found (status code 404) */ - - @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { - - @Authorization(value = "api_key") - }, tags={ "pet", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Pet not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/{petId}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId - -) { + default ResponseEntity getPetById( + @ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -245,29 +271,32 @@ default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", * or Pet not found (status code 404) * or Validation exception (status code 405) */ - - @ApiOperation(value = "Update an existing pet", nickname = "updatePet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Update an existing pet", + nickname = "updatePet", + 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 = 200, message = "successful operation"), - @ApiResponse(code = 400, message = "Invalid ID supplied"), - @ApiResponse(code = 404, message = "Pet not found"), - - @ApiResponse(code = 405, message = "Validation exception") }) + @ApiResponse(code = 405, message = "Validation exception") + }) @RequestMapping( method = RequestMethod.PUT, value = "/pet", consumes = { "application/json", "application/xml" } ) default ResponseEntity updatePet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -281,27 +310,31 @@ default ResponseEntity updatePet( * @param status Updated status of the pet (optional) * @return Invalid input (status code 405) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 405, message = "Invalid input") }) + @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" } ) - default ResponseEntity 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 @RequestPart(value = "name", required = false) String name, - -@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status) { + default ResponseEntity 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 @RequestPart(value = "name", required = false) String name, + @ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -315,28 +348,33 @@ default ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that * @param file file to upload (optional) * @return successful operation (status code 200) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @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" } ) - default ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { + default ResponseEntity uploadFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @ApiParam(value = "file to upload") @RequestPart(value = "file", required = false) MultipartFile file + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/StoreApi.java index 1d86f2d6fb0a..84abf7191820 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/StoreApi.java @@ -38,20 +38,23 @@ default Optional getRequest() { * @return Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(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", tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/store/order/{order_id}" ) - default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId - -) { + default ResponseEntity deleteOrder( + @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -63,20 +66,28 @@ default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that * * @return successful operation (status code 200) */ - - @ApiOperation(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") - }, tags={ "store", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) + @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" } ) - default ResponseEntity> getInventory() { + default ResponseEntity> getInventory( + + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -91,23 +102,26 @@ default ResponseEntity> getInventory() { * or Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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 generated 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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/store/order/{order_id}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId - -) { + default ResponseEntity getOrderById( + @Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -134,21 +148,25 @@ default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = " * @return successful operation (status code 200) * or Invalid Order (status code 400) */ - - @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid Order") + }) @RequestMapping( method = RequestMethod.POST, value = "/store/order", produces = { "application/xml", "application/json" } ) default ResponseEntity placeOrder( - -@ApiParam(value = "order placed for purchasing the pet", required = true ) @Valid @RequestBody Order body) { + @ApiParam(value = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/UserApi.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/UserApi.java index 8454fafb3209..86fcdae11023 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/UserApi.java @@ -38,18 +38,22 @@ default Optional getRequest() { * @param body Created user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Create user", + nickname = "createUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user" ) default ResponseEntity createUser( - -@ApiParam(value = "Created user object", required = true ) @Valid @RequestBody User body) { + @ApiParam(value = "Created user object", required = true) @Valid @RequestBody User body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -61,18 +65,22 @@ default ResponseEntity createUser( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithArrayInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithArray" ) default ResponseEntity createUsersWithArrayInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -84,18 +92,22 @@ default ResponseEntity createUsersWithArrayInput( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithListInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithList" ) default ResponseEntity createUsersWithListInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -109,20 +121,23 @@ default ResponseEntity createUsersWithListInput( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Delete user", + nickname = "deleteUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/user/{username}" ) - default ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username - -) { + default ResponseEntity deleteUser( + @ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -136,23 +151,26 @@ default ResponseEntity deleteUser(@ApiParam(value = "The name that needs t * or Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/{username}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username - -) { + default ResponseEntity getUserByName( + @ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -180,23 +198,26 @@ default ResponseEntity getUserByName(@ApiParam(value = "The name that need * @return successful operation (status code 200) * or Invalid username/password supplied (status code 400) */ - - @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid username/password supplied") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/login", produces = { "application/xml", "application/json" } ) - default ResponseEntity loginUser(@NotNull @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 - -) { + default ResponseEntity loginUser( + @NotNull @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 new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -207,16 +228,22 @@ default ResponseEntity loginUser(@NotNull @ApiParam(value = "The user na * * @return successful operation (status code 200) */ - - @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Logs out current logged in user session", + nickname = "logoutUser", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/logout" ) - default ResponseEntity logoutUser() { + default ResponseEntity logoutUser( + + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -231,22 +258,24 @@ default ResponseEntity logoutUser() { * @return Invalid user supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Updated user", + nickname = "updateUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid user supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.PUT, value = "/user/{username}" ) - default ResponseEntity 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 body) { + default ResponseEntity 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 body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/pom.xml b/samples/server/petstore/springboot-beanvalidation-no-nullable/pom.xml index 2c3a945d1916..f865833516e0 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/pom.xml +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/pom.xml @@ -9,12 +9,12 @@ 1.7 ${java.version} ${java.version} - 2.9.2 + 2.9.2 org.springframework.boot spring-boot-starter-parent - 1.5.12.RELEASE + 2.5.8 src/main/java @@ -22,13 +22,6 @@ org.springframework.boot spring-boot-maven-plugin - - - - repackage - - - @@ -45,26 +38,27 @@ io.springfox springfox-swagger2 - ${springfox-version} + ${springfox.version} + - io.springfox - springfox-swagger-ui - ${springfox-version} + com.google.code.findbugs + jsr305 + 3.0.2 - jakarta.xml.bind - jakarta.xml.bind-api + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml com.github.joschi.jackson jackson-datatype-threetenbp - 2.8.4 + 2.9.10 - + - jakarta.validation - jakarta.validation-api + org.springframework.boot + spring-boot-starter-validation com.fasterxml.jackson.core diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/AnotherFakeApi.java index 590ad40cffc7..f510b7947340 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -28,11 +28,16 @@ public interface AnotherFakeApi { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "$another-fake?" }, + value = "To test special tags", + nickname = "call123testSpecialTags", + notes = "To test special tags and operation ID starting with number", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/another-fake/dummy", @@ -40,7 +45,7 @@ public interface AnotherFakeApi { consumes = { "application/json" } ) ResponseEntity call123testSpecialTags( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body); + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ); } diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/AnotherFakeApiController.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/AnotherFakeApiController.java index ec32cf448bff..e8f022846bfc 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/AnotherFakeApiController.java +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/AnotherFakeApiController.java @@ -41,8 +41,8 @@ public AnotherFakeApiController(NativeWebRequest request) { * @see AnotherFakeApi#call123testSpecialTags */ public ResponseEntity call123testSpecialTags( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { String exampleString = "{ \"client\" : \"client\" }"; diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApi.java index 8d011f507a2e..17640717bccb 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApi.java @@ -37,19 +37,23 @@ public interface FakeApi { * @param xmlItem XmlItem Body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "creates an XmlItem", nickname = "createXmlItem", notes = "this route creates an XmlItem", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "creates an XmlItem", + nickname = "createXmlItem", + notes = "this route creates an XmlItem" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/create_xml_item", consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } ) ResponseEntity createXmlItem( - -@ApiParam(value = "XmlItem Body", required = true ) @Valid @RequestBody XmlItem xmlItem); + @ApiParam(value = "XmlItem Body", required = true) @Valid @RequestBody XmlItem xmlItem + ); /** @@ -59,19 +63,24 @@ ResponseEntity createXmlItem( * @param body Input boolean as post body (optional) * @return Output boolean (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterBooleanSerialize", + notes = "Test serialization of outer boolean types", + response = Boolean.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/boolean", produces = { "*/*" } ) ResponseEntity fakeOuterBooleanSerialize( - -@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body); + @ApiParam(value = "Input boolean as post body") @Valid @RequestBody(required = false) Boolean body + ); /** @@ -81,19 +90,24 @@ ResponseEntity fakeOuterBooleanSerialize( * @param body Input composite as post body (optional) * @return Output composite (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterCompositeSerialize", + notes = "Test serialization of object with outer number type", + response = OuterComposite.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/composite", produces = { "*/*" } ) ResponseEntity fakeOuterCompositeSerialize( - -@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body); + @ApiParam(value = "Input composite as post body") @Valid @RequestBody(required = false) OuterComposite body + ); /** @@ -103,19 +117,24 @@ ResponseEntity fakeOuterCompositeSerialize( * @param body Input number as post body (optional) * @return Output number (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterNumberSerialize", + notes = "Test serialization of outer number types", + response = BigDecimal.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/number", produces = { "*/*" } ) ResponseEntity fakeOuterNumberSerialize( - -@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body); + @ApiParam(value = "Input number as post body") @Valid @RequestBody(required = false) BigDecimal body + ); /** @@ -125,19 +144,24 @@ ResponseEntity fakeOuterNumberSerialize( * @param body Input string as post body (optional) * @return Output string (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output string", response = String.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterStringSerialize", + notes = "Test serialization of outer string types", + response = String.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output string", response = String.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/string", produces = { "*/*" } ) ResponseEntity fakeOuterStringSerialize( - -@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body); + @ApiParam(value = "Input string as post body") @Valid @RequestBody(required = false) String body + ); /** @@ -147,19 +171,23 @@ ResponseEntity fakeOuterStringSerialize( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithFileSchema", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithFileSchema", + notes = "For this test, the body for this request much reference a schema named `File`." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-file-schema", consumes = { "application/json" } ) ResponseEntity testBodyWithFileSchema( - -@ApiParam(value = "", required = true ) @Valid @RequestBody FileSchemaTestClass body); + @ApiParam(value = "", required = true) @Valid @RequestBody FileSchemaTestClass body + ); /** @@ -169,21 +197,24 @@ ResponseEntity testBodyWithFileSchema( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithQueryParams", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithQueryParams", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-query-params", consumes = { "application/json" } ) - ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query - -, - -@ApiParam(value = "", required = true ) @Valid @RequestBody User body); + ResponseEntity testBodyWithQueryParams( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query, + @ApiParam(value = "", required = true) @Valid @RequestBody User body + ); /** @@ -193,11 +224,16 @@ ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", requ * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake" }, + value = "To test \"client\" model", + nickname = "testClientModel", + notes = "To test \"client\" model", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake", @@ -205,8 +241,8 @@ ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", requ consumes = { "application/json" } ) ResponseEntity testClientModel( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body); + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ); /** @@ -230,50 +266,40 @@ ResponseEntity testClientModel( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", authorizations = { - - @Authorization(value = "http_basic_test") - }, tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + nickname = "testEndpointParameters", + notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + authorizations = { + @Authorization(value = "http_basic_test") + } + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) ResponseEntity testEndpointParameters( - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, - -@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, - -@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, - -@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, - -@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary, - -@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date, - -@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime, - -@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, - -@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback); + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, + @ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, + @ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, + @ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, + @ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, + @ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, + @ApiParam(value = "None") @RequestPart(value = "binary", required = false) MultipartFile binary, + @ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, + @ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback + ); /** @@ -291,35 +317,31 @@ ResponseEntity testEndpointParameters( * @return Invalid request (status code 400) * or Not found (status code 404) */ - - @ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "To test enum parameters", + nickname = "testEnumParameters", + notes = "To test enum parameters" + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid request"), - - @ApiResponse(code = 404, message = "Not found") }) + @ApiResponse(code = 404, message = "Not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) ResponseEntity testEnumParameters( -@ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray -, -@ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString -,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray - -,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble - -, - -@ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, - -@ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString); + @ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray, + @ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString, + @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, + @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble, + @ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, + @ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString + ); /** @@ -334,28 +356,27 @@ ResponseEntity testEnumParameters( * @param int64Group Integer in group parameters (optional) * @return Someting wrong (status code 400) */ - - @ApiOperation(value = "Fake endpoint to test group parameters (optional)", nickname = "testGroupParameters", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 400, message = "Someting wrong") }) + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint to test group parameters (optional)", + nickname = "testGroupParameters", + notes = "Fake endpoint to test group parameters (optional)" + ) + @ApiResponses({ + @ApiResponse(code = 400, message = "Someting wrong") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/fake" ) - ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup - -, -@ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup -,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group - -,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup - -, -@ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup -,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group - -); + ResponseEntity testGroupParameters( + @NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup, + @ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup, + @NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group, + @ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup, + @ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup, + @ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group + ); /** @@ -364,19 +385,23 @@ ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required St * @param param request body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test inline additionalProperties", + nickname = "testInlineAdditionalProperties", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/inline-additionalProperties", consumes = { "application/json" } ) ResponseEntity testInlineAdditionalProperties( - -@ApiParam(value = "request body", required = true ) @Valid @RequestBody Map param); + @ApiParam(value = "request body", required = true) @Valid @RequestBody Map param + ); /** @@ -386,21 +411,24 @@ ResponseEntity testInlineAdditionalProperties( * @param param2 field2 (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test json serialization of form data", + nickname = "testJsonFormData", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake/jsonFormData", consumes = { "application/x-www-form-urlencoded" } ) ResponseEntity testJsonFormData( - -@ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, - -@ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2); + @ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, + @ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2 + ); /** @@ -414,26 +442,26 @@ ResponseEntity testJsonFormData( * @param context (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testQueryParameterCollectionFormat", + notes = "To test the collection format in query parameters" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/test-query-parameters" ) - ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context - -); + ResponseEntity testQueryParameterCollectionFormat( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context + ); /** @@ -444,27 +472,32 @@ ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value * @param additionalMetadata Additional data to pass to server (optional) * @return successful operation (status code 200) */ - - @ApiOperation(value = "uploads an image (required)", nickname = "uploadFileWithRequiredFile", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @ApiOperation( + tags = { "pet" }, + value = "uploads an image (required)", + nickname = "uploadFileWithRequiredFile", + 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 = "/fake/{petId}/uploadImageWithRequiredFile", produces = { "application/json" }, consumes = { "multipart/form-data" } ) - ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata); + ResponseEntity uploadFileWithRequiredFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "file to upload", required = true) @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata + ); } diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApiController.java index 227840431fb3..76034668bf3c 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApiController.java @@ -50,8 +50,8 @@ public FakeApiController(NativeWebRequest request) { * @see FakeApi#createXmlItem */ public ResponseEntity createXmlItem( - -@ApiParam(value = "XmlItem Body", required = true ) @Valid @RequestBody XmlItem xmlItem) { + @ApiParam(value = "XmlItem Body", required = true) @Valid @RequestBody XmlItem xmlItem + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -65,8 +65,8 @@ public ResponseEntity createXmlItem( * @see FakeApi#fakeOuterBooleanSerialize */ public ResponseEntity fakeOuterBooleanSerialize( - -@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { + @ApiParam(value = "Input boolean as post body") @Valid @RequestBody(required = false) Boolean body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -80,8 +80,8 @@ public ResponseEntity fakeOuterBooleanSerialize( * @see FakeApi#fakeOuterCompositeSerialize */ public ResponseEntity fakeOuterCompositeSerialize( - -@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { + @ApiParam(value = "Input composite as post body") @Valid @RequestBody(required = false) OuterComposite body + ) { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) { String exampleString = "{ \"my_string\" : \"my_string\", \"my_number\" : 0.8008281904610115, \"my_boolean\" : true }"; @@ -102,8 +102,8 @@ public ResponseEntity fakeOuterCompositeSerialize( * @see FakeApi#fakeOuterNumberSerialize */ public ResponseEntity fakeOuterNumberSerialize( - -@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { + @ApiParam(value = "Input number as post body") @Valid @RequestBody(required = false) BigDecimal body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -117,8 +117,8 @@ public ResponseEntity fakeOuterNumberSerialize( * @see FakeApi#fakeOuterStringSerialize */ public ResponseEntity fakeOuterStringSerialize( - -@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { + @ApiParam(value = "Input string as post body") @Valid @RequestBody(required = false) String body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -132,8 +132,8 @@ public ResponseEntity fakeOuterStringSerialize( * @see FakeApi#testBodyWithFileSchema */ public ResponseEntity testBodyWithFileSchema( - -@ApiParam(value = "", required = true ) @Valid @RequestBody FileSchemaTestClass body) { + @ApiParam(value = "", required = true) @Valid @RequestBody FileSchemaTestClass body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -146,11 +146,10 @@ public ResponseEntity testBodyWithFileSchema( * @return Success (status code 200) * @see FakeApi#testBodyWithQueryParams */ - public ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query - -, - -@ApiParam(value = "", required = true ) @Valid @RequestBody User body) { + public ResponseEntity testBodyWithQueryParams( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query, + @ApiParam(value = "", required = true) @Valid @RequestBody User body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -164,8 +163,8 @@ public ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = " * @see FakeApi#testClientModel */ public ResponseEntity testClientModel( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { String exampleString = "{ \"client\" : \"client\" }"; @@ -200,34 +199,21 @@ public ResponseEntity testClientModel( * @see FakeApi#testEndpointParameters */ public ResponseEntity testEndpointParameters( - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, - -@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, - -@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, - -@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, - -@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary, - -@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date, - -@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime, - -@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, - -@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback) { + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, + @ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, + @ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, + @ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, + @ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, + @ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, + @ApiParam(value = "None") @RequestPart(value = "binary", required = false) MultipartFile binary, + @ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, + @ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -249,22 +235,15 @@ public ResponseEntity testEndpointParameters( * @see FakeApi#testEnumParameters */ public ResponseEntity testEnumParameters( -@ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray -, -@ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString -,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray - -,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble - -, - -@ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, - -@ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString) { + @ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray, + @ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString, + @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, + @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble, + @ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, + @ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -282,19 +261,14 @@ public ResponseEntity testEnumParameters( * @return Someting wrong (status code 400) * @see FakeApi#testGroupParameters */ - public ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup - -, -@ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup -,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group - -,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup - -, -@ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup -,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group - -) { + public ResponseEntity testGroupParameters( + @NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup, + @ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup, + @NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group, + @ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup, + @ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup, + @ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -307,8 +281,8 @@ public ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Requ * @see FakeApi#testInlineAdditionalProperties */ public ResponseEntity testInlineAdditionalProperties( - -@ApiParam(value = "request body", required = true ) @Valid @RequestBody Map param) { + @ApiParam(value = "request body", required = true) @Valid @RequestBody Map param + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -322,10 +296,9 @@ public ResponseEntity testInlineAdditionalProperties( * @see FakeApi#testJsonFormData */ public ResponseEntity testJsonFormData( - -@ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, - -@ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2) { + @ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, + @ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2 + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -342,17 +315,13 @@ public ResponseEntity testJsonFormData( * @return Success (status code 200) * @see FakeApi#testQueryParameterCollectionFormat */ - public ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context - -) { + public ResponseEntity testQueryParameterCollectionFormat( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -366,13 +335,11 @@ public ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiPara * @return successful operation (status code 200) * @see FakeApi#uploadFileWithRequiredFile */ - public ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata) { + public ResponseEntity uploadFileWithRequiredFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "file to upload", required = true) @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata + ) { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { String exampleString = "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\" }"; diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeClassnameTestApi.java index 5a1ad6bccd14..fc833265a31c 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -28,14 +28,19 @@ public interface FakeClassnameTestApi { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test class name in snake case", nickname = "testClassname", notes = "To test class name in snake case", response = Client.class, authorizations = { - - @Authorization(value = "api_key_query") - }, tags={ "fake_classname_tags 123#$%^", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake_classname_tags 123#$%^" }, + value = "To test class name in snake case", + nickname = "testClassname", + notes = "To test class name in snake case", + response = Client.class, + authorizations = { + @Authorization(value = "api_key_query") + } + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake_classname_test", @@ -43,7 +48,7 @@ public interface FakeClassnameTestApi { consumes = { "application/json" } ) ResponseEntity testClassname( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body); + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ); } diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java index 80e92bdeaf15..b705c60d83bb 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java @@ -41,8 +41,8 @@ public FakeClassnameTestApiController(NativeWebRequest request) { * @see FakeClassnameTestApi#testClassname */ public ResponseEntity testClassname( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { String exampleString = "{ \"client\" : \"client\" }"; diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/PetApi.java index fe8052a74dce..3a0cc9d976bc 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/PetApi.java @@ -30,25 +30,30 @@ public interface PetApi { * @return successful operation (status code 200) * or Invalid input (status code 405) */ - - @ApiOperation(value = "Add a new pet to the store", nickname = "addPet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Add a new pet to the store", + nickname = "addPet", + 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 = 200, message = "successful operation"), - - @ApiResponse(code = 405, message = "Invalid input") }) + @ApiResponse(code = 405, message = "Invalid input") + }) @RequestMapping( method = RequestMethod.POST, value = "/pet", consumes = { "application/json", "application/xml" } ) ResponseEntity addPet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body); + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ); /** @@ -59,26 +64,30 @@ ResponseEntity addPet( * @return successful operation (status code 200) * or Invalid pet value (status code 400) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = 200, message = "successful operation"), - - @ApiResponse(code = 400, message = "Invalid pet value") }) + @ApiResponse(code = 400, message = "Invalid pet value") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/pet/{petId}" ) - ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId - -, -@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey -); + ResponseEntity deletePet( + @ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey + ); /** @@ -89,25 +98,32 @@ ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", required = * @return successful operation (status code 200) * or Invalid status value (status code 400) */ - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid status value") }) + @ApiResponse(code = 400, message = "Invalid status value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByStatus", produces = { "application/xml", "application/json" } ) - ResponseEntity> 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 status - -); + ResponseEntity> 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 status + ); /** @@ -119,25 +135,32 @@ ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status va * or Invalid tag value (status code 400) * @deprecated */ - - @ApiOperation(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 = "Set", authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "Set", + 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, responseContainer = "Set"), - - @ApiResponse(code = 400, message = "Invalid tag value") }) + @ApiResponse(code = 400, message = "Invalid tag value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByTags", produces = { "application/xml", "application/json" } ) - ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags - -); + ResponseEntity> findPetsByTags( + @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags + ); /** @@ -149,26 +172,29 @@ ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filt * or Invalid ID supplied (status code 400) * or Pet not found (status code 404) */ - - @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { - - @Authorization(value = "api_key") - }, tags={ "pet", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Pet not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/{petId}", produces = { "application/xml", "application/json" } ) - ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId - -); + ResponseEntity getPetById( + @ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId + ); /** @@ -180,29 +206,32 @@ ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", required * or Pet not found (status code 404) * or Validation exception (status code 405) */ - - @ApiOperation(value = "Update an existing pet", nickname = "updatePet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Update an existing pet", + nickname = "updatePet", + 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 = 200, message = "successful operation"), - @ApiResponse(code = 400, message = "Invalid ID supplied"), - @ApiResponse(code = 404, message = "Pet not found"), - - @ApiResponse(code = 405, message = "Validation exception") }) + @ApiResponse(code = 405, message = "Validation exception") + }) @RequestMapping( method = RequestMethod.PUT, value = "/pet", consumes = { "application/json", "application/xml" } ) ResponseEntity updatePet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body); + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ); /** @@ -213,27 +242,31 @@ ResponseEntity updatePet( * @param status Updated status of the pet (optional) * @return Invalid input (status code 405) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 405, message = "Invalid input") }) + @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" } ) - ResponseEntity 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 @RequestPart(value = "name", required = false) String name, - -@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status); + ResponseEntity 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 @RequestPart(value = "name", required = false) String name, + @ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status + ); /** @@ -244,27 +277,32 @@ ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs t * @param file file to upload (optional) * @return successful operation (status code 200) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @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" } ) - ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file); + ResponseEntity uploadFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @ApiParam(value = "file to upload") @RequestPart(value = "file", required = false) MultipartFile file + ); } diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/PetApiController.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/PetApiController.java index 4905ee8920bd..f5625cea3f90 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/PetApiController.java +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/PetApiController.java @@ -43,8 +43,8 @@ public PetApiController(NativeWebRequest request) { * @see PetApi#addPet */ public ResponseEntity addPet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -58,11 +58,10 @@ public ResponseEntity addPet( * or Invalid pet value (status code 400) * @see PetApi#deletePet */ - public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId - -, -@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey -) { + public ResponseEntity deletePet( + @ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -76,9 +75,9 @@ public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", requ * or Invalid status value (status code 400) * @see PetApi#findPetsByStatus */ - public ResponseEntity> 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 status - -) { + public ResponseEntity> 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 status + ) { 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\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }"; @@ -105,9 +104,9 @@ public ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "St * @deprecated * @see PetApi#findPetsByTags */ - public ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags - -) { + public ResponseEntity> findPetsByTags( + @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags + ) { 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\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }"; @@ -134,9 +133,9 @@ public ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags * or Pet not found (status code 404) * @see PetApi#getPetById */ - public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId - -) { + public ResponseEntity getPetById( + @ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId + ) { 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\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }"; @@ -164,8 +163,8 @@ public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", r * @see PetApi#updatePet */ public ResponseEntity updatePet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -179,13 +178,11 @@ public ResponseEntity updatePet( * @return Invalid input (status code 405) * @see PetApi#updatePetWithForm */ - public ResponseEntity 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 @RequestPart(value = "name", required = false) String name, - -@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status) { + public ResponseEntity 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 @RequestPart(value = "name", required = false) String name, + @ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -199,13 +196,11 @@ public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that * @return successful operation (status code 200) * @see PetApi#uploadFile */ - public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { + public ResponseEntity uploadFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @ApiParam(value = "file to upload") @RequestPart(value = "file", required = false) MultipartFile file + ) { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { String exampleString = "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\" }"; diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/StoreApi.java index 36a33839249e..cbf52ad09926 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/StoreApi.java @@ -30,20 +30,23 @@ public interface StoreApi { * @return Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(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", tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/store/order/{order_id}" ) - ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId - -); + ResponseEntity deleteOrder( + @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId + ); /** @@ -52,20 +55,28 @@ ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs t * * @return successful operation (status code 200) */ - - @ApiOperation(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") - }, tags={ "store", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) + @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" } ) - ResponseEntity> getInventory(); + ResponseEntity> getInventory( + + ); /** @@ -77,23 +88,26 @@ ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs t * or Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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 generated 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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/store/order/{order_id}", produces = { "application/xml", "application/json" } ) - ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId - -); + ResponseEntity getOrderById( + @Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId + ); /** @@ -103,20 +117,24 @@ ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pe * @return successful operation (status code 200) * or Invalid Order (status code 400) */ - - @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid Order") + }) @RequestMapping( method = RequestMethod.POST, value = "/store/order", produces = { "application/xml", "application/json" } ) ResponseEntity placeOrder( - -@ApiParam(value = "order placed for purchasing the pet", required = true ) @Valid @RequestBody Order body); + @ApiParam(value = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order body + ); } diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/StoreApiController.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/StoreApiController.java index 392213709825..203faf80f73c 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/StoreApiController.java +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/StoreApiController.java @@ -42,9 +42,9 @@ public StoreApiController(NativeWebRequest request) { * or Order not found (status code 404) * @see StoreApi#deleteOrder */ - public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId - -) { + public ResponseEntity deleteOrder( + @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -56,7 +56,9 @@ public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that * @return successful operation (status code 200) * @see StoreApi#getInventory */ - public ResponseEntity> getInventory() { + public ResponseEntity> getInventory( + + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -71,9 +73,9 @@ public ResponseEntity> getInventory() { * or Order not found (status code 404) * @see StoreApi#getOrderById */ - public ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId - -) { + public ResponseEntity getOrderById( + @Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId + ) { 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\" }"; @@ -99,8 +101,8 @@ public ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "I * @see StoreApi#placeOrder */ public ResponseEntity placeOrder( - -@ApiParam(value = "order placed for purchasing the pet", required = true ) @Valid @RequestBody Order body) { + @ApiParam(value = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order body + ) { 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\" }"; diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/UserApi.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/UserApi.java index 8e8a5fbd7a6c..205840928976 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/UserApi.java @@ -30,18 +30,22 @@ public interface UserApi { * @param body Created user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Create user", + nickname = "createUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user" ) ResponseEntity createUser( - -@ApiParam(value = "Created user object", required = true ) @Valid @RequestBody User body); + @ApiParam(value = "Created user object", required = true) @Valid @RequestBody User body + ); /** @@ -50,18 +54,22 @@ ResponseEntity createUser( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithArrayInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithArray" ) ResponseEntity createUsersWithArrayInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body); + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ); /** @@ -70,18 +78,22 @@ ResponseEntity createUsersWithArrayInput( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithListInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithList" ) ResponseEntity createUsersWithListInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body); + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ); /** @@ -92,20 +104,23 @@ ResponseEntity createUsersWithListInput( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Delete user", + nickname = "deleteUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/user/{username}" ) - ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username - -); + ResponseEntity deleteUser( + @ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username + ); /** @@ -116,23 +131,26 @@ ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be del * or Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/{username}", produces = { "application/xml", "application/json" } ) - ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username - -); + ResponseEntity getUserByName( + @ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username + ); /** @@ -143,23 +161,26 @@ ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be * @return successful operation (status code 200) * or Invalid username/password supplied (status code 400) */ - - @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid username/password supplied") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/login", produces = { "application/xml", "application/json" } ) - ResponseEntity loginUser(@NotNull @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 - -); + ResponseEntity loginUser( + @NotNull @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 + ); /** @@ -167,16 +188,22 @@ ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for l * * @return successful operation (status code 200) */ - - @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Logs out current logged in user session", + nickname = "logoutUser", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/logout" ) - ResponseEntity logoutUser(); + ResponseEntity logoutUser( + + ); /** @@ -188,21 +215,23 @@ ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for l * @return Invalid user supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Updated user", + nickname = "updateUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid user supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.PUT, value = "/user/{username}" ) - ResponseEntity 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 body); + ResponseEntity 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 body + ); } diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/UserApiController.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/UserApiController.java index a5441a06b657..224d437db48a 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/UserApiController.java +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/UserApiController.java @@ -43,8 +43,8 @@ public UserApiController(NativeWebRequest request) { * @see UserApi#createUser */ public ResponseEntity createUser( - -@ApiParam(value = "Created user object", required = true ) @Valid @RequestBody User body) { + @ApiParam(value = "Created user object", required = true) @Valid @RequestBody User body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -57,8 +57,8 @@ public ResponseEntity createUser( * @see UserApi#createUsersWithArrayInput */ public ResponseEntity createUsersWithArrayInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -71,8 +71,8 @@ public ResponseEntity createUsersWithArrayInput( * @see UserApi#createUsersWithListInput */ public ResponseEntity createUsersWithListInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -86,9 +86,9 @@ public ResponseEntity createUsersWithListInput( * or User not found (status code 404) * @see UserApi#deleteUser */ - public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username - -) { + public ResponseEntity deleteUser( + @ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -102,9 +102,9 @@ public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to * or User not found (status code 404) * @see UserApi#getUserByName */ - public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username - -) { + public ResponseEntity getUserByName( + @ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username + ) { 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\" }"; @@ -130,11 +130,10 @@ public ResponseEntity getUserByName(@ApiParam(value = "The name that needs * or Invalid username/password supplied (status code 400) * @see UserApi#loginUser */ - public ResponseEntity loginUser(@NotNull @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 - -) { + public ResponseEntity loginUser( + @NotNull @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 new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -145,7 +144,9 @@ public ResponseEntity loginUser(@NotNull @ApiParam(value = "The user nam * @return successful operation (status code 200) * @see UserApi#logoutUser */ - public ResponseEntity logoutUser() { + public ResponseEntity logoutUser( + + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -160,11 +161,10 @@ public ResponseEntity logoutUser() { * or User not found (status code 404) * @see UserApi#updateUser */ - public ResponseEntity 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 body) { + public ResponseEntity 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 body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } diff --git a/samples/server/petstore/springboot-beanvalidation/pom.xml b/samples/server/petstore/springboot-beanvalidation/pom.xml index ae8ec70bc1c7..a9da2ec020fd 100644 --- a/samples/server/petstore/springboot-beanvalidation/pom.xml +++ b/samples/server/petstore/springboot-beanvalidation/pom.xml @@ -9,12 +9,12 @@ 1.8 ${java.version} ${java.version} - 2.9.2 + 2.9.2 org.springframework.boot spring-boot-starter-parent - 2.3.3.RELEASE + 2.5.8 src/main/java @@ -22,13 +22,6 @@ org.springframework.boot spring-boot-maven-plugin - - - - repackage - - - @@ -45,16 +38,17 @@ io.springfox springfox-swagger2 - ${springfox-version} + ${springfox.version} + - io.springfox - springfox-swagger-ui - ${springfox-version} + com.google.code.findbugs + jsr305 + 3.0.2 - jakarta.xml.bind - jakarta.xml.bind-api + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml com.fasterxml.jackson.datatype @@ -63,12 +57,12 @@ org.openapitools jackson-databind-nullable - 0.2.1 + 0.2.2 - + - jakarta.validation - jakarta.validation-api + org.springframework.boot + spring-boot-starter-validation com.fasterxml.jackson.core diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/AnotherFakeApi.java index e98182736edd..49d703d71daf 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -36,11 +36,16 @@ default Optional getRequest() { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "$another-fake?" }, + value = "To test special tags", + nickname = "call123testSpecialTags", + notes = "To test special tags and operation ID starting with number", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/another-fake/dummy", @@ -48,8 +53,8 @@ default Optional getRequest() { consumes = { "application/json" } ) default ResponseEntity call123testSpecialTags( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApi.java index e17bed0498fc..6f95540156b3 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApi.java @@ -45,19 +45,23 @@ default Optional getRequest() { * @param xmlItem XmlItem Body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "creates an XmlItem", nickname = "createXmlItem", notes = "this route creates an XmlItem", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "creates an XmlItem", + nickname = "createXmlItem", + notes = "this route creates an XmlItem" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/create_xml_item", consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } ) default ResponseEntity createXmlItem( - -@ApiParam(value = "XmlItem Body", required = true ) @Valid @RequestBody XmlItem xmlItem) { + @ApiParam(value = "XmlItem Body", required = true) @Valid @RequestBody XmlItem xmlItem + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -70,19 +74,24 @@ default ResponseEntity createXmlItem( * @param body Input boolean as post body (optional) * @return Output boolean (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterBooleanSerialize", + notes = "Test serialization of outer boolean types", + response = Boolean.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/boolean", produces = { "*/*" } ) default ResponseEntity fakeOuterBooleanSerialize( - -@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { + @ApiParam(value = "Input boolean as post body") @Valid @RequestBody(required = false) Boolean body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -95,19 +104,24 @@ default ResponseEntity fakeOuterBooleanSerialize( * @param body Input composite as post body (optional) * @return Output composite (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterCompositeSerialize", + notes = "Test serialization of object with outer number type", + response = OuterComposite.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/composite", produces = { "*/*" } ) default ResponseEntity fakeOuterCompositeSerialize( - -@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { + @ApiParam(value = "Input composite as post body") @Valid @RequestBody(required = false) OuterComposite body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) { @@ -129,19 +143,24 @@ default ResponseEntity fakeOuterCompositeSerialize( * @param body Input number as post body (optional) * @return Output number (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterNumberSerialize", + notes = "Test serialization of outer number types", + response = BigDecimal.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/number", produces = { "*/*" } ) default ResponseEntity fakeOuterNumberSerialize( - -@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { + @ApiParam(value = "Input number as post body") @Valid @RequestBody(required = false) BigDecimal body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -154,19 +173,24 @@ default ResponseEntity fakeOuterNumberSerialize( * @param body Input string as post body (optional) * @return Output string (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output string", response = String.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterStringSerialize", + notes = "Test serialization of outer string types", + response = String.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output string", response = String.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/string", produces = { "*/*" } ) default ResponseEntity fakeOuterStringSerialize( - -@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { + @ApiParam(value = "Input string as post body") @Valid @RequestBody(required = false) String body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -179,19 +203,23 @@ default ResponseEntity fakeOuterStringSerialize( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithFileSchema", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithFileSchema", + notes = "For this test, the body for this request much reference a schema named `File`." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-file-schema", consumes = { "application/json" } ) default ResponseEntity testBodyWithFileSchema( - -@ApiParam(value = "", required = true ) @Valid @RequestBody FileSchemaTestClass body) { + @ApiParam(value = "", required = true) @Valid @RequestBody FileSchemaTestClass body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -204,21 +232,24 @@ default ResponseEntity testBodyWithFileSchema( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithQueryParams", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithQueryParams", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-query-params", consumes = { "application/json" } ) - default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query - -, - -@ApiParam(value = "", required = true ) @Valid @RequestBody User body) { + default ResponseEntity testBodyWithQueryParams( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query, + @ApiParam(value = "", required = true) @Valid @RequestBody User body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -231,11 +262,16 @@ default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake" }, + value = "To test \"client\" model", + nickname = "testClientModel", + notes = "To test \"client\" model", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake", @@ -243,8 +279,8 @@ default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = consumes = { "application/json" } ) default ResponseEntity testClientModel( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -280,50 +316,40 @@ default ResponseEntity testClientModel( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", authorizations = { - - @Authorization(value = "http_basic_test") - }, tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + nickname = "testEndpointParameters", + notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + authorizations = { + @Authorization(value = "http_basic_test") + } + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testEndpointParameters( - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, - -@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, - -@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, - -@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, - -@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary, - -@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date, - -@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime, - -@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, - -@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback) { + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, + @ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, + @ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, + @ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, + @ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, + @ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, + @ApiParam(value = "None") @RequestPart(value = "binary", required = false) MultipartFile binary, + @ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, + @ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -344,35 +370,31 @@ default ResponseEntity testEndpointParameters( * @return Invalid request (status code 400) * or Not found (status code 404) */ - - @ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "To test enum parameters", + nickname = "testEnumParameters", + notes = "To test enum parameters" + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid request"), - - @ApiResponse(code = 404, message = "Not found") }) + @ApiResponse(code = 404, message = "Not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testEnumParameters( -@ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray -, -@ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString -,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray - -,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble - -, - -@ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, - -@ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString) { + @ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray, + @ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString, + @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, + @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble, + @ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, + @ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -390,28 +412,27 @@ default ResponseEntity testEnumParameters( * @param int64Group Integer in group parameters (optional) * @return Someting wrong (status code 400) */ - - @ApiOperation(value = "Fake endpoint to test group parameters (optional)", nickname = "testGroupParameters", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 400, message = "Someting wrong") }) + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint to test group parameters (optional)", + nickname = "testGroupParameters", + notes = "Fake endpoint to test group parameters (optional)" + ) + @ApiResponses({ + @ApiResponse(code = 400, message = "Someting wrong") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/fake" ) - default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup - -, -@ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup -,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group - -,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup - -, -@ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup -,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group - -) { + default ResponseEntity testGroupParameters( + @NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup, + @ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup, + @NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group, + @ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup, + @ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup, + @ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -423,19 +444,23 @@ default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Req * @param param request body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test inline additionalProperties", + nickname = "testInlineAdditionalProperties", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/inline-additionalProperties", consumes = { "application/json" } ) default ResponseEntity testInlineAdditionalProperties( - -@ApiParam(value = "request body", required = true ) @Valid @RequestBody Map param) { + @ApiParam(value = "request body", required = true) @Valid @RequestBody Map param + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -448,21 +473,24 @@ default ResponseEntity testInlineAdditionalProperties( * @param param2 field2 (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test json serialization of form data", + nickname = "testJsonFormData", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake/jsonFormData", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testJsonFormData( - -@ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, - -@ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2) { + @ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, + @ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2 + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -479,26 +507,26 @@ default ResponseEntity testJsonFormData( * @param context (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testQueryParameterCollectionFormat", + notes = "To test the collection format in query parameters" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/test-query-parameters" ) - default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context - -) { + default ResponseEntity testQueryParameterCollectionFormat( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -512,28 +540,33 @@ default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiPar * @param additionalMetadata Additional data to pass to server (optional) * @return successful operation (status code 200) */ - - @ApiOperation(value = "uploads an image (required)", nickname = "uploadFileWithRequiredFile", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @ApiOperation( + tags = { "pet" }, + value = "uploads an image (required)", + nickname = "uploadFileWithRequiredFile", + 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 = "/fake/{petId}/uploadImageWithRequiredFile", produces = { "application/json" }, consumes = { "multipart/form-data" } ) - default ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata) { + default ResponseEntity uploadFileWithRequiredFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "file to upload", required = true) @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeClassnameTestApi.java index efa3146991d6..8c44f6c0992f 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -36,14 +36,19 @@ default Optional getRequest() { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test class name in snake case", nickname = "testClassname", notes = "To test class name in snake case", response = Client.class, authorizations = { - - @Authorization(value = "api_key_query") - }, tags={ "fake_classname_tags 123#$%^", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake_classname_tags 123#$%^" }, + value = "To test class name in snake case", + nickname = "testClassname", + notes = "To test class name in snake case", + response = Client.class, + authorizations = { + @Authorization(value = "api_key_query") + } + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake_classname_test", @@ -51,8 +56,8 @@ default Optional getRequest() { consumes = { "application/json" } ) default ResponseEntity testClassname( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/PetApi.java index 30bbc2f6c18a..316f07e44847 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/PetApi.java @@ -38,25 +38,30 @@ default Optional getRequest() { * @return successful operation (status code 200) * or Invalid input (status code 405) */ - - @ApiOperation(value = "Add a new pet to the store", nickname = "addPet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Add a new pet to the store", + nickname = "addPet", + 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 = 200, message = "successful operation"), - - @ApiResponse(code = 405, message = "Invalid input") }) + @ApiResponse(code = 405, message = "Invalid input") + }) @RequestMapping( method = RequestMethod.POST, value = "/pet", consumes = { "application/json", "application/xml" } ) default ResponseEntity addPet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -70,26 +75,30 @@ default ResponseEntity addPet( * @return successful operation (status code 200) * or Invalid pet value (status code 400) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = 200, message = "successful operation"), - - @ApiResponse(code = 400, message = "Invalid pet value") }) + @ApiResponse(code = 400, message = "Invalid pet value") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/pet/{petId}" ) - default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId - -, -@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey -) { + default ResponseEntity deletePet( + @ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -103,25 +112,32 @@ default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", req * @return successful operation (status code 200) * or Invalid status value (status code 400) */ - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid status value") }) + @ApiResponse(code = 400, message = "Invalid status value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByStatus", produces = { "application/xml", "application/json" } ) - default ResponseEntity> 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 status - -) { + default ResponseEntity> 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 status + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -150,25 +166,32 @@ default ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "S * or Invalid tag value (status code 400) * @deprecated */ - - @ApiOperation(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 = "Set", authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "Set", + 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, responseContainer = "Set"), - - @ApiResponse(code = 400, message = "Invalid tag value") }) + @ApiResponse(code = 400, message = "Invalid tag value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByTags", produces = { "application/xml", "application/json" } ) - default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags - -) { + default ResponseEntity> findPetsByTags( + @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -197,26 +220,29 @@ default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags * or Invalid ID supplied (status code 400) * or Pet not found (status code 404) */ - - @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { - - @Authorization(value = "api_key") - }, tags={ "pet", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Pet not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/{petId}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId - -) { + default ResponseEntity getPetById( + @ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -245,29 +271,32 @@ default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", * or Pet not found (status code 404) * or Validation exception (status code 405) */ - - @ApiOperation(value = "Update an existing pet", nickname = "updatePet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Update an existing pet", + nickname = "updatePet", + 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 = 200, message = "successful operation"), - @ApiResponse(code = 400, message = "Invalid ID supplied"), - @ApiResponse(code = 404, message = "Pet not found"), - - @ApiResponse(code = 405, message = "Validation exception") }) + @ApiResponse(code = 405, message = "Validation exception") + }) @RequestMapping( method = RequestMethod.PUT, value = "/pet", consumes = { "application/json", "application/xml" } ) default ResponseEntity updatePet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -281,27 +310,31 @@ default ResponseEntity updatePet( * @param status Updated status of the pet (optional) * @return Invalid input (status code 405) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 405, message = "Invalid input") }) + @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" } ) - default ResponseEntity 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 @RequestPart(value = "name", required = false) String name, - -@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status) { + default ResponseEntity 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 @RequestPart(value = "name", required = false) String name, + @ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -315,28 +348,33 @@ default ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that * @param file file to upload (optional) * @return successful operation (status code 200) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @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" } ) - default ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { + default ResponseEntity uploadFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @ApiParam(value = "file to upload") @RequestPart(value = "file", required = false) MultipartFile file + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/StoreApi.java index 1d86f2d6fb0a..84abf7191820 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/StoreApi.java @@ -38,20 +38,23 @@ default Optional getRequest() { * @return Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(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", tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/store/order/{order_id}" ) - default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId - -) { + default ResponseEntity deleteOrder( + @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -63,20 +66,28 @@ default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that * * @return successful operation (status code 200) */ - - @ApiOperation(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") - }, tags={ "store", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) + @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" } ) - default ResponseEntity> getInventory() { + default ResponseEntity> getInventory( + + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -91,23 +102,26 @@ default ResponseEntity> getInventory() { * or Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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 generated 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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/store/order/{order_id}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId - -) { + default ResponseEntity getOrderById( + @Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -134,21 +148,25 @@ default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = " * @return successful operation (status code 200) * or Invalid Order (status code 400) */ - - @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid Order") + }) @RequestMapping( method = RequestMethod.POST, value = "/store/order", produces = { "application/xml", "application/json" } ) default ResponseEntity placeOrder( - -@ApiParam(value = "order placed for purchasing the pet", required = true ) @Valid @RequestBody Order body) { + @ApiParam(value = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/UserApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/UserApi.java index 8454fafb3209..86fcdae11023 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/UserApi.java @@ -38,18 +38,22 @@ default Optional getRequest() { * @param body Created user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Create user", + nickname = "createUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user" ) default ResponseEntity createUser( - -@ApiParam(value = "Created user object", required = true ) @Valid @RequestBody User body) { + @ApiParam(value = "Created user object", required = true) @Valid @RequestBody User body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -61,18 +65,22 @@ default ResponseEntity createUser( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithArrayInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithArray" ) default ResponseEntity createUsersWithArrayInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -84,18 +92,22 @@ default ResponseEntity createUsersWithArrayInput( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithListInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithList" ) default ResponseEntity createUsersWithListInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -109,20 +121,23 @@ default ResponseEntity createUsersWithListInput( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Delete user", + nickname = "deleteUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/user/{username}" ) - default ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username - -) { + default ResponseEntity deleteUser( + @ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -136,23 +151,26 @@ default ResponseEntity deleteUser(@ApiParam(value = "The name that needs t * or Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/{username}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username - -) { + default ResponseEntity getUserByName( + @ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -180,23 +198,26 @@ default ResponseEntity getUserByName(@ApiParam(value = "The name that need * @return successful operation (status code 200) * or Invalid username/password supplied (status code 400) */ - - @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid username/password supplied") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/login", produces = { "application/xml", "application/json" } ) - default ResponseEntity loginUser(@NotNull @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 - -) { + default ResponseEntity loginUser( + @NotNull @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 new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -207,16 +228,22 @@ default ResponseEntity loginUser(@NotNull @ApiParam(value = "The user na * * @return successful operation (status code 200) */ - - @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Logs out current logged in user session", + nickname = "logoutUser", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/logout" ) - default ResponseEntity logoutUser() { + default ResponseEntity logoutUser( + + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -231,22 +258,24 @@ default ResponseEntity logoutUser() { * @return Invalid user supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Updated user", + nickname = "updateUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid user supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.PUT, value = "/user/{username}" ) - default ResponseEntity 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 body) { + default ResponseEntity 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 body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } diff --git a/samples/server/petstore/springboot-delegate-j8/pom.xml b/samples/server/petstore/springboot-delegate-j8/pom.xml index 14ed219b34cc..4dc9b6f1c579 100644 --- a/samples/server/petstore/springboot-delegate-j8/pom.xml +++ b/samples/server/petstore/springboot-delegate-j8/pom.xml @@ -9,12 +9,12 @@ 1.8 ${java.version} ${java.version} - 2.9.2 + 2.9.2 org.springframework.boot spring-boot-starter-parent - 2.3.3.RELEASE + 2.5.8 src/main/java @@ -22,13 +22,6 @@ org.springframework.boot spring-boot-maven-plugin - - - - repackage - - - @@ -45,16 +38,17 @@ io.springfox springfox-swagger2 - ${springfox-version} + ${springfox.version} + - io.springfox - springfox-swagger-ui - ${springfox-version} + com.google.code.findbugs + jsr305 + 3.0.2 - jakarta.xml.bind - jakarta.xml.bind-api + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml com.fasterxml.jackson.datatype @@ -63,12 +57,12 @@ org.openapitools jackson-databind-nullable - 0.2.1 + 0.2.2 - + - jakarta.validation - jakarta.validation-api + org.springframework.boot + spring-boot-starter-validation com.fasterxml.jackson.core diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/AnotherFakeApi.java index 28b39d958853..c257e392d8ae 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -32,11 +32,16 @@ default AnotherFakeApiDelegate getDelegate() { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "$another-fake?" }, + value = "To test special tags", + nickname = "call123testSpecialTags", + notes = "To test special tags and operation ID starting with number", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/another-fake/dummy", @@ -44,8 +49,8 @@ default AnotherFakeApiDelegate getDelegate() { consumes = { "application/json" } ) default ResponseEntity call123testSpecialTags( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { return getDelegate().call123testSpecialTags(body); } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java index 7e6ac74b30f4..a86542ddf223 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java @@ -1,7 +1,6 @@ package org.openapitools.api; import org.openapitools.model.Client; -import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApi.java index b9541eb94dd8..0ea288f97280 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApi.java @@ -41,19 +41,23 @@ default FakeApiDelegate getDelegate() { * @param xmlItem XmlItem Body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "creates an XmlItem", nickname = "createXmlItem", notes = "this route creates an XmlItem", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "creates an XmlItem", + nickname = "createXmlItem", + notes = "this route creates an XmlItem" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/create_xml_item", consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } ) default ResponseEntity createXmlItem( - -@ApiParam(value = "XmlItem Body", required = true ) @Valid @RequestBody XmlItem xmlItem) { + @ApiParam(value = "XmlItem Body", required = true) @Valid @RequestBody XmlItem xmlItem + ) { return getDelegate().createXmlItem(xmlItem); } @@ -65,19 +69,24 @@ default ResponseEntity createXmlItem( * @param body Input boolean as post body (optional) * @return Output boolean (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterBooleanSerialize", + notes = "Test serialization of outer boolean types", + response = Boolean.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/boolean", produces = { "*/*" } ) default ResponseEntity fakeOuterBooleanSerialize( - -@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { + @ApiParam(value = "Input boolean as post body") @Valid @RequestBody(required = false) Boolean body + ) { return getDelegate().fakeOuterBooleanSerialize(body); } @@ -89,19 +98,24 @@ default ResponseEntity fakeOuterBooleanSerialize( * @param body Input composite as post body (optional) * @return Output composite (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterCompositeSerialize", + notes = "Test serialization of object with outer number type", + response = OuterComposite.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/composite", produces = { "*/*" } ) default ResponseEntity fakeOuterCompositeSerialize( - -@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { + @ApiParam(value = "Input composite as post body") @Valid @RequestBody(required = false) OuterComposite body + ) { return getDelegate().fakeOuterCompositeSerialize(body); } @@ -113,19 +127,24 @@ default ResponseEntity fakeOuterCompositeSerialize( * @param body Input number as post body (optional) * @return Output number (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterNumberSerialize", + notes = "Test serialization of outer number types", + response = BigDecimal.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/number", produces = { "*/*" } ) default ResponseEntity fakeOuterNumberSerialize( - -@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { + @ApiParam(value = "Input number as post body") @Valid @RequestBody(required = false) BigDecimal body + ) { return getDelegate().fakeOuterNumberSerialize(body); } @@ -137,19 +156,24 @@ default ResponseEntity fakeOuterNumberSerialize( * @param body Input string as post body (optional) * @return Output string (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output string", response = String.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterStringSerialize", + notes = "Test serialization of outer string types", + response = String.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output string", response = String.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/string", produces = { "*/*" } ) default ResponseEntity fakeOuterStringSerialize( - -@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { + @ApiParam(value = "Input string as post body") @Valid @RequestBody(required = false) String body + ) { return getDelegate().fakeOuterStringSerialize(body); } @@ -161,19 +185,23 @@ default ResponseEntity fakeOuterStringSerialize( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithFileSchema", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithFileSchema", + notes = "For this test, the body for this request much reference a schema named `File`." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-file-schema", consumes = { "application/json" } ) default ResponseEntity testBodyWithFileSchema( - -@ApiParam(value = "", required = true ) @Valid @RequestBody FileSchemaTestClass body) { + @ApiParam(value = "", required = true) @Valid @RequestBody FileSchemaTestClass body + ) { return getDelegate().testBodyWithFileSchema(body); } @@ -185,21 +213,24 @@ default ResponseEntity testBodyWithFileSchema( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithQueryParams", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithQueryParams", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-query-params", consumes = { "application/json" } ) - default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query - -, - -@ApiParam(value = "", required = true ) @Valid @RequestBody User body) { + default ResponseEntity testBodyWithQueryParams( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query, + @ApiParam(value = "", required = true) @Valid @RequestBody User body + ) { return getDelegate().testBodyWithQueryParams(query, body); } @@ -211,11 +242,16 @@ default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake" }, + value = "To test \"client\" model", + nickname = "testClientModel", + notes = "To test \"client\" model", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake", @@ -223,8 +259,8 @@ default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = consumes = { "application/json" } ) default ResponseEntity testClientModel( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { return getDelegate().testClientModel(body); } @@ -250,50 +286,40 @@ default ResponseEntity testClientModel( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", authorizations = { - - @Authorization(value = "http_basic_test") - }, tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + nickname = "testEndpointParameters", + notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + authorizations = { + @Authorization(value = "http_basic_test") + } + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testEndpointParameters( - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, - -@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, - -@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, - -@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, - -@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary, - -@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date, - -@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime, - -@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, - -@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback) { + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, + @ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, + @ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, + @ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, + @ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, + @ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, + @ApiParam(value = "None") @RequestPart(value = "binary", required = false) MultipartFile binary, + @ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, + @ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback + ) { return getDelegate().testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback); } @@ -313,35 +339,31 @@ default ResponseEntity testEndpointParameters( * @return Invalid request (status code 400) * or Not found (status code 404) */ - - @ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "To test enum parameters", + nickname = "testEnumParameters", + notes = "To test enum parameters" + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid request"), - - @ApiResponse(code = 404, message = "Not found") }) + @ApiResponse(code = 404, message = "Not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testEnumParameters( -@ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray -, -@ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString -,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray - -,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble - -, - -@ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, - -@ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString) { + @ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray, + @ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString, + @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, + @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble, + @ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, + @ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString + ) { return getDelegate().testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString); } @@ -358,28 +380,27 @@ default ResponseEntity testEnumParameters( * @param int64Group Integer in group parameters (optional) * @return Someting wrong (status code 400) */ - - @ApiOperation(value = "Fake endpoint to test group parameters (optional)", nickname = "testGroupParameters", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 400, message = "Someting wrong") }) + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint to test group parameters (optional)", + nickname = "testGroupParameters", + notes = "Fake endpoint to test group parameters (optional)" + ) + @ApiResponses({ + @ApiResponse(code = 400, message = "Someting wrong") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/fake" ) - default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup - -, -@ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup -,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group - -,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup - -, -@ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup -,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group - -) { + default ResponseEntity testGroupParameters( + @NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup, + @ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup, + @NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group, + @ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup, + @ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup, + @ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group + ) { return getDelegate().testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group); } @@ -390,19 +411,23 @@ default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Req * @param param request body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test inline additionalProperties", + nickname = "testInlineAdditionalProperties", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/inline-additionalProperties", consumes = { "application/json" } ) default ResponseEntity testInlineAdditionalProperties( - -@ApiParam(value = "request body", required = true ) @Valid @RequestBody Map param) { + @ApiParam(value = "request body", required = true) @Valid @RequestBody Map param + ) { return getDelegate().testInlineAdditionalProperties(param); } @@ -414,21 +439,24 @@ default ResponseEntity testInlineAdditionalProperties( * @param param2 field2 (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test json serialization of form data", + nickname = "testJsonFormData", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake/jsonFormData", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testJsonFormData( - -@ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, - -@ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2) { + @ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, + @ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2 + ) { return getDelegate().testJsonFormData(param, param2); } @@ -444,26 +472,26 @@ default ResponseEntity testJsonFormData( * @param context (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testQueryParameterCollectionFormat", + notes = "To test the collection format in query parameters" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/test-query-parameters" ) - default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context - -) { + default ResponseEntity testQueryParameterCollectionFormat( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context + ) { return getDelegate().testQueryParameterCollectionFormat(pipe, ioutil, http, url, context); } @@ -476,28 +504,33 @@ default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiPar * @param additionalMetadata Additional data to pass to server (optional) * @return successful operation (status code 200) */ - - @ApiOperation(value = "uploads an image (required)", nickname = "uploadFileWithRequiredFile", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @ApiOperation( + tags = { "pet" }, + value = "uploads an image (required)", + nickname = "uploadFileWithRequiredFile", + 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 = "/fake/{petId}/uploadImageWithRequiredFile", produces = { "application/json" }, consumes = { "multipart/form-data" } ) - default ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata) { + default ResponseEntity uploadFileWithRequiredFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "file to upload", required = true) @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata + ) { return getDelegate().uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata); } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApiDelegate.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApiDelegate.java index 32a862f8273f..d3a949e65d81 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApiDelegate.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApiDelegate.java @@ -10,7 +10,6 @@ import org.openapitools.model.OuterComposite; import org.openapitools.model.User; import org.openapitools.model.XmlItem; -import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeClassnameTestApi.java index 46441906cac5..757dc764c97e 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -32,14 +32,19 @@ default FakeClassnameTestApiDelegate getDelegate() { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test class name in snake case", nickname = "testClassname", notes = "To test class name in snake case", response = Client.class, authorizations = { - - @Authorization(value = "api_key_query") - }, tags={ "fake_classname_tags 123#$%^", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake_classname_tags 123#$%^" }, + value = "To test class name in snake case", + nickname = "testClassname", + notes = "To test class name in snake case", + response = Client.class, + authorizations = { + @Authorization(value = "api_key_query") + } + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake_classname_test", @@ -47,8 +52,8 @@ default FakeClassnameTestApiDelegate getDelegate() { consumes = { "application/json" } ) default ResponseEntity testClassname( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { return getDelegate().testClassname(body); } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java index c71fe13d195a..ed5a6bfc09a0 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java @@ -1,7 +1,6 @@ package org.openapitools.api; import org.openapitools.model.Client; -import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/PetApi.java index 59e1abe91c92..0575088eb083 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/PetApi.java @@ -34,25 +34,30 @@ default PetApiDelegate getDelegate() { * @return successful operation (status code 200) * or Invalid input (status code 405) */ - - @ApiOperation(value = "Add a new pet to the store", nickname = "addPet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Add a new pet to the store", + nickname = "addPet", + 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 = 200, message = "successful operation"), - - @ApiResponse(code = 405, message = "Invalid input") }) + @ApiResponse(code = 405, message = "Invalid input") + }) @RequestMapping( method = RequestMethod.POST, value = "/pet", consumes = { "application/json", "application/xml" } ) default ResponseEntity addPet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return getDelegate().addPet(body); } @@ -65,26 +70,30 @@ default ResponseEntity addPet( * @return successful operation (status code 200) * or Invalid pet value (status code 400) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = 200, message = "successful operation"), - - @ApiResponse(code = 400, message = "Invalid pet value") }) + @ApiResponse(code = 400, message = "Invalid pet value") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/pet/{petId}" ) - default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId - -, -@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey -) { + default ResponseEntity 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); } @@ -97,25 +106,32 @@ default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", req * @return successful operation (status code 200) * or Invalid status value (status code 400) */ - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid status value") }) + @ApiResponse(code = 400, message = "Invalid status value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByStatus", produces = { "application/xml", "application/json" } ) - default ResponseEntity> 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 status - -) { + default ResponseEntity> 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 status + ) { return getDelegate().findPetsByStatus(status); } @@ -129,25 +145,32 @@ default ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "S * or Invalid tag value (status code 400) * @deprecated */ - - @ApiOperation(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 = "Set", authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "Set", + 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, responseContainer = "Set"), - - @ApiResponse(code = 400, message = "Invalid tag value") }) + @ApiResponse(code = 400, message = "Invalid tag value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByTags", produces = { "application/xml", "application/json" } ) - default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags - -) { + default ResponseEntity> findPetsByTags( + @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags + ) { return getDelegate().findPetsByTags(tags); } @@ -161,26 +184,29 @@ default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags * or Invalid ID supplied (status code 400) * or Pet not found (status code 404) */ - - @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { - - @Authorization(value = "api_key") - }, tags={ "pet", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Pet not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/{petId}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId - -) { + default ResponseEntity getPetById( + @ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId + ) { return getDelegate().getPetById(petId); } @@ -194,29 +220,32 @@ default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", * or Pet not found (status code 404) * or Validation exception (status code 405) */ - - @ApiOperation(value = "Update an existing pet", nickname = "updatePet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Update an existing pet", + nickname = "updatePet", + 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 = 200, message = "successful operation"), - @ApiResponse(code = 400, message = "Invalid ID supplied"), - @ApiResponse(code = 404, message = "Pet not found"), - - @ApiResponse(code = 405, message = "Validation exception") }) + @ApiResponse(code = 405, message = "Validation exception") + }) @RequestMapping( method = RequestMethod.PUT, value = "/pet", consumes = { "application/json", "application/xml" } ) default ResponseEntity updatePet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return getDelegate().updatePet(body); } @@ -229,27 +258,31 @@ default ResponseEntity updatePet( * @param status Updated status of the pet (optional) * @return Invalid input (status code 405) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 405, message = "Invalid input") }) + @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" } ) - default ResponseEntity 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 @RequestPart(value = "name", required = false) String name, - -@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status) { + default ResponseEntity 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 @RequestPart(value = "name", required = false) String name, + @ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status + ) { return getDelegate().updatePetWithForm(petId, name, status); } @@ -262,28 +295,33 @@ default ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that * @param file file to upload (optional) * @return successful operation (status code 200) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @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" } ) - default ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { + default ResponseEntity uploadFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @ApiParam(value = "file to upload") @RequestPart(value = "file", required = false) MultipartFile file + ) { return getDelegate().uploadFile(petId, additionalMetadata, file); } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/PetApiDelegate.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/PetApiDelegate.java index b34d322223b6..e3adc7d4bca7 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/PetApiDelegate.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/PetApiDelegate.java @@ -3,7 +3,6 @@ import org.openapitools.model.ModelApiResponse; import org.openapitools.model.Pet; import java.util.Set; -import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/StoreApi.java index 6a5d569d8578..ee6e1fb2d912 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/StoreApi.java @@ -34,20 +34,23 @@ default StoreApiDelegate getDelegate() { * @return Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(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", tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/store/order/{order_id}" ) - default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId - -) { + default ResponseEntity deleteOrder( + @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId + ) { return getDelegate().deleteOrder(orderId); } @@ -58,20 +61,28 @@ default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that * * @return successful operation (status code 200) */ - - @ApiOperation(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") - }, tags={ "store", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) + @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" } ) - default ResponseEntity> getInventory() { + default ResponseEntity> getInventory( + + ) { return getDelegate().getInventory(); } @@ -85,23 +96,26 @@ default ResponseEntity> getInventory() { * or Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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 generated 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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/store/order/{order_id}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId - -) { + default ResponseEntity getOrderById( + @Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId + ) { return getDelegate().getOrderById(orderId); } @@ -113,21 +127,25 @@ default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = " * @return successful operation (status code 200) * or Invalid Order (status code 400) */ - - @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid Order") + }) @RequestMapping( method = RequestMethod.POST, value = "/store/order", produces = { "application/xml", "application/json" } ) default ResponseEntity placeOrder( - -@ApiParam(value = "order placed for purchasing the pet", required = true ) @Valid @RequestBody Order body) { + @ApiParam(value = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order body + ) { return getDelegate().placeOrder(body); } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/StoreApiDelegate.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/StoreApiDelegate.java index 5091e7e1f2cc..dfe4bb314961 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/StoreApiDelegate.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/StoreApiDelegate.java @@ -2,7 +2,6 @@ import java.util.Map; import org.openapitools.model.Order; -import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/UserApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/UserApi.java index e1e7144f3834..264279df93a7 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/UserApi.java @@ -34,18 +34,22 @@ default UserApiDelegate getDelegate() { * @param body Created user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Create user", + nickname = "createUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user" ) default ResponseEntity createUser( - -@ApiParam(value = "Created user object", required = true ) @Valid @RequestBody User body) { + @ApiParam(value = "Created user object", required = true) @Valid @RequestBody User body + ) { return getDelegate().createUser(body); } @@ -56,18 +60,22 @@ default ResponseEntity createUser( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithArrayInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithArray" ) default ResponseEntity createUsersWithArrayInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return getDelegate().createUsersWithArrayInput(body); } @@ -78,18 +86,22 @@ default ResponseEntity createUsersWithArrayInput( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithListInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithList" ) default ResponseEntity createUsersWithListInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return getDelegate().createUsersWithListInput(body); } @@ -102,20 +114,23 @@ default ResponseEntity createUsersWithListInput( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Delete user", + nickname = "deleteUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/user/{username}" ) - default ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username - -) { + default ResponseEntity deleteUser( + @ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username + ) { return getDelegate().deleteUser(username); } @@ -128,23 +143,26 @@ default ResponseEntity deleteUser(@ApiParam(value = "The name that needs t * or Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/{username}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username - -) { + default ResponseEntity getUserByName( + @ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username + ) { return getDelegate().getUserByName(username); } @@ -157,23 +175,26 @@ default ResponseEntity getUserByName(@ApiParam(value = "The name that need * @return successful operation (status code 200) * or Invalid username/password supplied (status code 400) */ - - @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid username/password supplied") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/login", produces = { "application/xml", "application/json" } ) - default ResponseEntity loginUser(@NotNull @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 - -) { + default ResponseEntity loginUser( + @NotNull @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); } @@ -183,16 +204,22 @@ default ResponseEntity loginUser(@NotNull @ApiParam(value = "The user na * * @return successful operation (status code 200) */ - - @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Logs out current logged in user session", + nickname = "logoutUser", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/logout" ) - default ResponseEntity logoutUser() { + default ResponseEntity logoutUser( + + ) { return getDelegate().logoutUser(); } @@ -206,22 +233,24 @@ default ResponseEntity logoutUser() { * @return Invalid user supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Updated user", + nickname = "updateUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid user supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.PUT, value = "/user/{username}" ) - default ResponseEntity 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 body) { + default ResponseEntity 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 body + ) { return getDelegate().updateUser(username, body); } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/UserApiDelegate.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/UserApiDelegate.java index b63fa7a1c28a..2efbd71c9dc9 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/UserApiDelegate.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/UserApiDelegate.java @@ -3,7 +3,6 @@ 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.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-delegate/pom.xml b/samples/server/petstore/springboot-delegate/pom.xml index f5fe58e2f14b..4e8cd4a140ea 100644 --- a/samples/server/petstore/springboot-delegate/pom.xml +++ b/samples/server/petstore/springboot-delegate/pom.xml @@ -9,12 +9,12 @@ 1.8 ${java.version} ${java.version} - 2.9.2 + 2.9.2 org.springframework.boot spring-boot-starter-parent - 2.3.3.RELEASE + 2.5.8 src/main/java @@ -22,13 +22,6 @@ org.springframework.boot spring-boot-maven-plugin - - - - repackage - - - @@ -45,16 +38,17 @@ io.springfox springfox-swagger2 - ${springfox-version} + ${springfox.version} + - io.springfox - springfox-swagger-ui - ${springfox-version} + com.google.code.findbugs + jsr305 + 3.0.2 - jakarta.xml.bind - jakarta.xml.bind-api + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml com.fasterxml.jackson.datatype @@ -63,12 +57,12 @@ org.openapitools jackson-databind-nullable - 0.2.1 + 0.2.2 - + - jakarta.validation - jakarta.validation-api + org.springframework.boot + spring-boot-starter-validation com.fasterxml.jackson.core diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApi.java index 28b39d958853..c257e392d8ae 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -32,11 +32,16 @@ default AnotherFakeApiDelegate getDelegate() { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "$another-fake?" }, + value = "To test special tags", + nickname = "call123testSpecialTags", + notes = "To test special tags and operation ID starting with number", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/another-fake/dummy", @@ -44,8 +49,8 @@ default AnotherFakeApiDelegate getDelegate() { consumes = { "application/json" } ) default ResponseEntity call123testSpecialTags( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { return getDelegate().call123testSpecialTags(body); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java index 7e6ac74b30f4..a86542ddf223 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java @@ -1,7 +1,6 @@ package org.openapitools.api; import org.openapitools.model.Client; -import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java index b9541eb94dd8..0ea288f97280 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java @@ -41,19 +41,23 @@ default FakeApiDelegate getDelegate() { * @param xmlItem XmlItem Body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "creates an XmlItem", nickname = "createXmlItem", notes = "this route creates an XmlItem", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "creates an XmlItem", + nickname = "createXmlItem", + notes = "this route creates an XmlItem" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/create_xml_item", consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } ) default ResponseEntity createXmlItem( - -@ApiParam(value = "XmlItem Body", required = true ) @Valid @RequestBody XmlItem xmlItem) { + @ApiParam(value = "XmlItem Body", required = true) @Valid @RequestBody XmlItem xmlItem + ) { return getDelegate().createXmlItem(xmlItem); } @@ -65,19 +69,24 @@ default ResponseEntity createXmlItem( * @param body Input boolean as post body (optional) * @return Output boolean (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterBooleanSerialize", + notes = "Test serialization of outer boolean types", + response = Boolean.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/boolean", produces = { "*/*" } ) default ResponseEntity fakeOuterBooleanSerialize( - -@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { + @ApiParam(value = "Input boolean as post body") @Valid @RequestBody(required = false) Boolean body + ) { return getDelegate().fakeOuterBooleanSerialize(body); } @@ -89,19 +98,24 @@ default ResponseEntity fakeOuterBooleanSerialize( * @param body Input composite as post body (optional) * @return Output composite (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterCompositeSerialize", + notes = "Test serialization of object with outer number type", + response = OuterComposite.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/composite", produces = { "*/*" } ) default ResponseEntity fakeOuterCompositeSerialize( - -@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { + @ApiParam(value = "Input composite as post body") @Valid @RequestBody(required = false) OuterComposite body + ) { return getDelegate().fakeOuterCompositeSerialize(body); } @@ -113,19 +127,24 @@ default ResponseEntity fakeOuterCompositeSerialize( * @param body Input number as post body (optional) * @return Output number (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterNumberSerialize", + notes = "Test serialization of outer number types", + response = BigDecimal.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/number", produces = { "*/*" } ) default ResponseEntity fakeOuterNumberSerialize( - -@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { + @ApiParam(value = "Input number as post body") @Valid @RequestBody(required = false) BigDecimal body + ) { return getDelegate().fakeOuterNumberSerialize(body); } @@ -137,19 +156,24 @@ default ResponseEntity fakeOuterNumberSerialize( * @param body Input string as post body (optional) * @return Output string (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output string", response = String.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterStringSerialize", + notes = "Test serialization of outer string types", + response = String.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output string", response = String.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/string", produces = { "*/*" } ) default ResponseEntity fakeOuterStringSerialize( - -@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { + @ApiParam(value = "Input string as post body") @Valid @RequestBody(required = false) String body + ) { return getDelegate().fakeOuterStringSerialize(body); } @@ -161,19 +185,23 @@ default ResponseEntity fakeOuterStringSerialize( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithFileSchema", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithFileSchema", + notes = "For this test, the body for this request much reference a schema named `File`." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-file-schema", consumes = { "application/json" } ) default ResponseEntity testBodyWithFileSchema( - -@ApiParam(value = "", required = true ) @Valid @RequestBody FileSchemaTestClass body) { + @ApiParam(value = "", required = true) @Valid @RequestBody FileSchemaTestClass body + ) { return getDelegate().testBodyWithFileSchema(body); } @@ -185,21 +213,24 @@ default ResponseEntity testBodyWithFileSchema( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithQueryParams", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithQueryParams", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-query-params", consumes = { "application/json" } ) - default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query - -, - -@ApiParam(value = "", required = true ) @Valid @RequestBody User body) { + default ResponseEntity testBodyWithQueryParams( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query, + @ApiParam(value = "", required = true) @Valid @RequestBody User body + ) { return getDelegate().testBodyWithQueryParams(query, body); } @@ -211,11 +242,16 @@ default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake" }, + value = "To test \"client\" model", + nickname = "testClientModel", + notes = "To test \"client\" model", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake", @@ -223,8 +259,8 @@ default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = consumes = { "application/json" } ) default ResponseEntity testClientModel( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { return getDelegate().testClientModel(body); } @@ -250,50 +286,40 @@ default ResponseEntity testClientModel( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", authorizations = { - - @Authorization(value = "http_basic_test") - }, tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + nickname = "testEndpointParameters", + notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + authorizations = { + @Authorization(value = "http_basic_test") + } + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testEndpointParameters( - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, - -@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, - -@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, - -@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, - -@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary, - -@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date, - -@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime, - -@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, - -@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback) { + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, + @ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, + @ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, + @ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, + @ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, + @ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, + @ApiParam(value = "None") @RequestPart(value = "binary", required = false) MultipartFile binary, + @ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, + @ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback + ) { return getDelegate().testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback); } @@ -313,35 +339,31 @@ default ResponseEntity testEndpointParameters( * @return Invalid request (status code 400) * or Not found (status code 404) */ - - @ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "To test enum parameters", + nickname = "testEnumParameters", + notes = "To test enum parameters" + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid request"), - - @ApiResponse(code = 404, message = "Not found") }) + @ApiResponse(code = 404, message = "Not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testEnumParameters( -@ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray -, -@ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString -,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray - -,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble - -, - -@ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, - -@ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString) { + @ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray, + @ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString, + @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, + @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble, + @ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, + @ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString + ) { return getDelegate().testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString); } @@ -358,28 +380,27 @@ default ResponseEntity testEnumParameters( * @param int64Group Integer in group parameters (optional) * @return Someting wrong (status code 400) */ - - @ApiOperation(value = "Fake endpoint to test group parameters (optional)", nickname = "testGroupParameters", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 400, message = "Someting wrong") }) + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint to test group parameters (optional)", + nickname = "testGroupParameters", + notes = "Fake endpoint to test group parameters (optional)" + ) + @ApiResponses({ + @ApiResponse(code = 400, message = "Someting wrong") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/fake" ) - default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup - -, -@ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup -,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group - -,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup - -, -@ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup -,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group - -) { + default ResponseEntity testGroupParameters( + @NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup, + @ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup, + @NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group, + @ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup, + @ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup, + @ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group + ) { return getDelegate().testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group); } @@ -390,19 +411,23 @@ default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Req * @param param request body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test inline additionalProperties", + nickname = "testInlineAdditionalProperties", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/inline-additionalProperties", consumes = { "application/json" } ) default ResponseEntity testInlineAdditionalProperties( - -@ApiParam(value = "request body", required = true ) @Valid @RequestBody Map param) { + @ApiParam(value = "request body", required = true) @Valid @RequestBody Map param + ) { return getDelegate().testInlineAdditionalProperties(param); } @@ -414,21 +439,24 @@ default ResponseEntity testInlineAdditionalProperties( * @param param2 field2 (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test json serialization of form data", + nickname = "testJsonFormData", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake/jsonFormData", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testJsonFormData( - -@ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, - -@ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2) { + @ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, + @ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2 + ) { return getDelegate().testJsonFormData(param, param2); } @@ -444,26 +472,26 @@ default ResponseEntity testJsonFormData( * @param context (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testQueryParameterCollectionFormat", + notes = "To test the collection format in query parameters" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/test-query-parameters" ) - default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context - -) { + default ResponseEntity testQueryParameterCollectionFormat( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context + ) { return getDelegate().testQueryParameterCollectionFormat(pipe, ioutil, http, url, context); } @@ -476,28 +504,33 @@ default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiPar * @param additionalMetadata Additional data to pass to server (optional) * @return successful operation (status code 200) */ - - @ApiOperation(value = "uploads an image (required)", nickname = "uploadFileWithRequiredFile", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @ApiOperation( + tags = { "pet" }, + value = "uploads an image (required)", + nickname = "uploadFileWithRequiredFile", + 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 = "/fake/{petId}/uploadImageWithRequiredFile", produces = { "application/json" }, consumes = { "multipart/form-data" } ) - default ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata) { + default ResponseEntity uploadFileWithRequiredFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "file to upload", required = true) @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata + ) { return getDelegate().uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiDelegate.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiDelegate.java index 32a862f8273f..d3a949e65d81 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiDelegate.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiDelegate.java @@ -10,7 +10,6 @@ import org.openapitools.model.OuterComposite; import org.openapitools.model.User; import org.openapitools.model.XmlItem; -import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeClassnameTestApi.java index 46441906cac5..757dc764c97e 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -32,14 +32,19 @@ default FakeClassnameTestApiDelegate getDelegate() { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test class name in snake case", nickname = "testClassname", notes = "To test class name in snake case", response = Client.class, authorizations = { - - @Authorization(value = "api_key_query") - }, tags={ "fake_classname_tags 123#$%^", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake_classname_tags 123#$%^" }, + value = "To test class name in snake case", + nickname = "testClassname", + notes = "To test class name in snake case", + response = Client.class, + authorizations = { + @Authorization(value = "api_key_query") + } + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake_classname_test", @@ -47,8 +52,8 @@ default FakeClassnameTestApiDelegate getDelegate() { consumes = { "application/json" } ) default ResponseEntity testClassname( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { return getDelegate().testClassname(body); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java index c71fe13d195a..ed5a6bfc09a0 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java @@ -1,7 +1,6 @@ package org.openapitools.api; import org.openapitools.model.Client; -import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApi.java index 59e1abe91c92..0575088eb083 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApi.java @@ -34,25 +34,30 @@ default PetApiDelegate getDelegate() { * @return successful operation (status code 200) * or Invalid input (status code 405) */ - - @ApiOperation(value = "Add a new pet to the store", nickname = "addPet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Add a new pet to the store", + nickname = "addPet", + 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 = 200, message = "successful operation"), - - @ApiResponse(code = 405, message = "Invalid input") }) + @ApiResponse(code = 405, message = "Invalid input") + }) @RequestMapping( method = RequestMethod.POST, value = "/pet", consumes = { "application/json", "application/xml" } ) default ResponseEntity addPet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return getDelegate().addPet(body); } @@ -65,26 +70,30 @@ default ResponseEntity addPet( * @return successful operation (status code 200) * or Invalid pet value (status code 400) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = 200, message = "successful operation"), - - @ApiResponse(code = 400, message = "Invalid pet value") }) + @ApiResponse(code = 400, message = "Invalid pet value") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/pet/{petId}" ) - default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId - -, -@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey -) { + default ResponseEntity 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); } @@ -97,25 +106,32 @@ default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", req * @return successful operation (status code 200) * or Invalid status value (status code 400) */ - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid status value") }) + @ApiResponse(code = 400, message = "Invalid status value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByStatus", produces = { "application/xml", "application/json" } ) - default ResponseEntity> 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 status - -) { + default ResponseEntity> 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 status + ) { return getDelegate().findPetsByStatus(status); } @@ -129,25 +145,32 @@ default ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "S * or Invalid tag value (status code 400) * @deprecated */ - - @ApiOperation(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 = "Set", authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "Set", + 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, responseContainer = "Set"), - - @ApiResponse(code = 400, message = "Invalid tag value") }) + @ApiResponse(code = 400, message = "Invalid tag value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByTags", produces = { "application/xml", "application/json" } ) - default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags - -) { + default ResponseEntity> findPetsByTags( + @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags + ) { return getDelegate().findPetsByTags(tags); } @@ -161,26 +184,29 @@ default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags * or Invalid ID supplied (status code 400) * or Pet not found (status code 404) */ - - @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { - - @Authorization(value = "api_key") - }, tags={ "pet", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Pet not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/{petId}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId - -) { + default ResponseEntity getPetById( + @ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId + ) { return getDelegate().getPetById(petId); } @@ -194,29 +220,32 @@ default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", * or Pet not found (status code 404) * or Validation exception (status code 405) */ - - @ApiOperation(value = "Update an existing pet", nickname = "updatePet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Update an existing pet", + nickname = "updatePet", + 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 = 200, message = "successful operation"), - @ApiResponse(code = 400, message = "Invalid ID supplied"), - @ApiResponse(code = 404, message = "Pet not found"), - - @ApiResponse(code = 405, message = "Validation exception") }) + @ApiResponse(code = 405, message = "Validation exception") + }) @RequestMapping( method = RequestMethod.PUT, value = "/pet", consumes = { "application/json", "application/xml" } ) default ResponseEntity updatePet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return getDelegate().updatePet(body); } @@ -229,27 +258,31 @@ default ResponseEntity updatePet( * @param status Updated status of the pet (optional) * @return Invalid input (status code 405) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 405, message = "Invalid input") }) + @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" } ) - default ResponseEntity 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 @RequestPart(value = "name", required = false) String name, - -@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status) { + default ResponseEntity 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 @RequestPart(value = "name", required = false) String name, + @ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status + ) { return getDelegate().updatePetWithForm(petId, name, status); } @@ -262,28 +295,33 @@ default ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that * @param file file to upload (optional) * @return successful operation (status code 200) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @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" } ) - default ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { + default ResponseEntity uploadFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @ApiParam(value = "file to upload") @RequestPart(value = "file", required = false) MultipartFile file + ) { return getDelegate().uploadFile(petId, additionalMetadata, file); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApiDelegate.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApiDelegate.java index b34d322223b6..e3adc7d4bca7 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApiDelegate.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApiDelegate.java @@ -3,7 +3,6 @@ import org.openapitools.model.ModelApiResponse; import org.openapitools.model.Pet; import java.util.Set; -import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/StoreApi.java index 6a5d569d8578..ee6e1fb2d912 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/StoreApi.java @@ -34,20 +34,23 @@ default StoreApiDelegate getDelegate() { * @return Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(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", tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/store/order/{order_id}" ) - default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId - -) { + default ResponseEntity deleteOrder( + @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId + ) { return getDelegate().deleteOrder(orderId); } @@ -58,20 +61,28 @@ default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that * * @return successful operation (status code 200) */ - - @ApiOperation(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") - }, tags={ "store", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) + @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" } ) - default ResponseEntity> getInventory() { + default ResponseEntity> getInventory( + + ) { return getDelegate().getInventory(); } @@ -85,23 +96,26 @@ default ResponseEntity> getInventory() { * or Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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 generated 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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/store/order/{order_id}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId - -) { + default ResponseEntity getOrderById( + @Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId + ) { return getDelegate().getOrderById(orderId); } @@ -113,21 +127,25 @@ default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = " * @return successful operation (status code 200) * or Invalid Order (status code 400) */ - - @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid Order") + }) @RequestMapping( method = RequestMethod.POST, value = "/store/order", produces = { "application/xml", "application/json" } ) default ResponseEntity placeOrder( - -@ApiParam(value = "order placed for purchasing the pet", required = true ) @Valid @RequestBody Order body) { + @ApiParam(value = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order body + ) { return getDelegate().placeOrder(body); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/StoreApiDelegate.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/StoreApiDelegate.java index 5091e7e1f2cc..dfe4bb314961 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/StoreApiDelegate.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/StoreApiDelegate.java @@ -2,7 +2,6 @@ import java.util.Map; import org.openapitools.model.Order; -import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/UserApi.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/UserApi.java index e1e7144f3834..264279df93a7 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/UserApi.java @@ -34,18 +34,22 @@ default UserApiDelegate getDelegate() { * @param body Created user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Create user", + nickname = "createUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user" ) default ResponseEntity createUser( - -@ApiParam(value = "Created user object", required = true ) @Valid @RequestBody User body) { + @ApiParam(value = "Created user object", required = true) @Valid @RequestBody User body + ) { return getDelegate().createUser(body); } @@ -56,18 +60,22 @@ default ResponseEntity createUser( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithArrayInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithArray" ) default ResponseEntity createUsersWithArrayInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return getDelegate().createUsersWithArrayInput(body); } @@ -78,18 +86,22 @@ default ResponseEntity createUsersWithArrayInput( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithListInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithList" ) default ResponseEntity createUsersWithListInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return getDelegate().createUsersWithListInput(body); } @@ -102,20 +114,23 @@ default ResponseEntity createUsersWithListInput( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Delete user", + nickname = "deleteUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/user/{username}" ) - default ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username - -) { + default ResponseEntity deleteUser( + @ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username + ) { return getDelegate().deleteUser(username); } @@ -128,23 +143,26 @@ default ResponseEntity deleteUser(@ApiParam(value = "The name that needs t * or Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/{username}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username - -) { + default ResponseEntity getUserByName( + @ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username + ) { return getDelegate().getUserByName(username); } @@ -157,23 +175,26 @@ default ResponseEntity getUserByName(@ApiParam(value = "The name that need * @return successful operation (status code 200) * or Invalid username/password supplied (status code 400) */ - - @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid username/password supplied") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/login", produces = { "application/xml", "application/json" } ) - default ResponseEntity loginUser(@NotNull @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 - -) { + default ResponseEntity loginUser( + @NotNull @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); } @@ -183,16 +204,22 @@ default ResponseEntity loginUser(@NotNull @ApiParam(value = "The user na * * @return successful operation (status code 200) */ - - @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Logs out current logged in user session", + nickname = "logoutUser", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/logout" ) - default ResponseEntity logoutUser() { + default ResponseEntity logoutUser( + + ) { return getDelegate().logoutUser(); } @@ -206,22 +233,24 @@ default ResponseEntity logoutUser() { * @return Invalid user supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Updated user", + nickname = "updateUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid user supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.PUT, value = "/user/{username}" ) - default ResponseEntity 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 body) { + default ResponseEntity 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 body + ) { return getDelegate().updateUser(username, body); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/UserApiDelegate.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/UserApiDelegate.java index b63fa7a1c28a..2efbd71c9dc9 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/UserApiDelegate.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/UserApiDelegate.java @@ -3,7 +3,6 @@ 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.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-implicitHeaders/pom.xml b/samples/server/petstore/springboot-implicitHeaders/pom.xml index 149407e2aad3..28802bac5446 100644 --- a/samples/server/petstore/springboot-implicitHeaders/pom.xml +++ b/samples/server/petstore/springboot-implicitHeaders/pom.xml @@ -9,12 +9,12 @@ 1.8 ${java.version} ${java.version} - 2.9.2 + 2.9.2 org.springframework.boot spring-boot-starter-parent - 2.3.3.RELEASE + 2.5.8 src/main/java @@ -22,13 +22,6 @@ org.springframework.boot spring-boot-maven-plugin - - - - repackage - - - @@ -45,16 +38,17 @@ io.springfox springfox-swagger2 - ${springfox-version} + ${springfox.version} + - io.springfox - springfox-swagger-ui - ${springfox-version} + com.google.code.findbugs + jsr305 + 3.0.2 - jakarta.xml.bind - jakarta.xml.bind-api + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml com.fasterxml.jackson.datatype @@ -63,12 +57,12 @@ org.openapitools jackson-databind-nullable - 0.2.1 + 0.2.2 - + - jakarta.validation - jakarta.validation-api + org.springframework.boot + spring-boot-starter-validation com.fasterxml.jackson.core diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/AnotherFakeApi.java index b09380d864a8..43a7fb5fc8ce 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -36,11 +36,16 @@ default Optional getRequest() { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "$another-fake?" }, + value = "To test special tags", + nickname = "call123testSpecialTags", + notes = "To test special tags and operation ID starting with number", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @ApiImplicitParams({ }) @RequestMapping( @@ -50,8 +55,8 @@ default Optional getRequest() { consumes = { "application/json" } ) default ResponseEntity call123testSpecialTags( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java index 05723fcc3ab5..ba1cf6d208fe 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java @@ -45,11 +45,15 @@ default Optional getRequest() { * @param xmlItem XmlItem Body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "creates an XmlItem", nickname = "createXmlItem", notes = "this route creates an XmlItem", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "creates an XmlItem", + nickname = "createXmlItem", + notes = "this route creates an XmlItem" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @ApiImplicitParams({ }) @RequestMapping( @@ -58,8 +62,8 @@ default Optional getRequest() { consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } ) default ResponseEntity createXmlItem( - -@ApiParam(value = "XmlItem Body", required = true ) @Valid @RequestBody XmlItem xmlItem) { + @ApiParam(value = "XmlItem Body", required = true) @Valid @RequestBody XmlItem xmlItem + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -72,11 +76,16 @@ default ResponseEntity createXmlItem( * @param body Input boolean as post body (optional) * @return Output boolean (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterBooleanSerialize", + notes = "Test serialization of outer boolean types", + response = Boolean.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) + }) @ApiImplicitParams({ }) @RequestMapping( @@ -85,8 +94,8 @@ default ResponseEntity createXmlItem( produces = { "*/*" } ) default ResponseEntity fakeOuterBooleanSerialize( - -@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { + @ApiParam(value = "Input boolean as post body") @Valid @RequestBody(required = false) Boolean body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -99,11 +108,16 @@ default ResponseEntity fakeOuterBooleanSerialize( * @param body Input composite as post body (optional) * @return Output composite (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterCompositeSerialize", + notes = "Test serialization of object with outer number type", + response = OuterComposite.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) + }) @ApiImplicitParams({ }) @RequestMapping( @@ -112,8 +126,8 @@ default ResponseEntity fakeOuterBooleanSerialize( produces = { "*/*" } ) default ResponseEntity fakeOuterCompositeSerialize( - -@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { + @ApiParam(value = "Input composite as post body") @Valid @RequestBody(required = false) OuterComposite body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) { @@ -135,11 +149,16 @@ default ResponseEntity fakeOuterCompositeSerialize( * @param body Input number as post body (optional) * @return Output number (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterNumberSerialize", + notes = "Test serialization of outer number types", + response = BigDecimal.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) + }) @ApiImplicitParams({ }) @RequestMapping( @@ -148,8 +167,8 @@ default ResponseEntity fakeOuterCompositeSerialize( produces = { "*/*" } ) default ResponseEntity fakeOuterNumberSerialize( - -@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { + @ApiParam(value = "Input number as post body") @Valid @RequestBody(required = false) BigDecimal body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -162,11 +181,16 @@ default ResponseEntity fakeOuterNumberSerialize( * @param body Input string as post body (optional) * @return Output string (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output string", response = String.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterStringSerialize", + notes = "Test serialization of outer string types", + response = String.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output string", response = String.class) + }) @ApiImplicitParams({ }) @RequestMapping( @@ -175,8 +199,8 @@ default ResponseEntity fakeOuterNumberSerialize( produces = { "*/*" } ) default ResponseEntity fakeOuterStringSerialize( - -@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { + @ApiParam(value = "Input string as post body") @Valid @RequestBody(required = false) String body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -189,11 +213,15 @@ default ResponseEntity fakeOuterStringSerialize( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithFileSchema", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithFileSchema", + notes = "For this test, the body for this request much reference a schema named `File`." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @ApiImplicitParams({ }) @RequestMapping( @@ -202,8 +230,8 @@ default ResponseEntity fakeOuterStringSerialize( consumes = { "application/json" } ) default ResponseEntity testBodyWithFileSchema( - -@ApiParam(value = "", required = true ) @Valid @RequestBody FileSchemaTestClass body) { + @ApiParam(value = "", required = true) @Valid @RequestBody FileSchemaTestClass body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -216,11 +244,15 @@ default ResponseEntity testBodyWithFileSchema( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithQueryParams", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithQueryParams", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @ApiImplicitParams({ }) @RequestMapping( @@ -228,11 +260,10 @@ default ResponseEntity testBodyWithFileSchema( value = "/fake/body-with-query-params", consumes = { "application/json" } ) - default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query - -, - -@ApiParam(value = "", required = true ) @Valid @RequestBody User body) { + default ResponseEntity testBodyWithQueryParams( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query, + @ApiParam(value = "", required = true) @Valid @RequestBody User body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -245,11 +276,16 @@ default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake" }, + value = "To test \"client\" model", + nickname = "testClientModel", + notes = "To test \"client\" model", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @ApiImplicitParams({ }) @RequestMapping( @@ -259,8 +295,8 @@ default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = consumes = { "application/json" } ) default ResponseEntity testClientModel( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -296,16 +332,19 @@ default ResponseEntity testClientModel( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", authorizations = { - - @Authorization(value = "http_basic_test") - }, tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + nickname = "testEndpointParameters", + notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + authorizations = { + @Authorization(value = "http_basic_test") + } + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @ApiImplicitParams({ }) @RequestMapping( @@ -314,34 +353,21 @@ default ResponseEntity testClientModel( consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testEndpointParameters( - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, - -@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, - -@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, - -@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, - -@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary, - -@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date, - -@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime, - -@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, - -@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback) { + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, + @ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, + @ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, + @ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, + @ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, + @ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, + @ApiParam(value = "None") @RequestPart(value = "binary", required = false) MultipartFile binary, + @ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, + @ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -360,35 +386,33 @@ default ResponseEntity testEndpointParameters( * @return Invalid request (status code 400) * or Not found (status code 404) */ - - @ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "To test enum parameters", + nickname = "testEnumParameters", + notes = "To test enum parameters" + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid request"), - - @ApiResponse(code = 404, message = "Not found") }) + @ApiResponse(code = 404, message = "Not found") + }) @ApiImplicitParams({ - @ApiImplicitParam(name = "enumHeaderStringArray", value = "Header parameter enum test (string array)", dataType = "List", paramType = "header"), - @ApiImplicitParam(name = "enumHeaderString", value = "Header parameter enum test (string)", dataType = "String", paramType = "header") + @ApiImplicitParam(name = "enumHeaderStringArray", value = "Header parameter enum test (string array)", dataType = "List", paramType = "header"), + @ApiImplicitParam(name = "enumHeaderString", value = "Header parameter enum test (string)", dataType = "String", paramType = "header") }) @RequestMapping( method = RequestMethod.GET, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) - default ResponseEntity testEnumParameters(@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray - -,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble - -, - -@ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, - -@ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString) { + default ResponseEntity testEnumParameters( + @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, + @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble, + @ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, + @ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -404,28 +428,29 @@ default ResponseEntity testEnumParameters(@ApiParam(value = "Query paramet * @param int64Group Integer in group parameters (optional) * @return Someting wrong (status code 400) */ - - @ApiOperation(value = "Fake endpoint to test group parameters (optional)", nickname = "testGroupParameters", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 400, message = "Someting wrong") }) + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint to test group parameters (optional)", + nickname = "testGroupParameters", + notes = "Fake endpoint to test group parameters (optional)" + ) + @ApiResponses({ + @ApiResponse(code = 400, message = "Someting wrong") + }) @ApiImplicitParams({ - @ApiImplicitParam(name = "requiredBooleanGroup", value = "Required Boolean in group parameters", required = true, dataType = "Boolean", paramType = "header"), - @ApiImplicitParam(name = "booleanGroup", value = "Boolean in group parameters", dataType = "Boolean", paramType = "header") + @ApiImplicitParam(name = "requiredBooleanGroup", value = "Required Boolean in group parameters", required = true, dataType = "Boolean", paramType = "header"), + @ApiImplicitParam(name = "booleanGroup", value = "Boolean in group parameters", dataType = "Boolean", paramType = "header") }) @RequestMapping( method = RequestMethod.DELETE, value = "/fake" ) - default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup - -,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group - -,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup - -,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group - -) { + default ResponseEntity testGroupParameters( + @NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup, + @NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group, + @ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup, + @ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -437,11 +462,15 @@ default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Req * @param param request body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test inline additionalProperties", + nickname = "testInlineAdditionalProperties", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @ApiImplicitParams({ }) @RequestMapping( @@ -450,8 +479,8 @@ default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Req consumes = { "application/json" } ) default ResponseEntity testInlineAdditionalProperties( - -@ApiParam(value = "request body", required = true ) @Valid @RequestBody Map param) { + @ApiParam(value = "request body", required = true) @Valid @RequestBody Map param + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -464,11 +493,15 @@ default ResponseEntity testInlineAdditionalProperties( * @param param2 field2 (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test json serialization of form data", + nickname = "testJsonFormData", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @ApiImplicitParams({ }) @RequestMapping( @@ -477,10 +510,9 @@ default ResponseEntity testInlineAdditionalProperties( consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testJsonFormData( - -@ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, - -@ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2) { + @ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, + @ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2 + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -497,28 +529,28 @@ default ResponseEntity testJsonFormData( * @param context (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testQueryParameterCollectionFormat", + notes = "To test the collection format in query parameters" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @ApiImplicitParams({ }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/test-query-parameters" ) - default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context - -) { + default ResponseEntity testQueryParameterCollectionFormat( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -532,15 +564,22 @@ default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiPar * @param additionalMetadata Additional data to pass to server (optional) * @return successful operation (status code 200) */ - - @ApiOperation(value = "uploads an image (required)", nickname = "uploadFileWithRequiredFile", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @ApiOperation( + tags = { "pet" }, + value = "uploads an image (required)", + nickname = "uploadFileWithRequiredFile", + 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) + }) @ApiImplicitParams({ }) @RequestMapping( @@ -549,13 +588,11 @@ default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiPar produces = { "application/json" }, consumes = { "multipart/form-data" } ) - default ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata) { + default ResponseEntity uploadFileWithRequiredFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "file to upload", required = true) @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeClassnameTestApi.java index 9e8272c417cc..6586cb13ebe9 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -36,14 +36,19 @@ default Optional getRequest() { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test class name in snake case", nickname = "testClassname", notes = "To test class name in snake case", response = Client.class, authorizations = { - - @Authorization(value = "api_key_query") - }, tags={ "fake_classname_tags 123#$%^", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake_classname_tags 123#$%^" }, + value = "To test class name in snake case", + nickname = "testClassname", + notes = "To test class name in snake case", + response = Client.class, + authorizations = { + @Authorization(value = "api_key_query") + } + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @ApiImplicitParams({ }) @RequestMapping( @@ -53,8 +58,8 @@ default Optional getRequest() { consumes = { "application/json" } ) default ResponseEntity testClassname( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/PetApi.java index 4fd532fb25a7..2dcbd379130e 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/PetApi.java @@ -38,17 +38,22 @@ default Optional getRequest() { * @return successful operation (status code 200) * or Invalid input (status code 405) */ - - @ApiOperation(value = "Add a new pet to the store", nickname = "addPet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Add a new pet to the store", + nickname = "addPet", + 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 = 200, message = "successful operation"), - - @ApiResponse(code = 405, message = "Invalid input") }) + @ApiResponse(code = 405, message = "Invalid input") + }) @ApiImplicitParams({ }) @RequestMapping( @@ -57,8 +62,8 @@ default Optional getRequest() { consumes = { "application/json", "application/xml" } ) default ResponseEntity addPet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -71,27 +76,32 @@ default ResponseEntity addPet( * @return successful operation (status code 200) * or Invalid pet value (status code 400) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = 200, message = "successful operation"), - - @ApiResponse(code = 400, message = "Invalid pet value") }) + @ApiResponse(code = 400, message = "Invalid pet value") + }) @ApiImplicitParams({ - @ApiImplicitParam(name = "apiKey", value = "", dataType = "String", paramType = "header") + @ApiImplicitParam(name = "apiKey", value = "", dataType = "String", paramType = "header") }) @RequestMapping( method = RequestMethod.DELETE, value = "/pet/{petId}" ) - default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId - -) { + default ResponseEntity deletePet( + @ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -105,17 +115,24 @@ default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", req * @return successful operation (status code 200) * or Invalid status value (status code 400) */ - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid status value") }) + @ApiResponse(code = 400, message = "Invalid status value") + }) @ApiImplicitParams({ }) @RequestMapping( @@ -123,9 +140,9 @@ default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", req value = "/pet/findByStatus", produces = { "application/xml", "application/json" } ) - default ResponseEntity> 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 status - -) { + default ResponseEntity> 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 status + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -154,17 +171,24 @@ default ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "S * or Invalid tag value (status code 400) * @deprecated */ - - @ApiOperation(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 = "Set", authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "Set", + 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, responseContainer = "Set"), - - @ApiResponse(code = 400, message = "Invalid tag value") }) + @ApiResponse(code = 400, message = "Invalid tag value") + }) @ApiImplicitParams({ }) @RequestMapping( @@ -172,9 +196,9 @@ default ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "S value = "/pet/findByTags", produces = { "application/xml", "application/json" } ) - default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags - -) { + default ResponseEntity> findPetsByTags( + @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -203,18 +227,21 @@ default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags * or Invalid ID supplied (status code 400) * or Pet not found (status code 404) */ - - @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { - - @Authorization(value = "api_key") - }, tags={ "pet", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Pet not found") + }) @ApiImplicitParams({ }) @RequestMapping( @@ -222,9 +249,9 @@ default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags value = "/pet/{petId}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId - -) { + default ResponseEntity getPetById( + @ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -253,21 +280,24 @@ default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", * or Pet not found (status code 404) * or Validation exception (status code 405) */ - - @ApiOperation(value = "Update an existing pet", nickname = "updatePet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Update an existing pet", + nickname = "updatePet", + 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 = 200, message = "successful operation"), - @ApiResponse(code = 400, message = "Invalid ID supplied"), - @ApiResponse(code = 404, message = "Pet not found"), - - @ApiResponse(code = 405, message = "Validation exception") }) + @ApiResponse(code = 405, message = "Validation exception") + }) @ApiImplicitParams({ }) @RequestMapping( @@ -276,8 +306,8 @@ default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", consumes = { "application/json", "application/xml" } ) default ResponseEntity updatePet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -291,15 +321,21 @@ default ResponseEntity updatePet( * @param status Updated status of the pet (optional) * @return Invalid input (status code 405) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 405, message = "Invalid input") }) + @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") + }) @ApiImplicitParams({ }) @RequestMapping( @@ -307,13 +343,11 @@ default ResponseEntity updatePet( value = "/pet/{petId}", consumes = { "application/x-www-form-urlencoded" } ) - default ResponseEntity 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 @RequestPart(value = "name", required = false) String name, - -@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status) { + default ResponseEntity 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 @RequestPart(value = "name", required = false) String name, + @ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -327,15 +361,22 @@ default ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that * @param file file to upload (optional) * @return successful operation (status code 200) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @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) + }) @ApiImplicitParams({ }) @RequestMapping( @@ -344,13 +385,11 @@ default ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that produces = { "application/json" }, consumes = { "multipart/form-data" } ) - default ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { + default ResponseEntity uploadFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @ApiParam(value = "file to upload") @RequestPart(value = "file", required = false) MultipartFile file + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/StoreApi.java index 239b0c22e23c..352248a430ca 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/StoreApi.java @@ -38,22 +38,25 @@ default Optional getRequest() { * @return Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(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", tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @ApiImplicitParams({ }) @RequestMapping( method = RequestMethod.DELETE, value = "/store/order/{order_id}" ) - default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId - -) { + default ResponseEntity deleteOrder( + @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -65,14 +68,20 @@ default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that * * @return successful operation (status code 200) */ - - @ApiOperation(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") - }, tags={ "store", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) + @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") + }) @ApiImplicitParams({ }) @RequestMapping( @@ -80,7 +89,9 @@ default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that value = "/store/inventory", produces = { "application/json" } ) - default ResponseEntity> getInventory() { + default ResponseEntity> getInventory( + + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -95,15 +106,18 @@ default ResponseEntity> getInventory() { * or Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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 generated 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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @ApiImplicitParams({ }) @RequestMapping( @@ -111,9 +125,9 @@ default ResponseEntity> getInventory() { value = "/store/order/{order_id}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId - -) { + default ResponseEntity getOrderById( + @Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -140,13 +154,17 @@ default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = " * @return successful operation (status code 200) * or Invalid Order (status code 400) */ - - @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid Order") + }) @ApiImplicitParams({ }) @RequestMapping( @@ -155,8 +173,8 @@ default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = " produces = { "application/xml", "application/json" } ) default ResponseEntity placeOrder( - -@ApiParam(value = "order placed for purchasing the pet", required = true ) @Valid @RequestBody Order body) { + @ApiParam(value = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/UserApi.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/UserApi.java index df2e57310e10..c4d2a0e29e43 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/UserApi.java @@ -38,11 +38,15 @@ default Optional getRequest() { * @param body Created user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Create user", + nickname = "createUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @ApiImplicitParams({ }) @RequestMapping( @@ -50,8 +54,8 @@ default Optional getRequest() { value = "/user" ) default ResponseEntity createUser( - -@ApiParam(value = "Created user object", required = true ) @Valid @RequestBody User body) { + @ApiParam(value = "Created user object", required = true) @Valid @RequestBody User body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -63,11 +67,15 @@ default ResponseEntity createUser( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithArrayInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @ApiImplicitParams({ }) @RequestMapping( @@ -75,8 +83,8 @@ default ResponseEntity createUser( value = "/user/createWithArray" ) default ResponseEntity createUsersWithArrayInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -88,11 +96,15 @@ default ResponseEntity createUsersWithArrayInput( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithListInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @ApiImplicitParams({ }) @RequestMapping( @@ -100,8 +112,8 @@ default ResponseEntity createUsersWithArrayInput( value = "/user/createWithList" ) default ResponseEntity createUsersWithListInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -115,22 +127,25 @@ default ResponseEntity createUsersWithListInput( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Delete user", + nickname = "deleteUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @ApiImplicitParams({ }) @RequestMapping( method = RequestMethod.DELETE, value = "/user/{username}" ) - default ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username - -) { + default ResponseEntity deleteUser( + @ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -144,15 +159,18 @@ default ResponseEntity deleteUser(@ApiParam(value = "The name that needs t * or Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "User not found") + }) @ApiImplicitParams({ }) @RequestMapping( @@ -160,9 +178,9 @@ default ResponseEntity deleteUser(@ApiParam(value = "The name that needs t value = "/user/{username}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username - -) { + default ResponseEntity getUserByName( + @ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -190,13 +208,17 @@ default ResponseEntity getUserByName(@ApiParam(value = "The name that need * @return successful operation (status code 200) * or Invalid username/password supplied (status code 400) */ - - @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid username/password supplied") + }) @ApiImplicitParams({ }) @RequestMapping( @@ -204,11 +226,10 @@ default ResponseEntity getUserByName(@ApiParam(value = "The name that need value = "/user/login", produces = { "application/xml", "application/json" } ) - default ResponseEntity loginUser(@NotNull @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 - -) { + default ResponseEntity loginUser( + @NotNull @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 new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -219,18 +240,24 @@ default ResponseEntity loginUser(@NotNull @ApiParam(value = "The user na * * @return successful operation (status code 200) */ - - @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Logs out current logged in user session", + nickname = "logoutUser", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @ApiImplicitParams({ }) @RequestMapping( method = RequestMethod.GET, value = "/user/logout" ) - default ResponseEntity logoutUser() { + default ResponseEntity logoutUser( + + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -245,24 +272,26 @@ default ResponseEntity logoutUser() { * @return Invalid user supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Updated user", + nickname = "updateUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid user supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @ApiImplicitParams({ }) @RequestMapping( method = RequestMethod.PUT, value = "/user/{username}" ) - default ResponseEntity 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 body) { + default ResponseEntity 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 body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } diff --git a/samples/server/petstore/springboot-reactive/pom.xml b/samples/server/petstore/springboot-reactive/pom.xml index bc82bfdfef5d..6f5e06c6e297 100644 --- a/samples/server/petstore/springboot-reactive/pom.xml +++ b/samples/server/petstore/springboot-reactive/pom.xml @@ -9,11 +9,12 @@ 1.8 ${java.version} ${java.version} + 1.6.3 org.springframework.boot spring-boot-starter-parent - 2.3.3.RELEASE + 2.5.8 src/main/java @@ -21,13 +22,6 @@ org.springframework.boot spring-boot-maven-plugin - - - - repackage - - - @@ -40,20 +34,10 @@ org.springframework.data spring-data-commons - - io.springfox - springfox-swagger2 - 2.8.0 - - - org.webjars - swagger-ui - 3.14.2 - io.swagger swagger-annotations - 1.5.14 + ${swagger-core-version} @@ -72,12 +56,12 @@ org.openapitools jackson-databind-nullable - 0.2.1 + 0.2.2 - + - jakarta.validation - jakarta.validation-api + org.springframework.boot + spring-boot-starter-validation com.fasterxml.jackson.core diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApi.java index b5fe7d207940..1768ee5a3c29 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -36,11 +36,16 @@ default AnotherFakeApiDelegate getDelegate() { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "$another-fake?" }, + value = "To test special tags", + nickname = "call123testSpecialTags", + notes = "To test special tags and operation ID starting with number", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/another-fake/dummy", @@ -48,8 +53,9 @@ default AnotherFakeApiDelegate getDelegate() { consumes = { "application/json" } ) default Mono> call123testSpecialTags( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Mono body, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Mono body, + final ServerWebExchange exchange + ) { return getDelegate().call123testSpecialTags(body, exchange); } diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java index f925f8ac4789..2ef11c811c11 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java @@ -1,7 +1,6 @@ package org.openapitools.api; import org.openapitools.model.Client; -import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApi.java index f6451bcf10f1..a0f7b30618af 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApi.java @@ -45,19 +45,24 @@ default FakeApiDelegate getDelegate() { * @param xmlItem XmlItem Body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "creates an XmlItem", nickname = "createXmlItem", notes = "this route creates an XmlItem", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "creates an XmlItem", + nickname = "createXmlItem", + notes = "this route creates an XmlItem" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/create_xml_item", consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } ) default Mono> createXmlItem( - -@ApiParam(value = "XmlItem Body", required = true ) @Valid @RequestBody Mono xmlItem, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + @ApiParam(value = "XmlItem Body", required = true) @Valid @RequestBody Mono xmlItem, + final ServerWebExchange exchange + ) { return getDelegate().createXmlItem(xmlItem, exchange); } @@ -69,19 +74,25 @@ default Mono> createXmlItem( * @param body Input boolean as post body (optional) * @return Output boolean (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterBooleanSerialize", + notes = "Test serialization of outer boolean types", + response = Boolean.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/boolean", produces = { "*/*" } ) default Mono> fakeOuterBooleanSerialize( - -@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Mono body, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + @ApiParam(value = "Input boolean as post body") @Valid @RequestBody(required = false) Mono body, + final ServerWebExchange exchange + ) { return getDelegate().fakeOuterBooleanSerialize(body, exchange); } @@ -93,19 +104,25 @@ default Mono> fakeOuterBooleanSerialize( * @param body Input composite as post body (optional) * @return Output composite (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterCompositeSerialize", + notes = "Test serialization of object with outer number type", + response = OuterComposite.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/composite", produces = { "*/*" } ) default Mono> fakeOuterCompositeSerialize( - -@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) Mono body, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + @ApiParam(value = "Input composite as post body") @Valid @RequestBody(required = false) Mono body, + final ServerWebExchange exchange + ) { return getDelegate().fakeOuterCompositeSerialize(body, exchange); } @@ -117,19 +134,25 @@ default Mono> fakeOuterCompositeSerialize( * @param body Input number as post body (optional) * @return Output number (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterNumberSerialize", + notes = "Test serialization of outer number types", + response = BigDecimal.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/number", produces = { "*/*" } ) default Mono> fakeOuterNumberSerialize( - -@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) Mono body, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + @ApiParam(value = "Input number as post body") @Valid @RequestBody(required = false) Mono body, + final ServerWebExchange exchange + ) { return getDelegate().fakeOuterNumberSerialize(body, exchange); } @@ -141,19 +164,25 @@ default Mono> fakeOuterNumberSerialize( * @param body Input string as post body (optional) * @return Output string (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output string", response = String.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterStringSerialize", + notes = "Test serialization of outer string types", + response = String.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output string", response = String.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/string", produces = { "*/*" } ) default Mono> fakeOuterStringSerialize( - -@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) Mono body, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + @ApiParam(value = "Input string as post body") @Valid @RequestBody(required = false) Mono body, + final ServerWebExchange exchange + ) { return getDelegate().fakeOuterStringSerialize(body, exchange); } @@ -165,19 +194,24 @@ default Mono> fakeOuterStringSerialize( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithFileSchema", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithFileSchema", + notes = "For this test, the body for this request much reference a schema named `File`." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-file-schema", consumes = { "application/json" } ) default Mono> testBodyWithFileSchema( - -@ApiParam(value = "", required = true ) @Valid @RequestBody Mono body, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + @ApiParam(value = "", required = true) @Valid @RequestBody Mono body, + final ServerWebExchange exchange + ) { return getDelegate().testBodyWithFileSchema(body, exchange); } @@ -189,21 +223,25 @@ default Mono> testBodyWithFileSchema( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithQueryParams", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithQueryParams", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-query-params", consumes = { "application/json" } ) - default Mono> testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query - -, - -@ApiParam(value = "", required = true ) @Valid @RequestBody Mono body, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + default Mono> testBodyWithQueryParams( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query, + @ApiParam(value = "", required = true) @Valid @RequestBody Mono body, + final ServerWebExchange exchange + ) { return getDelegate().testBodyWithQueryParams(query, body, exchange); } @@ -215,11 +253,16 @@ default Mono> testBodyWithQueryParams(@NotNull @ApiParam(va * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake" }, + value = "To test \"client\" model", + nickname = "testClientModel", + notes = "To test \"client\" model", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake", @@ -227,8 +270,9 @@ default Mono> testBodyWithQueryParams(@NotNull @ApiParam(va consumes = { "application/json" } ) default Mono> testClientModel( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Mono body, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Mono body, + final ServerWebExchange exchange + ) { return getDelegate().testClientModel(body, exchange); } @@ -254,50 +298,41 @@ default Mono> testClientModel( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", authorizations = { - - @Authorization(value = "http_basic_test") - }, tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + nickname = "testEndpointParameters", + notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + authorizations = { + @Authorization(value = "http_basic_test") + } + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) default Mono> testEndpointParameters( - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, - -@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, - -@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, - -@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, - -@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) Flux binary, - -@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date, - -@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime, - -@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, - -@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, + @ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, + @ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, + @ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, + @ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, + @ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, + @ApiParam(value = "None") @RequestPart(value = "binary", required = false) Flux binary, + @ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, + @ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback, + final ServerWebExchange exchange + ) { return getDelegate().testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback, exchange); } @@ -317,35 +352,32 @@ default Mono> testEndpointParameters( * @return Invalid request (status code 400) * or Not found (status code 404) */ - - @ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "To test enum parameters", + nickname = "testEnumParameters", + notes = "To test enum parameters" + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid request"), - - @ApiResponse(code = 404, message = "Not found") }) + @ApiResponse(code = 404, message = "Not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) default Mono> testEnumParameters( -@ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray -, -@ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString -,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray - -,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble - -, - -@ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, - -@ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + @ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray, + @ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString, + @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, + @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble, + @ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, + @ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString, + final ServerWebExchange exchange + ) { return getDelegate().testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, exchange); } @@ -362,28 +394,28 @@ default Mono> testEnumParameters( * @param int64Group Integer in group parameters (optional) * @return Someting wrong (status code 400) */ - - @ApiOperation(value = "Fake endpoint to test group parameters (optional)", nickname = "testGroupParameters", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 400, message = "Someting wrong") }) + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint to test group parameters (optional)", + nickname = "testGroupParameters", + notes = "Fake endpoint to test group parameters (optional)" + ) + @ApiResponses({ + @ApiResponse(code = 400, message = "Someting wrong") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/fake" ) - default Mono> testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup - -, -@ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup -,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group - -,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup - -, -@ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup -,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group - -, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + default Mono> testGroupParameters( + @NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup, + @ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup, + @NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group, + @ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup, + @ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup, + @ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group, + final ServerWebExchange exchange + ) { return getDelegate().testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, exchange); } @@ -394,19 +426,24 @@ default Mono> testGroupParameters(@NotNull @ApiParam(value * @param param request body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test inline additionalProperties", + nickname = "testInlineAdditionalProperties", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/inline-additionalProperties", consumes = { "application/json" } ) default Mono> testInlineAdditionalProperties( - -@ApiParam(value = "request body", required = true ) @Valid @RequestBody Mono> param, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + @ApiParam(value = "request body", required = true) @Valid @RequestBody Mono> param, + final ServerWebExchange exchange + ) { return getDelegate().testInlineAdditionalProperties(param, exchange); } @@ -418,21 +455,25 @@ default Mono> testInlineAdditionalProperties( * @param param2 field2 (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test json serialization of form data", + nickname = "testJsonFormData", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake/jsonFormData", consumes = { "application/x-www-form-urlencoded" } ) default Mono> testJsonFormData( - -@ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, - -@ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + @ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, + @ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2, + final ServerWebExchange exchange + ) { return getDelegate().testJsonFormData(param, param2, exchange); } @@ -448,26 +489,27 @@ default Mono> testJsonFormData( * @param context (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testQueryParameterCollectionFormat", + notes = "To test the collection format in query parameters" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/test-query-parameters" ) - default Mono> testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context - -, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + default Mono> testQueryParameterCollectionFormat( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context, + final ServerWebExchange exchange + ) { return getDelegate().testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, exchange); } @@ -480,28 +522,34 @@ default Mono> testQueryParameterCollectionFormat(@NotNull @ * @param additionalMetadata Additional data to pass to server (optional) * @return successful operation (status code 200) */ - - @ApiOperation(value = "uploads an image (required)", nickname = "uploadFileWithRequiredFile", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @ApiOperation( + tags = { "pet" }, + value = "uploads an image (required)", + nickname = "uploadFileWithRequiredFile", + 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 = "/fake/{petId}/uploadImageWithRequiredFile", produces = { "application/json" }, consumes = { "multipart/form-data" } ) - default Mono> uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) Flux requiredFile, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + default Mono> uploadFileWithRequiredFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "file to upload", required = true) @RequestPart(value = "requiredFile", required = true) Flux requiredFile, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + final ServerWebExchange exchange + ) { return getDelegate().uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata, exchange); } diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiDelegate.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiDelegate.java index 348bc54bb047..dbe78fa1c7f9 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiDelegate.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiDelegate.java @@ -10,7 +10,6 @@ import org.openapitools.model.OuterComposite; import org.openapitools.model.User; import org.openapitools.model.XmlItem; -import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApi.java index 7e7ab0fb2a74..60bad223e04b 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -36,14 +36,19 @@ default FakeClassnameTestApiDelegate getDelegate() { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test class name in snake case", nickname = "testClassname", notes = "To test class name in snake case", response = Client.class, authorizations = { - - @Authorization(value = "api_key_query") - }, tags={ "fake_classname_tags 123#$%^", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake_classname_tags 123#$%^" }, + value = "To test class name in snake case", + nickname = "testClassname", + notes = "To test class name in snake case", + response = Client.class, + authorizations = { + @Authorization(value = "api_key_query") + } + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake_classname_test", @@ -51,8 +56,9 @@ default FakeClassnameTestApiDelegate getDelegate() { consumes = { "application/json" } ) default Mono> testClassname( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Mono body, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Mono body, + final ServerWebExchange exchange + ) { return getDelegate().testClassname(body, exchange); } diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java index 621c23358185..4127d96d9e3e 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java @@ -1,7 +1,6 @@ package org.openapitools.api; import org.openapitools.model.Client; -import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApi.java index a7c97583ad84..f65a81e173e4 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApi.java @@ -38,25 +38,31 @@ default PetApiDelegate getDelegate() { * @return successful operation (status code 200) * or Invalid input (status code 405) */ - - @ApiOperation(value = "Add a new pet to the store", nickname = "addPet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Add a new pet to the store", + nickname = "addPet", + 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 = 200, message = "successful operation"), - - @ApiResponse(code = 405, message = "Invalid input") }) + @ApiResponse(code = 405, message = "Invalid input") + }) @RequestMapping( method = RequestMethod.POST, value = "/pet", consumes = { "application/json", "application/xml" } ) default Mono> addPet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Mono body, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Mono body, + final ServerWebExchange exchange + ) { return getDelegate().addPet(body, exchange); } @@ -69,26 +75,31 @@ default Mono> addPet( * @return successful operation (status code 200) * or Invalid pet value (status code 400) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = 200, message = "successful operation"), - - @ApiResponse(code = 400, message = "Invalid pet value") }) + @ApiResponse(code = 400, message = "Invalid pet value") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/pet/{petId}" ) - default Mono> deletePet(@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId - -, -@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey -, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + default Mono> deletePet( + @ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey, + final ServerWebExchange exchange + ) { return getDelegate().deletePet(petId, apiKey, exchange); } @@ -101,25 +112,33 @@ default Mono> deletePet(@ApiParam(value = "Pet id to delete * @return successful operation (status code 200) * or Invalid status value (status code 400) */ - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid status value") }) + @ApiResponse(code = 400, message = "Invalid status value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByStatus", produces = { "application/xml", "application/json" } ) - default Mono>> 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 status - -, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + default Mono>> 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 status, + final ServerWebExchange exchange + ) { return getDelegate().findPetsByStatus(status, exchange); } @@ -133,25 +152,33 @@ default Mono>> findPetsByStatus(@NotNull @ApiParam(valu * or Invalid tag value (status code 400) * @deprecated */ - - @ApiOperation(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 = "Set", authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "Set", + 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, responseContainer = "Set"), - - @ApiResponse(code = 400, message = "Invalid tag value") }) + @ApiResponse(code = 400, message = "Invalid tag value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByTags", produces = { "application/xml", "application/json" } ) - default Mono>> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags - -, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + default Mono>> findPetsByTags( + @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags, + final ServerWebExchange exchange + ) { return getDelegate().findPetsByTags(tags, exchange); } @@ -165,26 +192,30 @@ default Mono>> findPetsByTags(@NotNull @ApiParam(value * or Invalid ID supplied (status code 400) * or Pet not found (status code 404) */ - - @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { - - @Authorization(value = "api_key") - }, tags={ "pet", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Pet not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/{petId}", produces = { "application/xml", "application/json" } ) - default Mono> getPetById(@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId - -, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + default Mono> getPetById( + @ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId, + final ServerWebExchange exchange + ) { return getDelegate().getPetById(petId, exchange); } @@ -198,29 +229,33 @@ default Mono> getPetById(@ApiParam(value = "ID of pet to ret * or Pet not found (status code 404) * or Validation exception (status code 405) */ - - @ApiOperation(value = "Update an existing pet", nickname = "updatePet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Update an existing pet", + nickname = "updatePet", + 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 = 200, message = "successful operation"), - @ApiResponse(code = 400, message = "Invalid ID supplied"), - @ApiResponse(code = 404, message = "Pet not found"), - - @ApiResponse(code = 405, message = "Validation exception") }) + @ApiResponse(code = 405, message = "Validation exception") + }) @RequestMapping( method = RequestMethod.PUT, value = "/pet", consumes = { "application/json", "application/xml" } ) default Mono> updatePet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Mono body, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Mono body, + final ServerWebExchange exchange + ) { return getDelegate().updatePet(body, exchange); } @@ -233,27 +268,32 @@ default Mono> updatePet( * @param status Updated status of the pet (optional) * @return Invalid input (status code 405) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 405, message = "Invalid input") }) + @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" } ) - default Mono> 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 @RequestPart(value = "name", required = false) String name, - -@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + default Mono> 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 @RequestPart(value = "name", required = false) String name, + @ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status, + final ServerWebExchange exchange + ) { return getDelegate().updatePetWithForm(petId, name, status, exchange); } @@ -266,28 +306,34 @@ default Mono> updatePetWithForm(@ApiParam(value = "ID of pe * @param file file to upload (optional) * @return successful operation (status code 200) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @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" } ) - default Mono> uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) Flux file, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + default Mono> uploadFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @ApiParam(value = "file to upload") @RequestPart(value = "file", required = false) Flux file, + final ServerWebExchange exchange + ) { return getDelegate().uploadFile(petId, additionalMetadata, file, exchange); } diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApiDelegate.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApiDelegate.java index 12eca4209031..8dc1be776ea0 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApiDelegate.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApiDelegate.java @@ -3,7 +3,6 @@ import org.openapitools.model.ModelApiResponse; import org.openapitools.model.Pet; import java.util.Set; -import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApi.java index dfadce5ffb80..9de6b5365aee 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApi.java @@ -38,20 +38,24 @@ default StoreApiDelegate getDelegate() { * @return Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(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", tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/store/order/{order_id}" ) - default Mono> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId - -, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + default Mono> deleteOrder( + @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId, + final ServerWebExchange exchange + ) { return getDelegate().deleteOrder(orderId, exchange); } @@ -62,20 +66,28 @@ default Mono> deleteOrder(@ApiParam(value = "ID of the orde * * @return successful operation (status code 200) */ - - @ApiOperation(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") - }, tags={ "store", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) + @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" } ) - default Mono>> getInventory(@springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + default Mono>> getInventory( + final ServerWebExchange exchange + ) { return getDelegate().getInventory(exchange); } @@ -89,23 +101,27 @@ default Mono>> getInventory(@springfox.docum * or Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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 generated 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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/store/order/{order_id}", produces = { "application/xml", "application/json" } ) - default Mono> getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId - -, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + default Mono> getOrderById( + @Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId, + final ServerWebExchange exchange + ) { return getDelegate().getOrderById(orderId, exchange); } @@ -117,21 +133,26 @@ default Mono> getOrderById(@Min(1L) @Max(5L) @ApiParam(val * @return successful operation (status code 200) * or Invalid Order (status code 400) */ - - @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid Order") + }) @RequestMapping( method = RequestMethod.POST, value = "/store/order", produces = { "application/xml", "application/json" } ) default Mono> placeOrder( - -@ApiParam(value = "order placed for purchasing the pet", required = true ) @Valid @RequestBody Mono body, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + @ApiParam(value = "order placed for purchasing the pet", required = true) @Valid @RequestBody Mono body, + final ServerWebExchange exchange + ) { return getDelegate().placeOrder(body, exchange); } diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApiDelegate.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApiDelegate.java index 680de023d029..02daadf024a1 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApiDelegate.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApiDelegate.java @@ -2,7 +2,6 @@ import java.util.Map; import org.openapitools.model.Order; -import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApi.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApi.java index 9afa73d31479..9c1beb7f0382 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApi.java @@ -38,18 +38,23 @@ default UserApiDelegate getDelegate() { * @param body Created user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Create user", + nickname = "createUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user" ) default Mono> createUser( - -@ApiParam(value = "Created user object", required = true ) @Valid @RequestBody Mono body, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + @ApiParam(value = "Created user object", required = true) @Valid @RequestBody Mono body, + final ServerWebExchange exchange + ) { return getDelegate().createUser(body, exchange); } @@ -60,18 +65,23 @@ default Mono> createUser( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithArrayInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithArray" ) default Mono> createUsersWithArrayInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody Flux body, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody Flux body, + final ServerWebExchange exchange + ) { return getDelegate().createUsersWithArrayInput(body, exchange); } @@ -82,18 +92,23 @@ default Mono> createUsersWithArrayInput( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithListInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithList" ) default Mono> createUsersWithListInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody Flux body, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody Flux body, + final ServerWebExchange exchange + ) { return getDelegate().createUsersWithListInput(body, exchange); } @@ -106,20 +121,24 @@ default Mono> createUsersWithListInput( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Delete user", + nickname = "deleteUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/user/{username}" ) - default Mono> deleteUser(@ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username - -, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + default Mono> deleteUser( + @ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username, + final ServerWebExchange exchange + ) { return getDelegate().deleteUser(username, exchange); } @@ -132,23 +151,27 @@ default Mono> deleteUser(@ApiParam(value = "The name that n * or Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/{username}", produces = { "application/xml", "application/json" } ) - default Mono> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username - -, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + default Mono> getUserByName( + @ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username, + final ServerWebExchange exchange + ) { return getDelegate().getUserByName(username, exchange); } @@ -161,23 +184,27 @@ default Mono> getUserByName(@ApiParam(value = "The name tha * @return successful operation (status code 200) * or Invalid username/password supplied (status code 400) */ - - @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid username/password supplied") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/login", produces = { "application/xml", "application/json" } ) - default Mono> loginUser(@NotNull @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 - -, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + default Mono> loginUser( + @NotNull @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, + final ServerWebExchange exchange + ) { return getDelegate().loginUser(username, password, exchange); } @@ -187,16 +214,22 @@ default Mono> loginUser(@NotNull @ApiParam(value = "The u * * @return successful operation (status code 200) */ - - @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Logs out current logged in user session", + nickname = "logoutUser", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/logout" ) - default Mono> logoutUser(@springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + default Mono> logoutUser( + final ServerWebExchange exchange + ) { return getDelegate().logoutUser(exchange); } @@ -210,22 +243,25 @@ default Mono> logoutUser(@springfox.documentation.annotatio * @return Invalid user supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Updated user", + nickname = "updateUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid user supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.PUT, value = "/user/{username}" ) - default Mono> updateUser(@ApiParam(value = "name that need to be deleted", required = true) @PathVariable("username") String username - -, - -@ApiParam(value = "Updated user object", required = true ) @Valid @RequestBody Mono body, @springfox.documentation.annotations.ApiIgnore final ServerWebExchange exchange) { + default Mono> updateUser( + @ApiParam(value = "name that need to be deleted", required = true) @PathVariable("username") String username, + @ApiParam(value = "Updated user object", required = true) @Valid @RequestBody Mono body, + final ServerWebExchange exchange + ) { return getDelegate().updateUser(username, body, exchange); } diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApiDelegate.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApiDelegate.java index 563d11fa041e..3985dd30ecdf 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApiDelegate.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApiDelegate.java @@ -3,7 +3,6 @@ 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.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/pom.xml b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/pom.xml index d129b82917eb..93c4f5ec6dd5 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/pom.xml +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/pom.xml @@ -9,12 +9,12 @@ 1.7 ${java.version} ${java.version} - 2.9.2 + 2.9.2 org.springframework.boot spring-boot-starter-parent - 1.5.12.RELEASE + 2.5.8 src/main/java @@ -22,13 +22,6 @@ org.springframework.boot spring-boot-maven-plugin - - - - repackage - - - @@ -45,31 +38,32 @@ io.springfox springfox-swagger2 - ${springfox-version} + ${springfox.version} + - io.springfox - springfox-swagger-ui - ${springfox-version} + com.google.code.findbugs + jsr305 + 3.0.2 - jakarta.xml.bind - jakarta.xml.bind-api + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml com.github.joschi.jackson jackson-datatype-threetenbp - 2.8.4 + 2.9.10 org.openapitools jackson-databind-nullable - 0.2.1 + 0.2.2 - + - jakarta.validation - jakarta.validation-api + org.springframework.boot + spring-boot-starter-validation com.fasterxml.jackson.core diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/AnotherFakeApi.java index 590ad40cffc7..f510b7947340 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -28,11 +28,16 @@ public interface AnotherFakeApi { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "$another-fake?" }, + value = "To test special tags", + nickname = "call123testSpecialTags", + notes = "To test special tags and operation ID starting with number", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/another-fake/dummy", @@ -40,7 +45,7 @@ public interface AnotherFakeApi { consumes = { "application/json" } ) ResponseEntity call123testSpecialTags( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body); + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ); } diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/AnotherFakeApiController.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/AnotherFakeApiController.java index 30d4f1c90e32..f1ca88a6a5ed 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/AnotherFakeApiController.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/AnotherFakeApiController.java @@ -39,8 +39,8 @@ public AnotherFakeApiController(@org.springframework.beans.factory.annotation.Au * @see AnotherFakeApi#call123testSpecialTags */ public ResponseEntity call123testSpecialTags( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { return delegate.call123testSpecialTags(body); } diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java index d17e376d976f..17244270c859 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java @@ -1,7 +1,6 @@ package org.openapitools.api; import org.openapitools.model.Client; -import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.web.multipart.MultipartFile; diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeApi.java index 061be916d1a7..14646bf05606 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeApi.java @@ -37,19 +37,23 @@ public interface FakeApi { * @param xmlItem XmlItem Body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "creates an XmlItem", nickname = "createXmlItem", notes = "this route creates an XmlItem", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "creates an XmlItem", + nickname = "createXmlItem", + notes = "this route creates an XmlItem" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/create_xml_item", consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } ) ResponseEntity createXmlItem( - -@ApiParam(value = "XmlItem Body", required = true ) @Valid @RequestBody XmlItem xmlItem); + @ApiParam(value = "XmlItem Body", required = true) @Valid @RequestBody XmlItem xmlItem + ); /** @@ -59,19 +63,24 @@ ResponseEntity createXmlItem( * @param body Input boolean as post body (optional) * @return Output boolean (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterBooleanSerialize", + notes = "Test serialization of outer boolean types", + response = Boolean.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/boolean", produces = { "*/*" } ) ResponseEntity fakeOuterBooleanSerialize( - -@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body); + @ApiParam(value = "Input boolean as post body") @Valid @RequestBody(required = false) Boolean body + ); /** @@ -81,19 +90,24 @@ ResponseEntity fakeOuterBooleanSerialize( * @param body Input composite as post body (optional) * @return Output composite (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterCompositeSerialize", + notes = "Test serialization of object with outer number type", + response = OuterComposite.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/composite", produces = { "*/*" } ) ResponseEntity fakeOuterCompositeSerialize( - -@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body); + @ApiParam(value = "Input composite as post body") @Valid @RequestBody(required = false) OuterComposite body + ); /** @@ -103,19 +117,24 @@ ResponseEntity fakeOuterCompositeSerialize( * @param body Input number as post body (optional) * @return Output number (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterNumberSerialize", + notes = "Test serialization of outer number types", + response = BigDecimal.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/number", produces = { "*/*" } ) ResponseEntity fakeOuterNumberSerialize( - -@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body); + @ApiParam(value = "Input number as post body") @Valid @RequestBody(required = false) BigDecimal body + ); /** @@ -125,19 +144,24 @@ ResponseEntity fakeOuterNumberSerialize( * @param body Input string as post body (optional) * @return Output string (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output string", response = String.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterStringSerialize", + notes = "Test serialization of outer string types", + response = String.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output string", response = String.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/string", produces = { "*/*" } ) ResponseEntity fakeOuterStringSerialize( - -@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body); + @ApiParam(value = "Input string as post body") @Valid @RequestBody(required = false) String body + ); /** @@ -147,19 +171,23 @@ ResponseEntity fakeOuterStringSerialize( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithFileSchema", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithFileSchema", + notes = "For this test, the body for this request much reference a schema named `File`." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-file-schema", consumes = { "application/json" } ) ResponseEntity testBodyWithFileSchema( - -@ApiParam(value = "", required = true ) @Valid @RequestBody FileSchemaTestClass body); + @ApiParam(value = "", required = true) @Valid @RequestBody FileSchemaTestClass body + ); /** @@ -169,21 +197,24 @@ ResponseEntity testBodyWithFileSchema( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithQueryParams", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithQueryParams", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-query-params", consumes = { "application/json" } ) - ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query - -, - -@ApiParam(value = "", required = true ) @Valid @RequestBody User body); + ResponseEntity testBodyWithQueryParams( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query, + @ApiParam(value = "", required = true) @Valid @RequestBody User body + ); /** @@ -193,11 +224,16 @@ ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", requ * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake" }, + value = "To test \"client\" model", + nickname = "testClientModel", + notes = "To test \"client\" model", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake", @@ -205,8 +241,8 @@ ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", requ consumes = { "application/json" } ) ResponseEntity testClientModel( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body); + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ); /** @@ -230,50 +266,40 @@ ResponseEntity testClientModel( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", authorizations = { - - @Authorization(value = "http_basic_test") - }, tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", + nickname = "testEndpointParameters", + notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", + authorizations = { + @Authorization(value = "http_basic_test") + } + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) ResponseEntity testEndpointParameters( - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, - -@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, - -@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, - -@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, - -@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary, - -@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date, - -@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime, - -@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, - -@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback); + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, + @ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, + @ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, + @ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, + @ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, + @ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, + @ApiParam(value = "None") @RequestPart(value = "binary", required = false) MultipartFile binary, + @ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, + @ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback + ); /** @@ -291,35 +317,31 @@ ResponseEntity testEndpointParameters( * @return Invalid request (status code 400) * or Not found (status code 404) */ - - @ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "To test enum parameters", + nickname = "testEnumParameters", + notes = "To test enum parameters" + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid request"), - - @ApiResponse(code = 404, message = "Not found") }) + @ApiResponse(code = 404, message = "Not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) ResponseEntity testEnumParameters( -@ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray -, -@ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString -,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray - -,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble - -, - -@ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, - -@ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString); + @ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray, + @ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString, + @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, + @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble, + @ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, + @ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString + ); /** @@ -334,28 +356,27 @@ ResponseEntity testEnumParameters( * @param int64Group Integer in group parameters (optional) * @return Someting wrong (status code 400) */ - - @ApiOperation(value = "Fake endpoint to test group parameters (optional)", nickname = "testGroupParameters", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 400, message = "Someting wrong") }) + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint to test group parameters (optional)", + nickname = "testGroupParameters", + notes = "Fake endpoint to test group parameters (optional)" + ) + @ApiResponses({ + @ApiResponse(code = 400, message = "Someting wrong") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/fake" ) - ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup - -, -@ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup -,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group - -,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup - -, -@ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup -,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group - -); + ResponseEntity testGroupParameters( + @NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup, + @ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup, + @NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group, + @ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup, + @ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup, + @ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group + ); /** @@ -364,19 +385,23 @@ ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required St * @param param request body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test inline additionalProperties", + nickname = "testInlineAdditionalProperties", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/inline-additionalProperties", consumes = { "application/json" } ) ResponseEntity testInlineAdditionalProperties( - -@ApiParam(value = "request body", required = true ) @Valid @RequestBody Map param); + @ApiParam(value = "request body", required = true) @Valid @RequestBody Map param + ); /** @@ -386,21 +411,24 @@ ResponseEntity testInlineAdditionalProperties( * @param param2 field2 (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test json serialization of form data", + nickname = "testJsonFormData", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake/jsonFormData", consumes = { "application/x-www-form-urlencoded" } ) ResponseEntity testJsonFormData( - -@ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, - -@ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2); + @ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, + @ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2 + ); /** @@ -414,26 +442,26 @@ ResponseEntity testJsonFormData( * @param context (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testQueryParameterCollectionFormat", + notes = "To test the collection format in query parameters" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/test-query-parameters" ) - ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context - -); + ResponseEntity testQueryParameterCollectionFormat( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context + ); /** @@ -444,27 +472,32 @@ ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value * @param additionalMetadata Additional data to pass to server (optional) * @return successful operation (status code 200) */ - - @ApiOperation(value = "uploads an image (required)", nickname = "uploadFileWithRequiredFile", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @ApiOperation( + tags = { "pet" }, + value = "uploads an image (required)", + nickname = "uploadFileWithRequiredFile", + 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 = "/fake/{petId}/uploadImageWithRequiredFile", produces = { "application/json" }, consumes = { "multipart/form-data" } ) - ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata); + ResponseEntity uploadFileWithRequiredFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "file to upload", required = true) @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata + ); } diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeApiController.java index e714970497e1..76cc2bb95757 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeApiController.java @@ -48,8 +48,8 @@ public FakeApiController(@org.springframework.beans.factory.annotation.Autowired * @see FakeApi#createXmlItem */ public ResponseEntity createXmlItem( - -@ApiParam(value = "XmlItem Body", required = true ) @Valid @RequestBody XmlItem xmlItem) { + @ApiParam(value = "XmlItem Body", required = true) @Valid @RequestBody XmlItem xmlItem + ) { return delegate.createXmlItem(xmlItem); } @@ -62,8 +62,8 @@ public ResponseEntity createXmlItem( * @see FakeApi#fakeOuterBooleanSerialize */ public ResponseEntity fakeOuterBooleanSerialize( - -@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { + @ApiParam(value = "Input boolean as post body") @Valid @RequestBody(required = false) Boolean body + ) { return delegate.fakeOuterBooleanSerialize(body); } @@ -76,8 +76,8 @@ public ResponseEntity fakeOuterBooleanSerialize( * @see FakeApi#fakeOuterCompositeSerialize */ public ResponseEntity fakeOuterCompositeSerialize( - -@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { + @ApiParam(value = "Input composite as post body") @Valid @RequestBody(required = false) OuterComposite body + ) { return delegate.fakeOuterCompositeSerialize(body); } @@ -90,8 +90,8 @@ public ResponseEntity fakeOuterCompositeSerialize( * @see FakeApi#fakeOuterNumberSerialize */ public ResponseEntity fakeOuterNumberSerialize( - -@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { + @ApiParam(value = "Input number as post body") @Valid @RequestBody(required = false) BigDecimal body + ) { return delegate.fakeOuterNumberSerialize(body); } @@ -104,8 +104,8 @@ public ResponseEntity fakeOuterNumberSerialize( * @see FakeApi#fakeOuterStringSerialize */ public ResponseEntity fakeOuterStringSerialize( - -@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { + @ApiParam(value = "Input string as post body") @Valid @RequestBody(required = false) String body + ) { return delegate.fakeOuterStringSerialize(body); } @@ -118,8 +118,8 @@ public ResponseEntity fakeOuterStringSerialize( * @see FakeApi#testBodyWithFileSchema */ public ResponseEntity testBodyWithFileSchema( - -@ApiParam(value = "", required = true ) @Valid @RequestBody FileSchemaTestClass body) { + @ApiParam(value = "", required = true) @Valid @RequestBody FileSchemaTestClass body + ) { return delegate.testBodyWithFileSchema(body); } @@ -131,11 +131,10 @@ public ResponseEntity testBodyWithFileSchema( * @return Success (status code 200) * @see FakeApi#testBodyWithQueryParams */ - public ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query - -, - -@ApiParam(value = "", required = true ) @Valid @RequestBody User body) { + public ResponseEntity testBodyWithQueryParams( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query, + @ApiParam(value = "", required = true) @Valid @RequestBody User body + ) { return delegate.testBodyWithQueryParams(query, body); } @@ -148,8 +147,8 @@ public ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = " * @see FakeApi#testClientModel */ public ResponseEntity testClientModel( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { return delegate.testClientModel(body); } @@ -176,34 +175,21 @@ public ResponseEntity testClientModel( * @see FakeApi#testEndpointParameters */ public ResponseEntity testEndpointParameters( - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, - -@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, - -@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, - -@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, - -@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary, - -@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date, - -@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime, - -@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, - -@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback) { + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, + @ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, + @ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, + @ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, + @ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, + @ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, + @ApiParam(value = "None") @RequestPart(value = "binary", required = false) MultipartFile binary, + @ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, + @ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback + ) { return delegate.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback); } @@ -224,22 +210,15 @@ public ResponseEntity testEndpointParameters( * @see FakeApi#testEnumParameters */ public ResponseEntity testEnumParameters( -@ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray -, -@ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString -,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray - -,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble - -, - -@ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, - -@ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString) { + @ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray, + @ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString, + @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, + @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble, + @ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, + @ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString + ) { return delegate.testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString); } @@ -256,19 +235,14 @@ public ResponseEntity testEnumParameters( * @return Someting wrong (status code 400) * @see FakeApi#testGroupParameters */ - public ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup - -, -@ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup -,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group - -,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup - -, -@ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup -,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group - -) { + public ResponseEntity testGroupParameters( + @NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup, + @ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup, + @NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group, + @ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup, + @ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup, + @ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group + ) { return delegate.testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group); } @@ -280,8 +254,8 @@ public ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Requ * @see FakeApi#testInlineAdditionalProperties */ public ResponseEntity testInlineAdditionalProperties( - -@ApiParam(value = "request body", required = true ) @Valid @RequestBody Map param) { + @ApiParam(value = "request body", required = true) @Valid @RequestBody Map param + ) { return delegate.testInlineAdditionalProperties(param); } @@ -294,10 +268,9 @@ public ResponseEntity testInlineAdditionalProperties( * @see FakeApi#testJsonFormData */ public ResponseEntity testJsonFormData( - -@ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, - -@ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2) { + @ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, + @ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2 + ) { return delegate.testJsonFormData(param, param2); } @@ -313,17 +286,13 @@ public ResponseEntity testJsonFormData( * @return Success (status code 200) * @see FakeApi#testQueryParameterCollectionFormat */ - public ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context - -) { + public ResponseEntity testQueryParameterCollectionFormat( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context + ) { return delegate.testQueryParameterCollectionFormat(pipe, ioutil, http, url, context); } @@ -336,13 +305,11 @@ public ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiPara * @return successful operation (status code 200) * @see FakeApi#uploadFileWithRequiredFile */ - public ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata) { + public ResponseEntity uploadFileWithRequiredFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "file to upload", required = true) @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata + ) { return delegate.uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata); } diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeApiDelegate.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeApiDelegate.java index 3a442bdc25cf..e88b7aa6ca50 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeApiDelegate.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeApiDelegate.java @@ -10,7 +10,6 @@ import org.openapitools.model.OuterComposite; import org.openapitools.model.User; import org.openapitools.model.XmlItem; -import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.web.multipart.MultipartFile; diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeClassnameTestApi.java index 5a1ad6bccd14..fc833265a31c 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -28,14 +28,19 @@ public interface FakeClassnameTestApi { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test class name in snake case", nickname = "testClassname", notes = "To test class name in snake case", response = Client.class, authorizations = { - - @Authorization(value = "api_key_query") - }, tags={ "fake_classname_tags 123#$%^", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake_classname_tags 123#$%^" }, + value = "To test class name in snake case", + nickname = "testClassname", + notes = "To test class name in snake case", + response = Client.class, + authorizations = { + @Authorization(value = "api_key_query") + } + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake_classname_test", @@ -43,7 +48,7 @@ public interface FakeClassnameTestApi { consumes = { "application/json" } ) ResponseEntity testClassname( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body); + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ); } diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java index 027fe24ac123..65de19a78d30 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java @@ -39,8 +39,8 @@ public FakeClassnameTestApiController(@org.springframework.beans.factory.annotat * @see FakeClassnameTestApi#testClassname */ public ResponseEntity testClassname( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { return delegate.testClassname(body); } diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java index 20d9b798c627..31b94ac10958 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java @@ -1,7 +1,6 @@ package org.openapitools.api; import org.openapitools.model.Client; -import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.web.multipart.MultipartFile; diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/PetApi.java index 8b0e0fb8f08f..a9dfd3946707 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/PetApi.java @@ -29,25 +29,30 @@ public interface PetApi { * @return successful operation (status code 200) * or Invalid input (status code 405) */ - - @ApiOperation(value = "Add a new pet to the store", nickname = "addPet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Add a new pet to the store", + nickname = "addPet", + 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 = 200, message = "successful operation"), - - @ApiResponse(code = 405, message = "Invalid input") }) + @ApiResponse(code = 405, message = "Invalid input") + }) @RequestMapping( method = RequestMethod.POST, value = "/pet", consumes = { "application/json", "application/xml" } ) ResponseEntity addPet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body); + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ); /** @@ -58,26 +63,30 @@ ResponseEntity addPet( * @return successful operation (status code 200) * or Invalid pet value (status code 400) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = 200, message = "successful operation"), - - @ApiResponse(code = 400, message = "Invalid pet value") }) + @ApiResponse(code = 400, message = "Invalid pet value") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/pet/{petId}" ) - ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId - -, -@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey -); + ResponseEntity deletePet( + @ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey + ); /** @@ -88,25 +97,33 @@ ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", required = * @return successful operation (status code 200) * or Invalid status value (status code 400) */ - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid status value") }) + @ApiResponse(code = 400, message = "Invalid status value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByStatus", produces = { "application/xml", "application/json" } ) - ResponseEntity> 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 status - -, @springfox.documentation.annotations.ApiIgnore final org.springframework.data.domain.Pageable pageable); + ResponseEntity> 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 status, + @springfox.documentation.annotations.ApiIgnore final org.springframework.data.domain.Pageable pageable + ); /** @@ -118,25 +135,33 @@ ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status va * or Invalid tag value (status code 400) * @deprecated */ - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid tag value") }) + @ApiResponse(code = 400, message = "Invalid tag value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByTags", produces = { "application/xml", "application/json" } ) - ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags - -, @springfox.documentation.annotations.ApiIgnore final org.springframework.data.domain.Pageable pageable); + ResponseEntity> findPetsByTags( + @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, + @springfox.documentation.annotations.ApiIgnore final org.springframework.data.domain.Pageable pageable + ); /** @@ -148,26 +173,29 @@ ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to fil * or Invalid ID supplied (status code 400) * or Pet not found (status code 404) */ - - @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { - - @Authorization(value = "api_key") - }, tags={ "pet", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Pet not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/{petId}", produces = { "application/xml", "application/json" } ) - ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId - -); + ResponseEntity getPetById( + @ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId + ); /** @@ -179,29 +207,32 @@ ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", required * or Pet not found (status code 404) * or Validation exception (status code 405) */ - - @ApiOperation(value = "Update an existing pet", nickname = "updatePet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Update an existing pet", + nickname = "updatePet", + 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 = 200, message = "successful operation"), - @ApiResponse(code = 400, message = "Invalid ID supplied"), - @ApiResponse(code = 404, message = "Pet not found"), - - @ApiResponse(code = 405, message = "Validation exception") }) + @ApiResponse(code = 405, message = "Validation exception") + }) @RequestMapping( method = RequestMethod.PUT, value = "/pet", consumes = { "application/json", "application/xml" } ) ResponseEntity updatePet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body); + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ); /** @@ -212,27 +243,31 @@ ResponseEntity updatePet( * @param status Updated status of the pet (optional) * @return Invalid input (status code 405) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 405, message = "Invalid input") }) + @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" } ) - ResponseEntity 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 @RequestPart(value = "name", required = false) String name, - -@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status); + ResponseEntity 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 @RequestPart(value = "name", required = false) String name, + @ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status + ); /** @@ -243,27 +278,32 @@ ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs t * @param file file to upload (optional) * @return successful operation (status code 200) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @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" } ) - ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file); + ResponseEntity uploadFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @ApiParam(value = "file to upload") @RequestPart(value = "file", required = false) MultipartFile file + ); } diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/PetApiController.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/PetApiController.java index 79e735b977f3..5583546f3e50 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/PetApiController.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/PetApiController.java @@ -40,8 +40,8 @@ public PetApiController(@org.springframework.beans.factory.annotation.Autowired( * @see PetApi#addPet */ public ResponseEntity addPet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return delegate.addPet(body); } @@ -54,11 +54,10 @@ public ResponseEntity addPet( * or Invalid pet value (status code 400) * @see PetApi#deletePet */ - public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId - -, -@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey -) { + public ResponseEntity deletePet( + @ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey + ) { return delegate.deletePet(petId, apiKey); } @@ -71,9 +70,10 @@ public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", requ * or Invalid status value (status code 400) * @see PetApi#findPetsByStatus */ - public ResponseEntity> 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 status - -, @springfox.documentation.annotations.ApiIgnore final Pageable pageable) { + public ResponseEntity> 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 status, + @springfox.documentation.annotations.ApiIgnore final Pageable pageable + ) { return delegate.findPetsByStatus(status, pageable); } @@ -87,9 +87,10 @@ public ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "St * @deprecated * @see PetApi#findPetsByTags */ - public ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags - -, @springfox.documentation.annotations.ApiIgnore final Pageable pageable) { + public ResponseEntity> findPetsByTags( + @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, + @springfox.documentation.annotations.ApiIgnore final Pageable pageable + ) { return delegate.findPetsByTags(tags, pageable); } @@ -103,9 +104,9 @@ public ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags * or Pet not found (status code 404) * @see PetApi#getPetById */ - public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId - -) { + public ResponseEntity getPetById( + @ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId + ) { return delegate.getPetById(petId); } @@ -120,8 +121,8 @@ public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", r * @see PetApi#updatePet */ public ResponseEntity updatePet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return delegate.updatePet(body); } @@ -134,13 +135,11 @@ public ResponseEntity updatePet( * @return Invalid input (status code 405) * @see PetApi#updatePetWithForm */ - public ResponseEntity 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 @RequestPart(value = "name", required = false) String name, - -@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status) { + public ResponseEntity 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 @RequestPart(value = "name", required = false) String name, + @ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status + ) { return delegate.updatePetWithForm(petId, name, status); } @@ -153,13 +152,11 @@ public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that * @return successful operation (status code 200) * @see PetApi#uploadFile */ - public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { + public ResponseEntity uploadFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @ApiParam(value = "file to upload") @RequestPart(value = "file", required = false) MultipartFile file + ) { return delegate.uploadFile(petId, additionalMetadata, file); } diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/PetApiDelegate.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/PetApiDelegate.java index 6ccfd0c28742..94d3c58d3327 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/PetApiDelegate.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/PetApiDelegate.java @@ -2,7 +2,6 @@ import org.openapitools.model.ModelApiResponse; import org.openapitools.model.Pet; -import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.web.multipart.MultipartFile; @@ -47,7 +46,7 @@ ResponseEntity deletePet(Long petId, * or Invalid status value (status code 400) * @see PetApi#findPetsByStatus */ - ResponseEntity> findPetsByStatus(List status, final Pageable pageable); + ResponseEntity> findPetsByStatus(List status, final org.springframework.data.domain.Pageable pageable); /** * GET /pet/findByTags : Finds Pets by tags @@ -59,7 +58,7 @@ ResponseEntity deletePet(Long petId, * @deprecated * @see PetApi#findPetsByTags */ - ResponseEntity> findPetsByTags(List tags, final Pageable pageable); + ResponseEntity> findPetsByTags(List tags, final org.springframework.data.domain.Pageable pageable); /** * GET /pet/{petId} : Find pet by ID diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/StoreApi.java index 36a33839249e..cbf52ad09926 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/StoreApi.java @@ -30,20 +30,23 @@ public interface StoreApi { * @return Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(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", tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/store/order/{order_id}" ) - ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId - -); + ResponseEntity deleteOrder( + @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId + ); /** @@ -52,20 +55,28 @@ ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs t * * @return successful operation (status code 200) */ - - @ApiOperation(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") - }, tags={ "store", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) + @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" } ) - ResponseEntity> getInventory(); + ResponseEntity> getInventory( + + ); /** @@ -77,23 +88,26 @@ ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs t * or Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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 generated 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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/store/order/{order_id}", produces = { "application/xml", "application/json" } ) - ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId - -); + ResponseEntity getOrderById( + @Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId + ); /** @@ -103,20 +117,24 @@ ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pe * @return successful operation (status code 200) * or Invalid Order (status code 400) */ - - @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid Order") + }) @RequestMapping( method = RequestMethod.POST, value = "/store/order", produces = { "application/xml", "application/json" } ) ResponseEntity placeOrder( - -@ApiParam(value = "order placed for purchasing the pet", required = true ) @Valid @RequestBody Order body); + @ApiParam(value = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order body + ); } diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/StoreApiController.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/StoreApiController.java index 76d07f1fc783..3becdad6f4a6 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/StoreApiController.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/StoreApiController.java @@ -40,9 +40,9 @@ public StoreApiController(@org.springframework.beans.factory.annotation.Autowire * or Order not found (status code 404) * @see StoreApi#deleteOrder */ - public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId - -) { + public ResponseEntity deleteOrder( + @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId + ) { return delegate.deleteOrder(orderId); } @@ -53,7 +53,9 @@ public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that * @return successful operation (status code 200) * @see StoreApi#getInventory */ - public ResponseEntity> getInventory() { + public ResponseEntity> getInventory( + + ) { return delegate.getInventory(); } @@ -67,9 +69,9 @@ public ResponseEntity> getInventory() { * or Order not found (status code 404) * @see StoreApi#getOrderById */ - public ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId - -) { + public ResponseEntity getOrderById( + @Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId + ) { return delegate.getOrderById(orderId); } @@ -82,8 +84,8 @@ public ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "I * @see StoreApi#placeOrder */ public ResponseEntity placeOrder( - -@ApiParam(value = "order placed for purchasing the pet", required = true ) @Valid @RequestBody Order body) { + @ApiParam(value = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order body + ) { return delegate.placeOrder(body); } diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/StoreApiDelegate.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/StoreApiDelegate.java index a7bfc60e1289..a6ad2c609955 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/StoreApiDelegate.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/StoreApiDelegate.java @@ -2,7 +2,6 @@ import java.util.Map; import org.openapitools.model.Order; -import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.web.multipart.MultipartFile; diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/UserApi.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/UserApi.java index 8e8a5fbd7a6c..205840928976 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/UserApi.java @@ -30,18 +30,22 @@ public interface UserApi { * @param body Created user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Create user", + nickname = "createUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user" ) ResponseEntity createUser( - -@ApiParam(value = "Created user object", required = true ) @Valid @RequestBody User body); + @ApiParam(value = "Created user object", required = true) @Valid @RequestBody User body + ); /** @@ -50,18 +54,22 @@ ResponseEntity createUser( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithArrayInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithArray" ) ResponseEntity createUsersWithArrayInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body); + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ); /** @@ -70,18 +78,22 @@ ResponseEntity createUsersWithArrayInput( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithListInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithList" ) ResponseEntity createUsersWithListInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body); + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ); /** @@ -92,20 +104,23 @@ ResponseEntity createUsersWithListInput( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Delete user", + nickname = "deleteUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/user/{username}" ) - ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username - -); + ResponseEntity deleteUser( + @ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username + ); /** @@ -116,23 +131,26 @@ ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be del * or Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/{username}", produces = { "application/xml", "application/json" } ) - ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username - -); + ResponseEntity getUserByName( + @ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username + ); /** @@ -143,23 +161,26 @@ ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be * @return successful operation (status code 200) * or Invalid username/password supplied (status code 400) */ - - @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid username/password supplied") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/login", produces = { "application/xml", "application/json" } ) - ResponseEntity loginUser(@NotNull @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 - -); + ResponseEntity loginUser( + @NotNull @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 + ); /** @@ -167,16 +188,22 @@ ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for l * * @return successful operation (status code 200) */ - - @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Logs out current logged in user session", + nickname = "logoutUser", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/logout" ) - ResponseEntity logoutUser(); + ResponseEntity logoutUser( + + ); /** @@ -188,21 +215,23 @@ ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for l * @return Invalid user supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Updated user", + nickname = "updateUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid user supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.PUT, value = "/user/{username}" ) - ResponseEntity 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 body); + ResponseEntity 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 body + ); } diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/UserApiController.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/UserApiController.java index 927da273215f..a9721c9a469e 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/UserApiController.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/UserApiController.java @@ -41,8 +41,8 @@ public UserApiController(@org.springframework.beans.factory.annotation.Autowired * @see UserApi#createUser */ public ResponseEntity createUser( - -@ApiParam(value = "Created user object", required = true ) @Valid @RequestBody User body) { + @ApiParam(value = "Created user object", required = true) @Valid @RequestBody User body + ) { return delegate.createUser(body); } @@ -54,8 +54,8 @@ public ResponseEntity createUser( * @see UserApi#createUsersWithArrayInput */ public ResponseEntity createUsersWithArrayInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return delegate.createUsersWithArrayInput(body); } @@ -67,8 +67,8 @@ public ResponseEntity createUsersWithArrayInput( * @see UserApi#createUsersWithListInput */ public ResponseEntity createUsersWithListInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return delegate.createUsersWithListInput(body); } @@ -81,9 +81,9 @@ public ResponseEntity createUsersWithListInput( * or User not found (status code 404) * @see UserApi#deleteUser */ - public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username - -) { + public ResponseEntity deleteUser( + @ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username + ) { return delegate.deleteUser(username); } @@ -96,9 +96,9 @@ public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to * or User not found (status code 404) * @see UserApi#getUserByName */ - public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username - -) { + public ResponseEntity getUserByName( + @ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username + ) { return delegate.getUserByName(username); } @@ -111,11 +111,10 @@ public ResponseEntity getUserByName(@ApiParam(value = "The name that needs * or Invalid username/password supplied (status code 400) * @see UserApi#loginUser */ - public ResponseEntity loginUser(@NotNull @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 - -) { + public ResponseEntity loginUser( + @NotNull @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 delegate.loginUser(username, password); } @@ -125,7 +124,9 @@ public ResponseEntity loginUser(@NotNull @ApiParam(value = "The user nam * @return successful operation (status code 200) * @see UserApi#logoutUser */ - public ResponseEntity logoutUser() { + public ResponseEntity logoutUser( + + ) { return delegate.logoutUser(); } @@ -139,11 +140,10 @@ public ResponseEntity logoutUser() { * or User not found (status code 404) * @see UserApi#updateUser */ - public ResponseEntity 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 body) { + public ResponseEntity 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 body + ) { return delegate.updateUser(username, body); } diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/UserApiDelegate.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/UserApiDelegate.java index 00d156773a2e..f41ca92fd595 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/UserApiDelegate.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/UserApiDelegate.java @@ -3,7 +3,6 @@ import java.util.List; import org.threeten.bp.OffsetDateTime; import org.openapitools.model.User; -import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.web.multipart.MultipartFile; diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern/pom.xml b/samples/server/petstore/springboot-spring-pageable-delegatePattern/pom.xml index 5a29021686c6..a5ac06132f25 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern/pom.xml +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern/pom.xml @@ -9,12 +9,12 @@ 1.8 ${java.version} ${java.version} - 2.9.2 + 2.9.2 org.springframework.boot spring-boot-starter-parent - 2.3.3.RELEASE + 2.5.8 src/main/java @@ -22,13 +22,6 @@ org.springframework.boot spring-boot-maven-plugin - - - - repackage - - - @@ -45,16 +38,17 @@ io.springfox springfox-swagger2 - ${springfox-version} + ${springfox.version} + - io.springfox - springfox-swagger-ui - ${springfox-version} + com.google.code.findbugs + jsr305 + 3.0.2 - jakarta.xml.bind - jakarta.xml.bind-api + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml com.fasterxml.jackson.datatype @@ -63,12 +57,12 @@ org.openapitools jackson-databind-nullable - 0.2.1 + 0.2.2 - + - jakarta.validation - jakarta.validation-api + org.springframework.boot + spring-boot-starter-validation com.fasterxml.jackson.core diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/AnotherFakeApi.java index 28b39d958853..c257e392d8ae 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -32,11 +32,16 @@ default AnotherFakeApiDelegate getDelegate() { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "$another-fake?" }, + value = "To test special tags", + nickname = "call123testSpecialTags", + notes = "To test special tags and operation ID starting with number", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/another-fake/dummy", @@ -44,8 +49,8 @@ default AnotherFakeApiDelegate getDelegate() { consumes = { "application/json" } ) default ResponseEntity call123testSpecialTags( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { return getDelegate().call123testSpecialTags(body); } diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java index 7e6ac74b30f4..a86542ddf223 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java @@ -1,7 +1,6 @@ package org.openapitools.api; import org.openapitools.model.Client; -import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/FakeApi.java index e366cd99b490..95f16c94409a 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/FakeApi.java @@ -41,19 +41,23 @@ default FakeApiDelegate getDelegate() { * @param xmlItem XmlItem Body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "creates an XmlItem", nickname = "createXmlItem", notes = "this route creates an XmlItem", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "creates an XmlItem", + nickname = "createXmlItem", + notes = "this route creates an XmlItem" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/create_xml_item", consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } ) default ResponseEntity createXmlItem( - -@ApiParam(value = "XmlItem Body", required = true ) @Valid @RequestBody XmlItem xmlItem) { + @ApiParam(value = "XmlItem Body", required = true) @Valid @RequestBody XmlItem xmlItem + ) { return getDelegate().createXmlItem(xmlItem); } @@ -65,19 +69,24 @@ default ResponseEntity createXmlItem( * @param body Input boolean as post body (optional) * @return Output boolean (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterBooleanSerialize", + notes = "Test serialization of outer boolean types", + response = Boolean.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/boolean", produces = { "*/*" } ) default ResponseEntity fakeOuterBooleanSerialize( - -@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { + @ApiParam(value = "Input boolean as post body") @Valid @RequestBody(required = false) Boolean body + ) { return getDelegate().fakeOuterBooleanSerialize(body); } @@ -89,19 +98,24 @@ default ResponseEntity fakeOuterBooleanSerialize( * @param body Input composite as post body (optional) * @return Output composite (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterCompositeSerialize", + notes = "Test serialization of object with outer number type", + response = OuterComposite.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/composite", produces = { "*/*" } ) default ResponseEntity fakeOuterCompositeSerialize( - -@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { + @ApiParam(value = "Input composite as post body") @Valid @RequestBody(required = false) OuterComposite body + ) { return getDelegate().fakeOuterCompositeSerialize(body); } @@ -113,19 +127,24 @@ default ResponseEntity fakeOuterCompositeSerialize( * @param body Input number as post body (optional) * @return Output number (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterNumberSerialize", + notes = "Test serialization of outer number types", + response = BigDecimal.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/number", produces = { "*/*" } ) default ResponseEntity fakeOuterNumberSerialize( - -@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { + @ApiParam(value = "Input number as post body") @Valid @RequestBody(required = false) BigDecimal body + ) { return getDelegate().fakeOuterNumberSerialize(body); } @@ -137,19 +156,24 @@ default ResponseEntity fakeOuterNumberSerialize( * @param body Input string as post body (optional) * @return Output string (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output string", response = String.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterStringSerialize", + notes = "Test serialization of outer string types", + response = String.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output string", response = String.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/string", produces = { "*/*" } ) default ResponseEntity fakeOuterStringSerialize( - -@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { + @ApiParam(value = "Input string as post body") @Valid @RequestBody(required = false) String body + ) { return getDelegate().fakeOuterStringSerialize(body); } @@ -161,19 +185,23 @@ default ResponseEntity fakeOuterStringSerialize( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithFileSchema", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithFileSchema", + notes = "For this test, the body for this request much reference a schema named `File`." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-file-schema", consumes = { "application/json" } ) default ResponseEntity testBodyWithFileSchema( - -@ApiParam(value = "", required = true ) @Valid @RequestBody FileSchemaTestClass body) { + @ApiParam(value = "", required = true) @Valid @RequestBody FileSchemaTestClass body + ) { return getDelegate().testBodyWithFileSchema(body); } @@ -185,21 +213,24 @@ default ResponseEntity testBodyWithFileSchema( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithQueryParams", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithQueryParams", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-query-params", consumes = { "application/json" } ) - default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query - -, - -@ApiParam(value = "", required = true ) @Valid @RequestBody User body) { + default ResponseEntity testBodyWithQueryParams( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query, + @ApiParam(value = "", required = true) @Valid @RequestBody User body + ) { return getDelegate().testBodyWithQueryParams(query, body); } @@ -211,11 +242,16 @@ default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake" }, + value = "To test \"client\" model", + nickname = "testClientModel", + notes = "To test \"client\" model", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake", @@ -223,8 +259,8 @@ default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = consumes = { "application/json" } ) default ResponseEntity testClientModel( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { return getDelegate().testClientModel(body); } @@ -250,50 +286,40 @@ default ResponseEntity testClientModel( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", authorizations = { - - @Authorization(value = "http_basic_test") - }, tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", + nickname = "testEndpointParameters", + notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", + authorizations = { + @Authorization(value = "http_basic_test") + } + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testEndpointParameters( - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, - -@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, - -@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, - -@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, - -@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary, - -@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date, - -@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime, - -@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, - -@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback) { + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, + @ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, + @ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, + @ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, + @ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, + @ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, + @ApiParam(value = "None") @RequestPart(value = "binary", required = false) MultipartFile binary, + @ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, + @ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback + ) { return getDelegate().testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback); } @@ -313,35 +339,31 @@ default ResponseEntity testEndpointParameters( * @return Invalid request (status code 400) * or Not found (status code 404) */ - - @ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "To test enum parameters", + nickname = "testEnumParameters", + notes = "To test enum parameters" + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid request"), - - @ApiResponse(code = 404, message = "Not found") }) + @ApiResponse(code = 404, message = "Not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testEnumParameters( -@ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray -, -@ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString -,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray - -,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble - -, - -@ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, - -@ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString) { + @ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray, + @ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString, + @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, + @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble, + @ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, + @ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString + ) { return getDelegate().testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString); } @@ -358,28 +380,27 @@ default ResponseEntity testEnumParameters( * @param int64Group Integer in group parameters (optional) * @return Someting wrong (status code 400) */ - - @ApiOperation(value = "Fake endpoint to test group parameters (optional)", nickname = "testGroupParameters", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 400, message = "Someting wrong") }) + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint to test group parameters (optional)", + nickname = "testGroupParameters", + notes = "Fake endpoint to test group parameters (optional)" + ) + @ApiResponses({ + @ApiResponse(code = 400, message = "Someting wrong") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/fake" ) - default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup - -, -@ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup -,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group - -,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup - -, -@ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup -,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group - -) { + default ResponseEntity testGroupParameters( + @NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup, + @ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup, + @NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group, + @ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup, + @ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup, + @ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group + ) { return getDelegate().testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group); } @@ -390,19 +411,23 @@ default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Req * @param param request body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test inline additionalProperties", + nickname = "testInlineAdditionalProperties", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/inline-additionalProperties", consumes = { "application/json" } ) default ResponseEntity testInlineAdditionalProperties( - -@ApiParam(value = "request body", required = true ) @Valid @RequestBody Map param) { + @ApiParam(value = "request body", required = true) @Valid @RequestBody Map param + ) { return getDelegate().testInlineAdditionalProperties(param); } @@ -414,21 +439,24 @@ default ResponseEntity testInlineAdditionalProperties( * @param param2 field2 (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test json serialization of form data", + nickname = "testJsonFormData", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake/jsonFormData", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testJsonFormData( - -@ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, - -@ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2) { + @ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, + @ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2 + ) { return getDelegate().testJsonFormData(param, param2); } @@ -444,26 +472,26 @@ default ResponseEntity testJsonFormData( * @param context (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testQueryParameterCollectionFormat", + notes = "To test the collection format in query parameters" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/test-query-parameters" ) - default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context - -) { + default ResponseEntity testQueryParameterCollectionFormat( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context + ) { return getDelegate().testQueryParameterCollectionFormat(pipe, ioutil, http, url, context); } @@ -476,28 +504,33 @@ default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiPar * @param additionalMetadata Additional data to pass to server (optional) * @return successful operation (status code 200) */ - - @ApiOperation(value = "uploads an image (required)", nickname = "uploadFileWithRequiredFile", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @ApiOperation( + tags = { "pet" }, + value = "uploads an image (required)", + nickname = "uploadFileWithRequiredFile", + 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 = "/fake/{petId}/uploadImageWithRequiredFile", produces = { "application/json" }, consumes = { "multipart/form-data" } ) - default ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata) { + default ResponseEntity uploadFileWithRequiredFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "file to upload", required = true) @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata + ) { return getDelegate().uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata); } diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/FakeApiDelegate.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/FakeApiDelegate.java index 61a6142cc5e4..de03df402674 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/FakeApiDelegate.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/FakeApiDelegate.java @@ -10,7 +10,6 @@ import org.openapitools.model.OuterComposite; import org.openapitools.model.User; import org.openapitools.model.XmlItem; -import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/FakeClassnameTestApi.java index 46441906cac5..757dc764c97e 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -32,14 +32,19 @@ default FakeClassnameTestApiDelegate getDelegate() { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test class name in snake case", nickname = "testClassname", notes = "To test class name in snake case", response = Client.class, authorizations = { - - @Authorization(value = "api_key_query") - }, tags={ "fake_classname_tags 123#$%^", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake_classname_tags 123#$%^" }, + value = "To test class name in snake case", + nickname = "testClassname", + notes = "To test class name in snake case", + response = Client.class, + authorizations = { + @Authorization(value = "api_key_query") + } + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake_classname_test", @@ -47,8 +52,8 @@ default FakeClassnameTestApiDelegate getDelegate() { consumes = { "application/json" } ) default ResponseEntity testClassname( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { return getDelegate().testClassname(body); } diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java index c71fe13d195a..ed5a6bfc09a0 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java @@ -1,7 +1,6 @@ package org.openapitools.api; import org.openapitools.model.Client; -import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/PetApi.java index 8e9f330b3426..05b00c66fdea 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/PetApi.java @@ -33,25 +33,30 @@ default PetApiDelegate getDelegate() { * @return successful operation (status code 200) * or Invalid input (status code 405) */ - - @ApiOperation(value = "Add a new pet to the store", nickname = "addPet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Add a new pet to the store", + nickname = "addPet", + 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 = 200, message = "successful operation"), - - @ApiResponse(code = 405, message = "Invalid input") }) + @ApiResponse(code = 405, message = "Invalid input") + }) @RequestMapping( method = RequestMethod.POST, value = "/pet", consumes = { "application/json", "application/xml" } ) default ResponseEntity addPet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return getDelegate().addPet(body); } @@ -64,26 +69,30 @@ default ResponseEntity addPet( * @return successful operation (status code 200) * or Invalid pet value (status code 400) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = 200, message = "successful operation"), - - @ApiResponse(code = 400, message = "Invalid pet value") }) + @ApiResponse(code = 400, message = "Invalid pet value") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/pet/{petId}" ) - default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId - -, -@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey -) { + default ResponseEntity 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); } @@ -96,25 +105,33 @@ default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", req * @return successful operation (status code 200) * or Invalid status value (status code 400) */ - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid status value") }) + @ApiResponse(code = 400, message = "Invalid status value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByStatus", produces = { "application/xml", "application/json" } ) - default ResponseEntity> 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 status - -, @springfox.documentation.annotations.ApiIgnore final org.springframework.data.domain.Pageable pageable) { + default ResponseEntity> 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 status, + @springfox.documentation.annotations.ApiIgnore final org.springframework.data.domain.Pageable pageable + ) { return getDelegate().findPetsByStatus(status, pageable); } @@ -128,25 +145,33 @@ default ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "S * or Invalid tag value (status code 400) * @deprecated */ - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid tag value") }) + @ApiResponse(code = 400, message = "Invalid tag value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByTags", produces = { "application/xml", "application/json" } ) - default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags - -, @springfox.documentation.annotations.ApiIgnore final org.springframework.data.domain.Pageable pageable) { + default ResponseEntity> findPetsByTags( + @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, + @springfox.documentation.annotations.ApiIgnore final org.springframework.data.domain.Pageable pageable + ) { return getDelegate().findPetsByTags(tags, pageable); } @@ -160,26 +185,29 @@ default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tag * or Invalid ID supplied (status code 400) * or Pet not found (status code 404) */ - - @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { - - @Authorization(value = "api_key") - }, tags={ "pet", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Pet not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/{petId}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId - -) { + default ResponseEntity getPetById( + @ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId + ) { return getDelegate().getPetById(petId); } @@ -193,29 +221,32 @@ default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", * or Pet not found (status code 404) * or Validation exception (status code 405) */ - - @ApiOperation(value = "Update an existing pet", nickname = "updatePet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Update an existing pet", + nickname = "updatePet", + 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 = 200, message = "successful operation"), - @ApiResponse(code = 400, message = "Invalid ID supplied"), - @ApiResponse(code = 404, message = "Pet not found"), - - @ApiResponse(code = 405, message = "Validation exception") }) + @ApiResponse(code = 405, message = "Validation exception") + }) @RequestMapping( method = RequestMethod.PUT, value = "/pet", consumes = { "application/json", "application/xml" } ) default ResponseEntity updatePet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return getDelegate().updatePet(body); } @@ -228,27 +259,31 @@ default ResponseEntity updatePet( * @param status Updated status of the pet (optional) * @return Invalid input (status code 405) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 405, message = "Invalid input") }) + @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" } ) - default ResponseEntity 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 @RequestPart(value = "name", required = false) String name, - -@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status) { + default ResponseEntity 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 @RequestPart(value = "name", required = false) String name, + @ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status + ) { return getDelegate().updatePetWithForm(petId, name, status); } @@ -261,28 +296,33 @@ default ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that * @param file file to upload (optional) * @return successful operation (status code 200) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @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" } ) - default ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { + default ResponseEntity uploadFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @ApiParam(value = "file to upload") @RequestPart(value = "file", required = false) MultipartFile file + ) { return getDelegate().uploadFile(petId, additionalMetadata, file); } diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/PetApiDelegate.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/PetApiDelegate.java index 992e770d81d7..02d3eee8e53f 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/PetApiDelegate.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/PetApiDelegate.java @@ -2,7 +2,6 @@ import org.openapitools.model.ModelApiResponse; import org.openapitools.model.Pet; -import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; @@ -61,7 +60,7 @@ default ResponseEntity deletePet(Long petId, * or Invalid status value (status code 400) * @see PetApi#findPetsByStatus */ - default ResponseEntity> findPetsByStatus(List status, final Pageable pageable) { + default ResponseEntity> findPetsByStatus(List status, final org.springframework.data.domain.Pageable pageable) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -90,7 +89,7 @@ default ResponseEntity> findPetsByStatus(List status, final Pa * @deprecated * @see PetApi#findPetsByTags */ - default ResponseEntity> findPetsByTags(List tags, final Pageable pageable) { + default ResponseEntity> findPetsByTags(List tags, final org.springframework.data.domain.Pageable pageable) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/StoreApi.java index 6a5d569d8578..ee6e1fb2d912 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/StoreApi.java @@ -34,20 +34,23 @@ default StoreApiDelegate getDelegate() { * @return Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(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", tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/store/order/{order_id}" ) - default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId - -) { + default ResponseEntity deleteOrder( + @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId + ) { return getDelegate().deleteOrder(orderId); } @@ -58,20 +61,28 @@ default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that * * @return successful operation (status code 200) */ - - @ApiOperation(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") - }, tags={ "store", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) + @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" } ) - default ResponseEntity> getInventory() { + default ResponseEntity> getInventory( + + ) { return getDelegate().getInventory(); } @@ -85,23 +96,26 @@ default ResponseEntity> getInventory() { * or Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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 generated 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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/store/order/{order_id}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId - -) { + default ResponseEntity getOrderById( + @Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId + ) { return getDelegate().getOrderById(orderId); } @@ -113,21 +127,25 @@ default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = " * @return successful operation (status code 200) * or Invalid Order (status code 400) */ - - @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid Order") + }) @RequestMapping( method = RequestMethod.POST, value = "/store/order", produces = { "application/xml", "application/json" } ) default ResponseEntity placeOrder( - -@ApiParam(value = "order placed for purchasing the pet", required = true ) @Valid @RequestBody Order body) { + @ApiParam(value = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order body + ) { return getDelegate().placeOrder(body); } diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/StoreApiDelegate.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/StoreApiDelegate.java index 5091e7e1f2cc..dfe4bb314961 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/StoreApiDelegate.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/StoreApiDelegate.java @@ -2,7 +2,6 @@ import java.util.Map; import org.openapitools.model.Order; -import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/UserApi.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/UserApi.java index e1e7144f3834..264279df93a7 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/UserApi.java @@ -34,18 +34,22 @@ default UserApiDelegate getDelegate() { * @param body Created user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Create user", + nickname = "createUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user" ) default ResponseEntity createUser( - -@ApiParam(value = "Created user object", required = true ) @Valid @RequestBody User body) { + @ApiParam(value = "Created user object", required = true) @Valid @RequestBody User body + ) { return getDelegate().createUser(body); } @@ -56,18 +60,22 @@ default ResponseEntity createUser( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithArrayInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithArray" ) default ResponseEntity createUsersWithArrayInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return getDelegate().createUsersWithArrayInput(body); } @@ -78,18 +86,22 @@ default ResponseEntity createUsersWithArrayInput( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithListInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithList" ) default ResponseEntity createUsersWithListInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return getDelegate().createUsersWithListInput(body); } @@ -102,20 +114,23 @@ default ResponseEntity createUsersWithListInput( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Delete user", + nickname = "deleteUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/user/{username}" ) - default ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username - -) { + default ResponseEntity deleteUser( + @ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username + ) { return getDelegate().deleteUser(username); } @@ -128,23 +143,26 @@ default ResponseEntity deleteUser(@ApiParam(value = "The name that needs t * or Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/{username}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username - -) { + default ResponseEntity getUserByName( + @ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username + ) { return getDelegate().getUserByName(username); } @@ -157,23 +175,26 @@ default ResponseEntity getUserByName(@ApiParam(value = "The name that need * @return successful operation (status code 200) * or Invalid username/password supplied (status code 400) */ - - @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid username/password supplied") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/login", produces = { "application/xml", "application/json" } ) - default ResponseEntity loginUser(@NotNull @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 - -) { + default ResponseEntity loginUser( + @NotNull @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); } @@ -183,16 +204,22 @@ default ResponseEntity loginUser(@NotNull @ApiParam(value = "The user na * * @return successful operation (status code 200) */ - - @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Logs out current logged in user session", + nickname = "logoutUser", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/logout" ) - default ResponseEntity logoutUser() { + default ResponseEntity logoutUser( + + ) { return getDelegate().logoutUser(); } @@ -206,22 +233,24 @@ default ResponseEntity logoutUser() { * @return Invalid user supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Updated user", + nickname = "updateUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid user supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.PUT, value = "/user/{username}" ) - default ResponseEntity 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 body) { + default ResponseEntity 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 body + ) { return getDelegate().updateUser(username, body); } diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/UserApiDelegate.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/UserApiDelegate.java index b63fa7a1c28a..2efbd71c9dc9 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/UserApiDelegate.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/UserApiDelegate.java @@ -3,7 +3,6 @@ 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.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/pom.xml b/samples/server/petstore/springboot-spring-pageable-without-j8/pom.xml index 62d59d9d1d7d..b8f2eb116283 100644 --- a/samples/server/petstore/springboot-spring-pageable-without-j8/pom.xml +++ b/samples/server/petstore/springboot-spring-pageable-without-j8/pom.xml @@ -9,12 +9,12 @@ 1.7 ${java.version} ${java.version} - 2.9.2 + 2.9.2 org.springframework.boot spring-boot-starter-parent - 1.5.12.RELEASE + 2.5.8 src/main/java @@ -22,13 +22,6 @@ org.springframework.boot spring-boot-maven-plugin - - - - repackage - - - @@ -45,31 +38,32 @@ io.springfox springfox-swagger2 - ${springfox-version} + ${springfox.version} + - io.springfox - springfox-swagger-ui - ${springfox-version} + com.google.code.findbugs + jsr305 + 3.0.2 - jakarta.xml.bind - jakarta.xml.bind-api + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml com.github.joschi.jackson jackson-datatype-threetenbp - 2.8.4 + 2.9.10 org.openapitools jackson-databind-nullable - 0.2.1 + 0.2.2 - + - jakarta.validation - jakarta.validation-api + org.springframework.boot + spring-boot-starter-validation com.fasterxml.jackson.core diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/AnotherFakeApi.java index 590ad40cffc7..f510b7947340 100644 --- a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -28,11 +28,16 @@ public interface AnotherFakeApi { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "$another-fake?" }, + value = "To test special tags", + nickname = "call123testSpecialTags", + notes = "To test special tags and operation ID starting with number", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/another-fake/dummy", @@ -40,7 +45,7 @@ public interface AnotherFakeApi { consumes = { "application/json" } ) ResponseEntity call123testSpecialTags( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body); + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ); } diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/AnotherFakeApiController.java b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/AnotherFakeApiController.java index ec32cf448bff..e8f022846bfc 100644 --- a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/AnotherFakeApiController.java +++ b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/AnotherFakeApiController.java @@ -41,8 +41,8 @@ public AnotherFakeApiController(NativeWebRequest request) { * @see AnotherFakeApi#call123testSpecialTags */ public ResponseEntity call123testSpecialTags( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { String exampleString = "{ \"client\" : \"client\" }"; diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/FakeApi.java index 061be916d1a7..14646bf05606 100644 --- a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/FakeApi.java @@ -37,19 +37,23 @@ public interface FakeApi { * @param xmlItem XmlItem Body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "creates an XmlItem", nickname = "createXmlItem", notes = "this route creates an XmlItem", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "creates an XmlItem", + nickname = "createXmlItem", + notes = "this route creates an XmlItem" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/create_xml_item", consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } ) ResponseEntity createXmlItem( - -@ApiParam(value = "XmlItem Body", required = true ) @Valid @RequestBody XmlItem xmlItem); + @ApiParam(value = "XmlItem Body", required = true) @Valid @RequestBody XmlItem xmlItem + ); /** @@ -59,19 +63,24 @@ ResponseEntity createXmlItem( * @param body Input boolean as post body (optional) * @return Output boolean (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterBooleanSerialize", + notes = "Test serialization of outer boolean types", + response = Boolean.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/boolean", produces = { "*/*" } ) ResponseEntity fakeOuterBooleanSerialize( - -@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body); + @ApiParam(value = "Input boolean as post body") @Valid @RequestBody(required = false) Boolean body + ); /** @@ -81,19 +90,24 @@ ResponseEntity fakeOuterBooleanSerialize( * @param body Input composite as post body (optional) * @return Output composite (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterCompositeSerialize", + notes = "Test serialization of object with outer number type", + response = OuterComposite.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/composite", produces = { "*/*" } ) ResponseEntity fakeOuterCompositeSerialize( - -@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body); + @ApiParam(value = "Input composite as post body") @Valid @RequestBody(required = false) OuterComposite body + ); /** @@ -103,19 +117,24 @@ ResponseEntity fakeOuterCompositeSerialize( * @param body Input number as post body (optional) * @return Output number (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterNumberSerialize", + notes = "Test serialization of outer number types", + response = BigDecimal.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/number", produces = { "*/*" } ) ResponseEntity fakeOuterNumberSerialize( - -@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body); + @ApiParam(value = "Input number as post body") @Valid @RequestBody(required = false) BigDecimal body + ); /** @@ -125,19 +144,24 @@ ResponseEntity fakeOuterNumberSerialize( * @param body Input string as post body (optional) * @return Output string (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output string", response = String.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterStringSerialize", + notes = "Test serialization of outer string types", + response = String.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output string", response = String.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/string", produces = { "*/*" } ) ResponseEntity fakeOuterStringSerialize( - -@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body); + @ApiParam(value = "Input string as post body") @Valid @RequestBody(required = false) String body + ); /** @@ -147,19 +171,23 @@ ResponseEntity fakeOuterStringSerialize( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithFileSchema", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithFileSchema", + notes = "For this test, the body for this request much reference a schema named `File`." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-file-schema", consumes = { "application/json" } ) ResponseEntity testBodyWithFileSchema( - -@ApiParam(value = "", required = true ) @Valid @RequestBody FileSchemaTestClass body); + @ApiParam(value = "", required = true) @Valid @RequestBody FileSchemaTestClass body + ); /** @@ -169,21 +197,24 @@ ResponseEntity testBodyWithFileSchema( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithQueryParams", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithQueryParams", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-query-params", consumes = { "application/json" } ) - ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query - -, - -@ApiParam(value = "", required = true ) @Valid @RequestBody User body); + ResponseEntity testBodyWithQueryParams( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query, + @ApiParam(value = "", required = true) @Valid @RequestBody User body + ); /** @@ -193,11 +224,16 @@ ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", requ * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake" }, + value = "To test \"client\" model", + nickname = "testClientModel", + notes = "To test \"client\" model", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake", @@ -205,8 +241,8 @@ ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", requ consumes = { "application/json" } ) ResponseEntity testClientModel( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body); + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ); /** @@ -230,50 +266,40 @@ ResponseEntity testClientModel( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", authorizations = { - - @Authorization(value = "http_basic_test") - }, tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", + nickname = "testEndpointParameters", + notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", + authorizations = { + @Authorization(value = "http_basic_test") + } + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) ResponseEntity testEndpointParameters( - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, - -@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, - -@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, - -@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, - -@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary, - -@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date, - -@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime, - -@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, - -@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback); + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, + @ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, + @ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, + @ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, + @ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, + @ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, + @ApiParam(value = "None") @RequestPart(value = "binary", required = false) MultipartFile binary, + @ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, + @ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback + ); /** @@ -291,35 +317,31 @@ ResponseEntity testEndpointParameters( * @return Invalid request (status code 400) * or Not found (status code 404) */ - - @ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "To test enum parameters", + nickname = "testEnumParameters", + notes = "To test enum parameters" + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid request"), - - @ApiResponse(code = 404, message = "Not found") }) + @ApiResponse(code = 404, message = "Not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) ResponseEntity testEnumParameters( -@ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray -, -@ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString -,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray - -,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble - -, - -@ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, - -@ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString); + @ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray, + @ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString, + @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, + @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble, + @ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, + @ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString + ); /** @@ -334,28 +356,27 @@ ResponseEntity testEnumParameters( * @param int64Group Integer in group parameters (optional) * @return Someting wrong (status code 400) */ - - @ApiOperation(value = "Fake endpoint to test group parameters (optional)", nickname = "testGroupParameters", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 400, message = "Someting wrong") }) + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint to test group parameters (optional)", + nickname = "testGroupParameters", + notes = "Fake endpoint to test group parameters (optional)" + ) + @ApiResponses({ + @ApiResponse(code = 400, message = "Someting wrong") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/fake" ) - ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup - -, -@ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup -,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group - -,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup - -, -@ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup -,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group - -); + ResponseEntity testGroupParameters( + @NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup, + @ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup, + @NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group, + @ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup, + @ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup, + @ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group + ); /** @@ -364,19 +385,23 @@ ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required St * @param param request body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test inline additionalProperties", + nickname = "testInlineAdditionalProperties", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/inline-additionalProperties", consumes = { "application/json" } ) ResponseEntity testInlineAdditionalProperties( - -@ApiParam(value = "request body", required = true ) @Valid @RequestBody Map param); + @ApiParam(value = "request body", required = true) @Valid @RequestBody Map param + ); /** @@ -386,21 +411,24 @@ ResponseEntity testInlineAdditionalProperties( * @param param2 field2 (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test json serialization of form data", + nickname = "testJsonFormData", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake/jsonFormData", consumes = { "application/x-www-form-urlencoded" } ) ResponseEntity testJsonFormData( - -@ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, - -@ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2); + @ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, + @ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2 + ); /** @@ -414,26 +442,26 @@ ResponseEntity testJsonFormData( * @param context (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testQueryParameterCollectionFormat", + notes = "To test the collection format in query parameters" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/test-query-parameters" ) - ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context - -); + ResponseEntity testQueryParameterCollectionFormat( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context + ); /** @@ -444,27 +472,32 @@ ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value * @param additionalMetadata Additional data to pass to server (optional) * @return successful operation (status code 200) */ - - @ApiOperation(value = "uploads an image (required)", nickname = "uploadFileWithRequiredFile", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @ApiOperation( + tags = { "pet" }, + value = "uploads an image (required)", + nickname = "uploadFileWithRequiredFile", + 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 = "/fake/{petId}/uploadImageWithRequiredFile", produces = { "application/json" }, consumes = { "multipart/form-data" } ) - ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata); + ResponseEntity uploadFileWithRequiredFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "file to upload", required = true) @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata + ); } diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/FakeApiController.java index 34b4872f1857..9a5306056e85 100644 --- a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/FakeApiController.java @@ -50,8 +50,8 @@ public FakeApiController(NativeWebRequest request) { * @see FakeApi#createXmlItem */ public ResponseEntity createXmlItem( - -@ApiParam(value = "XmlItem Body", required = true ) @Valid @RequestBody XmlItem xmlItem) { + @ApiParam(value = "XmlItem Body", required = true) @Valid @RequestBody XmlItem xmlItem + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -65,8 +65,8 @@ public ResponseEntity createXmlItem( * @see FakeApi#fakeOuterBooleanSerialize */ public ResponseEntity fakeOuterBooleanSerialize( - -@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { + @ApiParam(value = "Input boolean as post body") @Valid @RequestBody(required = false) Boolean body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -80,8 +80,8 @@ public ResponseEntity fakeOuterBooleanSerialize( * @see FakeApi#fakeOuterCompositeSerialize */ public ResponseEntity fakeOuterCompositeSerialize( - -@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { + @ApiParam(value = "Input composite as post body") @Valid @RequestBody(required = false) OuterComposite body + ) { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) { String exampleString = "{ \"my_string\" : \"my_string\", \"my_number\" : 0.8008281904610115, \"my_boolean\" : true }"; @@ -102,8 +102,8 @@ public ResponseEntity fakeOuterCompositeSerialize( * @see FakeApi#fakeOuterNumberSerialize */ public ResponseEntity fakeOuterNumberSerialize( - -@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { + @ApiParam(value = "Input number as post body") @Valid @RequestBody(required = false) BigDecimal body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -117,8 +117,8 @@ public ResponseEntity fakeOuterNumberSerialize( * @see FakeApi#fakeOuterStringSerialize */ public ResponseEntity fakeOuterStringSerialize( - -@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { + @ApiParam(value = "Input string as post body") @Valid @RequestBody(required = false) String body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -132,8 +132,8 @@ public ResponseEntity fakeOuterStringSerialize( * @see FakeApi#testBodyWithFileSchema */ public ResponseEntity testBodyWithFileSchema( - -@ApiParam(value = "", required = true ) @Valid @RequestBody FileSchemaTestClass body) { + @ApiParam(value = "", required = true) @Valid @RequestBody FileSchemaTestClass body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -146,11 +146,10 @@ public ResponseEntity testBodyWithFileSchema( * @return Success (status code 200) * @see FakeApi#testBodyWithQueryParams */ - public ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query - -, - -@ApiParam(value = "", required = true ) @Valid @RequestBody User body) { + public ResponseEntity testBodyWithQueryParams( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query, + @ApiParam(value = "", required = true) @Valid @RequestBody User body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -164,8 +163,8 @@ public ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = " * @see FakeApi#testClientModel */ public ResponseEntity testClientModel( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { String exampleString = "{ \"client\" : \"client\" }"; @@ -200,34 +199,21 @@ public ResponseEntity testClientModel( * @see FakeApi#testEndpointParameters */ public ResponseEntity testEndpointParameters( - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, - -@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, - -@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, - -@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, - -@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary, - -@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date, - -@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime, - -@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, - -@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback) { + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, + @ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, + @ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, + @ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, + @ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, + @ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, + @ApiParam(value = "None") @RequestPart(value = "binary", required = false) MultipartFile binary, + @ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, + @ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -249,22 +235,15 @@ public ResponseEntity testEndpointParameters( * @see FakeApi#testEnumParameters */ public ResponseEntity testEnumParameters( -@ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray -, -@ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString -,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray - -,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble - -, - -@ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, - -@ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString) { + @ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray, + @ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString, + @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, + @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble, + @ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, + @ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -282,19 +261,14 @@ public ResponseEntity testEnumParameters( * @return Someting wrong (status code 400) * @see FakeApi#testGroupParameters */ - public ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup - -, -@ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup -,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group - -,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup - -, -@ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup -,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group - -) { + public ResponseEntity testGroupParameters( + @NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup, + @ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup, + @NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group, + @ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup, + @ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup, + @ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -307,8 +281,8 @@ public ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Requ * @see FakeApi#testInlineAdditionalProperties */ public ResponseEntity testInlineAdditionalProperties( - -@ApiParam(value = "request body", required = true ) @Valid @RequestBody Map param) { + @ApiParam(value = "request body", required = true) @Valid @RequestBody Map param + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -322,10 +296,9 @@ public ResponseEntity testInlineAdditionalProperties( * @see FakeApi#testJsonFormData */ public ResponseEntity testJsonFormData( - -@ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, - -@ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2) { + @ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, + @ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2 + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -342,17 +315,13 @@ public ResponseEntity testJsonFormData( * @return Success (status code 200) * @see FakeApi#testQueryParameterCollectionFormat */ - public ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context - -) { + public ResponseEntity testQueryParameterCollectionFormat( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -366,13 +335,11 @@ public ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiPara * @return successful operation (status code 200) * @see FakeApi#uploadFileWithRequiredFile */ - public ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata) { + public ResponseEntity uploadFileWithRequiredFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "file to upload", required = true) @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata + ) { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { String exampleString = "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\" }"; diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/FakeClassnameTestApi.java index 5a1ad6bccd14..fc833265a31c 100644 --- a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -28,14 +28,19 @@ public interface FakeClassnameTestApi { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test class name in snake case", nickname = "testClassname", notes = "To test class name in snake case", response = Client.class, authorizations = { - - @Authorization(value = "api_key_query") - }, tags={ "fake_classname_tags 123#$%^", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake_classname_tags 123#$%^" }, + value = "To test class name in snake case", + nickname = "testClassname", + notes = "To test class name in snake case", + response = Client.class, + authorizations = { + @Authorization(value = "api_key_query") + } + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake_classname_test", @@ -43,7 +48,7 @@ public interface FakeClassnameTestApi { consumes = { "application/json" } ) ResponseEntity testClassname( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body); + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ); } diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java index 80e92bdeaf15..b705c60d83bb 100644 --- a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java +++ b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java @@ -41,8 +41,8 @@ public FakeClassnameTestApiController(NativeWebRequest request) { * @see FakeClassnameTestApi#testClassname */ public ResponseEntity testClassname( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { String exampleString = "{ \"client\" : \"client\" }"; diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/PetApi.java index 8b0e0fb8f08f..a9dfd3946707 100644 --- a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/PetApi.java @@ -29,25 +29,30 @@ public interface PetApi { * @return successful operation (status code 200) * or Invalid input (status code 405) */ - - @ApiOperation(value = "Add a new pet to the store", nickname = "addPet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Add a new pet to the store", + nickname = "addPet", + 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 = 200, message = "successful operation"), - - @ApiResponse(code = 405, message = "Invalid input") }) + @ApiResponse(code = 405, message = "Invalid input") + }) @RequestMapping( method = RequestMethod.POST, value = "/pet", consumes = { "application/json", "application/xml" } ) ResponseEntity addPet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body); + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ); /** @@ -58,26 +63,30 @@ ResponseEntity addPet( * @return successful operation (status code 200) * or Invalid pet value (status code 400) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = 200, message = "successful operation"), - - @ApiResponse(code = 400, message = "Invalid pet value") }) + @ApiResponse(code = 400, message = "Invalid pet value") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/pet/{petId}" ) - ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId - -, -@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey -); + ResponseEntity deletePet( + @ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey + ); /** @@ -88,25 +97,33 @@ ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", required = * @return successful operation (status code 200) * or Invalid status value (status code 400) */ - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid status value") }) + @ApiResponse(code = 400, message = "Invalid status value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByStatus", produces = { "application/xml", "application/json" } ) - ResponseEntity> 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 status - -, @springfox.documentation.annotations.ApiIgnore final org.springframework.data.domain.Pageable pageable); + ResponseEntity> 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 status, + @springfox.documentation.annotations.ApiIgnore final org.springframework.data.domain.Pageable pageable + ); /** @@ -118,25 +135,33 @@ ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status va * or Invalid tag value (status code 400) * @deprecated */ - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid tag value") }) + @ApiResponse(code = 400, message = "Invalid tag value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByTags", produces = { "application/xml", "application/json" } ) - ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags - -, @springfox.documentation.annotations.ApiIgnore final org.springframework.data.domain.Pageable pageable); + ResponseEntity> findPetsByTags( + @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, + @springfox.documentation.annotations.ApiIgnore final org.springframework.data.domain.Pageable pageable + ); /** @@ -148,26 +173,29 @@ ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to fil * or Invalid ID supplied (status code 400) * or Pet not found (status code 404) */ - - @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { - - @Authorization(value = "api_key") - }, tags={ "pet", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Pet not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/{petId}", produces = { "application/xml", "application/json" } ) - ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId - -); + ResponseEntity getPetById( + @ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId + ); /** @@ -179,29 +207,32 @@ ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", required * or Pet not found (status code 404) * or Validation exception (status code 405) */ - - @ApiOperation(value = "Update an existing pet", nickname = "updatePet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Update an existing pet", + nickname = "updatePet", + 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 = 200, message = "successful operation"), - @ApiResponse(code = 400, message = "Invalid ID supplied"), - @ApiResponse(code = 404, message = "Pet not found"), - - @ApiResponse(code = 405, message = "Validation exception") }) + @ApiResponse(code = 405, message = "Validation exception") + }) @RequestMapping( method = RequestMethod.PUT, value = "/pet", consumes = { "application/json", "application/xml" } ) ResponseEntity updatePet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body); + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ); /** @@ -212,27 +243,31 @@ ResponseEntity updatePet( * @param status Updated status of the pet (optional) * @return Invalid input (status code 405) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 405, message = "Invalid input") }) + @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" } ) - ResponseEntity 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 @RequestPart(value = "name", required = false) String name, - -@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status); + ResponseEntity 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 @RequestPart(value = "name", required = false) String name, + @ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status + ); /** @@ -243,27 +278,32 @@ ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs t * @param file file to upload (optional) * @return successful operation (status code 200) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @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" } ) - ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file); + ResponseEntity uploadFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @ApiParam(value = "file to upload") @RequestPart(value = "file", required = false) MultipartFile file + ); } diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/PetApiController.java b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/PetApiController.java index 27bc49a0f61e..32b8031cf835 100644 --- a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/PetApiController.java +++ b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/PetApiController.java @@ -42,8 +42,8 @@ public PetApiController(NativeWebRequest request) { * @see PetApi#addPet */ public ResponseEntity addPet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -57,11 +57,10 @@ public ResponseEntity addPet( * or Invalid pet value (status code 400) * @see PetApi#deletePet */ - public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId - -, -@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey -) { + public ResponseEntity deletePet( + @ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -75,9 +74,10 @@ public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", requ * or Invalid status value (status code 400) * @see PetApi#findPetsByStatus */ - public ResponseEntity> 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 status - -, @springfox.documentation.annotations.ApiIgnore final Pageable pageable) { + public ResponseEntity> 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 status, + @springfox.documentation.annotations.ApiIgnore final Pageable pageable + ) { 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\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }"; @@ -104,9 +104,10 @@ public ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "St * @deprecated * @see PetApi#findPetsByTags */ - public ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags - -, @springfox.documentation.annotations.ApiIgnore final Pageable pageable) { + public ResponseEntity> findPetsByTags( + @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, + @springfox.documentation.annotations.ApiIgnore final Pageable pageable + ) { 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\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }"; @@ -133,9 +134,9 @@ public ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags * or Pet not found (status code 404) * @see PetApi#getPetById */ - public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId - -) { + public ResponseEntity getPetById( + @ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId + ) { 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\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }"; @@ -163,8 +164,8 @@ public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", r * @see PetApi#updatePet */ public ResponseEntity updatePet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -178,13 +179,11 @@ public ResponseEntity updatePet( * @return Invalid input (status code 405) * @see PetApi#updatePetWithForm */ - public ResponseEntity 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 @RequestPart(value = "name", required = false) String name, - -@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status) { + public ResponseEntity 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 @RequestPart(value = "name", required = false) String name, + @ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -198,13 +197,11 @@ public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that * @return successful operation (status code 200) * @see PetApi#uploadFile */ - public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { + public ResponseEntity uploadFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @ApiParam(value = "file to upload") @RequestPart(value = "file", required = false) MultipartFile file + ) { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { String exampleString = "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\" }"; diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/StoreApi.java index 36a33839249e..cbf52ad09926 100644 --- a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/StoreApi.java @@ -30,20 +30,23 @@ public interface StoreApi { * @return Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(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", tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/store/order/{order_id}" ) - ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId - -); + ResponseEntity deleteOrder( + @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId + ); /** @@ -52,20 +55,28 @@ ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs t * * @return successful operation (status code 200) */ - - @ApiOperation(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") - }, tags={ "store", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) + @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" } ) - ResponseEntity> getInventory(); + ResponseEntity> getInventory( + + ); /** @@ -77,23 +88,26 @@ ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs t * or Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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 generated 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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/store/order/{order_id}", produces = { "application/xml", "application/json" } ) - ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId - -); + ResponseEntity getOrderById( + @Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId + ); /** @@ -103,20 +117,24 @@ ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pe * @return successful operation (status code 200) * or Invalid Order (status code 400) */ - - @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid Order") + }) @RequestMapping( method = RequestMethod.POST, value = "/store/order", produces = { "application/xml", "application/json" } ) ResponseEntity placeOrder( - -@ApiParam(value = "order placed for purchasing the pet", required = true ) @Valid @RequestBody Order body); + @ApiParam(value = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order body + ); } diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/StoreApiController.java b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/StoreApiController.java index 392213709825..203faf80f73c 100644 --- a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/StoreApiController.java +++ b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/StoreApiController.java @@ -42,9 +42,9 @@ public StoreApiController(NativeWebRequest request) { * or Order not found (status code 404) * @see StoreApi#deleteOrder */ - public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId - -) { + public ResponseEntity deleteOrder( + @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -56,7 +56,9 @@ public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that * @return successful operation (status code 200) * @see StoreApi#getInventory */ - public ResponseEntity> getInventory() { + public ResponseEntity> getInventory( + + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -71,9 +73,9 @@ public ResponseEntity> getInventory() { * or Order not found (status code 404) * @see StoreApi#getOrderById */ - public ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId - -) { + public ResponseEntity getOrderById( + @Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId + ) { 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\" }"; @@ -99,8 +101,8 @@ public ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "I * @see StoreApi#placeOrder */ public ResponseEntity placeOrder( - -@ApiParam(value = "order placed for purchasing the pet", required = true ) @Valid @RequestBody Order body) { + @ApiParam(value = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order body + ) { 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\" }"; diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/UserApi.java b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/UserApi.java index 8e8a5fbd7a6c..205840928976 100644 --- a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/UserApi.java @@ -30,18 +30,22 @@ public interface UserApi { * @param body Created user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Create user", + nickname = "createUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user" ) ResponseEntity createUser( - -@ApiParam(value = "Created user object", required = true ) @Valid @RequestBody User body); + @ApiParam(value = "Created user object", required = true) @Valid @RequestBody User body + ); /** @@ -50,18 +54,22 @@ ResponseEntity createUser( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithArrayInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithArray" ) ResponseEntity createUsersWithArrayInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body); + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ); /** @@ -70,18 +78,22 @@ ResponseEntity createUsersWithArrayInput( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithListInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithList" ) ResponseEntity createUsersWithListInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body); + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ); /** @@ -92,20 +104,23 @@ ResponseEntity createUsersWithListInput( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Delete user", + nickname = "deleteUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/user/{username}" ) - ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username - -); + ResponseEntity deleteUser( + @ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username + ); /** @@ -116,23 +131,26 @@ ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be del * or Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/{username}", produces = { "application/xml", "application/json" } ) - ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username - -); + ResponseEntity getUserByName( + @ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username + ); /** @@ -143,23 +161,26 @@ ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be * @return successful operation (status code 200) * or Invalid username/password supplied (status code 400) */ - - @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid username/password supplied") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/login", produces = { "application/xml", "application/json" } ) - ResponseEntity loginUser(@NotNull @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 - -); + ResponseEntity loginUser( + @NotNull @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 + ); /** @@ -167,16 +188,22 @@ ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for l * * @return successful operation (status code 200) */ - - @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Logs out current logged in user session", + nickname = "logoutUser", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/logout" ) - ResponseEntity logoutUser(); + ResponseEntity logoutUser( + + ); /** @@ -188,21 +215,23 @@ ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for l * @return Invalid user supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Updated user", + nickname = "updateUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid user supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.PUT, value = "/user/{username}" ) - ResponseEntity 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 body); + ResponseEntity 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 body + ); } diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/UserApiController.java b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/UserApiController.java index a5441a06b657..224d437db48a 100644 --- a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/UserApiController.java +++ b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/UserApiController.java @@ -43,8 +43,8 @@ public UserApiController(NativeWebRequest request) { * @see UserApi#createUser */ public ResponseEntity createUser( - -@ApiParam(value = "Created user object", required = true ) @Valid @RequestBody User body) { + @ApiParam(value = "Created user object", required = true) @Valid @RequestBody User body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -57,8 +57,8 @@ public ResponseEntity createUser( * @see UserApi#createUsersWithArrayInput */ public ResponseEntity createUsersWithArrayInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -71,8 +71,8 @@ public ResponseEntity createUsersWithArrayInput( * @see UserApi#createUsersWithListInput */ public ResponseEntity createUsersWithListInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -86,9 +86,9 @@ public ResponseEntity createUsersWithListInput( * or User not found (status code 404) * @see UserApi#deleteUser */ - public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username - -) { + public ResponseEntity deleteUser( + @ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -102,9 +102,9 @@ public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to * or User not found (status code 404) * @see UserApi#getUserByName */ - public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username - -) { + public ResponseEntity getUserByName( + @ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username + ) { 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\" }"; @@ -130,11 +130,10 @@ public ResponseEntity getUserByName(@ApiParam(value = "The name that needs * or Invalid username/password supplied (status code 400) * @see UserApi#loginUser */ - public ResponseEntity loginUser(@NotNull @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 - -) { + public ResponseEntity loginUser( + @NotNull @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 new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -145,7 +144,9 @@ public ResponseEntity loginUser(@NotNull @ApiParam(value = "The user nam * @return successful operation (status code 200) * @see UserApi#logoutUser */ - public ResponseEntity logoutUser() { + public ResponseEntity logoutUser( + + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -160,11 +161,10 @@ public ResponseEntity logoutUser() { * or User not found (status code 404) * @see UserApi#updateUser */ - public ResponseEntity 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 body) { + public ResponseEntity 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 body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } diff --git a/samples/server/petstore/springboot-spring-pageable/pom.xml b/samples/server/petstore/springboot-spring-pageable/pom.xml index 38fbd7d57fa6..d0b710969509 100644 --- a/samples/server/petstore/springboot-spring-pageable/pom.xml +++ b/samples/server/petstore/springboot-spring-pageable/pom.xml @@ -9,12 +9,12 @@ 1.8 ${java.version} ${java.version} - 2.9.2 + 2.9.2 org.springframework.boot spring-boot-starter-parent - 2.3.3.RELEASE + 2.5.8 src/main/java @@ -22,13 +22,6 @@ org.springframework.boot spring-boot-maven-plugin - - - - repackage - - - @@ -45,16 +38,17 @@ io.springfox springfox-swagger2 - ${springfox-version} + ${springfox.version} + - io.springfox - springfox-swagger-ui - ${springfox-version} + com.google.code.findbugs + jsr305 + 3.0.2 - jakarta.xml.bind - jakarta.xml.bind-api + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml com.fasterxml.jackson.datatype @@ -63,12 +57,12 @@ org.openapitools jackson-databind-nullable - 0.2.1 + 0.2.2 - + - jakarta.validation - jakarta.validation-api + org.springframework.boot + spring-boot-starter-validation com.fasterxml.jackson.core diff --git a/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/api/AnotherFakeApi.java index e98182736edd..49d703d71daf 100644 --- a/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -36,11 +36,16 @@ default Optional getRequest() { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "$another-fake?" }, + value = "To test special tags", + nickname = "call123testSpecialTags", + notes = "To test special tags and operation ID starting with number", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/another-fake/dummy", @@ -48,8 +53,8 @@ default Optional getRequest() { consumes = { "application/json" } ) default ResponseEntity call123testSpecialTags( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/api/FakeApi.java index b163efb8b189..8c700d4f0f8e 100644 --- a/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/api/FakeApi.java @@ -45,19 +45,23 @@ default Optional getRequest() { * @param xmlItem XmlItem Body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "creates an XmlItem", nickname = "createXmlItem", notes = "this route creates an XmlItem", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "creates an XmlItem", + nickname = "createXmlItem", + notes = "this route creates an XmlItem" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/create_xml_item", consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } ) default ResponseEntity createXmlItem( - -@ApiParam(value = "XmlItem Body", required = true ) @Valid @RequestBody XmlItem xmlItem) { + @ApiParam(value = "XmlItem Body", required = true) @Valid @RequestBody XmlItem xmlItem + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -70,19 +74,24 @@ default ResponseEntity createXmlItem( * @param body Input boolean as post body (optional) * @return Output boolean (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterBooleanSerialize", + notes = "Test serialization of outer boolean types", + response = Boolean.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/boolean", produces = { "*/*" } ) default ResponseEntity fakeOuterBooleanSerialize( - -@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { + @ApiParam(value = "Input boolean as post body") @Valid @RequestBody(required = false) Boolean body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -95,19 +104,24 @@ default ResponseEntity fakeOuterBooleanSerialize( * @param body Input composite as post body (optional) * @return Output composite (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterCompositeSerialize", + notes = "Test serialization of object with outer number type", + response = OuterComposite.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/composite", produces = { "*/*" } ) default ResponseEntity fakeOuterCompositeSerialize( - -@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { + @ApiParam(value = "Input composite as post body") @Valid @RequestBody(required = false) OuterComposite body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) { @@ -129,19 +143,24 @@ default ResponseEntity fakeOuterCompositeSerialize( * @param body Input number as post body (optional) * @return Output number (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterNumberSerialize", + notes = "Test serialization of outer number types", + response = BigDecimal.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/number", produces = { "*/*" } ) default ResponseEntity fakeOuterNumberSerialize( - -@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { + @ApiParam(value = "Input number as post body") @Valid @RequestBody(required = false) BigDecimal body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -154,19 +173,24 @@ default ResponseEntity fakeOuterNumberSerialize( * @param body Input string as post body (optional) * @return Output string (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output string", response = String.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterStringSerialize", + notes = "Test serialization of outer string types", + response = String.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output string", response = String.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/string", produces = { "*/*" } ) default ResponseEntity fakeOuterStringSerialize( - -@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { + @ApiParam(value = "Input string as post body") @Valid @RequestBody(required = false) String body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -179,19 +203,23 @@ default ResponseEntity fakeOuterStringSerialize( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithFileSchema", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithFileSchema", + notes = "For this test, the body for this request much reference a schema named `File`." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-file-schema", consumes = { "application/json" } ) default ResponseEntity testBodyWithFileSchema( - -@ApiParam(value = "", required = true ) @Valid @RequestBody FileSchemaTestClass body) { + @ApiParam(value = "", required = true) @Valid @RequestBody FileSchemaTestClass body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -204,21 +232,24 @@ default ResponseEntity testBodyWithFileSchema( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithQueryParams", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithQueryParams", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-query-params", consumes = { "application/json" } ) - default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query - -, - -@ApiParam(value = "", required = true ) @Valid @RequestBody User body) { + default ResponseEntity testBodyWithQueryParams( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query, + @ApiParam(value = "", required = true) @Valid @RequestBody User body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -231,11 +262,16 @@ default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake" }, + value = "To test \"client\" model", + nickname = "testClientModel", + notes = "To test \"client\" model", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake", @@ -243,8 +279,8 @@ default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = consumes = { "application/json" } ) default ResponseEntity testClientModel( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -280,50 +316,40 @@ default ResponseEntity testClientModel( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", authorizations = { - - @Authorization(value = "http_basic_test") - }, tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", + nickname = "testEndpointParameters", + notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", + authorizations = { + @Authorization(value = "http_basic_test") + } + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testEndpointParameters( - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, - -@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, - -@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, - -@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, - -@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary, - -@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date, - -@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime, - -@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, - -@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback) { + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, + @ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, + @ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, + @ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, + @ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, + @ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, + @ApiParam(value = "None") @RequestPart(value = "binary", required = false) MultipartFile binary, + @ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, + @ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -344,35 +370,31 @@ default ResponseEntity testEndpointParameters( * @return Invalid request (status code 400) * or Not found (status code 404) */ - - @ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "To test enum parameters", + nickname = "testEnumParameters", + notes = "To test enum parameters" + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid request"), - - @ApiResponse(code = 404, message = "Not found") }) + @ApiResponse(code = 404, message = "Not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testEnumParameters( -@ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray -, -@ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString -,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray - -,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble - -, - -@ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, - -@ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString) { + @ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray, + @ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString, + @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, + @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble, + @ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, + @ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -390,28 +412,27 @@ default ResponseEntity testEnumParameters( * @param int64Group Integer in group parameters (optional) * @return Someting wrong (status code 400) */ - - @ApiOperation(value = "Fake endpoint to test group parameters (optional)", nickname = "testGroupParameters", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 400, message = "Someting wrong") }) + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint to test group parameters (optional)", + nickname = "testGroupParameters", + notes = "Fake endpoint to test group parameters (optional)" + ) + @ApiResponses({ + @ApiResponse(code = 400, message = "Someting wrong") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/fake" ) - default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup - -, -@ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup -,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group - -,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup - -, -@ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup -,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group - -) { + default ResponseEntity testGroupParameters( + @NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup, + @ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup, + @NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group, + @ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup, + @ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup, + @ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -423,19 +444,23 @@ default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Req * @param param request body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test inline additionalProperties", + nickname = "testInlineAdditionalProperties", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/inline-additionalProperties", consumes = { "application/json" } ) default ResponseEntity testInlineAdditionalProperties( - -@ApiParam(value = "request body", required = true ) @Valid @RequestBody Map param) { + @ApiParam(value = "request body", required = true) @Valid @RequestBody Map param + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -448,21 +473,24 @@ default ResponseEntity testInlineAdditionalProperties( * @param param2 field2 (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test json serialization of form data", + nickname = "testJsonFormData", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake/jsonFormData", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testJsonFormData( - -@ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, - -@ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2) { + @ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, + @ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2 + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -479,26 +507,26 @@ default ResponseEntity testJsonFormData( * @param context (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testQueryParameterCollectionFormat", + notes = "To test the collection format in query parameters" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/test-query-parameters" ) - default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context - -) { + default ResponseEntity testQueryParameterCollectionFormat( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -512,28 +540,33 @@ default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiPar * @param additionalMetadata Additional data to pass to server (optional) * @return successful operation (status code 200) */ - - @ApiOperation(value = "uploads an image (required)", nickname = "uploadFileWithRequiredFile", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @ApiOperation( + tags = { "pet" }, + value = "uploads an image (required)", + nickname = "uploadFileWithRequiredFile", + 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 = "/fake/{petId}/uploadImageWithRequiredFile", produces = { "application/json" }, consumes = { "multipart/form-data" } ) - default ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata) { + default ResponseEntity uploadFileWithRequiredFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "file to upload", required = true) @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/api/FakeClassnameTestApi.java index efa3146991d6..8c44f6c0992f 100644 --- a/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -36,14 +36,19 @@ default Optional getRequest() { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test class name in snake case", nickname = "testClassname", notes = "To test class name in snake case", response = Client.class, authorizations = { - - @Authorization(value = "api_key_query") - }, tags={ "fake_classname_tags 123#$%^", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake_classname_tags 123#$%^" }, + value = "To test class name in snake case", + nickname = "testClassname", + notes = "To test class name in snake case", + response = Client.class, + authorizations = { + @Authorization(value = "api_key_query") + } + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake_classname_test", @@ -51,8 +56,8 @@ default Optional getRequest() { consumes = { "application/json" } ) default ResponseEntity testClassname( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/api/PetApi.java index f768ce9be9b1..6e46b5c6f9d8 100644 --- a/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/api/PetApi.java @@ -37,25 +37,30 @@ default Optional getRequest() { * @return successful operation (status code 200) * or Invalid input (status code 405) */ - - @ApiOperation(value = "Add a new pet to the store", nickname = "addPet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Add a new pet to the store", + nickname = "addPet", + 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 = 200, message = "successful operation"), - - @ApiResponse(code = 405, message = "Invalid input") }) + @ApiResponse(code = 405, message = "Invalid input") + }) @RequestMapping( method = RequestMethod.POST, value = "/pet", consumes = { "application/json", "application/xml" } ) default ResponseEntity addPet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -69,26 +74,30 @@ default ResponseEntity addPet( * @return successful operation (status code 200) * or Invalid pet value (status code 400) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = 200, message = "successful operation"), - - @ApiResponse(code = 400, message = "Invalid pet value") }) + @ApiResponse(code = 400, message = "Invalid pet value") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/pet/{petId}" ) - default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId - -, -@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey -) { + default ResponseEntity deletePet( + @ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -102,25 +111,33 @@ default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", req * @return successful operation (status code 200) * or Invalid status value (status code 400) */ - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid status value") }) + @ApiResponse(code = 400, message = "Invalid status value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByStatus", produces = { "application/xml", "application/json" } ) - default ResponseEntity> 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 status - -, @springfox.documentation.annotations.ApiIgnore final org.springframework.data.domain.Pageable pageable) { + default ResponseEntity> 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 status, + @springfox.documentation.annotations.ApiIgnore final org.springframework.data.domain.Pageable pageable + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -149,25 +166,33 @@ default ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "S * or Invalid tag value (status code 400) * @deprecated */ - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid tag value") }) + @ApiResponse(code = 400, message = "Invalid tag value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByTags", produces = { "application/xml", "application/json" } ) - default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags - -, @springfox.documentation.annotations.ApiIgnore final org.springframework.data.domain.Pageable pageable) { + default ResponseEntity> findPetsByTags( + @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, + @springfox.documentation.annotations.ApiIgnore final org.springframework.data.domain.Pageable pageable + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -196,26 +221,29 @@ default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tag * or Invalid ID supplied (status code 400) * or Pet not found (status code 404) */ - - @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { - - @Authorization(value = "api_key") - }, tags={ "pet", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Pet not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/{petId}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId - -) { + default ResponseEntity getPetById( + @ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -244,29 +272,32 @@ default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", * or Pet not found (status code 404) * or Validation exception (status code 405) */ - - @ApiOperation(value = "Update an existing pet", nickname = "updatePet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Update an existing pet", + nickname = "updatePet", + 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 = 200, message = "successful operation"), - @ApiResponse(code = 400, message = "Invalid ID supplied"), - @ApiResponse(code = 404, message = "Pet not found"), - - @ApiResponse(code = 405, message = "Validation exception") }) + @ApiResponse(code = 405, message = "Validation exception") + }) @RequestMapping( method = RequestMethod.PUT, value = "/pet", consumes = { "application/json", "application/xml" } ) default ResponseEntity updatePet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -280,27 +311,31 @@ default ResponseEntity updatePet( * @param status Updated status of the pet (optional) * @return Invalid input (status code 405) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 405, message = "Invalid input") }) + @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" } ) - default ResponseEntity 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 @RequestPart(value = "name", required = false) String name, - -@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status) { + default ResponseEntity 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 @RequestPart(value = "name", required = false) String name, + @ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -314,28 +349,33 @@ default ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that * @param file file to upload (optional) * @return successful operation (status code 200) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @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" } ) - default ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { + default ResponseEntity uploadFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @ApiParam(value = "file to upload") @RequestPart(value = "file", required = false) MultipartFile file + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/api/StoreApi.java index 1d86f2d6fb0a..84abf7191820 100644 --- a/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/api/StoreApi.java @@ -38,20 +38,23 @@ default Optional getRequest() { * @return Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(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", tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/store/order/{order_id}" ) - default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId - -) { + default ResponseEntity deleteOrder( + @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -63,20 +66,28 @@ default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that * * @return successful operation (status code 200) */ - - @ApiOperation(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") - }, tags={ "store", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) + @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" } ) - default ResponseEntity> getInventory() { + default ResponseEntity> getInventory( + + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -91,23 +102,26 @@ default ResponseEntity> getInventory() { * or Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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 generated 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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/store/order/{order_id}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId - -) { + default ResponseEntity getOrderById( + @Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -134,21 +148,25 @@ default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = " * @return successful operation (status code 200) * or Invalid Order (status code 400) */ - - @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid Order") + }) @RequestMapping( method = RequestMethod.POST, value = "/store/order", produces = { "application/xml", "application/json" } ) default ResponseEntity placeOrder( - -@ApiParam(value = "order placed for purchasing the pet", required = true ) @Valid @RequestBody Order body) { + @ApiParam(value = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/api/UserApi.java b/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/api/UserApi.java index 8454fafb3209..86fcdae11023 100644 --- a/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/api/UserApi.java @@ -38,18 +38,22 @@ default Optional getRequest() { * @param body Created user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Create user", + nickname = "createUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user" ) default ResponseEntity createUser( - -@ApiParam(value = "Created user object", required = true ) @Valid @RequestBody User body) { + @ApiParam(value = "Created user object", required = true) @Valid @RequestBody User body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -61,18 +65,22 @@ default ResponseEntity createUser( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithArrayInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithArray" ) default ResponseEntity createUsersWithArrayInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -84,18 +92,22 @@ default ResponseEntity createUsersWithArrayInput( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithListInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithList" ) default ResponseEntity createUsersWithListInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -109,20 +121,23 @@ default ResponseEntity createUsersWithListInput( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Delete user", + nickname = "deleteUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/user/{username}" ) - default ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username - -) { + default ResponseEntity deleteUser( + @ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -136,23 +151,26 @@ default ResponseEntity deleteUser(@ApiParam(value = "The name that needs t * or Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/{username}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username - -) { + default ResponseEntity getUserByName( + @ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -180,23 +198,26 @@ default ResponseEntity getUserByName(@ApiParam(value = "The name that need * @return successful operation (status code 200) * or Invalid username/password supplied (status code 400) */ - - @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid username/password supplied") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/login", produces = { "application/xml", "application/json" } ) - default ResponseEntity loginUser(@NotNull @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 - -) { + default ResponseEntity loginUser( + @NotNull @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 new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -207,16 +228,22 @@ default ResponseEntity loginUser(@NotNull @ApiParam(value = "The user na * * @return successful operation (status code 200) */ - - @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Logs out current logged in user session", + nickname = "logoutUser", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/logout" ) - default ResponseEntity logoutUser() { + default ResponseEntity logoutUser( + + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -231,22 +258,24 @@ default ResponseEntity logoutUser() { * @return Invalid user supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Updated user", + nickname = "updateUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid user supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.PUT, value = "/user/{username}" ) - default ResponseEntity 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 body) { + default ResponseEntity 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 body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } diff --git a/samples/server/petstore/springboot-useoptional/pom.xml b/samples/server/petstore/springboot-useoptional/pom.xml index bbfc822dfbac..947ef54fb7eb 100644 --- a/samples/server/petstore/springboot-useoptional/pom.xml +++ b/samples/server/petstore/springboot-useoptional/pom.xml @@ -9,12 +9,12 @@ 1.8 ${java.version} ${java.version} - 2.9.2 + 2.9.2 org.springframework.boot spring-boot-starter-parent - 2.3.3.RELEASE + 2.5.8 src/main/java @@ -22,13 +22,6 @@ org.springframework.boot spring-boot-maven-plugin - - - - repackage - - - @@ -45,16 +38,17 @@ io.springfox springfox-swagger2 - ${springfox-version} + ${springfox.version} + - io.springfox - springfox-swagger-ui - ${springfox-version} + com.google.code.findbugs + jsr305 + 3.0.2 - jakarta.xml.bind - jakarta.xml.bind-api + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml com.fasterxml.jackson.datatype @@ -63,12 +57,12 @@ org.openapitools jackson-databind-nullable - 0.2.1 + 0.2.2 - + - jakarta.validation - jakarta.validation-api + org.springframework.boot + spring-boot-starter-validation com.fasterxml.jackson.core diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/AnotherFakeApi.java index e98182736edd..49d703d71daf 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -36,11 +36,16 @@ default Optional getRequest() { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "$another-fake?" }, + value = "To test special tags", + nickname = "call123testSpecialTags", + notes = "To test special tags and operation ID starting with number", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/another-fake/dummy", @@ -48,8 +53,8 @@ default Optional getRequest() { consumes = { "application/json" } ) default ResponseEntity call123testSpecialTags( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApi.java index e7dd6d004e3d..64b57f6c9c51 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApi.java @@ -45,19 +45,23 @@ default Optional getRequest() { * @param xmlItem XmlItem Body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "creates an XmlItem", nickname = "createXmlItem", notes = "this route creates an XmlItem", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "creates an XmlItem", + nickname = "createXmlItem", + notes = "this route creates an XmlItem" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/create_xml_item", consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } ) default ResponseEntity createXmlItem( - -@ApiParam(value = "XmlItem Body", required = true ) @Valid @RequestBody XmlItem xmlItem) { + @ApiParam(value = "XmlItem Body", required = true) @Valid @RequestBody XmlItem xmlItem + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -70,19 +74,24 @@ default ResponseEntity createXmlItem( * @param body Input boolean as post body (optional) * @return Output boolean (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterBooleanSerialize", + notes = "Test serialization of outer boolean types", + response = Boolean.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/boolean", produces = { "*/*" } ) default ResponseEntity fakeOuterBooleanSerialize( - -@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { + @ApiParam(value = "Input boolean as post body") @Valid @RequestBody(required = false) Boolean body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -95,19 +104,24 @@ default ResponseEntity fakeOuterBooleanSerialize( * @param body Input composite as post body (optional) * @return Output composite (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterCompositeSerialize", + notes = "Test serialization of object with outer number type", + response = OuterComposite.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/composite", produces = { "*/*" } ) default ResponseEntity fakeOuterCompositeSerialize( - -@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { + @ApiParam(value = "Input composite as post body") @Valid @RequestBody(required = false) OuterComposite body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) { @@ -129,19 +143,24 @@ default ResponseEntity fakeOuterCompositeSerialize( * @param body Input number as post body (optional) * @return Output number (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterNumberSerialize", + notes = "Test serialization of outer number types", + response = BigDecimal.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/number", produces = { "*/*" } ) default ResponseEntity fakeOuterNumberSerialize( - -@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { + @ApiParam(value = "Input number as post body") @Valid @RequestBody(required = false) BigDecimal body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -154,19 +173,24 @@ default ResponseEntity fakeOuterNumberSerialize( * @param body Input string as post body (optional) * @return Output string (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output string", response = String.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterStringSerialize", + notes = "Test serialization of outer string types", + response = String.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output string", response = String.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/string", produces = { "*/*" } ) default ResponseEntity fakeOuterStringSerialize( - -@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { + @ApiParam(value = "Input string as post body") @Valid @RequestBody(required = false) String body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -179,19 +203,23 @@ default ResponseEntity fakeOuterStringSerialize( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithFileSchema", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithFileSchema", + notes = "For this test, the body for this request much reference a schema named `File`." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-file-schema", consumes = { "application/json" } ) default ResponseEntity testBodyWithFileSchema( - -@ApiParam(value = "", required = true ) @Valid @RequestBody FileSchemaTestClass body) { + @ApiParam(value = "", required = true) @Valid @RequestBody FileSchemaTestClass body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -204,21 +232,24 @@ default ResponseEntity testBodyWithFileSchema( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithQueryParams", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithQueryParams", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-query-params", consumes = { "application/json" } ) - default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query - -, - -@ApiParam(value = "", required = true ) @Valid @RequestBody User body) { + default ResponseEntity testBodyWithQueryParams( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query, + @ApiParam(value = "", required = true) @Valid @RequestBody User body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -231,11 +262,16 @@ default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake" }, + value = "To test \"client\" model", + nickname = "testClientModel", + notes = "To test \"client\" model", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake", @@ -243,8 +279,8 @@ default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = consumes = { "application/json" } ) default ResponseEntity testClientModel( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -280,50 +316,40 @@ default ResponseEntity testClientModel( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", authorizations = { - - @Authorization(value = "http_basic_test") - }, tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + nickname = "testEndpointParameters", + notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + authorizations = { + @Authorization(value = "http_basic_test") + } + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testEndpointParameters( - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, - -@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, - -@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, - -@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, - -@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary, - -@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date, - -@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime, - -@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, - -@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback) { + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, + @ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, + @ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, + @ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, + @ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, + @ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, + @ApiParam(value = "None") @RequestPart(value = "binary", required = false) MultipartFile binary, + @ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, + @ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -344,35 +370,31 @@ default ResponseEntity testEndpointParameters( * @return Invalid request (status code 400) * or Not found (status code 404) */ - - @ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "To test enum parameters", + nickname = "testEnumParameters", + notes = "To test enum parameters" + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid request"), - - @ApiResponse(code = 404, message = "Not found") }) + @ApiResponse(code = 404, message = "Not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testEnumParameters( -@ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) Optional> enumHeaderStringArray -, -@ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) Optional enumHeaderString -,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) Optional> enumQueryStringArray - -,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") Optional enumQueryString - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Optional enumQueryInteger - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Optional enumQueryDouble - -, - -@ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, - -@ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString) { + @ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) Optional> enumHeaderStringArray, + @ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) Optional enumHeaderString, + @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) Optional> enumQueryStringArray, + @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") Optional enumQueryString, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Optional enumQueryInteger, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Optional enumQueryDouble, + @ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, + @ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -390,28 +412,27 @@ default ResponseEntity testEnumParameters( * @param int64Group Integer in group parameters (optional) * @return Someting wrong (status code 400) */ - - @ApiOperation(value = "Fake endpoint to test group parameters (optional)", nickname = "testGroupParameters", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 400, message = "Someting wrong") }) + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint to test group parameters (optional)", + nickname = "testGroupParameters", + notes = "Fake endpoint to test group parameters (optional)" + ) + @ApiResponses({ + @ApiResponse(code = 400, message = "Someting wrong") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/fake" ) - default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup - -, -@ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup -,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group - -,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Optional stringGroup - -, -@ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Optional booleanGroup -,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Optional int64Group - -) { + default ResponseEntity testGroupParameters( + @NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup, + @ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup, + @NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group, + @ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Optional stringGroup, + @ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Optional booleanGroup, + @ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Optional int64Group + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -423,19 +444,23 @@ default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Req * @param param request body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test inline additionalProperties", + nickname = "testInlineAdditionalProperties", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/inline-additionalProperties", consumes = { "application/json" } ) default ResponseEntity testInlineAdditionalProperties( - -@ApiParam(value = "request body", required = true ) @Valid @RequestBody Map param) { + @ApiParam(value = "request body", required = true) @Valid @RequestBody Map param + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -448,21 +473,24 @@ default ResponseEntity testInlineAdditionalProperties( * @param param2 field2 (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test json serialization of form data", + nickname = "testJsonFormData", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake/jsonFormData", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testJsonFormData( - -@ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, - -@ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2) { + @ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, + @ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2 + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -479,26 +507,26 @@ default ResponseEntity testJsonFormData( * @param context (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testQueryParameterCollectionFormat", + notes = "To test the collection format in query parameters" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/test-query-parameters" ) - default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context - -) { + default ResponseEntity testQueryParameterCollectionFormat( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -512,28 +540,33 @@ default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiPar * @param additionalMetadata Additional data to pass to server (optional) * @return successful operation (status code 200) */ - - @ApiOperation(value = "uploads an image (required)", nickname = "uploadFileWithRequiredFile", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @ApiOperation( + tags = { "pet" }, + value = "uploads an image (required)", + nickname = "uploadFileWithRequiredFile", + 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 = "/fake/{petId}/uploadImageWithRequiredFile", produces = { "application/json" }, consumes = { "multipart/form-data" } ) - default ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata) { + default ResponseEntity uploadFileWithRequiredFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "file to upload", required = true) @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeClassnameTestApi.java index efa3146991d6..8c44f6c0992f 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -36,14 +36,19 @@ default Optional getRequest() { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test class name in snake case", nickname = "testClassname", notes = "To test class name in snake case", response = Client.class, authorizations = { - - @Authorization(value = "api_key_query") - }, tags={ "fake_classname_tags 123#$%^", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake_classname_tags 123#$%^" }, + value = "To test class name in snake case", + nickname = "testClassname", + notes = "To test class name in snake case", + response = Client.class, + authorizations = { + @Authorization(value = "api_key_query") + } + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake_classname_test", @@ -51,8 +56,8 @@ default Optional getRequest() { consumes = { "application/json" } ) default ResponseEntity testClassname( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/PetApi.java index b14a6c3e74f5..18d9c9a2ca74 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/PetApi.java @@ -38,25 +38,30 @@ default Optional getRequest() { * @return successful operation (status code 200) * or Invalid input (status code 405) */ - - @ApiOperation(value = "Add a new pet to the store", nickname = "addPet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Add a new pet to the store", + nickname = "addPet", + 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 = 200, message = "successful operation"), - - @ApiResponse(code = 405, message = "Invalid input") }) + @ApiResponse(code = 405, message = "Invalid input") + }) @RequestMapping( method = RequestMethod.POST, value = "/pet", consumes = { "application/json", "application/xml" } ) default ResponseEntity addPet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -70,26 +75,30 @@ default ResponseEntity addPet( * @return successful operation (status code 200) * or Invalid pet value (status code 400) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = 200, message = "successful operation"), - - @ApiResponse(code = 400, message = "Invalid pet value") }) + @ApiResponse(code = 400, message = "Invalid pet value") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/pet/{petId}" ) - default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId - -, -@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) Optional apiKey -) { + default ResponseEntity deletePet( + @ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "") @RequestHeader(value = "api_key", required = false) Optional apiKey + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -103,25 +112,32 @@ default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", req * @return successful operation (status code 200) * or Invalid status value (status code 400) */ - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid status value") }) + @ApiResponse(code = 400, message = "Invalid status value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByStatus", produces = { "application/xml", "application/json" } ) - default ResponseEntity> 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 status - -) { + default ResponseEntity> 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 status + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -150,25 +166,32 @@ default ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "S * or Invalid tag value (status code 400) * @deprecated */ - - @ApiOperation(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 = "Set", authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "Set", + 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, responseContainer = "Set"), - - @ApiResponse(code = 400, message = "Invalid tag value") }) + @ApiResponse(code = 400, message = "Invalid tag value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByTags", produces = { "application/xml", "application/json" } ) - default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags - -) { + default ResponseEntity> findPetsByTags( + @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -197,26 +220,29 @@ default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags * or Invalid ID supplied (status code 400) * or Pet not found (status code 404) */ - - @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { - - @Authorization(value = "api_key") - }, tags={ "pet", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Pet not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/{petId}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId - -) { + default ResponseEntity getPetById( + @ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -245,29 +271,32 @@ default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", * or Pet not found (status code 404) * or Validation exception (status code 405) */ - - @ApiOperation(value = "Update an existing pet", nickname = "updatePet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Update an existing pet", + nickname = "updatePet", + 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 = 200, message = "successful operation"), - @ApiResponse(code = 400, message = "Invalid ID supplied"), - @ApiResponse(code = 404, message = "Pet not found"), - - @ApiResponse(code = 405, message = "Validation exception") }) + @ApiResponse(code = 405, message = "Validation exception") + }) @RequestMapping( method = RequestMethod.PUT, value = "/pet", consumes = { "application/json", "application/xml" } ) default ResponseEntity updatePet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -281,27 +310,31 @@ default ResponseEntity updatePet( * @param status Updated status of the pet (optional) * @return Invalid input (status code 405) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 405, message = "Invalid input") }) + @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" } ) - default ResponseEntity 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 @RequestPart(value = "name", required = false) String name, - -@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status) { + default ResponseEntity 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 @RequestPart(value = "name", required = false) String name, + @ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -315,28 +348,33 @@ default ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that * @param file file to upload (optional) * @return successful operation (status code 200) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @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" } ) - default ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { + default ResponseEntity uploadFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @ApiParam(value = "file to upload") @RequestPart(value = "file", required = false) MultipartFile file + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/StoreApi.java index 1d86f2d6fb0a..84abf7191820 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/StoreApi.java @@ -38,20 +38,23 @@ default Optional getRequest() { * @return Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(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", tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/store/order/{order_id}" ) - default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId - -) { + default ResponseEntity deleteOrder( + @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -63,20 +66,28 @@ default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that * * @return successful operation (status code 200) */ - - @ApiOperation(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") - }, tags={ "store", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) + @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" } ) - default ResponseEntity> getInventory() { + default ResponseEntity> getInventory( + + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -91,23 +102,26 @@ default ResponseEntity> getInventory() { * or Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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 generated 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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/store/order/{order_id}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId - -) { + default ResponseEntity getOrderById( + @Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -134,21 +148,25 @@ default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = " * @return successful operation (status code 200) * or Invalid Order (status code 400) */ - - @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid Order") + }) @RequestMapping( method = RequestMethod.POST, value = "/store/order", produces = { "application/xml", "application/json" } ) default ResponseEntity placeOrder( - -@ApiParam(value = "order placed for purchasing the pet", required = true ) @Valid @RequestBody Order body) { + @ApiParam(value = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/UserApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/UserApi.java index 8454fafb3209..86fcdae11023 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/UserApi.java @@ -38,18 +38,22 @@ default Optional getRequest() { * @param body Created user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Create user", + nickname = "createUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user" ) default ResponseEntity createUser( - -@ApiParam(value = "Created user object", required = true ) @Valid @RequestBody User body) { + @ApiParam(value = "Created user object", required = true) @Valid @RequestBody User body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -61,18 +65,22 @@ default ResponseEntity createUser( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithArrayInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithArray" ) default ResponseEntity createUsersWithArrayInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -84,18 +92,22 @@ default ResponseEntity createUsersWithArrayInput( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithListInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithList" ) default ResponseEntity createUsersWithListInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -109,20 +121,23 @@ default ResponseEntity createUsersWithListInput( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Delete user", + nickname = "deleteUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/user/{username}" ) - default ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username - -) { + default ResponseEntity deleteUser( + @ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -136,23 +151,26 @@ default ResponseEntity deleteUser(@ApiParam(value = "The name that needs t * or Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/{username}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username - -) { + default ResponseEntity getUserByName( + @ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -180,23 +198,26 @@ default ResponseEntity getUserByName(@ApiParam(value = "The name that need * @return successful operation (status code 200) * or Invalid username/password supplied (status code 400) */ - - @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid username/password supplied") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/login", produces = { "application/xml", "application/json" } ) - default ResponseEntity loginUser(@NotNull @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 - -) { + default ResponseEntity loginUser( + @NotNull @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 new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -207,16 +228,22 @@ default ResponseEntity loginUser(@NotNull @ApiParam(value = "The user na * * @return successful operation (status code 200) */ - - @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Logs out current logged in user session", + nickname = "logoutUser", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/logout" ) - default ResponseEntity logoutUser() { + default ResponseEntity logoutUser( + + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -231,22 +258,24 @@ default ResponseEntity logoutUser() { * @return Invalid user supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Updated user", + nickname = "updateUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid user supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.PUT, value = "/user/{username}" ) - default ResponseEntity 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 body) { + default ResponseEntity 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 body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } diff --git a/samples/server/petstore/springboot-virtualan/pom.xml b/samples/server/petstore/springboot-virtualan/pom.xml index 920b8d600891..dd52e11911b6 100644 --- a/samples/server/petstore/springboot-virtualan/pom.xml +++ b/samples/server/petstore/springboot-virtualan/pom.xml @@ -9,12 +9,12 @@ 1.8 ${java.version} ${java.version} - 2.9.2 + 2.9.2 org.springframework.boot spring-boot-starter-parent - 2.3.3.RELEASE + 2.5.8 src/main/java @@ -22,13 +22,6 @@ org.springframework.boot spring-boot-maven-plugin - - - - repackage - - - @@ -45,16 +38,17 @@ io.springfox springfox-swagger2 - ${springfox-version} + ${springfox.version} + - io.springfox - springfox-swagger-ui - ${springfox-version} + com.google.code.findbugs + jsr305 + 3.0.2 - jakarta.xml.bind - jakarta.xml.bind-api + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml com.fasterxml.jackson.datatype @@ -63,12 +57,12 @@ org.openapitools jackson-databind-nullable - 0.2.1 + 0.2.2 - + - jakarta.validation - jakarta.validation-api + org.springframework.boot + spring-boot-starter-validation diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/AnotherFakeApi.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/AnotherFakeApi.java index 106d9e0b671c..f4fbd0689463 100644 --- a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/AnotherFakeApi.java @@ -40,11 +40,16 @@ default Optional getRequest() { * @return successful operation (status code 200) */ @ApiVirtual - - @ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "$another-fake?" }, + value = "To test special tags", + nickname = "call123testSpecialTags", + notes = "To test special tags and operation ID starting with number", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/another-fake/dummy", @@ -52,8 +57,8 @@ default Optional getRequest() { consumes = { "application/json" } ) default ResponseEntity call123testSpecialTags( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeApi.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeApi.java index 1fefce44d06f..ba5291df0330 100644 --- a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeApi.java +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeApi.java @@ -49,19 +49,23 @@ default Optional getRequest() { * @return successful operation (status code 200) */ @ApiVirtual - - @ApiOperation(value = "creates an XmlItem", nickname = "createXmlItem", notes = "this route creates an XmlItem", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "creates an XmlItem", + nickname = "createXmlItem", + notes = "this route creates an XmlItem" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/create_xml_item", consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } ) default ResponseEntity createXmlItem( - -@ApiParam(value = "XmlItem Body", required = true ) @Valid @RequestBody XmlItem xmlItem) { + @ApiParam(value = "XmlItem Body", required = true) @Valid @RequestBody XmlItem xmlItem + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -75,19 +79,24 @@ default ResponseEntity createXmlItem( * @return Output boolean (status code 200) */ @ApiVirtual - - @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterBooleanSerialize", + notes = "Test serialization of outer boolean types", + response = Boolean.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/boolean", produces = { "*/*" } ) default ResponseEntity fakeOuterBooleanSerialize( - -@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { + @ApiParam(value = "Input boolean as post body") @Valid @RequestBody(required = false) Boolean body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -101,19 +110,24 @@ default ResponseEntity fakeOuterBooleanSerialize( * @return Output composite (status code 200) */ @ApiVirtual - - @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterCompositeSerialize", + notes = "Test serialization of object with outer number type", + response = OuterComposite.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/composite", produces = { "*/*" } ) default ResponseEntity fakeOuterCompositeSerialize( - -@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { + @ApiParam(value = "Input composite as post body") @Valid @RequestBody(required = false) OuterComposite body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) { @@ -136,19 +150,24 @@ default ResponseEntity fakeOuterCompositeSerialize( * @return Output number (status code 200) */ @ApiVirtual - - @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterNumberSerialize", + notes = "Test serialization of outer number types", + response = BigDecimal.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/number", produces = { "*/*" } ) default ResponseEntity fakeOuterNumberSerialize( - -@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { + @ApiParam(value = "Input number as post body") @Valid @RequestBody(required = false) BigDecimal body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -162,19 +181,24 @@ default ResponseEntity fakeOuterNumberSerialize( * @return Output string (status code 200) */ @ApiVirtual - - @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output string", response = String.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterStringSerialize", + notes = "Test serialization of outer string types", + response = String.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output string", response = String.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/string", produces = { "*/*" } ) default ResponseEntity fakeOuterStringSerialize( - -@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { + @ApiParam(value = "Input string as post body") @Valid @RequestBody(required = false) String body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -188,19 +212,23 @@ default ResponseEntity fakeOuterStringSerialize( * @return Success (status code 200) */ @ApiVirtual - - @ApiOperation(value = "", nickname = "testBodyWithFileSchema", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithFileSchema", + notes = "For this test, the body for this request much reference a schema named `File`." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-file-schema", consumes = { "application/json" } ) default ResponseEntity testBodyWithFileSchema( - -@ApiParam(value = "", required = true ) @Valid @RequestBody FileSchemaTestClass body) { + @ApiParam(value = "", required = true) @Valid @RequestBody FileSchemaTestClass body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -214,21 +242,24 @@ default ResponseEntity testBodyWithFileSchema( * @return Success (status code 200) */ @ApiVirtual - - @ApiOperation(value = "", nickname = "testBodyWithQueryParams", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithQueryParams", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-query-params", consumes = { "application/json" } ) - default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query - -, - -@ApiParam(value = "", required = true ) @Valid @RequestBody User body) { + default ResponseEntity testBodyWithQueryParams( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query, + @ApiParam(value = "", required = true) @Valid @RequestBody User body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -242,11 +273,16 @@ default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = * @return successful operation (status code 200) */ @ApiVirtual - - @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake" }, + value = "To test \"client\" model", + nickname = "testClientModel", + notes = "To test \"client\" model", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake", @@ -254,8 +290,8 @@ default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = consumes = { "application/json" } ) default ResponseEntity testClientModel( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -292,50 +328,40 @@ default ResponseEntity testClientModel( * or User not found (status code 404) */ @ApiVirtual - - @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", authorizations = { - - @Authorization(value = "http_basic_test") - }, tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + nickname = "testEndpointParameters", + notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + authorizations = { + @Authorization(value = "http_basic_test") + } + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testEndpointParameters( - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, - -@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, - -@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, - -@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, - -@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary, - -@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date, - -@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime, - -@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, - -@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback) { + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, + @ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, + @ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, + @ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, + @ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, + @ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, + @ApiParam(value = "None") @RequestPart(value = "binary", required = false) MultipartFile binary, + @ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, + @ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -357,35 +383,31 @@ default ResponseEntity testEndpointParameters( * or Not found (status code 404) */ @ApiVirtual - - @ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "To test enum parameters", + nickname = "testEnumParameters", + notes = "To test enum parameters" + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid request"), - - @ApiResponse(code = 404, message = "Not found") }) + @ApiResponse(code = 404, message = "Not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testEnumParameters( -@ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray -, -@ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString -,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray - -,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble - -, - -@ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, - -@ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString) { + @ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray, + @ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString, + @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, + @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble, + @ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, + @ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -404,28 +426,27 @@ default ResponseEntity testEnumParameters( * @return Someting wrong (status code 400) */ @ApiVirtual - - @ApiOperation(value = "Fake endpoint to test group parameters (optional)", nickname = "testGroupParameters", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 400, message = "Someting wrong") }) + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint to test group parameters (optional)", + nickname = "testGroupParameters", + notes = "Fake endpoint to test group parameters (optional)" + ) + @ApiResponses({ + @ApiResponse(code = 400, message = "Someting wrong") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/fake" ) - default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup - -, -@ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup -,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group - -,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup - -, -@ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup -,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group - -) { + default ResponseEntity testGroupParameters( + @NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup, + @ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup, + @NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group, + @ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup, + @ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup, + @ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -438,19 +459,23 @@ default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Req * @return successful operation (status code 200) */ @ApiVirtual - - @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test inline additionalProperties", + nickname = "testInlineAdditionalProperties", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/inline-additionalProperties", consumes = { "application/json" } ) default ResponseEntity testInlineAdditionalProperties( - -@ApiParam(value = "request body", required = true ) @Valid @RequestBody Map param) { + @ApiParam(value = "request body", required = true) @Valid @RequestBody Map param + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -464,21 +489,24 @@ default ResponseEntity testInlineAdditionalProperties( * @return successful operation (status code 200) */ @ApiVirtual - - @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test json serialization of form data", + nickname = "testJsonFormData", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake/jsonFormData", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testJsonFormData( - -@ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, - -@ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2) { + @ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, + @ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2 + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -496,26 +524,26 @@ default ResponseEntity testJsonFormData( * @return Success (status code 200) */ @ApiVirtual - - @ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testQueryParameterCollectionFormat", + notes = "To test the collection format in query parameters" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/test-query-parameters" ) - default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context - -) { + default ResponseEntity testQueryParameterCollectionFormat( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -530,28 +558,33 @@ default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiPar * @return successful operation (status code 200) */ @ApiVirtual - - @ApiOperation(value = "uploads an image (required)", nickname = "uploadFileWithRequiredFile", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @ApiOperation( + tags = { "pet" }, + value = "uploads an image (required)", + nickname = "uploadFileWithRequiredFile", + 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 = "/fake/{petId}/uploadImageWithRequiredFile", produces = { "application/json" }, consumes = { "multipart/form-data" } ) - default ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata) { + default ResponseEntity uploadFileWithRequiredFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "file to upload", required = true) @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeClassnameTestApi.java index 465a845bc96a..82c1f64160cb 100644 --- a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeClassnameTestApi.java @@ -40,14 +40,19 @@ default Optional getRequest() { * @return successful operation (status code 200) */ @ApiVirtual - - @ApiOperation(value = "To test class name in snake case", nickname = "testClassname", notes = "To test class name in snake case", response = Client.class, authorizations = { - - @Authorization(value = "api_key_query") - }, tags={ "fake_classname_tags 123#$%^", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake_classname_tags 123#$%^" }, + value = "To test class name in snake case", + nickname = "testClassname", + notes = "To test class name in snake case", + response = Client.class, + authorizations = { + @Authorization(value = "api_key_query") + } + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake_classname_test", @@ -55,8 +60,8 @@ default Optional getRequest() { consumes = { "application/json" } ) default ResponseEntity testClassname( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/PetApi.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/PetApi.java index 86c789dd6a8b..2048477990f6 100644 --- a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/PetApi.java +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/PetApi.java @@ -42,25 +42,30 @@ default Optional getRequest() { * or Invalid input (status code 405) */ @ApiVirtual - - @ApiOperation(value = "Add a new pet to the store", nickname = "addPet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Add a new pet to the store", + nickname = "addPet", + 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 = 200, message = "successful operation"), - - @ApiResponse(code = 405, message = "Invalid input") }) + @ApiResponse(code = 405, message = "Invalid input") + }) @RequestMapping( method = RequestMethod.POST, value = "/pet", consumes = { "application/json", "application/xml" } ) default ResponseEntity addPet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -75,26 +80,30 @@ default ResponseEntity addPet( * or Invalid pet value (status code 400) */ @ApiVirtual - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = 200, message = "successful operation"), - - @ApiResponse(code = 400, message = "Invalid pet value") }) + @ApiResponse(code = 400, message = "Invalid pet value") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/pet/{petId}" ) - default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId - -, -@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey -) { + default ResponseEntity deletePet( + @ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -109,25 +118,32 @@ default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", req * or Invalid status value (status code 400) */ @ApiVirtual - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid status value") }) + @ApiResponse(code = 400, message = "Invalid status value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByStatus", produces = { "application/xml", "application/json" } ) - default ResponseEntity> 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 status - -) { + default ResponseEntity> 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 status + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -157,25 +173,32 @@ default ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "S * @deprecated */ @ApiVirtual - - @ApiOperation(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 = "Set", authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "Set", + 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, responseContainer = "Set"), - - @ApiResponse(code = 400, message = "Invalid tag value") }) + @ApiResponse(code = 400, message = "Invalid tag value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByTags", produces = { "application/xml", "application/json" } ) - default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags - -) { + default ResponseEntity> findPetsByTags( + @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -205,26 +228,29 @@ default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags * or Pet not found (status code 404) */ @ApiVirtual - - @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { - - @Authorization(value = "api_key") - }, tags={ "pet", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Pet not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/{petId}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId - -) { + default ResponseEntity getPetById( + @ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -254,29 +280,32 @@ default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", * or Validation exception (status code 405) */ @ApiVirtual - - @ApiOperation(value = "Update an existing pet", nickname = "updatePet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Update an existing pet", + nickname = "updatePet", + 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 = 200, message = "successful operation"), - @ApiResponse(code = 400, message = "Invalid ID supplied"), - @ApiResponse(code = 404, message = "Pet not found"), - - @ApiResponse(code = 405, message = "Validation exception") }) + @ApiResponse(code = 405, message = "Validation exception") + }) @RequestMapping( method = RequestMethod.PUT, value = "/pet", consumes = { "application/json", "application/xml" } ) default ResponseEntity updatePet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -291,27 +320,31 @@ default ResponseEntity updatePet( * @return Invalid input (status code 405) */ @ApiVirtual - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 405, message = "Invalid input") }) + @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" } ) - default ResponseEntity 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 @RequestPart(value = "name", required = false) String name, - -@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status) { + default ResponseEntity 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 @RequestPart(value = "name", required = false) String name, + @ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -326,28 +359,33 @@ default ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that * @return successful operation (status code 200) */ @ApiVirtual - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @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" } ) - default ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { + default ResponseEntity uploadFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @ApiParam(value = "file to upload") @RequestPart(value = "file", required = false) MultipartFile file + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/StoreApi.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/StoreApi.java index c5b5f13a2e0b..c7975784e7f7 100644 --- a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/StoreApi.java +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/StoreApi.java @@ -42,20 +42,23 @@ default Optional getRequest() { * or Order not found (status code 404) */ @ApiVirtual - - @ApiOperation(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", tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/store/order/{order_id}" ) - default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId - -) { + default ResponseEntity deleteOrder( + @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -68,20 +71,28 @@ default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that * @return successful operation (status code 200) */ @ApiVirtual - - @ApiOperation(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") - }, tags={ "store", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) + @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" } ) - default ResponseEntity> getInventory() { + default ResponseEntity> getInventory( + + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -97,23 +108,26 @@ default ResponseEntity> getInventory() { * or Order not found (status code 404) */ @ApiVirtual - - @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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 generated 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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/store/order/{order_id}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId - -) { + default ResponseEntity getOrderById( + @Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -141,21 +155,25 @@ default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = " * or Invalid Order (status code 400) */ @ApiVirtual - - @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid Order") + }) @RequestMapping( method = RequestMethod.POST, value = "/store/order", produces = { "application/xml", "application/json" } ) default ResponseEntity placeOrder( - -@ApiParam(value = "order placed for purchasing the pet", required = true ) @Valid @RequestBody Order body) { + @ApiParam(value = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/UserApi.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/UserApi.java index 817e72d57a3f..0f5e1338b2cd 100644 --- a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/UserApi.java +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/UserApi.java @@ -42,18 +42,22 @@ default Optional getRequest() { * @return successful operation (status code 200) */ @ApiVirtual - - @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Create user", + nickname = "createUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user" ) default ResponseEntity createUser( - -@ApiParam(value = "Created user object", required = true ) @Valid @RequestBody User body) { + @ApiParam(value = "Created user object", required = true) @Valid @RequestBody User body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -66,18 +70,22 @@ default ResponseEntity createUser( * @return successful operation (status code 200) */ @ApiVirtual - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithArrayInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithArray" ) default ResponseEntity createUsersWithArrayInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -90,18 +98,22 @@ default ResponseEntity createUsersWithArrayInput( * @return successful operation (status code 200) */ @ApiVirtual - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithListInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithList" ) default ResponseEntity createUsersWithListInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -116,20 +128,23 @@ default ResponseEntity createUsersWithListInput( * or User not found (status code 404) */ @ApiVirtual - - @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Delete user", + nickname = "deleteUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/user/{username}" ) - default ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username - -) { + default ResponseEntity deleteUser( + @ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -144,23 +159,26 @@ default ResponseEntity deleteUser(@ApiParam(value = "The name that needs t * or User not found (status code 404) */ @ApiVirtual - - @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/{username}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username - -) { + default ResponseEntity getUserByName( + @ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -189,23 +207,26 @@ default ResponseEntity getUserByName(@ApiParam(value = "The name that need * or Invalid username/password supplied (status code 400) */ @ApiVirtual - - @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid username/password supplied") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/login", produces = { "application/xml", "application/json" } ) - default ResponseEntity loginUser(@NotNull @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 - -) { + default ResponseEntity loginUser( + @NotNull @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 new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -217,16 +238,22 @@ default ResponseEntity loginUser(@NotNull @ApiParam(value = "The user na * @return successful operation (status code 200) */ @ApiVirtual - - @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Logs out current logged in user session", + nickname = "logoutUser", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/logout" ) - default ResponseEntity logoutUser() { + default ResponseEntity logoutUser( + + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -242,22 +269,24 @@ default ResponseEntity logoutUser() { * or User not found (status code 404) */ @ApiVirtual - - @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Updated user", + nickname = "updateUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid user supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.PUT, value = "/user/{username}" ) - default ResponseEntity 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 body) { + default ResponseEntity 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 body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } diff --git a/samples/server/petstore/springboot/pom.xml b/samples/server/petstore/springboot/pom.xml index 62aa1140a3ef..2388f8831b10 100644 --- a/samples/server/petstore/springboot/pom.xml +++ b/samples/server/petstore/springboot/pom.xml @@ -9,12 +9,12 @@ 1.8 ${java.version} ${java.version} - 2.9.2 + 2.9.2 org.springframework.boot spring-boot-starter-parent - 2.3.3.RELEASE + 2.5.8 src/main/java @@ -22,13 +22,6 @@ org.springframework.boot spring-boot-maven-plugin - - - - repackage - - - @@ -45,16 +38,17 @@ io.springfox springfox-swagger2 - ${springfox-version} + ${springfox.version} + - io.springfox - springfox-swagger-ui - ${springfox-version} + com.google.code.findbugs + jsr305 + 3.0.2 - jakarta.xml.bind - jakarta.xml.bind-api + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml com.fasterxml.jackson.datatype @@ -63,12 +57,12 @@ org.openapitools jackson-databind-nullable - 0.2.1 + 0.2.2 - + - jakarta.validation - jakarta.validation-api + org.springframework.boot + spring-boot-starter-validation com.fasterxml.jackson.core diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/AnotherFakeApi.java index e98182736edd..49d703d71daf 100644 --- a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -36,11 +36,16 @@ default Optional getRequest() { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "$another-fake?" }, + value = "To test special tags", + nickname = "call123testSpecialTags", + notes = "To test special tags and operation ID starting with number", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/another-fake/dummy", @@ -48,8 +53,8 @@ default Optional getRequest() { consumes = { "application/json" } ) default ResponseEntity call123testSpecialTags( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeApi.java index e17bed0498fc..6f95540156b3 100644 --- a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeApi.java @@ -45,19 +45,23 @@ default Optional getRequest() { * @param xmlItem XmlItem Body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "creates an XmlItem", nickname = "createXmlItem", notes = "this route creates an XmlItem", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "creates an XmlItem", + nickname = "createXmlItem", + notes = "this route creates an XmlItem" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/create_xml_item", consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } ) default ResponseEntity createXmlItem( - -@ApiParam(value = "XmlItem Body", required = true ) @Valid @RequestBody XmlItem xmlItem) { + @ApiParam(value = "XmlItem Body", required = true) @Valid @RequestBody XmlItem xmlItem + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -70,19 +74,24 @@ default ResponseEntity createXmlItem( * @param body Input boolean as post body (optional) * @return Output boolean (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterBooleanSerialize", + notes = "Test serialization of outer boolean types", + response = Boolean.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/boolean", produces = { "*/*" } ) default ResponseEntity fakeOuterBooleanSerialize( - -@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { + @ApiParam(value = "Input boolean as post body") @Valid @RequestBody(required = false) Boolean body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -95,19 +104,24 @@ default ResponseEntity fakeOuterBooleanSerialize( * @param body Input composite as post body (optional) * @return Output composite (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterCompositeSerialize", + notes = "Test serialization of object with outer number type", + response = OuterComposite.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/composite", produces = { "*/*" } ) default ResponseEntity fakeOuterCompositeSerialize( - -@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { + @ApiParam(value = "Input composite as post body") @Valid @RequestBody(required = false) OuterComposite body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) { @@ -129,19 +143,24 @@ default ResponseEntity fakeOuterCompositeSerialize( * @param body Input number as post body (optional) * @return Output number (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterNumberSerialize", + notes = "Test serialization of outer number types", + response = BigDecimal.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/number", produces = { "*/*" } ) default ResponseEntity fakeOuterNumberSerialize( - -@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { + @ApiParam(value = "Input number as post body") @Valid @RequestBody(required = false) BigDecimal body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -154,19 +173,24 @@ default ResponseEntity fakeOuterNumberSerialize( * @param body Input string as post body (optional) * @return Output string (status code 200) */ - - @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Output string", response = String.class) }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "fakeOuterStringSerialize", + notes = "Test serialization of outer string types", + response = String.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Output string", response = String.class) + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/outer/string", produces = { "*/*" } ) default ResponseEntity fakeOuterStringSerialize( - -@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { + @ApiParam(value = "Input string as post body") @Valid @RequestBody(required = false) String body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -179,19 +203,23 @@ default ResponseEntity fakeOuterStringSerialize( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithFileSchema", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithFileSchema", + notes = "For this test, the body for this request much reference a schema named `File`." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-file-schema", consumes = { "application/json" } ) default ResponseEntity testBodyWithFileSchema( - -@ApiParam(value = "", required = true ) @Valid @RequestBody FileSchemaTestClass body) { + @ApiParam(value = "", required = true) @Valid @RequestBody FileSchemaTestClass body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -204,21 +232,24 @@ default ResponseEntity testBodyWithFileSchema( * @param body (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testBodyWithQueryParams", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testBodyWithQueryParams", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/body-with-query-params", consumes = { "application/json" } ) - default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query - -, - -@ApiParam(value = "", required = true ) @Valid @RequestBody User body) { + default ResponseEntity testBodyWithQueryParams( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query, + @ApiParam(value = "", required = true) @Valid @RequestBody User body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -231,11 +262,16 @@ default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake" }, + value = "To test \"client\" model", + nickname = "testClientModel", + notes = "To test \"client\" model", + response = Client.class + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake", @@ -243,8 +279,8 @@ default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = consumes = { "application/json" } ) default ResponseEntity testClientModel( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -280,50 +316,40 @@ default ResponseEntity testClientModel( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", authorizations = { - - @Authorization(value = "http_basic_test") - }, tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + nickname = "testEndpointParameters", + notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", + authorizations = { + @Authorization(value = "http_basic_test") + } + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testEndpointParameters( - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, - -@ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, - -@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, - -@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, - -@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, - -@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, - -@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary, - -@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date, - -@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime, - -@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, - -@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback) { + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "number", required = true) BigDecimal number, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "double", required = true) Double _double, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter, + @ApiParam(value = "None", required = true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte, + @ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer, + @ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32, + @ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64, + @ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float, + @ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string, + @ApiParam(value = "None") @RequestPart(value = "binary", required = false) MultipartFile binary, + @ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) LocalDate date, + @ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, + @ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, + @ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -344,35 +370,31 @@ default ResponseEntity testEndpointParameters( * @return Invalid request (status code 400) * or Not found (status code 404) */ - - @ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "fake" }, + value = "To test enum parameters", + nickname = "testEnumParameters", + notes = "To test enum parameters" + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid request"), - - @ApiResponse(code = 404, message = "Not found") }) + @ApiResponse(code = 404, message = "Not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testEnumParameters( -@ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray -, -@ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString -,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray - -,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger - -,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble - -, - -@ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, - -@ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString) { + @ApiParam(value = "Header parameter enum test (string array)", allowableValues = ">, $") @RequestHeader(value = "enum_header_string_array", required = false) List enumHeaderStringArray, + @ApiParam(value = "Header parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestHeader(value = "enum_header_string", required = false) String enumHeaderString, + @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, + @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue = "-efg") String enumQueryString, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble, + @ApiParam(value = "Form parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray, + @ApiParam(value = "Form parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -390,28 +412,27 @@ default ResponseEntity testEnumParameters( * @param int64Group Integer in group parameters (optional) * @return Someting wrong (status code 400) */ - - @ApiOperation(value = "Fake endpoint to test group parameters (optional)", nickname = "testGroupParameters", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 400, message = "Someting wrong") }) + @ApiOperation( + tags = { "fake" }, + value = "Fake endpoint to test group parameters (optional)", + nickname = "testGroupParameters", + notes = "Fake endpoint to test group parameters (optional)" + ) + @ApiResponses({ + @ApiResponse(code = 400, message = "Someting wrong") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/fake" ) - default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup - -, -@ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup -,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group - -,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup - -, -@ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup -,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group - -) { + default ResponseEntity testGroupParameters( + @NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup, + @ApiParam(value = "Required Boolean in group parameters", required = true) @RequestHeader(value = "required_boolean_group", required = true) Boolean requiredBooleanGroup, + @NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group, + @ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup, + @ApiParam(value = "Boolean in group parameters") @RequestHeader(value = "boolean_group", required = false) Boolean booleanGroup, + @ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -423,19 +444,23 @@ default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Req * @param param request body (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test inline additionalProperties", + nickname = "testInlineAdditionalProperties", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/fake/inline-additionalProperties", consumes = { "application/json" } ) default ResponseEntity testInlineAdditionalProperties( - -@ApiParam(value = "request body", required = true ) @Valid @RequestBody Map param) { + @ApiParam(value = "request body", required = true) @Valid @RequestBody Map param + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -448,21 +473,24 @@ default ResponseEntity testInlineAdditionalProperties( * @param param2 field2 (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "fake" }, + value = "test json serialization of form data", + nickname = "testJsonFormData", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/fake/jsonFormData", consumes = { "application/x-www-form-urlencoded" } ) default ResponseEntity testJsonFormData( - -@ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, - -@ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2) { + @ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, + @ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2 + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -479,26 +507,26 @@ default ResponseEntity testJsonFormData( * @param context (required) * @return Success (status code 200) */ - - @ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "Success") }) + @ApiOperation( + tags = { "fake" }, + value = "", + nickname = "testQueryParameterCollectionFormat", + notes = "To test the collection format in query parameters" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "Success") + }) @RequestMapping( method = RequestMethod.PUT, value = "/fake/test-query-parameters" ) - default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url - -,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context - -) { + default ResponseEntity testQueryParameterCollectionFormat( + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url, + @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -512,28 +540,33 @@ default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiPar * @param additionalMetadata Additional data to pass to server (optional) * @return successful operation (status code 200) */ - - @ApiOperation(value = "uploads an image (required)", nickname = "uploadFileWithRequiredFile", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @ApiOperation( + tags = { "pet" }, + value = "uploads an image (required)", + nickname = "uploadFileWithRequiredFile", + 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 = "/fake/{petId}/uploadImageWithRequiredFile", produces = { "application/json" }, consumes = { "multipart/form-data" } ) - default ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata) { + default ResponseEntity uploadFileWithRequiredFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "file to upload", required = true) @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeClassnameTestApi.java index efa3146991d6..8c44f6c0992f 100644 --- a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -36,14 +36,19 @@ default Optional getRequest() { * @param body client model (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "To test class name in snake case", nickname = "testClassname", notes = "To test class name in snake case", response = Client.class, authorizations = { - - @Authorization(value = "api_key_query") - }, tags={ "fake_classname_tags 123#$%^", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @ApiOperation( + tags = { "fake_classname_tags 123#$%^" }, + value = "To test class name in snake case", + nickname = "testClassname", + notes = "To test class name in snake case", + response = Client.class, + authorizations = { + @Authorization(value = "api_key_query") + } + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation", response = Client.class) + }) @RequestMapping( method = RequestMethod.PATCH, value = "/fake_classname_test", @@ -51,8 +56,8 @@ default Optional getRequest() { consumes = { "application/json" } ) default ResponseEntity testClassname( - -@ApiParam(value = "client model", required = true ) @Valid @RequestBody Client body) { + @ApiParam(value = "client model", required = true) @Valid @RequestBody Client body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/PetApi.java index 30bbc2f6c18a..316f07e44847 100644 --- a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/PetApi.java @@ -38,25 +38,30 @@ default Optional getRequest() { * @return successful operation (status code 200) * or Invalid input (status code 405) */ - - @ApiOperation(value = "Add a new pet to the store", nickname = "addPet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Add a new pet to the store", + nickname = "addPet", + 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 = 200, message = "successful operation"), - - @ApiResponse(code = 405, message = "Invalid input") }) + @ApiResponse(code = 405, message = "Invalid input") + }) @RequestMapping( method = RequestMethod.POST, value = "/pet", consumes = { "application/json", "application/xml" } ) default ResponseEntity addPet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -70,26 +75,30 @@ default ResponseEntity addPet( * @return successful operation (status code 200) * or Invalid pet value (status code 400) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = 200, message = "successful operation"), - - @ApiResponse(code = 400, message = "Invalid pet value") }) + @ApiResponse(code = 400, message = "Invalid pet value") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/pet/{petId}" ) - default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId - -, -@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey -) { + default ResponseEntity deletePet( + @ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -103,25 +112,32 @@ default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete", req * @return successful operation (status code 200) * or Invalid status value (status code 400) */ - - @ApiOperation(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 = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "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, responseContainer = "List"), - - @ApiResponse(code = 400, message = "Invalid status value") }) + @ApiResponse(code = 400, message = "Invalid status value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByStatus", produces = { "application/xml", "application/json" } ) - default ResponseEntity> 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 status - -) { + default ResponseEntity> 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 status + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -150,25 +166,32 @@ default ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "S * or Invalid tag value (status code 400) * @deprecated */ - - @ApiOperation(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 = "Set", authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @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 = "Set", + 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, responseContainer = "Set"), - - @ApiResponse(code = 400, message = "Invalid tag value") }) + @ApiResponse(code = 400, message = "Invalid tag value") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/findByTags", produces = { "application/xml", "application/json" } ) - default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags - -) { + default ResponseEntity> findPetsByTags( + @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -197,26 +220,29 @@ default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags * or Invalid ID supplied (status code 400) * or Pet not found (status code 404) */ - - @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { - - @Authorization(value = "api_key") - }, tags={ "pet", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Pet not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/pet/{petId}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId - -) { + default ResponseEntity getPetById( + @ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -245,29 +271,32 @@ default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return", * or Pet not found (status code 404) * or Validation exception (status code 405) */ - - @ApiOperation(value = "Update an existing pet", nickname = "updatePet", 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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "pet" }, + value = "Update an existing pet", + nickname = "updatePet", + 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 = 200, message = "successful operation"), - @ApiResponse(code = 400, message = "Invalid ID supplied"), - @ApiResponse(code = 404, message = "Pet not found"), - - @ApiResponse(code = 405, message = "Validation exception") }) + @ApiResponse(code = 405, message = "Validation exception") + }) @RequestMapping( method = RequestMethod.PUT, value = "/pet", consumes = { "application/json", "application/xml" } ) default ResponseEntity updatePet( - -@ApiParam(value = "Pet object that needs to be added to the store", required = true ) @Valid @RequestBody Pet body) { + @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -281,27 +310,31 @@ default ResponseEntity updatePet( * @param status Updated status of the pet (optional) * @return Invalid input (status code 405) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 405, message = "Invalid input") }) + @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" } ) - default ResponseEntity 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 @RequestPart(value = "name", required = false) String name, - -@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status) { + default ResponseEntity 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 @RequestPart(value = "name", required = false) String name, + @ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -315,28 +348,33 @@ default ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that * @param file file to upload (optional) * @return successful operation (status code 200) */ - - @ApiOperation(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") }) - }, tags={ "pet", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @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" } ) - default ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - -, - -@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, - -@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { + default ResponseEntity uploadFile( + @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @ApiParam(value = "file to upload") @RequestPart(value = "file", required = false) MultipartFile file + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/StoreApi.java index 1d86f2d6fb0a..84abf7191820 100644 --- a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/StoreApi.java @@ -38,20 +38,23 @@ default Optional getRequest() { * @return Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(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", tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/store/order/{order_id}" ) - default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId - -) { + default ResponseEntity deleteOrder( + @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -63,20 +66,28 @@ default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that * * @return successful operation (status code 200) */ - - @ApiOperation(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") - }, tags={ "store", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) + @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" } ) - default ResponseEntity> getInventory() { + default ResponseEntity> getInventory( + + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -91,23 +102,26 @@ default ResponseEntity> getInventory() { * or Invalid ID supplied (status code 400) * or Order not found (status code 404) */ - - @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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 generated 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") }) + @ApiResponse(code = 404, message = "Order not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/store/order/{order_id}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId - -) { + default ResponseEntity getOrderById( + @Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -134,21 +148,25 @@ default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = " * @return successful operation (status code 200) * or Invalid Order (status code 400) */ - - @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid Order") + }) @RequestMapping( method = RequestMethod.POST, value = "/store/order", produces = { "application/xml", "application/json" } ) default ResponseEntity placeOrder( - -@ApiParam(value = "order placed for purchasing the pet", required = true ) @Valid @RequestBody Order body) { + @ApiParam(value = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order body + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/UserApi.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/UserApi.java index 8454fafb3209..86fcdae11023 100644 --- a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/UserApi.java @@ -38,18 +38,22 @@ default Optional getRequest() { * @param body Created user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Create user", + nickname = "createUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user" ) default ResponseEntity createUser( - -@ApiParam(value = "Created user object", required = true ) @Valid @RequestBody User body) { + @ApiParam(value = "Created user object", required = true) @Valid @RequestBody User body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -61,18 +65,22 @@ default ResponseEntity createUser( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithArrayInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithArray" ) default ResponseEntity createUsersWithArrayInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -84,18 +92,22 @@ default ResponseEntity createUsersWithArrayInput( * @param body List of user object (required) * @return successful operation (status code 200) */ - - @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Creates list of users with given input array", + nickname = "createUsersWithListInput", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.POST, value = "/user/createWithList" ) default ResponseEntity createUsersWithListInput( - -@ApiParam(value = "List of user object", required = true ) @Valid @RequestBody List body) { + @ApiParam(value = "List of user object", required = true) @Valid @RequestBody List body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -109,20 +121,23 @@ default ResponseEntity createUsersWithListInput( * @return Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Delete user", + nickname = "deleteUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid username supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.DELETE, value = "/user/{username}" ) - default ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username - -) { + default ResponseEntity deleteUser( + @ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -136,23 +151,26 @@ default ResponseEntity deleteUser(@ApiParam(value = "The name that needs t * or Invalid username supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/{username}", produces = { "application/xml", "application/json" } ) - default ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username - -) { + default ResponseEntity getUserByName( + @ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username + ) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -180,23 +198,26 @@ default ResponseEntity getUserByName(@ApiParam(value = "The name that need * @return successful operation (status code 200) * or Invalid username/password supplied (status code 400) */ - - @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) - @ApiResponses(value = { - + @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") }) + @ApiResponse(code = 400, message = "Invalid username/password supplied") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/login", produces = { "application/xml", "application/json" } ) - default ResponseEntity loginUser(@NotNull @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 - -) { + default ResponseEntity loginUser( + @NotNull @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 new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -207,16 +228,22 @@ default ResponseEntity loginUser(@NotNull @ApiParam(value = "The user na * * @return successful operation (status code 200) */ - - @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) - @ApiResponses(value = { - - @ApiResponse(code = 200, message = "successful operation") }) + @ApiOperation( + tags = { "user" }, + value = "Logs out current logged in user session", + nickname = "logoutUser", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) @RequestMapping( method = RequestMethod.GET, value = "/user/logout" ) - default ResponseEntity logoutUser() { + default ResponseEntity logoutUser( + + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -231,22 +258,24 @@ default ResponseEntity logoutUser() { * @return Invalid user supplied (status code 400) * or User not found (status code 404) */ - - @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", }) - @ApiResponses(value = { - + @ApiOperation( + tags = { "user" }, + value = "Updated user", + nickname = "updateUser", + notes = "This can only be done by the logged in user." + ) + @ApiResponses({ @ApiResponse(code = 400, message = "Invalid user supplied"), - - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 404, message = "User not found") + }) @RequestMapping( method = RequestMethod.PUT, value = "/user/{username}" ) - default ResponseEntity 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 body) { + default ResponseEntity 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 body + ) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); }