@@ -85,7 +85,7 @@ private void AddOperation(
8585 ExceptionType = e . GetType ( ) . Name ,
8686 Message = e . Message
8787 }
88- ) ;
88+ ) ;
8989 }
9090 }
9191
@@ -132,7 +132,7 @@ private void AddOperation(
132132 ExceptionType = e . GetType ( ) . Name ,
133133 Message = e . Message
134134 }
135- ) ;
135+ ) ;
136136 }
137137 }
138138
@@ -161,7 +161,7 @@ private void AddOperation(
161161 ExceptionType = e . GetType ( ) . Name ,
162162 Message = e . Message
163163 }
164- ) ;
164+ ) ;
165165 }
166166 }
167167 }
@@ -276,120 +276,117 @@ IDictionary<DocumentVariantInfo, OpenApiDocument> openApiDocuments
276276
277277 try
278278 {
279- using ( var filePreparer = new FilePreparer ( ) )
280- {
281- generationDiagnostic = new GenerationDiagnostic ( ) ;
282- var documentGenerationDiagnostic = new DocumentGenerationDiagnostic ( ) ;
279+ generationDiagnostic = new GenerationDiagnostic ( ) ;
280+ var documentGenerationDiagnostic = new DocumentGenerationDiagnostic ( ) ;
283281
284- if ( documentVariantElementNames ? . Count > 1 )
282+ if ( documentVariantElementNames ? . Count > 1 )
283+ {
284+ documentGenerationDiagnostic . Errors . Add ( new GenerationError
285285 {
286- documentGenerationDiagnostic . Errors . Add ( new GenerationError
287- {
288- Message = string . Format (
289- SpecificationGenerationMessages . MoreThanOneVariantNameNotAllowed ,
290- documentVariantElementNames . First ( ) )
291- } ) ;
292- }
286+ Message = string . Format (
287+ SpecificationGenerationMessages . MoreThanOneVariantNameNotAllowed ,
288+ documentVariantElementNames . First ( ) )
289+ } ) ;
290+ }
293291
294- var typeFetcher = new TypeFetcher ( filePreparer . CopyFileToPrivateBin ( contractAssemblyPaths ) ) ;
292+ var typeFetcher = new TypeFetcher ( contractAssemblyPaths ) ;
295293
296- var operationGenerationDiagnostics = GenerateSpecificationDocuments (
297- typeFetcher ,
298- operationElements ,
299- operationConfigElement ,
300- documentVariantElementNames . FirstOrDefault ( ) ,
301- out var documents ) ;
294+ var operationGenerationDiagnostics = GenerateSpecificationDocuments (
295+ typeFetcher ,
296+ operationElements ,
297+ operationConfigElement ,
298+ documentVariantElementNames . FirstOrDefault ( ) ,
299+ out var documents ) ;
302300
303- foreach ( var operationGenerationDiagnostic in operationGenerationDiagnostics )
304- {
305- generationDiagnostic . OperationGenerationDiagnostics . Add (
306- new OperationGenerationDiagnostic ( operationGenerationDiagnostic ) ) ;
307- }
301+ foreach ( var operationGenerationDiagnostic in operationGenerationDiagnostics )
302+ {
303+ generationDiagnostic . OperationGenerationDiagnostics . Add (
304+ new OperationGenerationDiagnostic ( operationGenerationDiagnostic ) ) ;
305+ }
308306
309- foreach ( var variantInfoDocumentValuePair in documents )
310- {
311- var openApiDocument = variantInfoDocumentValuePair . Value ;
307+ foreach ( var variantInfoDocumentValuePair in documents )
308+ {
309+ var openApiDocument = variantInfoDocumentValuePair . Value ;
312310
313- foreach ( var documentFilter in _documentFilters )
311+ foreach ( var documentFilter in _documentFilters )
312+ {
313+ try
314314 {
315- try
316- {
317- documentFilter . Apply (
318- openApiDocument ,
319- annotationXmlDocuments ,
320- new DocumentFilterSettings
321- {
322- TypeFetcher = typeFetcher ,
323- OpenApiDocumentVersion = openApiDocumentVersion
324- } ) ;
325- }
326- catch ( Exception e )
327- {
328- documentGenerationDiagnostic . Errors . Add (
329- new GenerationError
330- {
331- ExceptionType = e . GetType ( ) . Name ,
332- Message = e . Message
333- } ) ;
334- }
315+ documentFilter . Apply (
316+ openApiDocument ,
317+ annotationXmlDocuments ,
318+ new DocumentFilterSettings
319+ {
320+ TypeFetcher = typeFetcher ,
321+ OpenApiDocumentVersion = openApiDocumentVersion
322+ } ) ;
335323 }
336-
337- foreach ( var filter in _postProcessingDocumentFilters )
324+ catch ( Exception e )
338325 {
339- filter . Apply (
340- openApiDocument ,
341- new PostProcessingDocumentFilterSettings ( )
326+ documentGenerationDiagnostic . Errors . Add (
327+ new GenerationError
342328 {
343- OperationGenerationDiagnostics = operationGenerationDiagnostics
329+ ExceptionType = e . GetType ( ) . Name ,
330+ Message = e . Message
344331 } ) ;
345332 }
346333 }
347334
348- if ( documentConfigElement != null )
335+ foreach ( var filter in _postProcessingDocumentFilters )
349336 {
350- foreach ( var documentConfigFilter in _documentConfigFilters )
351- {
352- try
337+ filter . Apply (
338+ openApiDocument ,
339+ new PostProcessingDocumentFilterSettings ( )
353340 {
354- documentConfigFilter . Apply (
355- documents ,
356- documentConfigElement ,
357- annotationXmlDocuments ,
358- new DocumentConfigFilterSettings ( ) ) ;
359- }
360- catch ( Exception e )
361- {
362- documentGenerationDiagnostic . Errors . Add (
363- new GenerationError
364- {
365- ExceptionType = e . GetType ( ) . Name ,
366- Message = e . Message
367- } ) ;
368- }
369- }
341+ OperationGenerationDiagnostics = operationGenerationDiagnostics
342+ } ) ;
370343 }
344+ }
371345
372- var failedOperations = generationDiagnostic . OperationGenerationDiagnostics
373- . Where ( i => i . Errors . Count > 0 ) ;
374-
375- if ( failedOperations . Any ( ) )
346+ if ( documentConfigElement != null )
347+ {
348+ foreach ( var documentConfigFilter in _documentConfigFilters )
376349 {
377- var totalOperationsCount = generationDiagnostic . OperationGenerationDiagnostics . Count ( ) ;
350+ try
351+ {
352+ documentConfigFilter . Apply (
353+ documents ,
354+ documentConfigElement ,
355+ annotationXmlDocuments ,
356+ new DocumentConfigFilterSettings ( ) ) ;
357+ }
358+ catch ( Exception e )
359+ {
360+ documentGenerationDiagnostic . Errors . Add (
361+ new GenerationError
362+ {
363+ ExceptionType = e . GetType ( ) . Name ,
364+ Message = e . Message
365+ } ) ;
366+ }
367+ }
368+ }
378369
379- var exception = new UnableToGenerateAllOperationsException (
380- totalOperationsCount - failedOperations . Count ( ) , totalOperationsCount ) ;
370+ var failedOperations = generationDiagnostic . OperationGenerationDiagnostics
371+ . Where ( i => i . Errors . Count > 0 ) ;
381372
382- documentGenerationDiagnostic . Errors . Add (
383- new GenerationError
384- {
385- ExceptionType = exception . GetType ( ) . Name ,
386- Message = exception . Message
387- } ) ;
388- }
373+ if ( failedOperations . Any ( ) )
374+ {
375+ var totalOperationsCount = generationDiagnostic . OperationGenerationDiagnostics . Count ( ) ;
376+
377+ var exception = new UnableToGenerateAllOperationsException (
378+ totalOperationsCount - failedOperations . Count ( ) , totalOperationsCount ) ;
389379
390- generationDiagnostic . DocumentGenerationDiagnostic = documentGenerationDiagnostic ;
391- return documents ;
380+ documentGenerationDiagnostic . Errors . Add (
381+ new GenerationError
382+ {
383+ ExceptionType = exception . GetType ( ) . Name ,
384+ Message = exception . Message
385+ } ) ;
392386 }
387+
388+ generationDiagnostic . DocumentGenerationDiagnostic = documentGenerationDiagnostic ;
389+ return documents ;
393390 }
394391 catch ( Exception e )
395392 {
0 commit comments