Skip to content

Commit fb519a9

Browse files
committed
Finish 0.2.0
2 parents daee845 + fb0861a commit fb519a9

23 files changed

+400
-220
lines changed

.travis.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
language: java
22
install: true
3-
script: gradle build --continue
3+
jdk:
4+
- oraclejdk8
5+
script: ./gradlew build --continue
6+
before_install:
7+
- chmod u+x gradlew
48
before_deploy:
5-
- gradle generatePomFileForMavenPublication
9+
- ./gradlew generatePomFileForMavenPublication
610
deploy:
711
key:
812
secure: Koqvbo26cGgG5QHR9zSGojtvkVtRMxkd3rTejEyWHXnmjbDAnWVLeJf81pz6Vn2lrHbZkCHx+Ec4t3Cptq+v5fXlrgKtjYUORirMK4KWKT0ZLwE41oFo37Y8YVtRLlUiIk7BIteUbY6+p9HTlcQE60TCo9DugVX6Kn8c5tvBtukjckq3uL2/K+IIhtVbHCL6IEMKlQ0O0Wzvhe2m2qTIhAyCjnHgrTM9TxWYqxU5K0ShpL/OgySzXPcJPxy49jPDjp1FmtiMU/Lu5L7l1pzJ8vfWay7rfwJuu0VOy4cCno+8NFNEz5To08eDSIMsHovyqD7CnWkOOeEp9Vkd+D/Td1m2+7xX4UO1HqPmoTaSi2JrBo6FLDdfW+MWd5QGFsSP66hRSaEVV6AicgC1qreFqQQJKxl7XeLlXBt/HCN3qMhh0mKWggN76gnVV9yQY3n1QmtxLR3xgn8DC4xcAepYiDyUsxibVk1k5q1YHmGTpn2AfkrxhB5Dw97f/T8FrG2iO32NopieiugKh7Ln60TEsgDzsscyVic9OGEhQpCHVBI34jSO+/alh8ui+ULcNpreltJNk+tQAGejvMqDTEcYpAXKcuij2CzlFGchnBXnVnJquXP9i/s0s8k/VxARlrY8zUy2AM2lOq0LjNCEPm1whstv2lM2WmUi8mUwdzCFngI=

