Skip to content

Solution of "Extend BookRestController" doesn't comply with OpenAPI Spec #74

@rweisleder

Description

@rweisleder

With task "Extend BookRestController", the attendees are supposed to add a new mapping, so that the following mappings are present in the BookRestController afterwards:

@GetMapping
public List<Book> getAllBooks() {
    // ...
}

@GetMapping("/{isbn}")
public Book getSingleBook(@PathVariable String isbn) throws Exception {
    // ...
}

@GetMapping(params = "author")
public Book searchBookByAuthor(@RequestParam String author) throws Exception {
    // ...
}

This means that for GET requests with path "/book" there are 2 mappings available now. For Spring this is not a problem. But if we add Springdoc/Swagger later, it gives a weird result:
image

For "GET /book" we have only one operation where the query parameter author is required and which returns only one Book object. The operation getAllBooks returning multiple books does not appear anymore. (Attendees also ask every time why searchBookByAuthor returns only one book and not multiple.)

From my point of view, our BookRestController is no longer OpenAPI conform, because there only one operation may be defined per path and method, see Specification. I suggest to move searchBookByAuthor to another path.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions