@@ -13,11 +13,6 @@ namespace Microsoft.OpenApi.Services
1313 /// </summary>
1414 public static class OpenApiFilterService
1515 {
16- public static readonly string GraphAuthorizationUrl = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize" ;
17- public static readonly string GraphTokenUrl = "https://login.microsoftonline.com/common/oauth2/v2.0/token" ;
18- public static readonly string GraphUrl = "https://graph.microsoft.com/{0}/" ;
19- public const string GraphVersion_V1 = "v1.0" ;
20-
2116 /// <summary>
2217 /// Create predicate function based on passed query parameters
2318 /// </summary>
@@ -55,41 +50,25 @@ public static Func<OpenApiOperation, bool> CreatePredicate(string operationIds)
5550 /// Create partial OpenAPI document based on the provided predicate.
5651 /// </summary>
5752 /// <param name="source">The target <see cref="OpenApiDocument"/>.</param>
58- /// <param name="title">The OpenAPI document title.</param>
59- /// <param name="graphVersion">Version of the target Microsoft Graph API.</param>
6053 /// <param name="predicate">A predicate function.</param>
6154 /// <returns>A partial OpenAPI document.</returns>
62- public static OpenApiDocument CreateFilteredDocument ( OpenApiDocument source , string title , string graphVersion , Func < OpenApiOperation , bool > predicate )
55+ public static OpenApiDocument CreateFilteredDocument ( OpenApiDocument source , Func < OpenApiOperation , bool > predicate )
6356 {
57+ // Fetch and copy title, graphVersion and server info from OpenApiDoc
6458 var subset = new OpenApiDocument
6559 {
6660 Info = new OpenApiInfo ( )
6761 {
68- Title = title ,
69- Version = graphVersion
62+ Title = source . Info . Title ,
63+ Version = source . Info . Version
7064 } ,
7165
7266 Components = new OpenApiComponents ( )
7367 } ;
74- var aadv2Scheme = new OpenApiSecurityScheme ( )
75- {
76- Type = SecuritySchemeType . OAuth2 ,
77- Flows = new OpenApiOAuthFlows ( )
78- {
79- AuthorizationCode = new OpenApiOAuthFlow ( )
80- {
81- AuthorizationUrl = new Uri ( GraphAuthorizationUrl ) ,
82- TokenUrl = new Uri ( GraphTokenUrl )
83- }
84- } ,
85- Reference = new OpenApiReference ( ) { Id = "azureaadv2" , Type = ReferenceType . SecurityScheme } ,
86- UnresolvedReference = false
87- } ;
88- subset . Components . SecuritySchemes . Add ( "azureaadv2" , aadv2Scheme ) ;
89-
90- subset . SecurityRequirements . Add ( new OpenApiSecurityRequirement ( ) { { aadv2Scheme , Array . Empty < string > ( ) } } ) ;
9168
92- subset . Servers . Add ( new OpenApiServer ( ) { Description = "Core" , Url = string . Format ( GraphUrl , graphVersion ) } ) ;
69+ subset . Components . SecuritySchemes = source . Components . SecuritySchemes ;
70+ subset . SecurityRequirements = source . SecurityRequirements ;
71+ subset . Servers = source . Servers ;
9372
9473 var results = FindOperations ( source , predicate ) ;
9574 foreach ( var result in results )
0 commit comments