We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 314dd38 commit b053848Copy full SHA for b053848
1 file changed
src/Microsoft.OpenApi.YamlReader/YamlConverter.cs
@@ -151,10 +151,19 @@ private static YamlScalarNode ToYamlScalar(this JsonValue val)
151
// Strings that look like numbers, booleans, or null need to be quoted
152
// to preserve their string type when round-tripping
153
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
+ };
163
164
return new YamlScalarNode(stringValue)
165
{
- Style = needsQuoting ? ScalarStyle.DoubleQuoted : ScalarStyle.Plain
166
+ Style = style
167
};
168
}
169
0 commit comments