File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
src/Microsoft.OpenApi.YamlReader Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -151,10 +151,19 @@ private static YamlScalarNode ToYamlScalar(this JsonValue val)
151151 // Strings that look like numbers, booleans, or null need to be quoted
152152 // to preserve their string type when round-tripping
153153 var needsQuoting = NeedsQuoting ( stringValue ) ;
154+
155+ var containsNewLine = stringValue . Contains ( '\n ' ) ;
156+
157+ var style = ( needsQuoting , containsNewLine ) switch
158+ {
159+ ( true , _ ) => ScalarStyle . DoubleQuoted ,
160+ ( false , true ) => ScalarStyle . Literal ,
161+ ( false , false ) => ScalarStyle . Plain
162+ } ;
154163
155164 return new YamlScalarNode ( stringValue )
156165 {
157- Style = needsQuoting ? ScalarStyle . DoubleQuoted : ScalarStyle . Plain
166+ Style = style
158167 } ;
159168 }
160169
You can’t perform that action at this time.
0 commit comments