Provide implementation guidance on handling UUIDs in POST
/PUT
#51
Labels
documentation
Improvements or additions to documentation
Milestone
Throughout the OSCAL REST API Specification, many paths support
PATCH
,PUT
, andPOST
operations. One of the complexities of the specification today is that the primary identifier of objects, their UUID, can generally be provided in two places: the request path and the request body. Because in many casesPUT
,POST
(andPATCH
) can be invoked in such a way that the results should be similar or identical, guidance should be provided on when each is most appropriate. We want to ensure that for each operation, we keep the meanings of the underlying HTTP verbs in mind.We likely want to provide guidance similar to the following:
POST
A
POST
request should be the preferred option for creating new objects, especially when the ID of the object is not already a value that the client cares about. The primary/root object of aPOST
request should not specify auuid
attribute and servers must return an HTTP 4xx error if one is specified.PUT
A
PUT
operation can be used to update an object by entirely replacing its definition and it can be used to create new objects when a specificuuid
is required. For example, a client may allow a user to create several new objects and specify relationships between them; to support this, the UUIDs may be generated client-side. Server implementations should support this flow by allowing objects to be created with a specified UUID.The
PUT
operation today is defined to include the UUID in the request path as well as in the request body. This opens the path to conflicts between the IDs. We should provide guidance that clients may omit the UUID from the request body; however, if it is specified it must match the UUID in the path (and servers must return an HTTP 4xx error if they do not match). Additionally, if a client makes aPUT
request to a path for which no object with that UUID exists, a new object should be created with that ID.Diagram(s)
I am not particularly well-versed in creating diagrams; however, the following ideally helps clarify the recommendation a bit:
Choosing between
PUT
andPOST
Making a
POST
requestMaking a
PUT
requestPotential specification changes
We may need to make adjustments to the specification to allow for bodies to exclude the UUID objects (or we may need to make adjustments in some cases to require them).
Related discussion
This has been discussed previously in:
The text was updated successfully, but these errors were encountered: