OpenAPI support for Atomic Operations #1580
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds full support for using atomic operations with OpenAPI. Tests and examples using NSwag and Kiota are provided.
Various types have been renamed, which heavily affects generated clients. For example,
personPatchRequestDocument
is nowupdatePersonRequestDocument
, andpersonAttributesInPostRequest
has becomeattributesInCreatePersonRequest
. These renames were done because atomic operations are reusing existing schemas. As we're breaking big now (sorry), I did some extra cleanups in schema names. The easiest way to overcome that is to use target-typed new.Both
id
andlid
are exposed in all request types, to avoid an explosion of schema types. But this only happens when an operations controller is found. The effect is that you can send alid
in a post-resource request (which will be rejected by the server). Because of theid
/lid
distinction, separate schemas are generated for resource identifiers in requests and responses (sostaffMemberIdentifier
is replaced bystaffMemberIdentifierInRequest
andstaffMemberIdentifierInResponse
).Another change is that the
id
property has moved from the abstractdataInResponse
type into the resource-specific derived types. The effect is that you first need to upcast/type-check before getting access to theid
.Both NSwag and Kiota choke on the quotes in the
application/vnd.api+json; ext="https://jsonapi.org/ext/atomic"
media type, generating code that doesn't compile. Therefore, OpenAPI uses the relaxed variant introduced in #1553.The exposed operations in OpenAPI are based on the
GenerateControllerEndpoints
by default, but can be customized using your ownIAtomicOperationFilter
, a new feature that was introduced in #1561.The generation of
id
/lid
properties takesClientIdGenerationMode
into account for create-resource operations. Likewise, get-only or set-only attribute properties are hidden in the appropriate schemas.There is currently no way to send
null
/default
attribute values in an operations request with NSwag. This is tracked at #1577.Example usage:
Closes #1060.
QUALITY CHECKLIST