-
Notifications
You must be signed in to change notification settings - Fork 396
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
feat: improve response (code) guidance (#787, #762, #737) #789
Conversation
Signed-off-by: tkrop <[email protected]>
* For a single resource (tree) {POST} is expected to utilize the {Location} | ||
header pointing to the URL of the newly created resource (tree) -- with or | ||
without returning the resource (tree). | ||
* For multiple resources {POST} may either return a collection of newly | ||
created resources as served by the {GET} collection endpoint, or a bulk | ||
response using the status code {207} (see also <<152>>). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tries to clarify on how to return created resources with respect to id
and location
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not convinced that we always should require the Location response header.
Propose the following change:
- {POST} must be used to create one or multiple new resources:
- Single resource creation: successful POST should return the new resource
object as response payload including the resource id. We expect that the resource id
can be used as a path parameter of the GET endpoint to read the resource. The URL to read
the resource must be provided via the Location response header, if the resource is
not returned. It is a good practice to always provide the Location header. - Multiple resource creation: successful {POST} may either return a collection of newly
created resources as served by the {GET} collection endpoint, or a bulk
response using the status code {207} (see also <<152>>).
- Single resource creation: successful POST should return the new resource
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #791 for the proposed changes from the discussion.
* Successful {DELETE} requests return {200} or {204} (if the resource was | ||
deleted -- with or without returning the resource), or {202} (if the request | ||
was accepted for asynchronous processing). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adds 202
.
* Successful {PATCH} requests return {200} or {204} (if the resource was | ||
updated -- with or without returning the resource), and {202} (if the request | ||
was accepted for asynchronous processing). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adds 202
.
👍 |
1 similar comment
👍 |
This pull request was starting from the still open issue #685 (originally addressed by #737) and the latest work done in #787 trying to grab the open ends and missed links to add more guidance on the correct usage of
Location
header inPOST
responses. While doing so I was also doing the review on #762, I was lacking behind.Changes to
chapters/http-requests.adoc
:202
as expected response codes onPUT
andPATCH
operations, since they may also support asynchronous processing.POST
responses utilizing theLocation
header.Changes to
chapters/http-status-codes-and-errors.adoc
:200
response code marks the return of an already existing resource on resource creation.3xx
response code. Before it incorrectly referenced rule 250 and was added to the chapter of3xx
response codes.use
-advise to response codes406
,412
,415
,428
,500
, and503
to highlight response codes that have use case defined within the guideline.423
,500
,501
, and503
giving details on use cases.424
,431
,502
,504
,505
,507
, and511
to complete the list of response codes defined by the three incorporated and referenced RFCs 9110, 6585, and 4918.Definitely fixes #685.