Я с помощью codegen сгенерировал следующий интерфейс:
/**
* POST /pet : Add a new pet to the store
*
* @param petModel Pet object that needs to be added to the store (required)
* @return Invalid input (status code 405)
*/
@ApiOperation(value = "Add a new pet to the store", nickname = "addPet", notes = "", tags={ "private", })
@ApiResponses(value = {
@ApiResponse(code = 405, message = "Invalid input") })
@RequestMapping(value = "/private/pet",
consumes = { "application/json" },
method = RequestMethod.POST)
default ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody PetModel petModel) throws Exception {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
Затем я заставляю свой контроллер реализовать его:
public class PetController implements Api{
public ResponseEntity<Void> addPet(...
}
Я также определил этот список:
@Bean
public Docket myApi(ServletContext servletContext) {
return new Docket(DocumentationType.SWAGGER_2).pathProvider(new DefaultPathProvider() {
@Override
public String getOperationPath(String operationPath) {
return StringUtils.substringAfter(super.getOperationPath(operationPath),contextPath) ;
}
})
.select()
.apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
.paths(PathSelectors.any())
.build();
}
@Bean
public WebMvcConfigurer webMvcConfigurer()
{
return new WebMvcConfigurer()
{
@Override
public void addResourceHandlers( ResourceHandlerRegistry registry )
{
registry.addResourceHandler( "swagger-ui.html" ).addResourceLocations( "classpath:/META-INF/resources/" );
registry.addResourceHandler( "/webjars/**" ).addResourceLocations( "classpath:/META-INF/resources/webjars/" );
}
};
}
Это работает, но в полученном чванстве я получаю пустую строку, связанную с моим контроллером. Как мне от этого избавиться?
![enter image description here](https://i.stack.imgur.com/qRY7N.png)