Skip to content

Commit

Permalink
feature(webflux): add webflux project
Browse files Browse the repository at this point in the history
there is the first usable version of webflux project.
there are a error while building swagger-ui webjar. the jar is empty.
We must use old webjar before fix.
  • Loading branch information
Thomas Deblock committed Jan 23, 2018
1 parent e945224 commit d5867d2
Show file tree
Hide file tree
Showing 143 changed files with 1,339 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.9.0-SNAPSHOT
2.9.1-SNAPSHOT
20 changes: 18 additions & 2 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ext {
slf4j = "1.7.24"
snakeyaml = '1.19'
spock = "1.1-groovy-2.4"
spring = "4.3.9.RELEASE"
spring = "5.0.2.RELEASE"
springHateoas = "0.24.0.RELEASE"
springDataRest = "2.6.9.RELEASE"
springPluginVersion = "1.2.0.RELEASE"
Expand Down Expand Up @@ -54,22 +54,38 @@ ext {
"org.springframework.plugin:spring-plugin-metadata:${springPluginVersion}",
],
springProvided: [
"org.springframework:spring-core:$spring",
"org.springframework:spring-web:$spring",
"org.springframework:spring-context:$spring",
],
springProvidedWithMvc: [
"org.springframework:spring-core:$spring",
"org.springframework:spring-web:$spring",
"org.springframework:spring-webmvc:$spring",
"org.springframework:spring-context:$spring",
],
springProvidedWithFlux: [
"org.springframework:spring-core:$spring",
"org.springframework:spring-web:$spring",
"org.springframework:spring-webflux:$spring",
"org.springframework:spring-context:$spring",
],
springProvidedNew: [
"org.springframework:spring-core:$spring",
"org.springframework:spring-web:$spring",
"org.springframework:spring-context:$spring",
],
clientProvided: [
"javax.servlet:javax.servlet-api:$servlet",
"com.fasterxml.jackson.core:jackson-core:${jackson}",
"com.fasterxml.jackson.core:jackson-databind:${jackson}",
"joda-time:joda-time:$joda"
],
clientProvidedServlet: [
"com.fasterxml.jackson.core:jackson-core:${jackson}",
"com.fasterxml.jackson.core:jackson-databind:${jackson}",
"joda-time:joda-time:$joda",
"javax.servlet:javax.servlet-api:$servlet",
],
core : [
"com.google.guava:guava:${guava}",
"com.fasterxml:classmate:${classmate}",
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Jan 14 11:40:26 CST 2018
#Mon Jan 22 15:52:00 CET 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ include 'springfox-core'
include 'springfox-spi'
include 'springfox-schema'
include 'springfox-spring-web'
include 'springfox-spring-webmvc'
include 'springfox-spring-webflux'
include 'springfox-swagger-common'
include 'springfox-swagger1'
include 'springfox-swagger2'
Expand Down
4 changes: 2 additions & 2 deletions springfox-data-rest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ dependencies {
compile libs.core
compile libs.spring
compile project(':springfox-spi')
compile project(':springfox-spring-web')
compile project(':springfox-spring-webmvc')

compile "org.springframework.data:spring-data-rest-webmvc:$springDataRest"
compile "org.springframework.hateoas:spring-hateoas:${springHateoas}"

provided libs.springProvided
provided libs.springProvidedWithMvc

testCompile project(':springfox-core')
testCompile libs.test
Expand Down
2 changes: 2 additions & 0 deletions springfox-spi/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
dependencies {
compile project(':springfox-core')

provided libs.clientProvidedServlet
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,32 @@ private void initExcludeAnnotations() {

private void initIgnorableTypes() {
ignored = newHashSet();
ignored.add(ServletRequest.class);
ignored.add(Class.class);
ignored.add(Void.class);
ignored.add(Void.TYPE);
ignored.add(HttpHeaders.class);
ignored.add(ServletResponse.class);
ignored.add(HttpServletRequest.class);
ignored.add(HttpServletResponse.class);
ignored.add(HttpHeaders.class);
ignored.add(BindingResult.class);
ignored.add(ServletContext.class);
ignored.add(UriComponentsBuilder.class);
ignored.add(ApiIgnore.class); //Used to ignore parameters

boolean exists = true;

try {
Class.forName("javax.servlet.ServletContext", false, this.getClass().getClassLoader());
} catch (ClassNotFoundException e) {
exists = false;
}

if (exists) {
ignored.add(ServletRequest.class);
ignored.add(ServletResponse.class);
ignored.add(HttpServletRequest.class);
ignored.add(HttpServletResponse.class);
ignored.add(ServletContext.class);
}


}

private void initResponseMessages() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
import springfox.documentation.swagger.web.TagsSorter;
import springfox.documentation.swagger.web.UiConfiguration;
import springfox.documentation.swagger.web.UiConfigurationBuilder;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
import springfox.petstore.controller.PetController;

import java.util.List;
Expand All @@ -60,7 +60,7 @@
import static springfox.documentation.schema.AlternateTypeRules.*;

@SpringBootApplication
@EnableSwagger2//<1>
@EnableSwagger2WebMvc//<1>
@ComponentScan(basePackageClasses = {
PetController.class
})//<2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private DocumentationPlugin defaultDocumentationPlugin() {

public DocumentationContextBuilder createContextBuilder(
DocumentationType documentationType,
DefaultConfiguration defaultConfiguration) {
DefaultsProviderPlugin defaultConfiguration) {
return defaultsProviders.getPluginFor(documentationType, defaultConfiguration)
.create(documentationType)
.withResourceGroupingStrategy(resourceGroupingStrategy(documentationType));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.google.common.collect.Sets;
import springfox.documentation.RequestHandler;
import springfox.documentation.service.ResolvedMethodParameter;
import springfox.documentation.spring.web.PatternsRequestConditionWrapper;

import java.util.List;
import java.util.Set;
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
30 changes: 30 additions & 0 deletions springfox-spring-webflux/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
ext {
limits = [
'instruction': 96.5,
'branch' : 91,
'line' : 96.5,
'complexity' : 92,
'method' : 96,
'class' : 100
]
}

dependencies {
compile "org.reflections:reflections:$reflections"
compile libs.core
compile libs.spring
compile project(':springfox-spi')
compile project(':springfox-schema').sourceSets.main.output
compile project(':springfox-spring-web')

provided libs.springProvidedWithFlux
provided libs.clientProvidedServlet

testCompile "javax.validation:validation-api:$validationApiVersion"
testCompile project(':springfox-core')
testCompile project(':springfox-spring-web').sourceSets.test.output
testCompile libs.test
testCompile libs.swagger2Core
testCompile project(':springfox-core').sourceSets.test.output
testCompile project(':springfox-schema').sourceSets.test.output
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package springfox.documentation.spring.web;

import springfox.documentation.springWrapper.NameValueExpression;

import java.util.HashSet;
import java.util.Set;

public class NameValueExpressionWrapper<T> implements NameValueExpression {
private org.springframework.web.reactive.result.condition.NameValueExpression<T> e;

public static <T> Set<NameValueExpression<T>> from(Set<org.springframework.web.reactive.result.condition.NameValueExpression<T>> springSet) {
Set<NameValueExpression<T>> wrapped = new HashSet<NameValueExpression<T>>();

for (org.springframework.web.reactive.result.condition.NameValueExpression e: springSet) {
wrapped.add(new NameValueExpressionWrapper<T>(e));
}

return wrapped;
}

public NameValueExpressionWrapper(org.springframework.web.reactive.result.condition.NameValueExpression<T> e) {
this.e = e;
}

@Override
public String getName() {
return this.e.getName();
}

@Override
public Object getValue() {
return this.e.getValue();
}

@Override
public boolean isNegated() {
return this.e.isNegated();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
*
* Copyright 2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/

package springfox.documentation.spring.web;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.http.codec.json.Jackson2JsonEncoder;
import springfox.documentation.schema.configuration.ObjectMapperConfigured;


public class ObjectMapperConfigurer implements BeanPostProcessor, ApplicationEventPublisherAware {

private ApplicationEventPublisher applicationEventPublisher;

@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof Jackson2JsonEncoder) {
Jackson2JsonEncoder encoder = (Jackson2JsonEncoder) bean;
fireObjectMapperConfiguredEvent(encoder.getObjectMapper());
}
return bean;
}

@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
return bean;
}

@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.applicationEventPublisher = applicationEventPublisher;
}

private void fireObjectMapperConfiguredEvent(ObjectMapper objectMapper) {
applicationEventPublisher.publishEvent(new ObjectMapperConfigured(this, objectMapper));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package springfox.documentation.spring.web;

import org.springframework.web.util.pattern.PathPattern;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class PatternUtil {

public static Set<String> toListString(Set<PathPattern> patterns) {
Set<String> paths = new HashSet<String>();
for (PathPattern p: patterns) {
paths.add(p.getPatternString());
}
return paths;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package springfox.documentation.spring.web;

import org.springframework.web.reactive.result.condition.PatternsRequestCondition;
import org.springframework.web.util.pattern.PathPattern;

import java.util.HashSet;
import java.util.Set;

public class PatternsRequestConditionWrapper implements springfox.documentation.springWrapper.PatternsRequestCondition<PatternsRequestCondition> {

private org.springframework.web.reactive.result.condition.PatternsRequestCondition condition;

public PatternsRequestConditionWrapper(org.springframework.web.reactive.result.condition.PatternsRequestCondition condition) {
this.condition = condition;
}

@Override
public springfox.documentation.springWrapper.PatternsRequestCondition combine(springfox.documentation.springWrapper.PatternsRequestCondition<PatternsRequestCondition> other) {
if (other instanceof PatternsRequestConditionWrapper) {
return new PatternsRequestConditionWrapper(this.condition.combine(((PatternsRequestConditionWrapper) other).condition));
}
return this;
}

@Override
public Set<String> getPatterns() {
return PatternUtil.toListString(this.condition.getPatterns());
}


@Override
public boolean equals(Object o) {
if (o instanceof PatternsRequestConditionWrapper) {
return this.condition.equals(((PatternsRequestConditionWrapper) o).condition);
}
return false;
}

@Override
public int hashCode() {
return this.condition.hashCode();
}



}

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package springfox.documentation.spring.web;

import org.springframework.web.reactive.result.method.RequestMappingInfo;

public class RequestMappingInfoWrapper implements springfox.documentation.springWrapper.RequestMappingInfo {

public RequestMappingInfoWrapper(RequestMappingInfo info) {
}
}
Loading

0 comments on commit d5867d2

Please sign in to comment.