File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change 1
1
// Copyright (c) Microsoft Corporation. All rights reserved.
2
2
// Licensed under the MIT license.
3
3
4
+ using System . Globalization ;
4
5
using System . IO ;
5
6
using Microsoft . OpenApi . Exceptions ;
6
7
using Microsoft . OpenApi . Interfaces ;
@@ -62,13 +63,14 @@ public static void Serialize<T>(
62
63
}
63
64
64
65
IOpenApiWriter writer ;
66
+ var streamWriter = new FormattingStreamWriter ( stream , CultureInfo . InvariantCulture ) ;
65
67
switch ( format )
66
68
{
67
69
case OpenApiFormat . Json :
68
- writer = new OpenApiJsonWriter ( new StreamWriter ( stream ) ) ;
70
+ writer = new OpenApiJsonWriter ( streamWriter ) ;
69
71
break ;
70
72
case OpenApiFormat . Yaml :
71
- writer = new OpenApiYamlWriter ( new StreamWriter ( stream ) ) ;
73
+ writer = new OpenApiYamlWriter ( streamWriter ) ;
72
74
break ;
73
75
default :
74
76
throw new OpenApiException ( string . Format ( SRResource . OpenApiFormatNotSupported , format ) ) ;
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . IO ;
4
+ using System . Linq ;
5
+ using System . Text ;
6
+ using System . Threading . Tasks ;
7
+
8
+ namespace Microsoft . OpenApi . Writers
9
+ {
10
+ public class FormattingStreamWriter : StreamWriter
11
+ {
12
+ public FormattingStreamWriter ( Stream stream , IFormatProvider formatProvider )
13
+ : base ( stream )
14
+ {
15
+ this . FormatProvider = formatProvider ;
16
+ }
17
+
18
+ public override IFormatProvider FormatProvider { get ; }
19
+ }
20
+ }
You can’t perform that action at this time.
0 commit comments