You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Daniyar Yeralin (JIRA)" <ji...@apache.org> on 2017/11/14 21:21:00 UTC
[jira] [Updated] (CXF-7563) non-unique operationIds in swagger.json
result in '_1' appended
[ https://issues.apache.org/jira/browse/CXF-7563?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Daniyar Yeralin updated CXF-7563:
---------------------------------
Affects Version/s: 3.1.11
Description:
We are using SpringBoot + JAX-RS server and define two service beans from *2 separate packages*. The jaxrs server is configured with Swagger2Feature to generate the swagger.json, but the operationIds and thus the URIs for these services get appended with '_1'.
Sample (Gradle + IDEA) project:
https://github.com/yeralin/ReproduceBug-CXF-7563-
Structure:
!https://i.imgur.com/Q0hh4O3.png!
Sample Java class:
{code:java}
@SpringBootApplication
public class DemoApplication {
@Autowired
private SampleService sampleService;
@Autowired
private SampleServiceInternal sampleServiceInternal;
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@Bean(destroyMethod = "shutdown")
public SpringBus cxf() {
return new SpringBus();
}
@Bean(destroyMethod = "destroy")
@DependsOn("cxf")
public Server jaxRsServer() {
final JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
factory.setServiceBeans(Arrays.asList(sampleService, sampleServiceInternal));
factory.setBus(cxf());
factory.setAddress("/");
factory.setFeatures(Arrays.asList(configureSwagger()));
return factory.create();
}
private Swagger2Feature configureSwagger() {
Swagger2Feature feature = new Swagger2Feature();
feature.setBasePath("/");
return feature;
}
}
{code}
Swagger.json:
{code:json}
// 20171114155626
// http://localhost:17070/services/swagger.json
{
"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",
"tags": Array[2][
{
"name": "internal"
},
{
"name": "test"
}
],
"paths": {
"/Internal/internal": {
"get": {
"tags": Array[1][
"internal"
],
"operationId": "getInternal_1",
"parameters": Array[0][
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"type": "string"
},
"headers": {
}
}
}
}
},
"/test/test": {
"get": {
"tags": Array[1][
"test"
],
"operationId": "getTest_1",
"parameters": Array[0][
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"type": "string"
},
"headers": {
}
}
}
}
}
}
}
{code}
was:
When using SpringBoot + JAX-RS server (with two service beans from *2 separate packages*) combined with Swagger2Feature (to generate swagger.json for provided ServiceBeans), URIs for these services get appended with '_1' (under "operationId" inside swagger.json)
Sample (Gradle + IDEA) project:
https://github.com/yeralin/ReproduceBug-CXF-7563-
Structure:
!https://i.imgur.com/Q0hh4O3.png!
Sample Java class:
{code:java}
@SpringBootApplication
public class DemoApplication {
@Autowired
private SampleService sampleService;
@Autowired
private SampleServiceInternal sampleServiceInternal;
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@Bean(destroyMethod = "shutdown")
public SpringBus cxf() {
return new SpringBus();
}
@Bean(destroyMethod = "destroy")
@DependsOn("cxf")
public Server jaxRsServer() {
final JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
factory.setServiceBeans(Arrays.asList(sampleService, sampleServiceInternal));
factory.setBus(cxf());
factory.setAddress("/");
factory.setFeatures(Arrays.asList(configureSwagger()));
return factory.create();
}
private Swagger2Feature configureSwagger() {
Swagger2Feature feature = new Swagger2Feature();
feature.setBasePath("/");
return feature;
}
}
{code}
Swagger.json:
{code:json}
// 20171114155626
// http://localhost:17070/services/swagger.json
{
"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",
"tags": Array[2][
{
"name": "internal"
},
{
"name": "test"
}
],
"paths": {
"/Internal/internal": {
"get": {
"tags": Array[1][
"internal"
],
"operationId": "getInternal_1",
"parameters": Array[0][
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"type": "string"
},
"headers": {
}
}
}
}
},
"/test/test": {
"get": {
"tags": Array[1][
"test"
],
"operationId": "getTest_1",
"parameters": Array[0][
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"type": "string"
},
"headers": {
}
}
}
}
}
}
}
{code}
Summary: non-unique operationIds in swagger.json result in '_1' appended (was: Swagger.json is generated with modified URI (appends '_1'))
> non-unique operationIds in swagger.json result in '_1' appended
> ---------------------------------------------------------------
>
> Key: CXF-7563
> URL: https://issues.apache.org/jira/browse/CXF-7563
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 3.1.11
> Environment: Tested on two systems:
> 1) Darwin 17.2.0 Darwin Kernel Version 17.2.0: Fri Sep 29 18:27:05 PDT 2017; root:xnu-4570.20.62~3/RELEASE_X86_64 x86_64
> 2) Linux 2.6.32-696.1.1.el6.x86_64 #1 SMP Tue Mar 21 12:19:18 EDT 2017 x86_64 x86_64 x86_64 GNU/Linux
> Reporter: Daniyar Yeralin
> Priority: Minor
>
> We are using SpringBoot + JAX-RS server and define two service beans from *2 separate packages*. The jaxrs server is configured with Swagger2Feature to generate the swagger.json, but the operationIds and thus the URIs for these services get appended with '_1'.
> Sample (Gradle + IDEA) project:
> https://github.com/yeralin/ReproduceBug-CXF-7563-
> Structure:
> !https://i.imgur.com/Q0hh4O3.png!
> Sample Java class:
> {code:java}
> @SpringBootApplication
> public class DemoApplication {
> @Autowired
> private SampleService sampleService;
> @Autowired
> private SampleServiceInternal sampleServiceInternal;
> public static void main(String[] args) {
> SpringApplication.run(DemoApplication.class, args);
> }
> @Bean(destroyMethod = "shutdown")
> public SpringBus cxf() {
> return new SpringBus();
> }
> @Bean(destroyMethod = "destroy")
> @DependsOn("cxf")
> public Server jaxRsServer() {
> final JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
> factory.setServiceBeans(Arrays.asList(sampleService, sampleServiceInternal));
> factory.setBus(cxf());
> factory.setAddress("/");
> factory.setFeatures(Arrays.asList(configureSwagger()));
> return factory.create();
> }
> private Swagger2Feature configureSwagger() {
> Swagger2Feature feature = new Swagger2Feature();
> feature.setBasePath("/");
> return feature;
> }
> }
> {code}
> Swagger.json:
> {code:json}
> // 20171114155626
> // http://localhost:17070/services/swagger.json
> {
> "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",
> "tags": Array[2][
> {
> "name": "internal"
> },
> {
> "name": "test"
> }
> ],
> "paths": {
> "/Internal/internal": {
> "get": {
> "tags": Array[1][
> "internal"
> ],
> "operationId": "getInternal_1",
> "parameters": Array[0][
>
> ],
> "responses": {
> "200": {
> "description": "successful operation",
> "schema": {
> "type": "string"
> },
> "headers": {
>
> }
> }
> }
> }
> },
> "/test/test": {
> "get": {
> "tags": Array[1][
> "test"
> ],
> "operationId": "getTest_1",
> "parameters": Array[0][
>
> ],
> "responses": {
> "200": {
> "description": "successful operation",
> "schema": {
> "type": "string"
> },
> "headers": {
>
> }
> }
> }
> }
> }
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)