You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Sergey Beryozkin <sb...@gmail.com> on 2017/08/17 10:55:03 UTC
Re: cxf git commit: improved Swagger description
Thanks for this update, but this reminds me of the idea of having
SwaggerFeature checking swagger.properties on the class path, so that
most of the simple well known properties can be set/modified without
them being encoded in the code.
The other thing which is worth investigating is having SwaggerFeature
checking if swagger.json is already available on the class path (done
earlier by java2swagger) and if yes then do not register Swagger
ApiListing at all and register instead a simple resource (similar to the
UI one) which will serve this swagger.json
I'll have a look a bit later on.
Cheers, Sergey
On 16/08/17 21:29, deki@apache.org wrote:
> Repository: cxf
> Updated Branches:
> refs/heads/master 2fbd4e82b -> 1dc79d9d5
>
>
> improved Swagger description
>
>
> Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
> Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/1dc79d9d
> Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/1dc79d9d
> Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/1dc79d9d
>
> Branch: refs/heads/master
> Commit: 1dc79d9d5a04462dea347a6b0a583458c2c28c47
> Parents: 2fbd4e8
> Author: Dennis Kieselhorst <de...@apache.org>
> Authored: Wed Aug 16 22:29:21 2017 +0200
> Committer: Dennis Kieselhorst <de...@apache.org>
> Committed: Wed Aug 16 22:29:21 2017 +0200
>
> ----------------------------------------------------------------------
> .../java/sample/rs/service/SampleRestApplication.java | 14 ++++++++++++++
> .../application/src/main/resources/application.yml | 4 ++--
> 2 files changed, 16 insertions(+), 2 deletions(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/1dc79d9d/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/java/sample/rs/service/SampleRestApplication.java
> ----------------------------------------------------------------------
> diff --git a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/java/sample/rs/service/SampleRestApplication.java b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/java/sample/rs/service/SampleRestApplication.java
> index 1f3ff56..1413b5a 100644
> --- a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/java/sample/rs/service/SampleRestApplication.java
> +++ b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/java/sample/rs/service/SampleRestApplication.java
> @@ -21,6 +21,7 @@ import java.util.Collections;
>
> import com.codahale.metrics.MetricRegistry;
>
> +import org.apache.cxf.jaxrs.swagger.Swagger2Feature;
> import org.springframework.boot.SpringApplication;
> import org.springframework.boot.actuate.endpoint.MetricReaderPublicMetrics;
> import org.springframework.boot.actuate.endpoint.MetricsEndpoint;
> @@ -47,4 +48,17 @@ public class SampleRestApplication {
> public static void main(String[] args) {
> SpringApplication.run(SampleRestApplication.class, args);
> }
> +
> + @Bean
> + public Swagger2Feature enhancedSwaggerDescription() {
> + Swagger2Feature swagger2Feature = new Swagger2Feature();
> + swagger2Feature.setPrettyPrint(true);
> + swagger2Feature.setTitle("Spring Boot CXF REST Scan Application");
> + swagger2Feature.setContact("The Apache CXF team");
> + swagger2Feature.setDescription("This sample project demonstrates how to use CXF JAX-RS services"
> + + " with Spring Boot. This demo has two JAX-RS class resources being auto-discovered"
> + + " and deployed in a single JAX-RS endpoint.");
> + swagger2Feature.setVersion("1.0.0");
> + return swagger2Feature;
> + }
> }
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/1dc79d9d/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/resources/application.yml
> ----------------------------------------------------------------------
> diff --git a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/resources/application.yml b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/resources/application.yml
> index 6ca143d..41e2dd9 100644
> --- a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/resources/application.yml
> +++ b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/resources/application.yml
> @@ -10,7 +10,7 @@ cxf:
> service-list-path: /info
> jaxrs:
> component-scan: true
> - classes-scan-packages: org.apache.cxf.jaxrs.swagger,org.apache.cxf.metrics
> + classes-scan-packages: org.apache.cxf.metrics
>
> eureka:
> client:
> @@ -21,7 +21,7 @@ eureka:
> statusPageUrlPath: /services/helloservice/info
> healthCheckUrlPath: /system/health
> metadataMap:
> - instanceId: ${spring.application.name}:${spring.application.instance_id:${random.value}}
> + instanceId: ${spring.application.name}:${spring.application.instance_id:${random.value}}
> servletPath: ${cxf.path}
>
> endpoints:
>
Re: cxf git commit: improved Swagger description
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Dennis, Freeman, all,
Couple of more comments,
On 17/08/17 11:55, Sergey Beryozkin wrote:
> Thanks for this update, but this reminds me of the idea of having
> SwaggerFeature checking swagger.properties on the class path, so that
> most of the simple well known properties can be set/modified without
> them being encoded in the code.
I guess the feature would check the properties at the configurable
'swaggerPropertiesLocation', with "/swagger.properties" being the
default one, and then use them to set the simple Swagger properties
which has not been already set by SwaggerFeature setters ?
>
> The other thing which is worth investigating is having SwaggerFeature
> checking if swagger.json is already available on the class path (done
> earlier by java2swagger) and if yes then do not register Swagger
> ApiListing at all and register instead a simple resource (similar to the
> UI one) which will serve this swagger.json
Similarly, it would probably check for a /swagger.json resource with the
location being configurable, and if avail - then skip all that code
which registers ApiListing, etc, though may be it will become a bit too
messy, may be we should start with the above task first
Freeman - how do you serve those generated swagger.jsons, is it detected
by ApiListing or do you register some custom resource ?
Sergey
>
> I'll have a look a bit later on.
>
> Cheers, Sergey
> On 16/08/17 21:29, deki@apache.org wrote:
>> Repository: cxf
>> Updated Branches:
>> refs/heads/master 2fbd4e82b -> 1dc79d9d5
>>
>>
>> improved Swagger description
>>
>>
>> Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
>> Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/1dc79d9d
>> Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/1dc79d9d
>> Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/1dc79d9d
>>
>> Branch: refs/heads/master
>> Commit: 1dc79d9d5a04462dea347a6b0a583458c2c28c47
>> Parents: 2fbd4e8
>> Author: Dennis Kieselhorst <de...@apache.org>
>> Authored: Wed Aug 16 22:29:21 2017 +0200
>> Committer: Dennis Kieselhorst <de...@apache.org>
>> Committed: Wed Aug 16 22:29:21 2017 +0200
>>
>> ----------------------------------------------------------------------
>> .../java/sample/rs/service/SampleRestApplication.java | 14
>> ++++++++++++++
>> .../application/src/main/resources/application.yml | 4 ++--
>> 2 files changed, 16 insertions(+), 2 deletions(-)
>> ----------------------------------------------------------------------
>>
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/1dc79d9d/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/java/sample/rs/service/SampleRestApplication.java
>>
>> ----------------------------------------------------------------------
>> diff --git
>> a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/java/sample/rs/service/SampleRestApplication.java
>> b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/java/sample/rs/service/SampleRestApplication.java
>>
>> index 1f3ff56..1413b5a 100644
>> ---
>> a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/java/sample/rs/service/SampleRestApplication.java
>>
>> +++
>> b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/java/sample/rs/service/SampleRestApplication.java
>>
>> @@ -21,6 +21,7 @@ import java.util.Collections;
>> import com.codahale.metrics.MetricRegistry;
>> +import org.apache.cxf.jaxrs.swagger.Swagger2Feature;
>> import org.springframework.boot.SpringApplication;
>> import
>> org.springframework.boot.actuate.endpoint.MetricReaderPublicMetrics;
>> import org.springframework.boot.actuate.endpoint.MetricsEndpoint;
>> @@ -47,4 +48,17 @@ public class SampleRestApplication {
>> public static void main(String[] args) {
>> SpringApplication.run(SampleRestApplication.class, args);
>> }
>> +
>> + @Bean
>> + public Swagger2Feature enhancedSwaggerDescription() {
>> + Swagger2Feature swagger2Feature = new Swagger2Feature();
>> + swagger2Feature.setPrettyPrint(true);
>> + swagger2Feature.setTitle("Spring Boot CXF REST Scan
>> Application");
>> + swagger2Feature.setContact("The Apache CXF team");
>> + swagger2Feature.setDescription("This sample project
>> demonstrates how to use CXF JAX-RS services"
>> + + " with Spring Boot. This demo has two JAX-RS class
>> resources being auto-discovered"
>> + + " and deployed in a single JAX-RS endpoint.");
>> + swagger2Feature.setVersion("1.0.0");
>> + return swagger2Feature;
>> + }
>> }
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/1dc79d9d/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/resources/application.yml
>>
>> ----------------------------------------------------------------------
>> diff --git
>> a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/resources/application.yml
>> b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/resources/application.yml
>>
>> index 6ca143d..41e2dd9 100644
>> ---
>> a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/resources/application.yml
>>
>> +++
>> b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/resources/application.yml
>>
>> @@ -10,7 +10,7 @@ cxf:
>> service-list-path: /info
>> jaxrs:
>> component-scan: true
>> - classes-scan-packages:
>> org.apache.cxf.jaxrs.swagger,org.apache.cxf.metrics
>> + classes-scan-packages: org.apache.cxf.metrics
>> eureka:
>> client:
>> @@ -21,7 +21,7 @@ eureka:
>> statusPageUrlPath: /services/helloservice/info
>> healthCheckUrlPath: /system/health
>> metadataMap:
>> - instanceId:
>> ${spring.application.name}:${spring.application.instance_id:${random.value}}
>>
>> + instanceId:
>> ${spring.application.name}:${spring.application.instance_id:${random.value}}
>>
>> servletPath: ${cxf.path}
>> endpoints:
>>
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/