-
Notifications
You must be signed in to change notification settings - Fork 62
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
[Feature] Adds support for RequiresExplicitBinding
and ExplicitOperationBindings
annotations for operations
#378
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irvinesunday
requested review from
xuzhg,
darrelmiller,
peombwa,
zengin,
baywet and
millicentachieng
as code owners
April 28, 2023 08:28
andrueastman
reviewed
May 2, 2023
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.
Thanks for this @irvinesunday
Co-authored-by: Eastman <[email protected]>
Kudos, SonarCloud Quality Gate passed! |
andrueastman
approved these changes
May 2, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #323, #232
This PR:
Org.OData.Core.V1.RequiresExplicitBinding
in operations andOrg.OData.Core.V1.ExplicitOperationBindings
in model elements to associate which operations are to be generated for which elements.How it works
Take for example the operation:
The
bindingParameter
is of typegraph.directoryObject
. This means that all model elements of this type (including all of its derived types) will have the operationgetMemberObjects
appended to their paths. In order to restrict the generation of this operation only to certain instances of the binding type -directoryObject
, we append the<Annotation Term="Org.OData.Core.V1.RequiresExplicitBinding"/>
annotation to the operation (as shown above).The navigation property
deletedItems
is an instance of typeCollection(graph.directoryObject)
:<NavigationProperty Name="deletedItems" Type="Collection(graph.directoryObject)" ContainsTarget="true" />
Ordinarily it would have the path
/directory/deletedItems/{directoryObject-id}/microsoft.graph.getMemberGroups
which is invalid. The only valid operation for this navigation property path would be/directory/deletedItems/{directoryObject-id}/microsoft.graph.restore
.To restrict all the operations bound to instances of
directoryObject
from being generated as operations on thedeletedItems
navigation property and only allow therestore
operation, we would create anExplicitOperationBindings
to the navigation property as such:The entity type
directoryObject
will need to invoke all the operations that are bound to it and since all the operations which bind todirectoryObject
have been annotated with the annotationOrg.OData.Core.V1.RequiresExplicitBinding
, a correspondingOrg.OData.Core.V1.ExplicitOperationBindings
annotations with the collection of allowable operations need to be specified. Specifying this annotation on the entity type itself would automatically propagate to all its derived types. Which is not what we want. Therefore, this corresponding annotation will need to be annotated on the navigation source instance of this entity type. For example:The above will yield the paths:
Unless a corresponding derived type of
directoryObject
gets annotated with theOrg.OData.Core.V1.ExplicitOperationBindings
, these operations will not be created for paths of this derived type.The net result from all this should be a significant reduction in the number of invalid operation paths and a reduction in the size of the OpenAPI document and consequently our SDKs. The appropriate annotations will need to be added to the CSDL through XSLT initially and later by workload teams to realise this.
NB: The default behaviour is preserved (all operations generated for the bound entity types) when none of these annotations are specified anywhere.