You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by em...@apache.org on 2022/09/29 06:54:32 UTC
[cxf] 01/02: CXF-8714: Migration path for Swagger v1.x
This is an automated email from the ASF dual-hosted git repository.
ema pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 3a9583d5edf20a16dd2fa739a9fb8fbce8168a23
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Mon Sep 26 20:04:36 2022 -0400
CXF-8714: Migration path for Swagger v1.x
---
bom/pom.xml | 5 -
distribution/javadoc/pom.xml | 5 -
.../samples/jax_rs/description_swagger2/README.txt | 43 --
.../samples/jax_rs/description_swagger2/pom.xml | 92 ---
.../demo/jaxrs/swagger/server/ApiOriginFilter.java | 45 --
.../main/java/demo/jaxrs/swagger/server/Item.java | 49 --
.../java/demo/jaxrs/swagger/server/Sample.java | 154 ----
.../java/demo/jaxrs/swagger/server/Server.java | 64 --
.../resources/META-INF/cxf/org.apache.cxf.Logger | 1 -
.../src/main/resources/logback.xml | 16 -
.../jax_rs/description_swagger2_spring/README.txt | 42 --
.../jax_rs/description_swagger2_spring/pom.xml | 102 ---
.../demo/jaxrs/swagger/server/ApiOriginFilter.java | 45 --
.../main/java/demo/jaxrs/swagger/server/Item.java | 49 --
.../java/demo/jaxrs/swagger/server/Sample.java | 140 ----
.../java/demo/jaxrs/swagger/server/Server.java | 39 --
.../resources/META-INF/cxf/org.apache.cxf.Logger | 1 -
.../src/main/resources/context.xml | 64 --
.../src/main/resources/logback.xml | 16 -
.../jax_rs/description_swagger2_web/README.txt | 47 --
.../jax_rs/description_swagger2_web/pom.xml | 95 ---
.../demo/jaxrs/swagger/server/ApiOriginFilter.java | 45 --
.../main/java/demo/jaxrs/swagger/server/Item.java | 49 --
.../java/demo/jaxrs/swagger/server/Sample.java | 140 ----
.../java/demo/jaxrs/swagger/server/Sample2.java | 140 ----
.../src/main/webapp/WEB-INF/context.xml | 87 ---
.../src/main/webapp/WEB-INF/web.xml | 41 --
.../jax_rs/spring_boot_scan/application/pom.xml | 5 -
distribution/src/main/release/samples/pom.xml | 3 -
maven-plugins/java2swagger-plugin/pom.xml | 221 ------
.../java2swagger/Java2SwaggerMojo.java | 301 --------
.../META-INF/m2e/lifecycle-mapping-metadata.xml | 35 -
maven-plugins/pom.xml | 1 -
parent/pom.xml | 8 -
rt/rs/description-swagger/pom.xml | 89 ---
.../cxf/jaxrs/swagger/AbstractSwaggerFeature.java | 308 --------
.../cxf/jaxrs/swagger/ApplicationBeanConfig.java | 42 --
.../apache/cxf/jaxrs/swagger/JaxRs2Extension.java | 230 ------
.../apache/cxf/jaxrs/swagger/MatrixParameter.java | 28 -
.../jaxrs/swagger/Swagger2ApiListingResource.java | 47 --
.../cxf/jaxrs/swagger/Swagger2Customizer.java | 232 ------
.../apache/cxf/jaxrs/swagger/Swagger2Feature.java | 693 ------------------
.../org/apache/cxf/jaxrs/swagger/SwaggerUi.java | 57 --
.../swagger/openapi/OpenApiConfiguration.java | 31 -
.../openapi/SwaggerToOpenApiConversionFilter.java | 81 ---
.../openapi/SwaggerToOpenApiConversionUtils.java | 414 -----------
.../jaxrs/swagger/parse/ParseConfiguration.java | 25 -
.../cxf/jaxrs/swagger/parse/SwaggerParseUtils.java | 209 ------
.../services/io.swagger.jaxrs.ext.SwaggerExtension | 1 -
.../cxf/jaxrs/swagger/Swagger2FeatureTest.java | 55 --
.../SwaggerToOpenApiConversionUtilsTest.java | 780 ---------------------
.../jaxrs/swagger/parse/SwaggerParseUtilsTest.java | 499 -------------
.../src/test/resources/swagger20.json | 48 --
.../src/test/resources/swagger20NoTags.json | 43 --
.../test/resources/swagger20TagsPathsMismatch.json | 48 --
.../src/test/resources/swagger2petShop.json | 741 --------------------
.../swagger2petShopWithNullOperations.json | 742 --------------------
rt/rs/pom.xml | 11 -
systests/jaxrs/pom.xml | 12 -
.../AbstractSwagger2ServiceDescriptionTest.java | 279 --------
.../description/BookStoreStylesheetsSwagger2.java | 37 -
.../jaxrs/description/BookStoreSwagger2.java | 81 ---
.../description/Swagger2CustomPropertiesTest.java | 69 --
.../Swagger2FilterServiceDescriptionTest.java | 56 --
...Swagger2NonAnnotatedServiceDescriptionTest.java | 84 ---
.../Swagger2RegularServiceDescriptionTest.java | 56 --
.../systest/jaxrs/description/Swagger2Server.java | 45 --
.../Swagger2XForwardedDescriptionTest.java | 62 --
.../SwaggerToOpenApiConversionTest.java | 262 -------
.../jaxrs/description/group1/BookStore.java | 3 -
.../AbstractOpenApiServiceDescriptionTest.java | 2 +-
...enApiContextBasedConfigApplicationOnlyTest.java | 2 +-
.../openapi/OpenApiContextBasedConfigTest.java | 2 +-
.../description/openapi/OpenApiCustomizerTest.java | 2 +-
.../OpenApiNonAnnotatedServiceDescriptionTest.java | 2 +-
.../SwaggerUiConfigurationQueryConfigTest.java | 27 +-
.../{ => openapi}/SwaggerUiConfigurationTest.java | 24 +-
77 files changed, 30 insertions(+), 8721 deletions(-)
diff --git a/bom/pom.xml b/bom/pom.xml
index 86e5f09f55..8bea3e1a45 100644
--- a/bom/pom.xml
+++ b/bom/pom.xml
@@ -264,11 +264,6 @@
<artifactId>cxf-rt-rs-service-description</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-rs-service-description-swagger</artifactId>
- <version>${project.version}</version>
- </dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-service-description-openapi-v3</artifactId>
diff --git a/distribution/javadoc/pom.xml b/distribution/javadoc/pom.xml
index f50664b3a9..a9041e5711 100644
--- a/distribution/javadoc/pom.xml
+++ b/distribution/javadoc/pom.xml
@@ -718,11 +718,6 @@
<profile>
<id>javax</id>
<dependencies>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-rs-service-description-swagger</artifactId>
- <version>${project.version}</version>
- </dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-websocket</artifactId>
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2/README.txt b/distribution/src/main/release/samples/jax_rs/description_swagger2/README.txt
deleted file mode 100644
index af5a737159..0000000000
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2/README.txt
+++ /dev/null
@@ -1,43 +0,0 @@
-JAX-RS Swagger2Feature Demo
-=================
-
-The demo shows a basic usage of Swagger 2.0 API documentation with REST based Web Services using
-JAX-RS 2.0 (JSR-339). Swagger UI is available at: http://localhost:9000/
-
-Building and running the demo using Maven
----------------------------------------
-
-From the base directory of this sample (i.e., where this README file is
-located), the Maven pom.xml file can be used to build and run the demo.
-
-
-Using either UNIX or Windows:
-
- mvn install
- mvn -Pserver (from one command line window)
-
-
-After the service is started, the Swagger API documents in JSON and YAML
-are available at
-
- http://localhost:9000/swagger.json
- http://localhost:9000/swagger.yaml
-
-
-To view the Swagger document using Swagger-UI, use your Browser to
-open the Swagger-UI page at
-
- http://localhost:9000/api-docs?url=/swagger.json
-
-or
-
- http://localhost:9000/api-docs?url=/swagger.yaml
-
-or access it from the CXF Services page:
-
- http://localhost:9000/services
- and follow a Swagger link.
-
-
-
-
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2/pom.xml b/distribution/src/main/release/samples/jax_rs/description_swagger2/pom.xml
deleted file mode 100644
index a3d7696967..0000000000
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2/pom.xml
+++ /dev/null
@@ -1,92 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <artifactId>jax_rs_description_swagger2</artifactId>
- <name>JAX-RS Swagger2 Demo</name>
- <description>JAX-RS Swagger2 Basic Demo using Jetty</description>
- <parent>
- <groupId>org.apache.cxf.samples</groupId>
- <artifactId>cxf-samples</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- <relativePath>../..</relativePath>
- </parent>
-
- <properties>
- <cxf.version>${project.version}</cxf.version>
- </properties>
-
- <profiles>
- <profile>
- <id>server</id>
- <build>
- <defaultGoal>test</defaultGoal>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <executions>
- <execution>
- <phase>test</phase>
- <goals>
- <goal>java</goal>
- </goals>
- <configuration>
- <mainClass>demo.jaxrs.swagger.server.Server</mainClass>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
- <dependencies>
- <dependency>
- <groupId>org.webjars</groupId>
- <artifactId>swagger-ui</artifactId>
- <version>${cxf.swagger.ui.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-frontend-jaxrs</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-rs-service-description-swagger</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.jakarta.rs</groupId>
- <artifactId>jackson-jakarta-rs-json-provider</artifactId>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-webapp</artifactId>
- </dependency>
- </dependencies>
-</project>
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2/src/main/java/demo/jaxrs/swagger/server/ApiOriginFilter.java b/distribution/src/main/release/samples/jax_rs/description_swagger2/src/main/java/demo/jaxrs/swagger/server/ApiOriginFilter.java
deleted file mode 100644
index de2d1b4538..0000000000
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2/src/main/java/demo/jaxrs/swagger/server/ApiOriginFilter.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 demo.jaxrs.swagger.server;
-
-import java.io.IOException;
-
-import jakarta.ws.rs.container.ContainerRequestContext;
-import jakarta.ws.rs.container.ContainerResponseContext;
-import jakarta.ws.rs.container.ContainerResponseFilter;
-import jakarta.ws.rs.core.MultivaluedMap;
-
-/**
- * This is a simple optional CORS filter used for this demo to make the resources accessible
- * from other origins. You may omit using this filter or use CXF's advanced CORS filter
- * org.apache.cxf.rs.security.cors.CrossOriginResourceSharingFilter
- * included in cxf-rt-rs-security-cors if you need a more comprehensive accessibility rules.
- */
-public class ApiOriginFilter implements ContainerResponseFilter {
-
- @Override
- public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
- throws IOException {
- MultivaluedMap<String, Object> headers = responseContext.getHeaders();
- headers.add("Access-Control-Allow-Origin", "*");
- headers.add("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
- headers.add("Access-Control-Allow-Headers", "Content-Type");
- }
-}
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2/src/main/java/demo/jaxrs/swagger/server/Item.java b/distribution/src/main/release/samples/jax_rs/description_swagger2/src/main/java/demo/jaxrs/swagger/server/Item.java
deleted file mode 100644
index 51b3cabaf8..0000000000
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2/src/main/java/demo/jaxrs/swagger/server/Item.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 demo.jaxrs.swagger.server;
-
-public class Item {
- private String name;
- private String value;
-
- public Item() {
- }
-
- public Item(final String name, final String value) {
- this.name = name;
- this.value = value;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-}
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2/src/main/java/demo/jaxrs/swagger/server/Sample.java b/distribution/src/main/release/samples/jax_rs/description_swagger2/src/main/java/demo/jaxrs/swagger/server/Sample.java
deleted file mode 100644
index 59a40f91ca..0000000000
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2/src/main/java/demo/jaxrs/swagger/server/Sample.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 demo.jaxrs.swagger.server;
-
-import java.util.Collections;
-import java.util.Map;
-import java.util.TreeMap;
-
-import jakarta.ws.rs.Consumes;
-import jakarta.ws.rs.DELETE;
-import jakarta.ws.rs.DefaultValue;
-import jakarta.ws.rs.FormParam;
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.HeaderParam;
-import jakarta.ws.rs.POST;
-import jakarta.ws.rs.PUT;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.PathParam;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.QueryParam;
-import jakarta.ws.rs.core.Context;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
-import jakarta.ws.rs.core.UriInfo;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.Contact;
-import io.swagger.annotations.Info;
-import io.swagger.annotations.SwaggerDefinition;
-
-@Path("/sample")
-@Api(value = "/sample")
-@SwaggerDefinition(
- info = @Info(
- description = "Sample JAX-RS service with Swagger documentation",
- version="1.0.0",
- title = "Sample REST Application",
- contact = @Contact(
- name = "Apache CXF",
- email = "users@cxf.apache.org"
- )
- )
-)
-public class Sample {
- private Map<String, Item> items;
-
- public Sample() {
- items = Collections.synchronizedMap(new TreeMap<String, Item>(String.CASE_INSENSITIVE_ORDER));
- items.put("Item 1", new Item("Item 1", "Value 1"));
- items.put("Item 2", new Item("Item 2", "Value 2"));
- }
-
-
- @Produces({ MediaType.APPLICATION_JSON })
- @GET
- @ApiOperation(
- value = "Get operation with Response and @Default value",
- notes = "Get operation with Response and @Default value",
- response = Item.class,
- responseContainer = "List"
- )
- public Response getItems(
- @ApiParam(value = "Page to fetch", required = true) @QueryParam("page") @DefaultValue("1") int page) {
-
- return Response.ok(items.values()).build();
- }
-
- @Produces({ MediaType.APPLICATION_JSON })
- @Path("/{name}")
- @GET
- @ApiOperation(
- value = "Get operation with type and headers",
- notes = "Get operation with type and headers",
- response = Item.class
- )
- public Item getItem(
- @ApiParam(value = "language", required = true) @HeaderParam("Accept-Language") final String language,
- @ApiParam(value = "name", required = true) @PathParam("name") String name) {
- return items.get(name);
- }
-
- @Consumes({ MediaType.APPLICATION_JSON })
- @POST
- @ApiOperation(
- value = "Post operation with entity in a body",
- notes = "Post operation with entity in a body",
- response = Item.class
- )
- public Response createItem(
- @Context final UriInfo uriInfo,
- @ApiParam(value = "item", required = true) final Item item) {
- items.put(item.getName(), item);
- return Response
- .created(uriInfo.getBaseUriBuilder().path(item.getName()).build())
- .entity(item).build();
- }
-
- @Produces({ MediaType.APPLICATION_JSON })
- @Path("/{name}")
- @PUT
- @ApiOperation(
- value = "Put operation with form parameter",
- notes = "Put operation with form parameter",
- response = Item.class
- )
- public Item updateItem(
- @ApiParam(value = "name", required = true) @PathParam("name") String name,
- @ApiParam(value = "value", required = true) @FormParam("value") String value) {
- Item item = new Item(name, value);
- items.put(name, item);
- return item;
- }
-
- @Path("/{name}")
- @DELETE
- @ApiOperation(
- value = "Delete operation with implicit header",
- notes = "Delete operation with implicit header"
- )
- @ApiImplicitParams(
- @ApiImplicitParam(
- name = "Accept-Language",
- value = "language",
- required = true,
- dataType = "String",
- paramType = "header"
- )
- )
- public Response delete(@ApiParam(value = "name", required = true) @PathParam("name") String name) {
- items.remove(name);
- return Response.ok().build();
- }
-}
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2/src/main/java/demo/jaxrs/swagger/server/Server.java b/distribution/src/main/release/samples/jax_rs/description_swagger2/src/main/java/demo/jaxrs/swagger/server/Server.java
deleted file mode 100644
index 88252cbb8b..0000000000
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2/src/main/java/demo/jaxrs/swagger/server/Server.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 demo.jaxrs.swagger.server;
-
-import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.cxf.jaxrs.provider.MultipartProvider;
-import org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet;
-import org.apache.cxf.jaxrs.swagger.Swagger2Feature;
-import org.eclipse.jetty.servlet.ServletContextHandler;
-import org.eclipse.jetty.servlet.ServletHolder;
-
-public class Server {
-
- protected Server() throws Exception {
- org.eclipse.jetty.server.Server server = new org.eclipse.jetty.server.Server(9000);
-
- final ServletHolder servletHolder = new ServletHolder(new CXFNonSpringJaxrsServlet());
- final ServletContextHandler context = new ServletContextHandler();
- context.setContextPath("/");
- context.addServlet(servletHolder, "/*");
- servletHolder.setInitParameter("jaxrs.serviceClasses", Sample.class.getName());
- servletHolder.setInitParameter("jaxrs.features",
- Swagger2Feature.class.getName());
- servletHolder.setInitParameter("jaxrs.providers", StringUtils.join(
- new String[] {
- MultipartProvider.class.getName(),
- JacksonJsonProvider.class.getName(),
- ApiOriginFilter.class.getName()
- }, ",")
- );
-
- server.setHandler(context);
- server.start();
- server.join();
- }
-
- public static void main(String[] args) throws Exception {
- new Server();
- System.out.println("Server ready...");
-
- Thread.sleep(5 * 6000 * 1000);
- System.out.println("Server exiting");
- System.exit(0);
- }
-}
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2/src/main/resources/META-INF/cxf/org.apache.cxf.Logger b/distribution/src/main/release/samples/jax_rs/description_swagger2/src/main/resources/META-INF/cxf/org.apache.cxf.Logger
deleted file mode 100644
index 27dd788b31..0000000000
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2/src/main/resources/META-INF/cxf/org.apache.cxf.Logger
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.cxf.common.logging.Slf4jLogger
\ No newline at end of file
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2/src/main/resources/logback.xml b/distribution/src/main/release/samples/jax_rs/description_swagger2/src/main/resources/logback.xml
deleted file mode 100644
index 59bce1262a..0000000000
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2/src/main/resources/logback.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<configuration scan="true" scanPeriod="5 seconds">
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>[%level] %d{yyyy-MM-dd HH:mm:ss.SSS} %logger{36} - [%X] %msg%n</pattern>
- </encoder>
- </appender>
-
- <root level="INFO">
- <appender-ref ref="STDOUT" />
- </root>
-
- <logger category="io.swagger" name="swagger">
- <level name="DEBUG"/>
- </logger>
-</configuration>
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/README.txt b/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/README.txt
deleted file mode 100644
index 22c9bc35d3..0000000000
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/README.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-JAX-RS Swagger2Feature Spring Demo
-=================
-
-The demo shows a basic usage of Swagger 2.0 API documentation with REST based Web Services using
-JAX-RS 2.0 (JSR-339).
-
-Building and running the demo using Maven
----------------------------------------
-
-From the base directory of this sample (i.e., where this README file is
-located), the Maven pom.xml file can be used to build and run the demo.
-
-
-Using either UNIX or Windows:
-
- mvn install
- mvn -Pserver (from one command line window)
-
-
-After the service is started, the Swagger API documents in JSON and YAML
-are available at
-
- http://localhost:9000/swaggerSample/swagger.json
- http://localhost:9000/swaggerSample/swagger.yaml
-
-To remove the target dir, run mvn clean".
-
-
-If you do not have your swagger-ui on your local system, you can download
-a copy from its download site.
-
-At the console, type
-
- wget -N https://github.com/swagger-api/swagger-ui/archive/master.zip
- unzip master.zip
-
-This will extract the content of the swagger-ui zip file. Using your Browser, open
-the index.html file at swagger-ui-master/dist/. Finally, type in the above swagger
-document URL in the input field and click on "Explore" to view the document.
-
-
-
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/pom.xml b/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/pom.xml
deleted file mode 100644
index cf99ef493e..0000000000
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/pom.xml
+++ /dev/null
@@ -1,102 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <artifactId>jax_rs_description_swagger2_spring</artifactId>
- <name>JAX-RS Swagger2 Spring Demo</name>
- <description>JAX-RS Swagger2 Basic Demo using Spring</description>
- <parent>
- <groupId>org.apache.cxf.samples</groupId>
- <artifactId>cxf-samples</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- <relativePath>../..</relativePath>
- </parent>
-
- <properties>
- <cxf.version>${project.version}</cxf.version>
- </properties>
-
- <profiles>
- <profile>
- <id>server</id>
- <build>
- <defaultGoal>test</defaultGoal>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <executions>
- <execution>
- <phase>test</phase>
- <goals>
- <goal>java</goal>
- </goals>
- <configuration>
- <mainClass>demo.jaxrs.swagger.server.Server</mainClass>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-transports-http</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- </dependency>
- <!-- This dependency is needed if you're using the Jetty container -->
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-frontend-jaxrs</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-rs-service-description-swagger</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>jakarta.ws.rs</groupId>
- <artifactId>jakarta.ws.rs-api</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.jakarta.rs</groupId>
- <artifactId>jackson-jakarta-rs-json-provider</artifactId>
- </dependency>
- <!-- spring -->
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-web</artifactId>
- </dependency>
- </dependencies>
-</project>
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/src/main/java/demo/jaxrs/swagger/server/ApiOriginFilter.java b/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/src/main/java/demo/jaxrs/swagger/server/ApiOriginFilter.java
deleted file mode 100644
index de2d1b4538..0000000000
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/src/main/java/demo/jaxrs/swagger/server/ApiOriginFilter.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 demo.jaxrs.swagger.server;
-
-import java.io.IOException;
-
-import jakarta.ws.rs.container.ContainerRequestContext;
-import jakarta.ws.rs.container.ContainerResponseContext;
-import jakarta.ws.rs.container.ContainerResponseFilter;
-import jakarta.ws.rs.core.MultivaluedMap;
-
-/**
- * This is a simple optional CORS filter used for this demo to make the resources accessible
- * from other origins. You may omit using this filter or use CXF's advanced CORS filter
- * org.apache.cxf.rs.security.cors.CrossOriginResourceSharingFilter
- * included in cxf-rt-rs-security-cors if you need a more comprehensive accessibility rules.
- */
-public class ApiOriginFilter implements ContainerResponseFilter {
-
- @Override
- public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
- throws IOException {
- MultivaluedMap<String, Object> headers = responseContext.getHeaders();
- headers.add("Access-Control-Allow-Origin", "*");
- headers.add("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
- headers.add("Access-Control-Allow-Headers", "Content-Type");
- }
-}
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/src/main/java/demo/jaxrs/swagger/server/Item.java b/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/src/main/java/demo/jaxrs/swagger/server/Item.java
deleted file mode 100644
index 51b3cabaf8..0000000000
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/src/main/java/demo/jaxrs/swagger/server/Item.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 demo.jaxrs.swagger.server;
-
-public class Item {
- private String name;
- private String value;
-
- public Item() {
- }
-
- public Item(final String name, final String value) {
- this.name = name;
- this.value = value;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-}
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/src/main/java/demo/jaxrs/swagger/server/Sample.java b/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/src/main/java/demo/jaxrs/swagger/server/Sample.java
deleted file mode 100644
index d1362876e2..0000000000
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/src/main/java/demo/jaxrs/swagger/server/Sample.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 demo.jaxrs.swagger.server;
-
-import java.util.Collections;
-import java.util.Map;
-import java.util.TreeMap;
-
-import jakarta.ws.rs.Consumes;
-import jakarta.ws.rs.DELETE;
-import jakarta.ws.rs.DefaultValue;
-import jakarta.ws.rs.FormParam;
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.HeaderParam;
-import jakarta.ws.rs.POST;
-import jakarta.ws.rs.PUT;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.PathParam;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.QueryParam;
-import jakarta.ws.rs.core.Context;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
-import jakarta.ws.rs.core.UriInfo;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-
-@Path("/sample")
-@Api(value = "/sample", description = "Sample JAX-RS service with Swagger documentation")
-public class Sample {
- private Map<String, Item> items;
-
- public Sample() {
- items = Collections.synchronizedMap(new TreeMap<String, Item>(String.CASE_INSENSITIVE_ORDER));
- items.put("Item 1", new Item("Item 1", "Value 1"));
- items.put("Item 2", new Item("Item 2", "Value 2"));
- }
-
-
- @Produces({ MediaType.APPLICATION_JSON })
- @GET
- @ApiOperation(
- value = "Get operation with Response and @Default value",
- notes = "Get operation with Response and @Default value",
- response = Item.class,
- responseContainer = "List"
- )
- public Response getItems(
- @ApiParam(value = "Page to fetch", required = true) @QueryParam("page") @DefaultValue("1") int page) {
-
- return Response.ok(items.values()).build();
- }
-
- @Produces({ MediaType.APPLICATION_JSON })
- @Path("/{name}")
- @GET
- @ApiOperation(
- value = "Get operation with type and headers",
- notes = "Get operation with type and headers",
- response = Item.class
- )
- public Item getItem(
- @ApiParam(value = "language", required = true) @HeaderParam("Accept-Language") final String language,
- @ApiParam(value = "name", required = true) @PathParam("name") String name) {
- return items.get(name);
- }
-
- @Consumes({ MediaType.APPLICATION_JSON })
- @POST
- @ApiOperation(
- value = "Post operation with entity in a body",
- notes = "Post operation with entity in a body",
- response = Item.class
- )
- public Response createItem(
- @Context final UriInfo uriInfo,
- @ApiParam(value = "item", required = true) final Item item) {
- items.put(item.getName(), item);
- return Response
- .created(uriInfo.getBaseUriBuilder().path(item.getName()).build())
- .entity(item).build();
- }
-
- @Produces({ MediaType.APPLICATION_JSON })
- @Path("/{name}")
- @PUT
- @ApiOperation(
- value = "Put operation with form parameter",
- notes = "Put operation with form parameter",
- response = Item.class
- )
- public Item updateItem(
- @ApiParam(value = "name", required = true) @PathParam("name") String name,
- @ApiParam(value = "value", required = true) @FormParam("value") String value) {
- Item item = new Item(name, value);
- items.put(name, item);
- return item;
- }
-
- @Path("/{name}")
- @DELETE
- @ApiOperation(
- value = "Delete operation with implicit header",
- notes = "Delete operation with implicit header"
- )
- @ApiImplicitParams(
- @ApiImplicitParam(
- name = "Accept-Language",
- value = "language",
- required = true,
- dataType = "String",
- paramType = "header"
- )
- )
- public Response delete(@ApiParam(value = "name", required = true) @PathParam("name") String name) {
- items.remove(name);
- return Response.ok().build();
- }
-}
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/src/main/java/demo/jaxrs/swagger/server/Server.java b/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/src/main/java/demo/jaxrs/swagger/server/Server.java
deleted file mode 100644
index 50ecfae505..0000000000
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/src/main/java/demo/jaxrs/swagger/server/Server.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 demo.jaxrs.swagger.server;
-
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-public final class Server {
- private Server() {
- }
-
- public static void main(String[] args) throws Exception {
- ApplicationContext appctxt =
- new ClassPathXmlApplicationContext(Server.class.getResource("/context.xml").toString());
-
- System.out.println("Server ready...");
-
- Thread.sleep(5 * 6000 * 1000);
- System.out.println("Server exiting");
- System.exit(0);
- }
-}
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/src/main/resources/META-INF/cxf/org.apache.cxf.Logger b/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/src/main/resources/META-INF/cxf/org.apache.cxf.Logger
deleted file mode 100644
index 27dd788b31..0000000000
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/src/main/resources/META-INF/cxf/org.apache.cxf.Logger
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.cxf.common.logging.Slf4jLogger
\ No newline at end of file
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/src/main/resources/context.xml b/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/src/main/resources/context.xml
deleted file mode 100644
index 0e569bf08c..0000000000
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/src/main/resources/context.xml
+++ /dev/null
@@ -1,64 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
--->
-<!-- START SNIPPET: beans -->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cxf="http://cxf.apache.org/core"
- xmlns:jaxrs="http://cxf.apache.org/jaxrs"
- xsi:schemaLocation="http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
- http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
-
- <import resource="classpath:META-INF/cxf/cxf.xml" />
-
- <!-- JAXRS providers -->
- <bean id="jsonProvider" class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider" />
- <bean id="multipartProvider" class="org.apache.cxf.jaxrs.provider.MultipartProvider" />
- <bean id="originFilter" class="demo.jaxrs.swagger.server.ApiOriginFilter" />
-
- <!-- Application resources -->
- <bean id="sampleResource" class="demo.jaxrs.swagger.server.Sample" />
-
- <!-- CXF Swagger2Feature -->
- <bean id="swagger2Feature" class="org.apache.cxf.jaxrs.swagger.Swagger2Feature">
- <property name="title" value="Sample REST Application" />
- </bean>
-
- <cxf:bus>
- <cxf:features>
- <cxf:logging />
- </cxf:features>
- </cxf:bus>
-
- <jaxrs:server id="sampleServer" address="http://localhost:9000/swaggerSample">
- <jaxrs:serviceBeans>
- <ref bean="sampleResource" />
- </jaxrs:serviceBeans>
- <jaxrs:providers>
- <ref bean="jsonProvider" />
- <ref bean="multipartProvider" />
- <ref bean="originFilter" />
- </jaxrs:providers>
- <jaxrs:features>
- <ref bean="swagger2Feature" />
- </jaxrs:features>
- </jaxrs:server>
-
-</beans>
-<!-- END SNIPPET: beans -->
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/src/main/resources/logback.xml b/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/src/main/resources/logback.xml
deleted file mode 100644
index 59bce1262a..0000000000
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2_spring/src/main/resources/logback.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<configuration scan="true" scanPeriod="5 seconds">
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>[%level] %d{yyyy-MM-dd HH:mm:ss.SSS} %logger{36} - [%X] %msg%n</pattern>
- </encoder>
- </appender>
-
- <root level="INFO">
- <appender-ref ref="STDOUT" />
- </root>
-
- <logger category="io.swagger" name="swagger">
- <level name="DEBUG"/>
- </logger>
-</configuration>
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2_web/README.txt b/distribution/src/main/release/samples/jax_rs/description_swagger2_web/README.txt
deleted file mode 100644
index e1a4166db0..0000000000
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2_web/README.txt
+++ /dev/null
@@ -1,47 +0,0 @@
-JAX-RS Swagger2Feature Demo using WebApp with Spring
-=================
-
-The demo shows a basic usage of Swagger API documentation with multiple REST based Web Services using
-JAX-RS 2.0 (JSR-339). In this demo, the Swagger2Feature is configured using Spring.
-
-Building and running the demo using Maven
----------------------------------------
-
-From the base directory of this sample (i.e., where this README file is
-located), the Maven pom.xml file can be used to build and run the demo.
-
-
-Using either UNIX or Windows:
-
- mvn install
- mvn jetty:run-war
-
-
-Two JAX-RS endpoints are available after the service has started.
-Swagger API documents in JSON and YAML are available at
-
- http://localhost:9000/app/swaggerSample/swagger.json
- http://localhost:9000/app/swaggerSample/swagger.yaml
-
-and
-
- http://localhost:9000/app/swaggerSample2/swagger.json
- http://localhost:9000/app/swaggerSample2/swagger.yaml
-
-To view the Swagger document using Swagger-UI, use your Browser to
-open the Swagger-UI page at
-
- http://localhost:9000/app/swaggerSample/api-docs?url=/app/swaggerSample/swagger.json
- or
- http://localhost:9000/app/swaggerSample2/api-docs?url=/app/swaggerSample2/swagger.json
-
-or go to the CXF services page:
-
- http://localhost:9000/app/services
-
-and follow Swagger links.
-
-To remove the target dir, run mvn clean".
-
-
-
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2_web/pom.xml b/distribution/src/main/release/samples/jax_rs/description_swagger2_web/pom.xml
deleted file mode 100644
index fa5c574b3f..0000000000
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2_web/pom.xml
+++ /dev/null
@@ -1,95 +0,0 @@
-<?xml version="1.0"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <artifactId>jax_rs_description_swagger2_web</artifactId>
- <packaging>war</packaging>
- <name>JAX-RS Swagger2 WebApp Demo</name>
- <description>JAX-RS Swagger2 Basic Demo using WebApp with Spring</description>
- <parent>
- <groupId>org.apache.cxf.samples</groupId>
- <artifactId>cxf-samples</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- <relativePath>../..</relativePath>
- </parent>
-
- <properties>
- <cxf.version>${project.version}</cxf.version>
- </properties>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-maven-plugin</artifactId>
- <version>${cxf.jetty11.version}</version>
- <configuration>
- <webApp>
- <contextPath>/</contextPath>
- </webApp>
- <httpConnector>
- <port>9000</port>
- </httpConnector>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.webjars</groupId>
- <artifactId>swagger-ui</artifactId>
- <version>${cxf.swagger.ui.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-transports-http</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-frontend-jaxrs</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-rs-service-description-swagger</artifactId>
- </dependency>
- <dependency>
- <groupId>jakarta.ws.rs</groupId>
- <artifactId>jakarta.ws.rs-api</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.jakarta.rs</groupId>
- <artifactId>jackson-jakarta-rs-json-provider</artifactId>
- </dependency>
- <!-- spring -->
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-web</artifactId>
- </dependency>
- <dependency>
- <groupId>jakarta.validation</groupId>
- <artifactId>jakarta.validation-api</artifactId>
- </dependency>
- </dependencies>
-</project>
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2_web/src/main/java/demo/jaxrs/swagger/server/ApiOriginFilter.java b/distribution/src/main/release/samples/jax_rs/description_swagger2_web/src/main/java/demo/jaxrs/swagger/server/ApiOriginFilter.java
deleted file mode 100644
index de2d1b4538..0000000000
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2_web/src/main/java/demo/jaxrs/swagger/server/ApiOriginFilter.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 demo.jaxrs.swagger.server;
-
-import java.io.IOException;
-
-import jakarta.ws.rs.container.ContainerRequestContext;
-import jakarta.ws.rs.container.ContainerResponseContext;
-import jakarta.ws.rs.container.ContainerResponseFilter;
-import jakarta.ws.rs.core.MultivaluedMap;
-
-/**
- * This is a simple optional CORS filter used for this demo to make the resources accessible
- * from other origins. You may omit using this filter or use CXF's advanced CORS filter
- * org.apache.cxf.rs.security.cors.CrossOriginResourceSharingFilter
- * included in cxf-rt-rs-security-cors if you need a more comprehensive accessibility rules.
- */
-public class ApiOriginFilter implements ContainerResponseFilter {
-
- @Override
- public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
- throws IOException {
- MultivaluedMap<String, Object> headers = responseContext.getHeaders();
- headers.add("Access-Control-Allow-Origin", "*");
- headers.add("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
- headers.add("Access-Control-Allow-Headers", "Content-Type");
- }
-}
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2_web/src/main/java/demo/jaxrs/swagger/server/Item.java b/distribution/src/main/release/samples/jax_rs/description_swagger2_web/src/main/java/demo/jaxrs/swagger/server/Item.java
deleted file mode 100644
index 51b3cabaf8..0000000000
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2_web/src/main/java/demo/jaxrs/swagger/server/Item.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 demo.jaxrs.swagger.server;
-
-public class Item {
- private String name;
- private String value;
-
- public Item() {
- }
-
- public Item(final String name, final String value) {
- this.name = name;
- this.value = value;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-}
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2_web/src/main/java/demo/jaxrs/swagger/server/Sample.java b/distribution/src/main/release/samples/jax_rs/description_swagger2_web/src/main/java/demo/jaxrs/swagger/server/Sample.java
deleted file mode 100644
index d1362876e2..0000000000
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2_web/src/main/java/demo/jaxrs/swagger/server/Sample.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 demo.jaxrs.swagger.server;
-
-import java.util.Collections;
-import java.util.Map;
-import java.util.TreeMap;
-
-import jakarta.ws.rs.Consumes;
-import jakarta.ws.rs.DELETE;
-import jakarta.ws.rs.DefaultValue;
-import jakarta.ws.rs.FormParam;
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.HeaderParam;
-import jakarta.ws.rs.POST;
-import jakarta.ws.rs.PUT;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.PathParam;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.QueryParam;
-import jakarta.ws.rs.core.Context;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
-import jakarta.ws.rs.core.UriInfo;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-
-@Path("/sample")
-@Api(value = "/sample", description = "Sample JAX-RS service with Swagger documentation")
-public class Sample {
- private Map<String, Item> items;
-
- public Sample() {
- items = Collections.synchronizedMap(new TreeMap<String, Item>(String.CASE_INSENSITIVE_ORDER));
- items.put("Item 1", new Item("Item 1", "Value 1"));
- items.put("Item 2", new Item("Item 2", "Value 2"));
- }
-
-
- @Produces({ MediaType.APPLICATION_JSON })
- @GET
- @ApiOperation(
- value = "Get operation with Response and @Default value",
- notes = "Get operation with Response and @Default value",
- response = Item.class,
- responseContainer = "List"
- )
- public Response getItems(
- @ApiParam(value = "Page to fetch", required = true) @QueryParam("page") @DefaultValue("1") int page) {
-
- return Response.ok(items.values()).build();
- }
-
- @Produces({ MediaType.APPLICATION_JSON })
- @Path("/{name}")
- @GET
- @ApiOperation(
- value = "Get operation with type and headers",
- notes = "Get operation with type and headers",
- response = Item.class
- )
- public Item getItem(
- @ApiParam(value = "language", required = true) @HeaderParam("Accept-Language") final String language,
- @ApiParam(value = "name", required = true) @PathParam("name") String name) {
- return items.get(name);
- }
-
- @Consumes({ MediaType.APPLICATION_JSON })
- @POST
- @ApiOperation(
- value = "Post operation with entity in a body",
- notes = "Post operation with entity in a body",
- response = Item.class
- )
- public Response createItem(
- @Context final UriInfo uriInfo,
- @ApiParam(value = "item", required = true) final Item item) {
- items.put(item.getName(), item);
- return Response
- .created(uriInfo.getBaseUriBuilder().path(item.getName()).build())
- .entity(item).build();
- }
-
- @Produces({ MediaType.APPLICATION_JSON })
- @Path("/{name}")
- @PUT
- @ApiOperation(
- value = "Put operation with form parameter",
- notes = "Put operation with form parameter",
- response = Item.class
- )
- public Item updateItem(
- @ApiParam(value = "name", required = true) @PathParam("name") String name,
- @ApiParam(value = "value", required = true) @FormParam("value") String value) {
- Item item = new Item(name, value);
- items.put(name, item);
- return item;
- }
-
- @Path("/{name}")
- @DELETE
- @ApiOperation(
- value = "Delete operation with implicit header",
- notes = "Delete operation with implicit header"
- )
- @ApiImplicitParams(
- @ApiImplicitParam(
- name = "Accept-Language",
- value = "language",
- required = true,
- dataType = "String",
- paramType = "header"
- )
- )
- public Response delete(@ApiParam(value = "name", required = true) @PathParam("name") String name) {
- items.remove(name);
- return Response.ok().build();
- }
-}
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2_web/src/main/java/demo/jaxrs/swagger/server/Sample2.java b/distribution/src/main/release/samples/jax_rs/description_swagger2_web/src/main/java/demo/jaxrs/swagger/server/Sample2.java
deleted file mode 100644
index 4464e0ace8..0000000000
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2_web/src/main/java/demo/jaxrs/swagger/server/Sample2.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 demo.jaxrs.swagger.server;
-
-import java.util.Collections;
-import java.util.Map;
-import java.util.TreeMap;
-
-import jakarta.ws.rs.Consumes;
-import jakarta.ws.rs.DELETE;
-import jakarta.ws.rs.DefaultValue;
-import jakarta.ws.rs.FormParam;
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.HeaderParam;
-import jakarta.ws.rs.POST;
-import jakarta.ws.rs.PUT;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.PathParam;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.QueryParam;
-import jakarta.ws.rs.core.Context;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
-import jakarta.ws.rs.core.UriInfo;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-
-@Path("/sample2")
-@Api(value = "/sample2", description = "Sample2 JAX-RS service with Swagger documentation")
-public class Sample2 {
- private Map<String, Item> items;
-
- public Sample2() {
- items = Collections.synchronizedMap(new TreeMap<String, Item>(String.CASE_INSENSITIVE_ORDER));
- items.put("Item 1", new Item("Item 1", "Value 1"));
- items.put("Item 2", new Item("Item 2", "Value 2"));
- }
-
-
- @Produces({ MediaType.APPLICATION_JSON })
- @GET
- @ApiOperation(
- value = "Get operation with Response and @Default value",
- notes = "Get operation with Response and @Default value",
- response = Item.class,
- responseContainer = "List"
- )
- public Response getItems(
- @ApiParam(value = "Page to fetch", required = true) @QueryParam("page") @DefaultValue("1") int page) {
-
- return Response.ok(items.values()).build();
- }
-
- @Produces({ MediaType.APPLICATION_JSON })
- @Path("/{name}")
- @GET
- @ApiOperation(
- value = "Get operation with type and headers",
- notes = "Get operation with type and headers",
- response = Item.class
- )
- public Item getItem(
- @ApiParam(value = "language", required = true) @HeaderParam("Accept-Language") final String language,
- @ApiParam(value = "name", required = true) @PathParam("name") String name) {
- return items.get(name);
- }
-
- @Consumes({ MediaType.APPLICATION_JSON })
- @POST
- @ApiOperation(
- value = "Post operation with entity in a body",
- notes = "Post operation with entity in a body",
- response = Item.class
- )
- public Response createItem(
- @Context final UriInfo uriInfo,
- @ApiParam(value = "item", required = true) final Item item) {
- items.put(item.getName(), item);
- return Response
- .created(uriInfo.getBaseUriBuilder().path(item.getName()).build())
- .entity(item).build();
- }
-
- @Produces({ MediaType.APPLICATION_JSON })
- @Path("/{name}")
- @PUT
- @ApiOperation(
- value = "Put operation with form parameter",
- notes = "Put operation with form parameter",
- response = Item.class
- )
- public Item updateItem(
- @ApiParam(value = "name", required = true) @PathParam("name") String name,
- @ApiParam(value = "value", required = true) @FormParam("value") String value) {
- Item item = new Item(name, value);
- items.put(name, item);
- return item;
- }
-
- @Path("/{name}")
- @DELETE
- @ApiOperation(
- value = "Delete operation with implicit header",
- notes = "Delete operation with implicit header"
- )
- @ApiImplicitParams(
- @ApiImplicitParam(
- name = "Accept-Language",
- value = "language",
- required = true,
- dataType = "String",
- paramType = "header"
- )
- )
- public Response delete(@ApiParam(value = "name", required = true) @PathParam("name") String name) {
- items.remove(name);
- return Response.ok().build();
- }
-}
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2_web/src/main/webapp/WEB-INF/context.xml b/distribution/src/main/release/samples/jax_rs/description_swagger2_web/src/main/webapp/WEB-INF/context.xml
deleted file mode 100644
index e060227c96..0000000000
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2_web/src/main/webapp/WEB-INF/context.xml
+++ /dev/null
@@ -1,87 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
--->
-<!-- START SNIPPET: beans -->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cxf="http://cxf.apache.org/core"
- xmlns:jaxrs="http://cxf.apache.org/jaxrs"
- xsi:schemaLocation="http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
- http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
-
- <import resource="classpath:META-INF/cxf/cxf.xml" />
-
- <cxf:bus>
- <cxf:features>
- <cxf:logging />
- </cxf:features>
- </cxf:bus>
-
- <!-- JAXRS providers -->
- <bean id="jsonProvider" class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider" />
- <bean id="originFilter" class="demo.jaxrs.swagger.server.ApiOriginFilter" />
-
- <!-- Application resource for the first Endpoint -->
- <bean id="sampleResource" class="demo.jaxrs.swagger.server.Sample" />
-
- <!-- Swagger2Feature for the first Endpoint -->
- <bean id="swagger2Feature" class="org.apache.cxf.jaxrs.swagger.Swagger2Feature">
- <property name="title" value="Sample REST Application"/>
- <property name="usePathBasedConfig" value="true"/>
- </bean>
-
- <!-- First Endpoint -->
- <jaxrs:server id="sampleServer" address="/swaggerSample">
- <jaxrs:serviceBeans>
- <ref bean="sampleResource" />
- </jaxrs:serviceBeans>
- <jaxrs:providers>
- <ref bean="jsonProvider" />
- <ref bean="originFilter" />
- </jaxrs:providers>
- <jaxrs:features>
- <ref bean="swagger2Feature" />
- </jaxrs:features>
- </jaxrs:server>
-
- <!-- Application resource for the second Endpoint -->
- <bean id="sampleResource2" class="demo.jaxrs.swagger.server.Sample2" />
-
- <!-- Swagger2Feature for the second Endpoint -->
- <bean id="swagger2Feature2" class="org.apache.cxf.jaxrs.swagger.Swagger2Feature">
- <property name="title" value="Sample REST Application"/>
- <property name="usePathBasedConfig" value="true"/>
- </bean>
-
- <!-- First Endpoint -->
- <jaxrs:server id="sampleServer2" address="/swaggerSample2">
- <jaxrs:serviceBeans>
- <ref bean="sampleResource2" />
- </jaxrs:serviceBeans>
- <jaxrs:providers>
- <ref bean="jsonProvider" />
- <ref bean="originFilter" />
- </jaxrs:providers>
- <jaxrs:features>
- <ref bean="swagger2Feature2" />
- </jaxrs:features>
- </jaxrs:server>
-
-</beans>
-<!-- END SNIPPET: beans -->
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2_web/src/main/webapp/WEB-INF/web.xml b/distribution/src/main/release/samples/jax_rs/description_swagger2_web/src/main/webapp/WEB-INF/web.xml
deleted file mode 100644
index 942887a4d3..0000000000
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2_web/src/main/webapp/WEB-INF/web.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
--->
-<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" version="3.0"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
-
- <display-name>CXF Swagger2 Spring Sample</display-name>
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>WEB-INF/context.xml</param-value>
- </context-param>
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
- <servlet>
- <display-name>CXF Service Servlet</display-name>
- <servlet-name>CXFServiceServlet</servlet-name>
- <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>CXFServiceServlet</servlet-name>
- <url-pattern>/app/*</url-pattern>
- </servlet-mapping>
-</web-app>
diff --git a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/pom.xml b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/pom.xml
index f26a4375e0..b18de9d0dc 100644
--- a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/pom.xml
+++ b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/pom.xml
@@ -27,11 +27,6 @@
<artifactId>swagger-ui</artifactId>
<version>${cxf.swagger.ui.version}</version>
</dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-rs-service-description-swagger</artifactId>
- <version>${project.version}</version>
- </dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-features-metrics</artifactId>
diff --git a/distribution/src/main/release/samples/pom.xml b/distribution/src/main/release/samples/pom.xml
index 8e4050c1a1..c9066d6a10 100644
--- a/distribution/src/main/release/samples/pom.xml
+++ b/distribution/src/main/release/samples/pom.xml
@@ -77,9 +77,6 @@
<module>jax_rs/description_openapi_v3</module>
<module>jax_rs/description_openapi_v3_web</module>
<module>jax_rs/description_openapi_v3_spring</module>
- <module>jax_rs/description_swagger2</module>
- <module>jax_rs/description_swagger2_spring</module>
- <module>jax_rs/description_swagger2_web</module>
<module>jax_rs/odata</module>
<module>jax_rs/search</module>
<module>jax_rs/spring_boot</module>
diff --git a/maven-plugins/java2swagger-plugin/pom.xml b/maven-plugins/java2swagger-plugin/pom.xml
deleted file mode 100644
index 49bb5d9815..0000000000
--- a/maven-plugins/java2swagger-plugin/pom.xml
+++ /dev/null
@@ -1,221 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-java2swagger-plugin</artifactId>
- <packaging>maven-plugin</packaging>
- <version>4.0.0-SNAPSHOT</version>
- <name>Apache CXF Java2Swagger Maven2 Plugin</name>
- <description>Apache CXF Java2Swagger Maven2 Plugin</description>
- <url>https://cxf.apache.org</url>
-
- <parent>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-maven-plugins</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- </parent>
- <properties>
- <cxf.module.name>org.apache.cxf.plugin.java2swagger</cxf.module.name>
- <cxf.manifest.location />
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.shared</groupId>
- <artifactId>maven-artifact-resolver</artifactId>
- <version>1.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-core</artifactId>
- <scope>provided</scope>
- <exclusions>
- <exclusion>
- <groupId>org.sonatype.sisu</groupId>
- <artifactId>sisu-guava</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-compat</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.sonatype.sisu</groupId>
- <artifactId>sisu-guava</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-artifact</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- <version>${cxf.plexus-utils.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-tools-common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-tools-wadlto-jaxrs</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <optional>true</optional>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-project</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-artifact-manager</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-toolchain</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-rs-service-description-swagger</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
-
- <profiles>
- <profile>
- <id>pre-java9</id>
- <dependencies>
- <dependency>
- <groupId>com.sun</groupId>
- <artifactId>tools</artifactId>
- <version>1.7.0</version>
- <scope>system</scope>
- <systemPath>${java.home}/../lib/tools.jar</systemPath>
- </dependency>
- </dependencies>
- <activation>
- <file>
- <exists>${java.home}/../lib/tools.jar</exists>
- </file>
- </activation>
- </profile>
- <profile>
- <id>ibmjdk</id>
- <activation>
- <property>
- <name>java.vendor</name>
- <value>IBM Corporation</value>
- </property>
- </activation>
- <dependencies>
- <dependency>
- <groupId>xerces</groupId>
- <artifactId>xercesImpl</artifactId>
- </dependency>
- </dependencies>
- </profile>
- <profile>
- <id>mac-jdk16</id>
- <activation>
- <file>
- <exists>${java.home}/../Classes/classes.jar</exists>
- </file>
- </activation>
- <dependencies>
- <dependency>
- <groupId>com.sun</groupId>
- <artifactId>tools</artifactId>
- <version>1.6.0</version>
- <scope>system</scope>
- <systemPath>${java.home}/../Classes/classes.jar</systemPath>
- </dependency>
- </dependencies>
- </profile>
- <profile>
- <id>setup.eclipse</id>
- <build>
- <defaultGoal>process-test-sources</defaultGoal>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>setup.eclipse.project.wadl2java</id>
- <phase>process-test-sources</phase>
- <configuration>
- <target>
- <!-- The javadoc dumping capability requires com.sun classes from with rt/classes.jar -->
- <propertyfile file="${basedir}/.settings/org.eclipse.jdt.core.prefs">
- <entry key="org.eclipse.jdt.core.compiler.problem.forbiddenReference" value="ignore" />
- </propertyfile>
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
diff --git a/maven-plugins/java2swagger-plugin/src/main/java/org/apache/cxf/maven_plugin/java2swagger/Java2SwaggerMojo.java b/maven-plugins/java2swagger-plugin/src/main/java/org/apache/cxf/maven_plugin/java2swagger/Java2SwaggerMojo.java
deleted file mode 100644
index eeefa9b9a7..0000000000
--- a/maven-plugins/java2swagger-plugin/src/main/java/org/apache/cxf/maven_plugin/java2swagger/Java2SwaggerMojo.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cxf.maven_plugin.java2swagger;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.lang.annotation.Annotation;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectWriter;
-
-import org.apache.cxf.helpers.FileUtils;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.MavenProjectHelper;
-import org.reflections.Reflections;
-
-import io.swagger.annotations.Api;
-import io.swagger.jaxrs.Reader;
-import io.swagger.models.Contact;
-import io.swagger.models.Info;
-import io.swagger.models.License;
-import io.swagger.models.Scheme;
-import io.swagger.models.Swagger;
-import io.swagger.util.Yaml;
-
-
-
-/**
- * @goal java2swagger
- * @description CXF Java To swagger payload Tool
- * @requiresDependencyResolution test
- * @threadSafe
- */
-public class Java2SwaggerMojo extends AbstractMojo {
-
- /**
- * @parameter
- * @required
- */
- private List<String> resourcePackages;
-
- /**
- * @parameter default-value="${project.version}"
- */
- private String version;
-
-
- /**
- * @parameter default-value="/api"
- */
- private String basePath;
-
- /**
- * @parameter default-value="${project.name}"
- */
- private String title;
-
-
- /**
- * @parameter default-value="${project.description}"
- */
- private String description;
-
-
- /**
- * @parameter
- */
- private String contact;
-
-
- /**
- * @parameter default-value="Apache 2.0 License"
- */
- private String license;
-
- /**
- * @parameter default-value="http://www.apache.org/licenses/LICENSE-2.0.html"
- */
- private String licenseUrl;
-
- /**
- * @parameter
- */
- private String host;
-
- /**
- * @parameter
- */
- private List<String> schemes;
-
-
- /**
- * @parameter default-value="json"
- */
- private String payload;
-
-
- /**
- * @parameter
- */
- private String outputFile;
-
-
- /**
- * Attach the generated swagger file to the list of files to be deployed
- * on install. This means the swagger file will be copied to the repository
- * with groupId, artifactId and version of the project and type "json" or "yaml".
- * <p/>
- * With this option you can use the maven repository as a Service Repository.
- *
- * @parameter default-value="false"
- */
- private Boolean attachSwagger;
-
-
- /**
- * @parameter
- */
- private String classifier;
-
-
- /**
- * @parameter expression="${project}"
- * @required
- */
- private MavenProject project;
-
-
- /**
- * Maven ProjectHelper.
- *
- * @component
- * @readonly
- */
- private MavenProjectHelper projectHelper;
-
-
- /**
- * @parameter
- */
- private String outputFileName;
-
-
- private ClassLoader resourceClassLoader;
-
- private Swagger swagger;
-
- private ObjectMapper mapper = new ObjectMapper();
-
- private Set<Class<?>> resourceClasses;
-
-
- public void execute() throws MojoExecutionException {
- try {
- configureSwagger();
- loadSwaggerAnnotation();
- generateSwaggerPayLoad();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
-
- private void generateSwaggerPayLoad() throws MojoExecutionException {
-
- if (outputFile == null && project != null) {
- // Put the json in target/generated/json
- // put the yaml in target/generated/yaml
-
- final String name;
- if (outputFileName != null) {
- name = outputFileName;
- } else if (resourceClasses.size() == 1) {
- name = resourceClasses.iterator().next().getSimpleName();
- } else {
- name = "swagger";
- }
- outputFile = (project.getBuild().getDirectory() + "/generated/" + payload.toLowerCase() + "/" + name + "."
- + payload.toLowerCase()).replace("/", File.separator);
- }
-
- FileUtils.mkDir(new File(outputFile).getParentFile());
- try (BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile))) {
- if ("json".equals(this.payload)) {
- ObjectWriter jsonWriter = mapper.writer(new DefaultPrettyPrinter());
- writer.write(jsonWriter.writeValueAsString(swagger));
- } else if ("yaml".equals(this.payload)) {
- writer.write(Yaml.pretty().writeValueAsString(swagger));
- }
-
- } catch (IOException e) {
- throw new MojoExecutionException(e.getMessage(), e);
- }
-
- // Attach the generated swagger file to the artifacts that get deployed
- // with the enclosing project
- if (attachSwagger && outputFile != null) {
- File jsonFile = new File(outputFile);
- if (jsonFile.exists()) {
- if (classifier != null) {
- projectHelper.attachArtifact(project, payload.toLowerCase(), classifier, jsonFile);
- } else {
- projectHelper.attachArtifact(project, payload.toLowerCase(), jsonFile);
- }
-
- }
- }
- }
-
-
- private ClassLoader getClassLoader() throws MojoExecutionException {
- if (resourceClassLoader == null) {
- try {
- List<?> runtimeClasspathElements = project.getRuntimeClasspathElements();
- URL[] runtimeUrls = new URL[runtimeClasspathElements.size()];
- for (int i = 0; i < runtimeClasspathElements.size(); i++) {
- String element = (String) runtimeClasspathElements.get(i);
- runtimeUrls[i] = new File(element).toURI().toURL();
- }
- resourceClassLoader = new URLClassLoader(runtimeUrls, Thread.currentThread()
- .getContextClassLoader());
- } catch (Exception e) {
- throw new MojoExecutionException(e.getMessage(), e);
- }
- }
- return resourceClassLoader;
- }
-
- private Set<Class<?>> loadResourceClasses(Class<? extends Annotation> clazz) throws MojoExecutionException {
- resourceClasses = new LinkedHashSet<>(this.resourcePackages.size());
- Thread.currentThread().setContextClassLoader(getClassLoader());
- for (String resourcePackage : resourcePackages) {
- Set<Class<?>> c = new Reflections(resourcePackage).getTypesAnnotatedWith(clazz, true);
- resourceClasses.addAll(c);
- Set<Class<?>> inherited = new Reflections(resourcePackage).getTypesAnnotatedWith(clazz);
- resourceClasses.addAll(inherited);
- }
-
- return resourceClasses;
- }
-
-
-
- private void loadSwaggerAnnotation() throws MojoExecutionException {
- Reader reader = new Reader(swagger);
- swagger = reader.read(loadResourceClasses(Api.class));
- }
-
- private void configureSwagger() {
- swagger = new Swagger();
- mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
- mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
- Info info = new Info();
- Contact swaggerContact = new Contact();
- License swaggerLicense = new License();
- swaggerLicense.name(this.license)
- .url(this.licenseUrl);
- swaggerContact.name(this.contact);
- info.version(this.version)
- .description(this.description)
- .contact(swaggerContact)
- .license(swaggerLicense)
- .title(this.title);
- swagger.setInfo(info);
- if (this.schemes != null) {
- for (String scheme : this.schemes) {
- swagger.scheme(Scheme.forValue(scheme));
- }
- }
- swagger.setHost(this.host);
- swagger.setBasePath(this.basePath);
- }
-}
diff --git a/maven-plugins/java2swagger-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml b/maven-plugins/java2swagger-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
deleted file mode 100644
index ad17f2f8fe..0000000000
--- a/maven-plugins/java2swagger-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
--->
-<lifecycleMappingMetadata>
- <pluginExecutions>
- <pluginExecution>
- <pluginExecutionFilter>
- <goals>
- <goal>java2swagger</goal>
- </goals>
- </pluginExecutionFilter>
- <action>
- <execute>
- <ignore/>
- </execute>
- </action>
- </pluginExecution>
- </pluginExecutions>
-</lifecycleMappingMetadata>
diff --git a/maven-plugins/pom.xml b/maven-plugins/pom.xml
index c7cc02f54b..6c162a8a4d 100644
--- a/maven-plugins/pom.xml
+++ b/maven-plugins/pom.xml
@@ -46,7 +46,6 @@
<id>javax</id>
<modules>
<module>wadl2java-plugin</module>
- <module>java2swagger-plugin</module>
</modules>
</profile>
</profiles>
diff --git a/parent/pom.xml b/parent/pom.xml
index 042aed44ba..6f5ede8f52 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -188,9 +188,6 @@
<cxf.stax-ex.version>1.8.3</cxf.stax-ex.version>
<cxf.swagger.ui.version>4.14.0</cxf.swagger.ui.version>
<cxf.swagger.v3.version>2.2.3</cxf.swagger.v3.version>
- <cxf.swagger2.version>1.6.6</cxf.swagger2.version>
- <cxf.swagger2.guava.version>31.0.1-jre</cxf.swagger2.guava.version>
- <cxf.swagger2.guava.failureaccess.version>1.0.1</cxf.swagger2.guava.failureaccess.version>
<cxf.tika.version>2.4.1</cxf.tika.version>
<cxf.tomcat.version>10.0.22</cxf.tomcat.version>
<cxf.tomitribe.http.signature.version>1.8</cxf.tomitribe.http.signature.version>
@@ -1748,11 +1745,6 @@
</exclusion>
</exclusions>
</dependency>
- <dependency>
- <groupId>io.swagger</groupId>
- <artifactId>swagger-jaxrs</artifactId>
- <version>${cxf.swagger2.version}</version>
- </dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-jaxrs2-jakarta</artifactId>
diff --git a/rt/rs/description-swagger/pom.xml b/rt/rs/description-swagger/pom.xml
deleted file mode 100644
index 87c43b4c95..0000000000
--- a/rt/rs/description-swagger/pom.xml
+++ /dev/null
@@ -1,89 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <artifactId>cxf-rt-rs-service-description-swagger</artifactId>
- <packaging>bundle</packaging>
- <name>Apache CXF JAX-RS Service Description Swagger</name>
- <description>Apache CXF JAX-RS Service Description Swagger</description>
- <url>https://cxf.apache.org</url>
- <parent>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-parent</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- <relativePath>../../../parent/pom.xml</relativePath>
- </parent>
- <properties>
- <cxf.module.name>org.apache.cxf.rs.swagger</cxf.module.name>
- </properties>
- <dependencies>
- <dependency>
- <groupId>jakarta.xml.ws</groupId>
- <artifactId>jakarta.xml.ws-api</artifactId>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${cxf.servlet-api.group}</groupId>
- <artifactId>${cxf.servlet-api.artifact}</artifactId>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-frontend-jaxrs</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-rs-service-description-common-openapi</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-rs-service-description-swagger-ui</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>io.swagger</groupId>
- <artifactId>swagger-jaxrs</artifactId>
- <exclusions>
- <exclusion>
- <groupId>javax.ws.rs</groupId>
- <artifactId>jsr311-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-rs-json-basic</artifactId>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
diff --git a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/AbstractSwaggerFeature.java b/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/AbstractSwaggerFeature.java
deleted file mode 100644
index c403242eb1..0000000000
--- a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/AbstractSwaggerFeature.java
+++ /dev/null
@@ -1,308 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cxf.jaxrs.swagger;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.cxf.Bus;
-import org.apache.cxf.common.util.PackageUtils;
-import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.feature.AbstractPortableFeature;
-import org.apache.cxf.feature.DelegatingFeature;
-import org.apache.cxf.jaxrs.JAXRSServiceFactoryBean;
-import org.apache.cxf.jaxrs.model.ClassResourceInfo;
-
-public abstract class AbstractSwaggerFeature<T extends AbstractSwaggerFeature.Portable>
- extends DelegatingFeature<T> {
- protected AbstractSwaggerFeature(final T d) {
- super(d);
- }
-
- public static boolean isSwaggerJaxRsAvailable() {
- return Portable.isSwaggerJaxRsAvailable();
- }
-
- public void addSwaggerResource(Server server, Bus bus) {
- getDelegate().addSwaggerResource(server, bus);
- }
-
- public void setBasePathByAddress(String address) {
- getDelegate().setBasePathByAddress(address);
- }
-
- public void calculateDefaultResourcePackage(Server server) {
- getDelegate().calculateDefaultResourcePackage(server);
- }
-
- public void calculateDefaultBasePath(Server server) {
- getDelegate().calculateDefaultBasePath(server);
- }
-
- public String getResourcePackage() {
- return getDelegate().getResourcePackage();
- }
-
- public void setResourcePackage(String resourcePackage) {
- getDelegate().setResourcePackage(resourcePackage);
- }
-
- public String getVersion() {
- return getDelegate().getVersion();
- }
-
- public void setVersion(String version) {
- getDelegate().setVersion(version);
- }
-
- public String getBasePath() {
- return getDelegate().getBasePath();
- }
-
- public void setBasePath(String basePath) {
- getDelegate().setBasePath(basePath);
- }
-
- public String getTitle() {
- return getDelegate().getTitle();
- }
-
- public void setTitle(String title) {
- getDelegate().setTitle(title);
- }
-
- public String getDescription() {
- return getDelegate().getDescription();
- }
-
- public void setDescription(String description) {
- getDelegate().setDescription(description);
- }
-
- public String getContact() {
- return getDelegate().getContact();
- }
-
- public void setContact(String contact) {
- getDelegate().setContact(contact);
- }
-
- public String getLicense() {
- return getDelegate().getLicense();
- }
-
- public void setLicense(String license) {
- getDelegate().setLicense(license);
- }
-
- public String getLicenseUrl() {
- return getDelegate().getLicenseUrl();
- }
-
- public void setLicenseUrl(String licenseUrl) {
- getDelegate().setLicenseUrl(licenseUrl);
- }
-
- public String getTermsOfServiceUrl() {
- return getDelegate().getTermsOfServiceUrl();
- }
-
- public void setTermsOfServiceUrl(String termsOfServiceUrl) {
- getDelegate().setTermsOfServiceUrl(termsOfServiceUrl);
- }
-
- public String getFilterClass() {
- return getDelegate().getFilterClass();
- }
-
- public void setFilterClass(String filterClass) {
- getDelegate().setFilterClass(filterClass);
- }
-
- public boolean isRunAsFilter() {
- return getDelegate().isRunAsFilter();
- }
-
- public void setRunAsFilter(boolean runAsFilter) {
- getDelegate().setRunAsFilter(runAsFilter);
- }
-
- public boolean isActivateOnlyIfJaxrsSupported() {
- return getDelegate().isActivateOnlyIfJaxrsSupported();
- }
-
- public void setActivateOnlyIfJaxrsSupported(boolean activateOnlyIfJaxrsSupported) {
- getDelegate().setActivateOnlyIfJaxrsSupported(activateOnlyIfJaxrsSupported);
- }
-
- public abstract static class Portable implements AbstractPortableFeature {
- private static final boolean SWAGGER_JAXRS_AVAILABLE;
-
- static {
- SWAGGER_JAXRS_AVAILABLE = isSwaggerJaxRsAvailable();
- }
-
- protected boolean licenseWasSet;
- private boolean runAsFilter;
- private boolean activateOnlyIfJaxrsSupported;
- private String resourcePackage;
- private String version;
- private String basePath;
- private String title;
- private String description;
- private String contact;
- private String license;
- private String licenseUrl;
- private String termsOfServiceUrl;
- private String filterClass;
-
- private static boolean isSwaggerJaxRsAvailable() {
- try {
- Class.forName("io.swagger.jaxrs.DefaultParameterExtension");
- return true;
- } catch (Throwable ex) {
- return false;
- }
- }
-
- @Override
- public void initialize(Server server, Bus bus) {
- if (!activateOnlyIfJaxrsSupported || SWAGGER_JAXRS_AVAILABLE) {
- calculateDefaultResourcePackage(server);
- calculateDefaultBasePath(server);
- addSwaggerResource(server, bus);
-
- doInitializeProvider(server.getEndpoint(), bus);
- bus.setProperty("swagger.service.description.available", "true");
- }
- }
-
- protected abstract void addSwaggerResource(Server server, Bus bus);
-
- protected abstract void setBasePathByAddress(String address);
-
- void calculateDefaultResourcePackage(Server server) {
- if (!StringUtils.isEmpty(getResourcePackage())) {
- return;
- }
- JAXRSServiceFactoryBean serviceFactoryBean =
- (JAXRSServiceFactoryBean)server.getEndpoint().get(JAXRSServiceFactoryBean.class.getName());
- List<ClassResourceInfo> resourceInfos = serviceFactoryBean.getClassResourceInfo();
-
- if (resourceInfos.size() == 1) {
- setResourcePackage(resourceInfos.get(0).getServiceClass().getPackage().getName());
- } else {
- List<Class<?>> serviceClasses = new ArrayList<>(resourceInfos.size());
- for (ClassResourceInfo cri : resourceInfos) {
- serviceClasses.add(cri.getServiceClass());
- }
- String sharedPackage = PackageUtils.getSharedPackageName(serviceClasses);
- if (!StringUtils.isEmpty(sharedPackage)) {
- setResourcePackage(sharedPackage);
- }
- }
- }
-
- protected void calculateDefaultBasePath(Server server) {
- if (getBasePath() == null || getBasePath().length() == 0) {
- String address = server.getEndpoint().getEndpointInfo().getAddress();
- setBasePathByAddress(address);
- }
- }
-
- public String getResourcePackage() {
- return resourcePackage;
- }
- public void setResourcePackage(String resourcePackage) {
- this.resourcePackage = resourcePackage;
- }
- public String getVersion() {
- return version;
- }
- public void setVersion(String version) {
- this.version = version;
- }
- public String getBasePath() {
- return basePath;
- }
- public void setBasePath(String basePath) {
- this.basePath = basePath;
- }
- public String getTitle() {
- return title;
- }
- public void setTitle(String title) {
- this.title = title;
- }
- public String getDescription() {
- return description;
- }
- public void setDescription(String description) {
- this.description = description;
- }
- public String getContact() {
- return contact;
- }
- public void setContact(String contact) {
- this.contact = contact;
- }
- public String getLicense() {
- return license;
- }
- public void setLicense(String license) {
- this.licenseWasSet = true;
- this.license = license;
- }
- public String getLicenseUrl() {
- return licenseUrl;
- }
- public void setLicenseUrl(String licenseUrl) {
- this.licenseUrl = licenseUrl;
- }
- public String getTermsOfServiceUrl() {
- return termsOfServiceUrl;
- }
- public void setTermsOfServiceUrl(String termsOfServiceUrl) {
- this.termsOfServiceUrl = termsOfServiceUrl;
- }
- public String getFilterClass() {
- return filterClass;
- }
- public void setFilterClass(String filterClass) {
- this.filterClass = filterClass;
- }
-
- public boolean isRunAsFilter() {
- return runAsFilter;
- }
- public void setRunAsFilter(boolean runAsFilter) {
- this.runAsFilter = runAsFilter;
- }
-
- public boolean isActivateOnlyIfJaxrsSupported() {
- return activateOnlyIfJaxrsSupported;
- }
-
- public void setActivateOnlyIfJaxrsSupported(boolean activateOnlyIfJaxrsSupported) {
- this.activateOnlyIfJaxrsSupported = activateOnlyIfJaxrsSupported;
- }
- }
-
-}
diff --git a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/ApplicationBeanConfig.java b/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/ApplicationBeanConfig.java
deleted file mode 100644
index e2ce73dd1f..0000000000
--- a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/ApplicationBeanConfig.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cxf.jaxrs.swagger;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import jakarta.ws.rs.core.Application;
-
-import io.swagger.jaxrs.config.BeanConfig;
-
-public class ApplicationBeanConfig extends BeanConfig {
- private Application app;
- public ApplicationBeanConfig(Application app) {
- this.app = app;
- }
- @Override
- public Set<Class<?>> classes() {
- Set<Class<?>> allClasses = new HashSet<>();
- allClasses.addAll(app.getClasses());
- for (Object singleton : app.getSingletons()) {
- allClasses.add(singleton.getClass());
- }
- return allClasses;
- }
-}
diff --git a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/JaxRs2Extension.java b/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/JaxRs2Extension.java
deleted file mode 100644
index aa7420e0ae..0000000000
--- a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/JaxRs2Extension.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cxf.jaxrs.swagger;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-
-import com.fasterxml.jackson.databind.BeanDescription;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.introspect.AnnotatedField;
-import com.fasterxml.jackson.databind.introspect.AnnotatedMethod;
-import com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition;
-
-import jakarta.validation.constraints.DecimalMax;
-import jakarta.validation.constraints.DecimalMin;
-import jakarta.validation.constraints.Max;
-import jakarta.validation.constraints.Min;
-import jakarta.validation.constraints.NotNull;
-import jakarta.validation.constraints.Pattern;
-import jakarta.validation.constraints.Size;
-import jakarta.ws.rs.BeanParam;
-import jakarta.ws.rs.MatrixParam;
-
-import io.swagger.converter.ModelConverters;
-import io.swagger.jaxrs.ext.AbstractSwaggerExtension;
-import io.swagger.jaxrs.ext.SwaggerExtension;
-import io.swagger.jaxrs.ext.SwaggerExtensions;
-import io.swagger.models.parameters.AbstractSerializableParameter;
-import io.swagger.models.parameters.Parameter;
-import io.swagger.models.properties.ArrayProperty;
-import io.swagger.models.properties.Property;
-import io.swagger.models.properties.RefProperty;
-import io.swagger.models.properties.StringProperty;
-import io.swagger.util.Json;
-import io.swagger.util.ParameterProcessor;
-
-
-public class JaxRs2Extension extends AbstractSwaggerExtension {
-
- private final ObjectMapper mapper = Json.mapper();
-
- @SuppressWarnings("deprecation")
- @Override
- public List<Parameter> extractParameters(
- final List<Annotation> annotations,
- final Type type,
- final Set<Type> typesToSkip,
- final Iterator<SwaggerExtension> chain) {
-
- if (shouldIgnoreType(type, typesToSkip)) {
- return new ArrayList<>();
- }
-
- List<Parameter> parameters = new ArrayList<>();
- for (Annotation annotation : annotations) {
- if (annotation instanceof MatrixParam) {
- MatrixParam param = (MatrixParam) annotation;
- MatrixParameter mp = new MatrixParameter().name(param.value());
-
- Property schema = createProperty(type);
- if (schema != null) {
- mp.setProperty(schema);
- }
- applyBeanValidatorAnnotations(mp, annotations);
- parameters.add(mp);
- } else if (annotation instanceof BeanParam) {
- // Use Jackson's logic for processing Beans
- final BeanDescription beanDesc = mapper.getSerializationConfig().introspect(constructType(type));
- final List<BeanPropertyDefinition> properties = beanDesc.findProperties();
-
- for (final BeanPropertyDefinition propDef : properties) {
- final AnnotatedField field = propDef.getField();
- final AnnotatedMethod setter = propDef.getSetter();
- final List<Annotation> paramAnnotations = new ArrayList<>();
- final Iterator<SwaggerExtension> extensions = SwaggerExtensions.chain();
- Type paramType = null;
-
- // Gather the field's details
- if (field != null) {
- paramType = field.getAnnotated().getType();
-
- for (final Annotation fieldAnnotation : field.annotations()) {
- if (!paramAnnotations.contains(fieldAnnotation)) {
- paramAnnotations.add(fieldAnnotation);
- }
- }
- }
-
- // Gather the setter's details but only the ones we need
- if (setter != null) {
- // Do not set the param class/type from the setter if the values are already identified
- if (paramType == null && setter.getMember().getGenericParameterTypes() != null) {
- paramType = setter.getMember().getGenericParameterTypes()[0];
- }
-
- for (final Annotation fieldAnnotation : setter.annotations()) {
- if (!paramAnnotations.contains(fieldAnnotation)) {
- paramAnnotations.add(fieldAnnotation);
- }
- }
- }
-
- // Re-process all Bean fields and let the default swagger-jaxrs processor do its thing
- List<Parameter> extracted =
- extensions.next().extractParameters(paramAnnotations, paramType, typesToSkip, extensions);
-
- // since downstream processors won't know how to introspect @BeanParam, process here
- for (Parameter param : extracted) {
- if (ParameterProcessor.applyAnnotations(null, param, paramType, paramAnnotations) != null) {
- applyBeanValidatorAnnotations(param, paramAnnotations);
- parameters.add(param);
- }
- }
- }
- }
- }
-
- // Only call down to the other items in the chain if no parameters were produced
- if (parameters.isEmpty()) {
- parameters = super.extractParameters(annotations, type, typesToSkip, chain);
- }
-
- return parameters;
- }
-
- private Property createProperty(final Type type) {
- return enforcePrimitive(ModelConverters.getInstance().readAsProperty(type), 0);
- }
-
- private Property enforcePrimitive(final Property in, final int level) {
- if (in instanceof RefProperty) {
- return new StringProperty();
- }
- if (in instanceof ArrayProperty) {
- if (level == 0) {
- final ArrayProperty array = (ArrayProperty) in;
- array.setItems(enforcePrimitive(array.getItems(), level + 1));
- } else {
- return new StringProperty();
- }
- }
- return in;
- }
-
- /**
- * This is essentially a duplicate of {@link io.swagger.jackson.ModelResolver.applyBeanValidatorAnnotations}.
- *
- * @param parameter
- * @param annotations
- */
- private void applyBeanValidatorAnnotations(final Parameter parameter, final List<Annotation> annotations) {
- Map<String, Annotation> annos = new HashMap<>();
- if (annotations != null) {
- for (Annotation annotation : annotations) {
- annos.put(annotation.annotationType().getName(), annotation);
- }
- }
-
- if (annos.containsKey(NotNull.class.getName())) {
- parameter.setRequired(true);
- }
-
- if (parameter instanceof AbstractSerializableParameter) {
- AbstractSerializableParameter<?> serializable = (AbstractSerializableParameter<?>) parameter;
-
- if (annos.containsKey(Min.class.getName())) {
- Min min = (Min) annos.get(Min.class.getName());
- serializable.setMinimum(BigDecimal.valueOf(min.value()));
- }
- if (annos.containsKey(Max.class.getName())) {
- Max max = (Max) annos.get(Max.class.getName());
- serializable.setMaximum(BigDecimal.valueOf(max.value()));
- }
- if (annos.containsKey(Size.class.getName())) {
- Size size = (Size) annos.get(Size.class.getName());
-
- serializable.setMinimum(BigDecimal.valueOf(size.min()));
- serializable.setMaximum(BigDecimal.valueOf(size.max()));
-
- serializable.setMinItems(size.min());
- serializable.setMaxItems(size.max());
- }
- if (annos.containsKey(DecimalMin.class.getName())) {
- DecimalMin min = (DecimalMin) annos.get(DecimalMin.class.getName());
- if (min.inclusive()) {
- serializable.setMinimum(BigDecimal.valueOf(Double.valueOf(min.value())));
- } else {
- serializable.setExclusiveMinimum(!min.inclusive());
- }
- }
- if (annos.containsKey(DecimalMax.class.getName())) {
- DecimalMax max = (DecimalMax) annos.get(DecimalMax.class.getName());
- if (max.inclusive()) {
- serializable.setMaximum(BigDecimal.valueOf(Double.valueOf(max.value())));
- } else {
- serializable.setExclusiveMaximum(!max.inclusive());
- }
- }
- if (annos.containsKey(Pattern.class.getName())) {
- Pattern pattern = (Pattern) annos.get(Pattern.class.getName());
- serializable.setPattern(pattern.regexp());
- }
- }
- }
-
-}
diff --git a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/MatrixParameter.java b/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/MatrixParameter.java
deleted file mode 100644
index f1472c2e1b..0000000000
--- a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/MatrixParameter.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cxf.jaxrs.swagger;
-
-import io.swagger.models.parameters.AbstractSerializableParameter;
-
-public class MatrixParameter extends AbstractSerializableParameter<MatrixParameter> {
-
- public MatrixParameter() {
- super.setIn("matrix");
- }
-}
diff --git a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2ApiListingResource.java b/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2ApiListingResource.java
deleted file mode 100644
index 00f0735958..0000000000
--- a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2ApiListingResource.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cxf.jaxrs.swagger;
-
-import jakarta.servlet.ServletConfig;
-import jakarta.servlet.ServletContext;
-import jakarta.ws.rs.core.Application;
-import jakarta.ws.rs.core.HttpHeaders;
-import jakarta.ws.rs.core.UriInfo;
-
-import io.swagger.jaxrs.listing.ApiListingResource;
-import io.swagger.models.Swagger;
-
-public class Swagger2ApiListingResource extends ApiListingResource {
- private Swagger2Customizer customizer;
- public Swagger2ApiListingResource(Swagger2Customizer customizer) {
- this.customizer = customizer;
- }
- @Override
- protected Swagger process(Application app,
- ServletContext servletContext,
- ServletConfig sc,
- HttpHeaders headers,
- UriInfo uriInfo) {
- Swagger s = super.process(app, servletContext, sc, headers, uriInfo);
- if (customizer != null) {
- s = customizer.customize(s);
- }
- return s;
- }
-}
\ No newline at end of file
diff --git a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Customizer.java b/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Customizer.java
deleted file mode 100644
index 5b5aa003d9..0000000000
--- a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Customizer.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cxf.jaxrs.swagger;
-
-import java.net.URL;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.apache.commons.lang3.tuple.Pair;
-import org.apache.cxf.jaxrs.ext.MessageContext;
-import org.apache.cxf.jaxrs.model.ClassResourceInfo;
-import org.apache.cxf.jaxrs.model.OperationResourceInfo;
-import org.apache.cxf.jaxrs.model.doc.DocumentationProvider;
-import org.apache.cxf.jaxrs.model.doc.JavaDocProvider;
-import org.apache.cxf.jaxrs.utils.JAXRSUtils;
-
-import io.swagger.jaxrs.config.BeanConfig;
-import io.swagger.models.HttpMethod;
-import io.swagger.models.Operation;
-import io.swagger.models.Path;
-import io.swagger.models.Swagger;
-import io.swagger.models.Tag;
-import io.swagger.models.parameters.Parameter;
-
-public class Swagger2Customizer {
-
- protected boolean dynamicBasePath;
-
- protected boolean replaceTags;
-
- protected boolean applyDefaultVersion = true;
-
- protected DocumentationProvider javadocProvider;
-
- protected List<ClassResourceInfo> cris;
-
- protected BeanConfig beanConfig;
-
- public Swagger customize(Swagger data) {
-
- if (dynamicBasePath) {
- MessageContext ctx = createMessageContext();
- String currentBasePath = StringUtils.substringBeforeLast(ctx.getHttpServletRequest().getRequestURI(), "/");
- data.setBasePath(currentBasePath);
- if (data.getHost() == null) {
- data.setHost(beanConfig.getHost());
- }
- if (data.getInfo() == null) {
- data.setInfo(beanConfig.getInfo());
- }
-
- if (beanConfig.getSwagger() != null
- && beanConfig.getSwagger().getSecurityDefinitions() != null
- && data.getSecurityDefinitions() == null) {
- data.setSecurityDefinitions(beanConfig.getSwagger().getSecurityDefinitions());
- }
- }
-
- if (replaceTags || javadocProvider != null) {
- Map<String, ClassResourceInfo> operations = new HashMap<>();
- Map<Pair<String, String>, OperationResourceInfo> methods = new HashMap<>();
- for (ClassResourceInfo cri : cris) {
- for (OperationResourceInfo ori : cri.getMethodDispatcher().getOperationResourceInfos()) {
- String normalizedPath = getNormalizedPath(
- cri.getURITemplate().getValue(), ori.getURITemplate().getValue());
-
- operations.put(normalizedPath, cri);
- methods.put(ImmutablePair.of(ori.getHttpMethod(), normalizedPath), ori);
- }
- }
-
- if (replaceTags && data.getTags() != null) {
- data.getTags().clear();
- }
- for (final Map.Entry<String, Path> entry : data.getPaths().entrySet()) {
- Tag tag = null;
- if (replaceTags && operations.containsKey(entry.getKey())) {
- ClassResourceInfo cri = operations.get(entry.getKey());
-
- tag = new Tag();
- tag.setName(cri.getURITemplate().getValue().replaceAll("/", "_"));
- if (javadocProvider != null) {
- tag.setDescription(javadocProvider.getClassDoc(cri));
- }
-
- data.addTag(tag);
- }
-
- for (Map.Entry<HttpMethod, Operation> subentry : entry.getValue().getOperationMap().entrySet()) {
- if (replaceTags && tag != null) {
- subentry.getValue().setTags(Collections.singletonList(tag.getName()));
- }
-
- Pair<String, String> key = ImmutablePair.of(subentry.getKey().name(), entry.getKey());
- if (methods.containsKey(key) && javadocProvider != null) {
- OperationResourceInfo ori = methods.get(key);
-
- subentry.getValue().setSummary(javadocProvider.getMethodDoc(ori));
- for (int i = 0; i < subentry.getValue().getParameters().size(); i++) {
- subentry.getValue().getParameters().get(i).
- setDescription(javadocProvider.getMethodParameterDoc(ori, i));
- }
- addParameters(subentry.getValue().getParameters());
-
- if (subentry.getValue().getResponses() != null
- && !subentry.getValue().getResponses().isEmpty()) {
-
- subentry.getValue().getResponses().entrySet().iterator().next().getValue().
- setDescription(javadocProvider.getMethodResponseDoc(ori));
- }
- }
- }
- }
- }
- if (replaceTags && data.getTags() != null) {
- Collections.sort(data.getTags(), new Comparator<Tag>() {
-
- @Override
- public int compare(final Tag tag1, final Tag tag2) {
- return tag1.getName().compareTo(tag2.getName());
- }
- });
- }
- applyDefaultVersion(data);
- return data;
- }
-
- private MessageContext createMessageContext() {
- return JAXRSUtils.createContextValue(
- JAXRSUtils.getCurrentMessage(), null, MessageContext.class);
- }
-
- protected String getNormalizedPath(String classResourcePath, String operationResourcePath) {
- StringBuilder normalizedPath = new StringBuilder();
-
- String[] segments = (classResourcePath + operationResourcePath).split("/");
- for (String segment : segments) {
- if (!StringUtils.isEmpty(segment)) {
- normalizedPath.append('/').append(segment);
- }
- }
- // Adapt to Swagger's path expression
- if (normalizedPath.toString().endsWith(":.*}")) {
- normalizedPath.setLength(normalizedPath.length() - 4);
- normalizedPath.append('}');
- }
- return StringUtils.EMPTY.equals(normalizedPath.toString()) ? "/" : normalizedPath.toString();
- }
-
- protected void applyDefaultVersion(Swagger data) {
- if (applyDefaultVersion && data.getInfo() != null && data.getInfo().getVersion() == null
- && beanConfig != null && beanConfig.getResourcePackage() != null) {
- Package resourcePackage = Package.getPackage(beanConfig.getResourcePackage());
- if (resourcePackage != null) {
- data.getInfo().setVersion(resourcePackage.getImplementationVersion());
- }
- }
- }
-
- /**
- * Allows to add parameters to the list, related to an {@link Operation} instance; the method is invoked
- * for all instances available.
- *
- * @param parameters list of parameters defined for an {@link Operation}
- * @see io.swagger.models.parameters.HeaderParameter
- * @see io.swagger.models.parameters.CookieParameter
- * @see io.swagger.models.parameters.PathParameter
- * @see io.swagger.models.parameters.BodyParameter
- * @see io.swagger.models.parameters.QueryParameter
- * @see io.swagger.models.parameters.RefParameter
- */
- protected void addParameters(final List<Parameter> parameters) {
- // does nothing by default
- }
-
- public void setDynamicBasePath(final boolean dynamicBasePath) {
- this.dynamicBasePath = dynamicBasePath;
- }
-
- public void setReplaceTags(final boolean replaceTags) {
- this.replaceTags = replaceTags;
- }
-
- public void setJavadocProvider(final DocumentationProvider javadocProvider) {
- this.javadocProvider = javadocProvider;
- }
-
- public void setClassResourceInfos(final List<ClassResourceInfo> classResourceInfos) {
- this.cris = classResourceInfos;
- }
-
- public void setJavaDocPath(final String javaDocPath) throws Exception {
- this.javadocProvider = new JavaDocProvider(javaDocPath);
- }
-
- public void setJavaDocPaths(final String... javaDocPaths) throws Exception {
- this.javadocProvider = new JavaDocProvider(javaDocPaths);
- }
-
- public void setJavaDocURLs(final URL[] javaDocURLs) {
- this.javadocProvider = new JavaDocProvider(javaDocURLs);
- }
-
- public void setBeanConfig(BeanConfig beanConfig) {
- this.beanConfig = beanConfig;
- }
-
- public void setApplyDefaultVersion(boolean applyDefaultVersion) {
- this.applyDefaultVersion = applyDefaultVersion;
- }
-}
diff --git a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Feature.java b/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Feature.java
deleted file mode 100644
index d346e7a089..0000000000
--- a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Feature.java
+++ /dev/null
@@ -1,693 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cxf.jaxrs.swagger;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Properties;
-import java.util.Set;
-import java.util.UUID;
-
-import jakarta.servlet.ServletConfig;
-import jakarta.servlet.ServletContext;
-import jakarta.ws.rs.container.ContainerRequestContext;
-import jakarta.ws.rs.container.ContainerRequestFilter;
-import jakarta.ws.rs.container.PreMatching;
-import jakarta.ws.rs.core.Application;
-import jakarta.ws.rs.core.Context;
-import jakarta.ws.rs.core.Response;
-import jakarta.ws.rs.core.UriInfo;
-import org.apache.cxf.Bus;
-import org.apache.cxf.annotations.Provider;
-import org.apache.cxf.annotations.Provider.Scope;
-import org.apache.cxf.annotations.Provider.Type;
-import org.apache.cxf.common.util.PropertyUtils;
-import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.jaxrs.JAXRSServiceFactoryBean;
-import org.apache.cxf.jaxrs.common.openapi.DefaultApplicationFactory;
-import org.apache.cxf.jaxrs.common.openapi.DelegatingServletConfig;
-import org.apache.cxf.jaxrs.common.openapi.SwaggerProperties;
-import org.apache.cxf.jaxrs.common.openapi.SyntheticServletConfig;
-import org.apache.cxf.jaxrs.ext.ContextProvider;
-import org.apache.cxf.jaxrs.ext.MessageContext;
-import org.apache.cxf.jaxrs.model.ApplicationInfo;
-import org.apache.cxf.jaxrs.model.ClassResourceInfo;
-import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
-import org.apache.cxf.jaxrs.swagger.ui.SwaggerUiConfig;
-import org.apache.cxf.jaxrs.swagger.ui.SwaggerUiSupport;
-import org.apache.cxf.jaxrs.utils.InjectionUtils;
-import org.apache.cxf.message.Message;
-
-import io.swagger.jaxrs.config.BeanConfig;
-import io.swagger.jaxrs.config.DefaultReaderConfig;
-import io.swagger.jaxrs.config.ReaderConfig;
-import io.swagger.jaxrs.config.SwaggerContextService;
-import io.swagger.jaxrs.listing.ApiListingResource;
-import io.swagger.jaxrs.listing.SwaggerSerializers;
-import io.swagger.models.Swagger;
-import io.swagger.models.auth.SecuritySchemeDefinition;
-
-@Provider(value = Type.Feature, scope = Scope.Server)
-public class Swagger2Feature extends AbstractSwaggerFeature<Swagger2Feature.Portable>
- implements SwaggerUiSupport, SwaggerProperties {
- public Swagger2Feature() {
- super(new Portable());
- }
-
- @Override
- protected Portable getDelegate() {
- return delegate;
- }
-
- @Override
- public void calculateDefaultBasePath(Server server) {
- delegate.calculateDefaultBasePath(server);
- }
-
- @Override
- public void addSwaggerResource(Server server, Bus bus) {
- delegate.addSwaggerResource(server, bus);
- }
-
- public void initBeanConfig(BeanConfig beanConfig, Properties props) {
- delegate.initBeanConfig(beanConfig, props);
- }
-
- public Boolean isUsePathBasedConfig() {
- return delegate.isUsePathBasedConfig();
- }
-
- public void setUsePathBasedConfig(Boolean usePathBasedConfig) {
- delegate.setUsePathBasedConfig(usePathBasedConfig);
- }
-
- public String getHost() {
- return delegate.getHost();
- }
-
- public void setHost(String host) {
- delegate.setHost(host);
- }
-
- public String[] getSchemes() {
- return delegate.getSchemes();
- }
-
- public void setSchemes(String[] schemes) {
- delegate.setSchemes(schemes);
- }
-
- public Boolean isPrettyPrint() {
- return delegate.isPrettyPrint();
- }
-
- public void setPrettyPrint(Boolean prettyPrint) {
- delegate.setPrettyPrint(prettyPrint);
- }
-
- public Swagger2Customizer getCustomizer() {
- return delegate.getCustomizer();
- }
-
- public void setCustomizer(Swagger2Customizer customizer) {
- delegate.setCustomizer(customizer);
- }
-
- public boolean isScanAllResources() {
- return delegate.isScanAllResources();
- }
-
- public void setScanAllResources(boolean scanAllResources) {
- delegate.setScanAllResources(scanAllResources);
- }
-
- public String getIgnoreRoutes() {
- return delegate.getIgnoreRoutes();
- }
-
- public void setIgnoreRoutes(String ignoreRoutes) {
- delegate.setIgnoreRoutes(ignoreRoutes);
- }
-
- @Override
- public void setBasePathByAddress(String address) {
- delegate.setBasePathByAddress(address);
- }
-
- public void setSwaggerUiMavenGroupAndArtifact(String swaggerUiMavenGroupAndArtifact) {
- delegate.setSwaggerUiMavenGroupAndArtifact(swaggerUiMavenGroupAndArtifact);
- }
-
- public void setSwaggerUiVersion(String swaggerUiVersion) {
- delegate.setSwaggerUiVersion(swaggerUiVersion);
- }
-
- public void setSupportSwaggerUi(boolean supportSwaggerUi) {
- delegate.setSupportSwaggerUi(supportSwaggerUi);
- }
-
- @Override
- public Boolean isSupportSwaggerUi() {
- return delegate.isSupportSwaggerUi();
- }
-
- public void setSwaggerUiMediaTypes(Map<String, String> swaggerUiMediaTypes) {
- delegate.setSwaggerUiMediaTypes(swaggerUiMediaTypes);
- }
-
- @Override
- public Map<String, String> getSwaggerUiMediaTypes() {
- return delegate.getSwaggerUiMediaTypes();
- }
-
- public void setSecurityDefinitions(Map<String, SecuritySchemeDefinition> securityDefinitions) {
- delegate.setSecurityDefinitions(securityDefinitions);
- }
-
- public String getPropertiesLocation() {
- return delegate.getPropertiesLocation();
- }
-
- public void setPropertiesLocation(String propertiesLocation) {
- delegate.setPropertiesLocation(propertiesLocation);
- }
-
- public boolean isScan() {
- return delegate.isScan();
- }
-
- public void setScan(boolean scan) {
- delegate.setScan(scan);
- }
-
- public void setSwaggerUiConfig(SwaggerUiConfig swaggerUiConfig) {
- delegate.setSwaggerUiConfig(swaggerUiConfig);
- }
-
- @Override
- public SwaggerUiConfig getSwaggerUiConfig() {
- return delegate.getSwaggerUiConfig();
- }
-
- @Override
- public String findSwaggerUiRoot() {
- return delegate.findSwaggerUiRoot();
- }
-
- public static class Portable extends AbstractSwaggerFeature.Portable
- implements SwaggerUiSupport, SwaggerProperties {
- private static final String SCHEMES_PROPERTY = "schemes";
- private static final String HOST_PROPERTY = "host";
- private static final String USE_PATH_CFG_PROPERTY = "use.path.based.config";
-
- private boolean scan;
- private boolean scanAllResources;
-
- private String ignoreRoutes;
-
- private Boolean supportSwaggerUi;
-
- private String swaggerUiVersion;
-
- private String swaggerUiMavenGroupAndArtifact;
-
- private Map<String, String> swaggerUiMediaTypes;
-
- private boolean dynamicBasePath;
-
- private Map<String, SecuritySchemeDefinition> securityDefinitions;
-
- private Swagger2Customizer customizer;
-
- private String host;
- private String[] schemes;
- private Boolean prettyPrint;
- private Boolean usePathBasedConfig;
-
- private String propertiesLocation = DEFAULT_PROPS_LOCATION;
- // Swagger UI configuration parameters (to be passed as query string).
- private SwaggerUiConfig swaggerUiConfig;
-
- @Override
- protected void calculateDefaultBasePath(Server server) {
- dynamicBasePath = true;
- super.calculateDefaultBasePath(server);
- }
-
- @Override
- protected void addSwaggerResource(Server server, Bus bus) {
- JAXRSServiceFactoryBean sfb =
- (JAXRSServiceFactoryBean) server.getEndpoint().get(JAXRSServiceFactoryBean.class.getName());
-
- ServerProviderFactory factory =
- (ServerProviderFactory)server.getEndpoint().get(ServerProviderFactory.class.getName());
- final ApplicationInfo appInfo = DefaultApplicationFactory.createApplicationInfoOrDefault(server,
- factory, sfb, bus, isScan());
-
- List<Object> swaggerResources = new LinkedList<>();
-
- if (customizer == null) {
- customizer = new Swagger2Customizer();
- }
- ApiListingResource apiListingResource = new Swagger2ApiListingResource(customizer);
- swaggerResources.add(apiListingResource);
-
- List<Object> providers = new ArrayList<>();
- providers.add(new SwaggerSerializers());
-
- if (isRunAsFilter()) {
- providers.add(new SwaggerContainerRequestFilter(appInfo == null ? null : appInfo.getProvider(),
- customizer));
- }
-
- final Properties swaggerProps = getSwaggerProperties(propertiesLocation, bus);
- final Registration swaggerUiRegistration = getSwaggerUi(bus, swaggerProps, isRunAsFilter());
-
- if (!isRunAsFilter()) {
- swaggerResources.addAll(swaggerUiRegistration.getResources());
- }
-
- providers.addAll(swaggerUiRegistration.getProviders());
- sfb.setResourceClassesFromBeans(swaggerResources);
-
- List<ClassResourceInfo> cris = sfb.getClassResourceInfo();
- if (!isRunAsFilter()) {
- for (ClassResourceInfo cri : cris) {
- if (ApiListingResource.class.isAssignableFrom(cri.getResourceClass())) {
- InjectionUtils.injectContextProxies(cri, apiListingResource);
- }
- }
- }
- customizer.setClassResourceInfos(cris);
- customizer.setDynamicBasePath(dynamicBasePath);
-
- BeanConfig beanConfig = appInfo == null
- ? new BeanConfig()
- : new ApplicationBeanConfig(appInfo.getProvider());
- initBeanConfig(beanConfig, swaggerProps);
-
- Swagger swagger = beanConfig.getSwagger();
- if (swagger != null && securityDefinitions != null) {
- swagger.setSecurityDefinitions(securityDefinitions);
- }
- customizer.setBeanConfig(beanConfig);
-
- providers.add(new ReaderConfigFilter());
-
- if (beanConfig.isUsePathBasedConfig()) {
- providers.add(new ServletConfigProvider());
- }
-
- factory.setUserProviders(providers);
- }
-
- protected void initBeanConfig(BeanConfig beanConfig, Properties props) {
-
- // resource package
- String theResourcePackage = getResourcePackage();
- if (theResourcePackage == null && props != null) {
- theResourcePackage = props.getProperty(RESOURCE_PACKAGE_PROPERTY);
- }
- beanConfig.setResourcePackage(theResourcePackage);
-
- // use path based configuration
- Boolean theUsePathBasedConfig = isUsePathBasedConfig();
- if (theUsePathBasedConfig == null && props != null) {
- theUsePathBasedConfig = PropertyUtils.isTrue(props.get(USE_PATH_CFG_PROPERTY));
- }
- if (theUsePathBasedConfig == null) {
- theUsePathBasedConfig = false;
- }
- beanConfig.setUsePathBasedConfig(theUsePathBasedConfig);
-
- // version
- String theVersion = getVersion();
- if (theVersion == null && props != null) {
- theVersion = props.getProperty(VERSION_PROPERTY);
- }
- beanConfig.setVersion(theVersion);
-
- // host
- String theHost = getHost();
- if (theHost == null && props != null) {
- theHost = props.getProperty(HOST_PROPERTY);
- }
- beanConfig.setHost(theHost);
-
- // schemes
- String[] theSchemes = getSchemes();
- if (theSchemes == null && props != null && props.containsKey(SCHEMES_PROPERTY)) {
- theSchemes = props.getProperty(SCHEMES_PROPERTY).split(",");
- }
- beanConfig.setSchemes(theSchemes);
-
- // title
- String theTitle = getTitle();
- if (theTitle == null && props != null) {
- theTitle = props.getProperty(TITLE_PROPERTY);
- }
- beanConfig.setTitle(theTitle);
-
- // description
- String theDescription = getDescription();
- if (theDescription == null && props != null) {
- theDescription = props.getProperty(DESCRIPTION_PROPERTY);
- }
- beanConfig.setDescription(theDescription);
-
- // contact
- String theContact = getContact();
- if (theContact == null && props != null) {
- theContact = props.getProperty(CONTACT_PROPERTY);
- }
- beanConfig.setContact(theContact);
-
- // license
- String theLicense = getLicense();
- if (theLicense == null && !licenseWasSet) {
- if (props != null) {
- theLicense = props.getProperty(LICENSE_PROPERTY);
- if (theLicense != null && theLicense.isEmpty()) {
- theLicense = null;
- }
- } else {
- theLicense = DEFAULT_LICENSE_VALUE;
- }
- }
- beanConfig.setLicense(theLicense);
-
- // license url
- String theLicenseUrl = getLicenseUrl();
- if (theLicenseUrl == null && props != null) {
- theLicenseUrl = props.getProperty(LICENSE_URL_PROPERTY);
- }
- if (theLicenseUrl == null && DEFAULT_LICENSE_VALUE.equals(theLicense)) {
- theLicenseUrl = DEFAULT_LICENSE_URL;
- }
- beanConfig.setLicenseUrl(theLicenseUrl);
-
- // terms of service url
- String theTermsUrl = getTermsOfServiceUrl();
- if (theTermsUrl == null && props != null) {
- theTermsUrl = props.getProperty(TERMS_URL_PROPERTY);
- }
- beanConfig.setTermsOfServiceUrl(theTermsUrl);
-
- // pretty print
- Boolean thePrettyPrint = isPrettyPrint();
- if (thePrettyPrint == null && props != null) {
- thePrettyPrint = PropertyUtils.isTrue(props.get(PRETTY_PRINT_PROPERTY));
- }
- if (thePrettyPrint == null) {
- thePrettyPrint = false;
- }
- beanConfig.setPrettyPrint(thePrettyPrint);
-
- // filter class
- String theFilterClass = getFilterClass();
- if (theFilterClass == null && props != null) {
- theFilterClass = props.getProperty(FILTER_CLASS_PROPERTY);
- }
- beanConfig.setFilterClass(theFilterClass);
-
- // scan
- beanConfig.setScan(isScan());
-
- // base path is calculated dynamically
- beanConfig.setBasePath(getBasePath());
-
- }
-
- public Boolean isUsePathBasedConfig() {
- return usePathBasedConfig;
- }
-
- public void setUsePathBasedConfig(Boolean usePathBasedConfig) {
- this.usePathBasedConfig = usePathBasedConfig;
- }
-
- public String getHost() {
- return host;
- }
-
- public void setHost(String host) {
- this.host = host;
- }
-
- public String[] getSchemes() {
- return schemes;
- }
-
- public void setSchemes(String[] schemes) {
- this.schemes = schemes;
- }
-
- public Boolean isPrettyPrint() {
- return prettyPrint;
- }
-
- public void setPrettyPrint(Boolean prettyPrint) {
- this.prettyPrint = prettyPrint;
- }
-
- public Swagger2Customizer getCustomizer() {
- return customizer;
- }
-
- public void setCustomizer(Swagger2Customizer customizer) {
- this.customizer = customizer;
- }
-
- public boolean isScanAllResources() {
- return scanAllResources;
- }
-
- public void setScanAllResources(boolean scanAllResources) {
- this.scanAllResources = scanAllResources;
- }
-
- public String getIgnoreRoutes() {
- return ignoreRoutes;
- }
-
- public void setIgnoreRoutes(String ignoreRoutes) {
- this.ignoreRoutes = ignoreRoutes;
- }
-
- @Override
- protected void setBasePathByAddress(String address) {
- if (!address.startsWith("/")) {
- // get the path part
- URI u = URI.create(address);
- setBasePath(u.getPath());
- if (getHost() == null) {
- setHost(u.getPort() < 0 ? u.getHost() : u.getHost() + ":" + u.getPort());
- }
- } else {
- setBasePath(address);
- }
- }
-
- /**
- * Set SwaggerUI Maven group and artifact using the "groupId/artifactId" format.
- * @param swaggerUiMavenGroupAndArtifact
- */
- public void setSwaggerUiMavenGroupAndArtifact(String swaggerUiMavenGroupAndArtifact) {
- this.swaggerUiMavenGroupAndArtifact = swaggerUiMavenGroupAndArtifact;
- }
-
- public void setSwaggerUiVersion(String swaggerUiVersion) {
- this.swaggerUiVersion = swaggerUiVersion;
- }
-
- public void setSupportSwaggerUi(boolean supportSwaggerUi) {
- this.supportSwaggerUi = supportSwaggerUi;
- }
-
- @Override
- public Boolean isSupportSwaggerUi() {
- return supportSwaggerUi;
- }
-
- public void setSwaggerUiMediaTypes(Map<String, String> swaggerUiMediaTypes) {
- this.swaggerUiMediaTypes = swaggerUiMediaTypes;
- }
-
- @Override
- public Map<String, String> getSwaggerUiMediaTypes() {
- return swaggerUiMediaTypes;
- }
-
- public void setSecurityDefinitions(Map<String, SecuritySchemeDefinition> securityDefinitions) {
- this.securityDefinitions = securityDefinitions;
- }
-
- public String getPropertiesLocation() {
- return propertiesLocation;
- }
-
- public void setPropertiesLocation(String propertiesLocation) {
- this.propertiesLocation = propertiesLocation;
- }
-
- public boolean isScan() {
- return scan;
- }
-
- public void setScan(boolean scan) {
- this.scan = scan;
- }
-
- public void setSwaggerUiConfig(final SwaggerUiConfig swaggerUiConfig) {
- this.swaggerUiConfig = swaggerUiConfig;
- }
-
- @Override
- public SwaggerUiConfig getSwaggerUiConfig() {
- return swaggerUiConfig;
- }
-
- @Override
- public String findSwaggerUiRoot() {
- return SwaggerUi.findSwaggerUiRoot(swaggerUiMavenGroupAndArtifact, swaggerUiVersion);
- }
-
- private class ServletConfigProvider implements ContextProvider<ServletConfig> {
-
- private String id = UUID.randomUUID().toString();
-
- @Override
- public ServletConfig createContext(Message message) {
- final ServletConfig sc = (ServletConfig)message.get("HTTP.CONFIG");
-
- // When deploying into OSGi container, it is possible to use embedded Jetty
- // transport. In this case, the ServletConfig is not available and Swagger
- // does not take into account certain configuration parameters. To overcome
- // that, the ServletConfig is synthesized from ServletContext instance.
- if (sc == null) {
- final ServletContext context = (ServletContext)message.get("HTTP.CONTEXT");
- if (context != null) {
- return new SyntheticServletConfig(context) {
- @Override
- public String getInitParameter(String name) {
- if (Objects.equals(SwaggerContextService.USE_PATH_BASED_CONFIG, name)) {
- return "true";
- } else if (SwaggerContextService.CONFIG_ID_KEY.equals(name)) {
- return id;
- } else {
- return super.getInitParameter(name);
- }
- }
- };
- }
- } else if (sc.getInitParameter(SwaggerContextService.USE_PATH_BASED_CONFIG) == null) {
- return new DelegatingServletConfig(sc) {
- @Override
- public String getInitParameter(String name) {
- if (Objects.equals(SwaggerContextService.USE_PATH_BASED_CONFIG, name)) {
- return "true";
- } else if (SwaggerContextService.CONFIG_ID_KEY.equals(name)) {
- return id;
- } else {
- return super.getInitParameter(name);
- }
- }
- };
- }
-
- return sc;
- }
- }
-
- protected class ReaderConfigFilter implements ContainerRequestFilter {
-
- @Context
- protected MessageContext mc;
-
- @Override
- public void filter(ContainerRequestContext requestContext) throws IOException {
- ServletContext servletContext = mc.getServletContext();
- if (servletContext != null && servletContext.getAttribute(ReaderConfig.class.getName()) == null) {
- if (mc.getServletConfig() != null
- && Boolean.valueOf(mc.getServletConfig().getInitParameter("scan.all.resources"))) {
- addReaderConfig(mc.getServletConfig().getInitParameter("ignore.routes"));
- } else if (isScanAllResources()) {
- addReaderConfig(getIgnoreRoutes());
- }
- }
- }
-
- protected void addReaderConfig(String ignoreRoutesParam) {
- DefaultReaderConfig rc = new DefaultReaderConfig();
- rc.setScanAllResources(true);
- if (ignoreRoutesParam != null) {
- Set<String> routes = new LinkedHashSet<>();
- for (String route : ignoreRoutesParam.split(",")) {
- routes.add(route.trim());
- }
- rc.setIgnoredRoutes(routes);
- }
- mc.getServletContext().setAttribute(ReaderConfig.class.getName(), rc);
- }
- }
- }
-
- @PreMatching
- protected static class SwaggerContainerRequestFilter extends Swagger2ApiListingResource
- implements ContainerRequestFilter {
-
- protected static final String APIDOCS_LISTING_PATH_JSON = "swagger.json";
- protected static final String APIDOCS_LISTING_PATH_YAML = "swagger.yaml";
-
- @Context
- protected MessageContext mc;
-
- private Application app;
- public SwaggerContainerRequestFilter(Application app, Swagger2Customizer customizer) {
- super(customizer);
- this.app = app;
- }
-
- @Override
- public void filter(ContainerRequestContext requestContext) throws IOException {
- UriInfo ui = mc.getUriInfo();
-
- Response response = null;
- if (ui.getPath().endsWith(APIDOCS_LISTING_PATH_JSON)) {
-
- response = getListingJsonResponse(
- app, mc.getServletContext(), mc.getServletConfig(), mc.getHttpHeaders(), ui);
- } else if (ui.getPath().endsWith(APIDOCS_LISTING_PATH_YAML)) {
-
- response = getListingYamlResponse(
- app, mc.getServletContext(), mc.getServletConfig(), mc.getHttpHeaders(), ui);
- }
-
- if (response != null) {
- requestContext.abortWith(response);
- }
- }
- }
-}
diff --git a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerUi.java b/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerUi.java
deleted file mode 100644
index 8e9376faa6..0000000000
--- a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerUi.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cxf.jaxrs.swagger;
-
-import org.apache.cxf.jaxrs.swagger.ui.SwaggerUiResolver;
-
-import io.swagger.annotations.Api;
-
-/**
- * SwaggerUI resolvers implementation for Swagger 1.5.x
- */
-public final class SwaggerUi {
- private static final SwaggerUiResolver HELPER;
-
- static {
- SwaggerUiResolver theHelper;
- //TODO: [OSGi+Jakarta] uncomment this when osgi comes back
- /* try {
- theHelper = new OsgiSwaggerUiResolver(Api.class);
- } catch (Throwable ex) {
- theHelper = new SwaggerUiResolver(AbstractSwaggerFeature.class.getClassLoader());
- }*/
- theHelper = new SwaggerUiResolver(AbstractSwaggerFeature.class.getClassLoader());
- HELPER = theHelper;
- }
-
- private SwaggerUi() {
- }
-
- public static String findSwaggerUiRoot(String swaggerUiMavenGroupAndArtifact,
- String swaggerUiVersion) {
- String root = HELPER.findSwaggerUiRootInternal(swaggerUiMavenGroupAndArtifact,
- swaggerUiVersion);
- if (root == null && HELPER.getClass() != SwaggerUiResolver.class) {
- root = new SwaggerUiResolver(AbstractSwaggerFeature.class.getClassLoader())
- .findSwaggerUiRootInternal(swaggerUiMavenGroupAndArtifact, swaggerUiVersion);
- }
- return root;
- }
-}
diff --git a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/openapi/OpenApiConfiguration.java b/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/openapi/OpenApiConfiguration.java
deleted file mode 100644
index c0f2256aa8..0000000000
--- a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/openapi/OpenApiConfiguration.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cxf.jaxrs.swagger.openapi;
-
-public class OpenApiConfiguration {
- private boolean createRequestBodies;
-
- public boolean isCreateRequestBodies() {
- return createRequestBodies;
- }
-
- public void setCreateRequestBodies(boolean createRequestBodies) {
- this.createRequestBodies = createRequestBodies;
- }
-}
diff --git a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/openapi/SwaggerToOpenApiConversionFilter.java b/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/openapi/SwaggerToOpenApiConversionFilter.java
deleted file mode 100644
index 70d768cfd1..0000000000
--- a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/openapi/SwaggerToOpenApiConversionFilter.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cxf.jaxrs.swagger.openapi;
-
-import java.io.IOException;
-import java.net.URI;
-
-import jakarta.ws.rs.container.ContainerRequestContext;
-import jakarta.ws.rs.container.ContainerRequestFilter;
-import jakarta.ws.rs.container.ContainerResponseContext;
-import jakarta.ws.rs.container.ContainerResponseFilter;
-import jakarta.ws.rs.container.PreMatching;
-import jakarta.ws.rs.ext.Provider;
-import org.apache.cxf.jaxrs.ext.MessageContext;
-import org.apache.cxf.jaxrs.utils.JAXRSUtils;
-
-import io.swagger.util.Json;
-
-@Provider
-@PreMatching
-public final class SwaggerToOpenApiConversionFilter implements ContainerRequestFilter, ContainerResponseFilter {
-
- private static final String SWAGGER_PATH = "swagger.json";
- private static final String OPEN_API_PATH = "openapi.json";
- private static final String OPEN_API_PROPERTY = "openapi";
-
- private OpenApiConfiguration openApiConfig;
- private String openApiJsonPath = OPEN_API_PATH;
-
- @Override
- public void filter(ContainerRequestContext reqCtx) throws IOException {
- String path = reqCtx.getUriInfo().getPath();
- if (path.endsWith(openApiJsonPath)) {
- reqCtx.setRequestUri(URI.create(SWAGGER_PATH));
- reqCtx.setProperty(OPEN_API_PROPERTY, Boolean.TRUE);
- }
-
- }
-
- @Override
- public void filter(ContainerRequestContext reqCtx, ContainerResponseContext respCtx) throws IOException {
- if (Boolean.TRUE == reqCtx.getProperty(OPEN_API_PROPERTY)) {
- final Object entity = respCtx.getEntity();
- // Right before 1.5.18, the entity was always a String but became a model object
- // (io.swagger.models.Swagger) after. For now, let us serialize it to JSON manually.
- String swaggerJson = entity instanceof String ? (String)entity : Json.pretty(entity);
- String openApiJson = SwaggerToOpenApiConversionUtils.getOpenApiFromSwaggerJson(
- createMessageContext(), swaggerJson, openApiConfig);
- respCtx.setEntity(openApiJson);
- }
- }
-
- private MessageContext createMessageContext() {
- return JAXRSUtils.createContextValue(
- JAXRSUtils.getCurrentMessage(), null, MessageContext.class);
- }
-
- public void setOpenApiConfig(OpenApiConfiguration openApiConfig) {
- this.openApiConfig = openApiConfig;
- }
-
- public void setOpenApiJsonPath(String openApiJsonPath) {
- this.openApiJsonPath = openApiJsonPath;
- }
-}
diff --git a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/openapi/SwaggerToOpenApiConversionUtils.java b/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/openapi/SwaggerToOpenApiConversionUtils.java
deleted file mode 100644
index 6abc5dd2d9..0000000000
--- a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/openapi/SwaggerToOpenApiConversionUtils.java
+++ /dev/null
@@ -1,414 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cxf.jaxrs.swagger.openapi;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Logger;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.BusFactory;
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.helpers.CastUtils;
-import org.apache.cxf.helpers.IOUtils;
-import org.apache.cxf.jaxrs.ext.MessageContext;
-import org.apache.cxf.jaxrs.json.basic.JsonMapObject;
-import org.apache.cxf.jaxrs.json.basic.JsonMapObjectReaderWriter;
-import org.apache.cxf.jaxrs.utils.ExceptionUtils;
-import org.apache.cxf.jaxrs.utils.ResourceUtils;
-
-public final class SwaggerToOpenApiConversionUtils {
- private static final Logger LOG = LogUtils.getL7dLogger(SwaggerToOpenApiConversionUtils.class);
-
- private static final List<String> SIMPLE_TYPE_RELATED_PROPS =
- Arrays.asList("format", "minimum", "maximum", "default");
-
- private SwaggerToOpenApiConversionUtils() {
-
- }
-
- public static String getOpenApiFromSwaggerLoc(String loc) {
- return getOpenApiFromSwaggerLoc(loc, null);
- }
-
- public static String getOpenApiFromSwaggerLoc(String loc, OpenApiConfiguration cfg) {
- return getOpenApiFromSwaggerLoc(loc, cfg, BusFactory.getThreadDefaultBus());
- }
-
- public static String getOpenApiFromSwaggerLoc(String loc, OpenApiConfiguration cfg, Bus bus) {
- try {
- InputStream is = ResourceUtils.getResourceStream(loc, bus);
- if (is == null) {
- return null;
- }
- return getOpenApiFromSwaggerStream(is, cfg);
- } catch (Exception ex) {
- LOG.warning("Problem with processing a user model at " + loc + ", exception: "
- + ExceptionUtils.getStackTrace(ex));
- }
- return null;
- }
-
- public static String getOpenApiFromSwaggerStream(InputStream is) throws IOException {
- return getOpenApiFromSwaggerStream(is, null);
- }
-
- public static String getOpenApiFromSwaggerStream(InputStream is, OpenApiConfiguration cfg) throws IOException {
- return getOpenApiFromSwaggerJson(null, IOUtils.readStringFromStream(is), cfg);
- }
-
- public static String getOpenApiFromSwaggerJson(String json) throws IOException {
- return getOpenApiFromSwaggerJson(null, json, null);
- }
-
- public static String getOpenApiFromSwaggerJson(
- MessageContext ctx, String json, OpenApiConfiguration cfg) throws IOException {
-
- JsonMapObjectReaderWriter readerWriter = new JsonMapObjectReaderWriter();
- JsonMapObject sw2 = readerWriter.fromJsonToJsonObject(json);
- JsonMapObject sw3 = new JsonMapObject();
-
- // "openapi"
- sw3.setProperty("openapi", "3.0.0");
-
- // "servers"
- setServersProperty(ctx, sw2, sw3);
-
- // "info"
- JsonMapObject infoObject = sw2.getJsonMapProperty("info");
- if (infoObject != null) {
- sw3.setProperty("info", infoObject);
- }
-
- // "tags"
- List<Map<String, Object>> tagsObject = sw2.getListMapProperty("tags");
- if (tagsObject != null) {
- sw3.setProperty("tags", tagsObject);
- }
-
- // paths
- Map<String, JsonMapObject> requestBodies = cfg != null && cfg.isCreateRequestBodies()
- ? new LinkedHashMap<>() : null;
- setPathsProperty(sw2, sw3, requestBodies);
-
- // components
- setComponentsProperty(sw2, sw3, requestBodies);
-
- // externalDocs
- Object externalDocsObject = sw2.getProperty("externalDocs");
- if (externalDocsObject != null) {
- sw3.setProperty("externalDocs", externalDocsObject);
- }
-
- return readerWriter.toJson(sw3).replace("#/definitions/", "#/components/schemas/");
- }
-
- private static void setComponentsProperty(JsonMapObject sw2, JsonMapObject sw3,
- Map<String, JsonMapObject> requestBodies) {
- JsonMapObject comps = new JsonMapObject();
- JsonMapObject requestBodiesObj = new JsonMapObject();
- if (requestBodies != null) {
- for (Map.Entry<String, JsonMapObject> entry : requestBodies.entrySet()) {
- requestBodiesObj.setProperty(entry.getKey(), entry.getValue());
- }
- }
- comps.setProperty("requestBodies", requestBodiesObj);
-
- Object s2Defs = sw2.getProperty("definitions");
- if (s2Defs != null) {
- comps.setProperty("schemas", s2Defs);
- }
- JsonMapObject s2SecurityDefs = sw2.getJsonMapProperty("securityDefinitions");
- if (s2SecurityDefs != null) {
- comps.setProperty("securitySchemes", s2SecurityDefs);
-
- for (String property : s2SecurityDefs.asMap().keySet()) {
- JsonMapObject securityScheme = s2SecurityDefs.getJsonMapProperty(property);
- if ("basic".equals(securityScheme.getStringProperty("type"))) {
- securityScheme.setProperty("type", "http");
- securityScheme.setProperty("scheme", "basic");
- }
- }
- }
-
- sw3.setProperty("components", comps);
- }
-
- private static void setPathsProperty(JsonMapObject sw2, JsonMapObject sw3,
- Map<String, JsonMapObject> requestBodies) {
- JsonMapObject sw2Paths = sw2.getJsonMapProperty("paths");
- for (Map.Entry<String, Object> sw2PathEntries : sw2Paths.asMap().entrySet()) {
- JsonMapObject sw2PathVerbs = new JsonMapObject(CastUtils.cast((Map<?, ?>)sw2PathEntries.getValue()));
- for (Map.Entry<String, Object> sw2PathVerbEntries : sw2PathVerbs.asMap().entrySet()) {
- JsonMapObject sw2PathVerbProps =
- new JsonMapObject(CastUtils.cast((Map<?, ?>)sw2PathVerbEntries.getValue()));
-
- prepareRequestBody(sw2PathVerbProps, requestBodies);
- prepareResponses(sw2PathVerbProps);
-
- }
- }
-
- sw3.setProperty("paths", sw2Paths);
- }
-
- private static void prepareResponses(JsonMapObject sw2PathVerbProps) {
- List<String> sw2PathVerbProduces =
- CastUtils.cast((List<?>)sw2PathVerbProps.removeProperty("produces"));
-
- JsonMapObject sw2PathVerbResps = sw2PathVerbProps.getJsonMapProperty("responses");
- if (sw2PathVerbResps != null) {
- JsonMapObject sw3PathVerbResps = new JsonMapObject();
-
- if (sw2PathVerbResps.containsProperty("200")) {
- JsonMapObject okResp =
- new JsonMapObject(CastUtils.cast((Map<?, ?>)sw2PathVerbResps.removeProperty("200")));
- JsonMapObject newOkResp = new JsonMapObject();
- String description = okResp.getStringProperty("description");
- if (description != null) {
- newOkResp.setProperty("description", description);
- }
- JsonMapObject schema = okResp.getJsonMapProperty("schema");
- if (schema != null) {
- JsonMapObject content = prepareContentFromSchema(schema, sw2PathVerbProduces, false);
- if (content != null) {
- newOkResp.setProperty("content", content);
- }
-
- }
- JsonMapObject headers = okResp.getJsonMapProperty("headers");
- if (headers != null) {
- newOkResp.setProperty("headers", headers);
- }
- sw3PathVerbResps.setProperty("200", newOkResp);
- }
- for (Map.Entry<String, Object> entry : sw2PathVerbResps.asMap().entrySet()) {
- sw3PathVerbResps.setProperty(entry.getKey(), entry.getValue());
- }
- sw2PathVerbProps.setProperty("responses", sw3PathVerbResps);
- }
- }
-
- private static void prepareRequestBody(JsonMapObject sw2PathVerbProps,
- Map<String, JsonMapObject> requestBodies) {
- List<String> sw2PathVerbConsumes =
- CastUtils.cast((List<?>)sw2PathVerbProps.removeProperty("consumes"));
-
- JsonMapObject sw3RequestBody = null;
- List<JsonMapObject> sw3formBody = null;
- List<Map<String, Object>> sw2PathVerbParamsList = sw2PathVerbProps.getListMapProperty("parameters");
- if (sw2PathVerbParamsList != null) {
- for (Iterator<Map<String, Object>> it = sw2PathVerbParamsList.iterator(); it.hasNext();) {
- JsonMapObject sw2PathVerbParamMap = new JsonMapObject(it.next());
- if ("body".equals(sw2PathVerbParamMap.getStringProperty("in"))) {
- it.remove();
-
- sw3RequestBody = new JsonMapObject();
- String description = sw2PathVerbParamMap.getStringProperty("description");
- if (description != null) {
- sw3RequestBody.setProperty("description", description);
- }
- Boolean required = sw2PathVerbParamMap.getBooleanProperty("required");
- if (required != null) {
- sw3RequestBody.setProperty("required", required);
- }
- JsonMapObject schema = sw2PathVerbParamMap.getJsonMapProperty("schema");
- if (schema != null) {
- JsonMapObject content = prepareContentFromSchema(schema, sw2PathVerbConsumes,
- requestBodies != null);
- if (content != null) {
- sw3RequestBody.setProperty("content", content);
- }
-
- }
- } else if ("formData".equals(sw2PathVerbParamMap.getStringProperty("in"))) {
- it.remove();
- if (sw3formBody == null) {
- sw3formBody = new LinkedList<>();
- sw3RequestBody = new JsonMapObject();
- }
- sw2PathVerbParamMap.removeProperty("in");
- sw2PathVerbParamMap.removeProperty("required");
- sw3formBody.add(sw2PathVerbParamMap);
- } else if ("array".equals(sw2PathVerbParamMap.getStringProperty("type"))) {
- sw2PathVerbParamMap.removeProperty("type");
- sw2PathVerbParamMap.removeProperty("collectionFormat");
- sw2PathVerbParamMap.setProperty("explode", true);
- JsonMapObject items = sw2PathVerbParamMap.getJsonMapProperty("items");
- sw2PathVerbParamMap.removeProperty("items");
- JsonMapObject schema = new JsonMapObject();
- schema.setProperty("type", "array");
- schema.setProperty("items", items);
- sw2PathVerbParamMap.setProperty("schema", schema);
- } else {
- if ("matrix".equals(sw2PathVerbParamMap.getStringProperty("in"))) {
- sw2PathVerbParamMap.removeProperty("in");
- sw2PathVerbParamMap.setProperty("in", "path");
- sw2PathVerbParamMap.setProperty("style", "matrix");
- }
-
- String type = (String)sw2PathVerbParamMap.removeProperty("type");
- Object enumK = sw2PathVerbParamMap.removeProperty("enum");
- if (type != null) {
- JsonMapObject schema = new JsonMapObject();
- schema.setProperty("type", type);
- if (enumK != null) {
- schema.setProperty("enum", enumK);
- }
- for (String prop : SIMPLE_TYPE_RELATED_PROPS) {
- Object value = sw2PathVerbParamMap.removeProperty(prop);
- if (value != null) {
- schema.setProperty(prop, value);
- }
- }
- if ("password".equals(sw2PathVerbParamMap.getProperty("name"))) {
- schema.setProperty("format", "password");
- }
- sw2PathVerbParamMap.setProperty("schema", schema);
- }
- }
- }
- }
- if (sw2PathVerbParamsList.isEmpty()) {
- sw2PathVerbProps.removeProperty("parameters");
- }
- if (sw3formBody != null) {
- sw3RequestBody.setProperty("content", prepareFormContent(sw3formBody, sw2PathVerbConsumes));
- }
- if (sw3RequestBody != null) {
- if (requestBodies == null || sw3formBody != null) {
- sw2PathVerbProps.setProperty("requestBody", sw3RequestBody);
- } else {
- JsonMapObject content = sw3RequestBody.getJsonMapProperty("content");
- if (content != null) {
- String requestBodyName = (String)content.removeProperty("requestBodyName");
- if (requestBodyName != null) {
- requestBodies.put(requestBodyName, sw3RequestBody);
- String ref = "#components/requestBodies/" + requestBodyName;
- sw2PathVerbProps.setProperty("requestBody",
- Collections.singletonMap("$ref", ref));
- }
- }
- }
- }
- }
-
- private static JsonMapObject prepareFormContent(List<JsonMapObject> formList, List<String> mediaTypes) {
- String mediaType = StringUtils.isEmpty(mediaTypes)
- ? "application/x-www-form-urlencoded" : mediaTypes.get(0);
- JsonMapObject content = new JsonMapObject();
- JsonMapObject formType = new JsonMapObject();
- JsonMapObject schema = new JsonMapObject();
- schema.setProperty("type", "object");
- JsonMapObject props = new JsonMapObject();
- for (JsonMapObject prop : formList) {
- String name = (String)prop.removeProperty("name");
- props.setProperty(name, prop);
- if ("file".equals(prop.getProperty("type"))) {
- prop.setProperty("type", "string");
- if (!prop.containsProperty("format")) {
- prop.setProperty("format", "binary");
- }
- }
- }
- schema.setProperty("properties", props);
- formType.setProperty("schema", schema);
- content.setProperty(mediaType, formType);
- return content;
- }
-
- private static JsonMapObject prepareContentFromSchema(JsonMapObject schema,
- List<String> mediaTypes,
- boolean storeModelName) {
- String type = schema.getStringProperty("type");
- String modelName = null;
- boolean isArray = false;
- if (!"object".equals(type) || !"string".equals(type)) {
- final String ref;
- JsonMapObject items = null;
- if ("array".equals(type)) {
- isArray = true;
- items = schema.getJsonMapProperty("items");
- ref = (String)items.getProperty("$ref");
- } else {
- ref = schema.getStringProperty("$ref");
- }
- if (ref != null) {
- int index = ref.lastIndexOf('/');
- modelName = ref.substring(index + 1);
- if (items == null) {
- schema.setProperty("$ref", "#components/schemas/" + modelName);
- } else {
- items.setProperty("$ref", "#components/schemas/" + modelName);
- }
- }
- }
- JsonMapObject content = new JsonMapObject();
-
- List<String> mediaTypesList = mediaTypes == null
- ? Collections.singletonList("application/json") : mediaTypes;
-
- for (String mediaType : mediaTypesList) {
- content.setProperty(mediaType,
- Collections.singletonMap("schema", schema));
-
- }
- if (modelName != null && storeModelName) {
- content.setProperty("requestBodyName", isArray ? modelName + "Array" : modelName);
- }
- // pass the model name via the content object
- return content;
- }
-
- private static void setServersProperty(MessageContext ctx, JsonMapObject sw2, JsonMapObject sw3) {
- URI requestURI = ctx == null ? null : URI.create(ctx.getHttpServletRequest().getRequestURL().toString());
-
- List<String> sw2Schemes = sw2.getListStringProperty("schemes");
- String sw2Scheme;
- if (StringUtils.isEmpty(sw2Schemes)) {
- if (requestURI == null) {
- sw2Scheme = "https";
- } else {
- sw2Scheme = requestURI.getScheme();
- }
- } else {
- sw2Scheme = sw2Schemes.get(0);
- }
-
- String sw2Host = sw2.getStringProperty("host");
- if (sw2Host == null && requestURI != null) {
- sw2Host = requestURI.getHost() + ':' + requestURI.getPort();
- }
-
- String sw2BasePath = sw2.getStringProperty("basePath");
-
- String sw3ServerUrl = sw2Scheme + "://" + sw2Host + sw2BasePath;
- sw3.setProperty("servers", Collections.singletonList(Collections.singletonMap("url", sw3ServerUrl)));
- }
-
-}
diff --git a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/parse/ParseConfiguration.java b/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/parse/ParseConfiguration.java
deleted file mode 100644
index bf1f8e479d..0000000000
--- a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/parse/ParseConfiguration.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cxf.jaxrs.swagger.parse;
-
-public class ParseConfiguration {
-
- public ParseConfiguration() {
- }
-}
diff --git a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/parse/SwaggerParseUtils.java b/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/parse/SwaggerParseUtils.java
deleted file mode 100644
index cecec165fe..0000000000
--- a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/parse/SwaggerParseUtils.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cxf.jaxrs.swagger.parse;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Logger;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.BusFactory;
-import org.apache.cxf.common.classloader.ClassLoaderUtils;
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.helpers.CastUtils;
-import org.apache.cxf.helpers.IOUtils;
-import org.apache.cxf.jaxrs.json.basic.JsonMapObjectReaderWriter;
-import org.apache.cxf.jaxrs.model.Parameter;
-import org.apache.cxf.jaxrs.model.ParameterType;
-import org.apache.cxf.jaxrs.model.UserApplication;
-import org.apache.cxf.jaxrs.model.UserOperation;
-import org.apache.cxf.jaxrs.model.UserResource;
-import org.apache.cxf.jaxrs.utils.ResourceUtils;
-
-public final class SwaggerParseUtils {
- private static final Logger LOG = LogUtils.getL7dLogger(ResourceUtils.class);
- private static final Map<String, Class<?>> SWAGGER_TYPE_MAP;
- static {
- SWAGGER_TYPE_MAP = new HashMap<>();
- SWAGGER_TYPE_MAP.put("string", String.class);
- SWAGGER_TYPE_MAP.put("integer", long.class);
- SWAGGER_TYPE_MAP.put("float", float.class);
- SWAGGER_TYPE_MAP.put("double", double.class);
- SWAGGER_TYPE_MAP.put("int", int.class);
- SWAGGER_TYPE_MAP.put("long", long.class);
- SWAGGER_TYPE_MAP.put("byte", byte.class);
- SWAGGER_TYPE_MAP.put("boolean", boolean.class);
- SWAGGER_TYPE_MAP.put("date", java.util.Date.class);
- SWAGGER_TYPE_MAP.put("dateTime", java.util.Date.class);
- SWAGGER_TYPE_MAP.put("File", java.io.InputStream.class);
- SWAGGER_TYPE_MAP.put("file", java.io.InputStream.class);
- }
- private SwaggerParseUtils() {
-
- }
- public static UserApplication getUserApplication(String loc) {
- return getUserApplication(loc, BusFactory.getThreadDefaultBus());
- }
- public static UserApplication getUserApplication(String loc, Bus bus) {
- return getUserApplication(loc, bus, new ParseConfiguration());
- }
- public static UserApplication getUserApplication(String loc, Bus bus, ParseConfiguration cfg) {
- try {
- InputStream is = ResourceUtils.getResourceStream(loc, bus);
- if (is == null) {
- return null;
- }
- return getUserApplicationFromStream(is, cfg);
- } catch (Exception ex) {
- LOG.warning("Problem with processing a user model at " + loc);
- }
- return null;
- }
- public static UserApplication getUserApplicationFromStream(InputStream is) throws IOException {
- return getUserApplicationFromStream(is, new ParseConfiguration());
- }
- public static UserApplication getUserApplicationFromStream(InputStream is,
- ParseConfiguration cfg) throws IOException {
- return getUserApplicationFromJson(IOUtils.readStringFromStream(is), cfg);
- }
- public static UserApplication getUserApplicationFromJson(String json) {
- return getUserApplicationFromJson(json, new ParseConfiguration());
- }
- public static UserApplication getUserApplicationFromJson(String json,
- ParseConfiguration cfg) {
- JsonMapObjectReaderWriter reader = new JsonMapObjectReaderWriter();
- Map<String, Object> map = reader.fromJson(json);
-
- UserApplication app = new UserApplication();
- String relativePath = (String)map.get("basePath");
- app.setBasePath(StringUtils.isEmpty(relativePath) ? "/" : relativePath);
-
-
- Map<String, List<UserOperation>> userOpsMap = new LinkedHashMap<>();
- Set<String> tags = new HashSet<>();
- List<Map<String, Object>> tagsProp = CastUtils.cast((List<?>)map.get("tags"));
- if (tagsProp != null) {
- for (Map<String, Object> tagProp : tagsProp) {
- tags.add((String)tagProp.get("name"));
- }
- } else {
- tags.add("");
- }
-
- for (String tag : tags) {
- userOpsMap.put(tag, new LinkedList<UserOperation>());
- }
-
-
- Map<String, Map<String, Object>> paths = CastUtils.cast((Map<?, ?>)map.get("paths"));
- for (Map.Entry<String, Map<String, Object>> pathEntry : paths.entrySet()) {
- String operPath = pathEntry.getKey();
-
- Map<String, Object> operations = pathEntry.getValue();
- for (Map.Entry<String, Object> operEntry : operations.entrySet()) {
-
- UserOperation userOp = new UserOperation();
- userOp.setVerb(operEntry.getKey().toUpperCase());
-
- Map<String, Object> oper = CastUtils.cast((Map<?, ?>)operEntry.getValue());
- // The operation could be null, the particular HTTP verb may not contain any
- // operations but Swagger may still include it.
- if (oper != null) {
- userOp.setPath(operPath);
-
- userOp.setName((String) oper.get("operationId"));
- List<String> opProduces = CastUtils.cast((List<?>) oper.get("produces"));
- userOp.setProduces(listToString(opProduces));
-
- List<String> opConsumes = CastUtils.cast((List<?>) oper.get("consumes"));
- userOp.setConsumes(listToString(opConsumes));
-
- List<Parameter> userOpParams = new LinkedList<>();
- List<Map<String, Object>> params = CastUtils.cast((List<?>) oper.get("parameters"));
- for (Map<String, Object> param : params) {
- String name = (String) param.get("name");
- //"query", "header", "path", "formData" or "body"
- String paramType = (String) param.get("in");
- ParameterType pType = "body".equals(paramType) ? ParameterType.REQUEST_BODY
- : "formData".equals(paramType)
- ? ParameterType.FORM : ParameterType.valueOf(paramType.toUpperCase());
- Parameter userParam = new Parameter(pType, name);
-
- setJavaType(userParam, (String) param.get("type"));
- userOpParams.add(userParam);
- }
- if (!userOpParams.isEmpty()) {
- userOp.setParameters(userOpParams);
- }
- List<String> opTags = CastUtils.cast((List<?>) oper.get("tags"));
- if (opTags == null) {
- opTags = Collections.singletonList("");
- }
- for (String opTag : opTags) {
- userOpsMap.get(opTag).add(userOp);
- }
- }
- }
- }
-
- List<UserResource> resources = new LinkedList<>();
-
- for (Map.Entry<String, List<UserOperation>> entry : userOpsMap.entrySet()) {
- UserResource ur = new UserResource();
- ur.setPath("/");
- ur.setOperations(entry.getValue());
- ur.setName(entry.getKey());
- resources.add(ur);
- }
-
- app.setResources(resources);
- return app;
- }
-
- private static void setJavaType(Parameter userParam, String typeName) {
- Class<?> javaType = SWAGGER_TYPE_MAP.get(typeName);
- if (javaType == null) {
- try {
- // May work if the model has already been compiled
- // TODO: need to know the package name
- javaType = ClassLoaderUtils.loadClass(typeName, SwaggerParseUtils.class);
- } catch (Throwable t) {
- // ignore
- }
- }
-
- userParam.setJavaType(javaType);
- }
-
- private static String listToString(List<String> list) {
- if (list != null) {
- return String.join(",", list);
- }
- return null;
- }
-}
diff --git a/rt/rs/description-swagger/src/main/resources/META-INF/services/io.swagger.jaxrs.ext.SwaggerExtension b/rt/rs/description-swagger/src/main/resources/META-INF/services/io.swagger.jaxrs.ext.SwaggerExtension
deleted file mode 100644
index 9803485e96..0000000000
--- a/rt/rs/description-swagger/src/main/resources/META-INF/services/io.swagger.jaxrs.ext.SwaggerExtension
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.cxf.jaxrs.swagger.JaxRs2Extension
diff --git a/rt/rs/description-swagger/src/test/java/org/apache/cxf/jaxrs/swagger/Swagger2FeatureTest.java b/rt/rs/description-swagger/src/test/java/org/apache/cxf/jaxrs/swagger/Swagger2FeatureTest.java
deleted file mode 100644
index b21858ed48..0000000000
--- a/rt/rs/description-swagger/src/test/java/org/apache/cxf/jaxrs/swagger/Swagger2FeatureTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cxf.jaxrs.swagger;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-/**
- *
- */
-public class Swagger2FeatureTest {
- @Test
- public void testSetBasePathByAddress() {
- Swagger2Feature f = new Swagger2Feature();
-
- f.setBasePathByAddress("http://localhost:8080/foo");
- assertEquals("/foo", f.getBasePath());
- assertEquals("localhost:8080", f.getHost());
- unsetBasePath(f);
-
- f.setBasePathByAddress("http://localhost/foo");
- assertEquals("/foo", f.getBasePath());
- assertEquals("localhost", f.getHost());
- unsetBasePath(f);
-
- f.setBasePathByAddress("/foo");
- assertEquals("/foo", f.getBasePath());
- assertNull(f.getHost());
- unsetBasePath(f);
- }
-
- private static void unsetBasePath(Swagger2Feature f) {
- f.setBasePath(null);
- f.setHost(null);
- }
-}
\ No newline at end of file
diff --git a/rt/rs/description-swagger/src/test/java/org/apache/cxf/jaxrs/swagger/openapi/SwaggerToOpenApiConversionUtilsTest.java b/rt/rs/description-swagger/src/test/java/org/apache/cxf/jaxrs/swagger/openapi/SwaggerToOpenApiConversionUtilsTest.java
deleted file mode 100644
index 9c60369fee..0000000000
--- a/rt/rs/description-swagger/src/test/java/org/apache/cxf/jaxrs/swagger/openapi/SwaggerToOpenApiConversionUtilsTest.java
+++ /dev/null
@@ -1,780 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cxf.jaxrs.swagger.openapi;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.cxf.jaxrs.json.basic.JsonMapObject;
-import org.apache.cxf.jaxrs.json.basic.JsonMapObjectReaderWriter;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-public class SwaggerToOpenApiConversionUtilsTest {
-
- @Test
- public void testConvertFromSwaggerToOpenApi() {
- OpenApiConfiguration cfg = new OpenApiConfiguration();
- String s = SwaggerToOpenApiConversionUtils.getOpenApiFromSwaggerLoc("/swagger2petShop.json");
- JsonMapObjectReaderWriter readerWriter = new JsonMapObjectReaderWriter();
- JsonMapObject sw3 = readerWriter.fromJsonToJsonObject(s);
- assertEquals("3.0.0", sw3.getStringProperty("openapi"));
- verifyServersProperty(sw3);
- verifyInfoProperty(sw3);
- verifyTagsProperty(sw3);
- verifyPathsProperty(sw3, cfg);
- verifyComponentsProperty(sw3, cfg);
- }
-
- @Test
- public void testConvertFromSwaggerToOpenApiWithRequestBodies() {
- OpenApiConfiguration cfg = new OpenApiConfiguration();
- cfg.setCreateRequestBodies(true);
- String s = SwaggerToOpenApiConversionUtils.getOpenApiFromSwaggerLoc("/swagger2petShop.json", cfg);
- JsonMapObjectReaderWriter readerWriter = new JsonMapObjectReaderWriter();
- JsonMapObject sw3 = readerWriter.fromJsonToJsonObject(s);
- assertEquals("3.0.0", sw3.getStringProperty("openapi"));
- verifyServersProperty(sw3);
- verifyInfoProperty(sw3);
- verifyTagsProperty(sw3);
- verifyPathsProperty(sw3, cfg);
- verifyComponentsProperty(sw3, cfg);
- }
-
- private void verifyPathsProperty(JsonMapObject sw3, OpenApiConfiguration cfg) {
- JsonMapObject paths = sw3.getJsonMapProperty("paths");
- assertEquals(14, paths.size());
- // /pet
- verifyPetPath(paths, cfg);
- // /pet/findByStatus
- verifyPetFindByStatusPath(paths);
- // /pet/findByTags
- verifyPetFindByTagsPath(paths);
- // /pet/{petId}
- verifyPetIdPath(paths);
- // "/pet/{petId}/uploadImage"
- verifyPetIdUploadImagePath(paths);
- // "/store/inventory"
- verifyStoreInventoryPath(paths);
- // "/store/order"
- verifyStoreOrderPath(paths, cfg);
- // "/store/order/{orderId}"
- verifyStoreOrderIdPath(paths);
- // "/user"
- verifyUserPath(paths, cfg);
- // "/user/createWithArray"
- verifyUserCreateWithArrayPath(paths, cfg);
- // "/user/createWithList"
- verifyUserCreateWithListPath(paths, cfg);
- // "/user/login"
- verifyUserLoginPath(paths);
- // "/user/logout"
- verifyUserLogoutPath(paths);
- // "/user/{username}"
- verifyUserUsernamePath(paths, cfg);
- }
-
- private void verifyPetPath(JsonMapObject paths, OpenApiConfiguration cfg) {
- // /pet
- JsonMapObject pet = paths.getJsonMapProperty("/pet");
- assertEquals(2, pet.size());
- verifyPetPathPost(pet, cfg);
- verifyPetPathPut(pet, cfg);
- }
-
- private void verifyPetFindByStatusPath(JsonMapObject paths) {
- // /pet/findByStatus
- JsonMapObject pet = paths.getJsonMapProperty("/pet/findByStatus");
- assertEquals(1, pet.size());
- verifyPetFindByStatusOrTags(pet, "findPetsByStatus");
-
- }
- private void verifyPetFindByTagsPath(JsonMapObject paths) {
- // /pet/findByTags
- JsonMapObject pet = paths.getJsonMapProperty("/pet/findByTags");
- assertEquals(1, pet.size());
- verifyPetFindByStatusOrTags(pet, "findPetsByTags");
- }
-
- private void verifyPetIdPath(JsonMapObject paths) {
- // /pet/{petId}
- JsonMapObject pet = paths.getJsonMapProperty("/pet/{petId}");
- assertEquals(3, pet.size());
- verifyPetIdPathPost(pet);
- verifyPetIdPathGet(pet);
- verifyPetIdPathDelete(pet);
- }
-
- private void verifyPetIdUploadImagePath(JsonMapObject paths) {
- // /pet/{petId}/uploadImage
- JsonMapObject pet = paths.getJsonMapProperty("/pet/{petId}/uploadImage");
- assertEquals(1, pet.size());
- verifyPetIdUploadImagePathPost(pet);
- }
-
- private void verifyStoreInventoryPath(JsonMapObject paths) {
- // /store/inventory
- JsonMapObject store = paths.getJsonMapProperty("/store/inventory");
- assertEquals(1, store.size());
- verifyStoreInventoryPathGet(store);
- }
-
- private void verifyStoreOrderPath(JsonMapObject paths, OpenApiConfiguration cfg) {
- // /store/order
- JsonMapObject store = paths.getJsonMapProperty("/store/order");
- assertEquals(1, store.size());
- verifyStoreOrderPathPost(store, cfg);
- }
-
- private void verifyStoreOrderIdPath(JsonMapObject paths) {
- // /store/order/{orderId}
- JsonMapObject store = paths.getJsonMapProperty("/store/order/{orderId}");
- assertEquals(2, store.size());
- verifyStoreOrderIdPathGet(store);
- verifyStoreOrderIdPathDelete(store);
- }
-
- private void verifyUserPath(JsonMapObject paths, OpenApiConfiguration cfg) {
- // /user
- JsonMapObject user = paths.getJsonMapProperty("/user");
- assertEquals(1, user.size());
- verifyUserPathPost(user, cfg);
- }
-
- private void verifyUserCreateWithArrayPath(JsonMapObject paths, OpenApiConfiguration cfg) {
- // /user/createWithArray
- JsonMapObject user = paths.getJsonMapProperty("/user/createWithArray");
- assertEquals(1, user.size());
- verifyUserCreateWithArrayPathPost(user, cfg);
- }
-
- private void verifyUserCreateWithListPath(JsonMapObject paths, OpenApiConfiguration cfg) {
- // /user/createWithList
- JsonMapObject user = paths.getJsonMapProperty("/user/createWithList");
- assertEquals(1, user.size());
- verifyUserCreateWithListPathPost(user, cfg);
- }
-
- private void verifyUserLoginPath(JsonMapObject paths) {
- // /user/login
- JsonMapObject user = paths.getJsonMapProperty("/user/login");
- assertEquals(1, user.size());
- verifyUserLoginPathPost(user);
- }
-
- private void verifyUserLogoutPath(JsonMapObject paths) {
- // /user/logout
- JsonMapObject user = paths.getJsonMapProperty("/user/logout");
- assertEquals(1, user.size());
- verifyUserLogoutPathGet(user);
- }
-
- private void verifyUserUsernamePath(JsonMapObject paths, OpenApiConfiguration cfg) {
- // /user/{username}
- JsonMapObject user = paths.getJsonMapProperty("/user/{username}");
- assertEquals(3, user.size());
- verifyUserUsernamePathGet(user);
- verifyUserUsernamePathPut(user, cfg);
- verifyUserUsernamePathDelete(user);
- }
-
- private void verifyUserLoginPathPost(JsonMapObject user) {
- JsonMapObject userPost = user.getJsonMapProperty("get");
- assertEquals(6, userPost.size());
- testCommonVerbPropsExceptSec(userPost, "loginUser");
- assertNull(userPost.getProperty("requestBody"));
- List<Map<String, Object>> parameters = userPost.getListMapProperty("parameters");
- assertEquals(2, parameters.size());
- verifyUserNameParameter(new JsonMapObject(parameters.get(0)), "username", "query");
- verifyPasswordParameter(new JsonMapObject(parameters.get(1)), "password");
- JsonMapObject responses = userPost.getJsonMapProperty("responses");
- assertEquals(2, responses.size());
- assertNotNull(responses.getJsonMapProperty("400"));
- JsonMapObject okResp = responses.getJsonMapProperty("200");
- assertEquals(3, okResp.size());
- assertNotNull(okResp.getProperty("description"));
- assertNotNull(okResp.getProperty("headers"));
- JsonMapObject content = okResp.getJsonMapProperty("content");
- assertEquals(2, content.size());
- verifySimpleStringContent(content, "application/json");
- verifySimpleStringContent(content, "application/xml");
- }
-
- private void verifyUserLogoutPathGet(JsonMapObject user) {
- JsonMapObject userGet = user.getJsonMapProperty("get");
- assertEquals(5, userGet.size());
- testCommonVerbPropsExceptSec(userGet, "logoutUser");
- assertNull(userGet.getListMapProperty("parameters"));
- assertNull(userGet.getProperty("requestBody"));
- JsonMapObject responses = userGet.getJsonMapProperty("responses");
- assertEquals(1, responses.size());
- testDefaultResponse(userGet);
- }
-
- private void verifyUserUsernamePathGet(JsonMapObject user) {
- JsonMapObject userGet = user.getJsonMapProperty("get");
- assertEquals(6, userGet.size());
- testCommonVerbPropsExceptSec(userGet, "getUserByName");
- List<Map<String, Object>> parameters = userGet.getListMapProperty("parameters");
- assertEquals(1, parameters.size());
- JsonMapObject userParam = new JsonMapObject(parameters.get(0));
- verifyUserNameParameter(userParam, "username", "path");
- assertNull(userGet.getProperty("requestBody"));
- JsonMapObject responses = userGet.getJsonMapProperty("responses");
- assertEquals(3, responses.size());
- assertNotNull(responses.getProperty("400"));
- assertNotNull(responses.getProperty("404"));
- JsonMapObject okResp = responses.getJsonMapProperty("200");
- assertEquals(2, okResp.size());
- assertNotNull(okResp.getProperty("description"));
- JsonMapObject content = okResp.getJsonMapProperty("content");
- assertEquals(2, content.size());
- verifySimpleContent(content, "application/json", "User");
- verifySimpleContent(content, "application/xml", "User");
- }
-
- private void verifyUserUsernamePathPut(JsonMapObject user, OpenApiConfiguration cfg) {
- JsonMapObject userPut = user.getJsonMapProperty("put");
- assertEquals(7, userPut.size());
- testCommonVerbPropsExceptSec(userPut, "updateUser");
- List<Map<String, Object>> parameters = userPut.getListMapProperty("parameters");
- assertEquals(1, parameters.size());
- JsonMapObject userParam = new JsonMapObject(parameters.get(0));
- verifyUserNameParameter(userParam, "username", "path");
- if (cfg.isCreateRequestBodies()) {
- verifyRequestBodyRef(userPut, "User");
- } else {
- JsonMapObject requestBody = userPut.getJsonMapProperty("requestBody");
- assertEquals(3, requestBody.size());
- assertNotNull(requestBody.getProperty("description"));
- assertTrue(requestBody.getBooleanProperty("required"));
- JsonMapObject content = requestBody.getJsonMapProperty("content");
- assertEquals(1, content.size());
- verifySimpleContent(content, "application/json", "User");
- }
-
- JsonMapObject responses = userPut.getJsonMapProperty("responses");
- assertEquals(2, responses.size());
- assertNotNull(responses.getProperty("400"));
- assertNotNull(responses.getProperty("404"));
- }
-
- private void verifyUserUsernamePathDelete(JsonMapObject user) {
- JsonMapObject usetDelete = user.getJsonMapProperty("delete");
- assertEquals(6, usetDelete.size());
- testCommonVerbPropsExceptSec(usetDelete, "deleteUser");
- List<Map<String, Object>> parameters = usetDelete.getListMapProperty("parameters");
- assertEquals(1, parameters.size());
- JsonMapObject userParam = new JsonMapObject(parameters.get(0));
- verifyUserNameParameter(userParam, "username", "path");
- assertNull(usetDelete.getJsonMapProperty("requestBody"));
- JsonMapObject responses = usetDelete.getJsonMapProperty("responses");
- assertEquals(2, responses.size());
- assertNotNull(responses.getProperty("400"));
- assertNotNull(responses.getProperty("404"));
-
-
- }
-
- private void verifyStoreOrderIdPathGet(JsonMapObject store) {
- JsonMapObject storeGet = store.getJsonMapProperty("get");
- assertEquals(6, storeGet.size());
- testCommonVerbPropsExceptSec(storeGet, "getOrderById");
- List<Map<String, Object>> parameters = storeGet.getListMapProperty("parameters");
- assertEquals(1, parameters.size());
- JsonMapObject orderIdParam = new JsonMapObject(parameters.get(0));
- verifyOrderIdParameter(orderIdParam, false);
- assertNull(storeGet.getJsonMapProperty("requestBody"));
- JsonMapObject responses = storeGet.getJsonMapProperty("responses");
- assertEquals(3, responses.size());
- assertNotNull(responses.getProperty("400"));
- assertNotNull(responses.getProperty("404"));
- JsonMapObject okResp = responses.getJsonMapProperty("200");
- assertEquals(2, okResp.size());
- assertNotNull(okResp.getProperty("description"));
- JsonMapObject content = okResp.getJsonMapProperty("content");
- assertEquals(2, content.size());
- verifySimpleContent(content, "application/json", "Order");
- verifySimpleContent(content, "application/xml", "Order");
- }
-
- private void verifyStoreOrderIdPathDelete(JsonMapObject store) {
- JsonMapObject storeGet = store.getJsonMapProperty("delete");
- assertEquals(6, storeGet.size());
- testCommonVerbPropsExceptSec(storeGet, "deleteOrder");
- List<Map<String, Object>> parameters = storeGet.getListMapProperty("parameters");
- assertEquals(1, parameters.size());
- JsonMapObject orderIdParam = new JsonMapObject(parameters.get(0));
- verifyOrderIdParameter(orderIdParam, true);
- assertNull(storeGet.getJsonMapProperty("requestBody"));
- JsonMapObject responses = storeGet.getJsonMapProperty("responses");
- assertEquals(2, responses.size());
- assertNotNull(responses.getProperty("400"));
- assertNotNull(responses.getProperty("404"));
- }
-
- private void verifyStoreOrderPathPost(JsonMapObject store, OpenApiConfiguration cfg) {
- JsonMapObject storePost = store.getJsonMapProperty("post");
- assertEquals(6, storePost.size());
- testCommonVerbPropsExceptSec(storePost, "placeOrder");
- assertNull(storePost.getProperty("parameters"));
-
- if (cfg.isCreateRequestBodies()) {
- verifyRequestBodyRef(storePost, "Order");
- } else {
- JsonMapObject contentIn = verifyRequestBodyContent(storePost);
- assertEquals(1, contentIn.size());
- verifySimpleContent(contentIn, "application/json", "Order");
- }
- JsonMapObject responses = storePost.getJsonMapProperty("responses");
- assertEquals(2, responses.size());
- assertNotNull(responses.getJsonMapProperty("400"));
- JsonMapObject okResp = responses.getJsonMapProperty("200");
- assertEquals(2, okResp.size());
- assertNotNull(okResp.getProperty("description"));
- JsonMapObject contentOut = okResp.getJsonMapProperty("content");
- assertEquals(2, contentOut.size());
- verifySimpleContent(contentOut, "application/json", "Order");
- verifySimpleContent(contentOut, "application/xml", "Order");
- }
-
- private void verifyUserPathPost(JsonMapObject store, OpenApiConfiguration cfg) {
- JsonMapObject userPost = store.getJsonMapProperty("post");
- assertEquals(6, userPost.size());
- testCommonVerbPropsExceptSec(userPost, "createUser");
- assertNull(userPost.getProperty("parameters"));
- if (cfg.isCreateRequestBodies()) {
- verifyRequestBodyRef(userPost, "User");
- } else {
- JsonMapObject contentIn = verifyRequestBodyContent(userPost);
- assertEquals(1, contentIn.size());
- verifySimpleContent(contentIn, "application/json", "User");
- }
- testDefaultResponse(userPost);
- }
-
- private void testDefaultResponse(JsonMapObject json) {
- JsonMapObject responses = json.getJsonMapProperty("responses");
- assertEquals(1, responses.size());
- assertNotNull(responses.getProperty("default"));
-
- }
-
- private void verifyUserCreateWithArrayPathPost(JsonMapObject store, OpenApiConfiguration cfg) {
- verifyUserCreateWithListOrArrayPathPost(store, "createUsersWithArrayInput", cfg);
- }
-
- private void verifyUserCreateWithListPathPost(JsonMapObject store, OpenApiConfiguration cfg) {
- verifyUserCreateWithListOrArrayPathPost(store, "createUsersWithListInput", cfg);
- }
-
- private void verifyUserCreateWithListOrArrayPathPost(JsonMapObject store, String opId,
- OpenApiConfiguration cfg) {
- JsonMapObject userPost = store.getJsonMapProperty("post");
- assertEquals(6, userPost.size());
- testCommonVerbPropsExceptSec(userPost, opId);
- assertNull(userPost.getProperty("parameters"));
- if (cfg.isCreateRequestBodies()) {
- verifyRequestBodyRef(userPost, "UserArray");
- } else {
- JsonMapObject contentIn = verifyRequestBodyContent(userPost);
- assertEquals(1, contentIn.size());
- verifyArrayContent(contentIn, "application/json", "User");
- }
- testDefaultResponse(userPost);
- }
-
- private void verifyStoreInventoryPathGet(JsonMapObject store) {
- JsonMapObject storeGet = store.getJsonMapProperty("get");
- assertEquals(6, storeGet.size());
- testCommonVerbProps(storeGet, "getInventory");
- assertNull(storeGet.getProperty("parameters"));
- assertNull(storeGet.getJsonMapProperty("requestBody"));
- JsonMapObject responses = storeGet.getJsonMapProperty("responses");
- assertEquals(1, responses.size());
- JsonMapObject okResp = responses.getJsonMapProperty("200");
- assertEquals(2, okResp.size());
- assertNotNull(okResp.getProperty("description"));
- JsonMapObject content = okResp.getJsonMapProperty("content");
- assertEquals(1, content.size());
- verifyMapContent(content, "application/json", "integer", "int32");
- }
-
- private void verifyPetFindByStatusOrTags(JsonMapObject pet, String opId) {
- JsonMapObject petGet = pet.getJsonMapProperty("get");
- boolean findByStatus = "findPetsByStatus".equals(opId);
-
- assertEquals(findByStatus ? 7 : 8, petGet.size());
- testCommonVerbProps(petGet, opId);
- assertNull(petGet.getJsonMapProperty("requestBody"));
- List<Map<String, Object>> parameters = petGet.getListMapProperty("parameters");
- assertEquals(1, parameters.size());
- JsonMapObject param = new JsonMapObject(parameters.get(0));
- assertEquals(findByStatus ? "status" : "tags", param.getProperty("name"));
- assertEquals("query", param.getProperty("in"));
- assertNull(param.getProperty("type"));
- assertNull(param.getProperty("items"));
- assertNull(param.getProperty("collectionFormat"));
- assertTrue(param.getBooleanProperty("explode"));
- assertTrue(param.getBooleanProperty("required"));
- JsonMapObject schema = param.getJsonMapProperty("schema");
- assertEquals(2, schema.size());
- assertEquals("array", schema.getStringProperty("type"));
- assertNotNull(schema.getProperty("items"));
- assertNull(schema.getProperty("requestBody"));
- JsonMapObject responses = petGet.getJsonMapProperty("responses");
- assertEquals(2, responses.size());
- assertNotNull(responses.getProperty("400"));
- JsonMapObject okResp = responses.getJsonMapProperty("200");
- assertEquals(2, okResp.size());
- assertNotNull(okResp.getProperty("description"));
- JsonMapObject content = okResp.getJsonMapProperty("content");
- assertEquals(2, content.size());
- verifyArrayContent(content, "application/json", "Pet");
- verifyArrayContent(content, "application/xml", "Pet");
- if (findByStatus) {
- assertNull(petGet.getProperty("deprecated"));
- } else {
- assertTrue(petGet.getBooleanProperty("deprecated"));
- }
- }
- private void verifyPetIdUploadImagePathPost(JsonMapObject pet) {
- JsonMapObject petPost = pet.getJsonMapProperty("post");
- assertEquals(8, petPost.size());
- testCommonVerbProps(petPost, "uploadFile");
- List<Map<String, Object>> parameters = petPost.getListMapProperty("parameters");
- assertEquals(1, parameters.size());
- JsonMapObject pathIdParam = new JsonMapObject(parameters.get(0));
- verifyPetIdParameter(pathIdParam);
-
- verifyPetFormContent(petPost, "multipart/form-data",
- "additionalMetadata", "file");
- JsonMapObject responses = petPost.getJsonMapProperty("responses");
- assertEquals(1, responses.size());
- JsonMapObject okResp = responses.getJsonMapProperty("200");
- assertEquals(2, okResp.size());
- assertNotNull(okResp.getProperty("description"));
- JsonMapObject content = okResp.getJsonMapProperty("content");
- assertEquals(1, content.size());
- verifySimpleContent(content, "application/json", "ApiResponse");
-
- }
- private void verifyPetIdPathPost(JsonMapObject pet) {
- JsonMapObject petPost = pet.getJsonMapProperty("post");
- assertEquals(8, petPost.size());
- testCommonVerbProps(petPost, "updatePetWithForm");
- List<Map<String, Object>> parameters = petPost.getListMapProperty("parameters");
- assertEquals(1, parameters.size());
- JsonMapObject pathIdParam = new JsonMapObject(parameters.get(0));
- verifyPetIdParameter(pathIdParam);
-
- verifyPetFormContent(petPost, "application/x-www-form-urlencoded",
- "name", "status");
- JsonMapObject responses = petPost.getJsonMapProperty("responses");
- assertEquals(1, responses.size());
- assertNotNull(responses.getProperty("405"));
-
- }
- private void verifyPetIdPathGet(JsonMapObject pet) {
- JsonMapObject petGet = pet.getJsonMapProperty("get");
- assertEquals(7, petGet.size());
- testCommonVerbProps(petGet, "getPetById");
- List<Map<String, Object>> parameters = petGet.getListMapProperty("parameters");
- assertEquals(1, parameters.size());
- JsonMapObject pathIdParam = new JsonMapObject(parameters.get(0));
- verifyPetIdParameter(pathIdParam);
-
- assertNull(petGet.getJsonMapProperty("requestBody"));
- JsonMapObject responses = petGet.getJsonMapProperty("responses");
- assertEquals(3, responses.size());
- JsonMapObject okResp = responses.getJsonMapProperty("200");
- assertEquals(2, okResp.size());
- JsonMapObject content = okResp.getJsonMapProperty("content");
- assertEquals(2, content.size());
- verifySimpleContent(content, "application/json", "Pet");
- verifySimpleContent(content, "application/xml", "Pet");
- assertNotNull(responses.getProperty("400"));
- assertNotNull(responses.getProperty("404"));
-
- }
-
- private void verifyPetIdPathDelete(JsonMapObject pet) {
- JsonMapObject petDel = pet.getJsonMapProperty("delete");
- assertEquals(7, petDel.size());
- testCommonVerbProps(petDel, "deletePet");
- List<Map<String, Object>> parameters = petDel.getListMapProperty("parameters");
- assertEquals(2, parameters.size());
- JsonMapObject apiKeyParam = new JsonMapObject(parameters.get(0));
- assertEquals("api_key", apiKeyParam.getProperty("name"));
- assertEquals("header", apiKeyParam.getProperty("in"));
- assertNull(apiKeyParam.getProperty("type"));
- assertNull(apiKeyParam.getProperty("format"));
- assertFalse(apiKeyParam.getBooleanProperty("required"));
- JsonMapObject schema = apiKeyParam.getJsonMapProperty("schema");
- assertEquals(1, schema.size());
- assertEquals("string", schema.getProperty("type"));
- JsonMapObject pathIdParam = new JsonMapObject(parameters.get(1));
- verifyPetIdParameter(pathIdParam);
- assertNull(petDel.getJsonMapProperty("requestBody"));
- JsonMapObject responses = petDel.getJsonMapProperty("responses");
- assertEquals(2, responses.size());
- assertNotNull(responses.getProperty("400"));
- assertNotNull(responses.getProperty("404"));
-
- }
-
- private void verifyPetIdParameter(JsonMapObject param) {
- assertEquals("petId", param.getProperty("name"));
- assertEquals("path", param.getProperty("in"));
- assertNull(param.getProperty("type"));
- assertNull(param.getProperty("format"));
- assertNotNull(param.getProperty("description"));
- assertTrue(param.getBooleanProperty("required"));
- JsonMapObject schema = param.getJsonMapProperty("schema");
- assertEquals(2, schema.size());
- assertEquals("integer", schema.getProperty("type"));
- assertEquals("int64", schema.getProperty("format"));
- }
-
- private void verifyUserNameParameter(JsonMapObject param, String name, String inType) {
- verifyStringParameter(param, "username", inType);
-
- }
-
- private void verifyPasswordParameter(JsonMapObject param, String name) {
- verifyStringParameter(param, "password", "query");
- assertEquals("password",
- param.getJsonMapProperty("schema").getProperty("format"));
- }
-
- private void verifyStringParameter(JsonMapObject param, String name, String inType) {
- assertEquals(name, param.getProperty("name"));
- assertEquals(inType, param.getProperty("in"));
- assertNull(param.getProperty("type"));
- assertNull(param.getProperty("format"));
- assertNotNull(param.getProperty("description"));
- assertTrue(param.getBooleanProperty("required"));
- JsonMapObject schema = param.getJsonMapProperty("schema");
- assertEquals("password".equals(name) ? 2 : 1, schema.size());
- assertEquals("string", schema.getProperty("type"));
- }
-
- private void verifyOrderIdParameter(JsonMapObject param, boolean minOnly) {
- assertEquals("orderId", param.getProperty("name"));
- assertEquals("path", param.getProperty("in"));
- assertNull(param.getProperty("type"));
- assertNull(param.getProperty("format"));
- assertNotNull(param.getProperty("description"));
- assertTrue(param.getBooleanProperty("required"));
- JsonMapObject schema = param.getJsonMapProperty("schema");
-
- assertEquals(minOnly ? 3 : 4, schema.size());
- assertEquals("integer", schema.getProperty("type"));
- assertNotNull(schema.getProperty("minimum"));
- if (!minOnly) {
- assertNotNull(schema.getProperty("maximum"));
- }
- }
-
- private void verifyPetPathPost(JsonMapObject pet, OpenApiConfiguration cfg) {
- JsonMapObject petPost = pet.getJsonMapProperty("post");
- assertEquals(7, petPost.size());
- testCommonVerbProps(petPost, "addPet");
- assertNull(petPost.getProperty("parameters"));
- if (cfg.isCreateRequestBodies()) {
- verifyRequestBodyRef(petPost, "Pet");
- } else {
- JsonMapObject content = verifyRequestBodyContent(petPost);
- assertEquals(2, content.size());
- verifySimpleContent(content, "application/json", "Pet");
- verifySimpleContent(content, "application/xml", "Pet");
- }
- JsonMapObject responses = petPost.getJsonMapProperty("responses");
- assertEquals(1, responses.size());
- assertNotNull(responses.getProperty("405"));
- }
- private JsonMapObject verifyRequestBodyContent(JsonMapObject json) {
- return verifyRequestBodyContent(json, "requestBody");
- }
- private JsonMapObject verifyRequestBodyContent(JsonMapObject json, String propName) {
- JsonMapObject requestBody = json.getJsonMapProperty(propName);
- assertEquals(3, requestBody.size());
- assertNotNull(requestBody.getProperty("description"));
- assertTrue(requestBody.getBooleanProperty("required"));
- return requestBody.getJsonMapProperty("content");
- }
- private void verifyRequestBodyRef(JsonMapObject json, String refName) {
- JsonMapObject requestBody = json.getJsonMapProperty("requestBody");
- assertEquals(1, requestBody.size());
- assertEquals("#components/requestBodies/" + refName,
- requestBody.getProperty("$ref"));
- }
-
- private void verifyPetPathPut(JsonMapObject pet, OpenApiConfiguration cfg) {
- JsonMapObject petPut = pet.getJsonMapProperty("put");
- assertEquals(7, petPut.size());
- testCommonVerbProps(petPut, "updatePet");
- assertNull(petPut.getProperty("parameters"));
- if (cfg.isCreateRequestBodies()) {
- verifyRequestBodyRef(petPut, "Pet");
- } else {
- JsonMapObject content = verifyRequestBodyContent(petPut);
- assertEquals(2, content.size());
- verifySimpleContent(content, "application/json", "Pet");
- verifySimpleContent(content, "application/xml", "Pet");
- }
- JsonMapObject responses = petPut.getJsonMapProperty("responses");
- assertEquals(3, responses.size());
- assertNotNull(responses.getProperty("400"));
- assertNotNull(responses.getProperty("404"));
- assertNotNull(responses.getProperty("405"));
- }
-
-
- private void verifySimpleContent(JsonMapObject contentMap, String mediaType, String modelName) {
- JsonMapObject content = contentMap.getJsonMapProperty(mediaType);
- assertEquals(1, content.size());
- JsonMapObject schema = content.getJsonMapProperty("schema");
- assertEquals(1, schema.size());
- assertEquals("#components/schemas/" + modelName, schema.getStringProperty("$ref"));
- }
- private void verifySimpleStringContent(JsonMapObject contentMap, String mediaType) {
- JsonMapObject content = contentMap.getJsonMapProperty(mediaType);
- assertEquals(1, content.size());
- JsonMapObject schema = content.getJsonMapProperty("schema");
- assertEquals(1, schema.size());
- assertEquals("string", schema.getStringProperty("type"));
- }
- private void verifyMapContent(JsonMapObject contentMap, String mediaType, String type, String format) {
- JsonMapObject content = contentMap.getJsonMapProperty(mediaType);
- assertEquals(1, content.size());
- JsonMapObject schema = content.getJsonMapProperty("schema");
- assertEquals(2, schema.size());
- assertEquals("object", schema.getStringProperty("type"));
- JsonMapObject additionalProps = schema.getJsonMapProperty("additionalProperties");
- assertEquals(type, additionalProps.getStringProperty("type"));
- assertEquals(format, additionalProps.getStringProperty("format"));
- }
- private void verifyPetFormContent(JsonMapObject petPost,
- String mediaType,
- String firstPropName,
- String secondPropName) {
- JsonMapObject requestBody = petPost.getJsonMapProperty("requestBody");
- assertEquals(1, requestBody.size());
- JsonMapObject contentMap = requestBody.getJsonMapProperty("content");
- assertEquals(1, contentMap.size());
-
-
- JsonMapObject content = contentMap.getJsonMapProperty(mediaType);
- assertEquals(1, content.size());
- JsonMapObject schema = content.getJsonMapProperty("schema");
- assertEquals(2, schema.size());
- assertEquals("object", schema.getStringProperty("type"));
- JsonMapObject props = schema.getJsonMapProperty("properties");
- assertEquals(2, props.size());
- JsonMapObject firstProp = props.getJsonMapProperty(firstPropName);
- assertNotNull(firstProp.getProperty("description"));
- assertEquals("string", firstProp.getProperty("type"));
- JsonMapObject secondProp = props.getJsonMapProperty(secondPropName);
- assertNotNull(secondProp.getProperty("description"));
- assertEquals("string", secondProp.getProperty("type"));
- if ("file".equals(secondPropName)) {
- assertEquals("binary", secondProp.getProperty("format"));
- }
- }
- private void verifyArrayContent(JsonMapObject contentMap, String mediaType, String modelName) {
- JsonMapObject content = contentMap.getJsonMapProperty(mediaType);
- assertEquals(1, content.size());
- JsonMapObject schema = content.getJsonMapProperty("schema");
- assertEquals(2, schema.size());
- assertEquals("array", schema.getStringProperty("type"));
- JsonMapObject items = schema.getJsonMapProperty("items");
- assertEquals(1, items.size());
- assertEquals("#components/schemas/" + modelName, items.getStringProperty("$ref"));
- }
-
- private void verifyServersProperty(JsonMapObject sw3) {
- List<Map<String, Object>> servers = sw3.getListMapProperty("servers");
- assertEquals(1, servers.size());
- JsonMapObject server = new JsonMapObject(servers.get(0));
- assertEquals(1, server.size());
- assertEquals("http://petstore.swagger.io/v2", server.getStringProperty("url"));
- }
-
- private void verifyInfoProperty(JsonMapObject sw3) {
- //TODO: check info properties as well, though it's only copied from the original doc
- assertNotNull(sw3.getJsonMapProperty("info"));
- }
-
- private void verifyTagsProperty(JsonMapObject sw3) {
- //TODO: check info properties as well, though it's only copied from the original doc
- assertNotNull(sw3.getListMapProperty("tags"));
- }
-
- private void verifyComponentsProperty(JsonMapObject sw3, OpenApiConfiguration cfg) {
- JsonMapObject comps = sw3.getJsonMapProperty("components");
- assertEquals(3, comps.size());
- JsonMapObject requestBodies = comps.getJsonMapProperty("requestBodies");
- if (cfg.isCreateRequestBodies()) {
- assertEquals(4, requestBodies.size());
- // UserArray
- JsonMapObject userArrayContent = verifyRequestBodyContent(requestBodies, "UserArray");
- assertEquals(1, userArrayContent.size());
- verifyArrayContent(userArrayContent, "application/json", "User");
- // Pet
- JsonMapObject petContent = verifyRequestBodyContent(requestBodies, "Pet");
- assertEquals(2, petContent.size());
- verifySimpleContent(petContent, "application/json", "Pet");
- verifySimpleContent(petContent, "application/xml", "Pet");
- // User
- JsonMapObject userContent = verifyRequestBodyContent(requestBodies, "User");
- assertEquals(1, userContent.size());
- verifySimpleContent(userContent, "application/json", "User");
- // Order
- JsonMapObject orderContent = verifyRequestBodyContent(requestBodies, "Order");
- assertEquals(1, orderContent.size());
- verifySimpleContent(orderContent, "application/json", "Order");
- } else {
- assertEquals(0, requestBodies.size());
- }
- assertNotNull(comps.getJsonMapProperty("schemas"));
- assertNotNull(comps.getJsonMapProperty("securitySchemes"));
-
- }
-
- private void testCommonVerbProps(JsonMapObject method, String opId) {
- testCommonVerbPropsExceptSec(method, opId);
- assertNotNull(method.getProperty("security"));
- }
- private void testCommonVerbPropsExceptSec(JsonMapObject method, String opId) {
- assertNotNull(method.getProperty("tags"));
- assertNotNull(method.getProperty("summary"));
- assertNotNull(method.getProperty("description"));
- assertEquals(opId, method.getStringProperty("operationId"));
- assertNull(method.getProperty("produces"));
- assertNull(method.getProperty("consumes"));
-
- }
-}
\ No newline at end of file
diff --git a/rt/rs/description-swagger/src/test/java/org/apache/cxf/jaxrs/swagger/parse/SwaggerParseUtilsTest.java b/rt/rs/description-swagger/src/test/java/org/apache/cxf/jaxrs/swagger/parse/SwaggerParseUtilsTest.java
deleted file mode 100644
index 21ec121b40..0000000000
--- a/rt/rs/description-swagger/src/test/java/org/apache/cxf/jaxrs/swagger/parse/SwaggerParseUtilsTest.java
+++ /dev/null
@@ -1,499 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cxf.jaxrs.swagger.parse;
-
-import java.io.InputStream;
-import java.util.Map;
-
-import org.apache.cxf.jaxrs.model.Parameter;
-import org.apache.cxf.jaxrs.model.ParameterType;
-import org.apache.cxf.jaxrs.model.UserApplication;
-import org.apache.cxf.jaxrs.model.UserOperation;
-import org.apache.cxf.jaxrs.model.UserResource;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-public class SwaggerParseUtilsTest {
-
- @Test
- public void testConvertPetShopDocToUserApp() {
- UserApplication ap = SwaggerParseUtils.getUserApplication("/swagger2petShop.json");
- assertNotNull(ap);
- assertEquals("/v2", ap.getBasePath());
- Map<String, UserResource> map = ap.getResourcesAsMap();
- assertEquals(3, map.size());
-
- UserResource pet = map.get("pet");
- verifyPetResource(pet);
-
- UserResource user = map.get("user");
- verifyPetUserResource(user);
-
- UserResource store = map.get("store");
- verifyPetStoreResource(store);
-
- }
- //CHECKSTYLE:OFF
- private void verifyPetResource(UserResource ur) {
- assertNotNull(ur);
- assertEquals("/", ur.getPath());
- assertEquals(8, ur.getOperations().size());
- //POST /pet
- UserOperation addPet = ur.getOperations().get(0);
- assertEquals("addPet", addPet.getName());
- assertEquals("/pet", addPet.getPath());
- assertEquals("POST", addPet.getVerb());
- assertEquals("application/xml,application/json", addPet.getProduces());
- assertEquals("application/json,application/xml", addPet.getConsumes());
- assertEquals(1, addPet.getParameters().size());
- Parameter addPetParam1 = addPet.getParameters().get(0);
- assertEquals("body", addPetParam1.getName());
- assertEquals(ParameterType.REQUEST_BODY, addPetParam1.getType());
- //TODO: check that addPetParam1 refers to Pet model
- //TODO: check default response type: JAX-RS Response ?
-
- //PUT /pet
- UserOperation putPet = ur.getOperations().get(1);
- assertEquals("updatePet", putPet.getName());
- assertEquals("/pet", putPet.getPath());
- assertEquals("PUT", putPet.getVerb());
- assertEquals("application/xml,application/json", addPet.getProduces());
- assertEquals("application/json,application/xml", addPet.getConsumes());
- assertEquals(1, putPet.getParameters().size());
- Parameter putPetParam1 = putPet.getParameters().get(0);
- assertEquals("body", putPetParam1.getName());
- assertEquals(ParameterType.REQUEST_BODY, putPetParam1.getType());
- //TODO: check that putPetParam1 refers to Pet model
- //TODO: check default response type: JAX-RS Response ?
-
- //GET /pet/findByStatus
- UserOperation findPetsByStatus = ur.getOperations().get(2);
- assertEquals("findPetsByStatus", findPetsByStatus.getName());
- assertEquals("/pet/findByStatus", findPetsByStatus.getPath());
- assertEquals("GET", findPetsByStatus.getVerb());
- assertEquals("application/xml,application/json", findPetsByStatus.getProduces());
- assertNull(findPetsByStatus.getConsumes());
- assertEquals(1, findPetsByStatus.getParameters().size());
- Parameter findPetsByStatusParam1 = findPetsByStatus.getParameters().get(0);
- assertEquals("status", findPetsByStatusParam1.getName());
- assertEquals(ParameterType.QUERY, findPetsByStatusParam1.getType());
- //TODO: check that findPetsByStatusParam1 refers to List of String
- //TODO: check that response refers to List of Pets
-
- //GET /pet/findByTag
- UserOperation findPetsByTags = ur.getOperations().get(3);
- assertEquals("findPetsByTags", findPetsByTags.getName());
- assertEquals("/pet/findByTags", findPetsByTags.getPath());
- assertEquals("GET", findPetsByTags.getVerb());
- assertEquals("application/xml,application/json", findPetsByTags.getProduces());
- assertNull(findPetsByTags.getConsumes());
- assertEquals(1, findPetsByTags.getParameters().size());
- Parameter findPetsByTagsParam1 = findPetsByTags.getParameters().get(0);
- assertEquals("tags", findPetsByTagsParam1.getName());
- assertEquals(ParameterType.QUERY, findPetsByTagsParam1.getType());
- //TODO: check that findPetsByTagsParam1 refers to List of String
- //TODO: check that response refers to List of Pets
-
- //GET /pet/{petId}
- UserOperation getPetById = ur.getOperations().get(4);
- assertEquals("getPetById", getPetById.getName());
- assertEquals("/pet/{petId}", getPetById.getPath());
- assertEquals("GET", getPetById.getVerb());
- assertEquals("application/xml,application/json", getPetById.getProduces());
- assertNull(getPetById.getConsumes());
- assertEquals(1, getPetById.getParameters().size());
- Parameter getPetByIdParam1 = getPetById.getParameters().get(0);
- assertEquals("petId", getPetByIdParam1.getName());
- assertEquals(ParameterType.PATH, getPetByIdParam1.getType());
- assertEquals(long.class, getPetByIdParam1.getJavaType());
-
- //POST /pet/{petId}
- UserOperation updatePetWithForm = ur.getOperations().get(5);
- assertEquals("updatePetWithForm", updatePetWithForm.getName());
- assertEquals("/pet/{petId}", updatePetWithForm.getPath());
- assertEquals("POST", updatePetWithForm.getVerb());
- assertEquals("application/xml,application/json", updatePetWithForm.getProduces());
- assertEquals("application/x-www-form-urlencoded", updatePetWithForm.getConsumes());
- assertEquals(3, updatePetWithForm.getParameters().size());
- Parameter updatePetWithFormParam1 = updatePetWithForm.getParameters().get(0);
- assertEquals("petId", updatePetWithFormParam1.getName());
- assertEquals(ParameterType.PATH, updatePetWithFormParam1.getType());
- assertEquals(long.class, updatePetWithFormParam1.getJavaType());
- Parameter updatePetWithFormParam2 = updatePetWithForm.getParameters().get(1);
- assertEquals("name", updatePetWithFormParam2.getName());
- assertEquals(ParameterType.FORM, updatePetWithFormParam2.getType());
- assertEquals(String.class, updatePetWithFormParam2.getJavaType());
- Parameter updatePetWithFormParam3 = updatePetWithForm.getParameters().get(2);
- assertEquals("status", updatePetWithFormParam3.getName());
- assertEquals(ParameterType.FORM, updatePetWithFormParam3.getType());
- assertEquals(String.class, updatePetWithFormParam3.getJavaType());
-
- //DELETE /pet/{petId}
- UserOperation deletePet = ur.getOperations().get(6);
- assertEquals("deletePet", deletePet.getName());
- assertEquals("/pet/{petId}", deletePet.getPath());
- assertEquals("DELETE", deletePet.getVerb());
- assertEquals("application/xml,application/json", deletePet.getProduces());
- assertNull(deletePet.getConsumes());
- assertEquals(2, deletePet.getParameters().size());
- Parameter deletePetParam1 = deletePet.getParameters().get(0);
- assertEquals("api_key", deletePetParam1.getName());
- assertEquals(ParameterType.HEADER, deletePetParam1.getType());
- assertEquals(String.class, deletePetParam1.getJavaType());
- Parameter deletePetParam2 = deletePet.getParameters().get(1);
- assertEquals("petId", deletePetParam2.getName());
- assertEquals(ParameterType.PATH, deletePetParam2.getType());
- assertEquals(long.class, deletePetParam2.getJavaType());
-
- //POST /pet/{petId}/uploadImage
- UserOperation uploadFile = ur.getOperations().get(7);
- assertEquals("uploadFile", uploadFile.getName());
- assertEquals("/pet/{petId}/uploadImage", uploadFile.getPath());
- assertEquals("POST", uploadFile.getVerb());
- assertEquals("application/json", uploadFile.getProduces());
- assertEquals("multipart/form-data", uploadFile.getConsumes());
- assertEquals(3, uploadFile.getParameters().size());
- Parameter uploadFileParam1 = uploadFile.getParameters().get(0);
- assertEquals("petId", uploadFileParam1.getName());
- assertEquals(ParameterType.PATH, uploadFileParam1.getType());
- assertEquals(long.class, uploadFileParam1.getJavaType());
- Parameter uploadFileParam2 = uploadFile.getParameters().get(1);
- assertEquals("additionalMetadata", uploadFileParam2.getName());
- assertEquals(ParameterType.FORM, uploadFileParam2.getType());
- assertEquals(String.class, uploadFileParam2.getJavaType());
- Parameter uploadFileParam3 = uploadFile.getParameters().get(2);
- assertEquals("file", uploadFileParam3.getName());
- assertEquals(ParameterType.FORM, uploadFileParam3.getType());
- assertEquals(InputStream.class, uploadFileParam3.getJavaType());
-
- }
- //CHECKSTYLE:ON
- //CHECKSTYLE:OFF
- private void verifyPetUserResource(UserResource ur) {
- assertNotNull(ur);
- assertEquals("/", ur.getPath());
- assertEquals(8, ur.getOperations().size());
- //POST /user
- UserOperation createUser = ur.getOperations().get(0);
- assertEquals("createUser", createUser.getName());
- assertEquals("/user", createUser.getPath());
- assertEquals("POST", createUser.getVerb());
- assertEquals("application/xml,application/json", createUser.getProduces());
- assertNull(createUser.getConsumes());
- assertEquals(1, createUser.getParameters().size());
- Parameter createUserParam1 = createUser.getParameters().get(0);
- assertEquals("body", createUserParam1.getName());
- assertEquals(ParameterType.REQUEST_BODY, createUserParam1.getType());
- //TODO: check that createUserParam1 refers to User model
- //TODO: check default response type: JAX-RS Response ?
-
- //POST /user/createWithArray
- UserOperation createWithArray = ur.getOperations().get(1);
- assertEquals("createUsersWithArrayInput", createWithArray.getName());
- assertEquals("/user/createWithArray", createWithArray.getPath());
- assertEquals("POST", createUser.getVerb());
- assertEquals("application/xml,application/json", createUser.getProduces());
- assertNull(createWithArray.getConsumes());
- assertEquals(1, createUser.getParameters().size());
- Parameter createWithArrayParam1 = createUser.getParameters().get(0);
- assertEquals("body", createWithArrayParam1.getName());
- assertEquals(ParameterType.REQUEST_BODY, createWithArrayParam1.getType());
- //TODO: check that createUserParam1 refers to an array of User model
- //TODO: check default response type: JAX-RS Response ?
-
- //POST /user/createWithList
- UserOperation createWithList = ur.getOperations().get(2);
- assertEquals("createUsersWithListInput", createWithList.getName());
- assertEquals("/user/createWithList", createWithList.getPath());
- assertEquals("POST", createWithList.getVerb());
- assertEquals("application/xml,application/json", createWithList.getProduces());
- assertNull(createWithList.getConsumes());
- assertEquals(1, createWithList.getParameters().size());
- Parameter createWithListParam1 = createWithList.getParameters().get(0);
- assertEquals("body", createWithListParam1.getName());
- assertEquals(ParameterType.REQUEST_BODY, createWithListParam1.getType());
- //TODO: check that createUserParam1 refers to an array of User model
- //TODO: check default response type: JAX-RS Response ?
-
- //GET /user/login
- UserOperation loginUser = ur.getOperations().get(3);
- assertEquals("loginUser", loginUser.getName());
- assertEquals("/user/login", loginUser.getPath());
- assertEquals("GET", loginUser.getVerb());
- assertEquals("application/xml,application/json", loginUser.getProduces());
- assertNull(loginUser.getConsumes());
- assertEquals(2, loginUser.getParameters().size());
- Parameter loginUserParam1 = loginUser.getParameters().get(0);
- assertEquals("username", loginUserParam1.getName());
- assertEquals(ParameterType.QUERY, loginUserParam1.getType());
- assertEquals(String.class, loginUserParam1.getJavaType());
- Parameter loginUserParam2 = loginUser.getParameters().get(1);
- assertEquals("password", loginUserParam2.getName());
- assertEquals(ParameterType.QUERY, loginUserParam2.getType());
- assertEquals(String.class, loginUserParam2.getJavaType());
- //TODO: check 200 response type
-
- //GET /user/logout
- UserOperation logoutUser = ur.getOperations().get(4);
- assertEquals("logoutUser", logoutUser.getName());
- assertEquals("/user/logout", logoutUser.getPath());
- assertEquals("GET", loginUser.getVerb());
- assertEquals("application/xml,application/json", logoutUser.getProduces());
- assertNull(logoutUser.getConsumes());
- assertEquals(0, logoutUser.getParameters().size());
- //TODO: check 200 response type
-
- //GET /user/{username}
- UserOperation getUserByName = ur.getOperations().get(5);
- assertEquals("getUserByName", getUserByName.getName());
- assertEquals("/user/{username}", getUserByName.getPath());
- assertEquals("GET", getUserByName.getVerb());
- assertEquals("application/xml,application/json", getUserByName.getProduces());
- assertNull(getUserByName.getConsumes());
- assertEquals(1, getUserByName.getParameters().size());
- Parameter getUserByNameParam1 = getUserByName.getParameters().get(0);
- assertEquals("username", getUserByNameParam1.getName());
- assertEquals(ParameterType.PATH, getUserByNameParam1.getType());
- assertEquals(String.class, getUserByNameParam1.getJavaType());
- //TODO: check 200 response type
-
- //PUT /user/{username}
- UserOperation updateUser = ur.getOperations().get(6);
- assertEquals("updateUser", updateUser.getName());
- assertEquals("/user/{username}", updateUser.getPath());
- assertEquals("PUT", updateUser.getVerb());
- assertEquals("application/xml,application/json", updateUser.getProduces());
- assertNull(updateUser.getConsumes());
- assertEquals(2, updateUser.getParameters().size());
- Parameter updateUserParam1 = updateUser.getParameters().get(0);
- assertEquals("username", updateUserParam1.getName());
- assertEquals(ParameterType.PATH, updateUserParam1.getType());
- assertEquals(String.class, updateUserParam1.getJavaType());
- Parameter updateUserParam2 = updateUser.getParameters().get(1);
- assertEquals("body", updateUserParam2.getName());
- assertEquals(ParameterType.REQUEST_BODY, updateUserParam2.getType());
- //TODO: check that createUserParam1 refers to an array of User model
- //TODO: check 200 response type
-
- //DELETE /user/{username}
- UserOperation deleteUser = ur.getOperations().get(7);
- assertEquals("deleteUser", deleteUser.getName());
- assertEquals("/user/{username}", deleteUser.getPath());
- assertEquals("DELETE", deleteUser.getVerb());
- assertEquals("application/xml,application/json", deleteUser.getProduces());
- assertNull(deleteUser.getConsumes());
- assertEquals(1, deleteUser.getParameters().size());
- Parameter deleteUserParam1 = deleteUser.getParameters().get(0);
- assertEquals("username", deleteUserParam1.getName());
- assertEquals(ParameterType.PATH, deleteUserParam1.getType());
- assertEquals(String.class, deleteUserParam1.getJavaType());
-
- }
- //CHECKSTYLE:ON
- private void verifyPetStoreResource(UserResource ur) {
- assertNotNull(ur);
- assertEquals("/", ur.getPath());
- assertEquals(4, ur.getOperations().size());
- //GET /store/inventory
- UserOperation getInv = ur.getOperations().get(0);
- assertEquals("getInventory", getInv.getName());
- assertEquals("/store/inventory", getInv.getPath());
- assertEquals("GET", getInv.getVerb());
- assertEquals("application/json", getInv.getProduces());
- assertNull(getInv.getConsumes());
- assertEquals(0, getInv.getParameters().size());
- //TODO: check 200 response type
-
- //POST /store/inventory
- UserOperation placeOrder = ur.getOperations().get(1);
- assertEquals("placeOrder", placeOrder.getName());
- assertEquals("/store/order", placeOrder.getPath());
- assertEquals("POST", placeOrder.getVerb());
- assertEquals("application/xml,application/json", placeOrder.getProduces());
- assertNull(placeOrder.getConsumes());
- assertEquals(1, placeOrder.getParameters().size());
- Parameter placeOrderParam1 = placeOrder.getParameters().get(0);
- assertEquals("body", placeOrderParam1.getName());
- assertEquals(ParameterType.REQUEST_BODY, placeOrderParam1.getType());
- //TODO: check that placeOrderParam1 refers to Order model
- //TODO: check 200 response type
-
- //GET /store/order/{orderId}
- UserOperation getOrderById = ur.getOperations().get(2);
- assertEquals("getOrderById", getOrderById.getName());
- assertEquals("/store/order/{orderId}", getOrderById.getPath());
- assertEquals("GET", getOrderById.getVerb());
- assertEquals("application/xml,application/json", getOrderById.getProduces());
- assertNull(getOrderById.getConsumes());
- assertEquals(1, getOrderById.getParameters().size());
- Parameter getOrderByIdParam1 = getOrderById.getParameters().get(0);
- assertEquals("orderId", getOrderByIdParam1.getName());
- assertEquals(ParameterType.PATH, getOrderByIdParam1.getType());
- assertEquals(long.class, getOrderByIdParam1.getJavaType());
- //TODO: check 200 response type
-
- //DELETE /store/order/{orderId}
- UserOperation deleteOrder = ur.getOperations().get(3);
- assertEquals("deleteOrder", deleteOrder.getName());
- assertEquals("/store/order/{orderId}", deleteOrder.getPath());
- assertEquals("DELETE", deleteOrder.getVerb());
- assertEquals("application/xml,application/json", deleteOrder.getProduces());
- assertNull(deleteOrder.getConsumes());
- assertEquals(1, getOrderById.getParameters().size());
- Parameter deleteOrderParam1 = deleteOrder.getParameters().get(0);
- assertEquals("orderId", deleteOrderParam1.getName());
- assertEquals(ParameterType.PATH, deleteOrderParam1.getType());
- assertEquals(long.class, deleteOrderParam1.getJavaType());
- //TODO: check 200 response type
-
- }
-
-
- @Test
- public void testConvertSimpleDocToUserApp() {
- UserApplication ap = SwaggerParseUtils.getUserApplication("/swagger20.json");
- assertNotNull(ap);
- assertEquals("/services/helloservice", ap.getBasePath());
- Map<String, UserResource> map = ap.getResourcesAsMap();
- assertEquals(2, map.size());
-
- UserResource ur = map.get("sayHello");
- assertNotNull(ur);
- assertEquals("/", ur.getPath());
- assertEquals(1, ur.getOperations().size());
- UserOperation op = ur.getOperations().get(0);
- assertEquals("sayHello", op.getName());
- assertEquals("/sayHello/{a}", op.getPath());
- assertEquals("GET", op.getVerb());
- assertEquals("text/plain", op.getProduces());
-
- assertEquals(1, op.getParameters().size());
- Parameter param1 = op.getParameters().get(0);
- assertEquals("a", param1.getName());
- assertEquals(ParameterType.PATH, param1.getType());
- assertEquals(String.class, param1.getJavaType());
-
- UserResource ur2 = map.get("sayHello2");
- assertNotNull(ur2);
- assertEquals("/", ur2.getPath());
- assertEquals(1, ur2.getOperations().size());
- UserOperation op2 = ur2.getOperations().get(0);
- assertEquals("sayHello", op2.getName());
- assertEquals("/sayHello2/{a}", op2.getPath());
- assertEquals("GET", op2.getVerb());
- assertEquals("text/plain", op2.getProduces());
-
- assertEquals(1, op2.getParameters().size());
- Parameter param2 = op.getParameters().get(0);
- assertEquals("a", param2.getName());
- assertEquals(ParameterType.PATH, param2.getType());
- assertEquals(String.class, param2.getJavaType());
-
- }
-
- @Test
- public void testConvertSimpleDocTagAndPathMismatchToUserApp() {
- UserApplication ap = SwaggerParseUtils.getUserApplication("/swagger20TagsPathsMismatch.json");
- assertNotNull(ap);
- assertEquals("/services/helloservice", ap.getBasePath());
- Map<String, UserResource> map = ap.getResourcesAsMap();
- assertEquals(2, map.size());
-
- UserResource ur = map.get("sayHello");
- assertNotNull(ur);
- assertEquals("/", ur.getPath());
- assertEquals(1, ur.getOperations().size());
- UserOperation op = ur.getOperations().get(0);
- assertEquals("sayHello", op.getName());
- assertEquals("/sayHi/{a}", op.getPath());
- assertEquals("GET", op.getVerb());
- assertEquals("text/plain", op.getProduces());
-
- assertEquals(1, op.getParameters().size());
- Parameter param1 = op.getParameters().get(0);
- assertEquals("a", param1.getName());
- assertEquals(ParameterType.PATH, param1.getType());
- assertEquals(String.class, param1.getJavaType());
-
- UserResource ur2 = map.get("sayHello2");
- assertNotNull(ur2);
- assertEquals("/", ur2.getPath());
- assertEquals(1, ur2.getOperations().size());
- UserOperation op2 = ur2.getOperations().get(0);
- assertEquals("sayHello", op2.getName());
- assertEquals("/sayHi2/{a}", op2.getPath());
- assertEquals("GET", op2.getVerb());
- assertEquals("text/plain", op2.getProduces());
-
- assertEquals(1, op2.getParameters().size());
- Parameter param2 = op.getParameters().get(0);
- assertEquals("a", param2.getName());
- assertEquals(ParameterType.PATH, param2.getType());
- assertEquals(String.class, param2.getJavaType());
-
- }
-
- @Test
- public void testConvertSimpleDocNoTagsToUserApp() {
- UserApplication ap = SwaggerParseUtils.getUserApplication("/swagger20NoTags.json");
- assertNotNull(ap);
- assertEquals("/services/helloservice", ap.getBasePath());
- Map<String, UserResource> map = ap.getResourcesAsMap();
- assertEquals(1, map.size());
-
- UserResource ur = map.get("");
- assertNotNull(ur);
- assertEquals("/", ur.getPath());
- assertEquals(2, ur.getOperations().size());
- UserOperation op = ur.getOperations().get(0);
- assertEquals("sayHello", op.getName());
- assertEquals("/sayHello/{a}", op.getPath());
- assertEquals("GET", op.getVerb());
- assertEquals("text/plain", op.getProduces());
-
- assertEquals(1, op.getParameters().size());
- Parameter param1 = op.getParameters().get(0);
- assertEquals("a", param1.getName());
- assertEquals(ParameterType.PATH, param1.getType());
- assertEquals(String.class, param1.getJavaType());
-
- UserOperation op2 = ur.getOperations().get(1);
- assertEquals("sayHello2", op2.getName());
- assertEquals("/sayHello2/{a}", op2.getPath());
- assertEquals("GET", op2.getVerb());
- assertEquals("text/plain", op2.getProduces());
-
- assertEquals(1, op2.getParameters().size());
- Parameter param2 = op.getParameters().get(0);
- assertEquals("a", param2.getName());
- assertEquals(ParameterType.PATH, param2.getType());
- assertEquals(String.class, param2.getJavaType());
-
- }
-
- @Test
- public void testConvertSwaggerWithNullValuesForOperations() {
- UserApplication ap = SwaggerParseUtils.getUserApplication("/swagger2petShopWithNullOperations.json");
- assertNotNull(ap);
- }
-}
\ No newline at end of file
diff --git a/rt/rs/description-swagger/src/test/resources/swagger20.json b/rt/rs/description-swagger/src/test/resources/swagger20.json
deleted file mode 100644
index 6fce9941c9..0000000000
--- a/rt/rs/description-swagger/src/test/resources/swagger20.json
+++ /dev/null
@@ -1,48 +0,0 @@
-{
- "swagger":"2.0",
- "info": {
- "description":"The Application",
- "version":"1.0.0",
- "title":"Sample REST Application",
- "contact": {"name":"users@cxf.apache.org"},
- "license":{"name":"Apache 2.0 License","url":"http://www.apache.org/licenses/LICENSE-2.0.html"}
- },
-
- basePath":"/services/helloservice",
-
- "tags":[
- {"name":"sayHello2"},
- {"name":"sayHello"}
- ],
- "paths":
- {
- "/sayHello/{a}":
- {
- "get":
- {
- "tags":["sayHello"],
- "operationId":"sayHello",
- "produces":
- ["text/plain"],
- "parameters":
- [
- {"name":"a",
- "in":"path",
- "required":true,
- "type":"string"
- }
- ],
- "responses":
- {
- "200":
- {
- "description":"successful operation",
- "schema":{"type":"string"},
- "headers":{}
- }
- }
- }
- },
- "/sayHello2/{a}":
- {
- "get":{"tags":["sayHello2"],"operationId":"sayHello","produces":["text/plain"],"parameters":[{"name":"a","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"successful operation","schema":{"type":"string"},"headers":{}}}}}}}
\ No newline at end of file
diff --git a/rt/rs/description-swagger/src/test/resources/swagger20NoTags.json b/rt/rs/description-swagger/src/test/resources/swagger20NoTags.json
deleted file mode 100644
index 7be32f6ed7..0000000000
--- a/rt/rs/description-swagger/src/test/resources/swagger20NoTags.json
+++ /dev/null
@@ -1,43 +0,0 @@
-{
- "swagger":"2.0",
- "info": {
- "description":"The Application",
- "version":"1.0.0",
- "title":"Sample REST Application",
- "contact": {"name":"users@cxf.apache.org"},
- "license":{"name":"Apache 2.0 License","url":"http://www.apache.org/licenses/LICENSE-2.0.html"}
- },
-
- basePath":"/services/helloservice",
-
- "paths":
- {
- "/sayHello/{a}":
- {
- "get":
- {
- "operationId":"sayHello",
- "produces":
- ["text/plain"],
- "parameters":
- [
- {"name":"a",
- "in":"path",
- "required":true,
- "type":"string"
- }
- ],
- "responses":
- {
- "200":
- {
- "description":"successful operation",
- "schema":{"type":"string"},
- "headers":{}
- }
- }
- }
- },
- "/sayHello2/{a}":
- {
- "get":{"operationId":"sayHello2","produces":["text/plain"],"parameters":[{"name":"a","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"successful operation","schema":{"type":"string"},"headers":{}}}}}}}
\ No newline at end of file
diff --git a/rt/rs/description-swagger/src/test/resources/swagger20TagsPathsMismatch.json b/rt/rs/description-swagger/src/test/resources/swagger20TagsPathsMismatch.json
deleted file mode 100644
index ac9c83aa11..0000000000
--- a/rt/rs/description-swagger/src/test/resources/swagger20TagsPathsMismatch.json
+++ /dev/null
@@ -1,48 +0,0 @@
-{
- "swagger":"2.0",
- "info": {
- "description":"The Application",
- "version":"1.0.0",
- "title":"Sample REST Application",
- "contact": {"name":"users@cxf.apache.org"},
- "license":{"name":"Apache 2.0 License","url":"http://www.apache.org/licenses/LICENSE-2.0.html"}
- },
-
- basePath":"/services/helloservice",
-
- "tags":[
- {"name":"sayHello2"},
- {"name":"sayHello"}
- ],
- "paths":
- {
- "/sayHi/{a}":
- {
- "get":
- {
- "tags":["sayHello"],
- "operationId":"sayHello",
- "produces":
- ["text/plain"],
- "parameters":
- [
- {"name":"a",
- "in":"path",
- "required":true,
- "type":"string"
- }
- ],
- "responses":
- {
- "200":
- {
- "description":"successful operation",
- "schema":{"type":"string"},
- "headers":{}
- }
- }
- }
- },
- "/sayHi2/{a}":
- {
- "get":{"tags":["sayHello2"],"operationId":"sayHello","produces":["text/plain"],"parameters":[{"name":"a","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"successful operation","schema":{"type":"string"},"headers":{}}}}}}}
\ No newline at end of file
diff --git a/rt/rs/description-swagger/src/test/resources/swagger2petShop.json b/rt/rs/description-swagger/src/test/resources/swagger2petShop.json
deleted file mode 100644
index 0a65f8de5c..0000000000
--- a/rt/rs/description-swagger/src/test/resources/swagger2petShop.json
+++ /dev/null
@@ -1,741 +0,0 @@
-{"swagger":"2.0",
- "info":{
- "description":"This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",
- "version":"1.0.0","title":"Swagger Petstore",
- "termsOfService":"http://swagger.io/terms/",
- "contact":{
- "email":"apiteam@swagger.io"
- },
- "license":{
- "name":"Apache 2.0",
- "url":"http://www.apache.org/licenses/LICENSE-2.0.html"
- }
- },
- "host":"petstore.swagger.io",
- "basePath":"/v2",
- "tags":[
- {
- "name":"pet",
- "description":"Everything about your Pets",
- "externalDocs":{
- "description":"Find out more",
- "url":"http://swagger.io"
- }
- },
- {
- "name":"store",
- "description":"Access to Petstore orders"
- },
- {
- "name":"user",
- "description":"Operations about user",
- "externalDocs":{
- "description": "Find out more about our store",
- "url":"http://swagger.io"
- }
- }
- ],
- "schemes":["http"],
- "paths":{
- "/pet":{
- "post":{
- "tags":["pet"],
- "summary":"Add a new pet to the store",
- "description":"",
- "operationId":"addPet",
- "consumes":["application/json","application/xml"],
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "in":"body",
- "name":"body",
- "description":"Pet object that needs to be added to the store",
- "required":true,
- "schema":{"$ref":"#/definitions/Pet"}
- }
- ],
- "responses":{
- "405":{"description":"Invalid input"}
- },
- "security":[
- {
- "petstore_auth":[
- "write:pets",
- "read:pets"
- ]
- }
- ]
- },
- "put":{
- "tags":["pet"],
- "summary":"Update an existing pet",
- "description":"",
- "operationId":"updatePet",
- "consumes":["application/json","application/xml"],
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "in":"body",
- "name":"body",
- "description":"Pet object that needs to be added to the store",
- "required":true,
- "schema":{"$ref":"#/definitions/Pet"}
- }
- ],
- "responses":{
- "400":{"description":"Invalid ID supplied"},
- "404":{"description":"Pet not found"},
- "405":{"description":"Validation exception"}
- },
- "security":[
- {
- "petstore_auth":["write:pets","read:pets"]
- }
- ]
- }
- },
-
- "/pet/findByStatus":{
- "get":{
- "tags":["pet"],
- "summary":"Finds Pets by status",
- "description":"Multiple status values can be provided with comma separated strings",
- "operationId":"findPetsByStatus",
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "name":"status",
- "in":"query",
- "description":"Status values that need to be considered for filter",
- "required":true,
- "type":"array",
- "items":{
- "type":"string",
- "enum":["available","pending","sold"],
- "default":"available"
- },
- "collectionFormat":"multi"
- }
- ],
- "responses":{
- "200":{
- "description":"successful operation",
- "schema":{"type":"array","items":{"$ref":"#/definitions/Pet"}}
- },
- "400":{"description":"Invalid status value"}
- },
- "security":[
- {"petstore_auth":["write:pets","read:pets"]}
- ]
- }
- },
- "/pet/findByTags":{
- "get":{
- "tags":["pet"],
- "summary":"Finds Pets by tags",
- "description":"Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.",
- "operationId":"findPetsByTags",
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "name":"tags",
- "in":"query",
- "description":"Tags to filter by",
- "required":true,
- "type":"array",
- "items":{
- "type":"string"
- },
- "collectionFormat":"multi"
- }
- ],
- "responses":{
- "200":{
- "description":"successful operation",
- "schema":{"type":"array","items":{"$ref":"#/definitions/Pet"}}},
- "400":{
- "description":"Invalid tag value"}
- },
- "security":[
- {"petstore_auth":["write:pets","read:pets"]}
- ],
- "deprecated":true
- }
- },
- "/pet/{petId}":{
- "get":{
- "tags":["pet"],
- "summary":"Find pet by ID",
- "description":"Returns a single pet",
- "operationId":"getPetById",
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "name":"petId",
- "in":"path",
- "description":"ID of pet to return",
- "required":true,
- "type":"integer",
- "format":"int64"
- }
- ],
- "responses":{
- "200":{
- "description":"successful operation",
- "schema":{"$ref":"#/definitions/Pet"}
- },
- "400":{
- "description":"Invalid ID supplied"
- },
- "404":{
- "description":"Pet not found"}
- },
- "security":[
- {"api_key":[]}
- ]
- },
- "post":{
- "tags":["pet"],
- "summary":"Updates a pet in the store with form data",
- "description":"",
- "operationId":"updatePetWithForm",
- "consumes":["application/x-www-form-urlencoded"],
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "name":"petId",
- "in":"path",
- "description":"ID of pet that needs to be updated",
- "required":true,
- "type":"integer",
- "format":"int64"
- },
- {
- "name":"name",
- "in":"formData",
- "description":"Updated name of the pet",
- "required":false,
- "type":"string"
- },
- {
- "name":"status",
- "in":"formData",
- "description":"Updated status of the pet",
- "required":false,
- "type":"string"
- }
- ],
- "responses":{
- "405":{
- "description":"Invalid input"}
- },
- "security":[
- {"petstore_auth":["write:pets","read:pets"]}
- ]
- },
- "delete":{
- "tags":["pet"],
- "summary":"Deletes a pet",
- "description":"",
- "operationId":"deletePet",
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "name":"api_key",
- "in":"header",
- "required":false,
- "type":"string"
- },
- {
- "name":"petId",
- "in":"path",
- "description":"Pet id to delete",
- "required":true,
- "type":"integer",
- "format":"int64"
- }
- ],
- "responses":{
- "400":{
- "description":"Invalid ID supplied"
- },
- "404":{
- "description":"Pet not found"
- }
- },
- "security":[
- {"petstore_auth":["write:pets","read:pets"]}
- ]
- }
- },
- "/pet/{petId}/uploadImage":{
- "post":{
- "tags":["pet"],
- "summary":"uploads an image",
- "description":"",
- "operationId":"uploadFile",
- "consumes":["multipart/form-data"],
- "produces":["application/json"],
- "parameters":[
- {
- "name":"petId",
- "in":"path",
- "description":"ID of pet to update",
- "required":true,
- "type":"integer",
- "format":"int64"
- },
- {
- "name":"additionalMetadata",
- "in":"formData",
- "description":"Additional data to pass to server",
- "required":false,
- "type":"string"
- },
- {
- "name":"file",
- "in":"formData",
- "description":"file to upload",
- "required":false,
- "type":"file"
- }
- ],
- "responses":{
- "200":{
- "description":"successful operation",
- "schema":{"$ref":"#/definitions/ApiResponse"}
- }
- },
- "security":[{"petstore_auth":["write:pets","read:pets"]}]
- }
- },
- "/store/inventory":{
- "get":{
- "tags":["store"],
- "summary":"Returns pet inventories by status",
- "description":"Returns a map of status codes to quantities",
- "operationId":"getInventory",
- "produces":["application/json"],
- "parameters":[],
- "responses":{
- "200":{
- "description":"successful operation",
- "schema":{
- "type":"object",
- "additionalProperties":{"type":"integer","format":"int32"}
- }
- }
- },
- "security":[{"api_key":[]}]
- }
- },
- "/store/order":{
- "post":{
- "tags":["store"],
- "summary":"Place an order for a pet",
- "description":"",
- "operationId":"placeOrder",
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "in":"body",
- "name":"body",
- "description":"order placed for purchasing the pet",
- "required":true,
- "schema":{"$ref":"#/definitions/Order"}
- }
- ],
- "responses":{
- "200":{
- "description":"successful operation",
- "schema":{"$ref":"#/definitions/Order"}
- },
- "400":{
- "description":"Invalid Order"
- }
- }
- }
- },
- "/store/order/{orderId}":{
- "get":{
- "tags":["store"],
- "summary":"Find purchase order by ID",
- "description":"For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions",
- "operationId":"getOrderById",
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "name":"orderId",
- "in":"path",
- "description":"ID of pet that needs to be fetched",
- "required":true,
- "type":"integer",
- "maximum":10.0,
- "minimum":1.0,
- "format":"int64"
- }
- ],
- "responses":{
- "200":{
- "description":"successful operation",
- "schema":{"$ref":"#/definitions/Order"}
- },
- "400":{
- "description":"Invalid ID supplied"
- },
- "404":{
- "description":"Order not found"
- }
- }
- },
- "delete":{
- "tags":["store"],
- "summary":"Delete purchase order by ID",
- "description":"For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors",
- "operationId":"deleteOrder",
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "name":"orderId",
- "in":"path",
- "description":"ID of the order that needs to be deleted",
- "required":true,
- "type":"integer",
- "minimum":1.0,
- "format":"int64"
- }
- ],
- "responses":
- {
- "400":{
- "description":"Invalid ID supplied"
- },
- "404":{
- "description":"Order not found"}
- }
- }
- },
- "/user":{
- "post":{
- "tags":["user"],
- "summary":"Create user",
- "description":"This can only be done by the logged in user.",
- "operationId":"createUser",
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "in":"body",
- "name":"body",
- "description":"Created user object",
- "required":true,
- "schema":{"$ref":"#/definitions/User"}
- }
- ],
- "responses":{
- "default":{
- "description":"successful operation"}
- }
- }
- },
- "/user/createWithArray":{
- "post":{
- "tags":["user"],
- "summary":"Creates list of users with given input array",
- "description":"",
- "operationId":"createUsersWithArrayInput",
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "in":"body",
- "name":"body",
- "description":"List of user object",
- "required":true,
- "schema":{
- "type":"array",
- "items":{"$ref":"#/definitions/User"}
- }
- }
- ],
- "responses":{
- "default":{"description":"successful operation"}
- }
- }
- },
- "/user/createWithList":{
- "post":{
- "tags":["user"],
- "summary":"Creates list of users with given input array",
- "description":"",
- "operationId":"createUsersWithListInput",
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "in":"body",
- "name":"body",
- "description":"List of user object",
- "required":true,
- "schema":{
- "type":"array",
- "items":{"$ref":"#/definitions/User"}
- }
- }
- ],
- "responses":{
- "default":{"description":"successful operation"}
- }
- }
- },
- "/user/login":{
- "get":{
- "tags":["user"],
- "summary":"Logs user into the system",
- "description":"",
- "operationId":"loginUser",
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "name":"username",
- "in":"query",
- "description":"The user name for login",
- "required":true,
- "type":"string"
- },
- {
- "name":"password",
- "in":"query",
- "description":"The password for login in clear text",
- "required":true,
- "type":"string"
- }
- ],
- "responses":{
- "200":{
- "description":"successful operation",
- "schema":{"type":"string"},
- "headers":{
- "X-Rate-Limit":{
- "type":"integer",
- "format":"int32",
- "description":"calls per hour allowed by the user"
- },
- "X-Expires-After":{
- "type":"string",
- "format":"date-time",
- "description":"date in UTC when token expires"
- }
- }
- },
- "400":{"description":"Invalid username/password supplied"}
- }
- }
- },
- "/user/logout":{
- "get":{
- "tags":["user"],
- "summary":"Logs out current logged in user session",
- "description":"",
- "operationId":"logoutUser",
- "produces":["application/xml","application/json"],
- "parameters":[],
- "responses":{
- "default":{"description":"successful operation"}
- }
- }
- },
- "/user/{username}":{
- "get":{
- "tags":["user"],
- "summary":"Get user by user name",
- "description":"",
- "operationId":"getUserByName",
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "name":"username",
- "in":"path",
- "description":"The name that needs to be fetched. Use user1 for testing. ",
- "required":true,
- "type":"string"
- }
- ],
- "responses":{
- "200":{
- "description":"successful operation",
- "schema":{"$ref":"#/definitions/User"}
- },
- "400":{"description":"Invalid username supplied"},
- "404":{"description":"User not found"}
- }
- },
- "put":{
- "tags":["user"],
- "summary":"Updated user",
- "description":"This can only be done by the logged in user.",
- "operationId":"updateUser",
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "name":"username",
- "in":"path",
- "description":"name that need to be updated",
- "required":true,
- "type":"string"
- },
- {
- "in":"body",
- "name":"body",
- "description":"Updated user object",
- "required":true,
- "schema":{"$ref":"#/definitions/User"}
- }
- ],
- "responses":{
- "400":{"description":"Invalid user supplied"},
- "404":{"description":"User not found"}
- }
- },
- "delete":{
- "tags":["user"],
- "summary":"Delete user",
- "description":"This can only be done by the logged in user.",
- "operationId":"deleteUser",
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "name":"username",
- "in":"path",
- "description":"The name that needs to be deleted",
- "required":true,"type":"string"
- }
- ],
- "responses":{
- "400":{"description":"Invalid username supplied"},
- "404":{"description":"User not found"}
- }
- }
- }
- },
- "securityDefinitions":{
- "petstore_auth":{
- "type":"oauth2",
- "authorizationUrl":"http://petstore.swagger.io/oauth/dialog",
- "flow":"implicit",
- "scopes":{
- "write:pets":"modify pets in your account",
- "read:pets":"read your pets"
- }
- },
- "api_key":{
- "type":"apiKey",
- "name":"api_key",
- "in":"header"
- }
- },
- "definitions":{
- "Order":{
- "type":"object",
- "properties":{
- "id":{
- "type":"integer",
- "format":"int64"
- },
- "petId":{
- "type":"integer",
- "format":"int64"
- },
- "quantity":{
- "type":"integer",
- "format":"int32"
- },
- "shipDate":{
- "type":"string",
- "format":"date-time"
- },
- "status":{
- "type":"string",
- "description":"Order Status",
- "enum":["placed","approved","delivered"]
- },
- "complete":{
- "type":"boolean",
- "default":false
- }
- },
- "xml":{
- "name":"Order"
- }
- },
- "Category":{
- "type":"object",
- "properties":{
- "id":{
- "type":"integer","format":"int64"
- },
- "name":{
- "type":"string"}
- },
- "xml":{"name":"Category"}
- },
- "User":{
- "type":"object",
- "properties":{
- "id":{
- "type":"integer",
- "format":"int64"
- },
- "username":{"type":"string"},
- "firstName":{"type":"string"},
- "lastName":{"type":"string"},
- "email":{"type":"string"},
- "password":{"type":"string"},
- "phone":{"type":"string"},
- "userStatus":{
- "type":"integer",
- "format":"int32",
- "description":"User Status"
- }
- },
- "xml":{"name":"User"}
- },
- "Tag":{
- "type":"object",
- "properties":{
- "id":{"type":"integer","format":"int64"},
- "name":{"type":"string"}
- },
- "xml":{"name":"Tag"}
- },
- "Pet":{
- "type":"object",
- "required":["name","photoUrls"],
- "properties":{
- "id":{"type":"integer","format":"int64"},
- "category":{"$ref":"#/definitions/Category"},
- "name":{"type":"string","example":"doggie"},
- "photoUrls":{
- "type":"array",
- "xml":{"name":"photoUrl","wrapped":true},
- "items":{"type":"string"}
- },
- "tags":{
- "type":"array",
- "xml":{"name":"tag","wrapped":true},
- "items":{"$ref":"#/definitions/Tag"}
- },
- "status":{"type":"string","description":"pet status in the store","enum":["available","pending","sold"]}},
- "xml":{"name":"Pet"}
- },
- "ApiResponse":{
- "type":"object",
- "properties":{
- "code":{
- "type":"integer",
- "format":"int32"
- },
- "type":{"type":"string"},
- "message":{"type":"string"}
- }
- }
- },
- "externalDocs":{"description":"Find out more about Swagger","url":"http://swagger.io"}
-}
diff --git a/rt/rs/description-swagger/src/test/resources/swagger2petShopWithNullOperations.json b/rt/rs/description-swagger/src/test/resources/swagger2petShopWithNullOperations.json
deleted file mode 100644
index fe03b1a214..0000000000
--- a/rt/rs/description-swagger/src/test/resources/swagger2petShopWithNullOperations.json
+++ /dev/null
@@ -1,742 +0,0 @@
-{"swagger":"2.0",
- "info":{
- "description":"This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",
- "version":"1.0.0","title":"Swagger Petstore",
- "termsOfService":"http://swagger.io/terms/",
- "contact":{
- "email":"apiteam@swagger.io"
- },
- "license":{
- "name":"Apache 2.0",
- "url":"http://www.apache.org/licenses/LICENSE-2.0.html"
- }
- },
- "host":"petstore.swagger.io",
- "basePath":"/v2",
- "tags":[
- {
- "name":"pet",
- "description":"Everything about your Pets",
- "externalDocs":{
- "description":"Find out more",
- "url":"http://swagger.io"
- }
- },
- {
- "name":"store",
- "description":"Access to Petstore orders"
- },
- {
- "name":"user",
- "description":"Operations about user",
- "externalDocs":{
- "description": "Find out more about our store",
- "url":"http://swagger.io"
- }
- }
- ],
- "schemes":["http"],
- "paths":{
- "/pet":{
- "head": null,
- "post":{
- "tags":["pet"],
- "summary":"Add a new pet to the store",
- "description":"",
- "operationId":"addPet",
- "consumes":["application/json","application/xml"],
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "in":"body",
- "name":"body",
- "description":"Pet object that needs to be added to the store",
- "required":true,
- "schema":{"$ref":"#/definitions/Pet"}
- }
- ],
- "responses":{
- "405":{"description":"Invalid input"}
- },
- "security":[
- {
- "petstore_auth":[
- "write:pets",
- "read:pets"
- ]
- }
- ]
- },
- "put":{
- "tags":["pet"],
- "summary":"Update an existing pet",
- "description":"",
- "operationId":"updatePet",
- "consumes":["application/json","application/xml"],
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "in":"body",
- "name":"body",
- "description":"Pet object that needs to be added to the store",
- "required":true,
- "schema":{"$ref":"#/definitions/Pet"}
- }
- ],
- "responses":{
- "400":{"description":"Invalid ID supplied"},
- "404":{"description":"Pet not found"},
- "405":{"description":"Validation exception"}
- },
- "security":[
- {
- "petstore_auth":["write:pets","read:pets"]
- }
- ]
- }
- },
-
- "/pet/findByStatus":{
- "get":{
- "tags":["pet"],
- "summary":"Finds Pets by status",
- "description":"Multiple status values can be provided with comma separated strings",
- "operationId":"findPetsByStatus",
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "name":"status",
- "in":"query",
- "description":"Status values that need to be considered for filter",
- "required":true,
- "type":"array",
- "items":{
- "type":"string",
- "enum":["available","pending","sold"],
- "default":"available"
- },
- "collectionFormat":"multi"
- }
- ],
- "responses":{
- "200":{
- "description":"successful operation",
- "schema":{"type":"array","items":{"$ref":"#/definitions/Pet"}}
- },
- "400":{"description":"Invalid status value"}
- },
- "security":[
- {"petstore_auth":["write:pets","read:pets"]}
- ]
- }
- },
- "/pet/findByTags":{
- "get":{
- "tags":["pet"],
- "summary":"Finds Pets by tags",
- "description":"Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.",
- "operationId":"findPetsByTags",
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "name":"tags",
- "in":"query",
- "description":"Tags to filter by",
- "required":true,
- "type":"array",
- "items":{
- "type":"string"
- },
- "collectionFormat":"multi"
- }
- ],
- "responses":{
- "200":{
- "description":"successful operation",
- "schema":{"type":"array","items":{"$ref":"#/definitions/Pet"}}},
- "400":{
- "description":"Invalid tag value"}
- },
- "security":[
- {"petstore_auth":["write:pets","read:pets"]}
- ],
- "deprecated":true
- }
- },
- "/pet/{petId}":{
- "get":{
- "tags":["pet"],
- "summary":"Find pet by ID",
- "description":"Returns a single pet",
- "operationId":"getPetById",
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "name":"petId",
- "in":"path",
- "description":"ID of pet to return",
- "required":true,
- "type":"integer",
- "format":"int64"
- }
- ],
- "responses":{
- "200":{
- "description":"successful operation",
- "schema":{"$ref":"#/definitions/Pet"}
- },
- "400":{
- "description":"Invalid ID supplied"
- },
- "404":{
- "description":"Pet not found"}
- },
- "security":[
- {"api_key":[]}
- ]
- },
- "post":{
- "tags":["pet"],
- "summary":"Updates a pet in the store with form data",
- "description":"",
- "operationId":"updatePetWithForm",
- "consumes":["application/x-www-form-urlencoded"],
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "name":"petId",
- "in":"path",
- "description":"ID of pet that needs to be updated",
- "required":true,
- "type":"integer",
- "format":"int64"
- },
- {
- "name":"name",
- "in":"formData",
- "description":"Updated name of the pet",
- "required":false,
- "type":"string"
- },
- {
- "name":"status",
- "in":"formData",
- "description":"Updated status of the pet",
- "required":false,
- "type":"string"
- }
- ],
- "responses":{
- "405":{
- "description":"Invalid input"}
- },
- "security":[
- {"petstore_auth":["write:pets","read:pets"]}
- ]
- },
- "delete":{
- "tags":["pet"],
- "summary":"Deletes a pet",
- "description":"",
- "operationId":"deletePet",
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "name":"api_key",
- "in":"header",
- "required":false,
- "type":"string"
- },
- {
- "name":"petId",
- "in":"path",
- "description":"Pet id to delete",
- "required":true,
- "type":"integer",
- "format":"int64"
- }
- ],
- "responses":{
- "400":{
- "description":"Invalid ID supplied"
- },
- "404":{
- "description":"Pet not found"
- }
- },
- "security":[
- {"petstore_auth":["write:pets","read:pets"]}
- ]
- }
- },
- "/pet/{petId}/uploadImage":{
- "post":{
- "tags":["pet"],
- "summary":"uploads an image",
- "description":"",
- "operationId":"uploadFile",
- "consumes":["multipart/form-data"],
- "produces":["application/json"],
- "parameters":[
- {
- "name":"petId",
- "in":"path",
- "description":"ID of pet to update",
- "required":true,
- "type":"integer",
- "format":"int64"
- },
- {
- "name":"additionalMetadata",
- "in":"formData",
- "description":"Additional data to pass to server",
- "required":false,
- "type":"string"
- },
- {
- "name":"file",
- "in":"formData",
- "description":"file to upload",
- "required":false,
- "type":"file"
- }
- ],
- "responses":{
- "200":{
- "description":"successful operation",
- "schema":{"$ref":"#/definitions/ApiResponse"}
- }
- },
- "security":[{"petstore_auth":["write:pets","read:pets"]}]
- }
- },
- "/store/inventory":{
- "get":{
- "tags":["store"],
- "summary":"Returns pet inventories by status",
- "description":"Returns a map of status codes to quantities",
- "operationId":"getInventory",
- "produces":["application/json"],
- "parameters":[],
- "responses":{
- "200":{
- "description":"successful operation",
- "schema":{
- "type":"object",
- "additionalProperties":{"type":"integer","format":"int32"}
- }
- }
- },
- "security":[{"api_key":[]}]
- }
- },
- "/store/order":{
- "post":{
- "tags":["store"],
- "summary":"Place an order for a pet",
- "description":"",
- "operationId":"placeOrder",
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "in":"body",
- "name":"body",
- "description":"order placed for purchasing the pet",
- "required":true,
- "schema":{"$ref":"#/definitions/Order"}
- }
- ],
- "responses":{
- "200":{
- "description":"successful operation",
- "schema":{"$ref":"#/definitions/Order"}
- },
- "400":{
- "description":"Invalid Order"
- }
- }
- }
- },
- "/store/order/{orderId}":{
- "get":{
- "tags":["store"],
- "summary":"Find purchase order by ID",
- "description":"For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions",
- "operationId":"getOrderById",
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "name":"orderId",
- "in":"path",
- "description":"ID of pet that needs to be fetched",
- "required":true,
- "type":"integer",
- "maximum":10.0,
- "minimum":1.0,
- "format":"int64"
- }
- ],
- "responses":{
- "200":{
- "description":"successful operation",
- "schema":{"$ref":"#/definitions/Order"}
- },
- "400":{
- "description":"Invalid ID supplied"
- },
- "404":{
- "description":"Order not found"
- }
- }
- },
- "delete":{
- "tags":["store"],
- "summary":"Delete purchase order by ID",
- "description":"For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors",
- "operationId":"deleteOrder",
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "name":"orderId",
- "in":"path",
- "description":"ID of the order that needs to be deleted",
- "required":true,
- "type":"integer",
- "minimum":1.0,
- "format":"int64"
- }
- ],
- "responses":
- {
- "400":{
- "description":"Invalid ID supplied"
- },
- "404":{
- "description":"Order not found"}
- }
- }
- },
- "/user":{
- "post":{
- "tags":["user"],
- "summary":"Create user",
- "description":"This can only be done by the logged in user.",
- "operationId":"createUser",
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "in":"body",
- "name":"body",
- "description":"Created user object",
- "required":true,
- "schema":{"$ref":"#/definitions/User"}
- }
- ],
- "responses":{
- "default":{
- "description":"successful operation"}
- }
- }
- },
- "/user/createWithArray":{
- "post":{
- "tags":["user"],
- "summary":"Creates list of users with given input array",
- "description":"",
- "operationId":"createUsersWithArrayInput",
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "in":"body",
- "name":"body",
- "description":"List of user object",
- "required":true,
- "schema":{
- "type":"array",
- "items":{"$ref":"#/definitions/User"}
- }
- }
- ],
- "responses":{
- "default":{"description":"successful operation"}
- }
- }
- },
- "/user/createWithList":{
- "post":{
- "tags":["user"],
- "summary":"Creates list of users with given input array",
- "description":"",
- "operationId":"createUsersWithListInput",
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "in":"body",
- "name":"body",
- "description":"List of user object",
- "required":true,
- "schema":{
- "type":"array",
- "items":{"$ref":"#/definitions/User"}
- }
- }
- ],
- "responses":{
- "default":{"description":"successful operation"}
- }
- }
- },
- "/user/login":{
- "get":{
- "tags":["user"],
- "summary":"Logs user into the system",
- "description":"",
- "operationId":"loginUser",
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "name":"username",
- "in":"query",
- "description":"The user name for login",
- "required":true,
- "type":"string"
- },
- {
- "name":"password",
- "in":"query",
- "description":"The password for login in clear text",
- "required":true,
- "type":"string"
- }
- ],
- "responses":{
- "200":{
- "description":"successful operation",
- "schema":{"type":"string"},
- "headers":{
- "X-Rate-Limit":{
- "type":"integer",
- "format":"int32",
- "description":"calls per hour allowed by the user"
- },
- "X-Expires-After":{
- "type":"string",
- "format":"date-time",
- "description":"date in UTC when token expires"
- }
- }
- },
- "400":{"description":"Invalid username/password supplied"}
- }
- }
- },
- "/user/logout":{
- "get":{
- "tags":["user"],
- "summary":"Logs out current logged in user session",
- "description":"",
- "operationId":"logoutUser",
- "produces":["application/xml","application/json"],
- "parameters":[],
- "responses":{
- "default":{"description":"successful operation"}
- }
- }
- },
- "/user/{username}":{
- "get":{
- "tags":["user"],
- "summary":"Get user by user name",
- "description":"",
- "operationId":"getUserByName",
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "name":"username",
- "in":"path",
- "description":"The name that needs to be fetched. Use user1 for testing. ",
- "required":true,
- "type":"string"
- }
- ],
- "responses":{
- "200":{
- "description":"successful operation",
- "schema":{"$ref":"#/definitions/User"}
- },
- "400":{"description":"Invalid username supplied"},
- "404":{"description":"User not found"}
- }
- },
- "put":{
- "tags":["user"],
- "summary":"Updated user",
- "description":"This can only be done by the logged in user.",
- "operationId":"updateUser",
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "name":"username",
- "in":"path",
- "description":"name that need to be updated",
- "required":true,
- "type":"string"
- },
- {
- "in":"body",
- "name":"body",
- "description":"Updated user object",
- "required":true,
- "schema":{"$ref":"#/definitions/User"}
- }
- ],
- "responses":{
- "400":{"description":"Invalid user supplied"},
- "404":{"description":"User not found"}
- }
- },
- "delete":{
- "tags":["user"],
- "summary":"Delete user",
- "description":"This can only be done by the logged in user.",
- "operationId":"deleteUser",
- "produces":["application/xml","application/json"],
- "parameters":[
- {
- "name":"username",
- "in":"path",
- "description":"The name that needs to be deleted",
- "required":true,"type":"string"
- }
- ],
- "responses":{
- "400":{"description":"Invalid username supplied"},
- "404":{"description":"User not found"}
- }
- }
- }
- },
- "securityDefinitions":{
- "petstore_auth":{
- "type":"oauth2",
- "authorizationUrl":"http://petstore.swagger.io/oauth/dialog",
- "flow":"implicit",
- "scopes":{
- "write:pets":"modify pets in your account",
- "read:pets":"read your pets"
- }
- },
- "api_key":{
- "type":"apiKey",
- "name":"api_key",
- "in":"header"
- }
- },
- "definitions":{
- "Order":{
- "type":"object",
- "properties":{
- "id":{
- "type":"integer",
- "format":"int64"
- },
- "petId":{
- "type":"integer",
- "format":"int64"
- },
- "quantity":{
- "type":"integer",
- "format":"int32"
- },
- "shipDate":{
- "type":"string",
- "format":"date-time"
- },
- "status":{
- "type":"string",
- "description":"Order Status",
- "enum":["placed","approved","delivered"]
- },
- "complete":{
- "type":"boolean",
- "default":false
- }
- },
- "xml":{
- "name":"Order"
- }
- },
- "Category":{
- "type":"object",
- "properties":{
- "id":{
- "type":"integer","format":"int64"
- },
- "name":{
- "type":"string"}
- },
- "xml":{"name":"Category"}
- },
- "User":{
- "type":"object",
- "properties":{
- "id":{
- "type":"integer",
- "format":"int64"
- },
- "username":{"type":"string"},
- "firstName":{"type":"string"},
- "lastName":{"type":"string"},
- "email":{"type":"string"},
- "password":{"type":"string"},
- "phone":{"type":"string"},
- "userStatus":{
- "type":"integer",
- "format":"int32",
- "description":"User Status"
- }
- },
- "xml":{"name":"User"}
- },
- "Tag":{
- "type":"object",
- "properties":{
- "id":{"type":"integer","format":"int64"},
- "name":{"type":"string"}
- },
- "xml":{"name":"Tag"}
- },
- "Pet":{
- "type":"object",
- "required":["name","photoUrls"],
- "properties":{
- "id":{"type":"integer","format":"int64"},
- "category":{"$ref":"#/definitions/Category"},
- "name":{"type":"string","example":"doggie"},
- "photoUrls":{
- "type":"array",
- "xml":{"name":"photoUrl","wrapped":true},
- "items":{"type":"string"}
- },
- "tags":{
- "type":"array",
- "xml":{"name":"tag","wrapped":true},
- "items":{"$ref":"#/definitions/Tag"}
- },
- "status":{"type":"string","description":"pet status in the store","enum":["available","pending","sold"]}},
- "xml":{"name":"Pet"}
- },
- "ApiResponse":{
- "type":"object",
- "properties":{
- "code":{
- "type":"integer",
- "format":"int32"
- },
- "type":{"type":"string"},
- "message":{"type":"string"}
- }
- }
- },
- "externalDocs":{"description":"Find out more about Swagger","url":"http://swagger.io"}
-}
diff --git a/rt/rs/pom.xml b/rt/rs/pom.xml
index 7c77002549..2a71dfd1c3 100644
--- a/rt/rs/pom.xml
+++ b/rt/rs/pom.xml
@@ -49,15 +49,4 @@
<module>description-common-openapi</module>
<module>description-microprofile-openapi</module>
</modules>
-
- <profiles>
- <!-- TODO: This profile includes modules which are still on 'javax.*' namespace and
- are not migrated to Jakarta -->
- <profile>
- <id>javax</id>
- <modules>
- <module>description-swagger</module>
- </modules>
- </profile>
- </profiles>
</project>
diff --git a/systests/jaxrs/pom.xml b/systests/jaxrs/pom.xml
index 50ed950a9f..3f26188ff0 100644
--- a/systests/jaxrs/pom.xml
+++ b/systests/jaxrs/pom.xml
@@ -92,18 +92,6 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-rs-service-description-swagger</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>javax.validation</groupId>
- <artifactId>validation-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-service-description-openapi-v3</artifactId>
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/AbstractSwagger2ServiceDescriptionTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/AbstractSwagger2ServiceDescriptionTest.java
deleted file mode 100644
index 5734603f04..0000000000
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/AbstractSwagger2ServiceDescriptionTest.java
+++ /dev/null
@@ -1,279 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cxf.systest.jaxrs.description;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
-
-import jakarta.ws.rs.HttpMethod;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
-import jakarta.ws.rs.core.Response.Status;
-import org.apache.cxf.Bus;
-import org.apache.cxf.ext.logging.LoggingFeature;
-import org.apache.cxf.feature.Feature;
-import org.apache.cxf.helpers.IOUtils;
-import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
-import org.apache.cxf.jaxrs.client.WebClient;
-import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
-import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
-import org.apache.cxf.jaxrs.model.Parameter;
-import org.apache.cxf.jaxrs.model.ParameterType;
-import org.apache.cxf.jaxrs.model.UserApplication;
-import org.apache.cxf.jaxrs.model.UserOperation;
-import org.apache.cxf.jaxrs.model.UserResource;
-import org.apache.cxf.jaxrs.swagger.Swagger2Feature;
-import org.apache.cxf.jaxrs.swagger.parse.SwaggerParseUtils;
-import org.apache.cxf.testutil.common.AbstractClientServerTestBase;
-import org.apache.cxf.testutil.common.AbstractServerTestServerBase;
-import org.hamcrest.CoreMatchers;
-import org.yaml.snakeyaml.Yaml;
-
-import org.junit.Ignore;
-import org.junit.Test;
-
-
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-public abstract class AbstractSwagger2ServiceDescriptionTest extends AbstractClientServerTestBase {
- static final String SECURITY_DEFINITION_NAME = "basicAuth";
-
- protected enum XForwarded {
- NONE,
- ONE_HOST,
- MANY_HOSTS;
-
- boolean isSet() {
- return this != NONE;
- }
- }
-
- private static final String CONTACT = "cxf@apache.org";
- private static final String TITLE = "CXF unittest";
- private static final String DESCRIPTION = "API Description";
- private static final String LICENSE = "API License";
- private static final String LICENSE_URL = "API License URL";
-
- public abstract static class Server extends AbstractServerTestServerBase {
- protected final String port;
- protected final boolean runAsFilter;
-
- Server(final String port, final boolean runAsFilter) {
- this.port = port;
- this.runAsFilter = runAsFilter;
- }
-
- @Override
- protected org.apache.cxf.endpoint.Server createServer(Bus bus) throws Exception {
- final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
- sf.setResourceClasses(BookStoreSwagger2.class);
- sf.setResourceClasses(BookStoreStylesheetsSwagger2.class);
- sf.setResourceProvider(BookStoreSwagger2.class,
- new SingletonResourceProvider(new BookStoreSwagger2()));
- sf.setProvider(new JacksonJsonProvider());
- final Swagger2Feature feature = createSwagger2Feature();
- sf.setFeatures(Arrays.asList(feature));
- sf.setAddress("http://localhost:" + port + "/");
- sf.setExtensionMappings(
- Collections.singletonMap("json", "application/json;charset=UTF-8"));
- return sf.create();
- }
-
- protected Swagger2Feature createSwagger2Feature() {
- final Swagger2Feature feature = new Swagger2Feature();
- feature.setRunAsFilter(runAsFilter);
- feature.setContact(CONTACT);
- feature.setTitle(TITLE);
- feature.setDescription(DESCRIPTION);
- feature.setLicense(LICENSE);
- feature.setLicenseUrl(LICENSE_URL);
- feature.setSecurityDefinitions(Collections.singletonMap(SECURITY_DEFINITION_NAME,
- new io.swagger.models.auth.BasicAuthDefinition()));
- return feature;
- }
- }
-
- protected static void startServers(final Class< ? extends Server> serverClass) throws Exception {
- AbstractResourceInfo.clearAllMaps();
- //keep out of process due to stack traces testing failures
- assertTrue("server did not launch correctly", launchServer(serverClass, false));
- }
-
- protected abstract String getPort();
-
- protected abstract String getExpectedFileYaml();
-
- protected void doTestApiListingIsProperlyReturnedJSON() throws Exception {
- doTestApiListingIsProperlyReturnedJSON(XForwarded.NONE);
- }
- protected void doTestApiListingIsProperlyReturnedJSON(XForwarded useXForwarded) throws Exception {
- doTestApiListingIsProperlyReturnedJSON(createWebClient("/swagger.json"),
- useXForwarded);
- checkUiResource();
- }
- protected static void doTestApiListingIsProperlyReturnedJSON(final WebClient client,
- XForwarded useXForwarded) throws Exception {
- if (useXForwarded == XForwarded.ONE_HOST) {
- client.header("USE_XFORWARDED", true);
- } else if (useXForwarded == XForwarded.MANY_HOSTS) {
- client.header("USE_XFORWARDED_MANY_HOSTS", true);
- }
-
- try {
- String swaggerJson = client.get(String.class);
- UserApplication ap = SwaggerParseUtils.getUserApplicationFromJson(swaggerJson);
- assertNotNull(ap);
- assertEquals(useXForwarded.isSet() ? "/reverse" : "/", ap.getBasePath());
-
- List<UserResource> urs = ap.getResources();
- assertNotNull(urs);
- assertEquals(1, urs.size());
- UserResource r = urs.get(0);
- String basePath = "";
- if (!"/".equals(r.getPath())) {
- basePath = r.getPath();
- }
- Map<String, UserOperation> map = r.getOperationsAsMap();
- assertEquals(3, map.size());
- UserOperation getBooksOp = map.get("getBooks");
- assertEquals(HttpMethod.GET, getBooksOp.getVerb());
- assertEquals("/bookstore", basePath + getBooksOp.getPath());
- assertEquals(MediaType.APPLICATION_JSON, getBooksOp.getProduces());
- List<Parameter> getBooksOpParams = getBooksOp.getParameters();
- assertEquals(1, getBooksOpParams.size());
- assertEquals(ParameterType.QUERY, getBooksOpParams.get(0).getType());
- UserOperation getBookOp = map.get("getBook");
- assertEquals(HttpMethod.GET, getBookOp.getVerb());
- assertEquals("/bookstore/{id}", basePath + getBookOp.getPath());
- assertEquals(MediaType.APPLICATION_JSON, getBookOp.getProduces());
- List<Parameter> getBookOpParams = getBookOp.getParameters();
- assertEquals(1, getBookOpParams.size());
- assertEquals(ParameterType.PATH, getBookOpParams.get(0).getType());
- UserOperation deleteOp = map.get("delete");
- assertEquals(HttpMethod.DELETE, deleteOp.getVerb());
- assertEquals("/bookstore/{id}", basePath + deleteOp.getPath());
- List<Parameter> delOpParams = deleteOp.getParameters();
- assertEquals(1, delOpParams.size());
- assertEquals(ParameterType.PATH, delOpParams.get(0).getType());
-
- assertThat(swaggerJson, CoreMatchers.containsString(CONTACT));
- assertThat(swaggerJson, CoreMatchers.containsString(TITLE));
- assertThat(swaggerJson, CoreMatchers.containsString(DESCRIPTION));
- assertThat(swaggerJson, CoreMatchers.containsString(LICENSE));
- assertThat(swaggerJson, CoreMatchers.containsString(LICENSE_URL));
- assertThat(swaggerJson, CoreMatchers.containsString(SECURITY_DEFINITION_NAME));
- } finally {
- client.close();
- }
- }
-
- @Test
- public void testNonUiResource() {
- // Test that Swagger UI resources do not interfere with
- // application-specific ones.
- WebClient uiClient = WebClient
- .create("http://localhost:" + getPort() + "/css/book.css")
- .accept("text/css");
- String css = uiClient.get(String.class);
- assertThat(css, equalTo("body { background-color: lightblue; }"));
- }
-
- @Test
- public void testUiResource() {
- // Test that Swagger UI resources do not interfere with
- // application-specific ones and are accessible.
- WebClient uiClient = WebClient
- .create("http://localhost:" + getPort() + "/swagger-ui.css")
- .accept("text/css");
-
- try (Response response = uiClient.get()) {
- String css = response.readEntity(String.class);
- assertThat(css, containsString(".swagger-ui{"));
- assertThat(response.getMediaType(), equalTo(MediaType.valueOf("text/css")));
- }
- }
-
- @Test
- public void testUiRootResource() {
- // Test that Swagger UI resources do not interfere with
- // application-specific ones and are accessible.
- WebClient uiClient = WebClient
- .create("http://localhost:" + getPort() + "/api-docs")
- .accept("*/*");
-
- try (Response response = uiClient.get()) {
- String html = response.readEntity(String.class);
- assertThat(html, containsString("<!-- HTML"));
- assertThat(response.getMediaType(), equalTo(MediaType.TEXT_HTML_TYPE));
- }
- }
-
- @Test
- @Ignore
- public void testApiListingIsProperlyReturnedYAML() throws Exception {
- final WebClient client = createWebClient("/swagger.yaml");
-
- try {
- final Response r = client.get();
- assertEquals(Status.OK.getStatusCode(), r.getStatus());
- //REVISIT find a better way of reliably comparing two yaml instances.
- // I noticed that yaml.load instantiates a Map and
- // for an integer valued key, an Integer or a String is arbitrarily instantiated,
- // which leads to the assertion error. So, we serilialize the yamls and compare the re-serialized texts.
- Yaml yaml = new Yaml();
- assertEquals(yaml.load(getExpectedValue(getExpectedFileYaml(), getPort())).toString(),
- yaml.load(IOUtils.readStringFromStream((InputStream)r.getEntity())).toString());
-
- } finally {
- client.close();
- }
- }
-
- protected WebClient createWebClient(final String url) {
- return WebClient
- .create("http://localhost:" + getPort() + url,
- Arrays.< Object >asList(new JacksonJsonProvider()),
- Arrays.< Feature >asList(new LoggingFeature()),
- null)
- .accept(MediaType.APPLICATION_JSON).accept("application/yaml");
- }
-
- protected void checkUiResource() {
- WebClient uiClient = WebClient.create("http://localhost:" + getPort() + "/api-docs")
- .accept(MediaType.WILDCARD);
- String uiHtml = uiClient.get(String.class);
- assertTrue(uiHtml.contains("<title>Swagger UI</title>"));
- }
-
- private static String getExpectedValue(String name, Object... args) throws IOException {
- return String.format(IOUtils.readStringFromStream(
- AbstractSwagger2ServiceDescriptionTest.class.getResourceAsStream(name)), args);
- }
-}
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/BookStoreStylesheetsSwagger2.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/BookStoreStylesheetsSwagger2.java
deleted file mode 100644
index e9f8939c44..0000000000
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/BookStoreStylesheetsSwagger2.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cxf.systest.jaxrs.description;
-
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.Produces;
-
-import io.swagger.annotations.Api;
-
-@Api(hidden = true)
-@Path("/")
-public class BookStoreStylesheetsSwagger2 {
- @Produces({ "text/css" })
- @Path("/css/book.css")
- @GET
- public String getCss() {
- return "body { background-color: lightblue; }";
- }
-}
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/BookStoreSwagger2.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/BookStoreSwagger2.java
deleted file mode 100644
index 061044dd5c..0000000000
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/BookStoreSwagger2.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cxf.systest.jaxrs.description;
-
-import java.util.Arrays;
-
-import jakarta.ws.rs.DELETE;
-import jakarta.ws.rs.DefaultValue;
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.PathParam;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.QueryParam;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
-import org.apache.cxf.systest.jaxrs.Book;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-
-@Path("/bookstore")
-@Api(value = "/bookstore", description = "Sample JAX-RS service with Swagger documentation")
-public class BookStoreSwagger2 {
- @Produces({ MediaType.APPLICATION_JSON })
- @GET
- @ApiOperation(
- value = "Get books",
- notes = "Get books",
- response = Book.class,
- responseContainer = "List"
- )
- public Response getBooks(
- @ApiParam(value = "Page to fetch", required = true) @QueryParam("page") @DefaultValue("1") int page) {
- return Response.ok(
- Arrays.asList(
- new Book("Book 1", 1),
- new Book("Book 2", 2)
- )
- ).build();
- }
-
- @Produces({ MediaType.APPLICATION_JSON })
- @Path("/{id}")
- @GET
- @ApiOperation(
- value = "Get book by Id",
- notes = "Get book by Id",
- response = Book.class
- )
- public Book getBook(@ApiParam(value = "id", required = true) @PathParam("id") Long id) {
- return new Book("Book", id);
- }
-
- @Path("/{id}")
- @DELETE
- @ApiOperation(
- value = "Delete book",
- notes = "Delete book"
- )
- public Response delete(@ApiParam(value = "id", required = true) @PathParam("id") String id) {
- return Response.ok().build();
- }
-}
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/Swagger2CustomPropertiesTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/Swagger2CustomPropertiesTest.java
deleted file mode 100644
index 95b470ab6b..0000000000
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/Swagger2CustomPropertiesTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cxf.systest.jaxrs.description;
-
-import java.util.Collections;
-
-import org.apache.cxf.jaxrs.swagger.Swagger2Feature;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class Swagger2CustomPropertiesTest extends AbstractSwagger2ServiceDescriptionTest {
- private static final String PORT = allocatePort(Swagger2CustomPropertiesTest.class);
-
- public static class SwaggerRegular extends Server {
- public SwaggerRegular() {
- super(PORT, false);
- }
-
- public static void main(String[] args) throws Exception {
- new SwaggerRegular().start();
- }
-
- protected Swagger2Feature createSwagger2Feature() {
- final Swagger2Feature feature = new Swagger2Feature();
- feature.setRunAsFilter(runAsFilter);
- feature.setPropertiesLocation("/files/swagger.properties");
- feature.setSecurityDefinitions(Collections.singletonMap(SECURITY_DEFINITION_NAME,
- new io.swagger.models.auth.BasicAuthDefinition()));
- return feature;
- }
- }
-
- @BeforeClass
- public static void startServers() throws Exception {
- startServers(SwaggerRegular.class);
- }
-
- @Override
- protected String getPort() {
- return PORT;
- }
-
- @Override
- protected String getExpectedFileYaml() {
- return "swagger2-yaml.txt";
- }
-
- @Test
- public void testApiListingIsProperlyReturnedJSON() throws Exception {
- doTestApiListingIsProperlyReturnedJSON();
- }
-}
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/Swagger2FilterServiceDescriptionTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/Swagger2FilterServiceDescriptionTest.java
deleted file mode 100644
index ea3d30e45c..0000000000
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/Swagger2FilterServiceDescriptionTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cxf.systest.jaxrs.description;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class Swagger2FilterServiceDescriptionTest extends AbstractSwagger2ServiceDescriptionTest {
- private static final String PORT = allocatePort(Swagger2FilterServiceDescriptionTest.class);
-
- public static class SwaggerFilter extends Server {
- public SwaggerFilter() {
- super(PORT, true);
- }
-
- public static void main(String[] args) throws Exception {
- new SwaggerFilter().start();
- }
- }
-
- @BeforeClass
- public static void startServers() throws Exception {
- startServers(SwaggerFilter.class);
- }
-
- @Override
- protected String getPort() {
- return PORT;
- }
-
- @Override
- protected String getExpectedFileYaml() {
- return "swagger2-yaml.txt";
- }
-
- @Test
- public void testApiListingIsProperlyReturnedJSON() throws Exception {
- doTestApiListingIsProperlyReturnedJSON();
- }
-}
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/Swagger2NonAnnotatedServiceDescriptionTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/Swagger2NonAnnotatedServiceDescriptionTest.java
deleted file mode 100644
index 1dd57e1d35..0000000000
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/Swagger2NonAnnotatedServiceDescriptionTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cxf.systest.jaxrs.description;
-
-import java.util.Arrays;
-
-import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
-import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
-import org.apache.cxf.jaxrs.swagger.Swagger2Feature;
-import org.apache.cxf.systest.jaxrs.description.group1.BookStore;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class Swagger2NonAnnotatedServiceDescriptionTest extends AbstractSwagger2ServiceDescriptionTest {
- private static final String PORT = allocatePort(Swagger2NonAnnotatedServiceDescriptionTest.class);
-
- public static class SwaggerRegularNonAnnotated extends Server {
- public SwaggerRegularNonAnnotated() {
- super(PORT, false);
- }
-
- @Override
- protected org.apache.cxf.endpoint.Server createServer(Bus bus) throws Exception {
- final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
- sf.setResourceClasses(BookStore.class);
- sf.setResourceClasses(BookStoreStylesheetsSwagger2.class);
- sf.setResourceProvider(BookStore.class,
- new SingletonResourceProvider(new BookStore()));
- sf.setProvider(new JacksonJsonProvider());
- final Swagger2Feature feature = createSwagger2Feature();
- //FIXME swagger-jaxrs 1.5.3 can't handle a self-recursive subresource like Book
- // so we need to exclude "org.apache.cxf.systest.jaxrs" for now.
- feature.setResourcePackage("org.apache.cxf.systest.jaxrs.description.group1");
- feature.setScanAllResources(true);
- sf.setFeatures(Arrays.asList(feature));
- sf.setAddress("http://localhost:" + port + "/");
- return sf.create();
- }
-
- public static void main(String[] args) throws Exception {
- new SwaggerRegularNonAnnotated().start();
- }
- }
-
- @BeforeClass
- public static void startServers() throws Exception {
- startServers(SwaggerRegularNonAnnotated.class);
- }
-
- @Override
- protected String getPort() {
- return PORT;
- }
-
- @Test
- public void testApiListingIsProperlyReturnedJSON() throws Exception {
- doTestApiListingIsProperlyReturnedJSON();
- }
-
- @Override
- protected String getExpectedFileYaml() {
- return "swagger2-noano-yaml.txt";
- }
-}
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/Swagger2RegularServiceDescriptionTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/Swagger2RegularServiceDescriptionTest.java
deleted file mode 100644
index 64c3263ef6..0000000000
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/Swagger2RegularServiceDescriptionTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cxf.systest.jaxrs.description;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class Swagger2RegularServiceDescriptionTest extends AbstractSwagger2ServiceDescriptionTest {
- private static final String PORT = allocatePort(Swagger2RegularServiceDescriptionTest.class);
-
- public static class SwaggerRegular extends Server {
- public SwaggerRegular() {
- super(PORT, false);
- }
-
- public static void main(String[] args) throws Exception {
- new SwaggerRegular().start();
- }
- }
-
- @BeforeClass
- public static void startServers() throws Exception {
- startServers(SwaggerRegular.class);
- }
-
- @Override
- protected String getPort() {
- return PORT;
- }
-
- @Override
- protected String getExpectedFileYaml() {
- return "swagger2-yaml.txt";
- }
-
- @Test
- public void testApiListingIsProperlyReturnedJSON() throws Exception {
- doTestApiListingIsProperlyReturnedJSON();
- }
-}
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/Swagger2Server.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/Swagger2Server.java
deleted file mode 100644
index 1235eaae45..0000000000
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/Swagger2Server.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cxf.systest.jaxrs.description;
-
-import org.apache.cxf.systest.jaxrs.AbstractSpringServer;
-
-
-public class Swagger2Server extends AbstractSpringServer {
-
- static final String PORT = allocatePort(Swagger2Server.class);
-
- public Swagger2Server() {
- super("/jaxrs_swagger2", Integer.parseInt(PORT));
- }
-
- public static void main(String[] args) {
- try {
- Swagger2Server s = new Swagger2Server();
- s.start();
- } catch (Exception ex) {
- ex.printStackTrace();
- System.exit(-1);
- } finally {
- System.out.println("done!");
- }
- }
-
-}
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/Swagger2XForwardedDescriptionTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/Swagger2XForwardedDescriptionTest.java
deleted file mode 100644
index 804139ec0b..0000000000
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/Swagger2XForwardedDescriptionTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cxf.systest.jaxrs.description;
-
-import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-
-public class Swagger2XForwardedDescriptionTest extends AbstractSwagger2ServiceDescriptionTest {
- private static final String PORT = Swagger2Server.PORT;
-
- @BeforeClass
- public static void startServers() throws Exception {
- AbstractResourceInfo.clearAllMaps();
- assertTrue("server did not launch correctly", launchServer(Swagger2Server.class));
- }
-
- @Test
- public void testApiListingIsProperlyReturnedJSON() throws Exception {
- doTestApiListingIsProperlyReturnedJSON();
- }
-
- @Test
- public void testApiListingIsProperlyReturnedJSONXForwarded() throws Exception {
- doTestApiListingIsProperlyReturnedJSON(XForwarded.ONE_HOST);
- }
-
- @Test
- public void testApiListingIsProperlyReturnedJSONXForwardedManyHosts() throws Exception {
- doTestApiListingIsProperlyReturnedJSON(XForwarded.MANY_HOSTS);
- }
-
- @Override
- protected String getPort() {
- return PORT;
- }
-
- @Override
- protected String getExpectedFileYaml() {
- // TODO Auto-generated method stub
- return null;
- }
-}
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/SwaggerToOpenApiConversionTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/SwaggerToOpenApiConversionTest.java
deleted file mode 100644
index df62501cce..0000000000
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/SwaggerToOpenApiConversionTest.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cxf.systest.jaxrs.description;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import jakarta.ws.rs.core.MediaType;
-import org.apache.cxf.Bus;
-import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
-import org.apache.cxf.jaxrs.client.WebClient;
-import org.apache.cxf.jaxrs.json.basic.JsonMapObject;
-import org.apache.cxf.jaxrs.json.basic.JsonMapObjectReaderWriter;
-import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
-import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
-import org.apache.cxf.jaxrs.swagger.Swagger2Feature;
-import org.apache.cxf.jaxrs.swagger.openapi.SwaggerToOpenApiConversionFilter;
-import org.apache.cxf.systest.jaxrs.description.AbstractSwagger2ServiceDescriptionTest.XForwarded;
-import org.apache.cxf.testutil.common.AbstractClientServerTestBase;
-import org.apache.cxf.testutil.common.AbstractServerTestServerBase;
-
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-public class SwaggerToOpenApiConversionTest extends AbstractClientServerTestBase {
- static final String PORT = allocatePort(SwaggerToOpenApiConversionTest.class);
- static final String SECURITY_DEFINITION_NAME = "basicAuth";
-
- private static final String CONTACT = "cxf@apache.org";
- private static final String TITLE = "CXF unittest";
- private static final String DESCRIPTION = "API Description";
- private static final String LICENSE = "API License";
- private static final String LICENSE_URL = "API License URL";
-
- @Ignore
- public static class Server extends AbstractServerTestServerBase {
- @Override
- protected org.apache.cxf.endpoint.Server createServer(Bus bus) throws Exception {
- final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
- sf.setResourceClasses(BookStoreSwagger2.class);
- sf.setResourceProvider(BookStoreSwagger2.class,
- new SingletonResourceProvider(new BookStoreSwagger2()));
- sf.setProvider(new SwaggerToOpenApiConversionFilter());
- final Swagger2Feature feature = createSwagger2Feature();
- sf.setFeatures(Arrays.asList(feature));
- sf.setAddress("http://localhost:" + PORT + "/");
- return sf.create();
- }
-
- protected Swagger2Feature createSwagger2Feature() {
- final Swagger2Feature feature = new Swagger2Feature();
- feature.setContact(CONTACT);
- feature.setTitle(TITLE);
- feature.setDescription(DESCRIPTION);
- feature.setLicense(LICENSE);
- feature.setLicenseUrl(LICENSE_URL);
- feature.setSecurityDefinitions(Collections.singletonMap(SECURITY_DEFINITION_NAME,
- new io.swagger.models.auth.BasicAuthDefinition()));
- return feature;
- }
- }
-
- @BeforeClass
- public static void startServers() throws Exception {
- AbstractResourceInfo.clearAllMaps();
- assertTrue("server did not launch correctly",
- launchServer(Server.class, true));
- }
-
-
- @Test
- public void testOpenApiJSON() throws Exception {
- final WebClient client = createWebClient("/openapi.json");
- String openApiResponse = client.get(String.class);
- JsonMapObject openApiJson = new JsonMapObjectReaderWriter().fromJsonToJsonObject(openApiResponse);
- assertEquals(6, openApiJson.size());
- // version
- assertEquals("3.0.0", openApiJson.getProperty("openapi"));
- // servers
- List<Map<String, Object>> servers = openApiJson.getListMapProperty("servers");
- assertEquals(1, servers.size());
- assertEquals(1, servers.get(0).size());
- assertEquals("http://localhost:" + PORT, servers.get(0).get("url"));
- // info
- JsonMapObject info = openApiJson.getJsonMapProperty("info");
- assertEquals(4, info.size());
- assertEquals(DESCRIPTION, info.getProperty("description"));
- assertEquals(TITLE, info.getProperty("title"));
- JsonMapObject contact = info.getJsonMapProperty("contact");
- assertEquals(1, contact.size());
- assertEquals(CONTACT, contact.getProperty("name"));
- JsonMapObject license = info.getJsonMapProperty("license");
- assertEquals(2, license.size());
- assertEquals(LICENSE, license.getProperty("name"));
- assertEquals(LICENSE_URL, license.getProperty("url"));
- // tags
- List<Map<String, Object>> tags = openApiJson.getListMapProperty("tags");
- assertEquals(1, tags.size());
- assertEquals(1, tags.get(0).size());
- assertEquals("bookstore", tags.get(0).get("name"));
- // paths
- JsonMapObject paths = openApiJson.getJsonMapProperty("paths");
- assertEquals(2, paths.size());
- //1: bookstore
- JsonMapObject bookstore = paths.getJsonMapProperty("/bookstore");
- assertEquals(1, bookstore.size());
- // get
- verifyBookStoreGet(bookstore);
- //2: bookstore/{id}
- JsonMapObject bookstoreId = paths.getJsonMapProperty("/bookstore/{id}");
- assertEquals(2, bookstoreId.size());
- // get
- verifyBookStoreIdGet(bookstoreId);
- // delete
- verifyBookStoreIdDelete(bookstoreId);
-
- // components
- JsonMapObject comps = openApiJson.getJsonMapProperty("components");
- assertEquals(3, comps.size());
- JsonMapObject requestBodies = comps.getJsonMapProperty("requestBodies");
- assertEquals(0, requestBodies.size());
- JsonMapObject schemas = comps.getJsonMapProperty("schemas");
- assertEquals(1, schemas.size());
- JsonMapObject secSchemes = comps.getJsonMapProperty("securitySchemes");
- assertEquals(1, secSchemes.size());
-
- // Finally check swagger.json can still be generated.
- doTestSwagger2JSON();
- }
- private void verifyBookStoreGet(JsonMapObject bookstore) {
- JsonMapObject bookstoreGet = bookstore.getJsonMapProperty("get");
- assertEquals(6, bookstoreGet.size());
- List<String> bookstoreGetTags = bookstoreGet.getListStringProperty("tags");
- assertEquals(1, bookstoreGetTags.size());
- assertEquals("bookstore", bookstoreGetTags.get(0));
- assertEquals("Get books", bookstoreGet.getProperty("summary"));
- assertEquals("Get books", bookstoreGet.getProperty("description"));
- assertEquals("getBooks", bookstoreGet.getProperty("operationId"));
- List<Map<String, Object>> bookstoreGetParams = bookstoreGet.getListMapProperty("parameters");
- assertEquals(1, bookstoreGetParams.size());
- JsonMapObject firstParam = new JsonMapObject(bookstoreGetParams.get(0));
- assertEquals(5, firstParam.size());
- assertEquals("page", firstParam.getProperty("name"));
- assertEquals("query", firstParam.getProperty("in"));
- assertEquals("Page to fetch", firstParam.getProperty("description"));
- assertTrue(firstParam.getBooleanProperty("required"));
- JsonMapObject schema = firstParam.getJsonMapProperty("schema");
- assertEquals(3, schema.size());
- assertEquals("integer", schema.getProperty("type"));
- assertEquals("int32", schema.getProperty("format"));
- assertEquals(Integer.valueOf(1), schema.getIntegerProperty("default"));
- JsonMapObject responses = bookstoreGet.getJsonMapProperty("responses");
- assertEquals(1, responses.size());
- JsonMapObject okResp = responses.getJsonMapProperty("200");
- assertEquals(2, okResp.size());
- assertEquals("successful operation", okResp.getProperty("description"));
- JsonMapObject content = okResp.getJsonMapProperty("content");
- assertEquals(1, content.size());
- JsonMapObject jsonResp = content.getJsonMapProperty("application/json");
- assertEquals(1, jsonResp.size());
- JsonMapObject jsonRespSchema = jsonResp.getJsonMapProperty("schema");
- assertEquals(2, jsonRespSchema.size());
- assertEquals("array", jsonRespSchema.getProperty("type"));
- JsonMapObject jsonRespSchemaItems = jsonRespSchema.getJsonMapProperty("items");
- assertEquals(1, jsonRespSchemaItems.size());
- assertEquals("#components/schemas/Book", jsonRespSchemaItems.getProperty("$ref"));
- }
- private void verifyBookStoreIdGet(JsonMapObject bookstore) {
- JsonMapObject bookstoreGet = bookstore.getJsonMapProperty("get");
- assertEquals(6, bookstoreGet.size());
- List<String> bookstoreGetTags = bookstoreGet.getListStringProperty("tags");
- assertEquals(1, bookstoreGetTags.size());
- assertEquals("bookstore", bookstoreGetTags.get(0));
- assertEquals("Get book by Id", bookstoreGet.getProperty("summary"));
- assertEquals("Get book by Id", bookstoreGet.getProperty("description"));
- assertEquals("getBook", bookstoreGet.getProperty("operationId"));
- List<Map<String, Object>> bookstoreGetParams = bookstoreGet.getListMapProperty("parameters");
- assertEquals(1, bookstoreGetParams.size());
- JsonMapObject firstParam = new JsonMapObject(bookstoreGetParams.get(0));
- assertEquals(5, firstParam.size());
- assertEquals("id", firstParam.getProperty("name"));
- assertEquals("path", firstParam.getProperty("in"));
- assertEquals("id", firstParam.getProperty("description"));
- assertTrue(firstParam.getBooleanProperty("required"));
- JsonMapObject schema = firstParam.getJsonMapProperty("schema");
- assertEquals(2, schema.size());
- assertEquals("integer", schema.getProperty("type"));
- assertEquals("int64", schema.getProperty("format"));
- JsonMapObject responses = bookstoreGet.getJsonMapProperty("responses");
- assertEquals(1, responses.size());
- JsonMapObject okResp = responses.getJsonMapProperty("200");
- assertEquals(2, okResp.size());
- assertEquals("successful operation", okResp.getProperty("description"));
- JsonMapObject content = okResp.getJsonMapProperty("content");
- assertEquals(1, content.size());
- JsonMapObject jsonResp = content.getJsonMapProperty("application/json");
- assertEquals(1, jsonResp.size());
- JsonMapObject jsonRespSchema = jsonResp.getJsonMapProperty("schema");
- assertEquals(1, jsonRespSchema.size());
- assertEquals("#components/schemas/Book", jsonRespSchema.getProperty("$ref"));
- }
- private void verifyBookStoreIdDelete(JsonMapObject bookstore) {
- JsonMapObject bookstoreDel = bookstore.getJsonMapProperty("delete");
- assertEquals(6, bookstoreDel.size());
- List<String> bookstoreDelTags = bookstoreDel.getListStringProperty("tags");
- assertEquals(1, bookstoreDelTags.size());
- assertEquals("bookstore", bookstoreDelTags.get(0));
- assertEquals("Delete book", bookstoreDel.getProperty("summary"));
- assertEquals("Delete book", bookstoreDel.getProperty("description"));
- assertEquals("delete", bookstoreDel.getProperty("operationId"));
- List<Map<String, Object>> bookstoreDelParams = bookstoreDel.getListMapProperty("parameters");
- assertEquals(1, bookstoreDelParams.size());
- JsonMapObject firstParam = new JsonMapObject(bookstoreDelParams.get(0));
- assertEquals(5, firstParam.size());
- assertEquals("id", firstParam.getProperty("name"));
- assertEquals("path", firstParam.getProperty("in"));
- assertEquals("id", firstParam.getProperty("description"));
- assertTrue(firstParam.getBooleanProperty("required"));
- JsonMapObject schema = firstParam.getJsonMapProperty("schema");
- assertEquals(1, schema.size());
- assertEquals("string", schema.getProperty("type"));
- JsonMapObject responses = bookstoreDel.getJsonMapProperty("responses");
- assertEquals(1, responses.size());
- JsonMapObject okResp = responses.getJsonMapProperty("default");
- assertEquals(1, okResp.size());
- assertEquals("successful operation", okResp.getProperty("description"));
- }
-
- protected WebClient createWebClient(final String url) {
- WebClient wc = WebClient.create("http://localhost:" + PORT + url)
- .accept(MediaType.APPLICATION_JSON);
- WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000L);
- return wc;
- }
-
- private void doTestSwagger2JSON() throws Exception {
- final WebClient client = createWebClient("/swagger.json");
- AbstractSwagger2ServiceDescriptionTest.doTestApiListingIsProperlyReturnedJSON(client, XForwarded.NONE);
- }
-}
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/group1/BookStore.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/group1/BookStore.java
index ab717e7ac7..521b817b83 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/group1/BookStore.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/group1/BookStore.java
@@ -32,10 +32,7 @@ import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import org.apache.cxf.systest.jaxrs.Book;
-import io.swagger.annotations.Api;
-
@Path("/bookstore")
-@Api("/bookstore")
public class BookStore {
@Produces({ MediaType.APPLICATION_JSON })
@GET
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/openapi/AbstractOpenApiServiceDescriptionTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/openapi/AbstractOpenApiServiceDescriptionTest.java
index 77053439fe..38d8b4cd6c 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/openapi/AbstractOpenApiServiceDescriptionTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/openapi/AbstractOpenApiServiceDescriptionTest.java
@@ -23,7 +23,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
-import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
+import com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider;
import jakarta.ws.rs.HttpMethod;
import jakarta.ws.rs.core.MediaType;
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/openapi/OpenApiContextBasedConfigApplicationOnlyTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/openapi/OpenApiContextBasedConfigApplicationOnlyTest.java
index ea847170ed..e2c5b8f485 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/openapi/OpenApiContextBasedConfigApplicationOnlyTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/openapi/OpenApiContextBasedConfigApplicationOnlyTest.java
@@ -22,7 +22,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Set;
-import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
+import com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider;
import jakarta.ws.rs.core.Application;
import jakarta.ws.rs.core.MediaType;
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/openapi/OpenApiContextBasedConfigTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/openapi/OpenApiContextBasedConfigTest.java
index 4a235d14ce..2c0c4baf12 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/openapi/OpenApiContextBasedConfigTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/openapi/OpenApiContextBasedConfigTest.java
@@ -21,7 +21,7 @@ package org.apache.cxf.systest.jaxrs.description.openapi;
import java.util.Arrays;
import java.util.Collections;
-import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
+import com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider;
import jakarta.ws.rs.core.MediaType;
import org.apache.cxf.Bus;
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/openapi/OpenApiCustomizerTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/openapi/OpenApiCustomizerTest.java
index 89cdcabeca..e133386805 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/openapi/OpenApiCustomizerTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/openapi/OpenApiCustomizerTest.java
@@ -21,7 +21,7 @@ package org.apache.cxf.systest.jaxrs.description.openapi;
import java.util.Arrays;
import java.util.Collections;
-import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
+import com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider;
import jakarta.ws.rs.ext.RuntimeDelegate;
import org.apache.cxf.Bus;
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/openapi/OpenApiNonAnnotatedServiceDescriptionTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/openapi/OpenApiNonAnnotatedServiceDescriptionTest.java
index 8da9ec140e..95186903de 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/openapi/OpenApiNonAnnotatedServiceDescriptionTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/openapi/OpenApiNonAnnotatedServiceDescriptionTest.java
@@ -21,7 +21,7 @@ package org.apache.cxf.systest.jaxrs.description.openapi;
import java.util.Arrays;
import java.util.Collections;
-import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
+import com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider;
import org.apache.cxf.Bus;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/SwaggerUiConfigurationQueryConfigTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/openapi/SwaggerUiConfigurationQueryConfigTest.java
similarity index 85%
rename from systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/SwaggerUiConfigurationQueryConfigTest.java
rename to systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/openapi/SwaggerUiConfigurationQueryConfigTest.java
index 1557600039..552766c1a7 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/SwaggerUiConfigurationQueryConfigTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/openapi/SwaggerUiConfigurationQueryConfigTest.java
@@ -16,21 +16,20 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.cxf.systest.jaxrs.description;
+package org.apache.cxf.systest.jaxrs.description.openapi;
import java.util.Arrays;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
+import com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
import org.apache.cxf.Bus;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
import org.apache.cxf.jaxrs.client.WebClient;
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
-import org.apache.cxf.jaxrs.swagger.Swagger2Feature;
+import org.apache.cxf.jaxrs.openapi.OpenApiFeature;
import org.apache.cxf.jaxrs.swagger.ui.SwaggerUiConfig;
import org.apache.cxf.testutil.common.AbstractClientServerTestBase;
import org.apache.cxf.testutil.common.AbstractServerTestServerBase;
@@ -52,13 +51,13 @@ public class SwaggerUiConfigurationQueryConfigTest extends AbstractClientServerT
@Override
protected org.apache.cxf.endpoint.Server createServer(Bus bus) throws Exception {
final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
- sf.setResourceClasses(BookStoreSwagger2.class);
- sf.setResourceProvider(BookStoreSwagger2.class,
- new SingletonResourceProvider(new BookStoreSwagger2()));
+ sf.setResourceClasses(BookStoreOpenApi.class);
+ sf.setResourceProvider(BookStoreOpenApi.class,
+ new SingletonResourceProvider(new BookStoreOpenApi()));
sf.setProvider(new JacksonJsonProvider());
- final Swagger2Feature feature = new Swagger2Feature();
+ final OpenApiFeature feature = new OpenApiFeature();
feature.setRunAsFilter(false);
- feature.setSwaggerUiConfig(new SwaggerUiConfig().url("/swagger.json"));
+ feature.setSwaggerUiConfig(new SwaggerUiConfig().url("/openapi.json"));
sf.setFeatures(Arrays.asList(feature));
sf.setAddress("http://localhost:" + PORT + "/");
return sf.create();
@@ -82,7 +81,7 @@ public class SwaggerUiConfigurationQueryConfigTest extends AbstractClientServerT
// application-specific ones and are accessible.
WebClient uiClient = WebClient
.create("http://localhost:" + getPort() + "/api-docs")
- .query("url", "/swagger.json")
+ .query("url", "/openapi.json")
.accept("*/*");
try (Response response = uiClient.get()) {
@@ -99,7 +98,7 @@ public class SwaggerUiConfigurationQueryConfigTest extends AbstractClientServerT
WebClient uiClient = WebClient
.create("http://localhost:" + getPort() + "/api-docs")
.path("/swagger-initializer.js")
- .query("url", "/another-swagger.json")
+ .query("url", "/another-openapi.json")
.accept("*/*");
try (Response response = uiClient.get()) {
@@ -107,7 +106,7 @@ public class SwaggerUiConfigurationQueryConfigTest extends AbstractClientServerT
// We can only verify that the url was not replaced with the one configured, but not that
// the one in query is used (that would be testing the Swagger itself). The query parameter was included
// to demonstrate how the address might look, though.
- assertFalse(jsCode.contains("url: \"/swagger.json\""));
+ assertFalse(jsCode.contains("url: \"/openapi.json\""));
}
}
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/SwaggerUiConfigurationTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/openapi/SwaggerUiConfigurationTest.java
similarity index 88%
rename from systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/SwaggerUiConfigurationTest.java
rename to systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/openapi/SwaggerUiConfigurationTest.java
index 4ea9aedaec..4ac2082afb 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/SwaggerUiConfigurationTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/openapi/SwaggerUiConfigurationTest.java
@@ -16,11 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.cxf.systest.jaxrs.description;
+package org.apache.cxf.systest.jaxrs.description.openapi;
import java.util.Arrays;
-import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
+import com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
@@ -29,7 +29,7 @@ import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
import org.apache.cxf.jaxrs.client.WebClient;
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
-import org.apache.cxf.jaxrs.swagger.Swagger2Feature;
+import org.apache.cxf.jaxrs.openapi.OpenApiFeature;
import org.apache.cxf.jaxrs.swagger.ui.SwaggerUiConfig;
import org.apache.cxf.testutil.common.AbstractClientServerTestBase;
import org.apache.cxf.testutil.common.AbstractServerTestServerBase;
@@ -51,13 +51,13 @@ public class SwaggerUiConfigurationTest extends AbstractClientServerTestBase {
@Override
protected org.apache.cxf.endpoint.Server createServer(Bus bus) throws Exception {
final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
- sf.setResourceClasses(BookStoreSwagger2.class);
- sf.setResourceProvider(BookStoreSwagger2.class,
- new SingletonResourceProvider(new BookStoreSwagger2()));
+ sf.setResourceClasses(BookStoreOpenApi.class);
+ sf.setResourceProvider(BookStoreOpenApi.class,
+ new SingletonResourceProvider(new BookStoreOpenApi()));
sf.setProvider(new JacksonJsonProvider());
- final Swagger2Feature feature = new Swagger2Feature();
+ final OpenApiFeature feature = new OpenApiFeature();
feature.setRunAsFilter(false);
- feature.setSwaggerUiConfig(new SwaggerUiConfig().url("/swagger.json").queryConfigEnabled(false));
+ feature.setSwaggerUiConfig(new SwaggerUiConfig().url("/openapi.json").queryConfigEnabled(false));
sf.setFeatures(Arrays.asList(feature));
sf.setAddress("http://localhost:" + PORT + "/");
return sf.create();
@@ -87,7 +87,7 @@ public class SwaggerUiConfigurationTest extends AbstractClientServerTestBase {
try (Response response = uiClient.get()) {
assertThat(response.getStatus(), equalTo(Response.Status.TEMPORARY_REDIRECT.getStatusCode()));
- assertThat(response.getHeaderString("Location"), equalTo(url + "?url=/swagger.json"));
+ assertThat(response.getHeaderString("Location"), equalTo(url + "?url=/openapi.json"));
}
}
@@ -130,13 +130,13 @@ public class SwaggerUiConfigurationTest extends AbstractClientServerTestBase {
WebClient uiClient = WebClient
.create("http://localhost:" + getPort() + "/api-docs")
.path("/swagger-initializer.js")
- .query("another-swagger.json")
+ .query("another-openapi.json")
.accept("*/*");
try (Response response = uiClient.get()) {
String jsCode = response.readEntity(String.class);
- assertTrue(jsCode.contains("url: \"/swagger.json\""));
- assertFalse(jsCode.contains("another-swagger.json"));
+ assertTrue(jsCode.contains("url: \"/openapi.json\""));
+ assertFalse(jsCode.contains("another-openapi.json"));
}
}