我正在使用这个库https://github.com/tkaczmarzyk/specification-arg-resolver在 Spring Boot 中生成规范。问题是这个库在运行时生成它们,而 swagger 在编译时工作。Swagger 仅检测分页中使用的参数。任何想法如何解决这个问题?
代码:
@And({
@Spec(path = "title", params = {"title"}, spec = LikeIgnoreCase.class),
@Spec(path = "rented", params = {"isRented", "rented"}, spec = Equal.class),
@Spec(path = "author.id", params = {"authorId"}, spec = Equal.class),
@Spec(path = "author.firstName", params = {"firstName"}, spec = LikeIgnoreCase.class),
@Spec(path = "author.lastName", params = {"lastName"}, spec = LikeIgnoreCase.class)
})
interface BookSpecification extends Specification<Book> {
}
@RestController
@CrossOrigin
@RequestMapping("/api/books")
public class BookController extends AbstractController<Book, BookDto> {
private final BookService bookService;
public BookController(BookService bookService) {
super(bookService);
this.bookService = bookService;
}
@GetMapping
public ResponseEntity<Page<BookDto>> getAll(BookSpecification authorSpecification, Pageable pageable) {
return ResponseEntity.ok(bookService.getAll(authorSpecification, pageable));
}
解决方案: https ://github.com/swagger-api/swagger-core/wiki/annotations#apiimplicitparam-apiimplicitparams