I have the following spring get mapping (org.springframework.web.bind.annotation.GetMapping
) in a controller:
@GetMapping("/v{version:[1-2]}/something/{id}")
I want to be able to access the two versions of the api in swagger. This is my swagger config:
@Bean
public Docket v1(SwaggerProperties swaggerProperties) {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("V1")
.select()
.paths(regex("/v1/.*")).build()
}
@Bean
public Docket v2(SwaggerProperties swaggerProperties) {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("V2")
.select()
.paths(regex("/v2/.*")).build()
}
This does not work, the only thing I can see in swagger when I remove the paths
selector is:
/v{version}/something/{id}
And I would like to see:
/v1/something/{id}
When selecting the V1
group in the swagger group selector:
And this when selecting V2
:
/v2/something/{id}