From d4e86fba1c3985ff23e22c405fcab2e648c48856 Mon Sep 17 00:00:00 2001 From: frantuma Date: Mon, 10 Sep 2018 19:14:47 +0200 Subject: [PATCH 1/7] added module swagger-maven-plugin --- modules/swagger-maven-plugin/pom.xml | 175 ++++++++++++++++++ ...jectDependenciesComponentConfigurator.java | 71 +++++++ .../swagger/v3/plugin/maven/SwaggerMojo.java | 136 ++++++++++++++ .../maven/BetterAbstractMojoTestCase.java | 105 +++++++++++ .../v3/plugin/maven/SwaggerResolveTest.java | 79 ++++++++ .../petstore/petstore/EmptyPetResource.java | 7 + .../maven/petstore/petstore/PetResource.java | 166 +++++++++++++++++ .../callback/ComplexCallbackResource.java | 62 +++++++ ...pleCallbacksTestWithOperationResource.java | 45 +++++ .../callback/RepeatableCallbackResource.java | 46 +++++ .../SimpleCallbackWithOperationResource.java | 44 +++++ .../petstore/example/ExamplesResource.java | 69 +++++++ .../example/SubscriptionResponse.java | 5 + .../petstore/petstore/link/LinksResource.java | 44 +++++ .../OpenAPIDefinitionResource.java | 48 +++++ .../AnnotatedSameNameOperationResource.java | 26 +++ .../ExternalDocumentationResource.java | 30 +++ .../FullyAnnotatedOperationResource.java | 38 ++++ .../operation/HiddenOperationResource.java | 29 +++ .../petstore/operation/InterfaceResource.java | 22 +++ ...NotAnnotatedSameNameOperationResource.java | 21 +++ .../petstore/operation/OperationResource.java | 77 ++++++++ .../OperationWithoutAnnotationResource.java | 15 ++ .../operation/ServerOperationResource.java | 30 +++ .../petstore/operation/SubResource.java | 20 ++ .../parameter/ArraySchemaResource.java | 44 +++++ .../parameter/ComplexParameterResource.java | 33 ++++ ...ComplexParameterWithOperationResource.java | 37 ++++ .../MultipleNotAnnotatedParameter.java | 18 ++ .../OpenAPIJaxRSAnnotatedParameter.java | 21 +++ ...APIWithContentJaxRSAnnotatedParameter.java | 25 +++ ...ImplementationJaxRSAnnotatedParameter.java | 23 +++ .../parameter/ParametersResource.java | 87 +++++++++ .../RepeatableParametersResource.java | 80 ++++++++ .../SingleJaxRSAnnotatedParameter.java | 20 ++ .../SingleNotAnnotatedParameter.java | 19 ++ .../RequestBodyMethodPriorityResource.java | 28 +++ .../RequestBodyParameterPriorityResource.java | 29 +++ .../requestbody/RequestBodyResource.java | 113 +++++++++++ .../responses/ComplexResponseResource.java | 34 ++++ .../ImplementationResponseResource.java | 71 +++++++ .../responses/MethodResponseResource.java | 24 +++ .../NoImplementationResponseResource.java | 66 +++++++ .../responses/NoResponseResource.java | 21 +++ .../responses/OperationResponseResource.java | 25 +++ .../responses/PriorityResponseResource.java | 25 +++ .../petstore/security/SecurityResource.java | 61 ++++++ .../petstore/tags/CompleteTagResource.java | 31 ++++ .../petstore/tags/TagClassResource.java | 14 ++ .../petstore/tags/TagMethodResource.java | 19 ++ .../tags/TagOpenAPIDefinitionResource.java | 14 ++ .../petstore/tags/TagOperationResource.java | 20 ++ .../maven/resources/QueryResultBean.java | 43 +++++ .../plugin/maven/resources/data/PetData.java | 151 +++++++++++++++ .../plugin/maven/resources/data/UserData.java | 98 ++++++++++ .../resources/exception/ApiException.java | 26 +++ .../exception/NotFoundException.java | 26 +++ .../maven/resources/model/Category.java | 51 +++++ .../resources/model/CustomGenerator.java | 32 ++++ .../maven/resources/model/ExtensionUser.java | 130 +++++++++++++ .../maven/resources/model/JacksonBean.java | 76 ++++++++ .../model/ListOfStringsBeanParam.java | 17 ++ .../model/ModelWithJsonIdentity.java | 145 +++++++++++++++ .../model/ModelWithJsonIdentityCyclic.java | 29 +++ .../resources/model/MultipleBaseBean.java | 11 ++ .../resources/model/MultipleSub1Bean.java | 8 + .../resources/model/MultipleSub2Bean.java | 8 + .../maven/resources/model/NotFoundModel.java | 30 +++ .../v3/plugin/maven/resources/model/Pet.java | 76 ++++++++ .../v3/plugin/maven/resources/model/Tag.java | 44 +++++ .../v3/plugin/maven/resources/model/User.java | 108 +++++++++++ .../src/test/resources/pom.resolveToFile.xml | 47 +++++ ...pom.resolveToFileAndUploadToSwaggerhub.xml | 47 +++++ .../pom.resolveToFileJsonAndYaml.xml | 47 +++++ .../resources/pom.resolveToFileNoName.xml | 46 +++++ pom.xml | 1 + 76 files changed, 3709 insertions(+) create mode 100644 modules/swagger-maven-plugin/pom.xml create mode 100644 modules/swagger-maven-plugin/src/main/java/io/swagger/v3/plugin/maven/IncludeProjectDependenciesComponentConfigurator.java create mode 100644 modules/swagger-maven-plugin/src/main/java/io/swagger/v3/plugin/maven/SwaggerMojo.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/BetterAbstractMojoTestCase.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/SwaggerResolveTest.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/EmptyPetResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/PetResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/callback/ComplexCallbackResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/callback/MultipleCallbacksTestWithOperationResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/callback/RepeatableCallbackResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/callback/SimpleCallbackWithOperationResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/example/ExamplesResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/example/SubscriptionResponse.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/link/LinksResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/openapidefintion/OpenAPIDefinitionResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/AnnotatedSameNameOperationResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/ExternalDocumentationResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/FullyAnnotatedOperationResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/HiddenOperationResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/InterfaceResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/NotAnnotatedSameNameOperationResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/OperationResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/OperationWithoutAnnotationResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/ServerOperationResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/SubResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/ArraySchemaResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/ComplexParameterResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/ComplexParameterWithOperationResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/MultipleNotAnnotatedParameter.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/OpenAPIJaxRSAnnotatedParameter.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/OpenAPIWithContentJaxRSAnnotatedParameter.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/OpenAPIWithImplementationJaxRSAnnotatedParameter.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/ParametersResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/RepeatableParametersResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/SingleJaxRSAnnotatedParameter.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/SingleNotAnnotatedParameter.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/requestbody/RequestBodyMethodPriorityResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/requestbody/RequestBodyParameterPriorityResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/requestbody/RequestBodyResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/responses/ComplexResponseResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/responses/ImplementationResponseResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/responses/MethodResponseResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/responses/NoImplementationResponseResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/responses/NoResponseResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/responses/OperationResponseResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/responses/PriorityResponseResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/security/SecurityResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/tags/CompleteTagResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/tags/TagClassResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/tags/TagMethodResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/tags/TagOpenAPIDefinitionResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/tags/TagOperationResource.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/QueryResultBean.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/data/PetData.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/data/UserData.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/exception/ApiException.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/exception/NotFoundException.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/Category.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/CustomGenerator.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/ExtensionUser.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/JacksonBean.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/ListOfStringsBeanParam.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/ModelWithJsonIdentity.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/ModelWithJsonIdentityCyclic.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/MultipleBaseBean.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/MultipleSub1Bean.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/MultipleSub2Bean.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/NotFoundModel.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/Pet.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/Tag.java create mode 100644 modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/User.java create mode 100644 modules/swagger-maven-plugin/src/test/resources/pom.resolveToFile.xml create mode 100644 modules/swagger-maven-plugin/src/test/resources/pom.resolveToFileAndUploadToSwaggerhub.xml create mode 100644 modules/swagger-maven-plugin/src/test/resources/pom.resolveToFileJsonAndYaml.xml create mode 100644 modules/swagger-maven-plugin/src/test/resources/pom.resolveToFileNoName.xml diff --git a/modules/swagger-maven-plugin/pom.xml b/modules/swagger-maven-plugin/pom.xml new file mode 100644 index 0000000000..c26880d610 --- /dev/null +++ b/modules/swagger-maven-plugin/pom.xml @@ -0,0 +1,175 @@ + + + io.swagger.core.v3 + swagger-project + 2.0.5-SNAPSHOT + ../.. + + 4.0.0 + swagger-maven-plugin + maven-plugin + swagger-maven.plugin + + + + org.codehaus.plexus + plexus-component-metadata + 1.7.1 + + + + generate-metadata + + + + + + org.apache.maven.plugins + maven-plugin-plugin + 3.5.1 + + + + + + org.apache.maven + maven-plugin-api + ${maven.version} + + + org.codehaus.plexus + plexus-utils + + + + + org.apache.maven.plugin-tools + maven-plugin-annotations + 3.3 + provided + + + org.apache.maven + maven-artifact + + + + + org.apache.maven.plugin-testing + maven-plugin-testing-harness + 3.3.0 + test + + + junit + junit + + + org.codehaus.plexus + plexus-utils + + + org.codehaus.plexus + plexus-component-annotations + + + + + org.apache.commons + commons-lang3 + 3.7 + + + org.codehaus.plexus + plexus-utils + 3.0.24 + + + org.codehaus.plexus + plexus-component-annotations + 1.5.5 + + + + org.apache.maven + maven-compat + ${maven.version} + + + com.google.guava + guava + + + org.codehaus.plexus + plexus-utils + + + org.codehaus.plexus + plexus-component-annotations + + + + + io.swagger.core.v3 + swagger-jaxrs2 + ${project.version} + + + + junit + junit + ${junit.version} + test + + + com.github.tomakehurst + wiremock + 2.15.0 + test + + + junit + junit + + + com.google.guava + guava + + + + + ch.qos.logback + logback-classic + 1.2.3 + test + + + ch.qos.logback + logback-core + 1.2.3 + test + + + javax.ws.rs + javax.ws.rs-api + 2.1 + test + + + javax.servlet + javax.servlet-api + 3.1.0 + test + + + + + 3.5.0 + 4.12 + + diff --git a/modules/swagger-maven-plugin/src/main/java/io/swagger/v3/plugin/maven/IncludeProjectDependenciesComponentConfigurator.java b/modules/swagger-maven-plugin/src/main/java/io/swagger/v3/plugin/maven/IncludeProjectDependenciesComponentConfigurator.java new file mode 100644 index 0000000000..48046735f4 --- /dev/null +++ b/modules/swagger-maven-plugin/src/main/java/io/swagger/v3/plugin/maven/IncludeProjectDependenciesComponentConfigurator.java @@ -0,0 +1,71 @@ +package io.swagger.v3.plugin.maven; + +import org.codehaus.plexus.classworlds.realm.ClassRealm; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.configurator.AbstractComponentConfigurator; +import org.codehaus.plexus.component.configurator.ComponentConfigurationException; +import org.codehaus.plexus.component.configurator.ComponentConfigurator; +import org.codehaus.plexus.component.configurator.ConfigurationListener; +import org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; +import org.codehaus.plexus.configuration.PlexusConfiguration; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +/* + * Thanks to original post by Brian Jackson (http://jaxzin.github.io/) http://maven.40175.n5.nabble.com/Adding-project-dependencies-and-generated-classes-to-classpath-of-my-plugin-tp110119p110121.html + */ +@Component(role = ComponentConfigurator.class, hint = "include-project-dependencies") +public class IncludeProjectDependenciesComponentConfigurator extends AbstractComponentConfigurator { + + @Override + public void configureComponent(Object component, PlexusConfiguration configuration, + ExpressionEvaluator expressionEvaluator, ClassRealm containerRealm, + ConfigurationListener listener) + throws ComponentConfigurationException { + + addProjectDependenciesToClassRealm(expressionEvaluator, containerRealm); + + ObjectWithFieldsConverter converter = new ObjectWithFieldsConverter(); + converter.processConfiguration(converterLookup, component, containerRealm, configuration, + expressionEvaluator, listener); + } + + private void addProjectDependenciesToClassRealm(ExpressionEvaluator expressionEvaluator, ClassRealm containerRealm) throws ComponentConfigurationException { + List compileClasspathElements; + try { + //noinspection unchecked + compileClasspathElements = (List) expressionEvaluator.evaluate("${project.compileClasspathElements}"); + } catch (ExpressionEvaluationException e) { + throw new ComponentConfigurationException("There was a problem evaluating: ${project.compileClasspathElements}", e); + } + + // Add the project dependencies to the ClassRealm + final URL[] urls = buildURLs(compileClasspathElements); + for (URL url : urls) { + containerRealm.addURL(url); + } + } + + private URL[] buildURLs(List runtimeClasspathElements) throws ComponentConfigurationException { + // Add the projects classes and dependencies + List urls = new ArrayList(runtimeClasspathElements.size()); + for (String element : runtimeClasspathElements) { + try { + final URL url = new File(element).toURI().toURL(); + urls.add(url); + } catch (MalformedURLException e) { + throw new ComponentConfigurationException("Unable to access project dependency: " + element, e); + } + } + + // Add the plugin's dependencies (so Trove stuff works if Trove isn't on + return urls.toArray(new URL[urls.size()]); + } + +} \ No newline at end of file diff --git a/modules/swagger-maven-plugin/src/main/java/io/swagger/v3/plugin/maven/SwaggerMojo.java b/modules/swagger-maven-plugin/src/main/java/io/swagger/v3/plugin/maven/SwaggerMojo.java new file mode 100644 index 0000000000..8bc20d902d --- /dev/null +++ b/modules/swagger-maven-plugin/src/main/java/io/swagger/v3/plugin/maven/SwaggerMojo.java @@ -0,0 +1,136 @@ +package io.swagger.v3.plugin.maven; + +import io.swagger.v3.core.util.Json; +import io.swagger.v3.core.util.Yaml; +import io.swagger.v3.jaxrs2.integration.JaxrsOpenApiContextBuilder; +import io.swagger.v3.oas.integration.OpenApiConfigurationException; +import io.swagger.v3.oas.integration.SwaggerConfiguration; +import io.swagger.v3.oas.models.OpenAPI; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.annotations.ResolutionScope; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Collection; +import java.util.Set; + +@Mojo( + name = "resolve", + requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, + defaultPhase = LifecyclePhase.COMPILE, + threadSafe = true, + configurator = "include-project-dependencies" +) +public class SwaggerMojo extends AbstractMojo { + + public enum Format {JSON, YAML, JSONANDYAML}; + + public void execute() throws MojoExecutionException, MojoFailureException + { + if (skip) { + getLog().info( "Skipping OpenAPI specification resolution" ); + return; + } + getLog().info( "Resolving OpenAPI specification.." ); + SwaggerConfiguration config = new SwaggerConfiguration() + .filterClass(filterClass) + .ignoredRoutes(ignoredRoutes) + .prettyPrint(prettyPrint) + .readAllResources(readAllResources) + .readerClass(readerClass) + .scannerClass(scannerClass) + .resourceClasses(resourceClasses) + .resourcePackages(resourcePackages); + try { + OpenAPI openAPI = new JaxrsOpenApiContextBuilder() + .openApiConfiguration(config) + .buildContext(true) + .read(); + String openapiJson = null; + String openapiYaml = null; + if (Format.JSON.equals(outputFormat) || Format.JSONANDYAML.equals(outputFormat)) { + if (prettyPrint) { + openapiJson = Json.pretty(openAPI); + } else { + openapiJson = Json.mapper().writeValueAsString(openAPI); + } + + } + if (Format.YAML.equals(outputFormat) || Format.JSONANDYAML.equals(outputFormat)) { + if (prettyPrint) { + openapiYaml = Yaml.pretty(openAPI); + } else { + openapiYaml = Yaml.mapper().writeValueAsString(openAPI); + } + + } + Path path = Paths.get(outputPath, "temp"); + final File parentFile = path.toFile().getParentFile(); + if (parentFile != null) { + parentFile.mkdirs(); + } + + if (openapiJson != null) { + path = Paths.get(outputPath, outputFileName + ".json"); + Files.write(path, openapiJson.getBytes(Charset.forName("UTF-8"))); + } + if (openapiYaml != null) { + path = Paths.get(outputPath, outputFileName + ".yaml"); + Files.write(path, openapiYaml.getBytes(Charset.forName("UTF-8"))); + } + + } catch (OpenApiConfigurationException e) { + getLog().error( "Error resolving API specification" , e); + throw new MojoFailureException(e.getMessage(), e); + } catch (IOException e) { + getLog().error( "Error writing API specification" , e); + throw new MojoExecutionException("Failed to write API definition", e); + } catch (Exception e) { + getLog().error( "Error resolving API specification" , e); + throw new MojoExecutionException(e.getMessage(), e); + } + } + + @Parameter( property = "resolve.outputFileName", defaultValue = "openapi") + private String outputFileName = "openapi"; + + @Parameter( property = "resolve.outputPath" ) + private String outputPath; + + @Parameter( property = "resolve.outputFormat", defaultValue = "JSON") + private Format outputFormat; + + @Parameter( property = "resolve.resourcePackages" ) + private Set resourcePackages; + @Parameter( property = "resolve.resourceClasses" ) + private Set resourceClasses; + @Parameter( property = "resolve.filterClass" ) + private String filterClass; + @Parameter( property = "resolve.readerClass" ) + private String readerClass; + @Parameter( property = "resolve.scannerClass" ) + private String scannerClass; + @Parameter( property = "resolve.prettyPrint" ) + private Boolean prettyPrint; + @Parameter( property = "resolve.readAllResources" ) + private Boolean readAllResources = Boolean.TRUE; + @Parameter( property = "resolve.ignoredRoutes" ) + private Collection ignoredRoutes; + + @Parameter( property = "resolve.skip" ) + private Boolean skip = Boolean.FALSE; + + public String getOutputPath() { + return outputPath; + } + +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/BetterAbstractMojoTestCase.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/BetterAbstractMojoTestCase.java new file mode 100644 index 0000000000..6d5fedc3aa --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/BetterAbstractMojoTestCase.java @@ -0,0 +1,105 @@ +package io.swagger.v3.plugin.maven; + +import org.apache.maven.DefaultMaven; +import org.apache.maven.Maven; +import org.apache.maven.execution.DefaultMavenExecutionRequest; +import org.apache.maven.execution.DefaultMavenExecutionResult; +import org.apache.maven.execution.MavenExecutionRequest; +import org.apache.maven.execution.MavenExecutionRequestPopulator; +import org.apache.maven.execution.MavenExecutionResult; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.plugin.Mojo; +import org.apache.maven.plugin.testing.AbstractMojoTestCase; +import org.apache.maven.project.MavenProject; +import org.apache.maven.project.ProjectBuilder; +import org.apache.maven.project.ProjectBuildingRequest; +import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; +import org.eclipse.aether.repository.LocalRepository; + +import java.io.File; +import java.util.Arrays; + +/** + * Copied from https://github.com/ahgittin/license-audit-maven-plugin + */ + +/** + * Use this as you would {@link AbstractMojoTestCase}, + * where you want more of the standard maven defaults to be set + * (and where the {@link AbstractMojoTestCase} leaves them as null or empty). + * This includes: + *
  • local repo, repo sessions and managers configured + *
  • maven default remote repos installed (NB: this does not use your ~/.m2 local settings) + *
  • system properties are copies + *

    + * No changes to subclass code is needed; this simply intercepts the {@link #newMavenSession(MavenProject)} method + * used by the various {@link #lookupMojo(String, File)} methods. + *

    + * This also provides new methods, {@link #newMavenSession()} to conveniently create a maven session, + * and {@link #lookupConfiguredMojo(File, String)} so you don't have to always build the project yourself. + */ +public abstract class BetterAbstractMojoTestCase extends AbstractMojoTestCase { + + protected MavenSession newMavenSession() { + try { + MavenExecutionRequest request = new DefaultMavenExecutionRequest(); + MavenExecutionResult result = new DefaultMavenExecutionResult(); + + // populate sensible defaults, including repository basedir and remote repos + MavenExecutionRequestPopulator populator; + populator = getContainer().lookup(MavenExecutionRequestPopulator.class); + populator.populateDefaults(request); + + // this is needed to allow java profiles to get resolved; i.e. avoid during project builds: + // [ERROR] Failed to determine Java version for profile java-1.5-detected @ org.apache.commons:commons-parent:22, /Users/alex/.m2/repository/org/apache/commons/commons-parent/22/commons-parent-22.pom, line 909, column 14 + request.setSystemProperties(System.getProperties()); + + // and this is needed so that the repo session in the maven session + // has a repo manager, and it points at the local repo + // (cf MavenRepositorySystemUtils.newSession() which is what is otherwise done) + DefaultMaven maven = (DefaultMaven) getContainer().lookup(Maven.class); + DefaultRepositorySystemSession repoSession = + (DefaultRepositorySystemSession) maven.newRepositorySession(request); + repoSession.setLocalRepositoryManager( + new SimpleLocalRepositoryManagerFactory().newInstance(repoSession, + new LocalRepository(request.getLocalRepository().getBasedir()))); + + @SuppressWarnings("deprecation") + MavenSession session = new MavenSession(getContainer(), + repoSession, + request, result); + return session; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * Extends the super to use the new {@link #newMavenSession()} introduced here + * which sets the defaults one expects from maven; the standard test case leaves a lot of things blank + */ + @Override + protected MavenSession newMavenSession(MavenProject project) { + MavenSession session = newMavenSession(); + session.setCurrentProject(project); + session.setProjects(Arrays.asList(project)); + return session; + } + + /** + * As {@link #lookupConfiguredMojo(MavenProject, String)} but taking the pom file + * and creating the {@link MavenProject}. + */ + protected Mojo lookupConfiguredMojo(File pom, String goal) throws Exception { + assertNotNull(pom); + assertTrue(pom.exists()); + this.getContainer().addComponent(new IncludeProjectDependenciesComponentConfigurator(), org.codehaus.plexus.component.configurator.ComponentConfigurator.class, "include-project-dependencies"); + ProjectBuildingRequest buildingRequest = newMavenSession().getProjectBuildingRequest(); + ProjectBuilder projectBuilder = lookup(ProjectBuilder.class); + MavenProject project = projectBuilder.build(pom, buildingRequest).getProject(); + + return lookupConfiguredMojo(project, goal); + } + +} \ No newline at end of file diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/SwaggerResolveTest.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/SwaggerResolveTest.java new file mode 100644 index 0000000000..694eba0751 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/SwaggerResolveTest.java @@ -0,0 +1,79 @@ +package io.swagger.v3.plugin.maven; + +import io.swagger.v3.core.util.Json; +import io.swagger.v3.core.util.Yaml; +import io.swagger.v3.oas.models.OpenAPI; +import org.apache.commons.io.FileUtils; +import org.codehaus.plexus.configuration.PlexusConfiguration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +public class SwaggerResolveTest extends BetterAbstractMojoTestCase{ + + protected static Logger LOGGER = LoggerFactory.getLogger(SwaggerResolveTest.class); + + protected void setUp() throws Exception { + // required for mojo lookups to work + super.setUp(); + } + + public void testResolve() throws Exception { + File pom = getTestFile("src/test/resources/pom.resolveToFile.xml"); + + runTest(pom); + } + + public void testResolveNoName() throws Exception { + File pom = getTestFile("src/test/resources/pom.resolveToFileNoName.xml"); + + runTest(pom); + } + + public void testResolveJsonAndYaml() throws Exception { + File pom = getTestFile("src/test/resources/pom.resolveToFileJsonAndYaml.xml"); + + runTest(pom); + } + + private void runTest(File pom) throws Exception { + assertNotNull(pom); + assertTrue( pom.exists() ); + + SwaggerMojo swaggerMojo = (SwaggerMojo) lookupConfiguredMojo(pom, "resolve"); + assertNotNull( swaggerMojo ); + + swaggerMojo.execute(); + final PlexusConfiguration config = extractPluginConfiguration("swagger-maven-plugin", pom); + //String outputPath = config.getChild("outputPath").getValue(); + String outputPath = swaggerMojo.getOutputPath(); + String outputFile = config.getChild("outputFileName").getValue(); + if (outputFile == null) { + outputFile = "openapi"; + } + String format = config.getChild("outputFormat").getValue(); + if (format.toLowerCase().equals("yaml") || format.toLowerCase().equals("jsonandyaml")) { + Path path = Paths.get(outputPath, outputFile + ".yaml"); + File file = path.toFile(); + assertTrue(Files.isRegularFile(path)); + String content = FileUtils.readFileToString(file, "UTF-8"); + final OpenAPI openAPI; + openAPI = Yaml.mapper().readValue(content, OpenAPI.class); + assertNotNull(openAPI); + } + if (format.toLowerCase().equals("json") || format.toLowerCase().equals("jsonandyaml")) { + Path path = Paths.get(outputPath, outputFile + ".json"); + File file = path.toFile(); + assertTrue(Files.isRegularFile(path)); + String content = FileUtils.readFileToString(file, "UTF-8"); + final OpenAPI openAPI; + openAPI = Json.mapper().readValue(content, OpenAPI.class); + assertNotNull(openAPI); + } + + } +} \ No newline at end of file diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/EmptyPetResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/EmptyPetResource.java new file mode 100644 index 0000000000..fdb40cd00d --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/EmptyPetResource.java @@ -0,0 +1,7 @@ +package io.swagger.v3.plugin.maven.petstore.petstore; + +/** + * An Empty PetResource Class + */ +public class EmptyPetResource { +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/PetResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/PetResource.java new file mode 100644 index 0000000000..e6b2be94dc --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/PetResource.java @@ -0,0 +1,166 @@ +/** + * Copyright 2016 SmartBear Software + *

    + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

    + * http://www.apache.org/licenses/LICENSE-2.0 + *

    + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugin.maven.petstore.petstore; + +import io.swagger.v3.plugin.maven.resources.QueryResultBean; +import io.swagger.v3.plugin.maven.resources.data.PetData; +import io.swagger.v3.plugin.maven.resources.exception.NotFoundException; +import io.swagger.v3.plugin.maven.resources.model.Pet; +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.plugin.maven.resources.QueryResultBean; + +import javax.ws.rs.BeanParam; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Response; + +@Consumes("application/json") +@Path("/pet") +@Produces({"application/json", "application/xml"}) +public class PetResource { + static PetData petData = new PetData(); + + @GET + @Path("/{petId}") + @Operation(summary = "Find pet by ID", + description = "Returns a pet when 0 < ID <= 10. ID > 10 or nonintegers will simulate API error conditions", + responses = { + @ApiResponse( + description = "The pet", content = @Content( + schema = @Schema(implementation = Pet.class) + )), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") + }) + public Response getPetById( + @Parameter(description = "ID of pet that needs to be fetched"/*, _enum = "range[1,10]"*/, required = true) + @PathParam("petId") final Long petId) throws NotFoundException { + Pet pet = petData.getPetById(petId); + if (null != pet) { + return Response.ok().entity(pet).build(); + } else { + throw new NotFoundException(404, "Pet not found"); + } + } + + @POST + @Consumes({"application/json", "application/xml"}) + @Operation(summary = "Add a new pet to the store", + responses = { + @ApiResponse(responseCode = "405", description = "Invalid input") + }) + public Response addPet( + @Parameter(description = "Pet object that needs to be added to the store", required = true) final Pet pet) { + petData.addPet(pet); + return Response.ok().entity("SUCCESS").build(); + } + + @POST + @Path("/bodynoannotation") + @Consumes({"application/json", "application/xml"}) + @Produces({"application/json", "application/xml"}) + @Operation(summary = "Add a new pet to the store no annotation", + responses = { + @ApiResponse(responseCode = "405", description = "Invalid input") + }) + public Response addPetNoAnnotation(final Pet pet) { + petData.addPet(pet); + return Response.ok().entity("SUCCESS").build(); + } + + @POST + @Path("/bodyid") + @Consumes({"application/json", "application/xml"}) + @Operation(summary = "Add a new pet to the store passing an integer with generic parameter annotation", + responses = { + @ApiResponse(responseCode = "405", description = "Invalid input") + }) + public Response addPetByInteger( + @Parameter(description = "Pet object that needs to be added to the store", required = true) final int petId) { + return Response.ok().entity("SUCCESS").build(); + } + + @POST + @Path("/bodyidnoannotation") + @Consumes({"application/json", "application/xml"}) + @Operation(summary = "Add a new pet to the store passing an integer without parameter annotation", + responses = { + @ApiResponse(responseCode = "405", description = "Invalid input") + }) + public Response addPetByIntegerNoAnnotation(final int petId) { + return Response.ok().entity("SUCCESS").build(); + } + + @PUT + @Operation(summary = "Update an existing pet", + responses = { + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found"), + @ApiResponse(responseCode = "405", description = "Validation exception")}) + public Response updatePet( + @Parameter(description = "Pet object that needs to be added to the store", required = true) final Pet pet) { + petData.addPet(pet); + return Response.ok().entity("SUCCESS").build(); + } + + @GET + @Path("/findByStatus") + @Produces("application/xml") + @Operation(summary = "Finds Pets by status", + description = "Multiple status values can be provided with comma seperated strings", + responses = { + @ApiResponse( + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = Pet.class))), + @ApiResponse( + responseCode = "400", description = "Invalid status value" + )} + ) + public Response findPetsByStatus( + @Parameter(description = "Status values that need to be considered for filter", required = true) @QueryParam("status") final String status, + @BeanParam final QueryResultBean qr + ) { + return Response.ok(petData.findPetByStatus(status)).build(); + } + + @GET + @Path("/findByTags") + @Produces("application/json") + @Operation(summary = "Finds Pets by tags", + description = "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", + responses = { + @ApiResponse(description = "Pets matching criteria", + content = @Content(schema = @Schema(implementation = Pet.class)) + ), + @ApiResponse(description = "Invalid tag value", responseCode = "400") + }) + @Deprecated + public Response findPetsByTags( + @Parameter(description = "Tags to filter by", required = true) @QueryParam("tags") final String tags) { + return Response.ok(petData.findPetByTags(tags)).build(); + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/callback/ComplexCallbackResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/callback/ComplexCallbackResource.java new file mode 100644 index 0000000000..a9572f76d0 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/callback/ComplexCallbackResource.java @@ -0,0 +1,62 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.callback; + +import io.swagger.v3.plugin.maven.resources.model.User; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.callbacks.Callback; +import io.swagger.v3.oas.annotations.callbacks.Callbacks; +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 javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +public class ComplexCallbackResource { + @Callbacks({ + @Callback( + name = "testCallback1", + operation = @Operation( + operationId = "getAllReviews", + summary = "get all the reviews", + method = "get", + responses = @ApiResponse( + responseCode = "200", + description = "successful operation", + content = @Content( + mediaType = "application/json", + schema = @Schema( + type = "integer", + format = "int32")))), + callbackUrlExpression = "http://www.url.com"), + @Callback( + name = "testCallback2", + operation = @Operation( + operationId = "getAnSpecificReviews", + summary = "get a review", + method = "get", + responses = @ApiResponse( + responseCode = "200", + description = "successful operation", + content = @Content( + mediaType = "application/json", + schema = @Schema( + implementation = User.class)))), + callbackUrlExpression = "http://www.url2.com") + }) + @Operation( + summary = "Simple get operation", + operationId = "getWithNoParameters", + responses = { + @ApiResponse( + responseCode = "200", + description = "voila!") + }) + @GET + @Path("/complexcallback") + public String simpleGet(@Parameter(description = "idParam", schema = @Schema(implementation = User.class)) + @QueryParam("id") final String id) { + return null; + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/callback/MultipleCallbacksTestWithOperationResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/callback/MultipleCallbacksTestWithOperationResource.java new file mode 100644 index 0000000000..9ac962674f --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/callback/MultipleCallbacksTestWithOperationResource.java @@ -0,0 +1,45 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.callback; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.callbacks.Callback; +import io.swagger.v3.oas.annotations.callbacks.Callbacks; +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 javax.ws.rs.GET; +import javax.ws.rs.Path; + +public class MultipleCallbacksTestWithOperationResource { + @Callbacks({ + @Callback( + name = "testCallback1", + operation = @Operation( + operationId = "getAllReviews", + summary = "get all the reviews", + method = "get", + responses = @ApiResponse( + responseCode = "200", + description = "successful operation", + content = @Content( + mediaType = "application/json", + schema = @Schema( + type = "integer", + format = "int32")))), + callbackUrlExpression = "http://www.url.com"), + @Callback(name = "testCallback2", operation = @Operation(), callbackUrlExpression = "http://$request.query.url") + }) + @Operation( + summary = "Simple get operation", + operationId = "getWithNoParameters", + responses = { + @ApiResponse( + responseCode = "200", + description = "voila!") + }) + @GET + @Path("/multiplecallback") + public String simpleGet() { + return null; + } +} \ No newline at end of file diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/callback/RepeatableCallbackResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/callback/RepeatableCallbackResource.java new file mode 100644 index 0000000000..3615402099 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/callback/RepeatableCallbackResource.java @@ -0,0 +1,46 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.callback; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.callbacks.Callback; +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 javax.ws.rs.GET; +import javax.ws.rs.Path; + +public class RepeatableCallbackResource { + @Callback(name = "testCallback", operation = + @Operation(), callbackUrlExpression = "http://$requests.query.url") + @Callback( + name = "testCallback1", + operation = @Operation( + operationId = "getAllReviews", + summary = "get all the reviews", + method = "get", + responses = @ApiResponse( + responseCode = "200", + description = "successful operation", + content = @Content( + mediaType = "application/json", + schema = @Schema( + type = "integer", + format = "int32")))), + callbackUrlExpression = "http://www.url.com") + @Callback(name = "testCallback2", operation = + @Operation(), + callbackUrlExpression = "http://$request.query.url") + @Operation( + summary = "Simple get operation", + operationId = "getWithNoParameters", + responses = { + @ApiResponse( + responseCode = "200", + description = "voila!") + }) + @GET + @Path("/repeatablecallback") + public String simpleGet() { + return null; + } +} \ No newline at end of file diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/callback/SimpleCallbackWithOperationResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/callback/SimpleCallbackWithOperationResource.java new file mode 100644 index 0000000000..056e82fb92 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/callback/SimpleCallbackWithOperationResource.java @@ -0,0 +1,44 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.callback; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.callbacks.Callback; +import io.swagger.v3.oas.annotations.callbacks.Callbacks; +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 javax.ws.rs.GET; +import javax.ws.rs.Path; + +public class SimpleCallbackWithOperationResource { + @Callbacks({ + @Callback( + name = "testCallback1", + operation = @Operation( + operationId = "getAllReviews", + summary = "get all the reviews", + method = "get", + responses = @ApiResponse( + responseCode = "200", + description = "successful operation", + content = @Content( + mediaType = "application/json", + schema = @Schema( + type = "integer", + format = "int32")))), + callbackUrlExpression = "http://www.url.com") + }) + @Operation( + summary = "Simple get operation", + operationId = "getWithNoParameters", + responses = { + @ApiResponse( + responseCode = "200", + description = "voila!") + }) + @GET + @Path("/simplecallback") + public String simpleGet() { + return null; + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/example/ExamplesResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/example/ExamplesResource.java new file mode 100644 index 0000000000..7a5db966cb --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/example/ExamplesResource.java @@ -0,0 +1,69 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.example; + +import io.swagger.v3.plugin.maven.resources.model.User; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.enums.ParameterStyle; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.ExampleObject; +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 javax.ws.rs.POST; +import javax.ws.rs.Path; + +/** + * Examples Resource Scenario + */ +public class ExamplesResource { + @Path("/example") + @POST + @Operation( + operationId = "subscribe", + description = "subscribes a client to updates relevant to the requestor's account", + parameters = { + @Parameter(in = ParameterIn.PATH, name = "subscriptionId", required = true, + schema = @Schema(name = "Schema", description = "Schema", example = "Subscription example"), + style = ParameterStyle.SIMPLE, example = "example", + examples = { + @ExampleObject(name = "subscriptionId_1", value = "12345", + summary = "Subscription number 12345", externalValue = "Subscription external value 1"), + @ExampleObject(name = "subscriptionId_2", value = "54321", + summary = "Subscription number 54321", externalValue = "Subscription external value 2") + }) + }, + responses = { + @ApiResponse( + description = "test description", + content = @Content( + mediaType = "*/*", + schema = @Schema( + type = "string", + format = "uuid", + description = "the generated UUID", + accessMode = Schema.AccessMode.READ_ONLY, + example = "Schema example" + ), + examples = { + @ExampleObject(name = "Default Response", value = "SubscriptionResponse", + summary = "Subscription Response Example", externalValue = "Subscription Response value 1") + } + )) + }) + public SubscriptionResponse subscribe(@RequestBody(description = "Created user object", required = true, + content = @Content( + schema = @Schema( + type = "string", + format = "uuid", + description = "the generated UUID", + accessMode = Schema.AccessMode.READ_ONLY, + example = "Schema example"), + examples = { + @ExampleObject(name = "Default Request", value = "SubscriptionRequest", + summary = "Subscription Request Example", externalValue = "Subscription Request Value") + })) User user) { + return null; + } +} \ No newline at end of file diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/example/SubscriptionResponse.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/example/SubscriptionResponse.java new file mode 100644 index 0000000000..143bbe9e76 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/example/SubscriptionResponse.java @@ -0,0 +1,5 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.example; + +public class SubscriptionResponse { + public String subscriptionId; +} \ No newline at end of file diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/link/LinksResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/link/LinksResource.java new file mode 100644 index 0000000000..97123f4704 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/link/LinksResource.java @@ -0,0 +1,44 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.link; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.links.Link; +import io.swagger.v3.oas.annotations.links.LinkParameter; +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 javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +/** + * Class with Links + */ +public class LinksResource { + @Path("/links") + @Operation(operationId = "getUserWithAddress", + responses = { + @ApiResponse(description = "test description", + content = @Content(mediaType = "*/*", schema = @Schema(ref = "#/components/schemas/User")), + links = { + @Link( + name = "address", + operationId = "getAddress", + parameters = @LinkParameter( + name = "userId", + expression = "$request.query.userId")), + @Link( + name = "user", + operationId = "getUser", + operationRef = "#/components/links/MyLink", + parameters = @LinkParameter( + name = "userId", + expression = "$request.query.userId")) + })} + ) + @GET + public String getUser(@QueryParam("userId")final String userId) { + return null; + } + +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/openapidefintion/OpenAPIDefinitionResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/openapidefintion/OpenAPIDefinitionResource.java new file mode 100644 index 0000000000..01a3c58835 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/openapidefintion/OpenAPIDefinitionResource.java @@ -0,0 +1,48 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.openapidefintion; + +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.info.Contact; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.info.License; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.servers.Server; +import io.swagger.v3.oas.annotations.servers.ServerVariable; +import io.swagger.v3.oas.annotations.tags.Tag; + +/** + * OpenAPIDefinition Example + */ +@OpenAPIDefinition( + info = @Info( + title = "Pet Resource Example", + version = "2.0", + description = "API Definition", + termsOfService = "Terms of service", + license = @License(name = "Apache 2.0", url = "http://foo.bar"), + contact = @Contact(url = "http://gigantic-server.com", name = "Fred", email = "Fred@gigagantic-server.com") + ), + tags = { + @Tag(name = "Tag 1", description = "desc 1", externalDocs = @ExternalDocumentation(description = "docs desc")), + @Tag(name = "Tag 2", description = "desc 2", externalDocs = @ExternalDocumentation(description = "docs desc 2")), + @Tag(name = "Tag 3") + }, + externalDocs = @ExternalDocumentation(description = "definition docs desc"), + security = { + @SecurityRequirement(name = "req 1", scopes = {"a", "b"}), + @SecurityRequirement(name = "req 2", scopes = {"b", "c"}) + }, + servers = { + @Server( + description = "server 1", + url = "http://foo", + variables = { + @ServerVariable(name = "var1", description = "var 1", defaultValue = "1", allowableValues = {"1", "2"}), + @ServerVariable(name = "var2", description = "var 2", defaultValue = "1", allowableValues = {"1", "2"}) + }) + } +) +public class OpenAPIDefinitionResource { + public void foo() { + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/AnnotatedSameNameOperationResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/AnnotatedSameNameOperationResource.java new file mode 100644 index 0000000000..5eec9d0b97 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/AnnotatedSameNameOperationResource.java @@ -0,0 +1,26 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.operation; + +import io.swagger.v3.oas.annotations.Operation; + +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +/** + * Resource With a Default Operation without Annotation + */ +public class AnnotatedSameNameOperationResource { + @Path("/sameOperationName") + @GET + @Operation(description = "Same Operation Name") + public String getUser() { + return new String(); + } + + @Path("//sameOperationName") + @DELETE + @Operation(description = "Same Operation Name Duplicated") + public String getUser(final String id) { + return new String(); + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/ExternalDocumentationResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/ExternalDocumentationResource.java new file mode 100644 index 0000000000..dd08c56fc1 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/ExternalDocumentationResource.java @@ -0,0 +1,30 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.operation; + +import io.swagger.v3.plugin.maven.resources.exception.NotFoundException; +import io.swagger.v3.plugin.maven.resources.model.Pet; +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.Response; + +/** + * Resource with Operations Examples + */ +public class ExternalDocumentationResource { + @GET + @Path("/{petId}") + @Operation(summary = "Find pet by ID", + description = "Returns a pet when 0 < ID <= 10. ID > 10 or non integers will simulate API error conditions", + operationId = "petId", + externalDocs = @ExternalDocumentation(description = "External in Operation", url = "http://url.me")) + @ExternalDocumentation(description = "External Annotation Documentation", url = "http://url.me") + public Response getPetById( + @Parameter(description = "ID of pet that needs to be fetched", required = true) + @PathParam("petId") Long petId) throws NotFoundException { + return Response.ok().entity(new Pet()).build(); + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/FullyAnnotatedOperationResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/FullyAnnotatedOperationResource.java new file mode 100644 index 0000000000..4f4b548237 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/FullyAnnotatedOperationResource.java @@ -0,0 +1,38 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.operation; + +import io.swagger.v3.plugin.maven.resources.exception.NotFoundException; +import io.swagger.v3.plugin.maven.resources.model.Pet; +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 javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.Response; + +/** + * Resource with Operations Examples + */ +public class FullyAnnotatedOperationResource { + @GET + @Path("/fullyannotatedoperation/{petId}") + @Operation(summary = "Find pet by ID", + description = "Returns a pet when 0 < ID <= 10. ID > 10 or non integers will simulate API error conditions", + operationId = "petId", + responses = { + @ApiResponse( + description = "The pet", content = @Content( + schema = @Schema(implementation = Pet.class) + )), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") + }) + public Response getPetById( + @Parameter(description = "ID of pet that needs to be fetched", required = true) + @PathParam("petId")final Long petId) throws NotFoundException { + return Response.ok().entity(new Pet()).build(); + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/HiddenOperationResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/HiddenOperationResource.java new file mode 100644 index 0000000000..c18083196d --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/HiddenOperationResource.java @@ -0,0 +1,29 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.operation; + +import io.swagger.v3.plugin.maven.resources.model.Pet; +import io.swagger.v3.plugin.maven.resources.model.User; +import io.swagger.v3.oas.annotations.Hidden; +import io.swagger.v3.oas.annotations.Operation; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +/** + * Resource With a Hidden Operation + */ +public class HiddenOperationResource { + @Path("/hiddenbyflag") + @GET + @Operation(operationId = "Pets", description = "Pets Example", hidden = true) + public Pet getPet() { + return new Pet(); + } + + @Path("/hiddenbyannotation") + @GET + @Operation(operationId = "Users", description = "Users Example") + @Hidden + public User getUser() { + return new User(); + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/InterfaceResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/InterfaceResource.java new file mode 100644 index 0000000000..ada2d56da1 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/InterfaceResource.java @@ -0,0 +1,22 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.operation; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.Response; + +/** + * Interface resource + */ +public interface InterfaceResource { + @GET + @Path("/interfaceoperation/{petId}") + @Operation(summary = "Find pet by ID Operation in Parent", + description = "Returns a pet in Parent" + ) + Response getPetById(@Parameter(description = "ID of pet that needs to be fetched", required = true) + @PathParam("petId") final Long petId); +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/NotAnnotatedSameNameOperationResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/NotAnnotatedSameNameOperationResource.java new file mode 100644 index 0000000000..9d8a7c6537 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/NotAnnotatedSameNameOperationResource.java @@ -0,0 +1,21 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.operation; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +/** + * Resource With a Default Operation without Annotation + */ +public class NotAnnotatedSameNameOperationResource { + @Path("/notannotatedoperation") + @GET + public String getUser() { + return new String(); + } + + @Path("/notannotatedoperationduplicated") + @GET + public String getUser(final String id) { + return new String(); + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/OperationResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/OperationResource.java new file mode 100644 index 0000000000..98d3c1142e --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/OperationResource.java @@ -0,0 +1,77 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.operation; + +import io.swagger.v3.plugin.maven.resources.model.Pet; +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 javax.ws.rs.GET; +import javax.ws.rs.HEAD; +import javax.ws.rs.NotFoundException; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Response; + +/** + * Resource with Complete Operations Examples + */ +public class OperationResource implements InterfaceResource { + @Override + @Operation(summary = "Find pet by ID Operation in SubResource", + description = "Returns a pet in SubResource" + ) + public Response getPetById(final Long petId) { + return Response.ok().entity(new Pet()).build(); + } + + @GET + @Path("/operationsresource") + @Operation(summary = "Find pet by ID", + description = "combinatedfullyannotatedoperation/{petId}", + operationId = "petId", + responses = { + @ApiResponse( + description = "The pet", content = @Content( + schema = @Schema(implementation = Pet.class) + )), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") + }) + public Response getPetById( + @Parameter(description = "ID of pet that needs to be fetched", required = true) + @QueryParam("petId") final Long petId, final String message) throws NotFoundException { + return Response.ok().entity(new Pet()).build(); + } + + @Path("/operationsresource") + @POST + public String getUser(final String id) { + return new String(); + } + + @Path("/operationsresource") + @PUT + @Operation(operationId = "combinated sameOperationName", + description = "combinatedsameOperationName") + public String getPerson() { + return new String(); + } + + @Path("/operationsresource") + @HEAD + @Operation(operationId = "combinatedsameOperationNameDuplicated", + description = "combinatedsameOperationNameDuplicated") + public String getPerson(final String id) { + return new String(); + } + + @Path("/operationsresource2") + @GET + public String getUser() { + return new String(); + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/OperationWithoutAnnotationResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/OperationWithoutAnnotationResource.java new file mode 100644 index 0000000000..7740873aa3 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/OperationWithoutAnnotationResource.java @@ -0,0 +1,15 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.operation; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +/** + * Resource With a Default Operation without Annotation + */ +public class OperationWithoutAnnotationResource { + @Path("/operationwithouannotation") + @GET + public String getUser() { + return new String(); + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/ServerOperationResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/ServerOperationResource.java new file mode 100644 index 0000000000..99062aa245 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/ServerOperationResource.java @@ -0,0 +1,30 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.operation; + +import io.swagger.v3.plugin.maven.resources.model.Pet; +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.servers.Server; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +/** + * Resource With a Hidden Operation + */ +@OpenAPIDefinition( + servers = { + @Server(description = "server 1", url = "http://foo") + } +) +public class ServerOperationResource { + @Path("/serversoperation") + @GET + @Operation(operationId = "Pets", description = "Pets Example", + servers = { + @Server(description = "server 2", url = "http://foo2") + } + ) + public Pet getPet() { + return new Pet(); + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/SubResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/SubResource.java new file mode 100644 index 0000000000..5f8e9c2d14 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/SubResource.java @@ -0,0 +1,20 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.operation; + +import io.swagger.v3.plugin.maven.resources.model.Pet; +import io.swagger.v3.oas.annotations.Operation; + +import javax.ws.rs.core.Response; + +/** + * SubResource + */ + +public class SubResource implements InterfaceResource { + @Override + @Operation(summary = "Find pet by ID Operation in SubResource", + description = "Returns a pet in SubResource" + ) + public Response getPetById(final Long petId) { + return Response.ok().entity(new Pet()).build(); + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/ArraySchemaResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/ArraySchemaResource.java new file mode 100644 index 0000000000..41cdaaed16 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/ArraySchemaResource.java @@ -0,0 +1,44 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.parameter; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.Explode; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.ArraySchema; +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 javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; + +public class ArraySchemaResource { + @Path("/arrayschema") + @POST + @Operation( + operationId = "subscribe", + description = "subscribes a client to updates relevant to the requestor's account, as " + + "identified by the input token. The supplied url will be used as the delivery address for response payloads", + parameters = { + @Parameter(in = ParameterIn.QUERY, name = "arrayParameter", required = true, explode = Explode.TRUE, + array = @ArraySchema(maxItems = 10, minItems = 1, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class), + uniqueItems = true + ) + ), + }, + responses = { + @ApiResponse( + description = "test description", content = @Content( + mediaType = "*/*", + schema = + @Schema( + implementation = ParametersResource.SubscriptionResponse.class) + )) + }) + @Consumes({"application/json", "application/xml"}) + public ParametersResource.SubscriptionResponse subscribe() { + return null; + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/ComplexParameterResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/ComplexParameterResource.java new file mode 100644 index 0000000000..f5f7507893 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/ComplexParameterResource.java @@ -0,0 +1,33 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.parameter; + +import io.swagger.v3.plugin.maven.resources.model.User; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +/** + * Class with a multiple annotated. + */ +public class ComplexParameterResource { + + @Parameter(description = "Phone definied in Field") + private String phone; + + public ComplexParameterResource(@Parameter(description = "phone Param", name = "phone") final String phone) { + this.phone = phone; + } + + @GET + @Path("/complexparameter") + @Operation(operationId = "create User") + public User findUser(@Parameter(description = "idParam") @QueryParam("id") final String id, + final String name, @QueryParam("lastName") final String lastName, + @Parameter(description = "address", schema = @Schema(implementation = User.class)) + @QueryParam("address") final String address) { + return new User(); + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/ComplexParameterWithOperationResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/ComplexParameterWithOperationResource.java new file mode 100644 index 0000000000..3b36cfa07b --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/ComplexParameterWithOperationResource.java @@ -0,0 +1,37 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.parameter; + +import io.swagger.v3.plugin.maven.resources.model.User; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +/** + * Class with a multiple annotated. + */ +public class ComplexParameterWithOperationResource { + + @Parameter(description = "Phone definied in Field") + private String phone; + + public ComplexParameterWithOperationResource(@Parameter(description = "phone Param", name = "phone") final String phone) { + this.phone = phone; + } + + @GET + @Path("/complexparameter") + @Operation(operationId = "create User", + parameters = { + @Parameter(description = "Phone", name = "phone", in = ParameterIn.PATH) + }) + public User findUser(@Parameter(description = "idParam") @QueryParam("id") final String id, + final String name, @QueryParam("lastName") final String lastName, + @Parameter(description = "address", schema = @Schema(implementation = User.class)) + @QueryParam("address") final String address) { + return new User(); + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/MultipleNotAnnotatedParameter.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/MultipleNotAnnotatedParameter.java new file mode 100644 index 0000000000..d5ca534c6a --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/MultipleNotAnnotatedParameter.java @@ -0,0 +1,18 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.parameter; + +import io.swagger.v3.oas.annotations.Operation; + +import javax.ws.rs.POST; +import javax.ws.rs.Path; + +/** + * Class with a multiple not annotated parameter. + */ +public class MultipleNotAnnotatedParameter { + @POST + @Path("/multiplenoannotatedparameter") + @Operation(operationId = "create User") + public void createUser(final String id, final String name) { + + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/OpenAPIJaxRSAnnotatedParameter.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/OpenAPIJaxRSAnnotatedParameter.java new file mode 100644 index 0000000000..d9c15c2b38 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/OpenAPIJaxRSAnnotatedParameter.java @@ -0,0 +1,21 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.parameter; + +import io.swagger.v3.plugin.maven.resources.model.User; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +/** + * Class with a single parameter annotated with jaxrs and open api annotation. + */ +public class OpenAPIJaxRSAnnotatedParameter { + @GET + @Path("/openapijaxrsannotatedparameter") + @Operation(operationId = "create User") + public User findUser(@Parameter(description = "idParam") @QueryParam("id") final String id) { + return new User(); + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/OpenAPIWithContentJaxRSAnnotatedParameter.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/OpenAPIWithContentJaxRSAnnotatedParameter.java new file mode 100644 index 0000000000..cdaf233999 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/OpenAPIWithContentJaxRSAnnotatedParameter.java @@ -0,0 +1,25 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.parameter; + +import io.swagger.v3.plugin.maven.resources.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 javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +/** + * Class with a single parameter annotated with jaxrs and open api annotation. + */ +public class OpenAPIWithContentJaxRSAnnotatedParameter { + @GET + @Path("/openapiwithcontentjaxrsannotatedparameter") + @Operation(operationId = "create User") + public User findUser(@Parameter(description = "idParam", content = + @Content(schema = @Schema(description = "Id Schema Definition", required = true, name = "id"))) + @QueryParam("id") final String id) { + return new User(); + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/OpenAPIWithImplementationJaxRSAnnotatedParameter.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/OpenAPIWithImplementationJaxRSAnnotatedParameter.java new file mode 100644 index 0000000000..252886e104 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/OpenAPIWithImplementationJaxRSAnnotatedParameter.java @@ -0,0 +1,23 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.parameter; + +import io.swagger.v3.plugin.maven.resources.model.User; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +/** + * Class with a single parameter annotated with jaxrs and open api annotation. + */ +public class OpenAPIWithImplementationJaxRSAnnotatedParameter { + @GET + @Path("/openapiwithimplementationjaxrsannotatedparameter") + @Operation(operationId = "create User") + public User findUser(@Parameter(description = "idParam", schema = @Schema(implementation = User.class)) + @QueryParam("id") final String id) { + return new User(); + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/ParametersResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/ParametersResource.java new file mode 100644 index 0000000000..c28cc96b3f --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/ParametersResource.java @@ -0,0 +1,87 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.parameter; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.Explode; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.enums.ParameterStyle; +import io.swagger.v3.oas.annotations.media.ArraySchema; +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 javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +/** + * Resource with some Parameters examples + */ +public class ParametersResource { + @Path("/parameters") + @POST + @Operation( + operationId = "subscribe", + description = "subscribes a client to updates relevant to the requestor's account, as " + + "identified by the input token. The supplied url will be used as the delivery address for response payloads", + parameters = { + @Parameter(in = ParameterIn.PATH, name = "subscriptionId", required = true, + schema = @Schema(implementation = RepeatableParametersResource.SubscriptionResponse.class), style = ParameterStyle.SIMPLE), + @Parameter(in = ParameterIn.QUERY, name = "formId", required = true, + example = "Example"), + @Parameter(in = ParameterIn.QUERY, name = "explodeFalse", required = true, explode = Explode.FALSE, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class)), + @Parameter(in = ParameterIn.QUERY, name = "explodeTrue", required = true, explode = Explode.TRUE, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class)), + @Parameter(in = ParameterIn.QUERY, name = "explodeAvoiding", required = true, explode = Explode.TRUE, + schema = @Schema( + type = "int", + format = "id", + description = "the generated id", + accessMode = Schema.AccessMode.READ_ONLY + )), + @Parameter(in = ParameterIn.QUERY, name = "arrayParameter", required = true, explode = Explode.TRUE, + array = @ArraySchema(maxItems = 10, minItems = 1, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class), + uniqueItems = true + ) + , + schema = @Schema( + type = "int", + format = "id", + description = "the generated id", + accessMode = Schema.AccessMode.READ_ONLY), + content = @Content(schema = @Schema(type = "number", + description = "the generated id", + accessMode = Schema.AccessMode.READ_ONLY)) + ), + @Parameter(in = ParameterIn.QUERY, name = "arrayParameterImplementation", required = true, explode = Explode.TRUE, + array = @ArraySchema(maxItems = 10, minItems = 1, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class), + uniqueItems = true + ) + ), + @Parameter(in = ParameterIn.QUERY, name = "arrayParameterImplementation2", required = true, explode = Explode.TRUE, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class)) + + }, + responses = { + @ApiResponse( + description = "test description", content = @Content( + mediaType = "*/*", + schema = + @Schema( + implementation = ParametersResource.SubscriptionResponse.class) + )) + }) + @Consumes({"application/json", "application/xml"}) + public ParametersResource.SubscriptionResponse subscribe(@Parameter(description = "idParam") + @QueryParam("id") final String id) { + return null; + } + + static class SubscriptionResponse { + public String subscriptionId; + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/RepeatableParametersResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/RepeatableParametersResource.java new file mode 100644 index 0000000000..530d9c30ee --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/RepeatableParametersResource.java @@ -0,0 +1,80 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.parameter; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.Explode; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.enums.ParameterStyle; +import io.swagger.v3.oas.annotations.media.ArraySchema; +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 javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; + +public class RepeatableParametersResource { + @Path("/repeatableparameter") + @POST + @Parameter(in = ParameterIn.PATH, name = "subscriptionId", required = true, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class), style = ParameterStyle.SIMPLE) + @Parameter(in = ParameterIn.QUERY, name = "formId", required = true, + example = "Example") + @Parameter(in = ParameterIn.QUERY, name = "explodeFalse", required = true, explode = Explode.FALSE, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class)) + @Parameter(in = ParameterIn.QUERY, name = "explodeTrue", required = true, explode = Explode.TRUE, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class)) + @Parameter(in = ParameterIn.QUERY, name = "explodeAvoiding", required = true, explode = Explode.TRUE, + schema = @Schema( + type = "int", + format = "id", + description = "the generated id", + accessMode = Schema.AccessMode.READ_ONLY + )) + @Parameter(in = ParameterIn.QUERY, name = "arrayParameter", required = true, explode = Explode.TRUE, + array = @ArraySchema(maxItems = 10, minItems = 1, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class), + uniqueItems = true + ) + , + schema = @Schema( + type = "int", + format = "id", + description = "the generated id", + accessMode = Schema.AccessMode.READ_ONLY), + content = @Content(schema = @Schema(type = "number", + description = "the generated id", + accessMode = Schema.AccessMode.READ_ONLY)) + ) + @Parameter(in = ParameterIn.QUERY, name = "arrayParameterImplementation", required = true, explode = Explode.TRUE, + array = @ArraySchema(maxItems = 10, minItems = 1, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class), + uniqueItems = true + ) + ) + @Parameter(in = ParameterIn.QUERY, name = "arrayParameterImplementation2", required = true, explode = Explode.TRUE, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class)) + @Operation( + operationId = "subscribe", + description = "subscribes a client to updates relevant to the requestor's account, as " + + "identified by the input token. The supplied url will be used as the delivery address for response payloads", + responses = { + @ApiResponse( + description = "test description", content = @Content( + mediaType = "*/*", + schema = + @Schema( + implementation = ParametersResource.SubscriptionResponse.class) + )) + }) + @Consumes({"application/json", "application/xml"}) + public ParametersResource.SubscriptionResponse subscribe() { + return null; + } + + static class SubscriptionResponse { + public String subscriptionId; + } +} + diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/SingleJaxRSAnnotatedParameter.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/SingleJaxRSAnnotatedParameter.java new file mode 100644 index 0000000000..6542dde245 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/SingleJaxRSAnnotatedParameter.java @@ -0,0 +1,20 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.parameter; + +import io.swagger.v3.plugin.maven.resources.model.User; +import io.swagger.v3.oas.annotations.Operation; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +/** + * Class with a single parameter annotated with jaxrs. + */ +public class SingleJaxRSAnnotatedParameter { + @GET + @Path("/singlejaxrsannotatedparameter") + @Operation(operationId = "create User") + public User findUser(@QueryParam("id") final String id) { + return new User(); + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/SingleNotAnnotatedParameter.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/SingleNotAnnotatedParameter.java new file mode 100644 index 0000000000..a645892c6f --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/parameter/SingleNotAnnotatedParameter.java @@ -0,0 +1,19 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.parameter; + +import io.swagger.v3.plugin.maven.resources.model.User; +import io.swagger.v3.oas.annotations.Operation; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +/** + * Class with a single not annotated parameter. + */ +public class SingleNotAnnotatedParameter { + @GET + @Path("/singlenoannotatedparameter") + @Operation(operationId = "create User") + public User findUser(final String id) { + return new User(); + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/requestbody/RequestBodyMethodPriorityResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/requestbody/RequestBodyMethodPriorityResource.java new file mode 100644 index 0000000000..cc063d4ea6 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/requestbody/RequestBodyMethodPriorityResource.java @@ -0,0 +1,28 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.requestbody; + +import io.swagger.v3.plugin.maven.resources.model.User; +import io.swagger.v3.oas.annotations.Operation; +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 javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; + +/** + * Resource with RequestBody inside Operation and another in Method + */ +public class RequestBodyMethodPriorityResource { + @POST + @Path("/requestbodymethodpriority") + @Operation(summary = "Create user", + description = "This can only be done by the logged in user.", + requestBody = @RequestBody(description = "Inside Operation")) + @RequestBody(description = "Created user object on Method", required = true, + content = @Content( + schema = @Schema(implementation = User.class))) + public Response methodWithRequestBodyAndTwoParameters(final User user) { + return Response.ok().entity("").build(); + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/requestbody/RequestBodyParameterPriorityResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/requestbody/RequestBodyParameterPriorityResource.java new file mode 100644 index 0000000000..abf363d0b3 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/requestbody/RequestBodyParameterPriorityResource.java @@ -0,0 +1,29 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.requestbody; + +import io.swagger.v3.plugin.maven.resources.model.User; +import io.swagger.v3.oas.annotations.Operation; +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 javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; + +/** + * Resource with RequestBody inside Operation and another in Method + */ +public class RequestBodyParameterPriorityResource { + @POST + @Path("/requestbodyparameterpriority") + @Operation(summary = "Create user", + description = "This can only be done by the logged in user.", + requestBody = @RequestBody(description = "Inside Operation")) + @RequestBody(description = "On method") + public Response methodWithRequestBodyAndTwoParameters( + @RequestBody(description = "Created user object inside Parameter", required = true, + content = @Content( + schema = @Schema(implementation = User.class)))final User user) { + return Response.ok().entity("").build(); + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/requestbody/RequestBodyResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/requestbody/RequestBodyResource.java new file mode 100644 index 0000000000..a72364537c --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/requestbody/RequestBodyResource.java @@ -0,0 +1,113 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.requestbody; + +import io.swagger.v3.plugin.maven.resources.model.Pet; +import io.swagger.v3.plugin.maven.resources.model.User; +import io.swagger.v3.oas.annotations.Operation; +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 javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Response; + +/** + * Resource with RequestBody examples + */ +public class RequestBodyResource { + @GET + @Path("/methodWithRequestBodyWithoutContent") + @Operation(summary = "Create user", + description = "This can only be done by the logged in user.") + public Response methodWithRequestBodyWithoutContent( + @RequestBody(description = "Created user object", required = true) final User user) { + return Response.ok().entity("").build(); + } + + @GET + @Path("/methodWithRequestBodyWithoutContentWithoutImplementation") + @Operation(summary = "Create user", + description = "This can only be done by the logged in user.") + public Response methodWithRequestBodyWithoutContentWithoutImplementation( + @RequestBody(description = "Created user object", required = true, + content = @Content( + schema = @Schema(name = "User", description = "User description", + example = "User Description", required = true))) final User user) { + return Response.ok().entity("").build(); + } + + @POST + @Path("/methodWithRequestBodyAndTwoParameters") + @Operation(summary = "Create user", + description = "This can only be done by the logged in user.") + public Response methodWithRequestBodyAndTwoParameters( + @RequestBody(description = "Created user object", required = true, + content = @Content( + schema = @Schema(implementation = User.class))) final User user, + @QueryParam("name") final String name, @QueryParam("code") final String code) { + return Response.ok().entity("").build(); + } + + @PUT + @Path("/methodWithRequestBodyWithoutAnnotation") + @Operation(summary = "Modify user", + description = "Modifying user.") + public Response methodWithRequestBodyWithoutAnnotation( + final User user) { + return Response.ok().entity("").build(); + } + + @DELETE + @Path("/methodWithoutRequestBodyAndTwoParameters") + @Operation(summary = "Delete user", + description = "This can only be done by the logged in user.") + public Response methodWithoutRequestBodyAndTwoParameters( + @QueryParam("name") final String name, @QueryParam("code") final String code) { + return Response.ok().entity("").build(); + } + + @PUT + @Path("/methodWithRequestBodyWithoutAnnotationAndTwoConsumes") + @Operation(summary = "Modify pet", + description = "Modifying pet.") + @Consumes({"application/json", "application/xml"}) + public Response methodWithRequestBodyWithoutAnnotationAndTwoConsumes( + final User user) { + return Response.ok().entity("").build(); + } + + @POST + @Path("/methodWithTwoRequestBodyWithoutAnnotationAndTwoConsumes") + @Operation(summary = "Create pet", + description = "Creating pet.") + @Consumes({"application/json", "application/xml"}) + public Response methodWithTwoRequestBodyWithoutAnnotationAndTwoConsumes( + final Pet pet, final User user) { + return Response.ok().entity("").build(); + } + + @POST + @Path("/methodWithTwoRequestBodyWithAnnotationAndTwoConsumes") + @Operation(summary = "Create pet", + description = "Creating pet.") + @Consumes({"application/json", "application/xml"}) + public Response methodWithTwoRequestBodyWithAnnotationAndTwoConsumes( + final @RequestBody(description = "Request Body Pet") Pet pet, + @RequestBody(description = "Request Body User") final User user) { + return Response.ok().entity("").build(); + } + + @DELETE + @Path("/methodWithOneSimpleRequestBody") + @Operation(summary = "Delete pet", + description = "Deleting pet.") + @Consumes({"application/json", "application/xml"}) + public Response methodWithOneSimpleRequestBody(final int id) { + return Response.ok().entity("").build(); + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/responses/ComplexResponseResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/responses/ComplexResponseResource.java new file mode 100644 index 0000000000..488614cda4 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/responses/ComplexResponseResource.java @@ -0,0 +1,34 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.responses; + +import io.swagger.v3.plugin.maven.resources.exception.NotFoundException; +import io.swagger.v3.plugin.maven.resources.model.Pet; +import io.swagger.v3.oas.annotations.Operation; +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 javax.ws.rs.GET; +import javax.ws.rs.Path; + +/** + * Resource with some responses + */ +public class ComplexResponseResource { + @GET + @Path("/complexresponse") + @Operation(summary = "Find pets", + description = "Returns the Pets", + responses = { + @ApiResponse(description = "Response inside Operation", responseCode = "200", + content = @Content(schema = + @Schema(implementation = Pet.class))), + @ApiResponse(description = "Default Pet", + content = @Content(schema = + @Schema(name = "Default Pet", description = "Default Pet", + required = true, example = "New Pet"))) + }) + @ApiResponse(responseCode = "404", description = "Couldn't find pet") + public Pet getPets() throws NotFoundException { + return new Pet(); + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/responses/ImplementationResponseResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/responses/ImplementationResponseResource.java new file mode 100644 index 0000000000..c73a9a4346 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/responses/ImplementationResponseResource.java @@ -0,0 +1,71 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.responses; + +import io.swagger.v3.oas.annotations.Operation; +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 javax.ws.rs.GET; +import javax.ws.rs.Path; + +/** + * Resource with a Response at Method Level + */ +public class ImplementationResponseResource { + @GET + @Path("/implementationresponse") + @Operation( + summary = "Simple get operation", + description = "Defines a simple get operation with no inputs and a complex output object", + operationId = "getWithPayloadResponse", + deprecated = true, + responses = { + @ApiResponse( + responseCode = "200", + description = "voila!", + content = { + @Content( + mediaType = "application/json", + schema = + @Schema( + implementation = ImplementationResponseResource.SampleResponseSchema.class) + ), + @Content( + mediaType = "application/json", + schema = + @Schema( + implementation = ImplementationResponseResource.SecondSampleResponseSchema.class) + ) + } + + ), + @ApiResponse( + responseCode = "400", + description = "boo", + content = @Content( + mediaType = "*/*", + schema = + @Schema(implementation = ImplementationResponseResource.GenericError.class) + ) + ) + } + ) + + public void getResponses() { + } + + static class SampleResponseSchema { + @Schema(description = "the user id") + private String id; + } + + static class SecondSampleResponseSchema { + @Schema(description = "the user id") + private String id; + } + + static class GenericError { + private int code; + private String message; + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/responses/MethodResponseResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/responses/MethodResponseResource.java new file mode 100644 index 0000000000..336cb804ac --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/responses/MethodResponseResource.java @@ -0,0 +1,24 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.responses; + +import io.swagger.v3.plugin.maven.resources.exception.NotFoundException; +import io.swagger.v3.plugin.maven.resources.model.Pet; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; + +/** + * Resource with a Response at Method Level + */ +public class MethodResponseResource { + @GET + @Path("/responseinmethod") + @Operation(summary = "Find pets", + description = "Returns the Pets") + @ApiResponse(responseCode = "200", description = "Status OK") + public Response getPets() throws NotFoundException { + return Response.ok().entity(new Pet()).build(); + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/responses/NoImplementationResponseResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/responses/NoImplementationResponseResource.java new file mode 100644 index 0000000000..069698aaf2 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/responses/NoImplementationResponseResource.java @@ -0,0 +1,66 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.responses; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.links.Link; +import io.swagger.v3.oas.annotations.links.LinkParameter; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +/** + * Resource with a Response at Method Level + */ +public class NoImplementationResponseResource { + @Path("/noimplementationresponseresource") + @Operation(operationId = "getUser", + responses = { + @ApiResponse(description = "test description", responseCode = "400", + links = { + @Link( + name = "user", + operationId = "getUser", + operationRef = "#/components/links/MyLink", + parameters = @LinkParameter( + name = "userId", + expression = "$request.query.userId")) + }), + @ApiResponse(description = "200 description", responseCode = "200", + links = { + @Link( + name = "pet", + operationId = "getUser", + operationRef = "#/components/links/MyLink", + parameters = @LinkParameter( + name = "userId", + expression = "$request.query.userId")) + }) + } + ) + @GET + public NoImplementationResponseResource.User getUser(@QueryParam("userId") final String userId) { + return null; + } + + static class User { + private String id; + private String username; + + public String getId() { + return id; + } + + public void setId(final String id) { + this.id = id; + } + + public String getUsername() { + return username; + } + + public void setUsername(final String username) { + this.username = username; + } + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/responses/NoResponseResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/responses/NoResponseResource.java new file mode 100644 index 0000000000..3a7ea5b8ea --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/responses/NoResponseResource.java @@ -0,0 +1,21 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.responses; + +import io.swagger.v3.plugin.maven.resources.exception.NotFoundException; +import io.swagger.v3.plugin.maven.resources.model.User; +import io.swagger.v3.oas.annotations.Operation; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +/** + * Resource with a Response at Method Level + */ +public class NoResponseResource { + @GET + @Path("/noresponse") + @Operation(summary = "Find pets", + description = "Returns the Pets") + public User getPets() throws NotFoundException { + return new User(); + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/responses/OperationResponseResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/responses/OperationResponseResource.java new file mode 100644 index 0000000000..dfacd71fa6 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/responses/OperationResponseResource.java @@ -0,0 +1,25 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.responses; + +import io.swagger.v3.plugin.maven.resources.exception.NotFoundException; +import io.swagger.v3.plugin.maven.resources.model.User; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; + +/** + * Resource with the response in the Operation Annotation + */ +public class OperationResponseResource { + @GET + @Path("/responseinoperation") + @Operation(summary = "Find Users", + description = "Returns the Users", + responses = {@ApiResponse(responseCode = "200", description = "Status OK")}) + public Response getUsers() throws NotFoundException { + return Response.ok().entity(new User()).build(); + } + +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/responses/PriorityResponseResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/responses/PriorityResponseResource.java new file mode 100644 index 0000000000..06394cfc75 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/responses/PriorityResponseResource.java @@ -0,0 +1,25 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.responses; + +import io.swagger.v3.plugin.maven.resources.exception.NotFoundException; +import io.swagger.v3.plugin.maven.resources.model.Pet; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; + +/** + * Resource with a Response at Method Level and Operation Level. + */ +public class PriorityResponseResource { + @GET + @Path("/priorityresponses") + @Operation(summary = "Find pets", + description = "Returns the Pets", + responses = {@ApiResponse(responseCode = "200", description = "Inside Operation Response")}) + @ApiResponse(responseCode = "200", description = "Inside Method Operation") + public Response getPets() throws NotFoundException { + return Response.ok().entity(new Pet()).build(); + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/security/SecurityResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/security/SecurityResource.java new file mode 100644 index 0000000000..9ab1d59b4e --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/security/SecurityResource.java @@ -0,0 +1,61 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.security; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeIn; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.security.OAuthFlow; +import io.swagger.v3.oas.annotations.security.OAuthFlows; +import io.swagger.v3.oas.annotations.security.OAuthScope; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.security.SecurityScheme; + +import javax.ws.rs.GET; +import javax.ws.rs.PATCH; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; + +@SecurityScheme(name = "myOauth2Security", + type = SecuritySchemeType.OAUTH2, + in = SecuritySchemeIn.HEADER, + description = "myOauthSecurity Description", + flows = @OAuthFlows(implicit = @OAuthFlow(authorizationUrl = "http://x.com", + scopes = @OAuthScope( + name = "write:pets", + description = "modify pets in your account")) + ) +) +@SecurityRequirement(name = "security_key", + scopes = {"write:pets", "read:pets"} +) +@SecurityRequirement(name = "myOauth2Security", + scopes = {"write:pets"} +) +@Path("/security") +public class SecurityResource { + @GET + @Operation(operationId = "Operation Id", + description = "description") + @SecurityRequirement(name = "security_key", + scopes = {"write:pets", "read:pets"} + ) + public void getSecurity() { + } + + @PATCH + @Operation(operationId = "Operation Id 2", + description = "description 2") + @SecurityRequirement(name = "security_key2", + scopes = {"write:pets", "read:pets"} + ) + public void getSecurity2() { + } + + @PUT + @Operation(operationId = "Operation Id 3", + description = "description 3", security = + @SecurityRequirement(name = "security_key3", + scopes = {"write:pets", "read:pets"} + )) + public void setSecurity(String security) { + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/tags/CompleteTagResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/tags/CompleteTagResource.java new file mode 100644 index 0000000000..5ea76e9ef6 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/tags/CompleteTagResource.java @@ -0,0 +1,31 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.tags; + +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; + +@OpenAPIDefinition(tags = { + @Tag(name = "Definition First Tag"), + @Tag(name = "Definition Second Tag full", description = "desc definition") +}) +@Tag(name = "Second Tag") +@Tag(name = "Fourth Tag Full", description = "desc class", externalDocs = @ExternalDocumentation(description = "docs desc class")) +@Tag(name = "Fifth Tag Full", description = "desc class", externalDocs = @ExternalDocumentation(description = "docs desc class")) +@Tag(name = "Sixth Tag") +public class CompleteTagResource { + + @GET + @Path("/completetags") + @Operation(tags = {"Example Tag", "Second Tag"}) + @Tag(name = "Third Tag") + @Tag(name = "Second Tag") + @Tag(name = "Fourth Tag Full", description = "desc", externalDocs = @ExternalDocumentation(description = "docs desc")) + public Response getTags() { + return Response.ok().entity("ok").build(); + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/tags/TagClassResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/tags/TagClassResource.java new file mode 100644 index 0000000000..f4e9f345f7 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/tags/TagClassResource.java @@ -0,0 +1,14 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.tags; + +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.tags.Tag; + +/** + * Class with Tag Annotations at Class level + */ +@Tag(name = "Second Tag") +@Tag(name = "Fourth Tag Full", description = "desc class", externalDocs = @ExternalDocumentation(description = "docs desc class")) +@Tag(name = "Fifth Tag Full", description = "desc class", externalDocs = @ExternalDocumentation(description = "docs desc class")) +@Tag(name = "Sixth Tag") +public class TagClassResource { +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/tags/TagMethodResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/tags/TagMethodResource.java new file mode 100644 index 0000000000..e6294186f1 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/tags/TagMethodResource.java @@ -0,0 +1,19 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.tags; + +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.tags.Tag; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; + +public class TagMethodResource { + @GET + @Path("/tagsinmethod") + @Tag(name = "Third Tag") + @Tag(name = "Second Tag") + @Tag(name = "Fourth Tag Full", description = "desc", externalDocs = @ExternalDocumentation(description = "docs desc")) + public Response getTags() { + return Response.ok().entity("ok").build(); + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/tags/TagOpenAPIDefinitionResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/tags/TagOpenAPIDefinitionResource.java new file mode 100644 index 0000000000..dae705929d --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/tags/TagOpenAPIDefinitionResource.java @@ -0,0 +1,14 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.tags; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.tags.Tag; + +/** + * Tag in the OpenAPIDefinition annotation + */ +@OpenAPIDefinition(tags = { + @Tag(name = "Definition First Tag"), + @Tag(name = "Definition Second Tag full", description = "desc definition") +}) +public class TagOpenAPIDefinitionResource { +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/tags/TagOperationResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/tags/TagOperationResource.java new file mode 100644 index 0000000000..b01e09f426 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/tags/TagOperationResource.java @@ -0,0 +1,20 @@ +package io.swagger.v3.plugin.maven.petstore.petstore.tags; + +import io.swagger.v3.oas.annotations.Operation; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; + +/** + * Resource with a Tag at Operation Level + */ +public class TagOperationResource { + + @GET + @Path("/tagoperation") + @Operation(tags = {"Example Tag", "Second Tag"}) + public Response getTags() { + return Response.ok().entity("ok").build(); + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/QueryResultBean.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/QueryResultBean.java new file mode 100644 index 0000000000..e64264e309 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/QueryResultBean.java @@ -0,0 +1,43 @@ +/** + * Copyright 2016 SmartBear Software + *

    + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

    + * http://www.apache.org/licenses/LICENSE-2.0 + *

    + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugin.maven.resources; + +import javax.ws.rs.QueryParam; + +public class QueryResultBean { + @QueryParam("skip") + private Integer skip; + + @QueryParam("limit") + private Integer limit; + + public Integer getSkip() { + return skip; + } + + public void setSkip(Integer skip) { + this.skip = skip; + } + + public Integer getLimit() { + return limit; + } + + public void setLimit(Integer limit) { + this.limit = limit; + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/data/PetData.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/data/PetData.java new file mode 100644 index 0000000000..a3999c8875 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/data/PetData.java @@ -0,0 +1,151 @@ +/** + * Copyright 2016 SmartBear Software + *

    + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

    + * http://www.apache.org/licenses/LICENSE-2.0 + *

    + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugin.maven.resources.data; + +import io.swagger.v3.plugin.maven.resources.model.Category; +import io.swagger.v3.plugin.maven.resources.model.Pet; +import io.swagger.v3.plugin.maven.resources.model.Tag; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +public class PetData { + static List pets = new ArrayList(); + static List categories = new ArrayList(); + + static { + categories.add(createCategory(1, "Dogs")); + categories.add(createCategory(2, "Cats")); + categories.add(createCategory(3, "Rabbits")); + categories.add(createCategory(4, "Lions")); + + pets.add(createPet(1, categories.get(1), "Cat 1", new String[]{ + "url1", "url2"}, new String[]{"tag1", "tag2"}, "available")); + pets.add(createPet(2, categories.get(1), "Cat 2", new String[]{ + "url1", "url2"}, new String[]{"tag2", "tag3"}, "available")); + pets.add(createPet(3, categories.get(1), "Cat 3", new String[]{ + "url1", "url2"}, new String[]{"tag3", "tag4"}, "pending")); + + pets.add(createPet(4, categories.get(0), "Dog 1", new String[]{ + "url1", "url2"}, new String[]{"tag1", "tag2"}, "available")); + pets.add(createPet(5, categories.get(0), "Dog 2", new String[]{ + "url1", "url2"}, new String[]{"tag2", "tag3"}, "sold")); + pets.add(createPet(6, categories.get(0), "Dog 3", new String[]{ + "url1", "url2"}, new String[]{"tag3", "tag4"}, "pending")); + + pets.add(createPet(7, categories.get(3), "Lion 1", new String[]{ + "url1", "url2"}, new String[]{"tag1", "tag2"}, "available")); + pets.add(createPet(8, categories.get(3), "Lion 2", new String[]{ + "url1", "url2"}, new String[]{"tag2", "tag3"}, "available")); + pets.add(createPet(9, categories.get(3), "Lion 3", new String[]{ + "url1", "url2"}, new String[]{"tag3", "tag4"}, "available")); + + pets.add(createPet(10, categories.get(2), "Rabbit 1", new String[]{ + "url1", "url2"}, new String[]{"tag3", "tag4"}, "available")); + } + + public Pet getPetById(long petId) { + for (Pet pet : pets) { + if (pet.getId() == petId) { + return pet; + } + } + return null; + } + + public List findPetByStatus(String status) { + String[] statues = status.split(","); + List result = new ArrayList(); + for (Pet pet : pets) { + for (String s : statues) { + if (s.equals(pet.getStatus())) { + result.add(pet); + } + } + } + return result; + } + + public List findPetByCategory(Category category) { + return pets.stream().filter(pet -> category.equals(pet.getCategory())).collect(Collectors.toList()); + } + + public List findPetByTags(String tags) { + String[] tagList = tags.split(","); + List result = new ArrayList(); + for (Pet pet : pets) { + if (null != pet.getTags()) { + for (Tag tag : pet.getTags()) { + for (String tagListString : tagList) { + if (tagListString.equals(tag.getName())) { + result.add(pet); + } + } + } + } + } + return result; + } + + public void addPet(Pet pet) { + if (pets.size() > 0) { + for (int i = pets.size() - 1; i >= 0; i--) { + if (pets.get(i).getId() == pet.getId()) { + pets.remove(i); + } + } + } + pets.add(pet); + } + + static Pet createPet(long id, Category cat, String name, String[] urls, + String[] tags, String status) { + Pet pet = new Pet(); + pet.setId(id); + pet.setCategory(cat); + pet.setName(name); + if (null != urls) { + List urlObjs = new ArrayList(); + for (String urlString : urls) { + urlObjs.add(urlString); + } + pet.setPhotoUrls(urlObjs); + } + List tagObjs = new ArrayList(); + int i = 0; + if (null != tags) { + for (String tagString : tags) { + i = i + 1; + Tag tag = new Tag(); + tag.setId(i); + tag.setName(tagString); + tagObjs.add(tag); + } + } + pet.setTags(tagObjs); + pet.setStatus(status); + return pet; + } + + static Category createCategory(long id, String name) { + Category category = new Category(); + category.setId(id); + category.setName(name); + return category; + } +} \ No newline at end of file diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/data/UserData.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/data/UserData.java new file mode 100644 index 0000000000..a745864832 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/data/UserData.java @@ -0,0 +1,98 @@ +/** + * Copyright 2016 SmartBear Software + *

    + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

    + * http://www.apache.org/licenses/LICENSE-2.0 + *

    + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugin.maven.resources.data; + +import io.swagger.v3.plugin.maven.resources.model.User; + +import java.util.ArrayList; +import java.util.List; + +public class UserData { + static List users = new ArrayList(); + + static { + users.add(createUser(1, "user1", "first name 1", "last name 1", + "email1@test.com", "123-456-7890", 1)); + users.add(createUser(2, "user2", "first name 2", "last name 2", + "email2@test.com", "123-456-7890", 2)); + users.add(createUser(3, "user3", "first name 3", "last name 3", + "email3@test.com", "123-456-7890", 3)); + users.add(createUser(4, "user4", "first name 4", "last name 4", + "email4@test.com", "123-456-7890", 1)); + users.add(createUser(5, "user5", "first name 5", "last name 5", + "email5@test.com", "123-456-7890", 2)); + users.add(createUser(6, "user6", "first name 6", "last name 6", + "email6@test.com", "123-456-7890", 3)); + users.add(createUser(7, "user7", "first name 7", "last name 7", + "email7@test.com", "123-456-7890", 1)); + users.add(createUser(8, "user8", "first name 8", "last name 8", + "email8@test.com", "123-456-7890", 2)); + users.add(createUser(9, "user9", "first name 9", "last name 9", + "email9@test.com", "123-456-7890", 3)); + users.add(createUser(10, "user10", "first name 10", "last name 10", + "email10@test.com", "123-456-7890", 1)); + users.add(createUser(11, "user?10", "first name ?10", "last name ?10", + "email101@test.com", "123-456-7890", 1)); + + } + + public User findUserByName(String username) { + for (User user : users) { + if (user.getUsername().equals(username)) { + return user; + } + } + return null; + } + + public void addUser(User user) { + if (users.size() > 0) { + for (int i = users.size() - 1; i >= 0; i--) { + if (users.get(i).getUsername().equals(user.getUsername())) { + users.remove(i); + } + } + } + users.add(user); + } + + public boolean removeUser(String username) { + if (users.size() > 0) { + for (int i = users.size() - 1; i >= 0; i--) { + if (users.get(i).getUsername().equals(username)) { + users.remove(i); + return true; + } + } + } + return false; + } + + private static User createUser(long id, String username, String firstName, + String lastName, String email, String phone, int userStatus) { + User user = new User(); + user.setId(id); + user.setUsername(username); + user.setFirstName(firstName); + user.setLastName(lastName); + user.setEmail(email); + user.setPassword("XXXXXXXXXXX"); + user.setPhone(phone); + user.setUserStatus(userStatus); + return user; + } +} \ No newline at end of file diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/exception/ApiException.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/exception/ApiException.java new file mode 100644 index 0000000000..9228e1e86e --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/exception/ApiException.java @@ -0,0 +1,26 @@ +/** + * Copyright 2016 SmartBear Software + *

    + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

    + * http://www.apache.org/licenses/LICENSE-2.0 + *

    + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugin.maven.resources.exception; + +public class ApiException extends Exception { + private int code; + + public ApiException(int code, String msg) { + super(msg); + this.code = code; + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/exception/NotFoundException.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/exception/NotFoundException.java new file mode 100644 index 0000000000..95c0775184 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/exception/NotFoundException.java @@ -0,0 +1,26 @@ +/** + * Copyright 2016 SmartBear Software + *

    + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

    + * http://www.apache.org/licenses/LICENSE-2.0 + *

    + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugin.maven.resources.exception; + +public class NotFoundException extends ApiException { + private int code; + + public NotFoundException(int code, String msg) { + super(code, msg); + this.code = code; + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/Category.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/Category.java new file mode 100644 index 0000000000..679f8bdbff --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/Category.java @@ -0,0 +1,51 @@ +/** + * Copyright 2016 SmartBear Software + *

    + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

    + * http://www.apache.org/licenses/LICENSE-2.0 + *

    + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugin.maven.resources.model; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "Category") +public class Category { + private long id; + private String name; + + @XmlElement(name = "id") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @XmlElement(name = "name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Category() { + } + + public Category(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/CustomGenerator.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/CustomGenerator.java new file mode 100644 index 0000000000..f2e2047d9a --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/CustomGenerator.java @@ -0,0 +1,32 @@ +package io.swagger.v3.plugin.maven.resources.model; + +import com.fasterxml.jackson.annotation.ObjectIdGenerator; +import com.fasterxml.jackson.annotation.ObjectIdGenerators; + +public class CustomGenerator extends ObjectIdGenerators.PropertyGenerator { + private static final long serialVersionUID = 1L; + + protected CustomGenerator(Class scope) { + super(scope); + } + + @Override + public ObjectIdGenerator forScope(Class scope) { + return null; + } + + @Override + public ObjectIdGenerator newForSerialization(Object context) { + return null; + } + + @Override + public IdKey key(Object key) { + return null; + } + + @Override + public Object generateId(Object forPojo) { + return null; + } +} \ No newline at end of file diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/ExtensionUser.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/ExtensionUser.java new file mode 100644 index 0000000000..210c56a332 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/ExtensionUser.java @@ -0,0 +1,130 @@ +/** + * Copyright 2016 SmartBear Software + *

    + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

    + * http://www.apache.org/licenses/LICENSE-2.0 + *

    + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugin.maven.resources.model; + +import io.swagger.v3.oas.annotations.extensions.Extension; +import io.swagger.v3.oas.annotations.extensions.ExtensionProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "User") +@Schema( + description = "User", + extensions = { + @Extension(name = "x-user", properties = { + @ExtensionProperty(name = "name", value = "Josh")}), + @Extension(name = "user-extensions", properties = { + @ExtensionProperty(name = "lastName", value = "Hart"), + @ExtensionProperty(name = "address", value = "House")}) + } +) +public class ExtensionUser { + private long id; + private String username; + private String firstName; + private String lastName; + private String email; + private String password; + private String phone; + private int userStatus; + + @XmlElement(name = "id") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @XmlElement(name = "firstName") + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + @XmlElement(name = "username") + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + @XmlElement(name = "lastName") + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + @XmlElement(name = "email") + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + @XmlElement(name = "password") + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @XmlElement(name = "phone") + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + @XmlElement(name = "userStatus") + //@Schema(description = "User Status", type = "string", allowableValues = {"1-registered", "2-active", "3-closed"}) + @Schema( + description = "User Status", + allowableValues = "1-registered,2-active,3-closed", + extensions = { + @Extension(name = "x-userStatus", properties = { + @ExtensionProperty(name = "name", value = "Josh")}), + @Extension(name = "userStatus-extensions", properties = { + @ExtensionProperty(name = "lastName", value = "Hart"), + @ExtensionProperty(name = "address", value = "House")}) + } + ) + public int getUserStatus() { + return userStatus; + } + + public void setUserStatus(int userStatus) { + this.userStatus = userStatus; + } +} \ No newline at end of file diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/JacksonBean.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/JacksonBean.java new file mode 100644 index 0000000000..ecf38e7494 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/JacksonBean.java @@ -0,0 +1,76 @@ +package io.swagger.v3.plugin.maven.resources.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonUnwrapped; +import com.fasterxml.jackson.annotation.JsonValue; + +public class JacksonBean { + + private String id; + private String ignored; + private StringValueBean bean; + private NotFoundModel model; + private NotFoundModel model2; + + @JsonIgnore + public String getIgnored() { + return ignored; + } + + public void setIgnored(String ignored) { + this.ignored = ignored; + } + + public void setId(String id) { + this.id = id; + } + + public void setModel(NotFoundModel model) { + this.model = model; + } + + public StringValueBean getBean() { + return bean; + } + + public void setBean(StringValueBean bean) { + this.bean = bean; + } + + @JsonProperty("identity") + public String getId() { + return id; + } + + @JsonUnwrapped + public NotFoundModel getModel() { + return model; + } + + @JsonUnwrapped(prefix = "pre", suffix = "suf") + public NotFoundModel getModel2() { + return model2; + } + + public void setModel2(NotFoundModel model2) { + this.model2 = model2; + } + + public static class StringValueBean { + + private final String value; + + @JsonCreator + public StringValueBean(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + } + +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/ListOfStringsBeanParam.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/ListOfStringsBeanParam.java new file mode 100644 index 0000000000..a9b2271623 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/ListOfStringsBeanParam.java @@ -0,0 +1,17 @@ +package io.swagger.v3.plugin.maven.resources.model; + +import javax.ws.rs.QueryParam; +import java.util.List; + +public class ListOfStringsBeanParam { + @QueryParam(value = "listOfStrings") + private List list; + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } +} \ No newline at end of file diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/ModelWithJsonIdentity.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/ModelWithJsonIdentity.java new file mode 100644 index 0000000000..32bb930902 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/ModelWithJsonIdentity.java @@ -0,0 +1,145 @@ +package io.swagger.v3.plugin.maven.resources.model; + +import com.fasterxml.jackson.annotation.JsonIdentityInfo; +import com.fasterxml.jackson.annotation.JsonIdentityReference; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.ObjectIdGenerators; + +public class ModelWithJsonIdentity { + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "name") + @JsonProperty("PropertyGeneratorAsId") + public SourceDefinition1 testPropertyGeneratorAsId; + + @JsonIdentityReference(alwaysAsId = false) + @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "name") + @JsonProperty("PropertyGeneratorAsProperty") + public SourceDefinition1 testPropertyGeneratorAsProperty; + + public class SourceDefinition1 { + public String driver; + public String name; + } + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "driverId") + @JsonProperty("ChangedPropertyName") + public SourceDefinition2 testChangedPropertyName; + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "driverId") + @JsonProperty("ChangedPropertyName2") + public SourceDefinition2 testChangedPropertyName2; + + static public class SourceDefinition2 { + @JsonProperty("driverId") + public String driver; + public String name; + } + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class) + @JsonProperty("SourceWithoutPropertyAsId") + public SourceDefinition3 testWithoutPropertyAsId; + + @JsonIdentityReference(alwaysAsId = false) + @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class) + @JsonProperty("SourceWithoutPropertyAsProperty") + public SourceDefinition3 testWithoutPropertyAsProperty; + + public class SourceDefinition3 { + @JsonProperty("driverId") + public String driver; + public String name; + + @JsonProperty("@id") + public String id; + } + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, property = "testName1") + @JsonProperty("IntSequenceGeneratorAsId") + public SourceDefinition4 testIntSequenceGeneratorAsId; + + @JsonIdentityReference(alwaysAsId = false) + @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, property = "testName2") + @JsonProperty("IntSequenceGeneratorAsProperty") + public SourceDefinition4 testIntSequenceGeneratorAsProperty; + + public class SourceDefinition4 { + public String name; + } + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class) + @JsonProperty("IntSequenceWithoutPropertyAsId") + public SourceDefinition5 testIntSequenceWithoutPropertyAsId; + + @JsonIdentityReference(alwaysAsId = false) + @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class) + @JsonProperty("IntSequenceWithoutPropertyAsProperty") + public SourceDefinition5 testIntSequenceWithoutPropertyAsProperty; + + public class SourceDefinition5 { + public String name; + } + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class, property = "UUID1") + @JsonProperty("UUIDGeneratorAsId") + public SourceDefinition6 testUUIDGeneratorAsId; + + @JsonIdentityReference(alwaysAsId = false) + @JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class, property = "UUID2") + @JsonProperty("UUIDGeneratorAsProperty") + public SourceDefinition6 testUUIDGeneratorAsProperty; + + public class SourceDefinition6 { + public String name; + } + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class) + @JsonProperty("UUIDGeneratorWithoutPropertyAsId") + public SourceDefinition7 testUUIDGeneratorWithoutPropertyAsId; + + @JsonIdentityReference(alwaysAsId = false) + @JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class) + @JsonProperty("UUIDGeneratorWithoutPropertyAsProperty") + public SourceDefinition7 testUUIDGeneratorWithoutPropertyAsProperty; + + public class SourceDefinition7 { + public String name; + } + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = ObjectIdGenerators.None.class, property = "testGeneratorsNone") + @JsonProperty("GeneratorsNone") + public SourceDefinition8 testGeneratorsNone; + + public class SourceDefinition8 { + @JsonProperty("driverId") + public String driver; + public String name; + } + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = CustomGenerator.class, property = "name") + @JsonProperty("CustomGenerator") + public SourceDefinition9 testCustomGenerator; + + public class SourceDefinition9 { + public String driver; + public String name; + } + + @JsonIdentityInfo(generator = CustomGenerator.class, property = "name") + @JsonProperty("WithoutJsonIdentityReference") + public SourceDefinition10 testWithoutJsonIdentityReference; + + public class SourceDefinition10 { + public String driver; + public String name; + } +} \ No newline at end of file diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/ModelWithJsonIdentityCyclic.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/ModelWithJsonIdentityCyclic.java new file mode 100644 index 0000000000..db30023271 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/ModelWithJsonIdentityCyclic.java @@ -0,0 +1,29 @@ +package io.swagger.v3.plugin.maven.resources.model; + +import com.fasterxml.jackson.annotation.JsonIdentityInfo; +import com.fasterxml.jackson.annotation.JsonIdentityReference; +import com.fasterxml.jackson.annotation.ObjectIdGenerators; + +import java.util.List; + +public class ModelWithJsonIdentityCyclic { + + public Long id; + + public List sourceDefinitions; + + @JsonIdentityInfo( + generator = ObjectIdGenerators.PropertyGenerator.class, + property = "name") + public static class SourceDefinition { + public String driver; + public String name; + + @JsonIdentityReference(alwaysAsId=true) + @JsonIdentityInfo( + generator = ObjectIdGenerators.PropertyGenerator.class, + property = "id") + public ModelWithJsonIdentityCyclic model; + } + +} \ No newline at end of file diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/MultipleBaseBean.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/MultipleBaseBean.java new file mode 100644 index 0000000000..c820b4255a --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/MultipleBaseBean.java @@ -0,0 +1,11 @@ +package io.swagger.v3.plugin.maven.resources.model; + +@io.swagger.v3.oas.annotations.media.Schema( + description = "MultipleBaseBean", + subTypes = { MultipleSub1Bean.class, MultipleSub2Bean.class } +) +public class MultipleBaseBean { + public String beanType; + public int a; + public String b; +} \ No newline at end of file diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/MultipleSub1Bean.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/MultipleSub1Bean.java new file mode 100644 index 0000000000..b7ae993096 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/MultipleSub1Bean.java @@ -0,0 +1,8 @@ +package io.swagger.v3.plugin.maven.resources.model; + +@io.swagger.v3.oas.annotations.media.Schema( + description = "MultipleSub1Bean" +) +public class MultipleSub1Bean extends MultipleBaseBean { + public int c; +} \ No newline at end of file diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/MultipleSub2Bean.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/MultipleSub2Bean.java new file mode 100644 index 0000000000..882d6d37d6 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/MultipleSub2Bean.java @@ -0,0 +1,8 @@ +package io.swagger.v3.plugin.maven.resources.model; + +@io.swagger.v3.oas.annotations.media.Schema( + description = "MultipleSub2Bean" +) +public class MultipleSub2Bean extends MultipleBaseBean { + public int d; +} \ No newline at end of file diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/NotFoundModel.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/NotFoundModel.java new file mode 100644 index 0000000000..fccf2e0f98 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/NotFoundModel.java @@ -0,0 +1,30 @@ +package io.swagger.v3.plugin.maven.resources.model; + +public class NotFoundModel { + int code; + String message; + + public NotFoundModel() { + } + + public NotFoundModel(int code, String message) { + this.code = code; + this.message = message; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/Pet.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/Pet.java new file mode 100644 index 0000000000..54b31e9946 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/Pet.java @@ -0,0 +1,76 @@ +package io.swagger.v3.plugin.maven.resources.model; + +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.List; + +@XmlRootElement(name = "Pet") +public class Pet { + private long id; + private Category category; + private String name; + private List photoUrls = new ArrayList(); + private List tags = new ArrayList(); + private String status; + + @XmlElement(name = "id") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @XmlElement(name = "category") + public Category getCategory() { + return category; + } + + public void setCategory(Category category) { + this.category = category; + } + + @XmlElement(name = "name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @XmlElementWrapper(name = "photoUrls") + @XmlElement(name = "photoUrl") + public List getPhotoUrls() { + return photoUrls; + } + + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + @XmlElementWrapper(name = "tags") + @XmlElement(name = "tag") + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + @XmlElement(name = "status") + @Schema(description = "pet status in the store", allowableValues = "available,pending,sold") + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/Tag.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/Tag.java new file mode 100644 index 0000000000..6d3d128292 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/Tag.java @@ -0,0 +1,44 @@ +/** + * Copyright 2016 SmartBear Software + *

    + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

    + * http://www.apache.org/licenses/LICENSE-2.0 + *

    + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugin.maven.resources.model; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "Tag") +public class Tag { + private long id; + private String name; + + @XmlElement(name = "id") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @XmlElement(name = "name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/User.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/User.java new file mode 100644 index 0000000000..248d713160 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/resources/model/User.java @@ -0,0 +1,108 @@ +/** + * Copyright 2016 SmartBear Software + *

    + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

    + * http://www.apache.org/licenses/LICENSE-2.0 + *

    + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugin.maven.resources.model; + +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "User") +public class User { + private long id; + private String username; + private String firstName; + private String lastName; + private String email; + private String password; + private String phone; + private int userStatus; + + @XmlElement(name = "id") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @XmlElement(name = "firstName") + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + @XmlElement(name = "username") + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + @XmlElement(name = "lastName") + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + @XmlElement(name = "email") + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + @XmlElement(name = "password") + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @XmlElement(name = "phone") + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + @XmlElement(name = "userStatus") + //@Schema(description = "User Status", type = "string", allowableValues = {"1-registered", "2-active", "3-closed"}) + @Schema(description = "User Status", allowableValues = "1-registered,2-active,3-closed") + public int getUserStatus() { + return userStatus; + } + + public void setUserStatus(int userStatus) { + this.userStatus = userStatus; + } +} \ No newline at end of file diff --git a/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFile.xml b/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFile.xml new file mode 100644 index 0000000000..a77e5bee14 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFile.xml @@ -0,0 +1,47 @@ + + 4.0.0 + io.swagger.core.v3 + swagger-maven-plugin-test + jar + 1.0-SNAPSHOT + Test Resolve YAML + + + + + io.swagger.core.v3 + swagger-maven-plugin + + spec + ${project.basedir}/../../../target/generatedtest + YAML + + io.swagger.v3.plugin.maven.petstore.petstore + + TRUE + + + + + + + + io.swagger.core.v3 + swagger-jaxrs2 + ${project.version} + + + + javax.ws.rs + javax.ws.rs-api + 2.1 + + + javax.servlet + javax.servlet-api + 3.1 + + + + \ No newline at end of file diff --git a/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFileAndUploadToSwaggerhub.xml b/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFileAndUploadToSwaggerhub.xml new file mode 100644 index 0000000000..95dac9a33f --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFileAndUploadToSwaggerhub.xml @@ -0,0 +1,47 @@ + + 4.0.0 + io.swagger.core.v3 + swagger-maven-plugin-test + jar + 1.0-SNAPSHOT + Test Resolve YAML + + + + + io.swagger.core.v3 + swagger-maven-plugin + + openapi + ${project.basedir}/../../../target/generatedtest + YAML + + io.swagger.v3.plugin.maven.petstore.petstore + + TRUE + + + + + + + + io.swagger.core.v3 + swagger-jaxrs2 + ${project.version} + + + + javax.ws.rs + javax.ws.rs-api + 2.1 + + + javax.servlet + javax.servlet-api + 3.1 + + + + \ No newline at end of file diff --git a/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFileJsonAndYaml.xml b/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFileJsonAndYaml.xml new file mode 100644 index 0000000000..84897bb8b7 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFileJsonAndYaml.xml @@ -0,0 +1,47 @@ + + 4.0.0 + io.swagger.core.v3 + swagger-maven-plugin-test + jar + 1.0-SNAPSHOT + Test Resolve YAML + + + + + io.swagger.core.v3 + swagger-maven-plugin + + openapi + ${project.basedir}/../../../target/generatedtest + JSONANDYAML + + io.swagger.v3.plugin.maven.petstore.petstore + + TRUE + + + + + + + + io.swagger.core.v3 + swagger-jaxrs2 + ${project.version} + + + + javax.ws.rs + javax.ws.rs-api + 2.1 + + + javax.servlet + javax.servlet-api + 3.1 + + + + \ No newline at end of file diff --git a/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFileNoName.xml b/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFileNoName.xml new file mode 100644 index 0000000000..e54176e2d6 --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFileNoName.xml @@ -0,0 +1,46 @@ + + 4.0.0 + io.swagger.core.v3 + swagger-maven-plugin-test + jar + 1.0-SNAPSHOT + Test Resolve YAML + + + + + io.swagger.core.v3 + swagger-maven-plugin + + ${project.basedir}/../../../target/generatedtest + YAML + + io.swagger.v3.plugin.maven.petstore.petstore + + TRUE + + + + + + + + io.swagger.core.v3 + swagger-jaxrs2 + ${project.version} + + + + javax.ws.rs + javax.ws.rs-api + 2.1 + + + javax.servlet + javax.servlet-api + 3.1 + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 1b3ded17f1..97cdffb112 100644 --- a/pom.xml +++ b/pom.xml @@ -309,6 +309,7 @@ modules/swagger-integration modules/swagger-jaxrs2 modules/swagger-jaxrs2-servlet-initializer + modules/swagger-maven-plugin From c15b421c274643f84d34ab5c34eacc55cf33a423 Mon Sep 17 00:00:00 2001 From: frantuma Date: Tue, 11 Sep 2018 17:37:44 +0200 Subject: [PATCH 2/7] added module swagger-gradle-plugin --- modules/swagger-gradle-plugin/.gitignore | 117 +++++++ modules/swagger-gradle-plugin/README.md | 67 ++++ modules/swagger-gradle-plugin/build.gradle | 88 +++++ .../swagger-gradle-plugin/gradle.properties | 1 + .../gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 54329 bytes .../gradle/wrapper/gradle-wrapper.properties | 6 + modules/swagger-gradle-plugin/gradlew | 172 ++++++++++ modules/swagger-gradle-plugin/gradlew.bat | 84 +++++ modules/swagger-gradle-plugin/settings.gradle | 1 + .../v3/plugins/gradle/SwaggerPlugin.java | 44 +++ .../v3/plugins/gradle/tasks/ResolveTask.java | 305 ++++++++++++++++++ .../v3/plugins/gradle/SwaggerResolveTest.java | 109 +++++++ .../javatest/petstore/EmptyPetResource.java | 7 + .../test/javatest/petstore/PetResource.java | 165 ++++++++++ .../callback/ComplexCallbackResource.java | 62 ++++ ...pleCallbacksTestWithOperationResource.java | 45 +++ .../callback/RepeatableCallbackResource.java | 46 +++ .../SimpleCallbackWithOperationResource.java | 44 +++ .../petstore/example/ExamplesResource.java | 69 ++++ .../example/SubscriptionResponse.java | 5 + .../javatest/petstore/link/LinksResource.java | 44 +++ .../OpenAPIDefinitionResource.java | 48 +++ .../AnnotatedSameNameOperationResource.java | 26 ++ .../ExternalDocumentationResource.java | 30 ++ .../FullyAnnotatedOperationResource.java | 38 +++ .../operation/HiddenOperationResource.java | 29 ++ .../petstore/operation/InterfaceResource.java | 22 ++ ...NotAnnotatedSameNameOperationResource.java | 21 ++ .../petstore/operation/OperationResource.java | 77 +++++ .../OperationWithoutAnnotationResource.java | 15 + .../operation/ServerOperationResource.java | 30 ++ .../petstore/operation/SubResource.java | 20 ++ .../parameter/ArraySchemaResource.java | 44 +++ .../parameter/ComplexParameterResource.java | 33 ++ ...ComplexParameterWithOperationResource.java | 37 +++ .../MultipleNotAnnotatedParameter.java | 18 ++ .../OpenAPIJaxRSAnnotatedParameter.java | 21 ++ ...APIWithContentJaxRSAnnotatedParameter.java | 25 ++ ...ImplementationJaxRSAnnotatedParameter.java | 23 ++ .../parameter/ParametersResource.java | 87 +++++ .../RepeatableParametersResource.java | 80 +++++ .../SingleJaxRSAnnotatedParameter.java | 20 ++ .../SingleNotAnnotatedParameter.java | 19 ++ .../RequestBodyMethodPriorityResource.java | 28 ++ .../RequestBodyParameterPriorityResource.java | 29 ++ .../requestbody/RequestBodyResource.java | 113 +++++++ .../responses/ComplexResponseResource.java | 34 ++ .../ImplementationResponseResource.java | 71 ++++ .../responses/MethodResponseResource.java | 24 ++ .../NoImplementationResponseResource.java | 66 ++++ .../responses/NoResponseResource.java | 21 ++ .../responses/OperationResponseResource.java | 25 ++ .../responses/PriorityResponseResource.java | 25 ++ .../petstore/security/SecurityResource.java | 61 ++++ .../petstore/tags/CompleteTagResource.java | 31 ++ .../petstore/tags/TagClassResource.java | 14 + .../petstore/tags/TagMethodResource.java | 19 ++ .../tags/TagOpenAPIDefinitionResource.java | 14 + .../petstore/tags/TagOperationResource.java | 20 ++ .../javatest/resources/QueryResultBean.java | 43 +++ .../test/javatest/resources/data/PetData.java | 151 +++++++++ .../javatest/resources/data/UserData.java | 98 ++++++ .../resources/exception/ApiException.java | 26 ++ .../exception/NotFoundException.java | 26 ++ .../javatest/resources/model/Category.java | 51 +++ .../resources/model/CustomGenerator.java | 32 ++ .../resources/model/ExtensionUser.java | 130 ++++++++ .../javatest/resources/model/JacksonBean.java | 76 +++++ .../model/ListOfStringsBeanParam.java | 17 + .../model/ModelWithJsonIdentity.java | 145 +++++++++ .../model/ModelWithJsonIdentityCyclic.java | 29 ++ .../resources/model/MultipleBaseBean.java | 11 + .../resources/model/MultipleSub1Bean.java | 8 + .../resources/model/MultipleSub2Bean.java | 8 + .../resources/model/NotFoundModel.java | 30 ++ .../test/javatest/resources/model/Pet.java | 76 +++++ .../test/javatest/resources/model/Tag.java | 44 +++ .../test/javatest/resources/model/User.java | 108 +++++++ .../v3/jaxrs2/integration/SwaggerLoader.java | 159 +++++++++ modules/swagger-maven-plugin/README.md | 77 +++++ modules/swagger-maven-plugin/pom.xml | 2 +- .../swagger/v3/plugin/maven/SwaggerMojo.java | 4 +- 82 files changed, 4187 insertions(+), 3 deletions(-) create mode 100644 modules/swagger-gradle-plugin/.gitignore create mode 100644 modules/swagger-gradle-plugin/README.md create mode 100644 modules/swagger-gradle-plugin/build.gradle create mode 100644 modules/swagger-gradle-plugin/gradle.properties create mode 100644 modules/swagger-gradle-plugin/gradle/wrapper/gradle-wrapper.jar create mode 100644 modules/swagger-gradle-plugin/gradle/wrapper/gradle-wrapper.properties create mode 100755 modules/swagger-gradle-plugin/gradlew create mode 100644 modules/swagger-gradle-plugin/gradlew.bat create mode 100644 modules/swagger-gradle-plugin/settings.gradle create mode 100644 modules/swagger-gradle-plugin/src/main/java/io/swagger/v3/plugins/gradle/SwaggerPlugin.java create mode 100644 modules/swagger-gradle-plugin/src/main/java/io/swagger/v3/plugins/gradle/tasks/ResolveTask.java create mode 100644 modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/SwaggerResolveTest.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/EmptyPetResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/PetResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/callback/ComplexCallbackResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/callback/MultipleCallbacksTestWithOperationResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/callback/RepeatableCallbackResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/callback/SimpleCallbackWithOperationResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/example/ExamplesResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/example/SubscriptionResponse.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/link/LinksResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/openapidefintion/OpenAPIDefinitionResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/AnnotatedSameNameOperationResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/ExternalDocumentationResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/FullyAnnotatedOperationResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/HiddenOperationResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/InterfaceResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/NotAnnotatedSameNameOperationResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/OperationResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/OperationWithoutAnnotationResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/ServerOperationResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/SubResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/ArraySchemaResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/ComplexParameterResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/ComplexParameterWithOperationResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/MultipleNotAnnotatedParameter.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/OpenAPIJaxRSAnnotatedParameter.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/OpenAPIWithContentJaxRSAnnotatedParameter.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/OpenAPIWithImplementationJaxRSAnnotatedParameter.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/ParametersResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/RepeatableParametersResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/SingleJaxRSAnnotatedParameter.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/SingleNotAnnotatedParameter.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/requestbody/RequestBodyMethodPriorityResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/requestbody/RequestBodyParameterPriorityResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/requestbody/RequestBodyResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/ComplexResponseResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/ImplementationResponseResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/MethodResponseResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/NoImplementationResponseResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/NoResponseResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/OperationResponseResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/PriorityResponseResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/security/SecurityResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/CompleteTagResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/TagClassResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/TagMethodResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/TagOpenAPIDefinitionResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/TagOperationResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/resources/QueryResultBean.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/resources/data/PetData.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/resources/data/UserData.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/resources/exception/ApiException.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/resources/exception/NotFoundException.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/resources/model/Category.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/resources/model/CustomGenerator.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/resources/model/ExtensionUser.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/resources/model/JacksonBean.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/resources/model/ListOfStringsBeanParam.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/resources/model/ModelWithJsonIdentity.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/resources/model/ModelWithJsonIdentityCyclic.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/resources/model/MultipleBaseBean.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/resources/model/MultipleSub1Bean.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/resources/model/MultipleSub2Bean.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/resources/model/NotFoundModel.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/resources/model/Pet.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/resources/model/Tag.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/resources/model/User.java create mode 100644 modules/swagger-jaxrs2/src/main/java/io/swagger/v3/jaxrs2/integration/SwaggerLoader.java create mode 100644 modules/swagger-maven-plugin/README.md diff --git a/modules/swagger-gradle-plugin/.gitignore b/modules/swagger-gradle-plugin/.gitignore new file mode 100644 index 0000000000..2e5ec09fe7 --- /dev/null +++ b/modules/swagger-gradle-plugin/.gitignore @@ -0,0 +1,117 @@ + +# Created by https://www.gitignore.io/api/java,gradle,intellij + +### Intellij ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff: +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/dictionaries + +# Sensitive or high-churn files: +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.xml +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml + +# Gradle: +.idea/**/gradle.xml +.idea/**/libraries + +# CMake +cmake-build-debug/ + +# Mongo Explorer plugin: +.idea/**/mongoSettings.xml + +## File-based project format: +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Ruby plugin and RubyMine +/.rakeTasks + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +### Intellij Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +.idea/sonarlint + +### Java ### +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +### Gradle ### +.gradle +**/build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar + +# Cache of project +.gradletasknamecache + +# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 +# gradle/wrapper/gradle-wrapper.properties + + +# End of https://www.gitignore.io/api/java,gradle,intellij + +.idea/modules +# IntelliJ IDEA +.idea/ +*.iml +*.iws +*.ipr diff --git a/modules/swagger-gradle-plugin/README.md b/modules/swagger-gradle-plugin/README.md new file mode 100644 index 0000000000..d940aee681 --- /dev/null +++ b/modules/swagger-gradle-plugin/README.md @@ -0,0 +1,67 @@ +# swagger-gradle-plugin + +## Installation +### Gradle 2.1 and higher + +``` +plugins { + id "io.swagger.core.v3.swagger-gradle-plugin" version "2.0.5-SNAPSHOT" +} +``` +### Gradle 1.x and 2.0 + +``` +buildscript { + repositories { + maven { + url "https://plugins.gradle.org/m2/" + } + } + dependencies { + classpath "gradle.plugin.io.swagger.core.v3.swagger-gradle-plugin:2.0.5-SNAPSHOT" + } +} + +apply plugin: "io.swagger.core.v3.swagger-gradle-plugin" +``` + +## Tasks +### resolve + +* Resolves project openAPI specification and saves the result in JSON, YAML or both formats. +All parameters except `outputFileName`, `outputFormat`, `classpath` `skip` and `outputPath` correspond +to `swagger` [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties) with same name. + +#### Example Usage + +``` + +resolve { + outputFileName = 'PetStoreAPI' + outputFormat = 'JSON' + prettyPrint = 'TRUE' + classpath = sourceSets.main.runtimeClasspath + resourcePackages = ['io.test'] + outputPath = 'test' +} +``` + +#### Parameters +Parameter | Description | Required | Default +--------- | ----------- | --------- | ------- +`classpath`|classpath for resources to scan (swagger and deps already included in classpath)|true| +`outputPath`|output path where file(s) are saved|true| +`outputFileName`|file name (no extension)|false|`openapi` +`outputFormat`|file format (`JSON`, `YAML`, `JSONANDYAML`|false|`JSON` +`skip`|if `TRUE` skip execution|false|`FALSE` +`resourcePackages`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| +`resourceClasses`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| +`prettyPrint`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false|`TRUE` +`filterClass`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| +`readerClass`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| +`scannerClass`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| +`readAllResources`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| +`ignoredRoutes`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| + +*** + diff --git a/modules/swagger-gradle-plugin/build.gradle b/modules/swagger-gradle-plugin/build.gradle new file mode 100644 index 0000000000..947190a3b2 --- /dev/null +++ b/modules/swagger-gradle-plugin/build.gradle @@ -0,0 +1,88 @@ +// * * * * * * * * * * * * +// Plugins +// * * * * * * * * * * * * +plugins { + id 'groovy' + id 'java-gradle-plugin' + id 'net.researchgate.release' version '2.6.0' + // Publishing publicly + id 'com.gradle.plugin-publish' version '0.9.10' + // Publishing to maven + id 'maven-publish' +} + +// * * * * * * * * * * * * +// Dependencies +// * * * * * * * * * * * * + +repositories { + jcenter() + mavenLocal() + mavenCentral() +} + +dependencies { + compile gradleApi() + compile group: 'org.apache.commons', name: 'commons-lang3', version:'3.7' + compile group: 'io.swagger.core.v3', name: 'swagger-jaxrs2', version:'2.0.5-SNAPSHOT' + compile group: 'javax.ws.rs', name: 'javax.ws.rs-api', version:'2.1' + compile group: 'javax.servlet', name: 'javax.servlet-api', version:'3.1.0' + testCompile group: 'com.github.tomakehurst', name: 'wiremock', version:'2.14.0' + testCompile gradleTestKit() + testCompile 'junit:junit:4+' + + +} + +// * * * * * * * * * * * * +// Project configuration +// * * * * * * * * * * * * + +project.description = 'Gradle Plugin for Swagger core' +project.group = 'io.swagger.core.v3' + +project.ext.name = 'swagger-gradle-plugin' +project.ext.pluginId = 'io.swagger.core.v3.swagger-gradle-plugin' +project.ext.scm = 'scm:git@github.com:swagger-api/swagger-core.git' +project.ext.url = 'https://github.com/swagger-api/swagger-core/modules/swagger-gradle-plugin' + +// Configuration for: java-gradle-plugin +gradlePlugin { + plugins { + swagger { + id = project.pluginId + implementationClass = 'io.swagger.v3.plugins.gradle.SwaggerPlugin' + } + } +} + +// * * * * * * * * * * * * +// Publishing +// * * * * * * * * * * * * + + +// Publishing to plugins.gradle.org +// -------------------------------- + +// Configuration for: com.gradle.plugin-publish +pluginBundle { + website = project.url + vcsUrl = project.scm + tags = ['swagger', 'openapi', 'api'] + + plugins { + swagger { + displayName = 'Swagger Gradle Plugin ' + description = project.description + id = project.pluginId + } + } +} + +publishing { + repositories { + maven { + url mavenLocal().url + } + } +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/gradle.properties b/modules/swagger-gradle-plugin/gradle.properties new file mode 100644 index 0000000000..aa4cef907a --- /dev/null +++ b/modules/swagger-gradle-plugin/gradle.properties @@ -0,0 +1 @@ +version=2.0.5-SNAPSHOT diff --git a/modules/swagger-gradle-plugin/gradle/wrapper/gradle-wrapper.jar b/modules/swagger-gradle-plugin/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..01b8bf6b1f99cad9213fc495b33ad5bbab8efd20 GIT binary patch literal 54329 zcmagFV|ZrKvM!pAZQHhO+qP}9lTNj?q^^Y^VFp)SH8qbSJ)2BQ2giqeFT zAwqu@)c?v~^Z#E_K}1nTQbJ9gQ9<%vVRAxVj)8FwL5_iTdUB>&m3fhE=kRWl;g`&m z!W5kh{WsV%fO*%je&j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<*3J{3+tSkSr zZYI74MtK0d8Nh}Aj0?C^0))Z*0$Ko|4`5-fYw#Ztx|e`M)@=6g0nNk%s4v4`0NDV3 zk$(aNj2kYlyp9eg0Cite{bxChmkiMtuw(CkDy9OY{&D}pkOpXIL^z{~#&0%1E{ zK>kKWfRLbwwWXniwY9mU&99s0sLU*`5Fi`R0H`V1bHxF7)Oh~@{qLkxKW*>VxO>Mc z_9Xz6CBOv$`cuIK{DNOpS@b_v_iMb2Qk2^-fHr0VWM=p)9vIcH@vQ6}bS*6Yn+<0` zHS-Vv-qdTr#{}n3wF3e|XZ$C;U)Qd{m8L}r&_O_ewZqTP@pJJM`6Zf!wef%L?Uz~3 zpTS_ne+l+mInQ6()XNOo&n#$?|C{C4&G0hQ=rg7e;4A)%PJcP|_)Ff=moW%6^ug z8A_gu6#(#0?fWxw=jFpM^OZb5obmUE|C2J}zt06c~G6javMT=uh?kFRJn{;a>`(Kf~)={S*9)sq#zMmpb6ju-(@G1p8+%!%NJUqO#AJ zLyrH1`9}=EfBQ1Nly7}TZE*Sx)c-E#`m*{jB`KeY#NB?E=#S?4w?O4ff|v4t&jdW4 zzd`U1Vt_B1UW$Z0Gx_`c2GegzhP~u`sr&TIN$CF@od2W(^^)qPP{uQrcGz!F{ex`A zOQx5i1kX&Gk-x$8hdJ>6Qlj7`)yr7$XDZp4-=+e5Uu^!Y>-Li5WoYd)iE;dIll<|% z{z+`)CCkeg&Sw^b#NTH5b42G$f|v1g&jg|=|DOc^tHoYMG(A({rT+%i|7@$5p)Jq& zu9?4q|IdLgFWc>9B)~ISBVax9V!-~>SoO!R`1K^~<^J \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/modules/swagger-gradle-plugin/gradlew.bat b/modules/swagger-gradle-plugin/gradlew.bat new file mode 100644 index 0000000000..e95643d6a2 --- /dev/null +++ b/modules/swagger-gradle-plugin/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/modules/swagger-gradle-plugin/settings.gradle b/modules/swagger-gradle-plugin/settings.gradle new file mode 100644 index 0000000000..aa1f239ad8 --- /dev/null +++ b/modules/swagger-gradle-plugin/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'swagger-gradle-plugin' diff --git a/modules/swagger-gradle-plugin/src/main/java/io/swagger/v3/plugins/gradle/SwaggerPlugin.java b/modules/swagger-gradle-plugin/src/main/java/io/swagger/v3/plugins/gradle/SwaggerPlugin.java new file mode 100644 index 0000000000..204cf4f6ef --- /dev/null +++ b/modules/swagger-gradle-plugin/src/main/java/io/swagger/v3/plugins/gradle/SwaggerPlugin.java @@ -0,0 +1,44 @@ +package io.swagger.v3.plugins.gradle; + +import io.swagger.v3.plugins.gradle.tasks.ResolveTask; +import org.gradle.api.Action; +import org.gradle.api.Plugin; +import org.gradle.api.Project; +import org.gradle.api.Task; +import org.gradle.api.artifacts.Configuration; +import org.gradle.api.artifacts.DependencySet; + +public class SwaggerPlugin implements Plugin { + public void apply(Project project) { + final Configuration config = project.getConfigurations().create("swaggerDeps") + .setVisible(false); + + config.defaultDependencies(new Action() { + public void execute(DependencySet dependencies) { + dependencies.add(project.getDependencies().create("org.apache.commons:commons-lang3:3.7")); + dependencies.add(project.getDependencies().create("io.swagger.core.v3:swagger-jaxrs2:2.0.5-SNAPSHOT")); + dependencies.add(project.getDependencies().create("javax.ws.rs:javax.ws.rs-api:2.1")); + dependencies.add(project.getDependencies().create("javax.servlet:javax.servlet-api:3.1.0")); + } + }); + Task task = project.getTasks().create("resolve", ResolveTask.class); + ((ResolveTask)task).setBuildClasspath(config); + + try { + if (project.getTasks().findByPath("classes") != null) { + task.dependsOn("classes"); + } + if (project.getTasks().findByPath("compileJava") != null) { + task.dependsOn("compileJava"); + } + if (project.getTasks().findByPath("compileTestJava") != null) { + task.dependsOn("compileTestJava"); + } + if (project.getTasks().findByPath("testClasses") != null) { + task.dependsOn("testClasses"); + } + } catch (Exception e) { + project.getLogger().warn("Exception in task dependencies: " + e.getMessage(), e); + } + } +} diff --git a/modules/swagger-gradle-plugin/src/main/java/io/swagger/v3/plugins/gradle/tasks/ResolveTask.java b/modules/swagger-gradle-plugin/src/main/java/io/swagger/v3/plugins/gradle/tasks/ResolveTask.java new file mode 100644 index 0000000000..bbd91d8caf --- /dev/null +++ b/modules/swagger-gradle-plugin/src/main/java/io/swagger/v3/plugins/gradle/tasks/ResolveTask.java @@ -0,0 +1,305 @@ +package io.swagger.v3.plugins.gradle.tasks; + +import org.apache.commons.lang3.StringUtils; +import org.gradle.api.DefaultTask; +import org.gradle.api.GradleException; +import org.gradle.api.logging.Logging; +import org.gradle.api.tasks.Classpath; +import org.gradle.api.tasks.Input; +import org.gradle.api.tasks.InputFiles; +import org.gradle.api.tasks.Optional; +import org.gradle.api.tasks.OutputDirectory; +import org.gradle.api.tasks.TaskAction; +import org.slf4j.Logger; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Method; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Collection; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.StreamSupport; + +public class ResolveTask extends DefaultTask { + private static Logger LOGGER = Logging.getLogger(ResolveTask.class); + + public enum Format {JSON, YAML, JSONANDYAML}; + + private String outputFileName = "openapi"; + + private String outputPath; + private File outputDir; + + + private Format outputFormat = Format.JSON; + + private Set resourcePackages; + private Set resourceClasses; + private String filterClass; + private String readerClass; + private String scannerClass; + private Boolean prettyPrint = false; + private Boolean readAllResources = Boolean.TRUE; + private Collection ignoredRoutes; + private Iterable buildClasspath; + private Iterable classpath; + + private Boolean skip = Boolean.FALSE; + + @Input + @Optional + public String getOutputFileName() { + return outputFileName; + } + + @Classpath + @InputFiles + public Iterable getClasspath() { + return classpath; + } + + public void setClasspath(Iterable classpath) { + this.classpath = classpath; + } + + @Classpath + @InputFiles + @Optional + public Iterable getBuildClasspath() { + return buildClasspath; + } + + public void setBuildClasspath(Iterable buildClasspath) { + this.buildClasspath = buildClasspath; + } + + public void setOutputFileName(String outputFileName) { + this.outputFileName = outputFileName; + } + + @Input + public String getOutputPath() { + return outputPath; + } + + public void setOutputPath(String outputPath) { + this.outputPath = outputPath; + outputDir = new File(outputPath); + } + + + @OutputDirectory + public File getOutputDir() { + return outputDir; + } + + public void setOutputDir(File outputDir) { + this.outputDir = outputDir; + } + + @Input + @Optional + public Format getOutputFormat() { + return outputFormat; + } + + public void setOutputFormat(Format outputFormat) { + this.outputFormat = outputFormat; + } + + @Input + @Optional + public Set getResourcePackages() { + return resourcePackages; + } + + public void setResourcePackages(Set resourcePackages) { + this.resourcePackages = resourcePackages; + } + + @Input + @Optional + public Set getResourceClasses() { + return resourceClasses; + } + + public void setResourceClasses(Set resourceClasses) { + this.resourceClasses = resourceClasses; + } + + @Input + @Optional + public String getFilterClass() { + return filterClass; + } + + public void setFilterClass(String filterClass) { + this.filterClass = filterClass; + } + + @Input + @Optional + public String getReaderClass() { + return readerClass; + } + + public void setReaderClass(String readerClass) { + this.readerClass = readerClass; + } + + @Input + @Optional + public String getScannerClass() { + return scannerClass; + } + + public void setScannerClass(String scannerClass) { + this.scannerClass = scannerClass; + } + + @Input + @Optional + public Boolean getPrettyPrint() { + return prettyPrint; + } + + public void setPrettyPrint(Boolean prettyPrint) { + this.prettyPrint = prettyPrint; + } + + @Input + @Optional + public Boolean getReadAllResources() { + return readAllResources; + } + + public void setReadAllResources(Boolean readAllResources) { + this.readAllResources = readAllResources; + } + + @Input + @Optional + public Collection getIgnoredRoutes() { + return ignoredRoutes; + } + + public void setIgnoredRoutes(Collection ignoredRoutes) { + this.ignoredRoutes = ignoredRoutes; + } + + @Input + @Optional + public Boolean getSkip() { + return skip; + } + + public void setSkip(Boolean skip) { + this.skip = skip; + } + + @TaskAction + public void resolve() throws GradleException { + if (skip) { + LOGGER.info( "Skipping OpenAPI specification resolution" ); + return; + } + LOGGER.info( "Resolving OpenAPI specification.." ); + + Set urls = StreamSupport.stream(getClasspath().spliterator(), false).map(f -> { + try { + return f.toURI().toURL(); + } + catch (MalformedURLException e) { + throw new GradleException( + String.format("Could not create classpath for annotations task %s.", getName()), e); + } + }).collect(Collectors.toSet()); + + Set buildUrls = StreamSupport.stream(getBuildClasspath().spliterator(), false).map(f -> { + try { + return f.toURI().toURL(); + } + catch (MalformedURLException e) { + throw new GradleException( + String.format("Could not create classpath for annotations task %s.", getName()), e); + } + }).collect(Collectors.toSet()); + + urls.addAll(buildUrls); + + //ClassLoader classLoader = new URLClassLoader(urls.toArray(new URL[urls.size()]), Thread.currentThread().getContextClassLoader()); + ClassLoader classLoader = new URLClassLoader(urls.toArray(new URL[urls.size()])); + + try { + Class swaggerLoaderClass = classLoader.loadClass("io.swagger.v3.jaxrs2.integration.SwaggerLoader"); + Object swaggerLoader = swaggerLoaderClass.newInstance(); + + Method method = null; + method=swaggerLoaderClass.getDeclaredMethod("setOutputFormat",String.class); + method.invoke(swaggerLoader, outputFormat.name()); + + if (resourcePackages != null && !resourcePackages.isEmpty()) { + method=swaggerLoaderClass.getDeclaredMethod("setResourcePackages",String.class); + method.invoke(swaggerLoader, resourcePackages.stream().map(Object::toString).collect(Collectors.joining(","))); + } + if (resourceClasses != null && !resourceClasses.isEmpty()) { + method=swaggerLoaderClass.getDeclaredMethod("setResourceClasses",String.class); + method.invoke(swaggerLoader, resourceClasses.stream().map(Object::toString).collect(Collectors.joining(","))); + } + if (ignoredRoutes != null && !ignoredRoutes.isEmpty()) { + method=swaggerLoaderClass.getDeclaredMethod("setIgnoredRoutes",String.class); + method.invoke(swaggerLoader, ignoredRoutes.stream().map(Object::toString).collect(Collectors.joining(","))); + } + + if (StringUtils.isNotBlank(filterClass)) { + method=swaggerLoaderClass.getDeclaredMethod("setFilterClass",String.class); + method.invoke(swaggerLoader, filterClass); + } + + if (StringUtils.isNotBlank(readerClass)) { + method=swaggerLoaderClass.getDeclaredMethod("setReaderClass",String.class); + method.invoke(swaggerLoader, readerClass); + } + + if (StringUtils.isNotBlank(scannerClass)) { + method=swaggerLoaderClass.getDeclaredMethod("setScannerClass",String.class); + method.invoke(swaggerLoader, scannerClass); + } + + method=swaggerLoaderClass.getDeclaredMethod("setPrettyPrint", Boolean.class); + method.invoke(swaggerLoader, prettyPrint); + + method=swaggerLoaderClass.getDeclaredMethod("setReadAllResources", Boolean.class); + method.invoke(swaggerLoader, readAllResources); + + method=swaggerLoaderClass.getDeclaredMethod("resolve"); + Map specs = (Map)method.invoke(swaggerLoader); + + Path path = Paths.get(outputPath, "temp"); + final File parentFile = path.toFile().getParentFile(); + if (parentFile != null) { + parentFile.mkdirs(); + } + if (specs.get("JSON") != null) { + path = Paths.get(outputPath, outputFileName + ".json"); + Files.write(path, specs.get("JSON").getBytes(Charset.forName("UTF-8"))); + } + if (specs.get("YAML") != null) { + path = Paths.get(outputPath, outputFileName + ".yaml"); + Files.write(path, specs.get("YAML").getBytes(Charset.forName("UTF-8"))); + } + } catch (IOException e) { + throw new GradleException("Failed to write API definition: " + e.getMessage(), e); + } catch (Exception e) { + throw new GradleException(e.getMessage(), e); + } + } +} diff --git a/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/SwaggerResolveTest.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/SwaggerResolveTest.java new file mode 100644 index 0000000000..a1a8f374de --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/SwaggerResolveTest.java @@ -0,0 +1,109 @@ +package io.swagger.v3.plugins.gradle; + +import org.gradle.testkit.runner.BuildResult; +import org.gradle.testkit.runner.GradleRunner; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +import static junit.framework.TestCase.assertTrue; +import static org.gradle.testkit.runner.TaskOutcome.SUCCESS; +import static org.junit.Assert.assertEquals; + +public class SwaggerResolveTest { + + @Rule + public final TemporaryFolder testProjectDir = new TemporaryFolder(); + private File buildFile; + private String outputFile; + private String outputDir; + + @Before + public void setup() throws IOException { + buildFile = testProjectDir.newFile("build.gradle"); + } + + @Test + public void testSwaggerResolveTask() throws IOException { + outputDir = testProjectDir.getRoot().toString() + "/target"; + outputFile = testProjectDir.getRoot().toString() + "/testAPI.json"; + //outputDir = "/tmp/a/target"; + String resolveTask = "resolve"; + + String buildFileContent = + "buildscript {\n" + + " dependencies {\n" + + " classpath files(\"" + testProjectDir.getRoot().toString() + "/classes/java/test\")\n" + + " }\n" + + " }\n" + + "plugins {\n" + + " id 'groovy'\n" + + " id 'java'\n" + + " id 'io.swagger.core.v3.swagger-gradle-plugin'\n" + + "}\n" + + "sourceSets {\n" + + " test {\n" + + " java {\n" + + " srcDirs = ['/dati/dev/progetti/swagger/projects/swagger-core/modules/swagger-gradle-plugin/src/test/javatest']\n" + + " }\n" + + " }\n" + + "}\n" + + "repositories {\n" + + " jcenter()\n" + + " mavenLocal()\n" + + " mavenCentral()\n" + + "}\n" + + "dependencies { \n" + + //" compile configurations.runtime\n" + + " compile group: 'org.apache.commons', name: 'commons-lang3', version:'3.7'\n" + + " compile group: 'io.swagger.core.v3', name: 'swagger-jaxrs2', version:'2.0.5-SNAPSHOT'\n" + + " compile group: 'javax.ws.rs', name: 'javax.ws.rs-api', version:'2.1'\n" + + " compile group: 'javax.servlet', name: 'javax.servlet-api', version:'3.1.0'\n" + + " testCompile group: 'com.github.tomakehurst', name: 'wiremock', version:'2.14.0'\n" + + " testCompile 'junit:junit:4+'\n" + + "\n" + + "\n" + + "}\n" + + resolveTask + " {\n" + + " outputFileName = 'PetStoreAPI'\n" + + " outputFormat = 'JSON'\n" + + " prettyPrint = 'TRUE'\n" + + //" classpath = compileTestJava.outputs.files\n" + + " classpath = sourceSets.test.runtimeClasspath\n" + + " resourcePackages = ['io.swagger.v3.plugins.gradle.petstore']\n" + + " outputPath = \'" + outputDir + "\'\n" + + "}"; + + + writeFile(buildFile, buildFileContent); + + BuildResult result = GradleRunner.create() + .withPluginClasspath() + .withProjectDir(testProjectDir.getRoot()) + .withDebug(true) + //.withArguments("build", "--stacktrace", "--info") + .withArguments(resolveTask, "--stacktrace") + .build(); + + assertEquals(SUCCESS, result.task(":" + resolveTask).getOutcome()); + assertTrue(new File(outputDir + "/PetStoreAPI.json").exists()); + } + + private void writeFile(File destination, String content) throws IOException { + BufferedWriter output = null; + try { + output = new BufferedWriter(new FileWriter(destination)); + output.write(content); + } finally { + if (output != null) { + output.close(); + } + } + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/EmptyPetResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/EmptyPetResource.java new file mode 100644 index 0000000000..3a60f75fe2 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/EmptyPetResource.java @@ -0,0 +1,7 @@ +package io.swagger.v3.plugins.gradle.petstore; + +/** + * An Empty PetResource Class + */ +public class EmptyPetResource { +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/PetResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/PetResource.java new file mode 100644 index 0000000000..a0d713071d --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/PetResource.java @@ -0,0 +1,165 @@ +/** + * Copyright 2016 SmartBear Software + *

      + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

      + * http://www.apache.org/licenses/LICENSE-2.0 + *

      + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugins.gradle.petstore; + +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.plugins.gradle.resources.QueryResultBean; +import io.swagger.v3.plugins.gradle.resources.data.PetData; +import io.swagger.v3.plugins.gradle.resources.exception.NotFoundException; +import io.swagger.v3.plugins.gradle.resources.model.Pet; + +import javax.ws.rs.BeanParam; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Response; + +@Consumes("application/json") +@Path("/pet") +@Produces({"application/json", "application/xml"}) +public class PetResource { + static PetData petData = new PetData(); + + @GET + @Path("/{petId}") + @Operation(summary = "Find pet by ID", + description = "Returns a pet when 0 < ID <= 10. ID > 10 or nonintegers will simulate API error conditions", + responses = { + @ApiResponse( + description = "The pet", content = @Content( + schema = @Schema(implementation = Pet.class) + )), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") + }) + public Response getPetById( + @Parameter(description = "ID of pet that needs to be fetched"/*, _enum = "range[1,10]"*/, required = true) + @PathParam("petId") final Long petId) throws NotFoundException { + Pet pet = petData.getPetById(petId); + if (null != pet) { + return Response.ok().entity(pet).build(); + } else { + throw new NotFoundException(404, "Pet not found"); + } + } + + @POST + @Consumes({"application/json", "application/xml"}) + @Operation(summary = "Add a new pet to the store", + responses = { + @ApiResponse(responseCode = "405", description = "Invalid input") + }) + public Response addPet( + @Parameter(description = "Pet object that needs to be added to the store", required = true) final Pet pet) { + petData.addPet(pet); + return Response.ok().entity("SUCCESS").build(); + } + + @POST + @Path("/bodynoannotation") + @Consumes({"application/json", "application/xml"}) + @Produces({"application/json", "application/xml"}) + @Operation(summary = "Add a new pet to the store no annotation", + responses = { + @ApiResponse(responseCode = "405", description = "Invalid input") + }) + public Response addPetNoAnnotation(final Pet pet) { + petData.addPet(pet); + return Response.ok().entity("SUCCESS").build(); + } + + @POST + @Path("/bodyid") + @Consumes({"application/json", "application/xml"}) + @Operation(summary = "Add a new pet to the store passing an integer with generic parameter annotation", + responses = { + @ApiResponse(responseCode = "405", description = "Invalid input") + }) + public Response addPetByInteger( + @Parameter(description = "Pet object that needs to be added to the store", required = true) final int petId) { + return Response.ok().entity("SUCCESS").build(); + } + + @POST + @Path("/bodyidnoannotation") + @Consumes({"application/json", "application/xml"}) + @Operation(summary = "Add a new pet to the store passing an integer without parameter annotation", + responses = { + @ApiResponse(responseCode = "405", description = "Invalid input") + }) + public Response addPetByIntegerNoAnnotation(final int petId) { + return Response.ok().entity("SUCCESS").build(); + } + + @PUT + @Operation(summary = "Update an existing pet", + responses = { + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found"), + @ApiResponse(responseCode = "405", description = "Validation exception")}) + public Response updatePet( + @Parameter(description = "Pet object that needs to be added to the store", required = true) final Pet pet) { + petData.addPet(pet); + return Response.ok().entity("SUCCESS").build(); + } + + @GET + @Path("/findByStatus") + @Produces("application/xml") + @Operation(summary = "Finds Pets by status", + description = "Multiple status values can be provided with comma seperated strings", + responses = { + @ApiResponse( + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = Pet.class))), + @ApiResponse( + responseCode = "400", description = "Invalid status value" + )} + ) + public Response findPetsByStatus( + @Parameter(description = "Status values that need to be considered for filter", required = true) @QueryParam("status") final String status, + @BeanParam final QueryResultBean qr + ) { + return Response.ok(petData.findPetByStatus(status)).build(); + } + + @GET + @Path("/findByTags") + @Produces("application/json") + @Operation(summary = "Finds Pets by tags", + description = "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", + responses = { + @ApiResponse(description = "Pets matching criteria", + content = @Content(schema = @Schema(implementation = Pet.class)) + ), + @ApiResponse(description = "Invalid tag value", responseCode = "400") + }) + @Deprecated + public Response findPetsByTags( + @Parameter(description = "Tags to filter by", required = true) @QueryParam("tags") final String tags) { + return Response.ok(petData.findPetByTags(tags)).build(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/callback/ComplexCallbackResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/callback/ComplexCallbackResource.java new file mode 100644 index 0000000000..44dfc535ee --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/callback/ComplexCallbackResource.java @@ -0,0 +1,62 @@ +package io.swagger.v3.plugins.gradle.petstore.callback; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.callbacks.Callback; +import io.swagger.v3.oas.annotations.callbacks.Callbacks; +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.plugins.gradle.resources.model.User; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +public class ComplexCallbackResource { + @Callbacks({ + @Callback( + name = "testCallback1", + operation = @Operation( + operationId = "getAllReviews", + summary = "get all the reviews", + method = "get", + responses = @ApiResponse( + responseCode = "200", + description = "successful operation", + content = @Content( + mediaType = "application/json", + schema = @Schema( + type = "integer", + format = "int32")))), + callbackUrlExpression = "http://www.url.com"), + @Callback( + name = "testCallback2", + operation = @Operation( + operationId = "getAnSpecificReviews", + summary = "get a review", + method = "get", + responses = @ApiResponse( + responseCode = "200", + description = "successful operation", + content = @Content( + mediaType = "application/json", + schema = @Schema( + implementation = User.class)))), + callbackUrlExpression = "http://www.url2.com") + }) + @Operation( + summary = "Simple get operation", + operationId = "getWithNoParameters", + responses = { + @ApiResponse( + responseCode = "200", + description = "voila!") + }) + @GET + @Path("/complexcallback") + public String simpleGet(@Parameter(description = "idParam", schema = @Schema(implementation = User.class)) + @QueryParam("id") final String id) { + return null; + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/callback/MultipleCallbacksTestWithOperationResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/callback/MultipleCallbacksTestWithOperationResource.java new file mode 100644 index 0000000000..2ec7309b1b --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/callback/MultipleCallbacksTestWithOperationResource.java @@ -0,0 +1,45 @@ +package io.swagger.v3.plugins.gradle.petstore.callback; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.callbacks.Callback; +import io.swagger.v3.oas.annotations.callbacks.Callbacks; +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 javax.ws.rs.GET; +import javax.ws.rs.Path; + +public class MultipleCallbacksTestWithOperationResource { + @Callbacks({ + @Callback( + name = "testCallback1", + operation = @Operation( + operationId = "getAllReviews", + summary = "get all the reviews", + method = "get", + responses = @ApiResponse( + responseCode = "200", + description = "successful operation", + content = @Content( + mediaType = "application/json", + schema = @Schema( + type = "integer", + format = "int32")))), + callbackUrlExpression = "http://www.url.com"), + @Callback(name = "testCallback2", operation = @Operation(), callbackUrlExpression = "http://$request.query.url") + }) + @Operation( + summary = "Simple get operation", + operationId = "getWithNoParameters", + responses = { + @ApiResponse( + responseCode = "200", + description = "voila!") + }) + @GET + @Path("/multiplecallback") + public String simpleGet() { + return null; + } +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/callback/RepeatableCallbackResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/callback/RepeatableCallbackResource.java new file mode 100644 index 0000000000..82a60ca110 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/callback/RepeatableCallbackResource.java @@ -0,0 +1,46 @@ +package io.swagger.v3.plugins.gradle.petstore.callback; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.callbacks.Callback; +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 javax.ws.rs.GET; +import javax.ws.rs.Path; + +public class RepeatableCallbackResource { + @Callback(name = "testCallback", operation = + @Operation(), callbackUrlExpression = "http://$requests.query.url") + @Callback( + name = "testCallback1", + operation = @Operation( + operationId = "getAllReviews", + summary = "get all the reviews", + method = "get", + responses = @ApiResponse( + responseCode = "200", + description = "successful operation", + content = @Content( + mediaType = "application/json", + schema = @Schema( + type = "integer", + format = "int32")))), + callbackUrlExpression = "http://www.url.com") + @Callback(name = "testCallback2", operation = + @Operation(), + callbackUrlExpression = "http://$request.query.url") + @Operation( + summary = "Simple get operation", + operationId = "getWithNoParameters", + responses = { + @ApiResponse( + responseCode = "200", + description = "voila!") + }) + @GET + @Path("/repeatablecallback") + public String simpleGet() { + return null; + } +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/callback/SimpleCallbackWithOperationResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/callback/SimpleCallbackWithOperationResource.java new file mode 100644 index 0000000000..2c6e543362 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/callback/SimpleCallbackWithOperationResource.java @@ -0,0 +1,44 @@ +package io.swagger.v3.plugins.gradle.petstore.callback; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.callbacks.Callback; +import io.swagger.v3.oas.annotations.callbacks.Callbacks; +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 javax.ws.rs.GET; +import javax.ws.rs.Path; + +public class SimpleCallbackWithOperationResource { + @Callbacks({ + @Callback( + name = "testCallback1", + operation = @Operation( + operationId = "getAllReviews", + summary = "get all the reviews", + method = "get", + responses = @ApiResponse( + responseCode = "200", + description = "successful operation", + content = @Content( + mediaType = "application/json", + schema = @Schema( + type = "integer", + format = "int32")))), + callbackUrlExpression = "http://www.url.com") + }) + @Operation( + summary = "Simple get operation", + operationId = "getWithNoParameters", + responses = { + @ApiResponse( + responseCode = "200", + description = "voila!") + }) + @GET + @Path("/simplecallback") + public String simpleGet() { + return null; + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/example/ExamplesResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/example/ExamplesResource.java new file mode 100644 index 0000000000..84ae58bfb7 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/example/ExamplesResource.java @@ -0,0 +1,69 @@ +package io.swagger.v3.plugins.gradle.petstore.example; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.enums.ParameterStyle; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.ExampleObject; +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.plugins.gradle.resources.model.User; + +import javax.ws.rs.POST; +import javax.ws.rs.Path; + +/** + * Examples Resource Scenario + */ +public class ExamplesResource { + @Path("/example") + @POST + @Operation( + operationId = "subscribe", + description = "subscribes a client to updates relevant to the requestor's account", + parameters = { + @Parameter(in = ParameterIn.PATH, name = "subscriptionId", required = true, + schema = @Schema(name = "Schema", description = "Schema", example = "Subscription example"), + style = ParameterStyle.SIMPLE, example = "example", + examples = { + @ExampleObject(name = "subscriptionId_1", value = "12345", + summary = "Subscription number 12345", externalValue = "Subscription external value 1"), + @ExampleObject(name = "subscriptionId_2", value = "54321", + summary = "Subscription number 54321", externalValue = "Subscription external value 2") + }) + }, + responses = { + @ApiResponse( + description = "test description", + content = @Content( + mediaType = "*/*", + schema = @Schema( + type = "string", + format = "uuid", + description = "the generated UUID", + accessMode = Schema.AccessMode.READ_ONLY, + example = "Schema example" + ), + examples = { + @ExampleObject(name = "Default Response", value = "SubscriptionResponse", + summary = "Subscription Response Example", externalValue = "Subscription Response value 1") + } + )) + }) + public SubscriptionResponse subscribe(@RequestBody(description = "Created user object", required = true, + content = @Content( + schema = @Schema( + type = "string", + format = "uuid", + description = "the generated UUID", + accessMode = Schema.AccessMode.READ_ONLY, + example = "Schema example"), + examples = { + @ExampleObject(name = "Default Request", value = "SubscriptionRequest", + summary = "Subscription Request Example", externalValue = "Subscription Request Value") + })) User user) { + return null; + } +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/example/SubscriptionResponse.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/example/SubscriptionResponse.java new file mode 100644 index 0000000000..7b8bc707a4 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/example/SubscriptionResponse.java @@ -0,0 +1,5 @@ +package io.swagger.v3.plugins.gradle.petstore.example; + +public class SubscriptionResponse { + public String subscriptionId; +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/link/LinksResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/link/LinksResource.java new file mode 100644 index 0000000000..8450a64abf --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/link/LinksResource.java @@ -0,0 +1,44 @@ +package io.swagger.v3.plugins.gradle.petstore.link; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.links.Link; +import io.swagger.v3.oas.annotations.links.LinkParameter; +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 javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +/** + * Class with Links + */ +public class LinksResource { + @Path("/links") + @Operation(operationId = "getUserWithAddress", + responses = { + @ApiResponse(description = "test description", + content = @Content(mediaType = "*/*", schema = @Schema(ref = "#/components/schemas/User")), + links = { + @Link( + name = "address", + operationId = "getAddress", + parameters = @LinkParameter( + name = "userId", + expression = "$request.query.userId")), + @Link( + name = "user", + operationId = "getUser", + operationRef = "#/components/links/MyLink", + parameters = @LinkParameter( + name = "userId", + expression = "$request.query.userId")) + })} + ) + @GET + public String getUser(@QueryParam("userId")final String userId) { + return null; + } + +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/openapidefintion/OpenAPIDefinitionResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/openapidefintion/OpenAPIDefinitionResource.java new file mode 100644 index 0000000000..5e3e4f8c7b --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/openapidefintion/OpenAPIDefinitionResource.java @@ -0,0 +1,48 @@ +package io.swagger.v3.plugins.gradle.petstore.openapidefintion; + +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.info.Contact; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.info.License; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.servers.Server; +import io.swagger.v3.oas.annotations.servers.ServerVariable; +import io.swagger.v3.oas.annotations.tags.Tag; + +/** + * OpenAPIDefinition Example + */ +@OpenAPIDefinition( + info = @Info( + title = "Pet Resource Example", + version = "2.0", + description = "API Definition", + termsOfService = "Terms of service", + license = @License(name = "Apache 2.0", url = "http://foo.bar"), + contact = @Contact(url = "http://gigantic-server.com", name = "Fred", email = "Fred@gigagantic-server.com") + ), + tags = { + @Tag(name = "Tag 1", description = "desc 1", externalDocs = @ExternalDocumentation(description = "docs desc")), + @Tag(name = "Tag 2", description = "desc 2", externalDocs = @ExternalDocumentation(description = "docs desc 2")), + @Tag(name = "Tag 3") + }, + externalDocs = @ExternalDocumentation(description = "definition docs desc"), + security = { + @SecurityRequirement(name = "req 1", scopes = {"a", "b"}), + @SecurityRequirement(name = "req 2", scopes = {"b", "c"}) + }, + servers = { + @Server( + description = "server 1", + url = "http://foo", + variables = { + @ServerVariable(name = "var1", description = "var 1", defaultValue = "1", allowableValues = {"1", "2"}), + @ServerVariable(name = "var2", description = "var 2", defaultValue = "1", allowableValues = {"1", "2"}) + }) + } +) +public class OpenAPIDefinitionResource { + public void foo() { + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/AnnotatedSameNameOperationResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/AnnotatedSameNameOperationResource.java new file mode 100644 index 0000000000..db73258ef0 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/AnnotatedSameNameOperationResource.java @@ -0,0 +1,26 @@ +package io.swagger.v3.plugins.gradle.petstore.operation; + +import io.swagger.v3.oas.annotations.Operation; + +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +/** + * Resource With a Default Operation without Annotation + */ +public class AnnotatedSameNameOperationResource { + @Path("/sameOperationName") + @GET + @Operation(description = "Same Operation Name") + public String getUser() { + return new String(); + } + + @Path("//sameOperationName") + @DELETE + @Operation(description = "Same Operation Name Duplicated") + public String getUser(final String id) { + return new String(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/ExternalDocumentationResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/ExternalDocumentationResource.java new file mode 100644 index 0000000000..a351ac68bf --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/ExternalDocumentationResource.java @@ -0,0 +1,30 @@ +package io.swagger.v3.plugins.gradle.petstore.operation; + +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.plugins.gradle.resources.exception.NotFoundException; +import io.swagger.v3.plugins.gradle.resources.model.Pet; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.Response; + +/** + * Resource with Operations Examples + */ +public class ExternalDocumentationResource { + @GET + @Path("/{petId}") + @Operation(summary = "Find pet by ID", + description = "Returns a pet when 0 < ID <= 10. ID > 10 or non integers will simulate API error conditions", + operationId = "petId", + externalDocs = @ExternalDocumentation(description = "External in Operation", url = "http://url.me")) + @ExternalDocumentation(description = "External Annotation Documentation", url = "http://url.me") + public Response getPetById( + @Parameter(description = "ID of pet that needs to be fetched", required = true) + @PathParam("petId") Long petId) throws NotFoundException { + return Response.ok().entity(new Pet()).build(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/FullyAnnotatedOperationResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/FullyAnnotatedOperationResource.java new file mode 100644 index 0000000000..2955c6590e --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/FullyAnnotatedOperationResource.java @@ -0,0 +1,38 @@ +package io.swagger.v3.plugins.gradle.petstore.operation; + +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.plugins.gradle.resources.exception.NotFoundException; +import io.swagger.v3.plugins.gradle.resources.model.Pet; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.Response; + +/** + * Resource with Operations Examples + */ +public class FullyAnnotatedOperationResource { + @GET + @Path("/fullyannotatedoperation/{petId}") + @Operation(summary = "Find pet by ID", + description = "Returns a pet when 0 < ID <= 10. ID > 10 or non integers will simulate API error conditions", + operationId = "petId", + responses = { + @ApiResponse( + description = "The pet", content = @Content( + schema = @Schema(implementation = Pet.class) + )), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") + }) + public Response getPetById( + @Parameter(description = "ID of pet that needs to be fetched", required = true) + @PathParam("petId")final Long petId) throws NotFoundException { + return Response.ok().entity(new Pet()).build(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/HiddenOperationResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/HiddenOperationResource.java new file mode 100644 index 0000000000..730e83657d --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/HiddenOperationResource.java @@ -0,0 +1,29 @@ +package io.swagger.v3.plugins.gradle.petstore.operation; + +import io.swagger.v3.oas.annotations.Hidden; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.plugins.gradle.resources.model.Pet; +import io.swagger.v3.plugins.gradle.resources.model.User; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +/** + * Resource With a Hidden Operation + */ +public class HiddenOperationResource { + @Path("/hiddenbyflag") + @GET + @Operation(operationId = "Pets", description = "Pets Example", hidden = true) + public Pet getPet() { + return new Pet(); + } + + @Path("/hiddenbyannotation") + @GET + @Operation(operationId = "Users", description = "Users Example") + @Hidden + public User getUser() { + return new User(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/InterfaceResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/InterfaceResource.java new file mode 100644 index 0000000000..aa5418ecc6 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/InterfaceResource.java @@ -0,0 +1,22 @@ +package io.swagger.v3.plugins.gradle.petstore.operation; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.Response; + +/** + * Interface resource + */ +public interface InterfaceResource { + @GET + @Path("/interfaceoperation/{petId}") + @Operation(summary = "Find pet by ID Operation in Parent", + description = "Returns a pet in Parent" + ) + Response getPetById(@Parameter(description = "ID of pet that needs to be fetched", required = true) + @PathParam("petId") final Long petId); +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/NotAnnotatedSameNameOperationResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/NotAnnotatedSameNameOperationResource.java new file mode 100644 index 0000000000..e8021608de --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/NotAnnotatedSameNameOperationResource.java @@ -0,0 +1,21 @@ +package io.swagger.v3.plugins.gradle.petstore.operation; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +/** + * Resource With a Default Operation without Annotation + */ +public class NotAnnotatedSameNameOperationResource { + @Path("/notannotatedoperation") + @GET + public String getUser() { + return new String(); + } + + @Path("/notannotatedoperationduplicated") + @GET + public String getUser(final String id) { + return new String(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/OperationResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/OperationResource.java new file mode 100644 index 0000000000..fdc5e495ca --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/OperationResource.java @@ -0,0 +1,77 @@ +package io.swagger.v3.plugins.gradle.petstore.operation; + +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.plugins.gradle.resources.model.Pet; + +import javax.ws.rs.GET; +import javax.ws.rs.HEAD; +import javax.ws.rs.NotFoundException; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Response; + +/** + * Resource with Complete Operations Examples + */ +public class OperationResource implements InterfaceResource { + @Override + @Operation(summary = "Find pet by ID Operation in SubResource", + description = "Returns a pet in SubResource" + ) + public Response getPetById(final Long petId) { + return Response.ok().entity(new Pet()).build(); + } + + @GET + @Path("/operationsresource") + @Operation(summary = "Find pet by ID", + description = "combinatedfullyannotatedoperation/{petId}", + operationId = "petId", + responses = { + @ApiResponse( + description = "The pet", content = @Content( + schema = @Schema(implementation = Pet.class) + )), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") + }) + public Response getPetById( + @Parameter(description = "ID of pet that needs to be fetched", required = true) + @QueryParam("petId") final Long petId, final String message) throws NotFoundException { + return Response.ok().entity(new Pet()).build(); + } + + @Path("/operationsresource") + @POST + public String getUser(final String id) { + return new String(); + } + + @Path("/operationsresource") + @PUT + @Operation(operationId = "combinated sameOperationName", + description = "combinatedsameOperationName") + public String getPerson() { + return new String(); + } + + @Path("/operationsresource") + @HEAD + @Operation(operationId = "combinatedsameOperationNameDuplicated", + description = "combinatedsameOperationNameDuplicated") + public String getPerson(final String id) { + return new String(); + } + + @Path("/operationsresource2") + @GET + public String getUser() { + return new String(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/OperationWithoutAnnotationResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/OperationWithoutAnnotationResource.java new file mode 100644 index 0000000000..7c4bf2cd02 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/OperationWithoutAnnotationResource.java @@ -0,0 +1,15 @@ +package io.swagger.v3.plugins.gradle.petstore.operation; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +/** + * Resource With a Default Operation without Annotation + */ +public class OperationWithoutAnnotationResource { + @Path("/operationwithouannotation") + @GET + public String getUser() { + return new String(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/ServerOperationResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/ServerOperationResource.java new file mode 100644 index 0000000000..955fc331d8 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/ServerOperationResource.java @@ -0,0 +1,30 @@ +package io.swagger.v3.plugins.gradle.petstore.operation; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.servers.Server; +import io.swagger.v3.plugins.gradle.resources.model.Pet; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +/** + * Resource With a Hidden Operation + */ +@OpenAPIDefinition( + servers = { + @Server(description = "server 1", url = "http://foo") + } +) +public class ServerOperationResource { + @Path("/serversoperation") + @GET + @Operation(operationId = "Pets", description = "Pets Example", + servers = { + @Server(description = "server 2", url = "http://foo2") + } + ) + public Pet getPet() { + return new Pet(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/SubResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/SubResource.java new file mode 100644 index 0000000000..d56a767030 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/SubResource.java @@ -0,0 +1,20 @@ +package io.swagger.v3.plugins.gradle.petstore.operation; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.plugins.gradle.resources.model.Pet; + +import javax.ws.rs.core.Response; + +/** + * SubResource + */ + +public class SubResource implements InterfaceResource { + @Override + @Operation(summary = "Find pet by ID Operation in SubResource", + description = "Returns a pet in SubResource" + ) + public Response getPetById(final Long petId) { + return Response.ok().entity(new Pet()).build(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/ArraySchemaResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/ArraySchemaResource.java new file mode 100644 index 0000000000..1ec07a8ce8 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/ArraySchemaResource.java @@ -0,0 +1,44 @@ +package io.swagger.v3.plugins.gradle.petstore.parameter; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.Explode; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.ArraySchema; +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 javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; + +public class ArraySchemaResource { + @Path("/arrayschema") + @POST + @Operation( + operationId = "subscribe", + description = "subscribes a client to updates relevant to the requestor's account, as " + + "identified by the input token. The supplied url will be used as the delivery address for response payloads", + parameters = { + @Parameter(in = ParameterIn.QUERY, name = "arrayParameter", required = true, explode = Explode.TRUE, + array = @ArraySchema(maxItems = 10, minItems = 1, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class), + uniqueItems = true + ) + ), + }, + responses = { + @ApiResponse( + description = "test description", content = @Content( + mediaType = "*/*", + schema = + @Schema( + implementation = ParametersResource.SubscriptionResponse.class) + )) + }) + @Consumes({"application/json", "application/xml"}) + public ParametersResource.SubscriptionResponse subscribe() { + return null; + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/ComplexParameterResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/ComplexParameterResource.java new file mode 100644 index 0000000000..c2ca2f84aa --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/ComplexParameterResource.java @@ -0,0 +1,33 @@ +package io.swagger.v3.plugins.gradle.petstore.parameter; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.plugins.gradle.resources.model.User; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +/** + * Class with a multiple annotated. + */ +public class ComplexParameterResource { + + @Parameter(description = "Phone definied in Field") + private String phone; + + public ComplexParameterResource(@Parameter(description = "phone Param", name = "phone") final String phone) { + this.phone = phone; + } + + @GET + @Path("/complexparameter") + @Operation(operationId = "create User") + public User findUser(@Parameter(description = "idParam") @QueryParam("id") final String id, + final String name, @QueryParam("lastName") final String lastName, + @Parameter(description = "address", schema = @Schema(implementation = User.class)) + @QueryParam("address") final String address) { + return new User(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/ComplexParameterWithOperationResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/ComplexParameterWithOperationResource.java new file mode 100644 index 0000000000..d1c36874c9 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/ComplexParameterWithOperationResource.java @@ -0,0 +1,37 @@ +package io.swagger.v3.plugins.gradle.petstore.parameter; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.plugins.gradle.resources.model.User; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +/** + * Class with a multiple annotated. + */ +public class ComplexParameterWithOperationResource { + + @Parameter(description = "Phone definied in Field") + private String phone; + + public ComplexParameterWithOperationResource(@Parameter(description = "phone Param", name = "phone") final String phone) { + this.phone = phone; + } + + @GET + @Path("/complexparameter") + @Operation(operationId = "create User", + parameters = { + @Parameter(description = "Phone", name = "phone", in = ParameterIn.PATH) + }) + public User findUser(@Parameter(description = "idParam") @QueryParam("id") final String id, + final String name, @QueryParam("lastName") final String lastName, + @Parameter(description = "address", schema = @Schema(implementation = User.class)) + @QueryParam("address") final String address) { + return new User(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/MultipleNotAnnotatedParameter.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/MultipleNotAnnotatedParameter.java new file mode 100644 index 0000000000..7303048545 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/MultipleNotAnnotatedParameter.java @@ -0,0 +1,18 @@ +package io.swagger.v3.plugins.gradle.petstore.parameter; + +import io.swagger.v3.oas.annotations.Operation; + +import javax.ws.rs.POST; +import javax.ws.rs.Path; + +/** + * Class with a multiple not annotated parameter. + */ +public class MultipleNotAnnotatedParameter { + @POST + @Path("/multiplenoannotatedparameter") + @Operation(operationId = "create User") + public void createUser(final String id, final String name) { + + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/OpenAPIJaxRSAnnotatedParameter.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/OpenAPIJaxRSAnnotatedParameter.java new file mode 100644 index 0000000000..9832b462db --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/OpenAPIJaxRSAnnotatedParameter.java @@ -0,0 +1,21 @@ +package io.swagger.v3.plugins.gradle.petstore.parameter; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.plugins.gradle.resources.model.User; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +/** + * Class with a single parameter annotated with jaxrs and open api annotation. + */ +public class OpenAPIJaxRSAnnotatedParameter { + @GET + @Path("/openapijaxrsannotatedparameter") + @Operation(operationId = "create User") + public User findUser(@Parameter(description = "idParam") @QueryParam("id") final String id) { + return new User(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/OpenAPIWithContentJaxRSAnnotatedParameter.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/OpenAPIWithContentJaxRSAnnotatedParameter.java new file mode 100644 index 0000000000..4c4f1ddc32 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/OpenAPIWithContentJaxRSAnnotatedParameter.java @@ -0,0 +1,25 @@ +package io.swagger.v3.plugins.gradle.petstore.parameter; + +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.plugins.gradle.resources.model.User; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +/** + * Class with a single parameter annotated with jaxrs and open api annotation. + */ +public class OpenAPIWithContentJaxRSAnnotatedParameter { + @GET + @Path("/openapiwithcontentjaxrsannotatedparameter") + @Operation(operationId = "create User") + public User findUser(@Parameter(description = "idParam", content = + @Content(schema = @Schema(description = "Id Schema Definition", required = true, name = "id"))) + @QueryParam("id") final String id) { + return new User(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/OpenAPIWithImplementationJaxRSAnnotatedParameter.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/OpenAPIWithImplementationJaxRSAnnotatedParameter.java new file mode 100644 index 0000000000..df23a83a76 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/OpenAPIWithImplementationJaxRSAnnotatedParameter.java @@ -0,0 +1,23 @@ +package io.swagger.v3.plugins.gradle.petstore.parameter; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.plugins.gradle.resources.model.User; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +/** + * Class with a single parameter annotated with jaxrs and open api annotation. + */ +public class OpenAPIWithImplementationJaxRSAnnotatedParameter { + @GET + @Path("/openapiwithimplementationjaxrsannotatedparameter") + @Operation(operationId = "create User") + public User findUser(@Parameter(description = "idParam", schema = @Schema(implementation = User.class)) + @QueryParam("id") final String id) { + return new User(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/ParametersResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/ParametersResource.java new file mode 100644 index 0000000000..849973f1a9 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/ParametersResource.java @@ -0,0 +1,87 @@ +package io.swagger.v3.plugins.gradle.petstore.parameter; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.Explode; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.enums.ParameterStyle; +import io.swagger.v3.oas.annotations.media.ArraySchema; +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 javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +/** + * Resource with some Parameters examples + */ +public class ParametersResource { + @Path("/parameters") + @POST + @Operation( + operationId = "subscribe", + description = "subscribes a client to updates relevant to the requestor's account, as " + + "identified by the input token. The supplied url will be used as the delivery address for response payloads", + parameters = { + @Parameter(in = ParameterIn.PATH, name = "subscriptionId", required = true, + schema = @Schema(implementation = RepeatableParametersResource.SubscriptionResponse.class), style = ParameterStyle.SIMPLE), + @Parameter(in = ParameterIn.QUERY, name = "formId", required = true, + example = "Example"), + @Parameter(in = ParameterIn.QUERY, name = "explodeFalse", required = true, explode = Explode.FALSE, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class)), + @Parameter(in = ParameterIn.QUERY, name = "explodeTrue", required = true, explode = Explode.TRUE, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class)), + @Parameter(in = ParameterIn.QUERY, name = "explodeAvoiding", required = true, explode = Explode.TRUE, + schema = @Schema( + type = "int", + format = "id", + description = "the generated id", + accessMode = Schema.AccessMode.READ_ONLY + )), + @Parameter(in = ParameterIn.QUERY, name = "arrayParameter", required = true, explode = Explode.TRUE, + array = @ArraySchema(maxItems = 10, minItems = 1, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class), + uniqueItems = true + ) + , + schema = @Schema( + type = "int", + format = "id", + description = "the generated id", + accessMode = Schema.AccessMode.READ_ONLY), + content = @Content(schema = @Schema(type = "number", + description = "the generated id", + accessMode = Schema.AccessMode.READ_ONLY)) + ), + @Parameter(in = ParameterIn.QUERY, name = "arrayParameterImplementation", required = true, explode = Explode.TRUE, + array = @ArraySchema(maxItems = 10, minItems = 1, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class), + uniqueItems = true + ) + ), + @Parameter(in = ParameterIn.QUERY, name = "arrayParameterImplementation2", required = true, explode = Explode.TRUE, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class)) + + }, + responses = { + @ApiResponse( + description = "test description", content = @Content( + mediaType = "*/*", + schema = + @Schema( + implementation = ParametersResource.SubscriptionResponse.class) + )) + }) + @Consumes({"application/json", "application/xml"}) + public ParametersResource.SubscriptionResponse subscribe(@Parameter(description = "idParam") + @QueryParam("id") final String id) { + return null; + } + + static class SubscriptionResponse { + public String subscriptionId; + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/RepeatableParametersResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/RepeatableParametersResource.java new file mode 100644 index 0000000000..2626f0c6ac --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/RepeatableParametersResource.java @@ -0,0 +1,80 @@ +package io.swagger.v3.plugins.gradle.petstore.parameter; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.Explode; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.enums.ParameterStyle; +import io.swagger.v3.oas.annotations.media.ArraySchema; +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 javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; + +public class RepeatableParametersResource { + @Path("/repeatableparameter") + @POST + @Parameter(in = ParameterIn.PATH, name = "subscriptionId", required = true, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class), style = ParameterStyle.SIMPLE) + @Parameter(in = ParameterIn.QUERY, name = "formId", required = true, + example = "Example") + @Parameter(in = ParameterIn.QUERY, name = "explodeFalse", required = true, explode = Explode.FALSE, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class)) + @Parameter(in = ParameterIn.QUERY, name = "explodeTrue", required = true, explode = Explode.TRUE, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class)) + @Parameter(in = ParameterIn.QUERY, name = "explodeAvoiding", required = true, explode = Explode.TRUE, + schema = @Schema( + type = "int", + format = "id", + description = "the generated id", + accessMode = Schema.AccessMode.READ_ONLY + )) + @Parameter(in = ParameterIn.QUERY, name = "arrayParameter", required = true, explode = Explode.TRUE, + array = @ArraySchema(maxItems = 10, minItems = 1, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class), + uniqueItems = true + ) + , + schema = @Schema( + type = "int", + format = "id", + description = "the generated id", + accessMode = Schema.AccessMode.READ_ONLY), + content = @Content(schema = @Schema(type = "number", + description = "the generated id", + accessMode = Schema.AccessMode.READ_ONLY)) + ) + @Parameter(in = ParameterIn.QUERY, name = "arrayParameterImplementation", required = true, explode = Explode.TRUE, + array = @ArraySchema(maxItems = 10, minItems = 1, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class), + uniqueItems = true + ) + ) + @Parameter(in = ParameterIn.QUERY, name = "arrayParameterImplementation2", required = true, explode = Explode.TRUE, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class)) + @Operation( + operationId = "subscribe", + description = "subscribes a client to updates relevant to the requestor's account, as " + + "identified by the input token. The supplied url will be used as the delivery address for response payloads", + responses = { + @ApiResponse( + description = "test description", content = @Content( + mediaType = "*/*", + schema = + @Schema( + implementation = ParametersResource.SubscriptionResponse.class) + )) + }) + @Consumes({"application/json", "application/xml"}) + public ParametersResource.SubscriptionResponse subscribe() { + return null; + } + + static class SubscriptionResponse { + public String subscriptionId; + } +} + diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/SingleJaxRSAnnotatedParameter.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/SingleJaxRSAnnotatedParameter.java new file mode 100644 index 0000000000..29788cd9eb --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/SingleJaxRSAnnotatedParameter.java @@ -0,0 +1,20 @@ +package io.swagger.v3.plugins.gradle.petstore.parameter; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.plugins.gradle.resources.model.User; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +/** + * Class with a single parameter annotated with jaxrs. + */ +public class SingleJaxRSAnnotatedParameter { + @GET + @Path("/singlejaxrsannotatedparameter") + @Operation(operationId = "create User") + public User findUser(@QueryParam("id") final String id) { + return new User(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/SingleNotAnnotatedParameter.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/SingleNotAnnotatedParameter.java new file mode 100644 index 0000000000..a322111708 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/SingleNotAnnotatedParameter.java @@ -0,0 +1,19 @@ +package io.swagger.v3.plugins.gradle.petstore.parameter; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.plugins.gradle.resources.model.User; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +/** + * Class with a single not annotated parameter. + */ +public class SingleNotAnnotatedParameter { + @GET + @Path("/singlenoannotatedparameter") + @Operation(operationId = "create User") + public User findUser(final String id) { + return new User(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/requestbody/RequestBodyMethodPriorityResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/requestbody/RequestBodyMethodPriorityResource.java new file mode 100644 index 0000000000..6e9ee3715b --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/requestbody/RequestBodyMethodPriorityResource.java @@ -0,0 +1,28 @@ +package io.swagger.v3.plugins.gradle.petstore.requestbody; + +import io.swagger.v3.oas.annotations.Operation; +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.plugins.gradle.resources.model.User; + +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; + +/** + * Resource with RequestBody inside Operation and another in Method + */ +public class RequestBodyMethodPriorityResource { + @POST + @Path("/requestbodymethodpriority") + @Operation(summary = "Create user", + description = "This can only be done by the logged in user.", + requestBody = @RequestBody(description = "Inside Operation")) + @RequestBody(description = "Created user object on Method", required = true, + content = @Content( + schema = @Schema(implementation = User.class))) + public Response methodWithRequestBodyAndTwoParameters(final User user) { + return Response.ok().entity("").build(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/requestbody/RequestBodyParameterPriorityResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/requestbody/RequestBodyParameterPriorityResource.java new file mode 100644 index 0000000000..f76a4781ae --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/requestbody/RequestBodyParameterPriorityResource.java @@ -0,0 +1,29 @@ +package io.swagger.v3.plugins.gradle.petstore.requestbody; + +import io.swagger.v3.oas.annotations.Operation; +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.plugins.gradle.resources.model.User; + +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; + +/** + * Resource with RequestBody inside Operation and another in Method + */ +public class RequestBodyParameterPriorityResource { + @POST + @Path("/requestbodyparameterpriority") + @Operation(summary = "Create user", + description = "This can only be done by the logged in user.", + requestBody = @RequestBody(description = "Inside Operation")) + @RequestBody(description = "On method") + public Response methodWithRequestBodyAndTwoParameters( + @RequestBody(description = "Created user object inside Parameter", required = true, + content = @Content( + schema = @Schema(implementation = User.class)))final User user) { + return Response.ok().entity("").build(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/requestbody/RequestBodyResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/requestbody/RequestBodyResource.java new file mode 100644 index 0000000000..b2e310e0cc --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/requestbody/RequestBodyResource.java @@ -0,0 +1,113 @@ +package io.swagger.v3.plugins.gradle.petstore.requestbody; + +import io.swagger.v3.oas.annotations.Operation; +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.plugins.gradle.resources.model.Pet; +import io.swagger.v3.plugins.gradle.resources.model.User; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Response; + +/** + * Resource with RequestBody examples + */ +public class RequestBodyResource { + @GET + @Path("/methodWithRequestBodyWithoutContent") + @Operation(summary = "Create user", + description = "This can only be done by the logged in user.") + public Response methodWithRequestBodyWithoutContent( + @RequestBody(description = "Created user object", required = true) final User user) { + return Response.ok().entity("").build(); + } + + @GET + @Path("/methodWithRequestBodyWithoutContentWithoutImplementation") + @Operation(summary = "Create user", + description = "This can only be done by the logged in user.") + public Response methodWithRequestBodyWithoutContentWithoutImplementation( + @RequestBody(description = "Created user object", required = true, + content = @Content( + schema = @Schema(name = "User", description = "User description", + example = "User Description", required = true))) final User user) { + return Response.ok().entity("").build(); + } + + @POST + @Path("/methodWithRequestBodyAndTwoParameters") + @Operation(summary = "Create user", + description = "This can only be done by the logged in user.") + public Response methodWithRequestBodyAndTwoParameters( + @RequestBody(description = "Created user object", required = true, + content = @Content( + schema = @Schema(implementation = User.class))) final User user, + @QueryParam("name") final String name, @QueryParam("code") final String code) { + return Response.ok().entity("").build(); + } + + @PUT + @Path("/methodWithRequestBodyWithoutAnnotation") + @Operation(summary = "Modify user", + description = "Modifying user.") + public Response methodWithRequestBodyWithoutAnnotation( + final User user) { + return Response.ok().entity("").build(); + } + + @DELETE + @Path("/methodWithoutRequestBodyAndTwoParameters") + @Operation(summary = "Delete user", + description = "This can only be done by the logged in user.") + public Response methodWithoutRequestBodyAndTwoParameters( + @QueryParam("name") final String name, @QueryParam("code") final String code) { + return Response.ok().entity("").build(); + } + + @PUT + @Path("/methodWithRequestBodyWithoutAnnotationAndTwoConsumes") + @Operation(summary = "Modify pet", + description = "Modifying pet.") + @Consumes({"application/json", "application/xml"}) + public Response methodWithRequestBodyWithoutAnnotationAndTwoConsumes( + final User user) { + return Response.ok().entity("").build(); + } + + @POST + @Path("/methodWithTwoRequestBodyWithoutAnnotationAndTwoConsumes") + @Operation(summary = "Create pet", + description = "Creating pet.") + @Consumes({"application/json", "application/xml"}) + public Response methodWithTwoRequestBodyWithoutAnnotationAndTwoConsumes( + final Pet pet, final User user) { + return Response.ok().entity("").build(); + } + + @POST + @Path("/methodWithTwoRequestBodyWithAnnotationAndTwoConsumes") + @Operation(summary = "Create pet", + description = "Creating pet.") + @Consumes({"application/json", "application/xml"}) + public Response methodWithTwoRequestBodyWithAnnotationAndTwoConsumes( + final @RequestBody(description = "Request Body Pet") Pet pet, + @RequestBody(description = "Request Body User") final User user) { + return Response.ok().entity("").build(); + } + + @DELETE + @Path("/methodWithOneSimpleRequestBody") + @Operation(summary = "Delete pet", + description = "Deleting pet.") + @Consumes({"application/json", "application/xml"}) + public Response methodWithOneSimpleRequestBody(final int id) { + return Response.ok().entity("").build(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/ComplexResponseResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/ComplexResponseResource.java new file mode 100644 index 0000000000..db25ec92da --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/ComplexResponseResource.java @@ -0,0 +1,34 @@ +package io.swagger.v3.plugins.gradle.petstore.responses; + +import io.swagger.v3.oas.annotations.Operation; +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.plugins.gradle.resources.exception.NotFoundException; +import io.swagger.v3.plugins.gradle.resources.model.Pet; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +/** + * Resource with some responses + */ +public class ComplexResponseResource { + @GET + @Path("/complexresponse") + @Operation(summary = "Find pets", + description = "Returns the Pets", + responses = { + @ApiResponse(description = "Response inside Operation", responseCode = "200", + content = @Content(schema = + @Schema(implementation = Pet.class))), + @ApiResponse(description = "Default Pet", + content = @Content(schema = + @Schema(name = "Default Pet", description = "Default Pet", + required = true, example = "New Pet"))) + }) + @ApiResponse(responseCode = "404", description = "Couldn't find pet") + public Pet getPets() throws NotFoundException { + return new Pet(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/ImplementationResponseResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/ImplementationResponseResource.java new file mode 100644 index 0000000000..779476fc5c --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/ImplementationResponseResource.java @@ -0,0 +1,71 @@ +package io.swagger.v3.plugins.gradle.petstore.responses; + +import io.swagger.v3.oas.annotations.Operation; +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 javax.ws.rs.GET; +import javax.ws.rs.Path; + +/** + * Resource with a Response at Method Level + */ +public class ImplementationResponseResource { + @GET + @Path("/implementationresponse") + @Operation( + summary = "Simple get operation", + description = "Defines a simple get operation with no inputs and a complex output object", + operationId = "getWithPayloadResponse", + deprecated = true, + responses = { + @ApiResponse( + responseCode = "200", + description = "voila!", + content = { + @Content( + mediaType = "application/json", + schema = + @Schema( + implementation = ImplementationResponseResource.SampleResponseSchema.class) + ), + @Content( + mediaType = "application/json", + schema = + @Schema( + implementation = ImplementationResponseResource.SecondSampleResponseSchema.class) + ) + } + + ), + @ApiResponse( + responseCode = "400", + description = "boo", + content = @Content( + mediaType = "*/*", + schema = + @Schema(implementation = ImplementationResponseResource.GenericError.class) + ) + ) + } + ) + + public void getResponses() { + } + + static class SampleResponseSchema { + @Schema(description = "the user id") + private String id; + } + + static class SecondSampleResponseSchema { + @Schema(description = "the user id") + private String id; + } + + static class GenericError { + private int code; + private String message; + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/MethodResponseResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/MethodResponseResource.java new file mode 100644 index 0000000000..45eab02a09 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/MethodResponseResource.java @@ -0,0 +1,24 @@ +package io.swagger.v3.plugins.gradle.petstore.responses; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.plugins.gradle.resources.exception.NotFoundException; +import io.swagger.v3.plugins.gradle.resources.model.Pet; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; + +/** + * Resource with a Response at Method Level + */ +public class MethodResponseResource { + @GET + @Path("/responseinmethod") + @Operation(summary = "Find pets", + description = "Returns the Pets") + @ApiResponse(responseCode = "200", description = "Status OK") + public Response getPets() throws NotFoundException { + return Response.ok().entity(new Pet()).build(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/NoImplementationResponseResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/NoImplementationResponseResource.java new file mode 100644 index 0000000000..a4cea952b1 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/NoImplementationResponseResource.java @@ -0,0 +1,66 @@ +package io.swagger.v3.plugins.gradle.petstore.responses; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.links.Link; +import io.swagger.v3.oas.annotations.links.LinkParameter; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +/** + * Resource with a Response at Method Level + */ +public class NoImplementationResponseResource { + @Path("/noimplementationresponseresource") + @Operation(operationId = "getUser", + responses = { + @ApiResponse(description = "test description", responseCode = "400", + links = { + @Link( + name = "user", + operationId = "getUser", + operationRef = "#/components/links/MyLink", + parameters = @LinkParameter( + name = "userId", + expression = "$request.query.userId")) + }), + @ApiResponse(description = "200 description", responseCode = "200", + links = { + @Link( + name = "pet", + operationId = "getUser", + operationRef = "#/components/links/MyLink", + parameters = @LinkParameter( + name = "userId", + expression = "$request.query.userId")) + }) + } + ) + @GET + public NoImplementationResponseResource.User getUser(@QueryParam("userId") final String userId) { + return null; + } + + static class User { + private String id; + private String username; + + public String getId() { + return id; + } + + public void setId(final String id) { + this.id = id; + } + + public String getUsername() { + return username; + } + + public void setUsername(final String username) { + this.username = username; + } + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/NoResponseResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/NoResponseResource.java new file mode 100644 index 0000000000..432b452a53 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/NoResponseResource.java @@ -0,0 +1,21 @@ +package io.swagger.v3.plugins.gradle.petstore.responses; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.plugins.gradle.resources.exception.NotFoundException; +import io.swagger.v3.plugins.gradle.resources.model.User; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +/** + * Resource with a Response at Method Level + */ +public class NoResponseResource { + @GET + @Path("/noresponse") + @Operation(summary = "Find pets", + description = "Returns the Pets") + public User getPets() throws NotFoundException { + return new User(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/OperationResponseResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/OperationResponseResource.java new file mode 100644 index 0000000000..38cbbc426e --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/OperationResponseResource.java @@ -0,0 +1,25 @@ +package io.swagger.v3.plugins.gradle.petstore.responses; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.plugins.gradle.resources.exception.NotFoundException; +import io.swagger.v3.plugins.gradle.resources.model.User; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; + +/** + * Resource with the response in the Operation Annotation + */ +public class OperationResponseResource { + @GET + @Path("/responseinoperation") + @Operation(summary = "Find Users", + description = "Returns the Users", + responses = {@ApiResponse(responseCode = "200", description = "Status OK")}) + public Response getUsers() throws NotFoundException { + return Response.ok().entity(new User()).build(); + } + +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/PriorityResponseResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/PriorityResponseResource.java new file mode 100644 index 0000000000..f14c1ff364 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/PriorityResponseResource.java @@ -0,0 +1,25 @@ +package io.swagger.v3.plugins.gradle.petstore.responses; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.plugins.gradle.resources.exception.NotFoundException; +import io.swagger.v3.plugins.gradle.resources.model.Pet; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; + +/** + * Resource with a Response at Method Level and Operation Level. + */ +public class PriorityResponseResource { + @GET + @Path("/priorityresponses") + @Operation(summary = "Find pets", + description = "Returns the Pets", + responses = {@ApiResponse(responseCode = "200", description = "Inside Operation Response")}) + @ApiResponse(responseCode = "200", description = "Inside Method Operation") + public Response getPets() throws NotFoundException { + return Response.ok().entity(new Pet()).build(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/security/SecurityResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/security/SecurityResource.java new file mode 100644 index 0000000000..b24bf3db65 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/security/SecurityResource.java @@ -0,0 +1,61 @@ +package io.swagger.v3.plugins.gradle.petstore.security; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeIn; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.security.OAuthFlow; +import io.swagger.v3.oas.annotations.security.OAuthFlows; +import io.swagger.v3.oas.annotations.security.OAuthScope; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.security.SecurityScheme; + +import javax.ws.rs.GET; +import javax.ws.rs.PATCH; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; + +@SecurityScheme(name = "myOauth2Security", + type = SecuritySchemeType.OAUTH2, + in = SecuritySchemeIn.HEADER, + description = "myOauthSecurity Description", + flows = @OAuthFlows(implicit = @OAuthFlow(authorizationUrl = "http://x.com", + scopes = @OAuthScope( + name = "write:pets", + description = "modify pets in your account")) + ) +) +@SecurityRequirement(name = "security_key", + scopes = {"write:pets", "read:pets"} +) +@SecurityRequirement(name = "myOauth2Security", + scopes = {"write:pets"} +) +@Path("/security") +public class SecurityResource { + @GET + @Operation(operationId = "Operation Id", + description = "description") + @SecurityRequirement(name = "security_key", + scopes = {"write:pets", "read:pets"} + ) + public void getSecurity() { + } + + @PATCH + @Operation(operationId = "Operation Id 2", + description = "description 2") + @SecurityRequirement(name = "security_key2", + scopes = {"write:pets", "read:pets"} + ) + public void getSecurity2() { + } + + @PUT + @Operation(operationId = "Operation Id 3", + description = "description 3", security = + @SecurityRequirement(name = "security_key3", + scopes = {"write:pets", "read:pets"} + )) + public void setSecurity(String security) { + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/CompleteTagResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/CompleteTagResource.java new file mode 100644 index 0000000000..a643d76982 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/CompleteTagResource.java @@ -0,0 +1,31 @@ +package io.swagger.v3.plugins.gradle.petstore.tags; + +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; + +@OpenAPIDefinition(tags = { + @Tag(name = "Definition First Tag"), + @Tag(name = "Definition Second Tag full", description = "desc definition") +}) +@Tag(name = "Second Tag") +@Tag(name = "Fourth Tag Full", description = "desc class", externalDocs = @ExternalDocumentation(description = "docs desc class")) +@Tag(name = "Fifth Tag Full", description = "desc class", externalDocs = @ExternalDocumentation(description = "docs desc class")) +@Tag(name = "Sixth Tag") +public class CompleteTagResource { + + @GET + @Path("/completetags") + @Operation(tags = {"Example Tag", "Second Tag"}) + @Tag(name = "Third Tag") + @Tag(name = "Second Tag") + @Tag(name = "Fourth Tag Full", description = "desc", externalDocs = @ExternalDocumentation(description = "docs desc")) + public Response getTags() { + return Response.ok().entity("ok").build(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/TagClassResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/TagClassResource.java new file mode 100644 index 0000000000..96e3611d62 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/TagClassResource.java @@ -0,0 +1,14 @@ +package io.swagger.v3.plugins.gradle.petstore.tags; + +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.tags.Tag; + +/** + * Class with Tag Annotations at Class level + */ +@Tag(name = "Second Tag") +@Tag(name = "Fourth Tag Full", description = "desc class", externalDocs = @ExternalDocumentation(description = "docs desc class")) +@Tag(name = "Fifth Tag Full", description = "desc class", externalDocs = @ExternalDocumentation(description = "docs desc class")) +@Tag(name = "Sixth Tag") +public class TagClassResource { +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/TagMethodResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/TagMethodResource.java new file mode 100644 index 0000000000..c4c65f146c --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/TagMethodResource.java @@ -0,0 +1,19 @@ +package io.swagger.v3.plugins.gradle.petstore.tags; + +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.tags.Tag; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; + +public class TagMethodResource { + @GET + @Path("/tagsinmethod") + @Tag(name = "Third Tag") + @Tag(name = "Second Tag") + @Tag(name = "Fourth Tag Full", description = "desc", externalDocs = @ExternalDocumentation(description = "docs desc")) + public Response getTags() { + return Response.ok().entity("ok").build(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/TagOpenAPIDefinitionResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/TagOpenAPIDefinitionResource.java new file mode 100644 index 0000000000..0362a7fba5 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/TagOpenAPIDefinitionResource.java @@ -0,0 +1,14 @@ +package io.swagger.v3.plugins.gradle.petstore.tags; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.tags.Tag; + +/** + * Tag in the OpenAPIDefinition annotation + */ +@OpenAPIDefinition(tags = { + @Tag(name = "Definition First Tag"), + @Tag(name = "Definition Second Tag full", description = "desc definition") +}) +public class TagOpenAPIDefinitionResource { +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/TagOperationResource.java b/modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/TagOperationResource.java new file mode 100644 index 0000000000..58d67f1b1c --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/TagOperationResource.java @@ -0,0 +1,20 @@ +package io.swagger.v3.plugins.gradle.petstore.tags; + +import io.swagger.v3.oas.annotations.Operation; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; + +/** + * Resource with a Tag at Operation Level + */ +public class TagOperationResource { + + @GET + @Path("/tagoperation") + @Operation(tags = {"Example Tag", "Second Tag"}) + public Response getTags() { + return Response.ok().entity("ok").build(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/QueryResultBean.java b/modules/swagger-gradle-plugin/src/test/javatest/resources/QueryResultBean.java new file mode 100644 index 0000000000..4ce4ed7528 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/resources/QueryResultBean.java @@ -0,0 +1,43 @@ +/** + * Copyright 2016 SmartBear Software + *

      + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

      + * http://www.apache.org/licenses/LICENSE-2.0 + *

      + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugins.gradle.resources; + +import javax.ws.rs.QueryParam; + +public class QueryResultBean { + @QueryParam("skip") + private Integer skip; + + @QueryParam("limit") + private Integer limit; + + public Integer getSkip() { + return skip; + } + + public void setSkip(Integer skip) { + this.skip = skip; + } + + public Integer getLimit() { + return limit; + } + + public void setLimit(Integer limit) { + this.limit = limit; + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/data/PetData.java b/modules/swagger-gradle-plugin/src/test/javatest/resources/data/PetData.java new file mode 100644 index 0000000000..e221796180 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/resources/data/PetData.java @@ -0,0 +1,151 @@ +/** + * Copyright 2016 SmartBear Software + *

      + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

      + * http://www.apache.org/licenses/LICENSE-2.0 + *

      + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugins.gradle.resources.data; + +import io.swagger.v3.plugins.gradle.resources.model.Category; +import io.swagger.v3.plugins.gradle.resources.model.Pet; +import io.swagger.v3.plugins.gradle.resources.model.Tag; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +public class PetData { + static List pets = new ArrayList(); + static List categories = new ArrayList(); + + static { + categories.add(createCategory(1, "Dogs")); + categories.add(createCategory(2, "Cats")); + categories.add(createCategory(3, "Rabbits")); + categories.add(createCategory(4, "Lions")); + + pets.add(createPet(1, categories.get(1), "Cat 1", new String[]{ + "url1", "url2"}, new String[]{"tag1", "tag2"}, "available")); + pets.add(createPet(2, categories.get(1), "Cat 2", new String[]{ + "url1", "url2"}, new String[]{"tag2", "tag3"}, "available")); + pets.add(createPet(3, categories.get(1), "Cat 3", new String[]{ + "url1", "url2"}, new String[]{"tag3", "tag4"}, "pending")); + + pets.add(createPet(4, categories.get(0), "Dog 1", new String[]{ + "url1", "url2"}, new String[]{"tag1", "tag2"}, "available")); + pets.add(createPet(5, categories.get(0), "Dog 2", new String[]{ + "url1", "url2"}, new String[]{"tag2", "tag3"}, "sold")); + pets.add(createPet(6, categories.get(0), "Dog 3", new String[]{ + "url1", "url2"}, new String[]{"tag3", "tag4"}, "pending")); + + pets.add(createPet(7, categories.get(3), "Lion 1", new String[]{ + "url1", "url2"}, new String[]{"tag1", "tag2"}, "available")); + pets.add(createPet(8, categories.get(3), "Lion 2", new String[]{ + "url1", "url2"}, new String[]{"tag2", "tag3"}, "available")); + pets.add(createPet(9, categories.get(3), "Lion 3", new String[]{ + "url1", "url2"}, new String[]{"tag3", "tag4"}, "available")); + + pets.add(createPet(10, categories.get(2), "Rabbit 1", new String[]{ + "url1", "url2"}, new String[]{"tag3", "tag4"}, "available")); + } + + public Pet getPetById(long petId) { + for (Pet pet : pets) { + if (pet.getId() == petId) { + return pet; + } + } + return null; + } + + public List findPetByStatus(String status) { + String[] statues = status.split(","); + List result = new ArrayList(); + for (Pet pet : pets) { + for (String s : statues) { + if (s.equals(pet.getStatus())) { + result.add(pet); + } + } + } + return result; + } + + public List findPetByCategory(Category category) { + return pets.stream().filter(pet -> category.equals(pet.getCategory())).collect(Collectors.toList()); + } + + public List findPetByTags(String tags) { + String[] tagList = tags.split(","); + List result = new ArrayList(); + for (Pet pet : pets) { + if (null != pet.getTags()) { + for (Tag tag : pet.getTags()) { + for (String tagListString : tagList) { + if (tagListString.equals(tag.getName())) { + result.add(pet); + } + } + } + } + } + return result; + } + + public void addPet(Pet pet) { + if (pets.size() > 0) { + for (int i = pets.size() - 1; i >= 0; i--) { + if (pets.get(i).getId() == pet.getId()) { + pets.remove(i); + } + } + } + pets.add(pet); + } + + static Pet createPet(long id, Category cat, String name, String[] urls, + String[] tags, String status) { + Pet pet = new Pet(); + pet.setId(id); + pet.setCategory(cat); + pet.setName(name); + if (null != urls) { + List urlObjs = new ArrayList(); + for (String urlString : urls) { + urlObjs.add(urlString); + } + pet.setPhotoUrls(urlObjs); + } + List tagObjs = new ArrayList(); + int i = 0; + if (null != tags) { + for (String tagString : tags) { + i = i + 1; + Tag tag = new Tag(); + tag.setId(i); + tag.setName(tagString); + tagObjs.add(tag); + } + } + pet.setTags(tagObjs); + pet.setStatus(status); + return pet; + } + + static Category createCategory(long id, String name) { + Category category = new Category(); + category.setId(id); + category.setName(name); + return category; + } +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/data/UserData.java b/modules/swagger-gradle-plugin/src/test/javatest/resources/data/UserData.java new file mode 100644 index 0000000000..a23afc1ded --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/resources/data/UserData.java @@ -0,0 +1,98 @@ +/** + * Copyright 2016 SmartBear Software + *

      + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

      + * http://www.apache.org/licenses/LICENSE-2.0 + *

      + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugins.gradle.resources.data; + +import io.swagger.v3.plugins.gradle.resources.model.User; + +import java.util.ArrayList; +import java.util.List; + +public class UserData { + static List users = new ArrayList(); + + static { + users.add(createUser(1, "user1", "first name 1", "last name 1", + "email1@test.com", "123-456-7890", 1)); + users.add(createUser(2, "user2", "first name 2", "last name 2", + "email2@test.com", "123-456-7890", 2)); + users.add(createUser(3, "user3", "first name 3", "last name 3", + "email3@test.com", "123-456-7890", 3)); + users.add(createUser(4, "user4", "first name 4", "last name 4", + "email4@test.com", "123-456-7890", 1)); + users.add(createUser(5, "user5", "first name 5", "last name 5", + "email5@test.com", "123-456-7890", 2)); + users.add(createUser(6, "user6", "first name 6", "last name 6", + "email6@test.com", "123-456-7890", 3)); + users.add(createUser(7, "user7", "first name 7", "last name 7", + "email7@test.com", "123-456-7890", 1)); + users.add(createUser(8, "user8", "first name 8", "last name 8", + "email8@test.com", "123-456-7890", 2)); + users.add(createUser(9, "user9", "first name 9", "last name 9", + "email9@test.com", "123-456-7890", 3)); + users.add(createUser(10, "user10", "first name 10", "last name 10", + "email10@test.com", "123-456-7890", 1)); + users.add(createUser(11, "user?10", "first name ?10", "last name ?10", + "email101@test.com", "123-456-7890", 1)); + + } + + public User findUserByName(String username) { + for (User user : users) { + if (user.getUsername().equals(username)) { + return user; + } + } + return null; + } + + public void addUser(User user) { + if (users.size() > 0) { + for (int i = users.size() - 1; i >= 0; i--) { + if (users.get(i).getUsername().equals(user.getUsername())) { + users.remove(i); + } + } + } + users.add(user); + } + + public boolean removeUser(String username) { + if (users.size() > 0) { + for (int i = users.size() - 1; i >= 0; i--) { + if (users.get(i).getUsername().equals(username)) { + users.remove(i); + return true; + } + } + } + return false; + } + + private static User createUser(long id, String username, String firstName, + String lastName, String email, String phone, int userStatus) { + User user = new User(); + user.setId(id); + user.setUsername(username); + user.setFirstName(firstName); + user.setLastName(lastName); + user.setEmail(email); + user.setPassword("XXXXXXXXXXX"); + user.setPhone(phone); + user.setUserStatus(userStatus); + return user; + } +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/exception/ApiException.java b/modules/swagger-gradle-plugin/src/test/javatest/resources/exception/ApiException.java new file mode 100644 index 0000000000..5fd6be63d7 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/resources/exception/ApiException.java @@ -0,0 +1,26 @@ +/** + * Copyright 2016 SmartBear Software + *

      + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

      + * http://www.apache.org/licenses/LICENSE-2.0 + *

      + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugins.gradle.resources.exception; + +public class ApiException extends Exception { + private int code; + + public ApiException(int code, String msg) { + super(msg); + this.code = code; + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/exception/NotFoundException.java b/modules/swagger-gradle-plugin/src/test/javatest/resources/exception/NotFoundException.java new file mode 100644 index 0000000000..545e6a9940 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/resources/exception/NotFoundException.java @@ -0,0 +1,26 @@ +/** + * Copyright 2016 SmartBear Software + *

      + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

      + * http://www.apache.org/licenses/LICENSE-2.0 + *

      + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugins.gradle.resources.exception; + +public class NotFoundException extends ApiException { + private int code; + + public NotFoundException(int code, String msg) { + super(code, msg); + this.code = code; + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/model/Category.java b/modules/swagger-gradle-plugin/src/test/javatest/resources/model/Category.java new file mode 100644 index 0000000000..a973cb86d4 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/resources/model/Category.java @@ -0,0 +1,51 @@ +/** + * Copyright 2016 SmartBear Software + *

      + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

      + * http://www.apache.org/licenses/LICENSE-2.0 + *

      + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugins.gradle.resources.model; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "Category") +public class Category { + private long id; + private String name; + + @XmlElement(name = "id") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @XmlElement(name = "name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Category() { + } + + public Category(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/model/CustomGenerator.java b/modules/swagger-gradle-plugin/src/test/javatest/resources/model/CustomGenerator.java new file mode 100644 index 0000000000..c41bf37d3b --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/resources/model/CustomGenerator.java @@ -0,0 +1,32 @@ +package io.swagger.v3.plugins.gradle.resources.model; + +import com.fasterxml.jackson.annotation.ObjectIdGenerator; +import com.fasterxml.jackson.annotation.ObjectIdGenerators; + +public class CustomGenerator extends ObjectIdGenerators.PropertyGenerator { + private static final long serialVersionUID = 1L; + + protected CustomGenerator(Class scope) { + super(scope); + } + + @Override + public ObjectIdGenerator forScope(Class scope) { + return null; + } + + @Override + public ObjectIdGenerator newForSerialization(Object context) { + return null; + } + + @Override + public IdKey key(Object key) { + return null; + } + + @Override + public Object generateId(Object forPojo) { + return null; + } +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/model/ExtensionUser.java b/modules/swagger-gradle-plugin/src/test/javatest/resources/model/ExtensionUser.java new file mode 100644 index 0000000000..9615b3b170 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/resources/model/ExtensionUser.java @@ -0,0 +1,130 @@ +/** + * Copyright 2016 SmartBear Software + *

      + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

      + * http://www.apache.org/licenses/LICENSE-2.0 + *

      + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugins.gradle.resources.model; + +import io.swagger.v3.oas.annotations.extensions.Extension; +import io.swagger.v3.oas.annotations.extensions.ExtensionProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "User") +@Schema( + description = "User", + extensions = { + @Extension(name = "x-user", properties = { + @ExtensionProperty(name = "name", value = "Josh")}), + @Extension(name = "user-extensions", properties = { + @ExtensionProperty(name = "lastName", value = "Hart"), + @ExtensionProperty(name = "address", value = "House")}) + } +) +public class ExtensionUser { + private long id; + private String username; + private String firstName; + private String lastName; + private String email; + private String password; + private String phone; + private int userStatus; + + @XmlElement(name = "id") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @XmlElement(name = "firstName") + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + @XmlElement(name = "username") + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + @XmlElement(name = "lastName") + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + @XmlElement(name = "email") + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + @XmlElement(name = "password") + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @XmlElement(name = "phone") + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + @XmlElement(name = "userStatus") + //@Schema(description = "User Status", type = "string", allowableValues = {"1-registered", "2-active", "3-closed"}) + @Schema( + description = "User Status", + allowableValues = "1-registered,2-active,3-closed", + extensions = { + @Extension(name = "x-userStatus", properties = { + @ExtensionProperty(name = "name", value = "Josh")}), + @Extension(name = "userStatus-extensions", properties = { + @ExtensionProperty(name = "lastName", value = "Hart"), + @ExtensionProperty(name = "address", value = "House")}) + } + ) + public int getUserStatus() { + return userStatus; + } + + public void setUserStatus(int userStatus) { + this.userStatus = userStatus; + } +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/model/JacksonBean.java b/modules/swagger-gradle-plugin/src/test/javatest/resources/model/JacksonBean.java new file mode 100644 index 0000000000..6ab65aa81a --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/resources/model/JacksonBean.java @@ -0,0 +1,76 @@ +package io.swagger.v3.plugins.gradle.resources.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonUnwrapped; +import com.fasterxml.jackson.annotation.JsonValue; + +public class JacksonBean { + + private String id; + private String ignored; + private StringValueBean bean; + private NotFoundModel model; + private NotFoundModel model2; + + @JsonIgnore + public String getIgnored() { + return ignored; + } + + public void setIgnored(String ignored) { + this.ignored = ignored; + } + + public void setId(String id) { + this.id = id; + } + + public void setModel(NotFoundModel model) { + this.model = model; + } + + public StringValueBean getBean() { + return bean; + } + + public void setBean(StringValueBean bean) { + this.bean = bean; + } + + @JsonProperty("identity") + public String getId() { + return id; + } + + @JsonUnwrapped + public NotFoundModel getModel() { + return model; + } + + @JsonUnwrapped(prefix = "pre", suffix = "suf") + public NotFoundModel getModel2() { + return model2; + } + + public void setModel2(NotFoundModel model2) { + this.model2 = model2; + } + + public static class StringValueBean { + + private final String value; + + @JsonCreator + public StringValueBean(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + } + +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/model/ListOfStringsBeanParam.java b/modules/swagger-gradle-plugin/src/test/javatest/resources/model/ListOfStringsBeanParam.java new file mode 100644 index 0000000000..d002e3c4ff --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/resources/model/ListOfStringsBeanParam.java @@ -0,0 +1,17 @@ +package io.swagger.v3.plugins.gradle.resources.model; + +import javax.ws.rs.QueryParam; +import java.util.List; + +public class ListOfStringsBeanParam { + @QueryParam(value = "listOfStrings") + private List list; + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/model/ModelWithJsonIdentity.java b/modules/swagger-gradle-plugin/src/test/javatest/resources/model/ModelWithJsonIdentity.java new file mode 100644 index 0000000000..72470ea57f --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/resources/model/ModelWithJsonIdentity.java @@ -0,0 +1,145 @@ +package io.swagger.v3.plugins.gradle.resources.model; + +import com.fasterxml.jackson.annotation.JsonIdentityInfo; +import com.fasterxml.jackson.annotation.JsonIdentityReference; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.ObjectIdGenerators; + +public class ModelWithJsonIdentity { + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "name") + @JsonProperty("PropertyGeneratorAsId") + public SourceDefinition1 testPropertyGeneratorAsId; + + @JsonIdentityReference(alwaysAsId = false) + @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "name") + @JsonProperty("PropertyGeneratorAsProperty") + public SourceDefinition1 testPropertyGeneratorAsProperty; + + public class SourceDefinition1 { + public String driver; + public String name; + } + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "driverId") + @JsonProperty("ChangedPropertyName") + public SourceDefinition2 testChangedPropertyName; + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "driverId") + @JsonProperty("ChangedPropertyName2") + public SourceDefinition2 testChangedPropertyName2; + + static public class SourceDefinition2 { + @JsonProperty("driverId") + public String driver; + public String name; + } + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class) + @JsonProperty("SourceWithoutPropertyAsId") + public SourceDefinition3 testWithoutPropertyAsId; + + @JsonIdentityReference(alwaysAsId = false) + @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class) + @JsonProperty("SourceWithoutPropertyAsProperty") + public SourceDefinition3 testWithoutPropertyAsProperty; + + public class SourceDefinition3 { + @JsonProperty("driverId") + public String driver; + public String name; + + @JsonProperty("@id") + public String id; + } + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, property = "testName1") + @JsonProperty("IntSequenceGeneratorAsId") + public SourceDefinition4 testIntSequenceGeneratorAsId; + + @JsonIdentityReference(alwaysAsId = false) + @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, property = "testName2") + @JsonProperty("IntSequenceGeneratorAsProperty") + public SourceDefinition4 testIntSequenceGeneratorAsProperty; + + public class SourceDefinition4 { + public String name; + } + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class) + @JsonProperty("IntSequenceWithoutPropertyAsId") + public SourceDefinition5 testIntSequenceWithoutPropertyAsId; + + @JsonIdentityReference(alwaysAsId = false) + @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class) + @JsonProperty("IntSequenceWithoutPropertyAsProperty") + public SourceDefinition5 testIntSequenceWithoutPropertyAsProperty; + + public class SourceDefinition5 { + public String name; + } + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class, property = "UUID1") + @JsonProperty("UUIDGeneratorAsId") + public SourceDefinition6 testUUIDGeneratorAsId; + + @JsonIdentityReference(alwaysAsId = false) + @JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class, property = "UUID2") + @JsonProperty("UUIDGeneratorAsProperty") + public SourceDefinition6 testUUIDGeneratorAsProperty; + + public class SourceDefinition6 { + public String name; + } + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class) + @JsonProperty("UUIDGeneratorWithoutPropertyAsId") + public SourceDefinition7 testUUIDGeneratorWithoutPropertyAsId; + + @JsonIdentityReference(alwaysAsId = false) + @JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class) + @JsonProperty("UUIDGeneratorWithoutPropertyAsProperty") + public SourceDefinition7 testUUIDGeneratorWithoutPropertyAsProperty; + + public class SourceDefinition7 { + public String name; + } + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = ObjectIdGenerators.None.class, property = "testGeneratorsNone") + @JsonProperty("GeneratorsNone") + public SourceDefinition8 testGeneratorsNone; + + public class SourceDefinition8 { + @JsonProperty("driverId") + public String driver; + public String name; + } + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = CustomGenerator.class, property = "name") + @JsonProperty("CustomGenerator") + public SourceDefinition9 testCustomGenerator; + + public class SourceDefinition9 { + public String driver; + public String name; + } + + @JsonIdentityInfo(generator = CustomGenerator.class, property = "name") + @JsonProperty("WithoutJsonIdentityReference") + public SourceDefinition10 testWithoutJsonIdentityReference; + + public class SourceDefinition10 { + public String driver; + public String name; + } +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/model/ModelWithJsonIdentityCyclic.java b/modules/swagger-gradle-plugin/src/test/javatest/resources/model/ModelWithJsonIdentityCyclic.java new file mode 100644 index 0000000000..e20f5fcf95 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/resources/model/ModelWithJsonIdentityCyclic.java @@ -0,0 +1,29 @@ +package io.swagger.v3.plugins.gradle.resources.model; + +import com.fasterxml.jackson.annotation.JsonIdentityInfo; +import com.fasterxml.jackson.annotation.JsonIdentityReference; +import com.fasterxml.jackson.annotation.ObjectIdGenerators; + +import java.util.List; + +public class ModelWithJsonIdentityCyclic { + + public Long id; + + public List sourceDefinitions; + + @JsonIdentityInfo( + generator = ObjectIdGenerators.PropertyGenerator.class, + property = "name") + public static class SourceDefinition { + public String driver; + public String name; + + @JsonIdentityReference(alwaysAsId=true) + @JsonIdentityInfo( + generator = ObjectIdGenerators.PropertyGenerator.class, + property = "id") + public ModelWithJsonIdentityCyclic model; + } + +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/model/MultipleBaseBean.java b/modules/swagger-gradle-plugin/src/test/javatest/resources/model/MultipleBaseBean.java new file mode 100644 index 0000000000..0d5966fa1e --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/resources/model/MultipleBaseBean.java @@ -0,0 +1,11 @@ +package io.swagger.v3.plugins.gradle.resources.model; + +@io.swagger.v3.oas.annotations.media.Schema( + description = "MultipleBaseBean", + subTypes = { MultipleSub1Bean.class, MultipleSub2Bean.class } +) +public class MultipleBaseBean { + public String beanType; + public int a; + public String b; +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/model/MultipleSub1Bean.java b/modules/swagger-gradle-plugin/src/test/javatest/resources/model/MultipleSub1Bean.java new file mode 100644 index 0000000000..c1a03258d0 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/resources/model/MultipleSub1Bean.java @@ -0,0 +1,8 @@ +package io.swagger.v3.plugins.gradle.resources.model; + +@io.swagger.v3.oas.annotations.media.Schema( + description = "MultipleSub1Bean" +) +public class MultipleSub1Bean extends MultipleBaseBean { + public int c; +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/model/MultipleSub2Bean.java b/modules/swagger-gradle-plugin/src/test/javatest/resources/model/MultipleSub2Bean.java new file mode 100644 index 0000000000..763e5f0454 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/resources/model/MultipleSub2Bean.java @@ -0,0 +1,8 @@ +package io.swagger.v3.plugins.gradle.resources.model; + +@io.swagger.v3.oas.annotations.media.Schema( + description = "MultipleSub2Bean" +) +public class MultipleSub2Bean extends MultipleBaseBean { + public int d; +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/model/NotFoundModel.java b/modules/swagger-gradle-plugin/src/test/javatest/resources/model/NotFoundModel.java new file mode 100644 index 0000000000..73e0b3f95c --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/resources/model/NotFoundModel.java @@ -0,0 +1,30 @@ +package io.swagger.v3.plugins.gradle.resources.model; + +public class NotFoundModel { + int code; + String message; + + public NotFoundModel() { + } + + public NotFoundModel(int code, String message) { + this.code = code; + this.message = message; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/model/Pet.java b/modules/swagger-gradle-plugin/src/test/javatest/resources/model/Pet.java new file mode 100644 index 0000000000..0cf61e4857 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/resources/model/Pet.java @@ -0,0 +1,76 @@ +package io.swagger.v3.plugins.gradle.resources.model; + +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.List; + +@XmlRootElement(name = "Pet") +public class Pet { + private long id; + private Category category; + private String name; + private List photoUrls = new ArrayList(); + private List tags = new ArrayList(); + private String status; + + @XmlElement(name = "id") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @XmlElement(name = "category") + public Category getCategory() { + return category; + } + + public void setCategory(Category category) { + this.category = category; + } + + @XmlElement(name = "name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @XmlElementWrapper(name = "photoUrls") + @XmlElement(name = "photoUrl") + public List getPhotoUrls() { + return photoUrls; + } + + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + @XmlElementWrapper(name = "tags") + @XmlElement(name = "tag") + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + @XmlElement(name = "status") + @Schema(description = "pet status in the store", allowableValues = "available,pending,sold") + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/model/Tag.java b/modules/swagger-gradle-plugin/src/test/javatest/resources/model/Tag.java new file mode 100644 index 0000000000..107de03ebf --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/resources/model/Tag.java @@ -0,0 +1,44 @@ +/** + * Copyright 2016 SmartBear Software + *

      + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

      + * http://www.apache.org/licenses/LICENSE-2.0 + *

      + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugins.gradle.resources.model; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "Tag") +public class Tag { + private long id; + private String name; + + @XmlElement(name = "id") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @XmlElement(name = "name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/model/User.java b/modules/swagger-gradle-plugin/src/test/javatest/resources/model/User.java new file mode 100644 index 0000000000..ae67103476 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/resources/model/User.java @@ -0,0 +1,108 @@ +/** + * Copyright 2016 SmartBear Software + *

      + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

      + * http://www.apache.org/licenses/LICENSE-2.0 + *

      + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugins.gradle.resources.model; + +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "User") +public class User { + private long id; + private String username; + private String firstName; + private String lastName; + private String email; + private String password; + private String phone; + private int userStatus; + + @XmlElement(name = "id") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @XmlElement(name = "firstName") + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + @XmlElement(name = "username") + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + @XmlElement(name = "lastName") + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + @XmlElement(name = "email") + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + @XmlElement(name = "password") + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @XmlElement(name = "phone") + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + @XmlElement(name = "userStatus") + //@Schema(description = "User Status", type = "string", allowableValues = {"1-registered", "2-active", "3-closed"}) + @Schema(description = "User Status", allowableValues = "1-registered,2-active,3-closed") + public int getUserStatus() { + return userStatus; + } + + public void setUserStatus(int userStatus) { + this.userStatus = userStatus; + } +} \ No newline at end of file diff --git a/modules/swagger-jaxrs2/src/main/java/io/swagger/v3/jaxrs2/integration/SwaggerLoader.java b/modules/swagger-jaxrs2/src/main/java/io/swagger/v3/jaxrs2/integration/SwaggerLoader.java new file mode 100644 index 0000000000..1df77b0429 --- /dev/null +++ b/modules/swagger-jaxrs2/src/main/java/io/swagger/v3/jaxrs2/integration/SwaggerLoader.java @@ -0,0 +1,159 @@ +package io.swagger.v3.jaxrs2.integration; + +import io.swagger.v3.core.util.Json; +import io.swagger.v3.core.util.Yaml; +import io.swagger.v3.oas.integration.OpenApiConfigurationException; +import io.swagger.v3.oas.integration.SwaggerConfiguration; +import io.swagger.v3.oas.models.OpenAPI; +import org.apache.commons.lang3.StringUtils; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +public class SwaggerLoader { + + private String outputFormat; + + private String resourcePackages; + private String resourceClasses; + private String filterClass; + private String readerClass; + private String scannerClass; + private Boolean prettyPrint = false; + private Boolean readAllResources = Boolean.TRUE; + private String ignoredRoutes; + + public String getOutputFormat() { + return outputFormat; + } + + public void setOutputFormat(String outputFormat) { + this.outputFormat = outputFormat; + } + + public String getResourcePackages() { + return resourcePackages; + } + + public void setResourcePackages(String resourcePackages) { + this.resourcePackages = resourcePackages; + } + + public String getResourceClasses() { + return resourceClasses; + } + + public void setResourceClasses(String resourceClasses) { + this.resourceClasses = resourceClasses; + } + + public String getFilterClass() { + return filterClass; + } + + public void setFilterClass(String filterClass) { + this.filterClass = filterClass; + } + + public String getReaderClass() { + return readerClass; + } + + public void setReaderClass(String readerClass) { + this.readerClass = readerClass; + } + + public String getScannerClass() { + return scannerClass; + } + + public void setScannerClass(String scannerClass) { + this.scannerClass = scannerClass; + } + + public Boolean getPrettyPrint() { + return prettyPrint; + } + + public void setPrettyPrint(Boolean prettyPrint) { + this.prettyPrint = prettyPrint; + } + + public Boolean getReadAllResources() { + return readAllResources; + } + + public void setReadAllResources(Boolean readAllResources) { + this.readAllResources = readAllResources; + } + + public String getIgnoredRoutes() { + return ignoredRoutes; + } + + public void setIgnoredRoutes(String ignoredRoutes) { + this.ignoredRoutes = ignoredRoutes; + } + + public Map resolve() throws Exception{ + + Set ignoredRoutesSet = null; + if (StringUtils.isNotBlank(ignoredRoutes)) { + ignoredRoutesSet = new HashSet<>(Arrays.asList(ignoredRoutes.split(","))); + } + Set resourceClassesSet = null; + if (StringUtils.isNotBlank(resourceClasses)) { + resourceClassesSet = new HashSet<>(Arrays.asList(resourceClasses.split(","))); + } + Set resourcePackagesSet = null; + if (StringUtils.isNotBlank(resourcePackages)) { + resourcePackagesSet = new HashSet<>(Arrays.asList(resourcePackages.split(","))); + } + + SwaggerConfiguration config = new SwaggerConfiguration() + .filterClass(filterClass) + .ignoredRoutes(ignoredRoutesSet) + .prettyPrint(prettyPrint) + .readAllResources(readAllResources) + .readerClass(readerClass) + .scannerClass(scannerClass) + .resourceClasses(resourceClassesSet) + .resourcePackages(resourcePackagesSet); + try { + + OpenAPI openAPI = new JaxrsOpenApiContextBuilder() + .openApiConfiguration(config) + .buildContext(true) + .read(); + String openapiJson = null; + String openapiYaml = null; + if ("JSON".equals(outputFormat) || "JSONANDYAML".equals(outputFormat)) { + if (prettyPrint) { + openapiJson = Json.pretty(openAPI); + } else { + openapiJson = Json.mapper().writeValueAsString(openAPI); + } + } + if ("YAML".equals(outputFormat) || "JSONANDYAML".equals(outputFormat)) { + if (prettyPrint) { + openapiYaml = Yaml.pretty(openAPI); + } else { + openapiYaml = Yaml.mapper().writeValueAsString(openAPI); + } + + } + HashMap map = new HashMap(); + map.put("JSON", openapiJson); + map.put("YAML", openapiYaml); + return map; + } catch (OpenApiConfigurationException e) { + throw new Exception("Error resolving API specification: " + e.getMessage(), e); + } catch (Exception e) { + throw new Exception("Error resolving API specification: " + e.getMessage(), e); + } + + } +} diff --git a/modules/swagger-maven-plugin/README.md b/modules/swagger-maven-plugin/README.md new file mode 100644 index 0000000000..9a202bd475 --- /dev/null +++ b/modules/swagger-maven-plugin/README.md @@ -0,0 +1,77 @@ +# swagger-maven-plugin + +* Resolves project openAPI specification and saves the result in JSON, YAML or both formats. +All parameters except `outputFileName`, `outputFormat` `skip` and `outputPath` correspond +to `swagger` [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties) with same name. + +## Configuration example + + +```xml + + + + + io.swagger.core.v3 + swagger-maven-plugin + 2.0.5-SNAPSHOT + + openapi + ${project.build.directory}/generatedtest + JSONANDYAML + + test.petstore + + TRUE + + + + compile + + resolve + + + + + + + + + io.swagger.core.v3 + swagger-jaxrs2 + 2.0.5-SNAPSHOT + + + + javax.ws.rs + javax.ws.rs-api + 2.1 + + + javax.servlet + javax.servlet-api + 3.1.0 + + + +``` + + +#### Parameters +Parameter | Description | Required | Default +--------- | ----------- | --------- | ------- +`outputPath`|output path where file(s) are saved|true| +`outputFileName`|file name (no extension)|false|`openapi` +`outputFormat`|file format (`JSON`, `YAML`, `JSONANDYAML`|false|`JSON` +`skip`|if `TRUE` skip execution|false|`FALSE` +`resourcePackages`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| +`resourceClasses`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| +`prettyPrint`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false|`TRUE` +`filterClass`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| +`readerClass`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| +`scannerClass`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| +`readAllResources`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| +`ignoredRoutes`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| + +*** + diff --git a/modules/swagger-maven-plugin/pom.xml b/modules/swagger-maven-plugin/pom.xml index c26880d610..bec60ac7bc 100644 --- a/modules/swagger-maven-plugin/pom.xml +++ b/modules/swagger-maven-plugin/pom.xml @@ -10,7 +10,7 @@ 4.0.0 swagger-maven-plugin maven-plugin - swagger-maven.plugin + swagger-maven-plugin diff --git a/modules/swagger-maven-plugin/src/main/java/io/swagger/v3/plugin/maven/SwaggerMojo.java b/modules/swagger-maven-plugin/src/main/java/io/swagger/v3/plugin/maven/SwaggerMojo.java index 8bc20d902d..0a5851a32d 100644 --- a/modules/swagger-maven-plugin/src/main/java/io/swagger/v3/plugin/maven/SwaggerMojo.java +++ b/modules/swagger-maven-plugin/src/main/java/io/swagger/v3/plugin/maven/SwaggerMojo.java @@ -107,7 +107,7 @@ public void execute() throws MojoExecutionException, MojoFailureException private String outputPath; @Parameter( property = "resolve.outputFormat", defaultValue = "JSON") - private Format outputFormat; + private Format outputFormat = Format.JSON; @Parameter( property = "resolve.resourcePackages" ) private Set resourcePackages; @@ -120,7 +120,7 @@ public void execute() throws MojoExecutionException, MojoFailureException @Parameter( property = "resolve.scannerClass" ) private String scannerClass; @Parameter( property = "resolve.prettyPrint" ) - private Boolean prettyPrint; + private Boolean prettyPrint = false; @Parameter( property = "resolve.readAllResources" ) private Boolean readAllResources = Boolean.TRUE; @Parameter( property = "resolve.ignoredRoutes" ) From d758d2a634cef3a19213513c343407593c005e99 Mon Sep 17 00:00:00 2001 From: frantuma Date: Fri, 14 Sep 2018 12:41:08 +0200 Subject: [PATCH 3/7] input openapi support in swagger-maven-plugin --- modules/swagger-gradle-plugin/README.md | 1 + modules/swagger-maven-plugin/README.md | 1 + .../swagger/v3/plugin/maven/SwaggerMojo.java | 34 ++++++++++++++ .../v3/plugin/maven/SwaggerResolveTest.java | 2 + .../OpenAPIDefinitionResource.java | 5 +- .../operation/ServerOperationResource.java | 6 --- .../src/test/resources/openapiinput.yaml | 17 +++++++ .../src/test/resources/pom.resolveToFile.xml | 1 + ...pom.resolveToFileAndUploadToSwaggerhub.xml | 47 ------------------- .../pom.resolveToFileJsonAndYaml.xml | 1 + .../resources/pom.resolveToFileNoName.xml | 1 + 11 files changed, 61 insertions(+), 55 deletions(-) create mode 100644 modules/swagger-maven-plugin/src/test/resources/openapiinput.yaml delete mode 100644 modules/swagger-maven-plugin/src/test/resources/pom.resolveToFileAndUploadToSwaggerhub.xml diff --git a/modules/swagger-gradle-plugin/README.md b/modules/swagger-gradle-plugin/README.md index d940aee681..2f90a06881 100644 --- a/modules/swagger-gradle-plugin/README.md +++ b/modules/swagger-gradle-plugin/README.md @@ -57,6 +57,7 @@ Parameter | Description | Required | Default `resourcePackages`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| `resourceClasses`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| `prettyPrint`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false|`TRUE` +`openapiFilePath`|path to openapi file to be merged with resolved specification, see [config](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| `filterClass`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| `readerClass`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| `scannerClass`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| diff --git a/modules/swagger-maven-plugin/README.md b/modules/swagger-maven-plugin/README.md index 9a202bd475..d2f88432da 100644 --- a/modules/swagger-maven-plugin/README.md +++ b/modules/swagger-maven-plugin/README.md @@ -67,6 +67,7 @@ Parameter | Description | Required | Default `resourcePackages`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| `resourceClasses`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| `prettyPrint`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false|`TRUE` +`openapiFilePath`|path to openapi file to be merged with resolved specification, see [config](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| `filterClass`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| `readerClass`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| `scannerClass`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| diff --git a/modules/swagger-maven-plugin/src/main/java/io/swagger/v3/plugin/maven/SwaggerMojo.java b/modules/swagger-maven-plugin/src/main/java/io/swagger/v3/plugin/maven/SwaggerMojo.java index 0a5851a32d..3c5f0c52cb 100644 --- a/modules/swagger-maven-plugin/src/main/java/io/swagger/v3/plugin/maven/SwaggerMojo.java +++ b/modules/swagger-maven-plugin/src/main/java/io/swagger/v3/plugin/maven/SwaggerMojo.java @@ -13,6 +13,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; +import org.codehaus.plexus.util.StringUtils; import java.io.File; import java.io.IOException; @@ -41,6 +42,32 @@ public void execute() throws MojoExecutionException, MojoFailureException return; } getLog().info( "Resolving OpenAPI specification.." ); + + OpenAPI openAPIInput = null; + try { + if (StringUtils.isNotBlank(openapiFilePath)) { + Path openapiPath = Paths.get(openapiFilePath); + if (openapiPath.toFile().exists() && openapiPath.toFile().isFile()) { + String openapiFileContent = new String(Files.readAllBytes(openapiPath), "UTF-8"); + if (StringUtils.isNotBlank(openapiFileContent)) { + try { + openAPIInput = Json.mapper().readValue(openapiFileContent, OpenAPI.class); + } catch (Exception e) { + try { + openAPIInput = Yaml.mapper().readValue(openapiFileContent, OpenAPI.class); + } catch (Exception e1) { + getLog().error( "Error reading/deserializing openapi file" , e); + throw new MojoFailureException(e.getMessage(), e); + } + } + } + } + } + } catch (Exception e) { + getLog().error( "Error reading/deserializing openapi file" , e); + throw new MojoFailureException(e.getMessage(), e); + } + SwaggerConfiguration config = new SwaggerConfiguration() .filterClass(filterClass) .ignoredRoutes(ignoredRoutes) @@ -49,6 +76,7 @@ public void execute() throws MojoExecutionException, MojoFailureException .readerClass(readerClass) .scannerClass(scannerClass) .resourceClasses(resourceClasses) + .openAPI(openAPIInput) .resourcePackages(resourcePackages); try { OpenAPI openAPI = new JaxrsOpenApiContextBuilder() @@ -129,8 +157,14 @@ public void execute() throws MojoExecutionException, MojoFailureException @Parameter( property = "resolve.skip" ) private Boolean skip = Boolean.FALSE; + @Parameter( property = "resolve.openapiFilePath") + private String openapiFilePath; + public String getOutputPath() { return outputPath; } + public String getOpenapiFilePath() { + return openapiFilePath; + } } diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/SwaggerResolveTest.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/SwaggerResolveTest.java index 694eba0751..74af1d47ab 100644 --- a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/SwaggerResolveTest.java +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/SwaggerResolveTest.java @@ -64,6 +64,7 @@ private void runTest(File pom) throws Exception { final OpenAPI openAPI; openAPI = Yaml.mapper().readValue(content, OpenAPI.class); assertNotNull(openAPI); + assertEquals(openAPI.getServers().get(0).getVariables().size(), 2); } if (format.toLowerCase().equals("json") || format.toLowerCase().equals("jsonandyaml")) { Path path = Paths.get(outputPath, outputFile + ".json"); @@ -73,6 +74,7 @@ private void runTest(File pom) throws Exception { final OpenAPI openAPI; openAPI = Json.mapper().readValue(content, OpenAPI.class); assertNotNull(openAPI); + assertEquals(openAPI.getServers().get(0).getVariables().size(), 2); } } diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/openapidefintion/OpenAPIDefinitionResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/openapidefintion/OpenAPIDefinitionResource.java index 01a3c58835..a6a2b6604e 100644 --- a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/openapidefintion/OpenAPIDefinitionResource.java +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/openapidefintion/OpenAPIDefinitionResource.java @@ -31,7 +31,8 @@ security = { @SecurityRequirement(name = "req 1", scopes = {"a", "b"}), @SecurityRequirement(name = "req 2", scopes = {"b", "c"}) - }, + } +/* , servers = { @Server( description = "server 1", @@ -40,7 +41,7 @@ @ServerVariable(name = "var1", description = "var 1", defaultValue = "1", allowableValues = {"1", "2"}), @ServerVariable(name = "var2", description = "var 2", defaultValue = "1", allowableValues = {"1", "2"}) }) - } + }*/ ) public class OpenAPIDefinitionResource { public void foo() { diff --git a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/ServerOperationResource.java b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/ServerOperationResource.java index 99062aa245..1299bcaf8a 100644 --- a/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/ServerOperationResource.java +++ b/modules/swagger-maven-plugin/src/test/java/io/swagger/v3/plugin/maven/petstore/petstore/operation/ServerOperationResource.java @@ -1,7 +1,6 @@ package io.swagger.v3.plugin.maven.petstore.petstore.operation; import io.swagger.v3.plugin.maven.resources.model.Pet; -import io.swagger.v3.oas.annotations.OpenAPIDefinition; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.servers.Server; @@ -11,11 +10,6 @@ /** * Resource With a Hidden Operation */ -@OpenAPIDefinition( - servers = { - @Server(description = "server 1", url = "http://foo") - } -) public class ServerOperationResource { @Path("/serversoperation") @GET diff --git a/modules/swagger-maven-plugin/src/test/resources/openapiinput.yaml b/modules/swagger-maven-plugin/src/test/resources/openapiinput.yaml new file mode 100644 index 0000000000..126a36d76b --- /dev/null +++ b/modules/swagger-maven-plugin/src/test/resources/openapiinput.yaml @@ -0,0 +1,17 @@ +openapi: 3.0.1 +servers: +- url: http://foo + description: server 1 + variables: + var1: + description: var 1 + enum: + - "1" + - "2" + default: "1" + var2: + description: var 2 + enum: + - "1" + - "2" + default: "1" \ No newline at end of file diff --git a/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFile.xml b/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFile.xml index a77e5bee14..329e7229cf 100644 --- a/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFile.xml +++ b/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFile.xml @@ -15,6 +15,7 @@ spec ${project.basedir}/../../../target/generatedtest + ${project.basedir}/../../../src/test/resources/openapiinput.yaml YAML io.swagger.v3.plugin.maven.petstore.petstore diff --git a/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFileAndUploadToSwaggerhub.xml b/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFileAndUploadToSwaggerhub.xml deleted file mode 100644 index 95dac9a33f..0000000000 --- a/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFileAndUploadToSwaggerhub.xml +++ /dev/null @@ -1,47 +0,0 @@ - - 4.0.0 - io.swagger.core.v3 - swagger-maven-plugin-test - jar - 1.0-SNAPSHOT - Test Resolve YAML - - - - - io.swagger.core.v3 - swagger-maven-plugin - - openapi - ${project.basedir}/../../../target/generatedtest - YAML - - io.swagger.v3.plugin.maven.petstore.petstore - - TRUE - - - - - - - - io.swagger.core.v3 - swagger-jaxrs2 - ${project.version} - - - - javax.ws.rs - javax.ws.rs-api - 2.1 - - - javax.servlet - javax.servlet-api - 3.1 - - - - \ No newline at end of file diff --git a/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFileJsonAndYaml.xml b/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFileJsonAndYaml.xml index 84897bb8b7..364744242b 100644 --- a/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFileJsonAndYaml.xml +++ b/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFileJsonAndYaml.xml @@ -15,6 +15,7 @@ openapi ${project.basedir}/../../../target/generatedtest + ${project.basedir}/../../../src/test/resources/openapiinput.yaml JSONANDYAML io.swagger.v3.plugin.maven.petstore.petstore diff --git a/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFileNoName.xml b/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFileNoName.xml index e54176e2d6..b0d6b15288 100644 --- a/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFileNoName.xml +++ b/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFileNoName.xml @@ -14,6 +14,7 @@ swagger-maven-plugin ${project.basedir}/../../../target/generatedtest + ${project.basedir}/../../../src/test/resources/openapiinput.yaml YAML io.swagger.v3.plugin.maven.petstore.petstore From 06ff090fdeb9204ac02b9a3485063c34408e2a14 Mon Sep 17 00:00:00 2001 From: frantuma Date: Fri, 14 Sep 2018 14:38:33 +0200 Subject: [PATCH 4/7] input openapi support in swagger-gradle-plugin --- modules/swagger-gradle-plugin/README.md | 2 +- .../v3/plugins/gradle/tasks/ResolveTask.java | 22 +++ .../v3/plugins/gradle/SwaggerResolveTest.java | 24 ++- .../gradle}/petstore/EmptyPetResource.java | 0 .../plugins/gradle}/petstore/PetResource.java | 0 .../callback/ComplexCallbackResource.java | 0 ...pleCallbacksTestWithOperationResource.java | 0 .../callback/RepeatableCallbackResource.java | 0 .../SimpleCallbackWithOperationResource.java | 0 .../petstore/example/ExamplesResource.java | 0 .../example/SubscriptionResponse.java | 0 .../gradle}/petstore/link/LinksResource.java | 0 .../OpenAPIDefinitionResource.java | 12 +- .../AnnotatedSameNameOperationResource.java | 0 .../ExternalDocumentationResource.java | 0 .../FullyAnnotatedOperationResource.java | 0 .../operation/HiddenOperationResource.java | 0 .../petstore/operation/InterfaceResource.java | 0 ...NotAnnotatedSameNameOperationResource.java | 0 .../petstore/operation/OperationResource.java | 0 .../OperationWithoutAnnotationResource.java | 0 .../operation/ServerOperationResource.java | 5 - .../petstore/operation/SubResource.java | 0 .../parameter/ArraySchemaResource.java | 0 .../parameter/ComplexParameterResource.java | 0 ...ComplexParameterWithOperationResource.java | 0 .../MultipleNotAnnotatedParameter.java | 0 .../OpenAPIJaxRSAnnotatedParameter.java | 0 ...APIWithContentJaxRSAnnotatedParameter.java | 0 ...ImplementationJaxRSAnnotatedParameter.java | 0 .../parameter/ParametersResource.java | 87 +++++++++ .../RepeatableParametersResource.java | 0 .../SingleJaxRSAnnotatedParameter.java | 0 .../SingleNotAnnotatedParameter.java | 0 .../RequestBodyMethodPriorityResource.java | 0 .../RequestBodyParameterPriorityResource.java | 0 .../requestbody/RequestBodyResource.java | 0 .../responses/ComplexResponseResource.java | 0 .../ImplementationResponseResource.java | 71 ++++++++ .../responses/MethodResponseResource.java | 0 .../NoImplementationResponseResource.java | 66 +++++++ .../responses/NoResponseResource.java | 0 .../responses/OperationResponseResource.java | 0 .../responses/PriorityResponseResource.java | 0 .../petstore/security/SecurityResource.java | 0 .../petstore/tags/CompleteTagResource.java | 0 .../petstore/tags/TagClassResource.java | 0 .../petstore/tags/TagMethodResource.java | 0 .../tags/TagOpenAPIDefinitionResource.java | 0 .../petstore/tags/TagOperationResource.java | 0 .../gradle}/resources/QueryResultBean.java | 0 .../gradle}/resources/data/PetData.java | 0 .../gradle}/resources/data/UserData.java | 0 .../resources/exception/ApiException.java | 0 .../exception/NotFoundException.java | 0 .../gradle}/resources/model/Category.java | 0 .../resources/model/CustomGenerator.java | 0 .../resources/model/ExtensionUser.java | 0 .../gradle}/resources/model/JacksonBean.java | 0 .../model/ListOfStringsBeanParam.java | 0 .../model/ModelWithJsonIdentity.java | 0 .../model/ModelWithJsonIdentityCyclic.java | 0 .../resources/model/MultipleBaseBean.java | 0 .../resources/model/MultipleSub1Bean.java | 0 .../resources/model/MultipleSub2Bean.java | 0 .../resources/model/NotFoundModel.java | 0 .../plugins/gradle}/resources/model/Pet.java | 0 .../plugins/gradle}/resources/model/Tag.java | 0 .../plugins/gradle}/resources/model/User.java | 0 .../gradle/petstore/EmptyPetResource.java | 7 + .../plugins/gradle/petstore/PetResource.java | 165 ++++++++++++++++++ .../callback/ComplexCallbackResource.java | 62 +++++++ ...pleCallbacksTestWithOperationResource.java | 45 +++++ .../callback/RepeatableCallbackResource.java | 46 +++++ .../SimpleCallbackWithOperationResource.java | 44 +++++ .../petstore/example/ExamplesResource.java | 69 ++++++++ .../example/SubscriptionResponse.java | 5 + .../gradle/petstore/link/LinksResource.java | 44 +++++ .../OpenAPIDefinitionResource.java | 38 ++++ .../AnnotatedSameNameOperationResource.java | 26 +++ .../ExternalDocumentationResource.java | 30 ++++ .../FullyAnnotatedOperationResource.java | 38 ++++ .../operation/HiddenOperationResource.java | 29 +++ .../petstore/operation/InterfaceResource.java | 22 +++ ...NotAnnotatedSameNameOperationResource.java | 21 +++ .../petstore/operation/OperationResource.java | 77 ++++++++ .../OperationWithoutAnnotationResource.java | 15 ++ .../operation/ServerOperationResource.java | 25 +++ .../petstore/operation/SubResource.java | 20 +++ .../parameter/ArraySchemaResource.java | 44 +++++ .../parameter/ComplexParameterResource.java | 33 ++++ ...ComplexParameterWithOperationResource.java | 37 ++++ .../MultipleNotAnnotatedParameter.java | 18 ++ .../OpenAPIJaxRSAnnotatedParameter.java | 21 +++ ...APIWithContentJaxRSAnnotatedParameter.java | 25 +++ ...ImplementationJaxRSAnnotatedParameter.java | 23 +++ .../parameter/ParametersResource.java | 0 .../RepeatableParametersResource.java | 80 +++++++++ .../SingleJaxRSAnnotatedParameter.java | 20 +++ .../SingleNotAnnotatedParameter.java | 19 ++ .../RequestBodyMethodPriorityResource.java | 28 +++ .../RequestBodyParameterPriorityResource.java | 29 +++ .../requestbody/RequestBodyResource.java | 113 ++++++++++++ .../responses/ComplexResponseResource.java | 34 ++++ .../ImplementationResponseResource.java | 0 .../responses/MethodResponseResource.java | 24 +++ .../NoImplementationResponseResource.java | 0 .../responses/NoResponseResource.java | 21 +++ .../responses/OperationResponseResource.java | 25 +++ .../responses/PriorityResponseResource.java | 25 +++ .../petstore/security/SecurityResource.java | 61 +++++++ .../petstore/tags/CompleteTagResource.java | 31 ++++ .../petstore/tags/TagClassResource.java | 14 ++ .../petstore/tags/TagMethodResource.java | 19 ++ .../tags/TagOpenAPIDefinitionResource.java | 14 ++ .../petstore/tags/TagOperationResource.java | 20 +++ .../gradle/resources/QueryResultBean.java | 43 +++++ .../gradle/resources/data/PetData.java | 151 ++++++++++++++++ .../gradle/resources/data/UserData.java | 98 +++++++++++ .../resources/exception/ApiException.java | 26 +++ .../exception/NotFoundException.java | 26 +++ .../gradle/resources/model/Category.java | 51 ++++++ .../resources/model/CustomGenerator.java | 32 ++++ .../gradle/resources/model/ExtensionUser.java | 130 ++++++++++++++ .../gradle/resources/model/JacksonBean.java | 76 ++++++++ .../model/ListOfStringsBeanParam.java | 17 ++ .../model/ModelWithJsonIdentity.java | 145 +++++++++++++++ .../model/ModelWithJsonIdentityCyclic.java | 29 +++ .../resources/model/MultipleBaseBean.java | 11 ++ .../resources/model/MultipleSub1Bean.java | 8 + .../resources/model/MultipleSub2Bean.java | 8 + .../gradle/resources/model/NotFoundModel.java | 30 ++++ .../plugins/gradle/resources/model/Pet.java | 76 ++++++++ .../plugins/gradle/resources/model/Tag.java | 44 +++++ .../plugins/gradle/resources/model/User.java | 108 ++++++++++++ .../v3/jaxrs2/integration/SwaggerLoader.java | 26 ++- 136 files changed, 3010 insertions(+), 20 deletions(-) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/EmptyPetResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/PetResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/callback/ComplexCallbackResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/callback/MultipleCallbacksTestWithOperationResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/callback/RepeatableCallbackResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/callback/SimpleCallbackWithOperationResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/example/ExamplesResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/example/SubscriptionResponse.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/link/LinksResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/openapidefintion/OpenAPIDefinitionResource.java (77%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/operation/AnnotatedSameNameOperationResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/operation/ExternalDocumentationResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/operation/FullyAnnotatedOperationResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/operation/HiddenOperationResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/operation/InterfaceResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/operation/NotAnnotatedSameNameOperationResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/operation/OperationResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/operation/OperationWithoutAnnotationResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/operation/ServerOperationResource.java (85%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/operation/SubResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/parameter/ArraySchemaResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/parameter/ComplexParameterResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/parameter/ComplexParameterWithOperationResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/parameter/MultipleNotAnnotatedParameter.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/parameter/OpenAPIJaxRSAnnotatedParameter.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/parameter/OpenAPIWithContentJaxRSAnnotatedParameter.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/parameter/OpenAPIWithImplementationJaxRSAnnotatedParameter.java (100%) create mode 100644 modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/parameter/ParametersResource.java rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/parameter/RepeatableParametersResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/parameter/SingleJaxRSAnnotatedParameter.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/parameter/SingleNotAnnotatedParameter.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/requestbody/RequestBodyMethodPriorityResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/requestbody/RequestBodyParameterPriorityResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/requestbody/RequestBodyResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/responses/ComplexResponseResource.java (100%) create mode 100644 modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/responses/ImplementationResponseResource.java rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/responses/MethodResponseResource.java (100%) create mode 100644 modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/responses/NoImplementationResponseResource.java rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/responses/NoResponseResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/responses/OperationResponseResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/responses/PriorityResponseResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/security/SecurityResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/tags/CompleteTagResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/tags/TagClassResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/tags/TagMethodResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/tags/TagOpenAPIDefinitionResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/petstore/tags/TagOperationResource.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/resources/QueryResultBean.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/resources/data/PetData.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/resources/data/UserData.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/resources/exception/ApiException.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/resources/exception/NotFoundException.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/resources/model/Category.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/resources/model/CustomGenerator.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/resources/model/ExtensionUser.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/resources/model/JacksonBean.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/resources/model/ListOfStringsBeanParam.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/resources/model/ModelWithJsonIdentity.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/resources/model/ModelWithJsonIdentityCyclic.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/resources/model/MultipleBaseBean.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/resources/model/MultipleSub1Bean.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/resources/model/MultipleSub2Bean.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/resources/model/NotFoundModel.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/resources/model/Pet.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/resources/model/Tag.java (100%) rename modules/swagger-gradle-plugin/src/test/{javatest => java/io/swagger/v3/plugins/gradle}/resources/model/User.java (100%) create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/EmptyPetResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/PetResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/callback/ComplexCallbackResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/callback/MultipleCallbacksTestWithOperationResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/callback/RepeatableCallbackResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/callback/SimpleCallbackWithOperationResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/example/ExamplesResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/example/SubscriptionResponse.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/link/LinksResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/openapidefintion/OpenAPIDefinitionResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/AnnotatedSameNameOperationResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/ExternalDocumentationResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/FullyAnnotatedOperationResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/HiddenOperationResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/InterfaceResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/NotAnnotatedSameNameOperationResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/OperationResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/OperationWithoutAnnotationResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/ServerOperationResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/SubResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/ArraySchemaResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/ComplexParameterResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/ComplexParameterWithOperationResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/MultipleNotAnnotatedParameter.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/OpenAPIJaxRSAnnotatedParameter.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/OpenAPIWithContentJaxRSAnnotatedParameter.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/OpenAPIWithImplementationJaxRSAnnotatedParameter.java rename modules/swagger-gradle-plugin/src/test/javatest/{ => io/swagger/v3/plugins/gradle}/petstore/parameter/ParametersResource.java (100%) create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/RepeatableParametersResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/SingleJaxRSAnnotatedParameter.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/SingleNotAnnotatedParameter.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/requestbody/RequestBodyMethodPriorityResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/requestbody/RequestBodyParameterPriorityResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/requestbody/RequestBodyResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/responses/ComplexResponseResource.java rename modules/swagger-gradle-plugin/src/test/javatest/{ => io/swagger/v3/plugins/gradle}/petstore/responses/ImplementationResponseResource.java (100%) create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/responses/MethodResponseResource.java rename modules/swagger-gradle-plugin/src/test/javatest/{ => io/swagger/v3/plugins/gradle}/petstore/responses/NoImplementationResponseResource.java (100%) create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/responses/NoResponseResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/responses/OperationResponseResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/responses/PriorityResponseResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/security/SecurityResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/tags/CompleteTagResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/tags/TagClassResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/tags/TagMethodResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/tags/TagOpenAPIDefinitionResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/tags/TagOperationResource.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/QueryResultBean.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/data/PetData.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/data/UserData.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/exception/ApiException.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/exception/NotFoundException.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/Category.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/CustomGenerator.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/ExtensionUser.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/JacksonBean.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/ListOfStringsBeanParam.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/ModelWithJsonIdentity.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/ModelWithJsonIdentityCyclic.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/MultipleBaseBean.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/MultipleSub1Bean.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/MultipleSub2Bean.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/NotFoundModel.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/Pet.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/Tag.java create mode 100644 modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/User.java diff --git a/modules/swagger-gradle-plugin/README.md b/modules/swagger-gradle-plugin/README.md index 2f90a06881..5591d2adf9 100644 --- a/modules/swagger-gradle-plugin/README.md +++ b/modules/swagger-gradle-plugin/README.md @@ -57,7 +57,7 @@ Parameter | Description | Required | Default `resourcePackages`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| `resourceClasses`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| `prettyPrint`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false|`TRUE` -`openapiFilePath`|path to openapi file to be merged with resolved specification, see [config](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| +`openApiFile`|openapi file to be merged with resolved specification, see [config](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| `filterClass`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| `readerClass`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| `scannerClass`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| diff --git a/modules/swagger-gradle-plugin/src/main/java/io/swagger/v3/plugins/gradle/tasks/ResolveTask.java b/modules/swagger-gradle-plugin/src/main/java/io/swagger/v3/plugins/gradle/tasks/ResolveTask.java index bbd91d8caf..62007c4c5d 100644 --- a/modules/swagger-gradle-plugin/src/main/java/io/swagger/v3/plugins/gradle/tasks/ResolveTask.java +++ b/modules/swagger-gradle-plugin/src/main/java/io/swagger/v3/plugins/gradle/tasks/ResolveTask.java @@ -6,6 +6,7 @@ import org.gradle.api.logging.Logging; import org.gradle.api.tasks.Classpath; import org.gradle.api.tasks.Input; +import org.gradle.api.tasks.InputFile; import org.gradle.api.tasks.InputFiles; import org.gradle.api.tasks.Optional; import org.gradle.api.tasks.OutputDirectory; @@ -38,6 +39,7 @@ public enum Format {JSON, YAML, JSONANDYAML}; private String outputPath; private File outputDir; + private File openApiFile; private Format outputFormat = Format.JSON; @@ -60,6 +62,16 @@ public String getOutputFileName() { return outputFileName; } + @InputFile + @Optional + public File getOpenApiFile() { + return openApiFile; + } + + public void setOpenApiFile(File openApiFile) { + this.openApiFile = openApiFile; + } + @Classpath @InputFiles public Iterable getClasspath() { @@ -246,6 +258,16 @@ public void resolve() throws GradleException { method=swaggerLoaderClass.getDeclaredMethod("setOutputFormat",String.class); method.invoke(swaggerLoader, outputFormat.name()); + if (openApiFile != null) { + if (openApiFile.exists() && openApiFile.isFile()) { + String openapiFileContent = new String(Files.readAllBytes(openApiFile.toPath()), "UTF-8"); + if (StringUtils.isNotBlank(openapiFileContent)) { + method=swaggerLoaderClass.getDeclaredMethod("setOpenapiAsString",String.class); + method.invoke(swaggerLoader, openapiFileContent); + } + } + } + if (resourcePackages != null && !resourcePackages.isEmpty()) { method=swaggerLoaderClass.getDeclaredMethod("setResourcePackages",String.class); method.invoke(swaggerLoader, resourcePackages.stream().map(Object::toString).collect(Collectors.joining(","))); diff --git a/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/SwaggerResolveTest.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/SwaggerResolveTest.java index a1a8f374de..2704869496 100644 --- a/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/SwaggerResolveTest.java +++ b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/SwaggerResolveTest.java @@ -21,19 +21,38 @@ public class SwaggerResolveTest { @Rule public final TemporaryFolder testProjectDir = new TemporaryFolder(); private File buildFile; + private File openapiInputFile; private String outputFile; private String outputDir; @Before public void setup() throws IOException { buildFile = testProjectDir.newFile("build.gradle"); + openapiInputFile = testProjectDir.newFile("openapiinput.yaml"); + writeFile(openapiInputFile, "openapi: 3.0.1\n" + + "servers:\n" + + "- url: http://foo\n" + + " description: server 1\n" + + " variables:\n" + + " var1:\n" + + " description: var 1\n" + + " enum:\n" + + " - \"1\"\n" + + " - \"2\"\n" + + " default: \"2\"\n" + + " var2:\n" + + " description: var 2\n" + + " enum:\n" + + " - \"1\"\n" + + " - \"2\"\n" + + " default: \"2\""); } @Test public void testSwaggerResolveTask() throws IOException { outputDir = testProjectDir.getRoot().toString() + "/target"; outputFile = testProjectDir.getRoot().toString() + "/testAPI.json"; - //outputDir = "/tmp/a/target"; + outputDir = "/tmp/a/target"; String resolveTask = "resolve"; String buildFileContent = @@ -50,7 +69,7 @@ public void testSwaggerResolveTask() throws IOException { "sourceSets {\n" + " test {\n" + " java {\n" + - " srcDirs = ['/dati/dev/progetti/swagger/projects/swagger-core/modules/swagger-gradle-plugin/src/test/javatest']\n" + + " srcDirs = ['" + new File("src/test/javatest").getAbsolutePath() + "']\n" + " }\n" + " }\n" + "}\n" + @@ -78,6 +97,7 @@ public void testSwaggerResolveTask() throws IOException { " classpath = sourceSets.test.runtimeClasspath\n" + " resourcePackages = ['io.swagger.v3.plugins.gradle.petstore']\n" + " outputPath = \'" + outputDir + "\'\n" + + " openApiFile = file(\'" + openapiInputFile.getAbsolutePath() + "\')\n" + "}"; diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/EmptyPetResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/EmptyPetResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/EmptyPetResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/EmptyPetResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/PetResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/PetResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/PetResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/PetResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/callback/ComplexCallbackResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/callback/ComplexCallbackResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/callback/ComplexCallbackResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/callback/ComplexCallbackResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/callback/MultipleCallbacksTestWithOperationResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/callback/MultipleCallbacksTestWithOperationResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/callback/MultipleCallbacksTestWithOperationResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/callback/MultipleCallbacksTestWithOperationResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/callback/RepeatableCallbackResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/callback/RepeatableCallbackResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/callback/RepeatableCallbackResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/callback/RepeatableCallbackResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/callback/SimpleCallbackWithOperationResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/callback/SimpleCallbackWithOperationResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/callback/SimpleCallbackWithOperationResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/callback/SimpleCallbackWithOperationResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/example/ExamplesResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/example/ExamplesResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/example/ExamplesResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/example/ExamplesResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/example/SubscriptionResponse.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/example/SubscriptionResponse.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/example/SubscriptionResponse.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/example/SubscriptionResponse.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/link/LinksResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/link/LinksResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/link/LinksResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/link/LinksResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/openapidefintion/OpenAPIDefinitionResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/openapidefintion/OpenAPIDefinitionResource.java similarity index 77% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/openapidefintion/OpenAPIDefinitionResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/openapidefintion/OpenAPIDefinitionResource.java index 5e3e4f8c7b..5ac0c573fa 100644 --- a/modules/swagger-gradle-plugin/src/test/javatest/petstore/openapidefintion/OpenAPIDefinitionResource.java +++ b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/openapidefintion/OpenAPIDefinitionResource.java @@ -31,17 +31,7 @@ security = { @SecurityRequirement(name = "req 1", scopes = {"a", "b"}), @SecurityRequirement(name = "req 2", scopes = {"b", "c"}) - }, - servers = { - @Server( - description = "server 1", - url = "http://foo", - variables = { - @ServerVariable(name = "var1", description = "var 1", defaultValue = "1", allowableValues = {"1", "2"}), - @ServerVariable(name = "var2", description = "var 2", defaultValue = "1", allowableValues = {"1", "2"}) - }) - } -) + }) public class OpenAPIDefinitionResource { public void foo() { } diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/AnnotatedSameNameOperationResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/operation/AnnotatedSameNameOperationResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/AnnotatedSameNameOperationResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/operation/AnnotatedSameNameOperationResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/ExternalDocumentationResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/operation/ExternalDocumentationResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/ExternalDocumentationResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/operation/ExternalDocumentationResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/FullyAnnotatedOperationResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/operation/FullyAnnotatedOperationResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/FullyAnnotatedOperationResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/operation/FullyAnnotatedOperationResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/HiddenOperationResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/operation/HiddenOperationResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/HiddenOperationResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/operation/HiddenOperationResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/InterfaceResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/operation/InterfaceResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/InterfaceResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/operation/InterfaceResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/NotAnnotatedSameNameOperationResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/operation/NotAnnotatedSameNameOperationResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/NotAnnotatedSameNameOperationResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/operation/NotAnnotatedSameNameOperationResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/OperationResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/operation/OperationResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/OperationResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/operation/OperationResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/OperationWithoutAnnotationResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/operation/OperationWithoutAnnotationResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/OperationWithoutAnnotationResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/operation/OperationWithoutAnnotationResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/ServerOperationResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/operation/ServerOperationResource.java similarity index 85% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/ServerOperationResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/operation/ServerOperationResource.java index 955fc331d8..725fed837b 100644 --- a/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/ServerOperationResource.java +++ b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/operation/ServerOperationResource.java @@ -11,11 +11,6 @@ /** * Resource With a Hidden Operation */ -@OpenAPIDefinition( - servers = { - @Server(description = "server 1", url = "http://foo") - } -) public class ServerOperationResource { @Path("/serversoperation") @GET diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/SubResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/operation/SubResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/operation/SubResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/operation/SubResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/ArraySchemaResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/parameter/ArraySchemaResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/ArraySchemaResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/parameter/ArraySchemaResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/ComplexParameterResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/parameter/ComplexParameterResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/ComplexParameterResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/parameter/ComplexParameterResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/ComplexParameterWithOperationResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/parameter/ComplexParameterWithOperationResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/ComplexParameterWithOperationResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/parameter/ComplexParameterWithOperationResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/MultipleNotAnnotatedParameter.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/parameter/MultipleNotAnnotatedParameter.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/MultipleNotAnnotatedParameter.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/parameter/MultipleNotAnnotatedParameter.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/OpenAPIJaxRSAnnotatedParameter.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/parameter/OpenAPIJaxRSAnnotatedParameter.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/OpenAPIJaxRSAnnotatedParameter.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/parameter/OpenAPIJaxRSAnnotatedParameter.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/OpenAPIWithContentJaxRSAnnotatedParameter.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/parameter/OpenAPIWithContentJaxRSAnnotatedParameter.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/OpenAPIWithContentJaxRSAnnotatedParameter.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/parameter/OpenAPIWithContentJaxRSAnnotatedParameter.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/OpenAPIWithImplementationJaxRSAnnotatedParameter.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/parameter/OpenAPIWithImplementationJaxRSAnnotatedParameter.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/OpenAPIWithImplementationJaxRSAnnotatedParameter.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/parameter/OpenAPIWithImplementationJaxRSAnnotatedParameter.java diff --git a/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/parameter/ParametersResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/parameter/ParametersResource.java new file mode 100644 index 0000000000..5a7c40cbd3 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/parameter/ParametersResource.java @@ -0,0 +1,87 @@ +package io.swagger.v3.plugins.gradle.petstore.parameter; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.Explode; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.enums.ParameterStyle; +import io.swagger.v3.oas.annotations.media.ArraySchema; +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 javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +/** + * Resource with some Parameters examples + */ +public class ParametersResource { + @Path("/parameters") + @POST + @Operation( + operationId = "subscribe", + description = "subscribes a client to updates relevant to the requestor's account, as " + + "identified by the input token. The supplied url will be used as the delivery address for response payloads", + parameters = { + @Parameter(in = ParameterIn.PATH, name = "subscriptionId", required = true, + schema = @Schema(implementation = RepeatableParametersResource.SubscriptionResponse.class), style = ParameterStyle.SIMPLE), + @Parameter(in = ParameterIn.QUERY, name = "formId", required = true, + example = "Example"), + @Parameter(in = ParameterIn.QUERY, name = "explodeFalse", required = true, explode = Explode.FALSE, + schema = @Schema(implementation = SubscriptionResponse.class)), + @Parameter(in = ParameterIn.QUERY, name = "explodeTrue", required = true, explode = Explode.TRUE, + schema = @Schema(implementation = SubscriptionResponse.class)), + @Parameter(in = ParameterIn.QUERY, name = "explodeAvoiding", required = true, explode = Explode.TRUE, + schema = @Schema( + type = "int", + format = "id", + description = "the generated id", + accessMode = Schema.AccessMode.READ_ONLY + )), + @Parameter(in = ParameterIn.QUERY, name = "arrayParameter", required = true, explode = Explode.TRUE, + array = @ArraySchema(maxItems = 10, minItems = 1, + schema = @Schema(implementation = SubscriptionResponse.class), + uniqueItems = true + ) + , + schema = @Schema( + type = "int", + format = "id", + description = "the generated id", + accessMode = Schema.AccessMode.READ_ONLY), + content = @Content(schema = @Schema(type = "number", + description = "the generated id", + accessMode = Schema.AccessMode.READ_ONLY)) + ), + @Parameter(in = ParameterIn.QUERY, name = "arrayParameterImplementation", required = true, explode = Explode.TRUE, + array = @ArraySchema(maxItems = 10, minItems = 1, + schema = @Schema(implementation = SubscriptionResponse.class), + uniqueItems = true + ) + ), + @Parameter(in = ParameterIn.QUERY, name = "arrayParameterImplementation2", required = true, explode = Explode.TRUE, + schema = @Schema(implementation = SubscriptionResponse.class)) + + }, + responses = { + @ApiResponse( + description = "test description", content = @Content( + mediaType = "*/*", + schema = + @Schema( + implementation = SubscriptionResponse.class) + )) + }) + @Consumes({"application/json", "application/xml"}) + public SubscriptionResponse subscribe(@Parameter(description = "idParam") + @QueryParam("id") final String id) { + return null; + } + + static class SubscriptionResponse { + public String subscriptionId; + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/RepeatableParametersResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/parameter/RepeatableParametersResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/RepeatableParametersResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/parameter/RepeatableParametersResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/SingleJaxRSAnnotatedParameter.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/parameter/SingleJaxRSAnnotatedParameter.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/SingleJaxRSAnnotatedParameter.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/parameter/SingleJaxRSAnnotatedParameter.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/SingleNotAnnotatedParameter.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/parameter/SingleNotAnnotatedParameter.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/SingleNotAnnotatedParameter.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/parameter/SingleNotAnnotatedParameter.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/requestbody/RequestBodyMethodPriorityResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/requestbody/RequestBodyMethodPriorityResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/requestbody/RequestBodyMethodPriorityResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/requestbody/RequestBodyMethodPriorityResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/requestbody/RequestBodyParameterPriorityResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/requestbody/RequestBodyParameterPriorityResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/requestbody/RequestBodyParameterPriorityResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/requestbody/RequestBodyParameterPriorityResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/requestbody/RequestBodyResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/requestbody/RequestBodyResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/requestbody/RequestBodyResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/requestbody/RequestBodyResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/ComplexResponseResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/responses/ComplexResponseResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/ComplexResponseResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/responses/ComplexResponseResource.java diff --git a/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/responses/ImplementationResponseResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/responses/ImplementationResponseResource.java new file mode 100644 index 0000000000..88c163f348 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/responses/ImplementationResponseResource.java @@ -0,0 +1,71 @@ +package io.swagger.v3.plugins.gradle.petstore.responses; + +import io.swagger.v3.oas.annotations.Operation; +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 javax.ws.rs.GET; +import javax.ws.rs.Path; + +/** + * Resource with a Response at Method Level + */ +public class ImplementationResponseResource { + @GET + @Path("/implementationresponse") + @Operation( + summary = "Simple get operation", + description = "Defines a simple get operation with no inputs and a complex output object", + operationId = "getWithPayloadResponse", + deprecated = true, + responses = { + @ApiResponse( + responseCode = "200", + description = "voila!", + content = { + @Content( + mediaType = "application/json", + schema = + @Schema( + implementation = SampleResponseSchema.class) + ), + @Content( + mediaType = "application/json", + schema = + @Schema( + implementation = SecondSampleResponseSchema.class) + ) + } + + ), + @ApiResponse( + responseCode = "400", + description = "boo", + content = @Content( + mediaType = "*/*", + schema = + @Schema(implementation = GenericError.class) + ) + ) + } + ) + + public void getResponses() { + } + + static class SampleResponseSchema { + @Schema(description = "the user id") + private String id; + } + + static class SecondSampleResponseSchema { + @Schema(description = "the user id") + private String id; + } + + static class GenericError { + private int code; + private String message; + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/MethodResponseResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/responses/MethodResponseResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/MethodResponseResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/responses/MethodResponseResource.java diff --git a/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/responses/NoImplementationResponseResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/responses/NoImplementationResponseResource.java new file mode 100644 index 0000000000..6659f6babe --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/responses/NoImplementationResponseResource.java @@ -0,0 +1,66 @@ +package io.swagger.v3.plugins.gradle.petstore.responses; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.links.Link; +import io.swagger.v3.oas.annotations.links.LinkParameter; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +/** + * Resource with a Response at Method Level + */ +public class NoImplementationResponseResource { + @Path("/noimplementationresponseresource") + @Operation(operationId = "getUser", + responses = { + @ApiResponse(description = "test description", responseCode = "400", + links = { + @Link( + name = "user", + operationId = "getUser", + operationRef = "#/components/links/MyLink", + parameters = @LinkParameter( + name = "userId", + expression = "$request.query.userId")) + }), + @ApiResponse(description = "200 description", responseCode = "200", + links = { + @Link( + name = "pet", + operationId = "getUser", + operationRef = "#/components/links/MyLink", + parameters = @LinkParameter( + name = "userId", + expression = "$request.query.userId")) + }) + } + ) + @GET + public User getUser(@QueryParam("userId") final String userId) { + return null; + } + + static class User { + private String id; + private String username; + + public String getId() { + return id; + } + + public void setId(final String id) { + this.id = id; + } + + public String getUsername() { + return username; + } + + public void setUsername(final String username) { + this.username = username; + } + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/NoResponseResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/responses/NoResponseResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/NoResponseResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/responses/NoResponseResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/OperationResponseResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/responses/OperationResponseResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/OperationResponseResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/responses/OperationResponseResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/PriorityResponseResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/responses/PriorityResponseResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/PriorityResponseResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/responses/PriorityResponseResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/security/SecurityResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/security/SecurityResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/security/SecurityResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/security/SecurityResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/CompleteTagResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/tags/CompleteTagResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/CompleteTagResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/tags/CompleteTagResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/TagClassResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/tags/TagClassResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/TagClassResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/tags/TagClassResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/TagMethodResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/tags/TagMethodResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/TagMethodResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/tags/TagMethodResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/TagOpenAPIDefinitionResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/tags/TagOpenAPIDefinitionResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/TagOpenAPIDefinitionResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/tags/TagOpenAPIDefinitionResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/TagOperationResource.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/tags/TagOperationResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/tags/TagOperationResource.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/petstore/tags/TagOperationResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/QueryResultBean.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/QueryResultBean.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/resources/QueryResultBean.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/QueryResultBean.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/data/PetData.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/data/PetData.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/resources/data/PetData.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/data/PetData.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/data/UserData.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/data/UserData.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/resources/data/UserData.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/data/UserData.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/exception/ApiException.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/exception/ApiException.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/resources/exception/ApiException.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/exception/ApiException.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/exception/NotFoundException.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/exception/NotFoundException.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/resources/exception/NotFoundException.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/exception/NotFoundException.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/model/Category.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/model/Category.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/resources/model/Category.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/model/Category.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/model/CustomGenerator.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/model/CustomGenerator.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/resources/model/CustomGenerator.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/model/CustomGenerator.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/model/ExtensionUser.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/model/ExtensionUser.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/resources/model/ExtensionUser.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/model/ExtensionUser.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/model/JacksonBean.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/model/JacksonBean.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/resources/model/JacksonBean.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/model/JacksonBean.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/model/ListOfStringsBeanParam.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/model/ListOfStringsBeanParam.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/resources/model/ListOfStringsBeanParam.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/model/ListOfStringsBeanParam.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/model/ModelWithJsonIdentity.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/model/ModelWithJsonIdentity.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/resources/model/ModelWithJsonIdentity.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/model/ModelWithJsonIdentity.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/model/ModelWithJsonIdentityCyclic.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/model/ModelWithJsonIdentityCyclic.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/resources/model/ModelWithJsonIdentityCyclic.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/model/ModelWithJsonIdentityCyclic.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/model/MultipleBaseBean.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/model/MultipleBaseBean.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/resources/model/MultipleBaseBean.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/model/MultipleBaseBean.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/model/MultipleSub1Bean.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/model/MultipleSub1Bean.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/resources/model/MultipleSub1Bean.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/model/MultipleSub1Bean.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/model/MultipleSub2Bean.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/model/MultipleSub2Bean.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/resources/model/MultipleSub2Bean.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/model/MultipleSub2Bean.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/model/NotFoundModel.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/model/NotFoundModel.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/resources/model/NotFoundModel.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/model/NotFoundModel.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/model/Pet.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/model/Pet.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/resources/model/Pet.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/model/Pet.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/model/Tag.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/model/Tag.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/resources/model/Tag.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/model/Tag.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/resources/model/User.java b/modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/model/User.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/resources/model/User.java rename to modules/swagger-gradle-plugin/src/test/java/io/swagger/v3/plugins/gradle/resources/model/User.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/EmptyPetResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/EmptyPetResource.java new file mode 100644 index 0000000000..3a60f75fe2 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/EmptyPetResource.java @@ -0,0 +1,7 @@ +package io.swagger.v3.plugins.gradle.petstore; + +/** + * An Empty PetResource Class + */ +public class EmptyPetResource { +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/PetResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/PetResource.java new file mode 100644 index 0000000000..a0d713071d --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/PetResource.java @@ -0,0 +1,165 @@ +/** + * Copyright 2016 SmartBear Software + *

      + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

      + * http://www.apache.org/licenses/LICENSE-2.0 + *

      + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugins.gradle.petstore; + +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.plugins.gradle.resources.QueryResultBean; +import io.swagger.v3.plugins.gradle.resources.data.PetData; +import io.swagger.v3.plugins.gradle.resources.exception.NotFoundException; +import io.swagger.v3.plugins.gradle.resources.model.Pet; + +import javax.ws.rs.BeanParam; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Response; + +@Consumes("application/json") +@Path("/pet") +@Produces({"application/json", "application/xml"}) +public class PetResource { + static PetData petData = new PetData(); + + @GET + @Path("/{petId}") + @Operation(summary = "Find pet by ID", + description = "Returns a pet when 0 < ID <= 10. ID > 10 or nonintegers will simulate API error conditions", + responses = { + @ApiResponse( + description = "The pet", content = @Content( + schema = @Schema(implementation = Pet.class) + )), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") + }) + public Response getPetById( + @Parameter(description = "ID of pet that needs to be fetched"/*, _enum = "range[1,10]"*/, required = true) + @PathParam("petId") final Long petId) throws NotFoundException { + Pet pet = petData.getPetById(petId); + if (null != pet) { + return Response.ok().entity(pet).build(); + } else { + throw new NotFoundException(404, "Pet not found"); + } + } + + @POST + @Consumes({"application/json", "application/xml"}) + @Operation(summary = "Add a new pet to the store", + responses = { + @ApiResponse(responseCode = "405", description = "Invalid input") + }) + public Response addPet( + @Parameter(description = "Pet object that needs to be added to the store", required = true) final Pet pet) { + petData.addPet(pet); + return Response.ok().entity("SUCCESS").build(); + } + + @POST + @Path("/bodynoannotation") + @Consumes({"application/json", "application/xml"}) + @Produces({"application/json", "application/xml"}) + @Operation(summary = "Add a new pet to the store no annotation", + responses = { + @ApiResponse(responseCode = "405", description = "Invalid input") + }) + public Response addPetNoAnnotation(final Pet pet) { + petData.addPet(pet); + return Response.ok().entity("SUCCESS").build(); + } + + @POST + @Path("/bodyid") + @Consumes({"application/json", "application/xml"}) + @Operation(summary = "Add a new pet to the store passing an integer with generic parameter annotation", + responses = { + @ApiResponse(responseCode = "405", description = "Invalid input") + }) + public Response addPetByInteger( + @Parameter(description = "Pet object that needs to be added to the store", required = true) final int petId) { + return Response.ok().entity("SUCCESS").build(); + } + + @POST + @Path("/bodyidnoannotation") + @Consumes({"application/json", "application/xml"}) + @Operation(summary = "Add a new pet to the store passing an integer without parameter annotation", + responses = { + @ApiResponse(responseCode = "405", description = "Invalid input") + }) + public Response addPetByIntegerNoAnnotation(final int petId) { + return Response.ok().entity("SUCCESS").build(); + } + + @PUT + @Operation(summary = "Update an existing pet", + responses = { + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found"), + @ApiResponse(responseCode = "405", description = "Validation exception")}) + public Response updatePet( + @Parameter(description = "Pet object that needs to be added to the store", required = true) final Pet pet) { + petData.addPet(pet); + return Response.ok().entity("SUCCESS").build(); + } + + @GET + @Path("/findByStatus") + @Produces("application/xml") + @Operation(summary = "Finds Pets by status", + description = "Multiple status values can be provided with comma seperated strings", + responses = { + @ApiResponse( + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = Pet.class))), + @ApiResponse( + responseCode = "400", description = "Invalid status value" + )} + ) + public Response findPetsByStatus( + @Parameter(description = "Status values that need to be considered for filter", required = true) @QueryParam("status") final String status, + @BeanParam final QueryResultBean qr + ) { + return Response.ok(petData.findPetByStatus(status)).build(); + } + + @GET + @Path("/findByTags") + @Produces("application/json") + @Operation(summary = "Finds Pets by tags", + description = "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", + responses = { + @ApiResponse(description = "Pets matching criteria", + content = @Content(schema = @Schema(implementation = Pet.class)) + ), + @ApiResponse(description = "Invalid tag value", responseCode = "400") + }) + @Deprecated + public Response findPetsByTags( + @Parameter(description = "Tags to filter by", required = true) @QueryParam("tags") final String tags) { + return Response.ok(petData.findPetByTags(tags)).build(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/callback/ComplexCallbackResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/callback/ComplexCallbackResource.java new file mode 100644 index 0000000000..44dfc535ee --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/callback/ComplexCallbackResource.java @@ -0,0 +1,62 @@ +package io.swagger.v3.plugins.gradle.petstore.callback; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.callbacks.Callback; +import io.swagger.v3.oas.annotations.callbacks.Callbacks; +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.plugins.gradle.resources.model.User; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +public class ComplexCallbackResource { + @Callbacks({ + @Callback( + name = "testCallback1", + operation = @Operation( + operationId = "getAllReviews", + summary = "get all the reviews", + method = "get", + responses = @ApiResponse( + responseCode = "200", + description = "successful operation", + content = @Content( + mediaType = "application/json", + schema = @Schema( + type = "integer", + format = "int32")))), + callbackUrlExpression = "http://www.url.com"), + @Callback( + name = "testCallback2", + operation = @Operation( + operationId = "getAnSpecificReviews", + summary = "get a review", + method = "get", + responses = @ApiResponse( + responseCode = "200", + description = "successful operation", + content = @Content( + mediaType = "application/json", + schema = @Schema( + implementation = User.class)))), + callbackUrlExpression = "http://www.url2.com") + }) + @Operation( + summary = "Simple get operation", + operationId = "getWithNoParameters", + responses = { + @ApiResponse( + responseCode = "200", + description = "voila!") + }) + @GET + @Path("/complexcallback") + public String simpleGet(@Parameter(description = "idParam", schema = @Schema(implementation = User.class)) + @QueryParam("id") final String id) { + return null; + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/callback/MultipleCallbacksTestWithOperationResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/callback/MultipleCallbacksTestWithOperationResource.java new file mode 100644 index 0000000000..2ec7309b1b --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/callback/MultipleCallbacksTestWithOperationResource.java @@ -0,0 +1,45 @@ +package io.swagger.v3.plugins.gradle.petstore.callback; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.callbacks.Callback; +import io.swagger.v3.oas.annotations.callbacks.Callbacks; +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 javax.ws.rs.GET; +import javax.ws.rs.Path; + +public class MultipleCallbacksTestWithOperationResource { + @Callbacks({ + @Callback( + name = "testCallback1", + operation = @Operation( + operationId = "getAllReviews", + summary = "get all the reviews", + method = "get", + responses = @ApiResponse( + responseCode = "200", + description = "successful operation", + content = @Content( + mediaType = "application/json", + schema = @Schema( + type = "integer", + format = "int32")))), + callbackUrlExpression = "http://www.url.com"), + @Callback(name = "testCallback2", operation = @Operation(), callbackUrlExpression = "http://$request.query.url") + }) + @Operation( + summary = "Simple get operation", + operationId = "getWithNoParameters", + responses = { + @ApiResponse( + responseCode = "200", + description = "voila!") + }) + @GET + @Path("/multiplecallback") + public String simpleGet() { + return null; + } +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/callback/RepeatableCallbackResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/callback/RepeatableCallbackResource.java new file mode 100644 index 0000000000..82a60ca110 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/callback/RepeatableCallbackResource.java @@ -0,0 +1,46 @@ +package io.swagger.v3.plugins.gradle.petstore.callback; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.callbacks.Callback; +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 javax.ws.rs.GET; +import javax.ws.rs.Path; + +public class RepeatableCallbackResource { + @Callback(name = "testCallback", operation = + @Operation(), callbackUrlExpression = "http://$requests.query.url") + @Callback( + name = "testCallback1", + operation = @Operation( + operationId = "getAllReviews", + summary = "get all the reviews", + method = "get", + responses = @ApiResponse( + responseCode = "200", + description = "successful operation", + content = @Content( + mediaType = "application/json", + schema = @Schema( + type = "integer", + format = "int32")))), + callbackUrlExpression = "http://www.url.com") + @Callback(name = "testCallback2", operation = + @Operation(), + callbackUrlExpression = "http://$request.query.url") + @Operation( + summary = "Simple get operation", + operationId = "getWithNoParameters", + responses = { + @ApiResponse( + responseCode = "200", + description = "voila!") + }) + @GET + @Path("/repeatablecallback") + public String simpleGet() { + return null; + } +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/callback/SimpleCallbackWithOperationResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/callback/SimpleCallbackWithOperationResource.java new file mode 100644 index 0000000000..2c6e543362 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/callback/SimpleCallbackWithOperationResource.java @@ -0,0 +1,44 @@ +package io.swagger.v3.plugins.gradle.petstore.callback; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.callbacks.Callback; +import io.swagger.v3.oas.annotations.callbacks.Callbacks; +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 javax.ws.rs.GET; +import javax.ws.rs.Path; + +public class SimpleCallbackWithOperationResource { + @Callbacks({ + @Callback( + name = "testCallback1", + operation = @Operation( + operationId = "getAllReviews", + summary = "get all the reviews", + method = "get", + responses = @ApiResponse( + responseCode = "200", + description = "successful operation", + content = @Content( + mediaType = "application/json", + schema = @Schema( + type = "integer", + format = "int32")))), + callbackUrlExpression = "http://www.url.com") + }) + @Operation( + summary = "Simple get operation", + operationId = "getWithNoParameters", + responses = { + @ApiResponse( + responseCode = "200", + description = "voila!") + }) + @GET + @Path("/simplecallback") + public String simpleGet() { + return null; + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/example/ExamplesResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/example/ExamplesResource.java new file mode 100644 index 0000000000..84ae58bfb7 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/example/ExamplesResource.java @@ -0,0 +1,69 @@ +package io.swagger.v3.plugins.gradle.petstore.example; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.enums.ParameterStyle; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.ExampleObject; +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.plugins.gradle.resources.model.User; + +import javax.ws.rs.POST; +import javax.ws.rs.Path; + +/** + * Examples Resource Scenario + */ +public class ExamplesResource { + @Path("/example") + @POST + @Operation( + operationId = "subscribe", + description = "subscribes a client to updates relevant to the requestor's account", + parameters = { + @Parameter(in = ParameterIn.PATH, name = "subscriptionId", required = true, + schema = @Schema(name = "Schema", description = "Schema", example = "Subscription example"), + style = ParameterStyle.SIMPLE, example = "example", + examples = { + @ExampleObject(name = "subscriptionId_1", value = "12345", + summary = "Subscription number 12345", externalValue = "Subscription external value 1"), + @ExampleObject(name = "subscriptionId_2", value = "54321", + summary = "Subscription number 54321", externalValue = "Subscription external value 2") + }) + }, + responses = { + @ApiResponse( + description = "test description", + content = @Content( + mediaType = "*/*", + schema = @Schema( + type = "string", + format = "uuid", + description = "the generated UUID", + accessMode = Schema.AccessMode.READ_ONLY, + example = "Schema example" + ), + examples = { + @ExampleObject(name = "Default Response", value = "SubscriptionResponse", + summary = "Subscription Response Example", externalValue = "Subscription Response value 1") + } + )) + }) + public SubscriptionResponse subscribe(@RequestBody(description = "Created user object", required = true, + content = @Content( + schema = @Schema( + type = "string", + format = "uuid", + description = "the generated UUID", + accessMode = Schema.AccessMode.READ_ONLY, + example = "Schema example"), + examples = { + @ExampleObject(name = "Default Request", value = "SubscriptionRequest", + summary = "Subscription Request Example", externalValue = "Subscription Request Value") + })) User user) { + return null; + } +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/example/SubscriptionResponse.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/example/SubscriptionResponse.java new file mode 100644 index 0000000000..7b8bc707a4 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/example/SubscriptionResponse.java @@ -0,0 +1,5 @@ +package io.swagger.v3.plugins.gradle.petstore.example; + +public class SubscriptionResponse { + public String subscriptionId; +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/link/LinksResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/link/LinksResource.java new file mode 100644 index 0000000000..8450a64abf --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/link/LinksResource.java @@ -0,0 +1,44 @@ +package io.swagger.v3.plugins.gradle.petstore.link; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.links.Link; +import io.swagger.v3.oas.annotations.links.LinkParameter; +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 javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +/** + * Class with Links + */ +public class LinksResource { + @Path("/links") + @Operation(operationId = "getUserWithAddress", + responses = { + @ApiResponse(description = "test description", + content = @Content(mediaType = "*/*", schema = @Schema(ref = "#/components/schemas/User")), + links = { + @Link( + name = "address", + operationId = "getAddress", + parameters = @LinkParameter( + name = "userId", + expression = "$request.query.userId")), + @Link( + name = "user", + operationId = "getUser", + operationRef = "#/components/links/MyLink", + parameters = @LinkParameter( + name = "userId", + expression = "$request.query.userId")) + })} + ) + @GET + public String getUser(@QueryParam("userId")final String userId) { + return null; + } + +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/openapidefintion/OpenAPIDefinitionResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/openapidefintion/OpenAPIDefinitionResource.java new file mode 100644 index 0000000000..5ac0c573fa --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/openapidefintion/OpenAPIDefinitionResource.java @@ -0,0 +1,38 @@ +package io.swagger.v3.plugins.gradle.petstore.openapidefintion; + +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.info.Contact; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.info.License; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.servers.Server; +import io.swagger.v3.oas.annotations.servers.ServerVariable; +import io.swagger.v3.oas.annotations.tags.Tag; + +/** + * OpenAPIDefinition Example + */ +@OpenAPIDefinition( + info = @Info( + title = "Pet Resource Example", + version = "2.0", + description = "API Definition", + termsOfService = "Terms of service", + license = @License(name = "Apache 2.0", url = "http://foo.bar"), + contact = @Contact(url = "http://gigantic-server.com", name = "Fred", email = "Fred@gigagantic-server.com") + ), + tags = { + @Tag(name = "Tag 1", description = "desc 1", externalDocs = @ExternalDocumentation(description = "docs desc")), + @Tag(name = "Tag 2", description = "desc 2", externalDocs = @ExternalDocumentation(description = "docs desc 2")), + @Tag(name = "Tag 3") + }, + externalDocs = @ExternalDocumentation(description = "definition docs desc"), + security = { + @SecurityRequirement(name = "req 1", scopes = {"a", "b"}), + @SecurityRequirement(name = "req 2", scopes = {"b", "c"}) + }) +public class OpenAPIDefinitionResource { + public void foo() { + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/AnnotatedSameNameOperationResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/AnnotatedSameNameOperationResource.java new file mode 100644 index 0000000000..db73258ef0 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/AnnotatedSameNameOperationResource.java @@ -0,0 +1,26 @@ +package io.swagger.v3.plugins.gradle.petstore.operation; + +import io.swagger.v3.oas.annotations.Operation; + +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +/** + * Resource With a Default Operation without Annotation + */ +public class AnnotatedSameNameOperationResource { + @Path("/sameOperationName") + @GET + @Operation(description = "Same Operation Name") + public String getUser() { + return new String(); + } + + @Path("//sameOperationName") + @DELETE + @Operation(description = "Same Operation Name Duplicated") + public String getUser(final String id) { + return new String(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/ExternalDocumentationResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/ExternalDocumentationResource.java new file mode 100644 index 0000000000..a351ac68bf --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/ExternalDocumentationResource.java @@ -0,0 +1,30 @@ +package io.swagger.v3.plugins.gradle.petstore.operation; + +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.plugins.gradle.resources.exception.NotFoundException; +import io.swagger.v3.plugins.gradle.resources.model.Pet; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.Response; + +/** + * Resource with Operations Examples + */ +public class ExternalDocumentationResource { + @GET + @Path("/{petId}") + @Operation(summary = "Find pet by ID", + description = "Returns a pet when 0 < ID <= 10. ID > 10 or non integers will simulate API error conditions", + operationId = "petId", + externalDocs = @ExternalDocumentation(description = "External in Operation", url = "http://url.me")) + @ExternalDocumentation(description = "External Annotation Documentation", url = "http://url.me") + public Response getPetById( + @Parameter(description = "ID of pet that needs to be fetched", required = true) + @PathParam("petId") Long petId) throws NotFoundException { + return Response.ok().entity(new Pet()).build(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/FullyAnnotatedOperationResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/FullyAnnotatedOperationResource.java new file mode 100644 index 0000000000..2955c6590e --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/FullyAnnotatedOperationResource.java @@ -0,0 +1,38 @@ +package io.swagger.v3.plugins.gradle.petstore.operation; + +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.plugins.gradle.resources.exception.NotFoundException; +import io.swagger.v3.plugins.gradle.resources.model.Pet; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.Response; + +/** + * Resource with Operations Examples + */ +public class FullyAnnotatedOperationResource { + @GET + @Path("/fullyannotatedoperation/{petId}") + @Operation(summary = "Find pet by ID", + description = "Returns a pet when 0 < ID <= 10. ID > 10 or non integers will simulate API error conditions", + operationId = "petId", + responses = { + @ApiResponse( + description = "The pet", content = @Content( + schema = @Schema(implementation = Pet.class) + )), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") + }) + public Response getPetById( + @Parameter(description = "ID of pet that needs to be fetched", required = true) + @PathParam("petId")final Long petId) throws NotFoundException { + return Response.ok().entity(new Pet()).build(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/HiddenOperationResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/HiddenOperationResource.java new file mode 100644 index 0000000000..730e83657d --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/HiddenOperationResource.java @@ -0,0 +1,29 @@ +package io.swagger.v3.plugins.gradle.petstore.operation; + +import io.swagger.v3.oas.annotations.Hidden; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.plugins.gradle.resources.model.Pet; +import io.swagger.v3.plugins.gradle.resources.model.User; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +/** + * Resource With a Hidden Operation + */ +public class HiddenOperationResource { + @Path("/hiddenbyflag") + @GET + @Operation(operationId = "Pets", description = "Pets Example", hidden = true) + public Pet getPet() { + return new Pet(); + } + + @Path("/hiddenbyannotation") + @GET + @Operation(operationId = "Users", description = "Users Example") + @Hidden + public User getUser() { + return new User(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/InterfaceResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/InterfaceResource.java new file mode 100644 index 0000000000..aa5418ecc6 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/InterfaceResource.java @@ -0,0 +1,22 @@ +package io.swagger.v3.plugins.gradle.petstore.operation; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.Response; + +/** + * Interface resource + */ +public interface InterfaceResource { + @GET + @Path("/interfaceoperation/{petId}") + @Operation(summary = "Find pet by ID Operation in Parent", + description = "Returns a pet in Parent" + ) + Response getPetById(@Parameter(description = "ID of pet that needs to be fetched", required = true) + @PathParam("petId") final Long petId); +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/NotAnnotatedSameNameOperationResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/NotAnnotatedSameNameOperationResource.java new file mode 100644 index 0000000000..e8021608de --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/NotAnnotatedSameNameOperationResource.java @@ -0,0 +1,21 @@ +package io.swagger.v3.plugins.gradle.petstore.operation; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +/** + * Resource With a Default Operation without Annotation + */ +public class NotAnnotatedSameNameOperationResource { + @Path("/notannotatedoperation") + @GET + public String getUser() { + return new String(); + } + + @Path("/notannotatedoperationduplicated") + @GET + public String getUser(final String id) { + return new String(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/OperationResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/OperationResource.java new file mode 100644 index 0000000000..fdc5e495ca --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/OperationResource.java @@ -0,0 +1,77 @@ +package io.swagger.v3.plugins.gradle.petstore.operation; + +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.plugins.gradle.resources.model.Pet; + +import javax.ws.rs.GET; +import javax.ws.rs.HEAD; +import javax.ws.rs.NotFoundException; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Response; + +/** + * Resource with Complete Operations Examples + */ +public class OperationResource implements InterfaceResource { + @Override + @Operation(summary = "Find pet by ID Operation in SubResource", + description = "Returns a pet in SubResource" + ) + public Response getPetById(final Long petId) { + return Response.ok().entity(new Pet()).build(); + } + + @GET + @Path("/operationsresource") + @Operation(summary = "Find pet by ID", + description = "combinatedfullyannotatedoperation/{petId}", + operationId = "petId", + responses = { + @ApiResponse( + description = "The pet", content = @Content( + schema = @Schema(implementation = Pet.class) + )), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") + }) + public Response getPetById( + @Parameter(description = "ID of pet that needs to be fetched", required = true) + @QueryParam("petId") final Long petId, final String message) throws NotFoundException { + return Response.ok().entity(new Pet()).build(); + } + + @Path("/operationsresource") + @POST + public String getUser(final String id) { + return new String(); + } + + @Path("/operationsresource") + @PUT + @Operation(operationId = "combinated sameOperationName", + description = "combinatedsameOperationName") + public String getPerson() { + return new String(); + } + + @Path("/operationsresource") + @HEAD + @Operation(operationId = "combinatedsameOperationNameDuplicated", + description = "combinatedsameOperationNameDuplicated") + public String getPerson(final String id) { + return new String(); + } + + @Path("/operationsresource2") + @GET + public String getUser() { + return new String(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/OperationWithoutAnnotationResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/OperationWithoutAnnotationResource.java new file mode 100644 index 0000000000..7c4bf2cd02 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/OperationWithoutAnnotationResource.java @@ -0,0 +1,15 @@ +package io.swagger.v3.plugins.gradle.petstore.operation; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +/** + * Resource With a Default Operation without Annotation + */ +public class OperationWithoutAnnotationResource { + @Path("/operationwithouannotation") + @GET + public String getUser() { + return new String(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/ServerOperationResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/ServerOperationResource.java new file mode 100644 index 0000000000..725fed837b --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/ServerOperationResource.java @@ -0,0 +1,25 @@ +package io.swagger.v3.plugins.gradle.petstore.operation; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.servers.Server; +import io.swagger.v3.plugins.gradle.resources.model.Pet; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +/** + * Resource With a Hidden Operation + */ +public class ServerOperationResource { + @Path("/serversoperation") + @GET + @Operation(operationId = "Pets", description = "Pets Example", + servers = { + @Server(description = "server 2", url = "http://foo2") + } + ) + public Pet getPet() { + return new Pet(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/SubResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/SubResource.java new file mode 100644 index 0000000000..d56a767030 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/operation/SubResource.java @@ -0,0 +1,20 @@ +package io.swagger.v3.plugins.gradle.petstore.operation; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.plugins.gradle.resources.model.Pet; + +import javax.ws.rs.core.Response; + +/** + * SubResource + */ + +public class SubResource implements InterfaceResource { + @Override + @Operation(summary = "Find pet by ID Operation in SubResource", + description = "Returns a pet in SubResource" + ) + public Response getPetById(final Long petId) { + return Response.ok().entity(new Pet()).build(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/ArraySchemaResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/ArraySchemaResource.java new file mode 100644 index 0000000000..1ec07a8ce8 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/ArraySchemaResource.java @@ -0,0 +1,44 @@ +package io.swagger.v3.plugins.gradle.petstore.parameter; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.Explode; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.ArraySchema; +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 javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; + +public class ArraySchemaResource { + @Path("/arrayschema") + @POST + @Operation( + operationId = "subscribe", + description = "subscribes a client to updates relevant to the requestor's account, as " + + "identified by the input token. The supplied url will be used as the delivery address for response payloads", + parameters = { + @Parameter(in = ParameterIn.QUERY, name = "arrayParameter", required = true, explode = Explode.TRUE, + array = @ArraySchema(maxItems = 10, minItems = 1, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class), + uniqueItems = true + ) + ), + }, + responses = { + @ApiResponse( + description = "test description", content = @Content( + mediaType = "*/*", + schema = + @Schema( + implementation = ParametersResource.SubscriptionResponse.class) + )) + }) + @Consumes({"application/json", "application/xml"}) + public ParametersResource.SubscriptionResponse subscribe() { + return null; + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/ComplexParameterResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/ComplexParameterResource.java new file mode 100644 index 0000000000..c2ca2f84aa --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/ComplexParameterResource.java @@ -0,0 +1,33 @@ +package io.swagger.v3.plugins.gradle.petstore.parameter; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.plugins.gradle.resources.model.User; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +/** + * Class with a multiple annotated. + */ +public class ComplexParameterResource { + + @Parameter(description = "Phone definied in Field") + private String phone; + + public ComplexParameterResource(@Parameter(description = "phone Param", name = "phone") final String phone) { + this.phone = phone; + } + + @GET + @Path("/complexparameter") + @Operation(operationId = "create User") + public User findUser(@Parameter(description = "idParam") @QueryParam("id") final String id, + final String name, @QueryParam("lastName") final String lastName, + @Parameter(description = "address", schema = @Schema(implementation = User.class)) + @QueryParam("address") final String address) { + return new User(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/ComplexParameterWithOperationResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/ComplexParameterWithOperationResource.java new file mode 100644 index 0000000000..d1c36874c9 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/ComplexParameterWithOperationResource.java @@ -0,0 +1,37 @@ +package io.swagger.v3.plugins.gradle.petstore.parameter; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.plugins.gradle.resources.model.User; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +/** + * Class with a multiple annotated. + */ +public class ComplexParameterWithOperationResource { + + @Parameter(description = "Phone definied in Field") + private String phone; + + public ComplexParameterWithOperationResource(@Parameter(description = "phone Param", name = "phone") final String phone) { + this.phone = phone; + } + + @GET + @Path("/complexparameter") + @Operation(operationId = "create User", + parameters = { + @Parameter(description = "Phone", name = "phone", in = ParameterIn.PATH) + }) + public User findUser(@Parameter(description = "idParam") @QueryParam("id") final String id, + final String name, @QueryParam("lastName") final String lastName, + @Parameter(description = "address", schema = @Schema(implementation = User.class)) + @QueryParam("address") final String address) { + return new User(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/MultipleNotAnnotatedParameter.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/MultipleNotAnnotatedParameter.java new file mode 100644 index 0000000000..7303048545 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/MultipleNotAnnotatedParameter.java @@ -0,0 +1,18 @@ +package io.swagger.v3.plugins.gradle.petstore.parameter; + +import io.swagger.v3.oas.annotations.Operation; + +import javax.ws.rs.POST; +import javax.ws.rs.Path; + +/** + * Class with a multiple not annotated parameter. + */ +public class MultipleNotAnnotatedParameter { + @POST + @Path("/multiplenoannotatedparameter") + @Operation(operationId = "create User") + public void createUser(final String id, final String name) { + + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/OpenAPIJaxRSAnnotatedParameter.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/OpenAPIJaxRSAnnotatedParameter.java new file mode 100644 index 0000000000..9832b462db --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/OpenAPIJaxRSAnnotatedParameter.java @@ -0,0 +1,21 @@ +package io.swagger.v3.plugins.gradle.petstore.parameter; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.plugins.gradle.resources.model.User; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +/** + * Class with a single parameter annotated with jaxrs and open api annotation. + */ +public class OpenAPIJaxRSAnnotatedParameter { + @GET + @Path("/openapijaxrsannotatedparameter") + @Operation(operationId = "create User") + public User findUser(@Parameter(description = "idParam") @QueryParam("id") final String id) { + return new User(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/OpenAPIWithContentJaxRSAnnotatedParameter.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/OpenAPIWithContentJaxRSAnnotatedParameter.java new file mode 100644 index 0000000000..4c4f1ddc32 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/OpenAPIWithContentJaxRSAnnotatedParameter.java @@ -0,0 +1,25 @@ +package io.swagger.v3.plugins.gradle.petstore.parameter; + +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.plugins.gradle.resources.model.User; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +/** + * Class with a single parameter annotated with jaxrs and open api annotation. + */ +public class OpenAPIWithContentJaxRSAnnotatedParameter { + @GET + @Path("/openapiwithcontentjaxrsannotatedparameter") + @Operation(operationId = "create User") + public User findUser(@Parameter(description = "idParam", content = + @Content(schema = @Schema(description = "Id Schema Definition", required = true, name = "id"))) + @QueryParam("id") final String id) { + return new User(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/OpenAPIWithImplementationJaxRSAnnotatedParameter.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/OpenAPIWithImplementationJaxRSAnnotatedParameter.java new file mode 100644 index 0000000000..df23a83a76 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/OpenAPIWithImplementationJaxRSAnnotatedParameter.java @@ -0,0 +1,23 @@ +package io.swagger.v3.plugins.gradle.petstore.parameter; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.plugins.gradle.resources.model.User; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +/** + * Class with a single parameter annotated with jaxrs and open api annotation. + */ +public class OpenAPIWithImplementationJaxRSAnnotatedParameter { + @GET + @Path("/openapiwithimplementationjaxrsannotatedparameter") + @Operation(operationId = "create User") + public User findUser(@Parameter(description = "idParam", schema = @Schema(implementation = User.class)) + @QueryParam("id") final String id) { + return new User(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/ParametersResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/ParametersResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/parameter/ParametersResource.java rename to modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/ParametersResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/RepeatableParametersResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/RepeatableParametersResource.java new file mode 100644 index 0000000000..2626f0c6ac --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/RepeatableParametersResource.java @@ -0,0 +1,80 @@ +package io.swagger.v3.plugins.gradle.petstore.parameter; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.Explode; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.enums.ParameterStyle; +import io.swagger.v3.oas.annotations.media.ArraySchema; +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 javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; + +public class RepeatableParametersResource { + @Path("/repeatableparameter") + @POST + @Parameter(in = ParameterIn.PATH, name = "subscriptionId", required = true, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class), style = ParameterStyle.SIMPLE) + @Parameter(in = ParameterIn.QUERY, name = "formId", required = true, + example = "Example") + @Parameter(in = ParameterIn.QUERY, name = "explodeFalse", required = true, explode = Explode.FALSE, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class)) + @Parameter(in = ParameterIn.QUERY, name = "explodeTrue", required = true, explode = Explode.TRUE, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class)) + @Parameter(in = ParameterIn.QUERY, name = "explodeAvoiding", required = true, explode = Explode.TRUE, + schema = @Schema( + type = "int", + format = "id", + description = "the generated id", + accessMode = Schema.AccessMode.READ_ONLY + )) + @Parameter(in = ParameterIn.QUERY, name = "arrayParameter", required = true, explode = Explode.TRUE, + array = @ArraySchema(maxItems = 10, minItems = 1, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class), + uniqueItems = true + ) + , + schema = @Schema( + type = "int", + format = "id", + description = "the generated id", + accessMode = Schema.AccessMode.READ_ONLY), + content = @Content(schema = @Schema(type = "number", + description = "the generated id", + accessMode = Schema.AccessMode.READ_ONLY)) + ) + @Parameter(in = ParameterIn.QUERY, name = "arrayParameterImplementation", required = true, explode = Explode.TRUE, + array = @ArraySchema(maxItems = 10, minItems = 1, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class), + uniqueItems = true + ) + ) + @Parameter(in = ParameterIn.QUERY, name = "arrayParameterImplementation2", required = true, explode = Explode.TRUE, + schema = @Schema(implementation = ParametersResource.SubscriptionResponse.class)) + @Operation( + operationId = "subscribe", + description = "subscribes a client to updates relevant to the requestor's account, as " + + "identified by the input token. The supplied url will be used as the delivery address for response payloads", + responses = { + @ApiResponse( + description = "test description", content = @Content( + mediaType = "*/*", + schema = + @Schema( + implementation = ParametersResource.SubscriptionResponse.class) + )) + }) + @Consumes({"application/json", "application/xml"}) + public ParametersResource.SubscriptionResponse subscribe() { + return null; + } + + static class SubscriptionResponse { + public String subscriptionId; + } +} + diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/SingleJaxRSAnnotatedParameter.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/SingleJaxRSAnnotatedParameter.java new file mode 100644 index 0000000000..29788cd9eb --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/SingleJaxRSAnnotatedParameter.java @@ -0,0 +1,20 @@ +package io.swagger.v3.plugins.gradle.petstore.parameter; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.plugins.gradle.resources.model.User; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +/** + * Class with a single parameter annotated with jaxrs. + */ +public class SingleJaxRSAnnotatedParameter { + @GET + @Path("/singlejaxrsannotatedparameter") + @Operation(operationId = "create User") + public User findUser(@QueryParam("id") final String id) { + return new User(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/SingleNotAnnotatedParameter.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/SingleNotAnnotatedParameter.java new file mode 100644 index 0000000000..a322111708 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/parameter/SingleNotAnnotatedParameter.java @@ -0,0 +1,19 @@ +package io.swagger.v3.plugins.gradle.petstore.parameter; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.plugins.gradle.resources.model.User; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +/** + * Class with a single not annotated parameter. + */ +public class SingleNotAnnotatedParameter { + @GET + @Path("/singlenoannotatedparameter") + @Operation(operationId = "create User") + public User findUser(final String id) { + return new User(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/requestbody/RequestBodyMethodPriorityResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/requestbody/RequestBodyMethodPriorityResource.java new file mode 100644 index 0000000000..6e9ee3715b --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/requestbody/RequestBodyMethodPriorityResource.java @@ -0,0 +1,28 @@ +package io.swagger.v3.plugins.gradle.petstore.requestbody; + +import io.swagger.v3.oas.annotations.Operation; +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.plugins.gradle.resources.model.User; + +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; + +/** + * Resource with RequestBody inside Operation and another in Method + */ +public class RequestBodyMethodPriorityResource { + @POST + @Path("/requestbodymethodpriority") + @Operation(summary = "Create user", + description = "This can only be done by the logged in user.", + requestBody = @RequestBody(description = "Inside Operation")) + @RequestBody(description = "Created user object on Method", required = true, + content = @Content( + schema = @Schema(implementation = User.class))) + public Response methodWithRequestBodyAndTwoParameters(final User user) { + return Response.ok().entity("").build(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/requestbody/RequestBodyParameterPriorityResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/requestbody/RequestBodyParameterPriorityResource.java new file mode 100644 index 0000000000..f76a4781ae --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/requestbody/RequestBodyParameterPriorityResource.java @@ -0,0 +1,29 @@ +package io.swagger.v3.plugins.gradle.petstore.requestbody; + +import io.swagger.v3.oas.annotations.Operation; +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.plugins.gradle.resources.model.User; + +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; + +/** + * Resource with RequestBody inside Operation and another in Method + */ +public class RequestBodyParameterPriorityResource { + @POST + @Path("/requestbodyparameterpriority") + @Operation(summary = "Create user", + description = "This can only be done by the logged in user.", + requestBody = @RequestBody(description = "Inside Operation")) + @RequestBody(description = "On method") + public Response methodWithRequestBodyAndTwoParameters( + @RequestBody(description = "Created user object inside Parameter", required = true, + content = @Content( + schema = @Schema(implementation = User.class)))final User user) { + return Response.ok().entity("").build(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/requestbody/RequestBodyResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/requestbody/RequestBodyResource.java new file mode 100644 index 0000000000..b2e310e0cc --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/requestbody/RequestBodyResource.java @@ -0,0 +1,113 @@ +package io.swagger.v3.plugins.gradle.petstore.requestbody; + +import io.swagger.v3.oas.annotations.Operation; +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.plugins.gradle.resources.model.Pet; +import io.swagger.v3.plugins.gradle.resources.model.User; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Response; + +/** + * Resource with RequestBody examples + */ +public class RequestBodyResource { + @GET + @Path("/methodWithRequestBodyWithoutContent") + @Operation(summary = "Create user", + description = "This can only be done by the logged in user.") + public Response methodWithRequestBodyWithoutContent( + @RequestBody(description = "Created user object", required = true) final User user) { + return Response.ok().entity("").build(); + } + + @GET + @Path("/methodWithRequestBodyWithoutContentWithoutImplementation") + @Operation(summary = "Create user", + description = "This can only be done by the logged in user.") + public Response methodWithRequestBodyWithoutContentWithoutImplementation( + @RequestBody(description = "Created user object", required = true, + content = @Content( + schema = @Schema(name = "User", description = "User description", + example = "User Description", required = true))) final User user) { + return Response.ok().entity("").build(); + } + + @POST + @Path("/methodWithRequestBodyAndTwoParameters") + @Operation(summary = "Create user", + description = "This can only be done by the logged in user.") + public Response methodWithRequestBodyAndTwoParameters( + @RequestBody(description = "Created user object", required = true, + content = @Content( + schema = @Schema(implementation = User.class))) final User user, + @QueryParam("name") final String name, @QueryParam("code") final String code) { + return Response.ok().entity("").build(); + } + + @PUT + @Path("/methodWithRequestBodyWithoutAnnotation") + @Operation(summary = "Modify user", + description = "Modifying user.") + public Response methodWithRequestBodyWithoutAnnotation( + final User user) { + return Response.ok().entity("").build(); + } + + @DELETE + @Path("/methodWithoutRequestBodyAndTwoParameters") + @Operation(summary = "Delete user", + description = "This can only be done by the logged in user.") + public Response methodWithoutRequestBodyAndTwoParameters( + @QueryParam("name") final String name, @QueryParam("code") final String code) { + return Response.ok().entity("").build(); + } + + @PUT + @Path("/methodWithRequestBodyWithoutAnnotationAndTwoConsumes") + @Operation(summary = "Modify pet", + description = "Modifying pet.") + @Consumes({"application/json", "application/xml"}) + public Response methodWithRequestBodyWithoutAnnotationAndTwoConsumes( + final User user) { + return Response.ok().entity("").build(); + } + + @POST + @Path("/methodWithTwoRequestBodyWithoutAnnotationAndTwoConsumes") + @Operation(summary = "Create pet", + description = "Creating pet.") + @Consumes({"application/json", "application/xml"}) + public Response methodWithTwoRequestBodyWithoutAnnotationAndTwoConsumes( + final Pet pet, final User user) { + return Response.ok().entity("").build(); + } + + @POST + @Path("/methodWithTwoRequestBodyWithAnnotationAndTwoConsumes") + @Operation(summary = "Create pet", + description = "Creating pet.") + @Consumes({"application/json", "application/xml"}) + public Response methodWithTwoRequestBodyWithAnnotationAndTwoConsumes( + final @RequestBody(description = "Request Body Pet") Pet pet, + @RequestBody(description = "Request Body User") final User user) { + return Response.ok().entity("").build(); + } + + @DELETE + @Path("/methodWithOneSimpleRequestBody") + @Operation(summary = "Delete pet", + description = "Deleting pet.") + @Consumes({"application/json", "application/xml"}) + public Response methodWithOneSimpleRequestBody(final int id) { + return Response.ok().entity("").build(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/responses/ComplexResponseResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/responses/ComplexResponseResource.java new file mode 100644 index 0000000000..db25ec92da --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/responses/ComplexResponseResource.java @@ -0,0 +1,34 @@ +package io.swagger.v3.plugins.gradle.petstore.responses; + +import io.swagger.v3.oas.annotations.Operation; +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.plugins.gradle.resources.exception.NotFoundException; +import io.swagger.v3.plugins.gradle.resources.model.Pet; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +/** + * Resource with some responses + */ +public class ComplexResponseResource { + @GET + @Path("/complexresponse") + @Operation(summary = "Find pets", + description = "Returns the Pets", + responses = { + @ApiResponse(description = "Response inside Operation", responseCode = "200", + content = @Content(schema = + @Schema(implementation = Pet.class))), + @ApiResponse(description = "Default Pet", + content = @Content(schema = + @Schema(name = "Default Pet", description = "Default Pet", + required = true, example = "New Pet"))) + }) + @ApiResponse(responseCode = "404", description = "Couldn't find pet") + public Pet getPets() throws NotFoundException { + return new Pet(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/ImplementationResponseResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/responses/ImplementationResponseResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/ImplementationResponseResource.java rename to modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/responses/ImplementationResponseResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/responses/MethodResponseResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/responses/MethodResponseResource.java new file mode 100644 index 0000000000..45eab02a09 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/responses/MethodResponseResource.java @@ -0,0 +1,24 @@ +package io.swagger.v3.plugins.gradle.petstore.responses; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.plugins.gradle.resources.exception.NotFoundException; +import io.swagger.v3.plugins.gradle.resources.model.Pet; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; + +/** + * Resource with a Response at Method Level + */ +public class MethodResponseResource { + @GET + @Path("/responseinmethod") + @Operation(summary = "Find pets", + description = "Returns the Pets") + @ApiResponse(responseCode = "200", description = "Status OK") + public Response getPets() throws NotFoundException { + return Response.ok().entity(new Pet()).build(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/NoImplementationResponseResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/responses/NoImplementationResponseResource.java similarity index 100% rename from modules/swagger-gradle-plugin/src/test/javatest/petstore/responses/NoImplementationResponseResource.java rename to modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/responses/NoImplementationResponseResource.java diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/responses/NoResponseResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/responses/NoResponseResource.java new file mode 100644 index 0000000000..432b452a53 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/responses/NoResponseResource.java @@ -0,0 +1,21 @@ +package io.swagger.v3.plugins.gradle.petstore.responses; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.plugins.gradle.resources.exception.NotFoundException; +import io.swagger.v3.plugins.gradle.resources.model.User; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +/** + * Resource with a Response at Method Level + */ +public class NoResponseResource { + @GET + @Path("/noresponse") + @Operation(summary = "Find pets", + description = "Returns the Pets") + public User getPets() throws NotFoundException { + return new User(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/responses/OperationResponseResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/responses/OperationResponseResource.java new file mode 100644 index 0000000000..38cbbc426e --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/responses/OperationResponseResource.java @@ -0,0 +1,25 @@ +package io.swagger.v3.plugins.gradle.petstore.responses; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.plugins.gradle.resources.exception.NotFoundException; +import io.swagger.v3.plugins.gradle.resources.model.User; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; + +/** + * Resource with the response in the Operation Annotation + */ +public class OperationResponseResource { + @GET + @Path("/responseinoperation") + @Operation(summary = "Find Users", + description = "Returns the Users", + responses = {@ApiResponse(responseCode = "200", description = "Status OK")}) + public Response getUsers() throws NotFoundException { + return Response.ok().entity(new User()).build(); + } + +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/responses/PriorityResponseResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/responses/PriorityResponseResource.java new file mode 100644 index 0000000000..f14c1ff364 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/responses/PriorityResponseResource.java @@ -0,0 +1,25 @@ +package io.swagger.v3.plugins.gradle.petstore.responses; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.plugins.gradle.resources.exception.NotFoundException; +import io.swagger.v3.plugins.gradle.resources.model.Pet; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; + +/** + * Resource with a Response at Method Level and Operation Level. + */ +public class PriorityResponseResource { + @GET + @Path("/priorityresponses") + @Operation(summary = "Find pets", + description = "Returns the Pets", + responses = {@ApiResponse(responseCode = "200", description = "Inside Operation Response")}) + @ApiResponse(responseCode = "200", description = "Inside Method Operation") + public Response getPets() throws NotFoundException { + return Response.ok().entity(new Pet()).build(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/security/SecurityResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/security/SecurityResource.java new file mode 100644 index 0000000000..b24bf3db65 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/security/SecurityResource.java @@ -0,0 +1,61 @@ +package io.swagger.v3.plugins.gradle.petstore.security; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeIn; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.security.OAuthFlow; +import io.swagger.v3.oas.annotations.security.OAuthFlows; +import io.swagger.v3.oas.annotations.security.OAuthScope; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.security.SecurityScheme; + +import javax.ws.rs.GET; +import javax.ws.rs.PATCH; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; + +@SecurityScheme(name = "myOauth2Security", + type = SecuritySchemeType.OAUTH2, + in = SecuritySchemeIn.HEADER, + description = "myOauthSecurity Description", + flows = @OAuthFlows(implicit = @OAuthFlow(authorizationUrl = "http://x.com", + scopes = @OAuthScope( + name = "write:pets", + description = "modify pets in your account")) + ) +) +@SecurityRequirement(name = "security_key", + scopes = {"write:pets", "read:pets"} +) +@SecurityRequirement(name = "myOauth2Security", + scopes = {"write:pets"} +) +@Path("/security") +public class SecurityResource { + @GET + @Operation(operationId = "Operation Id", + description = "description") + @SecurityRequirement(name = "security_key", + scopes = {"write:pets", "read:pets"} + ) + public void getSecurity() { + } + + @PATCH + @Operation(operationId = "Operation Id 2", + description = "description 2") + @SecurityRequirement(name = "security_key2", + scopes = {"write:pets", "read:pets"} + ) + public void getSecurity2() { + } + + @PUT + @Operation(operationId = "Operation Id 3", + description = "description 3", security = + @SecurityRequirement(name = "security_key3", + scopes = {"write:pets", "read:pets"} + )) + public void setSecurity(String security) { + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/tags/CompleteTagResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/tags/CompleteTagResource.java new file mode 100644 index 0000000000..a643d76982 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/tags/CompleteTagResource.java @@ -0,0 +1,31 @@ +package io.swagger.v3.plugins.gradle.petstore.tags; + +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; + +@OpenAPIDefinition(tags = { + @Tag(name = "Definition First Tag"), + @Tag(name = "Definition Second Tag full", description = "desc definition") +}) +@Tag(name = "Second Tag") +@Tag(name = "Fourth Tag Full", description = "desc class", externalDocs = @ExternalDocumentation(description = "docs desc class")) +@Tag(name = "Fifth Tag Full", description = "desc class", externalDocs = @ExternalDocumentation(description = "docs desc class")) +@Tag(name = "Sixth Tag") +public class CompleteTagResource { + + @GET + @Path("/completetags") + @Operation(tags = {"Example Tag", "Second Tag"}) + @Tag(name = "Third Tag") + @Tag(name = "Second Tag") + @Tag(name = "Fourth Tag Full", description = "desc", externalDocs = @ExternalDocumentation(description = "docs desc")) + public Response getTags() { + return Response.ok().entity("ok").build(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/tags/TagClassResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/tags/TagClassResource.java new file mode 100644 index 0000000000..96e3611d62 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/tags/TagClassResource.java @@ -0,0 +1,14 @@ +package io.swagger.v3.plugins.gradle.petstore.tags; + +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.tags.Tag; + +/** + * Class with Tag Annotations at Class level + */ +@Tag(name = "Second Tag") +@Tag(name = "Fourth Tag Full", description = "desc class", externalDocs = @ExternalDocumentation(description = "docs desc class")) +@Tag(name = "Fifth Tag Full", description = "desc class", externalDocs = @ExternalDocumentation(description = "docs desc class")) +@Tag(name = "Sixth Tag") +public class TagClassResource { +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/tags/TagMethodResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/tags/TagMethodResource.java new file mode 100644 index 0000000000..c4c65f146c --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/tags/TagMethodResource.java @@ -0,0 +1,19 @@ +package io.swagger.v3.plugins.gradle.petstore.tags; + +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.tags.Tag; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; + +public class TagMethodResource { + @GET + @Path("/tagsinmethod") + @Tag(name = "Third Tag") + @Tag(name = "Second Tag") + @Tag(name = "Fourth Tag Full", description = "desc", externalDocs = @ExternalDocumentation(description = "docs desc")) + public Response getTags() { + return Response.ok().entity("ok").build(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/tags/TagOpenAPIDefinitionResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/tags/TagOpenAPIDefinitionResource.java new file mode 100644 index 0000000000..0362a7fba5 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/tags/TagOpenAPIDefinitionResource.java @@ -0,0 +1,14 @@ +package io.swagger.v3.plugins.gradle.petstore.tags; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.tags.Tag; + +/** + * Tag in the OpenAPIDefinition annotation + */ +@OpenAPIDefinition(tags = { + @Tag(name = "Definition First Tag"), + @Tag(name = "Definition Second Tag full", description = "desc definition") +}) +public class TagOpenAPIDefinitionResource { +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/tags/TagOperationResource.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/tags/TagOperationResource.java new file mode 100644 index 0000000000..58d67f1b1c --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/petstore/tags/TagOperationResource.java @@ -0,0 +1,20 @@ +package io.swagger.v3.plugins.gradle.petstore.tags; + +import io.swagger.v3.oas.annotations.Operation; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; + +/** + * Resource with a Tag at Operation Level + */ +public class TagOperationResource { + + @GET + @Path("/tagoperation") + @Operation(tags = {"Example Tag", "Second Tag"}) + public Response getTags() { + return Response.ok().entity("ok").build(); + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/QueryResultBean.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/QueryResultBean.java new file mode 100644 index 0000000000..4ce4ed7528 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/QueryResultBean.java @@ -0,0 +1,43 @@ +/** + * Copyright 2016 SmartBear Software + *

      + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

      + * http://www.apache.org/licenses/LICENSE-2.0 + *

      + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugins.gradle.resources; + +import javax.ws.rs.QueryParam; + +public class QueryResultBean { + @QueryParam("skip") + private Integer skip; + + @QueryParam("limit") + private Integer limit; + + public Integer getSkip() { + return skip; + } + + public void setSkip(Integer skip) { + this.skip = skip; + } + + public Integer getLimit() { + return limit; + } + + public void setLimit(Integer limit) { + this.limit = limit; + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/data/PetData.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/data/PetData.java new file mode 100644 index 0000000000..e221796180 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/data/PetData.java @@ -0,0 +1,151 @@ +/** + * Copyright 2016 SmartBear Software + *

      + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

      + * http://www.apache.org/licenses/LICENSE-2.0 + *

      + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugins.gradle.resources.data; + +import io.swagger.v3.plugins.gradle.resources.model.Category; +import io.swagger.v3.plugins.gradle.resources.model.Pet; +import io.swagger.v3.plugins.gradle.resources.model.Tag; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +public class PetData { + static List pets = new ArrayList(); + static List categories = new ArrayList(); + + static { + categories.add(createCategory(1, "Dogs")); + categories.add(createCategory(2, "Cats")); + categories.add(createCategory(3, "Rabbits")); + categories.add(createCategory(4, "Lions")); + + pets.add(createPet(1, categories.get(1), "Cat 1", new String[]{ + "url1", "url2"}, new String[]{"tag1", "tag2"}, "available")); + pets.add(createPet(2, categories.get(1), "Cat 2", new String[]{ + "url1", "url2"}, new String[]{"tag2", "tag3"}, "available")); + pets.add(createPet(3, categories.get(1), "Cat 3", new String[]{ + "url1", "url2"}, new String[]{"tag3", "tag4"}, "pending")); + + pets.add(createPet(4, categories.get(0), "Dog 1", new String[]{ + "url1", "url2"}, new String[]{"tag1", "tag2"}, "available")); + pets.add(createPet(5, categories.get(0), "Dog 2", new String[]{ + "url1", "url2"}, new String[]{"tag2", "tag3"}, "sold")); + pets.add(createPet(6, categories.get(0), "Dog 3", new String[]{ + "url1", "url2"}, new String[]{"tag3", "tag4"}, "pending")); + + pets.add(createPet(7, categories.get(3), "Lion 1", new String[]{ + "url1", "url2"}, new String[]{"tag1", "tag2"}, "available")); + pets.add(createPet(8, categories.get(3), "Lion 2", new String[]{ + "url1", "url2"}, new String[]{"tag2", "tag3"}, "available")); + pets.add(createPet(9, categories.get(3), "Lion 3", new String[]{ + "url1", "url2"}, new String[]{"tag3", "tag4"}, "available")); + + pets.add(createPet(10, categories.get(2), "Rabbit 1", new String[]{ + "url1", "url2"}, new String[]{"tag3", "tag4"}, "available")); + } + + public Pet getPetById(long petId) { + for (Pet pet : pets) { + if (pet.getId() == petId) { + return pet; + } + } + return null; + } + + public List findPetByStatus(String status) { + String[] statues = status.split(","); + List result = new ArrayList(); + for (Pet pet : pets) { + for (String s : statues) { + if (s.equals(pet.getStatus())) { + result.add(pet); + } + } + } + return result; + } + + public List findPetByCategory(Category category) { + return pets.stream().filter(pet -> category.equals(pet.getCategory())).collect(Collectors.toList()); + } + + public List findPetByTags(String tags) { + String[] tagList = tags.split(","); + List result = new ArrayList(); + for (Pet pet : pets) { + if (null != pet.getTags()) { + for (Tag tag : pet.getTags()) { + for (String tagListString : tagList) { + if (tagListString.equals(tag.getName())) { + result.add(pet); + } + } + } + } + } + return result; + } + + public void addPet(Pet pet) { + if (pets.size() > 0) { + for (int i = pets.size() - 1; i >= 0; i--) { + if (pets.get(i).getId() == pet.getId()) { + pets.remove(i); + } + } + } + pets.add(pet); + } + + static Pet createPet(long id, Category cat, String name, String[] urls, + String[] tags, String status) { + Pet pet = new Pet(); + pet.setId(id); + pet.setCategory(cat); + pet.setName(name); + if (null != urls) { + List urlObjs = new ArrayList(); + for (String urlString : urls) { + urlObjs.add(urlString); + } + pet.setPhotoUrls(urlObjs); + } + List tagObjs = new ArrayList(); + int i = 0; + if (null != tags) { + for (String tagString : tags) { + i = i + 1; + Tag tag = new Tag(); + tag.setId(i); + tag.setName(tagString); + tagObjs.add(tag); + } + } + pet.setTags(tagObjs); + pet.setStatus(status); + return pet; + } + + static Category createCategory(long id, String name) { + Category category = new Category(); + category.setId(id); + category.setName(name); + return category; + } +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/data/UserData.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/data/UserData.java new file mode 100644 index 0000000000..a23afc1ded --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/data/UserData.java @@ -0,0 +1,98 @@ +/** + * Copyright 2016 SmartBear Software + *

      + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

      + * http://www.apache.org/licenses/LICENSE-2.0 + *

      + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugins.gradle.resources.data; + +import io.swagger.v3.plugins.gradle.resources.model.User; + +import java.util.ArrayList; +import java.util.List; + +public class UserData { + static List users = new ArrayList(); + + static { + users.add(createUser(1, "user1", "first name 1", "last name 1", + "email1@test.com", "123-456-7890", 1)); + users.add(createUser(2, "user2", "first name 2", "last name 2", + "email2@test.com", "123-456-7890", 2)); + users.add(createUser(3, "user3", "first name 3", "last name 3", + "email3@test.com", "123-456-7890", 3)); + users.add(createUser(4, "user4", "first name 4", "last name 4", + "email4@test.com", "123-456-7890", 1)); + users.add(createUser(5, "user5", "first name 5", "last name 5", + "email5@test.com", "123-456-7890", 2)); + users.add(createUser(6, "user6", "first name 6", "last name 6", + "email6@test.com", "123-456-7890", 3)); + users.add(createUser(7, "user7", "first name 7", "last name 7", + "email7@test.com", "123-456-7890", 1)); + users.add(createUser(8, "user8", "first name 8", "last name 8", + "email8@test.com", "123-456-7890", 2)); + users.add(createUser(9, "user9", "first name 9", "last name 9", + "email9@test.com", "123-456-7890", 3)); + users.add(createUser(10, "user10", "first name 10", "last name 10", + "email10@test.com", "123-456-7890", 1)); + users.add(createUser(11, "user?10", "first name ?10", "last name ?10", + "email101@test.com", "123-456-7890", 1)); + + } + + public User findUserByName(String username) { + for (User user : users) { + if (user.getUsername().equals(username)) { + return user; + } + } + return null; + } + + public void addUser(User user) { + if (users.size() > 0) { + for (int i = users.size() - 1; i >= 0; i--) { + if (users.get(i).getUsername().equals(user.getUsername())) { + users.remove(i); + } + } + } + users.add(user); + } + + public boolean removeUser(String username) { + if (users.size() > 0) { + for (int i = users.size() - 1; i >= 0; i--) { + if (users.get(i).getUsername().equals(username)) { + users.remove(i); + return true; + } + } + } + return false; + } + + private static User createUser(long id, String username, String firstName, + String lastName, String email, String phone, int userStatus) { + User user = new User(); + user.setId(id); + user.setUsername(username); + user.setFirstName(firstName); + user.setLastName(lastName); + user.setEmail(email); + user.setPassword("XXXXXXXXXXX"); + user.setPhone(phone); + user.setUserStatus(userStatus); + return user; + } +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/exception/ApiException.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/exception/ApiException.java new file mode 100644 index 0000000000..5fd6be63d7 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/exception/ApiException.java @@ -0,0 +1,26 @@ +/** + * Copyright 2016 SmartBear Software + *

      + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

      + * http://www.apache.org/licenses/LICENSE-2.0 + *

      + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugins.gradle.resources.exception; + +public class ApiException extends Exception { + private int code; + + public ApiException(int code, String msg) { + super(msg); + this.code = code; + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/exception/NotFoundException.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/exception/NotFoundException.java new file mode 100644 index 0000000000..545e6a9940 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/exception/NotFoundException.java @@ -0,0 +1,26 @@ +/** + * Copyright 2016 SmartBear Software + *

      + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

      + * http://www.apache.org/licenses/LICENSE-2.0 + *

      + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugins.gradle.resources.exception; + +public class NotFoundException extends ApiException { + private int code; + + public NotFoundException(int code, String msg) { + super(code, msg); + this.code = code; + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/Category.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/Category.java new file mode 100644 index 0000000000..a973cb86d4 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/Category.java @@ -0,0 +1,51 @@ +/** + * Copyright 2016 SmartBear Software + *

      + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

      + * http://www.apache.org/licenses/LICENSE-2.0 + *

      + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugins.gradle.resources.model; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "Category") +public class Category { + private long id; + private String name; + + @XmlElement(name = "id") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @XmlElement(name = "name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Category() { + } + + public Category(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/CustomGenerator.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/CustomGenerator.java new file mode 100644 index 0000000000..c41bf37d3b --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/CustomGenerator.java @@ -0,0 +1,32 @@ +package io.swagger.v3.plugins.gradle.resources.model; + +import com.fasterxml.jackson.annotation.ObjectIdGenerator; +import com.fasterxml.jackson.annotation.ObjectIdGenerators; + +public class CustomGenerator extends ObjectIdGenerators.PropertyGenerator { + private static final long serialVersionUID = 1L; + + protected CustomGenerator(Class scope) { + super(scope); + } + + @Override + public ObjectIdGenerator forScope(Class scope) { + return null; + } + + @Override + public ObjectIdGenerator newForSerialization(Object context) { + return null; + } + + @Override + public IdKey key(Object key) { + return null; + } + + @Override + public Object generateId(Object forPojo) { + return null; + } +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/ExtensionUser.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/ExtensionUser.java new file mode 100644 index 0000000000..9615b3b170 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/ExtensionUser.java @@ -0,0 +1,130 @@ +/** + * Copyright 2016 SmartBear Software + *

      + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

      + * http://www.apache.org/licenses/LICENSE-2.0 + *

      + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugins.gradle.resources.model; + +import io.swagger.v3.oas.annotations.extensions.Extension; +import io.swagger.v3.oas.annotations.extensions.ExtensionProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "User") +@Schema( + description = "User", + extensions = { + @Extension(name = "x-user", properties = { + @ExtensionProperty(name = "name", value = "Josh")}), + @Extension(name = "user-extensions", properties = { + @ExtensionProperty(name = "lastName", value = "Hart"), + @ExtensionProperty(name = "address", value = "House")}) + } +) +public class ExtensionUser { + private long id; + private String username; + private String firstName; + private String lastName; + private String email; + private String password; + private String phone; + private int userStatus; + + @XmlElement(name = "id") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @XmlElement(name = "firstName") + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + @XmlElement(name = "username") + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + @XmlElement(name = "lastName") + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + @XmlElement(name = "email") + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + @XmlElement(name = "password") + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @XmlElement(name = "phone") + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + @XmlElement(name = "userStatus") + //@Schema(description = "User Status", type = "string", allowableValues = {"1-registered", "2-active", "3-closed"}) + @Schema( + description = "User Status", + allowableValues = "1-registered,2-active,3-closed", + extensions = { + @Extension(name = "x-userStatus", properties = { + @ExtensionProperty(name = "name", value = "Josh")}), + @Extension(name = "userStatus-extensions", properties = { + @ExtensionProperty(name = "lastName", value = "Hart"), + @ExtensionProperty(name = "address", value = "House")}) + } + ) + public int getUserStatus() { + return userStatus; + } + + public void setUserStatus(int userStatus) { + this.userStatus = userStatus; + } +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/JacksonBean.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/JacksonBean.java new file mode 100644 index 0000000000..6ab65aa81a --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/JacksonBean.java @@ -0,0 +1,76 @@ +package io.swagger.v3.plugins.gradle.resources.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonUnwrapped; +import com.fasterxml.jackson.annotation.JsonValue; + +public class JacksonBean { + + private String id; + private String ignored; + private StringValueBean bean; + private NotFoundModel model; + private NotFoundModel model2; + + @JsonIgnore + public String getIgnored() { + return ignored; + } + + public void setIgnored(String ignored) { + this.ignored = ignored; + } + + public void setId(String id) { + this.id = id; + } + + public void setModel(NotFoundModel model) { + this.model = model; + } + + public StringValueBean getBean() { + return bean; + } + + public void setBean(StringValueBean bean) { + this.bean = bean; + } + + @JsonProperty("identity") + public String getId() { + return id; + } + + @JsonUnwrapped + public NotFoundModel getModel() { + return model; + } + + @JsonUnwrapped(prefix = "pre", suffix = "suf") + public NotFoundModel getModel2() { + return model2; + } + + public void setModel2(NotFoundModel model2) { + this.model2 = model2; + } + + public static class StringValueBean { + + private final String value; + + @JsonCreator + public StringValueBean(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + } + +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/ListOfStringsBeanParam.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/ListOfStringsBeanParam.java new file mode 100644 index 0000000000..d002e3c4ff --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/ListOfStringsBeanParam.java @@ -0,0 +1,17 @@ +package io.swagger.v3.plugins.gradle.resources.model; + +import javax.ws.rs.QueryParam; +import java.util.List; + +public class ListOfStringsBeanParam { + @QueryParam(value = "listOfStrings") + private List list; + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/ModelWithJsonIdentity.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/ModelWithJsonIdentity.java new file mode 100644 index 0000000000..72470ea57f --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/ModelWithJsonIdentity.java @@ -0,0 +1,145 @@ +package io.swagger.v3.plugins.gradle.resources.model; + +import com.fasterxml.jackson.annotation.JsonIdentityInfo; +import com.fasterxml.jackson.annotation.JsonIdentityReference; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.ObjectIdGenerators; + +public class ModelWithJsonIdentity { + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "name") + @JsonProperty("PropertyGeneratorAsId") + public SourceDefinition1 testPropertyGeneratorAsId; + + @JsonIdentityReference(alwaysAsId = false) + @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "name") + @JsonProperty("PropertyGeneratorAsProperty") + public SourceDefinition1 testPropertyGeneratorAsProperty; + + public class SourceDefinition1 { + public String driver; + public String name; + } + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "driverId") + @JsonProperty("ChangedPropertyName") + public SourceDefinition2 testChangedPropertyName; + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "driverId") + @JsonProperty("ChangedPropertyName2") + public SourceDefinition2 testChangedPropertyName2; + + static public class SourceDefinition2 { + @JsonProperty("driverId") + public String driver; + public String name; + } + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class) + @JsonProperty("SourceWithoutPropertyAsId") + public SourceDefinition3 testWithoutPropertyAsId; + + @JsonIdentityReference(alwaysAsId = false) + @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class) + @JsonProperty("SourceWithoutPropertyAsProperty") + public SourceDefinition3 testWithoutPropertyAsProperty; + + public class SourceDefinition3 { + @JsonProperty("driverId") + public String driver; + public String name; + + @JsonProperty("@id") + public String id; + } + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, property = "testName1") + @JsonProperty("IntSequenceGeneratorAsId") + public SourceDefinition4 testIntSequenceGeneratorAsId; + + @JsonIdentityReference(alwaysAsId = false) + @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, property = "testName2") + @JsonProperty("IntSequenceGeneratorAsProperty") + public SourceDefinition4 testIntSequenceGeneratorAsProperty; + + public class SourceDefinition4 { + public String name; + } + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class) + @JsonProperty("IntSequenceWithoutPropertyAsId") + public SourceDefinition5 testIntSequenceWithoutPropertyAsId; + + @JsonIdentityReference(alwaysAsId = false) + @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class) + @JsonProperty("IntSequenceWithoutPropertyAsProperty") + public SourceDefinition5 testIntSequenceWithoutPropertyAsProperty; + + public class SourceDefinition5 { + public String name; + } + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class, property = "UUID1") + @JsonProperty("UUIDGeneratorAsId") + public SourceDefinition6 testUUIDGeneratorAsId; + + @JsonIdentityReference(alwaysAsId = false) + @JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class, property = "UUID2") + @JsonProperty("UUIDGeneratorAsProperty") + public SourceDefinition6 testUUIDGeneratorAsProperty; + + public class SourceDefinition6 { + public String name; + } + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class) + @JsonProperty("UUIDGeneratorWithoutPropertyAsId") + public SourceDefinition7 testUUIDGeneratorWithoutPropertyAsId; + + @JsonIdentityReference(alwaysAsId = false) + @JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class) + @JsonProperty("UUIDGeneratorWithoutPropertyAsProperty") + public SourceDefinition7 testUUIDGeneratorWithoutPropertyAsProperty; + + public class SourceDefinition7 { + public String name; + } + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = ObjectIdGenerators.None.class, property = "testGeneratorsNone") + @JsonProperty("GeneratorsNone") + public SourceDefinition8 testGeneratorsNone; + + public class SourceDefinition8 { + @JsonProperty("driverId") + public String driver; + public String name; + } + + @JsonIdentityReference(alwaysAsId = true) + @JsonIdentityInfo(generator = CustomGenerator.class, property = "name") + @JsonProperty("CustomGenerator") + public SourceDefinition9 testCustomGenerator; + + public class SourceDefinition9 { + public String driver; + public String name; + } + + @JsonIdentityInfo(generator = CustomGenerator.class, property = "name") + @JsonProperty("WithoutJsonIdentityReference") + public SourceDefinition10 testWithoutJsonIdentityReference; + + public class SourceDefinition10 { + public String driver; + public String name; + } +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/ModelWithJsonIdentityCyclic.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/ModelWithJsonIdentityCyclic.java new file mode 100644 index 0000000000..e20f5fcf95 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/ModelWithJsonIdentityCyclic.java @@ -0,0 +1,29 @@ +package io.swagger.v3.plugins.gradle.resources.model; + +import com.fasterxml.jackson.annotation.JsonIdentityInfo; +import com.fasterxml.jackson.annotation.JsonIdentityReference; +import com.fasterxml.jackson.annotation.ObjectIdGenerators; + +import java.util.List; + +public class ModelWithJsonIdentityCyclic { + + public Long id; + + public List sourceDefinitions; + + @JsonIdentityInfo( + generator = ObjectIdGenerators.PropertyGenerator.class, + property = "name") + public static class SourceDefinition { + public String driver; + public String name; + + @JsonIdentityReference(alwaysAsId=true) + @JsonIdentityInfo( + generator = ObjectIdGenerators.PropertyGenerator.class, + property = "id") + public ModelWithJsonIdentityCyclic model; + } + +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/MultipleBaseBean.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/MultipleBaseBean.java new file mode 100644 index 0000000000..0d5966fa1e --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/MultipleBaseBean.java @@ -0,0 +1,11 @@ +package io.swagger.v3.plugins.gradle.resources.model; + +@io.swagger.v3.oas.annotations.media.Schema( + description = "MultipleBaseBean", + subTypes = { MultipleSub1Bean.class, MultipleSub2Bean.class } +) +public class MultipleBaseBean { + public String beanType; + public int a; + public String b; +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/MultipleSub1Bean.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/MultipleSub1Bean.java new file mode 100644 index 0000000000..c1a03258d0 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/MultipleSub1Bean.java @@ -0,0 +1,8 @@ +package io.swagger.v3.plugins.gradle.resources.model; + +@io.swagger.v3.oas.annotations.media.Schema( + description = "MultipleSub1Bean" +) +public class MultipleSub1Bean extends MultipleBaseBean { + public int c; +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/MultipleSub2Bean.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/MultipleSub2Bean.java new file mode 100644 index 0000000000..763e5f0454 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/MultipleSub2Bean.java @@ -0,0 +1,8 @@ +package io.swagger.v3.plugins.gradle.resources.model; + +@io.swagger.v3.oas.annotations.media.Schema( + description = "MultipleSub2Bean" +) +public class MultipleSub2Bean extends MultipleBaseBean { + public int d; +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/NotFoundModel.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/NotFoundModel.java new file mode 100644 index 0000000000..73e0b3f95c --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/NotFoundModel.java @@ -0,0 +1,30 @@ +package io.swagger.v3.plugins.gradle.resources.model; + +public class NotFoundModel { + int code; + String message; + + public NotFoundModel() { + } + + public NotFoundModel(int code, String message) { + this.code = code; + this.message = message; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/Pet.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/Pet.java new file mode 100644 index 0000000000..0cf61e4857 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/Pet.java @@ -0,0 +1,76 @@ +package io.swagger.v3.plugins.gradle.resources.model; + +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.List; + +@XmlRootElement(name = "Pet") +public class Pet { + private long id; + private Category category; + private String name; + private List photoUrls = new ArrayList(); + private List tags = new ArrayList(); + private String status; + + @XmlElement(name = "id") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @XmlElement(name = "category") + public Category getCategory() { + return category; + } + + public void setCategory(Category category) { + this.category = category; + } + + @XmlElement(name = "name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @XmlElementWrapper(name = "photoUrls") + @XmlElement(name = "photoUrl") + public List getPhotoUrls() { + return photoUrls; + } + + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + @XmlElementWrapper(name = "tags") + @XmlElement(name = "tag") + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + @XmlElement(name = "status") + @Schema(description = "pet status in the store", allowableValues = "available,pending,sold") + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/Tag.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/Tag.java new file mode 100644 index 0000000000..107de03ebf --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/Tag.java @@ -0,0 +1,44 @@ +/** + * Copyright 2016 SmartBear Software + *

      + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

      + * http://www.apache.org/licenses/LICENSE-2.0 + *

      + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugins.gradle.resources.model; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "Tag") +public class Tag { + private long id; + private String name; + + @XmlElement(name = "id") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @XmlElement(name = "name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/User.java b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/User.java new file mode 100644 index 0000000000..ae67103476 --- /dev/null +++ b/modules/swagger-gradle-plugin/src/test/javatest/io/swagger/v3/plugins/gradle/resources/model/User.java @@ -0,0 +1,108 @@ +/** + * Copyright 2016 SmartBear Software + *

      + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

      + * http://www.apache.org/licenses/LICENSE-2.0 + *

      + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.v3.plugins.gradle.resources.model; + +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "User") +public class User { + private long id; + private String username; + private String firstName; + private String lastName; + private String email; + private String password; + private String phone; + private int userStatus; + + @XmlElement(name = "id") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @XmlElement(name = "firstName") + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + @XmlElement(name = "username") + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + @XmlElement(name = "lastName") + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + @XmlElement(name = "email") + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + @XmlElement(name = "password") + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @XmlElement(name = "phone") + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + @XmlElement(name = "userStatus") + //@Schema(description = "User Status", type = "string", allowableValues = {"1-registered", "2-active", "3-closed"}) + @Schema(description = "User Status", allowableValues = "1-registered,2-active,3-closed") + public int getUserStatus() { + return userStatus; + } + + public void setUserStatus(int userStatus) { + this.userStatus = userStatus; + } +} \ No newline at end of file diff --git a/modules/swagger-jaxrs2/src/main/java/io/swagger/v3/jaxrs2/integration/SwaggerLoader.java b/modules/swagger-jaxrs2/src/main/java/io/swagger/v3/jaxrs2/integration/SwaggerLoader.java index 1df77b0429..7e18db375c 100644 --- a/modules/swagger-jaxrs2/src/main/java/io/swagger/v3/jaxrs2/integration/SwaggerLoader.java +++ b/modules/swagger-jaxrs2/src/main/java/io/swagger/v3/jaxrs2/integration/SwaggerLoader.java @@ -26,6 +26,8 @@ public class SwaggerLoader { private Boolean readAllResources = Boolean.TRUE; private String ignoredRoutes; + private String openapiAsString; + public String getOutputFormat() { return outputFormat; } @@ -98,6 +100,15 @@ public void setIgnoredRoutes(String ignoredRoutes) { this.ignoredRoutes = ignoredRoutes; } + public String getOpenapiAsString() { + return openapiAsString; + } + + public void setOpenapiAsString(String openapiAsString) { + this.openapiAsString = openapiAsString; + } + + public Map resolve() throws Exception{ Set ignoredRoutesSet = null; @@ -113,17 +124,30 @@ public Map resolve() throws Exception{ resourcePackagesSet = new HashSet<>(Arrays.asList(resourcePackages.split(","))); } + OpenAPI openAPIInput = null; + if (StringUtils.isNotBlank(openapiAsString)) { + try { + openAPIInput = Json.mapper().readValue(openapiAsString, OpenAPI.class); + } catch (Exception e) { + try { + openAPIInput = Yaml.mapper().readValue(openapiAsString, OpenAPI.class); + } catch (Exception e1) { + throw new Exception("Error reading/deserializing openapi input: " + e.getMessage(), e); + } + } + } + SwaggerConfiguration config = new SwaggerConfiguration() .filterClass(filterClass) .ignoredRoutes(ignoredRoutesSet) .prettyPrint(prettyPrint) .readAllResources(readAllResources) + .openAPI(openAPIInput) .readerClass(readerClass) .scannerClass(scannerClass) .resourceClasses(resourceClassesSet) .resourcePackages(resourcePackagesSet); try { - OpenAPI openAPI = new JaxrsOpenApiContextBuilder() .openApiConfiguration(config) .buildContext(true) From 8e52b3308c7038f5dc94f6a3cec0e54b2ae91f67 Mon Sep 17 00:00:00 2001 From: frantuma Date: Fri, 14 Sep 2018 15:16:04 +0200 Subject: [PATCH 5/7] encoding support in maven and gradle plugin --- modules/swagger-gradle-plugin/README.md | 3 ++- .../v3/plugins/gradle/tasks/ResolveTask.java | 19 +++++++++++--- modules/swagger-maven-plugin/README.md | 3 ++- modules/swagger-maven-plugin/pom.xml | 1 + .../swagger/v3/plugin/maven/SwaggerMojo.java | 25 ++++++++++++++++--- .../src/test/resources/pom.resolveToFile.xml | 3 +++ 6 files changed, 46 insertions(+), 8 deletions(-) diff --git a/modules/swagger-gradle-plugin/README.md b/modules/swagger-gradle-plugin/README.md index 5591d2adf9..bc24927386 100644 --- a/modules/swagger-gradle-plugin/README.md +++ b/modules/swagger-gradle-plugin/README.md @@ -29,7 +29,7 @@ apply plugin: "io.swagger.core.v3.swagger-gradle-plugin" ### resolve * Resolves project openAPI specification and saves the result in JSON, YAML or both formats. -All parameters except `outputFileName`, `outputFormat`, `classpath` `skip` and `outputPath` correspond +All parameters except `outputFileName`, `outputFormat`, `classpath`, `skip`, `encoding` and `outputPath` correspond to `swagger` [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties) with same name. #### Example Usage @@ -54,6 +54,7 @@ Parameter | Description | Required | Default `outputFileName`|file name (no extension)|false|`openapi` `outputFormat`|file format (`JSON`, `YAML`, `JSONANDYAML`|false|`JSON` `skip`|if `TRUE` skip execution|false|`FALSE` +`encoding`|encoding of output file(s)|false| `resourcePackages`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| `resourceClasses`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| `prettyPrint`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false|`TRUE` diff --git a/modules/swagger-gradle-plugin/src/main/java/io/swagger/v3/plugins/gradle/tasks/ResolveTask.java b/modules/swagger-gradle-plugin/src/main/java/io/swagger/v3/plugins/gradle/tasks/ResolveTask.java index 62007c4c5d..ae27874d40 100644 --- a/modules/swagger-gradle-plugin/src/main/java/io/swagger/v3/plugins/gradle/tasks/ResolveTask.java +++ b/modules/swagger-gradle-plugin/src/main/java/io/swagger/v3/plugins/gradle/tasks/ResolveTask.java @@ -56,6 +56,8 @@ public enum Format {JSON, YAML, JSONANDYAML}; private Boolean skip = Boolean.FALSE; + private String encoding = "UTF-8"; + @Input @Optional public String getOutputFileName() { @@ -217,6 +219,17 @@ public void setSkip(Boolean skip) { this.skip = skip; } + @Input + @Optional + public String getEncoding() { + return encoding; + } + + public void setEncoding(String resourceClasses) { + this.encoding = encoding; + } + + @TaskAction public void resolve() throws GradleException { if (skip) { @@ -260,7 +273,7 @@ public void resolve() throws GradleException { if (openApiFile != null) { if (openApiFile.exists() && openApiFile.isFile()) { - String openapiFileContent = new String(Files.readAllBytes(openApiFile.toPath()), "UTF-8"); + String openapiFileContent = new String(Files.readAllBytes(openApiFile.toPath()), encoding); if (StringUtils.isNotBlank(openapiFileContent)) { method=swaggerLoaderClass.getDeclaredMethod("setOpenapiAsString",String.class); method.invoke(swaggerLoader, openapiFileContent); @@ -312,11 +325,11 @@ public void resolve() throws GradleException { } if (specs.get("JSON") != null) { path = Paths.get(outputPath, outputFileName + ".json"); - Files.write(path, specs.get("JSON").getBytes(Charset.forName("UTF-8"))); + Files.write(path, specs.get("JSON").getBytes(Charset.forName(encoding))); } if (specs.get("YAML") != null) { path = Paths.get(outputPath, outputFileName + ".yaml"); - Files.write(path, specs.get("YAML").getBytes(Charset.forName("UTF-8"))); + Files.write(path, specs.get("YAML").getBytes(Charset.forName(encoding))); } } catch (IOException e) { throw new GradleException("Failed to write API definition: " + e.getMessage(), e); diff --git a/modules/swagger-maven-plugin/README.md b/modules/swagger-maven-plugin/README.md index d2f88432da..292f29f01b 100644 --- a/modules/swagger-maven-plugin/README.md +++ b/modules/swagger-maven-plugin/README.md @@ -1,7 +1,7 @@ # swagger-maven-plugin * Resolves project openAPI specification and saves the result in JSON, YAML or both formats. -All parameters except `outputFileName`, `outputFormat` `skip` and `outputPath` correspond +All parameters except `outputFileName`, `outputFormat`, `skip`, `encoding` and `outputPath` correspond to `swagger` [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties) with same name. ## Configuration example @@ -64,6 +64,7 @@ Parameter | Description | Required | Default `outputFileName`|file name (no extension)|false|`openapi` `outputFormat`|file format (`JSON`, `YAML`, `JSONANDYAML`|false|`JSON` `skip`|if `TRUE` skip execution|false|`FALSE` +`encoding`|encoding of output file(s)|false| `resourcePackages`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| `resourceClasses`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false| `prettyPrint`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false|`TRUE` diff --git a/modules/swagger-maven-plugin/pom.xml b/modules/swagger-maven-plugin/pom.xml index bec60ac7bc..453a215634 100644 --- a/modules/swagger-maven-plugin/pom.xml +++ b/modules/swagger-maven-plugin/pom.xml @@ -169,6 +169,7 @@ + UTF-8 3.5.0 4.12 diff --git a/modules/swagger-maven-plugin/src/main/java/io/swagger/v3/plugin/maven/SwaggerMojo.java b/modules/swagger-maven-plugin/src/main/java/io/swagger/v3/plugin/maven/SwaggerMojo.java index 3c5f0c52cb..79dd428c19 100644 --- a/modules/swagger-maven-plugin/src/main/java/io/swagger/v3/plugin/maven/SwaggerMojo.java +++ b/modules/swagger-maven-plugin/src/main/java/io/swagger/v3/plugin/maven/SwaggerMojo.java @@ -13,6 +13,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.project.MavenProject; import org.codehaus.plexus.util.StringUtils; import java.io.File; @@ -43,12 +44,22 @@ public void execute() throws MojoExecutionException, MojoFailureException } getLog().info( "Resolving OpenAPI specification.." ); + if(project !=null) { + String pEnc = project.getProperties().getProperty("project.build.sourceEncoding"); + if (StringUtils.isNotBlank(pEnc)) { + projectEncoding = pEnc; + } + } + if (StringUtils.isBlank(encoding)) { + encoding = projectEncoding; + } + OpenAPI openAPIInput = null; try { if (StringUtils.isNotBlank(openapiFilePath)) { Path openapiPath = Paths.get(openapiFilePath); if (openapiPath.toFile().exists() && openapiPath.toFile().isFile()) { - String openapiFileContent = new String(Files.readAllBytes(openapiPath), "UTF-8"); + String openapiFileContent = new String(Files.readAllBytes(openapiPath), encoding); if (StringUtils.isNotBlank(openapiFileContent)) { try { openAPIInput = Json.mapper().readValue(openapiFileContent, OpenAPI.class); @@ -109,11 +120,11 @@ public void execute() throws MojoExecutionException, MojoFailureException if (openapiJson != null) { path = Paths.get(outputPath, outputFileName + ".json"); - Files.write(path, openapiJson.getBytes(Charset.forName("UTF-8"))); + Files.write(path, openapiJson.getBytes(Charset.forName(encoding))); } if (openapiYaml != null) { path = Paths.get(outputPath, outputFileName + ".yaml"); - Files.write(path, openapiYaml.getBytes(Charset.forName("UTF-8"))); + Files.write(path, openapiYaml.getBytes(Charset.forName(encoding))); } } catch (OpenApiConfigurationException e) { @@ -160,6 +171,14 @@ public void execute() throws MojoExecutionException, MojoFailureException @Parameter( property = "resolve.openapiFilePath") private String openapiFilePath; + @Parameter(defaultValue = "${project}", readonly = true) + private MavenProject project; + + @Parameter( property = "resolve.encoding" ) + private String encoding; + + private String projectEncoding = "UTF-8"; + public String getOutputPath() { return outputPath; } diff --git a/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFile.xml b/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFile.xml index 329e7229cf..9cd84a64d8 100644 --- a/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFile.xml +++ b/modules/swagger-maven-plugin/src/test/resources/pom.resolveToFile.xml @@ -45,4 +45,7 @@ + + ISO-8859-1 + \ No newline at end of file From cac9f4aba569da9a0feb9bae5a80c46022c9e3f9 Mon Sep 17 00:00:00 2001 From: frantuma Date: Wed, 19 Sep 2018 12:33:29 +0200 Subject: [PATCH 6/7] updated com.gradle.plugin-publish version --- modules/swagger-gradle-plugin/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-gradle-plugin/build.gradle b/modules/swagger-gradle-plugin/build.gradle index 947190a3b2..2e475d5180 100644 --- a/modules/swagger-gradle-plugin/build.gradle +++ b/modules/swagger-gradle-plugin/build.gradle @@ -6,7 +6,7 @@ plugins { id 'java-gradle-plugin' id 'net.researchgate.release' version '2.6.0' // Publishing publicly - id 'com.gradle.plugin-publish' version '0.9.10' + id 'com.gradle.plugin-publish' version '0.10.0' // Publishing to maven id 'maven-publish' } From 4288f962fd885af0a8c3d3870592c95ade0cb81a Mon Sep 17 00:00:00 2001 From: frantuma Date: Wed, 19 Sep 2018 12:44:12 +0200 Subject: [PATCH 7/7] fixes wiki link in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6ac8f6ff8a..306b6dbf3a 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Swagger-core is the Java implementation of Swagger. Current version supports *JA Check out the [OpenAPI Specification](https://github.com/OAI/OpenAPI-Specification) for additional information about the Swagger project. ## Get started with Swagger! -See the guide on [getting started with swagger](https://github.com/frantuma/swagger-core/wiki/Swagger-2.X---Getting-started) to get started with adding swagger to your API. +See the guide on [getting started with swagger](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Getting-started) to get started with adding swagger to your API. ## See the Wiki! The [github wiki](https://github.com/swagger-api/swagger-core/wiki) contains documentation, samples, contributions, etc. Start there.