@@ -35,29 +35,45 @@ public static class OpenApiUrlTreeNodeExtensions
3535 OpenApiUrlTreeNode result = parentNode ;
3636 foreach ( var segment in pathParts )
3737 {
38+ var segmentToMatch = segment ;
3839 OpenApiUrlTreeNode ? nextNode = null ;
3940
40- if ( segment == "{id}" )
41+ if ( segmentToMatch == "{id}" )
4142 {
4243 nextNode = result . Children . FirstOrDefault ( c => c . Value . Segment . StartsWith ( '{' ) &&
4344 c . Value . Segment . EndsWith ( '}' ) && c . Value . Segment . Contains ( "id" , StringComparison . InvariantCultureIgnoreCase ) ) . Value ;
4445 }
4546 else
4647 {
47- var matchNodes = result . Children . Where ( c => c . Value . Segment . IsEqualIgnoringCase ( segment ) ||
48- c . Value . Segment . IsEqualIgnoringCase ( $ "{ graphNamespace } .{ segment } ") ||
49- c . Value . Segment . IsEqualIgnoringCase ( $ "{ segment } ()") ||
50- c . Value . Segment . IsEqualIgnoringCase ( $ "{ graphNamespace } .{ segment } ()") ) ;
48+ var matchNodes = result . Children . Where ( c => c . Value . Segment . IsEqualIgnoringCase ( segmentToMatch ) ||
49+ c . Value . Segment . IsEqualIgnoringCase ( $ "{ graphNamespace } .{ segmentToMatch } ") ||
50+ c . Value . Segment . IsEqualIgnoringCase ( $ "{ segmentToMatch } ()") ||
51+ c . Value . Segment . IsEqualIgnoringCase ( $ "{ graphNamespace } .{ segmentToMatch } ()") ) ;
52+
53+ if ( matchNodes ? . Count ( ) == 0 &&
54+ segmentToMatch . StartsWith ( "microsoft.graph" , StringComparison . InvariantCultureIgnoreCase ) )
55+ {
56+ // OpenAPI docs sometimes leave off the "microsoft." prefix
57+ var trimmedSegment = segmentToMatch . Replace ( "microsoft." , string . Empty , StringComparison . InvariantCultureIgnoreCase ) ;
58+
59+ matchNodes = result . Children . Where ( c => c . Value . Segment . IsEqualIgnoringCase ( trimmedSegment ) ||
60+ c . Value . Segment . IsEqualIgnoringCase ( $ "{ trimmedSegment } ()") ) ;
61+
62+ if ( matchNodes ? . Count ( ) >= 1 )
63+ {
64+ segmentToMatch = trimmedSegment ;
65+ }
66+ }
5167
5268 if ( matchNodes ? . Count ( ) > 1 )
5369 {
5470 var matchCount = matchNodes . Count ( ) ;
5571 }
5672
57- nextNode = result . Children . FirstOrDefault ( c => c . Value . Segment . IsEqualIgnoringCase ( segment ) ||
58- c . Value . Segment . IsEqualIgnoringCase ( $ "{ graphNamespace } .{ segment } ") ) . Value ??
59- result . Children . FirstOrDefault ( c => c . Value . Segment . IsEqualIgnoringCase ( $ "{ segment } ()") ||
60- c . Value . Segment . IsEqualIgnoringCase ( $ "{ graphNamespace } .{ segment } ()") ) . Value ;
73+ nextNode = result . Children . FirstOrDefault ( c => c . Value . Segment . IsEqualIgnoringCase ( segmentToMatch ) ||
74+ c . Value . Segment . IsEqualIgnoringCase ( $ "{ graphNamespace } .{ segmentToMatch } ") ) . Value ??
75+ result . Children . FirstOrDefault ( c => c . Value . Segment . IsEqualIgnoringCase ( $ "{ segmentToMatch } ()") ||
76+ c . Value . Segment . IsEqualIgnoringCase ( $ "{ graphNamespace } .{ segmentToMatch } ()") ) . Value ;
6177 }
6278
6379 if ( nextNode == null )
0 commit comments