-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong behaviour when using mime type api versioning #965
Labels
Milestone
Comments
Couple of things
@Bean
public Docket arqV1Api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
// create a Predicate<RequestHandler> predicate that fill detect presence of a media type support in
// RequestHandler.getRequestMapping().getProducesCondition() in this case we want apis that DO NOT
// support v2 media types
.apis(not(withMediaType("application/vnd.arch.service.v2+json")))
.paths(PathSelectors.regex("/api/architecture/.*"))
.build()
.apiInfo(new ApiInfo("Architecture Rest Api","Architecture REST Services","v1","","","",""))
.produces(new HashSet<String>(Arrays.asList(new String[{"application/vnd.arch.mail.v1+json"})))
.securitySchemes(newArrayList(apiKey()))
.securityContexts(newArrayList(securityContext()))
.groupName("Arq v1 group");
}
@Bean
public Docket arqV2Api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
// create a Predicate<RequestHandler> predicate that fill detect presence of a media type support in
// RequestHandler.getRequestMapping().getProducesCondition() in this case we want apis that DO NOT
// support v1 media types
.apis(not(withMediaType("application/vnd.arch.service.v1+json")))
.paths(PathSelectors.regex("/api/architecture/.*"))
.build()
.apiInfo(new ApiInfo("Architecture Rest Api","Architecture REST Services","v2","","","",""))
.produces(new HashSet<String>(Arrays.asList(new String[]{"application/vnd.arch.service.v2+json"})))
.securitySchemes(newArrayList(apiKey()))
.securityContexts(newArrayList(securityContext()))
.groupName("Arq v2 group");
} |
@dilipkrish thanks for clearing it up! In case someone needs it, this is how I implemented it: Helper static methods:
Docket definitions:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We are starting with our REST API versioning and after having read a lot about the different options (URI versioning, mime type versioning) have decided to use the latter approach.
We were expecting that Springfox generates the following doc:
v1:
v2:
However, in the v2 I also get this:
get /api/architecture/services - application/vnd.arch.service.v1+json
It shouldn't be there since I configured the v2 Docklet with
.produces(new HashSet<String>(Arrays.asList(new String[]{"application/vnd.arch.service.v2+json"})))
so that it filters the services according to the versioned mime type.Here is our springfox config:
Spring MVC Rest Controller:
The text was updated successfully, but these errors were encountered: