@@ -63,29 +63,13 @@ public static IServiceCollection AddOpenApi(this IServiceCollection services, st
6363 // as routing in ASP.NET Core is case-insensitive by default.
6464 var lowercasedDocumentName = documentName . ToLowerInvariant ( ) ;
6565
66- AddOpenApiCore ( services , lowercasedDocumentName ) ;
66+ services . AddOpenApiCore ( services , lowercasedDocumentName ) ;
6767 services . Configure < OpenApiOptions > ( lowercasedDocumentName , options =>
6868 {
6969 options . DocumentName = lowercasedDocumentName ;
7070 configureOptions ( options ) ;
7171 } ) ;
7272 return services ;
73-
74- // The reason this method is a local function is to prevent case-sensitive document names being passed into this method (from other methods) in the future.
75- static IServiceCollection AddOpenApiCore ( IServiceCollection services , string documentName )
76- {
77- services . AddEndpointsApiExplorer ( ) ;
78- services . AddKeyedSingleton < OpenApiSchemaService > ( documentName ) ;
79- services . AddKeyedSingleton < OpenApiSchemaStore > ( documentName ) ;
80- services . AddKeyedSingleton < OpenApiDocumentService > ( documentName ) ;
81- // Required for build-time generation
82- services . AddSingleton < IDocumentProvider , OpenApiDocumentProvider > ( ) ;
83- // Required to resolve document names for build-time generation
84- services . AddSingleton ( new NamedService < OpenApiDocumentService > ( documentName ) ) ;
85- // Required to support JSON serializations
86- services . TryAddEnumerable ( ServiceDescriptor . Singleton < IConfigureOptions < JsonOptions > , OpenApiSchemaJsonOptions > ( ) ) ;
87- return services ;
88- }
8973 }
9074
9175 /// <summary>
@@ -121,4 +105,19 @@ public static IServiceCollection AddOpenApi(this IServiceCollection services, Ac
121105 /// </example>
122106 public static IServiceCollection AddOpenApi ( this IServiceCollection services )
123107 => services . AddOpenApi ( OpenApiConstants . DefaultDocumentName ) ;
108+
109+ static IServiceCollection AddOpenApiCore ( IServiceCollection services , string documentName )
110+ {
111+ services . AddEndpointsApiExplorer ( ) ;
112+ services . AddKeyedSingleton < OpenApiSchemaService > ( documentName ) ;
113+ services . AddKeyedSingleton < OpenApiSchemaStore > ( documentName ) ;
114+ services . AddKeyedSingleton < OpenApiDocumentService > ( documentName ) ;
115+ // Required for build-time generation
116+ services . AddSingleton < IDocumentProvider , OpenApiDocumentProvider > ( ) ;
117+ // Required to resolve document names for build-time generation
118+ services . AddSingleton ( new NamedService < OpenApiDocumentService > ( documentName ) ) ;
119+ // Required to support JSON serializations
120+ services . TryAddEnumerable ( ServiceDescriptor . Singleton < IConfigureOptions < JsonOptions > , OpenApiSchemaJsonOptions > ( ) ) ;
121+ return services ;
122+ }
124123}
0 commit comments