Skip to content

Commit

Permalink
Moved the petstore docket configuration to its own module
Browse files Browse the repository at this point in the history
Demonstrates that the issue 1890 is not reproducable.

fixes springfox#1890
  • Loading branch information
dilipkrish committed Dec 5, 2017
1 parent cb9690d commit 6d1bfd7
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 20 deletions.
5 changes: 4 additions & 1 deletion springfox-petstore/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@ dependencies {
compile libs.spring
compile libs.springProvided
compile libs.swagger2Core
compile "com.google.guava:guava:${guava}"
compile libs.core
compile project(':springfox-spi')
compile project(':springfox-core')
compile project(':springfox-spring-web')
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
*
* Copyright 2017-2018 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.petstore;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.service.SecurityScheme;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.List;

import static com.google.common.base.Predicates.*;
import static com.google.common.collect.Sets.*;
import static springfox.documentation.builders.PathSelectors.*;

@Configuration
public class PetStoreConfiguration {

@Bean
Docket petstore(List<SecurityScheme> authorizationTypes) {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("petstore")
.useDefaultResponseMessages(false)
.securitySchemes(authorizationTypes)
.produces(newHashSet("application/xml", "application/json"))
.select()
.paths(or(
and(
regex("/api/.*"),
not(regex("/api/store/search.*"))),
regex("/generic/.*")))
.build()
.host("petstore.swagger.io")
.protocols(newHashSet("http", "https"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import springfox.documentation.spring.data.rest.configuration.SpringDataRestConf
import springfox.documentation.spring.web.dummy.controllers.BugsController
import springfox.documentation.spring.web.plugins.Docket
import springfox.documentation.swagger2.annotations.EnableSwagger2
import springfox.petstore.PetStoreConfiguration
import springfox.test.contract.swagger.Bug1767ListingScanner

import java.nio.ByteBuffer
Expand All @@ -44,30 +45,12 @@ import static springfox.documentation.schema.AlternateTypeRules.*
@Configuration
@EnableSwagger2
@EnableHypermediaSupport(type = EnableHypermediaSupport.HypermediaType.HAL)
@Import(SpringDataRestConfiguration)
@Import([SpringDataRestConfiguration, PetStoreConfiguration])
class Swagger2TestConfig {

@Autowired
private TypeResolver resolver

@Bean
Docket petstore(List<SecurityScheme> authorizationTypes) {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("petstore")
.useDefaultResponseMessages(false)
.securitySchemes(authorizationTypes)
.produces(['application/xml', 'application/json'] as Set)
.select()
.paths(or(
and(
regex("/api/.*"),
not(regex("/api/store/search.*"))),
regex("/generic/.*")))
.build()
.host("petstore.swagger.io")
.protocols(['http', 'https'] as Set)
}

@Bean
Docket petstoreWithUriTemplating(List<SecurityScheme> authorizationTypes) {
return new Docket(DocumentationType.SWAGGER_2)
Expand Down

0 comments on commit 6d1bfd7

Please sign in to comment.