@@ -45,7 +45,7 @@ internal abstract class EdmOperationOperationHandler : OperationHandler
45
45
46
46
/// <inheritdoc/>
47
47
protected override void Initialize ( ODataContext context , ODataPath path )
48
- {
48
+ {
49
49
base . Initialize ( context , path ) ;
50
50
51
51
// It's bound operation, the first segment must be the navigaiton source.
@@ -57,9 +57,9 @@ protected override void Initialize(ODataContext context, ODataPath path)
57
57
58
58
HasTypeCast = path . Segments . Any ( s => s is ODataTypeCastSegment ) ;
59
59
60
- _operationRestriction = Context . Model . GetRecord < OperationRestrictionsType > ( TargetPath , CapabilitiesConstants . OperationRestrictions ) ;
61
- var operationRestrictions = Context . Model . GetRecord < OperationRestrictionsType > ( EdmOperation , CapabilitiesConstants . OperationRestrictions ) ;
62
- _operationRestriction ? . MergePropertiesIfNull ( operationRestrictions ) ;
60
+ _operationRestriction = Context . Model . GetRecord < OperationRestrictionsType > ( TargetPath , CapabilitiesConstants . OperationRestrictions ) ;
61
+ var operationRestrictions = Context . Model . GetRecord < OperationRestrictionsType > ( EdmOperation , CapabilitiesConstants . OperationRestrictions ) ;
62
+ _operationRestriction ? . MergePropertiesIfNull ( operationRestrictions ) ;
63
63
_operationRestriction ??= operationRestrictions ;
64
64
}
65
65
@@ -81,6 +81,7 @@ protected override void SetBasicInfo(OpenApiOperation operation)
81
81
// duplicates in entity vs entityset functions/actions
82
82
83
83
List < string > identifiers = new ( ) ;
84
+ string pathHash = string . Empty ;
84
85
foreach ( ODataSegment segment in Path . Segments )
85
86
{
86
87
if ( segment is ODataKeySegment keySegment )
@@ -89,41 +90,43 @@ protected override void SetBasicInfo(OpenApiOperation operation)
89
90
{
90
91
identifiers . Add ( segment . EntityType . Name ) ;
91
92
continue ;
92
- }
93
-
94
- // We'll consider alternate keys in the operation id to eliminate potential duplicates with operation id of primary path
95
- if ( segment == Path . Segments . Last ( ) )
96
- {
97
- identifiers . Add ( "By" + string . Join ( "" , keySegment . Identifier . Split ( ',' ) . Select ( static x => Utils . UpperFirstChar ( x ) ) ) ) ;
98
- }
99
- else
100
- {
101
- identifiers . Add ( keySegment . Identifier ) ;
102
- }
93
+ }
94
+
95
+ // We'll consider alternate keys in the operation id to eliminate potential duplicates with operation id of primary path
96
+ if ( segment == Path . Segments . Last ( ) )
97
+ {
98
+ identifiers . Add ( "By" + string . Join ( "" , keySegment . Identifier . Split ( ',' ) . Select ( static x => Utils . UpperFirstChar ( x ) ) ) ) ;
99
+ }
100
+ else
101
+ {
102
+ identifiers . Add ( keySegment . Identifier ) ;
103
+ }
104
+ }
105
+ else if ( segment is ODataOperationSegment opSegment )
106
+ {
107
+ if ( opSegment . Operation is IEdmFunction function && Context . Model . IsOperationOverload ( function ) )
108
+ {
109
+ // Hash the segment to avoid duplicate operationIds
110
+ pathHash = segment . GetPathHash ( Context . Settings ) ;
111
+ }
112
+
113
+ identifiers . Add ( segment . Identifier ) ;
103
114
}
104
115
else
105
116
{
106
- identifiers . Add ( segment . Identifier ) ;
117
+ identifiers . Add ( segment . Identifier ) ;
107
118
}
108
119
}
109
120
110
121
string operationId = string . Join ( "." , identifiers ) ;
111
122
112
- if ( EdmOperation . IsAction ( ) )
123
+ if ( ! string . IsNullOrEmpty ( pathHash ) )
113
124
{
114
- operation . OperationId = operationId ;
125
+ operation . OperationId = operationId + "-" + pathHash ;
115
126
}
116
127
else
117
128
{
118
- if ( Path . LastSegment is ODataOperationSegment operationSegment &&
119
- Context . Model . IsOperationOverload ( operationSegment . Operation ) )
120
- {
121
- operation . OperationId = operationId + "-" + Path . LastSegment . GetPathHash ( Context . Settings ) ;
122
- }
123
- else
124
- {
125
- operation . OperationId = operationId ;
126
- }
129
+ operation . OperationId = operationId ;
127
130
}
128
131
}
129
132
@@ -269,15 +272,15 @@ protected override void SetExternalDocs(OpenApiOperation operation)
269
272
if ( Context . Settings . ShowExternalDocs )
270
273
{
271
274
var externalDocs = Context . Model . GetLinkRecord ( TargetPath , CustomLinkRel ) ??
272
- Context . Model . GetLinkRecord ( EdmOperation , CustomLinkRel ) ;
273
-
274
- if ( externalDocs != null )
275
- {
276
- operation . ExternalDocs = new OpenApiExternalDocs ( )
277
- {
278
- Description = CoreConstants . ExternalDocsDescription ,
279
- Url = externalDocs . Href
280
- } ;
275
+ Context . Model . GetLinkRecord ( EdmOperation , CustomLinkRel ) ;
276
+
277
+ if ( externalDocs != null )
278
+ {
279
+ operation . ExternalDocs = new OpenApiExternalDocs ( )
280
+ {
281
+ Description = CoreConstants . ExternalDocsDescription ,
282
+ Url = externalDocs . Href
283
+ } ;
281
284
}
282
285
}
283
286
}
0 commit comments