README.MD

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Swagger addon for Spring Cloud ZUUL
2-
[![Build Status](https://travis-ci.org/lex-em/zuul-springfox-swagger.svg?branch=develop)](https://travis-ci.org/lex-em/zuul-springfox-swagger)
2+
[![Build Status](https://travis-ci.org/lex-em/zuul-springfox-swagger.svg?branch=develop)](https://travis-ci.org/lex-em/zuul-springfox-swagger)[![Release](https://jitpack.io/v/ru.reliabletech/zuul-springfox-swagger.svg)](https://jitpack.io/#ru.reliabletech/zuul-springfox-swagger)
33

44
## Overview
55

@@ -14,6 +14,7 @@ Repository contains library for using springfox swagger UI under ZUUL proxy
1414
Swagger addon for Spring Cloud ZUUL is open source software released under the [Apache 2.0 license][1].
1515

1616
## Usage
17+
### Configuration
1718
Plugin extends ZUUL configuration:
1819
```yaml
1920
zuul:
@@ -31,32 +32,54 @@ zuul:
3132
swaggerUrl: api-documentation
3233
protocol: https://
3334
```
35+
To turn plugin on just put annotation `@EnableZuulSpringfoxSwagger`:
36+
```java
37+
@Configuration
38+
@EnableZuulSpringfoxSwagger
39+
public class YourConfiguration {
40+
...
41+
}
42+
```
3443

35-
For use it you should include dependency (** SNAPSHOTS DO NOT AVAILABLE AT THIS MOMENT [#1](/../../issues/1)**):
44+
Also plugin needs Swagger2 and RestTemplate (load balanced is preferable) to be configured.
45+
46+
If the project configuration do not contain that, then it will be configured automatically (since version 0.1.1).
47+
48+
Since 0.2.0 version plugin supports versioned api (and other with route transformations via ServiceRouteMapper).
49+
Any `org.springframework.cloud.netflix.zuul.filters.discovery.ServiceRouteMapper` bean will turn on this approach, but here some nuances, described in #3.
50+
### Dependency
3651
```groovy
52+
repositories {
53+
...
54+
jcenter()
55+
// or
56+
maven { url 'https://jitpack.io' }
57+
}
3758
dependencies {
3859
...
3960
compile "ru.reliabletech:zuul-springfox-swagger:${zuulSpringfoxSwaggerVersion}"
4061
...
4162
}
4263
...
4364
```
44-
And add annotation:
45-
```java
46-
@Configuration
47-
@EnableZuulSpringfoxSwagger
48-
public class YourConfiguration {
65+
Also available snapshots in jitpack version notation develop-SNAPSHOT:
66+
```groovy
67+
repositories {
4968
...
69+
maven { url 'https://jitpack.io' }
5070
}
71+
dependencies {
72+
...
73+
compile "ru.reliabletech:zuul-springfox-swagger:develop-SNAPSHOT"
74+
...
75+
}
76+
...
5177
```
52-
Also plugin needs Swagger2 and RestTemplate (load balanced is preferable) to be configured.
53-
54-
If the project configuration do not contain that, then it will be configured automatically (since version 0.1.1).
5578

5679
## Build
5780

5881
Gradle tasks may be running via `gradle` wrapper - `gradlew`(gradle v4.3.1) from project root folder.
5982

6083
* build: `gradle clean build`
6184

62-
[1]: http://www.apache.org/licenses/LICENSE-2.0.html
85+
[1]: http://www.apache.org/licenses/LICENSE-2.0.html

build.gradle

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import java.time.LocalDate
12
import java.time.format.DateTimeFormatter
23

34
buildscript {
@@ -16,60 +17,58 @@ apply plugin: 'maven-publish'
1617

1718
// project properties
1819
group 'ru.reliabletech'
19-
def artifact = 'zuul-springfox-swagger'
20-
version '0.1.1'
20+
def libName = 'zuul-springfox-swagger'
21+
version '0.2.0'
2122
sourceCompatibility = 1.8
23+
def currentDate = LocalDate.now().format(DateTimeFormatter.ISO_DATE)
24+
25+
//tasks
26+
task sourcesJar(type: Jar) {
27+
classifier = 'sources'
28+
from sourceSets.main.allSource
29+
}
30+
31+
artifacts {
32+
archives sourcesJar
33+
}
34+
35+
task expandDescriptor(type: Copy) {
36+
from 'descriptor.json'
37+
into 'build'
38+
expand(version: project.version, date: currentDate)
39+
}
40+
41+
build.dependsOn expandDescriptor
42+
compileJava.dependsOn(processResources)
2243

2344
// plugin settings
2445
publishing {
2546
publications {
2647
maven(MavenPublication) {
2748
from components.java
49+
artifact sourcesJar
2850
groupId project.group
29-
artifactId artifact
51+
artifactId libName
3052
version project.version
31-
}
32-
}
33-
}
3453

35-
model {
36-
tasks.generatePomFileForMavenPublication {
37-
destination = file("$buildDir/libs/$artifact-${version}.pom")
54+
}
3855
}
3956
}
4057

4158
jar {
4259
manifest {
4360
attributes(
4461
"Group": group,
45-
"Artifact-Id": artifact,
62+
"Artifact-Id": libName,
4663
"Version": version,
4764
"Source-Compatibility": sourceCompatibility,
48-
"Build-Time": new Date()
65+
"Build-Time": currentDate
4966
)
5067
}
5168
}
5269

53-
//tasks
54-
task sourcesJar(type: Jar) {
55-
classifier = 'sources'
56-
from sourceSets.main.allSource
57-
}
58-
59-
artifacts {
60-
archives sourcesJar
61-
}
62-
63-
task expandDescriptor(type: Copy) {
64-
from 'descriptor.json'
65-
into 'build'
66-
expand(version: project.version, date: java.time.LocalDate.now().format(DateTimeFormatter.ISO_DATE))
67-
}
68-
69-
build.dependsOn expandDescriptor
70-
7170
//dependency management
72-
def springCloudVersion = 'Dalston.SR3'
71+
def springCloudVersion = 'Finchley.SR1'
7372

7473
dependencyManagement {
7574
imports {
@@ -82,12 +81,11 @@ repositories {
8281
}
8382

8483
dependencies {
85-
compile 'org.springframework.cloud:spring-cloud-starter-eureka'
86-
compile 'org.springframework.cloud:spring-cloud-starter-zuul'
87-
compile 'org.projectlombok:lombok:1.16.18'
88-
compile 'io.springfox:springfox-swagger2:2.7.0'
84+
compileOnly 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-server'
85+
compileOnly 'org.springframework.cloud:spring-cloud-starter-netflix-zuul'
86+
annotationProcessor 'org.projectlombok:lombok:1.18.4'
87+
implementation 'org.projectlombok:lombok:1.18.4'
88+
compile 'io.springfox:springfox-swagger2:2.9.2'
8989
compile 'io.springfox.ui:springfox-swagger-ui-rfc6570:1.0.0'
90-
}
91-
task wrapper(type: Wrapper) {
92-
gradleVersion = '4.3.1'
90+
compileOnly 'org.springframework.boot:spring-boot-configuration-processor:1.5.9.RELEASE'
9391
}

descriptor.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"gpgSign": false
2323
},
2424
"files":[
25-
{"includePattern": "build/libs/(.*)", "uploadPattern": "ru/reliabletech/zuul-springfox-swagger/${version}/\$1"}
25+
{"includePattern": "build/libs/(.*)", "uploadPattern": "ru/reliabletech/zuul-springfox-swagger/${version}/\$1"},
26+
{"includePattern": "build/publications/maven/pom-default.xml", "uploadPattern": "ru/reliabletech/zuul-springfox-swagger/${version}/pom-${version}.xml"}
2627
],
2728
"publish": true
2829
}

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3.1-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1-bin.zip

jitpack.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
env:
2+
GROUP: "ru.reliabletech"

src/main/java/ru/reliabletech/zuul/swagger/EnableZuulSpringfoxSwagger.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22

33
import org.springframework.context.annotation.Import;
44

5-
import java.lang.annotation.ElementType;
6-
import java.lang.annotation.Inherited;
7-
import java.lang.annotation.Retention;
8-
import java.lang.annotation.RetentionPolicy;
9-
import java.lang.annotation.Target;
5+
import java.lang.annotation.*;
106

117
/**
8+
* Enabling ZuulSpringfoxSwaggerPlugin annotation.
9+
*
1210
* @author Alexandr Emelyanov <[email protected]>
1311
* on 27.11.2017.
1412
*/

src/main/java/ru/reliabletech/zuul/swagger/GenericSwaggerService.java

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/main/java/ru/reliabletech/zuul/swagger/ServiceInfo.java

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/main/java/ru/reliabletech/zuul/swagger/SwaggerService.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/main/java/ru/reliabletech/zuul/swagger/ZuulSpringfoxSwaggerConfiguration.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
11
package ru.reliabletech.zuul.swagger;
22

3+
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
34
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
45
import org.springframework.boot.context.properties.EnableConfigurationProperties;
56
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
7+
import org.springframework.cloud.netflix.zuul.filters.discovery.ServiceRouteMapper;
68
import org.springframework.context.annotation.Bean;
79
import org.springframework.context.annotation.ComponentScan;
10+
import org.springframework.context.annotation.Configuration;
811
import org.springframework.web.client.RestTemplate;
12+
import ru.reliabletech.zuul.swagger.props.ServicesSwaggerInfo;
13+
import ru.reliabletech.zuul.swagger.service.GenericRouteService;
14+
import ru.reliabletech.zuul.swagger.service.RouteService;
15+
import ru.reliabletech.zuul.swagger.service.ServiceRouteMapperRouteService;
916
import springfox.documentation.spring.web.plugins.Docket;
1017
import springfox.documentation.swagger2.annotations.EnableSwagger2;
1118

1219
/**
20+
* Main configuration for ZuulSpringfoxPlugin
21+
*
1322
* @author Alexandr Emelyanov <[email protected]>
1423
* on 27.11.2017.
1524
*/
25+
@Configuration
1626
@ComponentScan(basePackageClasses = ZuulSpringfoxSwaggerConfiguration.class)
1727
@EnableConfigurationProperties(ServicesSwaggerInfo.class)
1828
public class ZuulSpringfoxSwaggerConfiguration {
@@ -28,4 +38,25 @@ public RestTemplate restTemplate() {
2838
return new RestTemplate();
2939
}
3040

41+
/**
42+
* Configure automatically {@link ServiceRouteMapper } based {@link RouteService }
43+
*
44+
* @return
45+
*/
46+
@Bean
47+
@ConditionalOnBean(ServiceRouteMapper.class)
48+
public RouteService versionedRouteService() {
49+
return new ServiceRouteMapperRouteService();
50+
}
51+
52+
/**
53+
* Default {@link RouteService}
54+
*
55+
* @return
56+
*/
57+
@Bean
58+
@ConditionalOnMissingBean(RouteService.class)
59+
public RouteService genericRouteService() {
60+
return new GenericRouteService();
61+
}
3162
}

0 commit comments

Comments
 (0)