Skip to content

Support @RequestMapping.param for overloaded endpoints #580

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

Closed
pcalouche opened this issue Apr 16, 2020 · 1 comment
Closed

Support @RequestMapping.param for overloaded endpoints #580

pcalouche opened this issue Apr 16, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@pcalouche
Copy link

I saw this issues was marked as won't fix here #15, but I think there are valid uses cases for it and Spring supports it. Springfox also supported this as well.

For example

// handle save draft of audit
@PatchMapping(value = "/audits/{auditId}", params = "action=saveDraft")
public AuditDto saveDraft(@PathVariable int auditId, @RequestBody AuditPatchRequest auditPatchRequest) {
}

// save audit and mark it as reviewed
@PatchMapping(value = "/audits/{auditId}", params = "action=markReviewed")
public AuditDto markedReviewed(@PathVariable int auditId, @RequestBody AuditPatchRequest auditPatchRequest) {
}

// marks audit as complete, but makes no other changes
@PatchMapping(value = "/audits/{auditId}", params = "action=markComplete")
public AuditDto markComplete(@PathVariable int auditId) {

}

I would expect to see these endpoints generated in the documentation:

PATCH /audits/{auditId}?action=saveDraft
PATCH /audits/{auditId}?action=markReviewed
PATCH /audits/{auditId}?action=markComplete

I'm open to an alternate way to do handle such endpoints if you can suggest one along with constructive criticism as to why may not be good REST API practice. Keep up the good work.

@bnasslahsen
Copy link
Collaborator

bnasslahsen commented Apr 17, 2020

@pcalouche,

With OpenAPI 3, you can not have 3 endpoints for the same path:
You will have one endpoint and only one OpenAPI description.

paths:
  '/audits/{auditId}':
    patch:

What you can do is add the @Operation annotation on the top of one of the methods, where you add the OpenAPI documentation of the merged OpenAPI description of all your other methods as well and add the @Hidden annotation on the two others

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants