Skip to content

Create vs update, PUT / POST / PATCH, and minimal OpenAPI redundancy #1453

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
mewalig opened this issue Jan 5, 2018 · 4 comments
Closed
Labels
Moved to Moonwalk Issues that can be closed or migrated as being addressed in Moonwalk

Comments

@mewalig
Copy link

mewalig commented Jan 5, 2018

Suppose I have a service that must provide separate "create" vs "update" operations for creating a new resource. The calls for create and update with be exactly the same except for whatever differentiates between create and update. That differentiation could come from the method (post vs put vs patch), from the url (/resource/id/create vs /resource/id/update), from the data in the body-- it seems that request method is the only one I have seen recommended, but whatever the case may be, everything about the create/update request would otherwise be the same.

  1. If I decided to implement this using two different methods (e.g. PUT vs PATCH), is there a way using OpenAPI to not have to repeat the duplicate parts of the specification?
  2. If the answer to the above is that, there is no way, then, is request method (PUT vs PATCH) the only approach for handling this scenario that would be considered "well-designed", or could any of the other approaches (using URL or data to differentiate create vs update) work equally well while also eliminating that redundancy in the corresponding OpenAPI spec?
@hkosova
Copy link
Contributor

hkosova commented Mar 6, 2018

@antillean
Copy link

The "Reusable Bodies" section in the documentation on Describing Request Body mostly solves this problem. The example there shows how you can use it to eliminate the duplication in the specifications for POST and PUT requests to the same resource type.

@kscheirer
Copy link

I am evaluating this as a possible use case for overlays, OAI/Overlay-Specification#9.

I do not think overlays would be much help here. Previous comment shows to to handle this case in openapi3.

@handrews handrews added the Moved to Moonwalk Issues that can be closed or migrated as being addressed in Moonwalk label Jan 29, 2024
@handrews
Copy link
Member

This was partially answered a while ago. For the rest, as with the similar issue #2201, the magnitude of change means it will be addressed in Moonwalk (OAS 4) rather than 3.x. Please join the discussions in that repo, such as OAI/sig-moonwalk#30 (resource oriented).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Moved to Moonwalk Issues that can be closed or migrated as being addressed in Moonwalk
Projects
None yet
Development

No branches or pull requests

5 participants