@@ -13,11 +13,6 @@ namespace Microsoft.OpenApi.Services
13
13
/// </summary>
14
14
public static class OpenApiFilterService
15
15
{
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
-
21
16
/// <summary>
22
17
/// Create predicate function based on passed query parameters
23
18
/// </summary>
@@ -55,41 +50,25 @@ public static Func<OpenApiOperation, bool> CreatePredicate(string operationIds)
55
50
/// Create partial OpenAPI document based on the provided predicate.
56
51
/// </summary>
57
52
/// <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>
60
53
/// <param name="predicate">A predicate function.</param>
61
54
/// <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 )
63
56
{
57
+ // Fetch and copy title, graphVersion and server info from OpenApiDoc
64
58
var subset = new OpenApiDocument
65
59
{
66
60
Info = new OpenApiInfo ( )
67
61
{
68
- Title = title ,
69
- Version = graphVersion
62
+ Title = source . Info . Title ,
63
+ Version = source . Info . Version
70
64
} ,
71
65
72
66
Components = new OpenApiComponents ( )
73
67
} ;
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 > ( ) } } ) ;
91
68
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 ;
93
72
94
73
var results = FindOperations ( source , predicate ) ;
95
74
foreach ( var result in results )
0 commit comments