-
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
[Fix] Resolves operation ids for $count
and overloaded functions paths
#386
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e3a09d5
Remove Get or Set prefix from $count operation ids
irvinesunday eacfecc
Add hash suffix to functions with params to avoid duplications
irvinesunday c1ac49d
Update and re-use function checking for operation overload
irvinesunday 75d81fc
Updates release note
irvinesunday 3bf9a04
Remove unnecessary whitespace
irvinesunday 2d32b07
Update XML summary
irvinesunday 2b8f4b7
Update tests
millicentachieng 2442d60
Update src/Microsoft.OpenApi.OData.Reader/Common/EdmModelHelper.cs
irvinesunday d98bf2a
Remove redundant else block
irvinesunday File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -279,8 +279,9 @@ internal static string GenerateComplexPropertyPathTagName(ODataPath path, ODataC | |
/// Generates the operation id prefix from an OData type cast path. | ||
/// </summary> | ||
/// <param name="path">The target <see cref="ODataPath"/>.</param> | ||
/// <param name="includeListOrGetPrefix">Optional: Whether to include the List or Get prefix to the generated operation id.</param> | ||
/// <returns>The operation id prefix generated from the OData type cast path.</returns> | ||
internal static string GenerateODataTypeCastPathOperationIdPrefix(ODataPath path) | ||
internal static string GenerateODataTypeCastPathOperationIdPrefix(ODataPath path, bool includeListOrGetPrefix = true) | ||
{ | ||
// Get the segment before the last OData type cast segment | ||
ODataTypeCastSegment typeCastSegment = path.Segments.OfType<ODataTypeCastSegment>()?.Last(); | ||
|
@@ -309,24 +310,24 @@ internal static string GenerateODataTypeCastPathOperationIdPrefix(ODataPath path | |
string operationId = null; | ||
if (secondLastSegment is ODataComplexPropertySegment complexSegment) | ||
{ | ||
string listOrGet = complexSegment.Property.Type.IsCollection() ? "List" : "Get"; | ||
string listOrGet = includeListOrGetPrefix ? (complexSegment.Property.Type.IsCollection() ? "List" : "Get") : null; | ||
operationId = GenerateComplexPropertyPathOperationId(path, listOrGet); | ||
} | ||
else if (secondLastSegment as ODataNavigationPropertySegment is not null || isIndexedCollValuedNavProp) | ||
{ | ||
string prefix = "Get"; | ||
if (!isIndexedCollValuedNavProp && | ||
(secondLastSegment as ODataNavigationPropertySegment)?.NavigationProperty.TargetMultiplicity() == EdmMultiplicity.Many) | ||
string listOrGet = null; | ||
if (includeListOrGetPrefix) | ||
{ | ||
prefix = "List"; | ||
listOrGet = !isIndexedCollValuedNavProp && (secondLastSegment as ODataNavigationPropertySegment)?.NavigationProperty.TargetMultiplicity() == EdmMultiplicity.Many ? "List" : "Get"; | ||
} | ||
|
||
operationId = GenerateNavigationPropertyPathOperationId(path, prefix); | ||
operationId = GenerateNavigationPropertyPathOperationId(path, listOrGet); | ||
} | ||
else if (secondLastSegment is ODataKeySegment keySegment && !isIndexedCollValuedNavProp) | ||
{ | ||
string entityTypeName = keySegment.EntityType.Name; | ||
string operationName = $"Get{Utils.UpperFirstChar(entityTypeName)}"; | ||
string getPrefix = includeListOrGetPrefix ? "Get" : null; | ||
string operationName = $"{getPrefix}{Utils.UpperFirstChar(entityTypeName)}"; | ||
if (keySegment.IsAlternateKey) | ||
{ | ||
string alternateKeyName = string.Join("", keySegment.Identifier.Split(',').Select(static x => Utils.UpperFirstChar(x))); | ||
|
@@ -338,8 +339,8 @@ internal static string GenerateODataTypeCastPathOperationIdPrefix(ODataPath path | |
else if (secondLastSegment is ODataNavigationSourceSegment) | ||
{ | ||
operationId = (entitySet != null) | ||
? entitySet.Name + "." + entitySet.EntityType().Name + ".List" + Utils.UpperFirstChar(entitySet.EntityType().Name) | ||
: singleton.Name + "." + singleton.EntityType().Name + ".Get" + Utils.UpperFirstChar(singleton.EntityType().Name); | ||
? entitySet.Name + "." + entitySet.EntityType().Name + $".{(includeListOrGetPrefix ? "List" : null)}" + Utils.UpperFirstChar(entitySet.EntityType().Name) | ||
: singleton.Name + "." + singleton.EntityType().Name + $".{(includeListOrGetPrefix ? "Get" : null)}" + Utils.UpperFirstChar(singleton.EntityType().Name); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Singleton can technically be null here |
||
} | ||
|
||
return operationId; | ||
|
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
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
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
Oops, something went wrong.
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.
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.
Less work when we enable NRT this way