Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3fd4939
Initial commit to update descriptions and tags
irvinesunday Jan 31, 2023
40762cb
Second init for operations and tags
irvinesunday Jan 31, 2023
1bcc59b
Get operation ids
irvinesunday Jan 31, 2023
57fbd6a
Refactor out common code into a helper class for re-use
irvinesunday Feb 1, 2023
f7930ef
Fix tags; refactor; remove redundant code
irvinesunday Feb 1, 2023
7b4efdb
Updates release notes
irvinesunday Feb 1, 2023
b379821
Add SetTags operation for $count operations; update operationId
irvinesunday Mar 8, 2023
993a03e
Remove unnecessary usings
irvinesunday Mar 8, 2023
4eed44a
Add operation id for $count paths for OData type cast segments
irvinesunday Mar 8, 2023
8cc0aaa
Refactor variable name
irvinesunday Mar 8, 2023
aade254
Merge remote-tracking branch 'origin/master' into fix/is/odata-type-c…
irvinesunday Mar 8, 2023
f85e816
Bump up lib. version
irvinesunday Mar 9, 2023
10a9c62
Refactor out private method; update tag generation
irvinesunday Mar 9, 2023
8109875
Update tags generation
irvinesunday Mar 9, 2023
178191a
Create common reusable class
irvinesunday Mar 9, 2023
47ad99a
Generate complex property path tag name in a helper class
irvinesunday Mar 13, 2023
d4680b5
Generate tags for entity set $count paths
irvinesunday Mar 13, 2023
98612fd
Variables renaming
irvinesunday Mar 13, 2023
6ef2f4b
Update integration and unit tests
irvinesunday Mar 13, 2023
abb3c34
Refactor methods that generate operation ids and tags
irvinesunday Mar 14, 2023
ca1e12c
Fix formatting; use methods in helper class to generate tags
irvinesunday Mar 14, 2023
a8785e1
Update unit and integration tests
irvinesunday Mar 15, 2023
490cf70
Variable renaming; fix type cast and complex types operation ids
irvinesunday Mar 15, 2023
d79cdfd
Merge branch 'master' into fix/is/odata-type-cast-opIds
irvinesunday Mar 28, 2023
0c847cf
Bump up version
irvinesunday Mar 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Get operation ids
  • Loading branch information
irvinesunday committed Jan 31, 2023
commit 1bcc59b47140a8c5a7ad3ae7e041ba137c678425
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.OData.Edm;
using Microsoft.OData.Edm.Vocabularies;
Expand Down Expand Up @@ -43,7 +44,7 @@ private bool IsSingleElement
private NavigationPropertyRestriction restriction;
private IEdmSingleton singleton;
private IEdmEntitySet entitySet;
private IEdmEntityType entityTypeName;
private string entityTypeName;
private IEdmNavigationProperty navigationProperty;
private IEdmStructuredType parentStructuredType;
private IEdmSchemaElement ParentSchemaElement => parentStructuredType as IEdmSchemaElement;
Expand Down Expand Up @@ -131,7 +132,7 @@ private void SetEntitySetAndRestrictionFromSourceSegment(ODataNavigationSourceSe
{
entitySet = eSet;
SetRestrictionFromAnnotable(eSet);
entityTypeName = entitySet.EntityType();
entityTypeName = entitySet.EntityType().Name;

}
}
Expand All @@ -142,7 +143,7 @@ private void SetSingletonAndRestrictionFromSourceSegment(ODataNavigationSourceSe
{
singleton = sTon;
SetRestrictionFromAnnotable(sTon);
entityTypeName = singleton.EntityType();
entityTypeName = singleton.EntityType().Name;
}

}
Expand All @@ -168,7 +169,7 @@ protected override void SetBasicInfo(OpenApiOperation operation)
// OperationId
if (Context.Settings.EnableOperationId)
{
var operationItem = IsSingleElement ? $"Get{Utils.UpperFirstChar(typeName)}" : ".List" + Utils.UpperFirstChar(typeName);
var operationItem = IsSingleElement ? $".Get{Utils.UpperFirstChar(entityTypeName)}" : ".List" + Utils.UpperFirstChar(entityTypeName);
operation.OperationId = $"Get.{ParentSchemaElement.ShortQualifiedName()}{operationItem}.As.{TargetSchemaElement.ShortQualifiedName()}-{Path.GetPathHash(Context.Settings)}";
}

Expand Down Expand Up @@ -250,21 +251,21 @@ private void SetSingleResponse(OpenApiOperation operation)
/// <inheritdoc/>
protected override void SetTags(OpenApiOperation operation)
{
//IList<string> items = new List<string>
//{
// ParentSchemaElement.Name,
// TargetSchemaElement.Name,
//};
//IList<string> items = new List<string>
//{
// ParentSchemaElement.Name,
// TargetSchemaElement.Name,
//};

string tagName = entitySet != null
? entitySet.Name + entityTypeName.Name
: singleton.Name + entityTypeName.Name;

// string name = string.Join(".", items);
OpenApiTag tag = new()
{
Name = tagName
};
Name = entitySet != null
? entitySet.Name + entityTypeName
: singleton.Name + entityTypeName
};

if(!IsSingleElement)
tag.Extensions.Add(Constants.xMsTocType, new OpenApiString("page"));
operation.Tags.Add(tag);
Expand Down Expand Up @@ -410,4 +411,44 @@ protected override void AppendCustomParameters(OpenApiOperation operation)
AppendCustomParameters(operation, readRestrictions.CustomQueryOptions, ParameterLocation.Query);
}
}

private string CreateOperationId(ODataPath path)
{
string operationId = null;

if (LastSecondSegment is ODataComplexPropertySegment)
{
ODataComplexPropertySegment complexPropertySegment = parentStructuredType as ODataComplexPropertySegment;
string typeName = complexPropertySegment.ComplexType.Name;
string listOrGet = complexPropertySegment.Property.Type.IsCollection() ? ".List" : ".Get";
operationId = complexPropertySegment.Property.Name + "." + typeName + listOrGet + Utils.UpperFirstChar(typeName);
}
else if (LastSecondSegment is ODataNavigationPropertySegment)
{
string prefix = "Get";
if (path.LastSegment is not ODataKeySegment && navigationProperty.TargetMultiplicity() == EdmMultiplicity.Many)
{
prefix = "List";
}

NavigationPropertyGetOperationHandler handler = new();
operationId = handler.GetOperationId(prefix, path);
}
else if (LastSecondSegment is ODataKeySegment)
{

}
else if (LastSecondSegment is ODataNavigationSourceSegment)
{

}

if (operationId != null)
{
operationId = $"{operationId}As{targetStructuredType}";
}

return operationId;

}
}