Skip to content

Commit

Permalink
pulling latest master (#1)
Browse files Browse the repository at this point in the history
* Create a FormParameter model object instead of BodyParameter for fields that are part of a multipart form (in=formData).

* Adapted behavior of ParameterMapper and added tests.

* Fix contract tests.

* Reduce diff from master contract files.

* Bump mixin-deep from 1.3.1 to 1.3.2 in /springfox-swagger-ui/src/web

Bumps [mixin-deep](https://github.com/jonschlinkert/mixin-deep) from 1.3.1 to 1.3.2.
- [Release notes](https://github.com/jonschlinkert/mixin-deep/releases)
- [Commits](jonschlinkert/mixin-deep@1.3.1...1.3.2)

Signed-off-by: dependabot[bot] <support@github.com>

* [fix issue 3118] discriminator not set to discriminator from model

* fix discriminator usage in test templates

* springfox#182

Fix sort ordering.

* springfox#182

Fix checkstyle.

* springfox#182

Fix resource listing.

* springfox#182

Fix Webflux tests.

* Bump swagger-ui depdency

Security fix detailed in swagger-ui's release notes.
https://github.com/swagger-api/swagger-ui/releases/tag/v3.23.11

* Set the basePath using the request context path if present

This allows the X-Forwarded-Prefix header to work correctly

* Updated spring dependencies to spring 5.2.0 and spring boot 2.2.0, fixed changed interfaces

* Added documentationType in DocPluginManager tests

* Fixed typo (springfox#3161)

* springfox#2932 - Removed trailing space

* springfox#2932 - Spring HATEOAS 1.0.0.RELEASE

* springfox#2932 - Spring Data REST 3.2.0.RELEASE

* springfox#2932 - fix hateos collectionModel rule

* Fixed checkstyle issues in ParameterMapper.java

Signed-off-by: Martin Kremers <info@martinkremers.de>

* More test cases for parameter Mapper spec

Signed-off-by: Martin Kremers <info@martinkremers.de>

* fix for issue springfox#3178

replace  new FileInputStream(resource.getFile()) with springfox#3178

* reéoved unused import

* added test for coverage

* springfox#3189 - handle defaults in Spring placeholders

* springfox#3189 - return default value if property not found in environment

* springfox#2932: Fixed import for model test.

* springfox#2932: Minor version upgrades of spring dependencies. Aligned contract tests with Spring HATEOAS 1.x. Fixed wrong client encoding used in tests.

* jackson 2.10.1

* Bump handlebars from 4.1.2 to 4.5.3 in /springfox-swagger-ui/src/web

Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.1.2 to 4.5.3.
- [Release notes](https://github.com/wycats/handlebars.js/releases)
- [Changelog](https://github.com/wycats/handlebars.js/blob/master/release-notes.md)
- [Commits](handlebars-lang/handlebars.js@v4.1.2...v4.5.3)

Signed-off-by: dependabot[bot] <support@github.com>

* Update test to pass when running on Windows.

* Upgrade to version of swagger which fixes css injection vulnerability as defined in https://github.com/tarantula-team/CSS-injection-in-Swagger-UI

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Stefan Bissell <26431980+weaselflink@users.noreply.github.com>
Co-authored-by: Maksim Orlov <maksim.orlov@yahoo.fr>
Co-authored-by: Steven Locke <StevenLocke@users.noreply.github.com>
Co-authored-by: Jerry Collings <jcollings@ancestry.com>
Co-authored-by: JoGir <JoGir@users.noreply.github.com>
Co-authored-by: Andree Wormuth <wormuth@users.noreply.github.com>
Co-authored-by: Martin Kremers <info@martinkremers.de>
Co-authored-by: Olivier Gérardin <ogerardin@yahoo.com>
Co-authored-by: Andreas Kluth <AndreasKl@users.noreply.github.com>
Co-authored-by: sullis <github@seansullivan.com>
Co-authored-by: Dilip Krishnan <dilipkrish@users.noreply.github.com>
  • Loading branch information
13 people committed Jan 23, 2020
1 parent fb478cf commit b09f7cf
Show file tree
Hide file tree
Showing 55 changed files with 1,241 additions and 1,096 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class BuildInfoFactory {
def isReleaseBuild = project.gradle.startParameter.taskNames.contains("release")

SemanticVersion buildVersion = versioningStrategy.buildVersion(releaseType, isReleaseBuild)
project.logger.lifecycle("[RELEASE] current verison: ${versioningStrategy.current(project)}, " +
project.logger.lifecycle("[RELEASE] current version: ${versioningStrategy.current(project)}, " +
"build version: $buildVersion, dryRun: $dryRun, releaseBuild: $isReleaseBuild")
new BuildInfo(
versioningStrategy.current(project),
Expand Down
16 changes: 8 additions & 8 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ ext {
classGraph = "4.1.7"
equalsverifierVersion = '3.1.5'
groovy = "2.5.4"
jacocoVersion = '0.8.1'
jackson = '2.9.8'
jacocoVersion = '0.8.5'
jackson = '2.10.1'
joda = "2.10.1"
jsonPath = "2.4.0"
jsonAssert = "1.5.0"
Expand All @@ -18,13 +18,13 @@ ext {
slf4j = "1.7.25"
snakeyaml = '1.23'
spock = "1.3-RC1-groovy-2.5"
spring = "5.1.5.RELEASE"
springIntegration = "5.1.3.RELEASE"
springHateoas = "0.25.1.RELEASE"
springDataRest = "3.1.5.RELEASE"
springPluginVersion = "1.2.0.RELEASE"
spring = "5.2.2.RELEASE"
springIntegration = "5.2.2.RELEASE"
springHateoas = "1.0.2.RELEASE"
springDataRest = "3.2.3.RELEASE"
springPluginVersion = "2.0.0.RELEASE"
swagger2Core = "1.5.20"
springBoot = "2.1.3.RELEASE"
springBoot = "2.2.2.RELEASE"
springfoxRfc6570Version = "1.0.0"
undercouch = "3.4.3"
validationApiVersion = '2.0.1.Final'
Expand Down
1 change: 1 addition & 0 deletions springfox-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ dependencies {

testCompile libs.test
testCompile libs.clientProvidedServlet
testCompile libs.springProvidedWithMvc
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public ModelBuilder(Model model) {
this.qualifiedType = model.getQualifiedType();
this.description = model.getDescription();
this.baseModel = model.getBaseModel();
this.discriminator = model.getDescription();
this.discriminator = model.getDiscriminator();
this.modelType = model.getType();
this.example = model.getExample();
this.xml = model.getXml();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class ActionSpecification {
private final List<ResolvedMethodParameter> parameters;
private final ResolvedType returnType;
private final HandlerMethod handlerMethod;
private final Class<?> entityType;
private final String name;
private final String path;

Expand All @@ -50,6 +51,7 @@ class ActionSpecification {
Set<MediaType> produces,
Set<MediaType> consumes,
HandlerMethod handlerMethod,
Class<?> entityType,
List<ResolvedMethodParameter> parameters,
ResolvedType returnType) {
this.name = name;
Expand All @@ -60,6 +62,7 @@ class ActionSpecification {
this.parameters = parameters;
this.returnType = returnType;
this.handlerMethod = handlerMethod;
this.entityType = entityType;
}

public String getName() {
Expand Down Expand Up @@ -95,12 +98,12 @@ public Optional<HandlerMethod> getHandlerMethod() {
}

public Optional<Class<?>> getDeclaringClass() {
return getHandlerMethod().map(input -> {
return Optional.ofNullable(getHandlerMethod().map(input -> {
Object bean = new OptionalDeferencer<>().convert(handlerMethod.getBean());
if (AopUtils.isAopProxy(bean)) {
return AopUtils.getTargetClass(bean);
}
return (Class<?>) bean;
});
}).orElse(entityType));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.data.mapping.PersistentEntity;
import org.springframework.data.mapping.PersistentProperty;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.Resources;
import org.springframework.hateoas.EntityModel;
import org.springframework.hateoas.CollectionModel;
import org.springframework.web.method.HandlerMethod;

import java.lang.annotation.Annotation;
Expand Down Expand Up @@ -95,26 +95,26 @@ static String propertyIdentifierName(PersistentProperty<?> property) {

static ResolvedType propertyResponse(PersistentProperty<?> property, TypeResolver resolver) {
if (property.isCollectionLike()) {
return resolver.resolve(Resources.class, property.getComponentType());
return resolver.resolve(CollectionModel.class, property.getComponentType());
} else if (property.isMap()) {
return resolver.resolve(
Resource.class,
EntityModel.class,
resolver.resolve(
Map.class,
String.class,
property.getMapValueType()));
}
return resolver.resolve(Resource.class, property.getType());
return resolver.resolve(EntityModel.class, property.getType());
}

static ResolvedType propertyItemResponse(PersistentProperty<?> property, TypeResolver resolver) {
if (property.isCollectionLike()) {
return resolver.resolve(Resource.class, property.getComponentType());
return resolver.resolve(EntityModel.class, property.getComponentType());
} else if (property.isMap()) {
return resolver.resolve(
Resource.class,
EntityModel.class,
property.getMapValueType());
}
return resolver.resolve(Resource.class, property.getType());
return resolver.resolve(EntityModel.class, property.getType());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import org.springframework.data.repository.core.RepositoryMetadata;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.Resources;
import org.springframework.hateoas.EntityModel;
import org.springframework.hateoas.CollectionModel;
import org.springframework.http.MediaType;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMethod;
Expand Down Expand Up @@ -196,6 +196,7 @@ Optional<ActionSpecification> build() {
getProduces(),
getConsumes(),
null,
getType(),
getParameters(),
returnType(resolver))
);
Expand All @@ -210,6 +211,10 @@ private String actionName(
upperCamelCaseName(property.getName()));
}

private Class<?> getType() {
return context.getEntityContext().entity().get().getType();
}

private ResolvedType returnType(TypeResolver resolver) {
return getSupportedMethods().contains(DELETE)
? resolver.resolve(Void.TYPE)
Expand Down Expand Up @@ -305,6 +310,7 @@ Optional<ActionSpecification> build() {
getProduces(),
getConsumes(),
handlerMethod,
getType(),
inputParameters(),
inferReturnType(context, handlerMethod))
);
Expand All @@ -324,17 +330,17 @@ private ResolvedType inferReturnType(
methodResolver.methodReturnType(handler);

if (isContainerType(methodReturnType)) {
return resolver.resolve(Resources.class,
return resolver.resolve(CollectionModel.class,
collectionElementType(methodReturnType));
} else if (Iterable.class.isAssignableFrom(methodReturnType.getErasedType())) {
return resolver.resolve(Resources.class, domainReturnType);
return resolver.resolve(CollectionModel.class, domainReturnType);
} else if (Types.isBaseType(domainReturnType)) {
return domainReturnType;
} else if (Types.isVoid(domainReturnType)) {
return resolver.resolve(Void.TYPE);
}

return resolver.resolve(Resource.class, domainReturnType);
return resolver.resolve(EntityModel.class, domainReturnType);
}

private List<ResolvedMethodParameter> transferResolvedMethodParameterList(
Expand All @@ -349,6 +355,10 @@ private List<ResolvedMethodParameter> transferResolvedMethodParameterList(
.collect(Collectors.toList());
}

private Class<?> getType() {
return context.entity().get().getType();
}

private List<ResolvedMethodParameter> inputParameters() {
return !getParameters().isEmpty()
? getParameters()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

import com.fasterxml.classmate.ResolvedType;
import com.fasterxml.classmate.TypeResolver;
import org.springframework.hateoas.RelProvider;
import org.springframework.hateoas.Resources;
import org.springframework.hateoas.CollectionModel;
import org.springframework.hateoas.server.LinkRelationProvider;
import springfox.documentation.builders.ModelPropertyBuilder;
import springfox.documentation.schema.Model;
import springfox.documentation.schema.ModelProperty;
Expand All @@ -43,13 +43,13 @@
class EmbeddedCollectionModelProvider implements SyntheticModelProviderPlugin {

private final TypeResolver resolver;
private final RelProvider relProvider;
private final LinkRelationProvider relProvider;
private final TypeNameExtractor typeNameExtractor;
private final EnumTypeDeterminer enumTypeDeterminer;

EmbeddedCollectionModelProvider(
TypeResolver resolver,
RelProvider relProvider,
LinkRelationProvider relProvider,
TypeNameExtractor typeNameExtractor,
EnumTypeDeterminer enumTypeDeterminer) {
this.resolver = resolver;
Expand Down Expand Up @@ -86,9 +86,9 @@ public List<ModelProperty> properties(ModelContext context) {
Class<?> type = typeParameters.get(0).getErasedType();
return singletonList(
new ModelPropertyBuilder()
.name(relProvider.getCollectionResourceRelFor(type))
.name(relProvider.getCollectionResourceRelFor(type).value())
.type(resolver.resolve(List.class, type))
.qualifiedType(Resources.class.getName())
.qualifiedType(CollectionModel.class.getName())
.position(0)
.required(true)
.isHidden(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

import com.fasterxml.classmate.ResolvedType;
import com.fasterxml.classmate.TypeResolver;
import org.springframework.hateoas.CollectionModel;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.Resources;
import springfox.documentation.builders.ModelPropertyBuilder;
import springfox.documentation.schema.Model;
import springfox.documentation.schema.ModelProperty;
Expand Down Expand Up @@ -139,7 +139,7 @@ public Set<ResolvedType> dependencies(ModelContext context) {

@Override
public boolean supports(ModelContext delimiter) {
return Resources.class.equals(resourceType(delimiter.getType()).getErasedType())
return CollectionModel.class.equals(resourceType(delimiter.getType()).getErasedType())
&& delimiter.getDocumentationType() == DocumentationType.SWAGGER_2;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.hateoas.RelProvider;
import org.springframework.hateoas.server.LinkRelationProvider;
import springfox.documentation.schema.TypeNameExtractor;
import springfox.documentation.spi.schema.EnumTypeDeterminer;

Expand All @@ -41,7 +41,7 @@ public ResourcesModelProvider resourcesModelProvider(
public EmbeddedCollectionModelProvider embeddedCollectionProvider(
TypeResolver resolver,
@Qualifier("_relProvider")
RelProvider relProvider,
LinkRelationProvider relProvider,
TypeNameExtractor typeNameExtractor,
EnumTypeDeterminer enumTypeDeterminer) {
return new EmbeddedCollectionModelProvider(resolver, relProvider, typeNameExtractor, enumTypeDeterminer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ private String modelName(
if (!isMapType(asResolved(context.getType())) && knownNames.containsKey(context.getTypeId())) {
return knownNames.get(context.getTypeId());
}
TypeNameProviderPlugin selected = typeNameProviders.getPluginFor(
TypeNameProviderPlugin selected = typeNameProviders.getPluginOrDefaultFor(
context.getDocumentationType(),
new DefaultTypeNameProvider());
String modelName = selected.nameFor(((ResolvedType) context.getType()).getErasedType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@
import java.util.Optional;
import java.util.Set;

import static java.util.Optional.*;

@Component
public class SchemaPluginsManager {
private final PluginRegistry<ModelPropertyBuilderPlugin, DocumentationType> propertyEnrichers;
private final PluginRegistry<ModelBuilderPlugin, DocumentationType> modelEnrichers;
private final PluginRegistry<ViewProviderPlugin, DocumentationType> viewProviders;
private final PluginRegistry<SyntheticModelProviderPlugin, ModelContext> syntheticModelProviders;
private final PluginRegistry<SyntheticModelProviderPlugin, ModelContext> syntheticModelProviders;

@Autowired
public SchemaPluginsManager(
Expand Down Expand Up @@ -80,27 +78,21 @@ public Model model(ModelContext context) {
}

public ViewProviderPlugin viewProvider(DocumentationType documentationType) {
return viewProviders.getPluginFor(documentationType);
return viewProviders.getPluginFor(documentationType)
.orElseThrow(() -> new IllegalStateException("No ViewProviderPlugin for " + documentationType.getName()));
}

public Optional<Model> syntheticModel(ModelContext context) {
if (syntheticModelProviders.hasPluginFor(context)) {
return of(syntheticModelProviders.getPluginFor(context).create(context));
}
return empty();
return syntheticModelProviders.getPluginFor(context).map(plugin -> plugin.create(context));
}

public List<ModelProperty> syntheticProperties(ModelContext context) {
if (syntheticModelProviders.hasPluginFor(context)) {
return syntheticModelProviders.getPluginFor(context).properties(context);
}
return new ArrayList<ModelProperty>();
return syntheticModelProviders.getPluginFor(context).map(plugin -> plugin.properties(context))
.orElseGet(ArrayList::new);
}

public Set<ResolvedType> dependencies(ModelContext context) {
if (syntheticModelProviders.hasPluginFor(context)) {
return syntheticModelProviders.getPluginFor(context).dependencies(context);
}
return new HashSet<ResolvedType>();
return syntheticModelProviders.getPluginFor(context).map(plugin -> plugin.dependencies(context))
.orElseGet(HashSet::new);
}
}

0 comments on commit b09f7cf

Please sign in to comment.