diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs
index d698bd5b2..93c39a738 100644
--- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs
+++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs
@@ -664,18 +664,21 @@ internal static void WriteTreeDocumentAsHtml(string sourceUrl, OpenApiDocument d
{
var rootNode = OpenApiUrlTreeNode.Create(document, "main");
- writer.WriteLine(@"
-
-
-
-
-
-
-");
+ writer.WriteLine(
+ """
+
+
+
+
+
+
+
+
+ """);
writer.WriteLine("" + document.Info.Title + "
");
writer.WriteLine();
writer.WriteLine($"");
@@ -686,6 +689,7 @@ internal static void WriteTreeDocumentAsHtml(string sourceUrl, OpenApiDocument d
{
writer.WriteLine($"{style.Key.Replace("_", " ", StringComparison.OrdinalIgnoreCase)}");
}
+
writer.WriteLine("");
writer.WriteLine("
");
writer.WriteLine("");
@@ -693,18 +697,21 @@ internal static void WriteTreeDocumentAsHtml(string sourceUrl, OpenApiDocument d
writer.WriteLine("");
// Write script tag to include JS library for rendering markdown
- writer.WriteLine(@"");
+ writer.WriteLine(
+ """
+
+ """);
// Write script tag to include JS library for rendering mermaid
writer.WriteLine(" {
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiContactTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiContactTests.cs
index 71489d39f..c80c05a4f 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiContactTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiContactTests.cs
@@ -13,13 +13,14 @@ public class OpenApiContactTests
[Fact]
public void ParseStringContactFragmentShouldSucceed()
{
- var input = @"
-{
- ""name"": ""API Support"",
- ""url"": ""http://www.swagger.io/support"",
- ""email"": ""support@swagger.io""
-}
-";
+ var input =
+ """
+ {
+ "name": "API Support",
+ "url": "http://www.swagger.io/support",
+ "email": "support@swagger.io"
+ }
+ """;
var reader = new OpenApiStringReader();
var diagnostic = new OpenApiDiagnostic();
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs
index 4acdb583f..1d01c6a33 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs
@@ -22,26 +22,24 @@ public class OpenApiDocumentTests
{
private const string SampleFolderPath = "V2Tests/Samples/";
-
-
-
[Fact]
public void ShouldThrowWhenReferenceTypeIsInvalid()
{
- var input = @"
-swagger: 2.0
-info:
- title: test
- version: 1.0.0
-paths:
- '/':
- get:
- responses:
- '200':
- description: ok
- schema:
- $ref: '#/defi888nition/does/notexist'
-";
+ var input =
+ """
+ swagger: 2.0
+ info:
+ title: test
+ version: 1.0.0
+ paths:
+ '/':
+ get:
+ responses:
+ '200':
+ description: ok
+ schema:
+ $ref: '#/defi888nition/does/notexist'
+ """;
var reader = new OpenApiStringReader();
var doc = reader.Read(input, out var diagnostic);
@@ -54,21 +52,22 @@ public void ShouldThrowWhenReferenceTypeIsInvalid()
[Fact]
public void ShouldThrowWhenReferenceDoesNotExist()
{
- var input = @"
-swagger: 2.0
-info:
- title: test
- version: 1.0.0
-paths:
- '/':
- get:
- produces: ['application/json']
- responses:
- '200':
- description: ok
- schema:
- $ref: '#/definitions/doesnotexist'
-";
+ var input =
+ """
+ swagger: 2.0
+ info:
+ title: test
+ version: 1.0.0
+ paths:
+ '/':
+ get:
+ produces: ['application/json']
+ responses:
+ '200':
+ description: ok
+ schema:
+ $ref: '#/definitions/doesnotexist'
+ """;
var reader = new OpenApiStringReader();
@@ -91,23 +90,24 @@ public void ParseDocumentWithDifferentCultureShouldSucceed(string culture)
Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);
var openApiDoc = new OpenApiStringReader().Read(
- @"
-swagger: 2.0
-info:
- title: Simple Document
- version: 0.9.1
- x-extension: 2.335
-definitions:
- sampleSchema:
- type: object
- properties:
- sampleProperty:
- type: double
- minimum: 100.54
- maximum: 60000000.35
- exclusiveMaximum: true
- exclusiveMinimum: false
-paths: {}",
+ """
+ swagger: 2.0
+ info:
+ title: Simple Document
+ version: 0.9.1
+ x-extension: 2.335
+ definitions:
+ sampleSchema:
+ type: object
+ properties:
+ sampleProperty:
+ type: double
+ minimum: 100.54
+ maximum: 60000000.35
+ exclusiveMaximum: true
+ exclusiveMinimum: false
+ paths: {}
+ """,
out var context);
openApiDoc.Should().BeEquivalentTo(
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiServerTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiServerTests.cs
index 5037007a2..f809219e7 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiServerTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiServerTests.cs
@@ -11,13 +11,14 @@ public class OpenApiServerTests
[Fact]
public void NoServer()
{
- var input = @"
-swagger: 2.0
-info:
- title: test
- version: 1.0.0
-paths: {}
-";
+ var input =
+ """
+ swagger: 2.0
+ info:
+ title: test
+ version: 1.0.0
+ paths: {}
+ """;
var reader = new OpenApiStringReader(new OpenApiReaderSettings
{
});
@@ -30,15 +31,16 @@ public void NoServer()
[Fact]
public void JustSchemeNoDefault()
{
- var input = @"
-swagger: 2.0
-info:
- title: test
- version: 1.0.0
-schemes:
- - http
-paths: {}
-";
+ var input =
+ """
+ swagger: 2.0
+ info:
+ title: test
+ version: 1.0.0
+ schemes:
+ - http
+ paths: {}
+ """;
var reader = new OpenApiStringReader(new OpenApiReaderSettings
{
});
@@ -51,14 +53,15 @@ public void JustSchemeNoDefault()
[Fact]
public void JustHostNoDefault()
{
- var input = @"
-swagger: 2.0
-info:
- title: test
- version: 1.0.0
-host: www.foo.com
-paths: {}
-";
+ var input =
+ """
+ swagger: 2.0
+ info:
+ title: test
+ version: 1.0.0
+ host: www.foo.com
+ paths: {}
+ """;
var reader = new OpenApiStringReader(new OpenApiReaderSettings
{
});
@@ -73,16 +76,17 @@ public void JustHostNoDefault()
[Fact]
public void NoBasePath()
{
- var input = @"
-swagger: 2.0
-info:
- title: test
- version: 1.0.0
-host: www.foo.com
-schemes:
- - http
-paths: {}
-";
+ var input =
+ """
+ swagger: 2.0
+ info:
+ title: test
+ version: 1.0.0
+ host: www.foo.com
+ schemes:
+ - http
+ paths: {}
+ """;
var reader = new OpenApiStringReader(new OpenApiReaderSettings
{
BaseUrl = new Uri("https://www.foo.com/spec.yaml")
@@ -98,14 +102,15 @@ public void NoBasePath()
[Fact]
public void JustBasePathNoDefault()
{
- var input = @"
-swagger: 2.0
-info:
- title: test
- version: 1.0.0
-basePath: /baz
-paths: {}
-";
+ var input =
+ """
+ swagger: 2.0
+ info:
+ title: test
+ version: 1.0.0
+ basePath: /baz
+ paths: {}
+ """;
var reader = new OpenApiStringReader(new OpenApiReaderSettings
{
});
@@ -120,15 +125,16 @@ public void JustBasePathNoDefault()
[Fact]
public void JustSchemeWithCustomHost()
{
- var input = @"
-swagger: 2.0
-info:
- title: test
- version: 1.0.0
-schemes:
- - http
-paths: {}
-";
+ var input =
+ """
+ swagger: 2.0
+ info:
+ title: test
+ version: 1.0.0
+ schemes:
+ - http
+ paths: {}
+ """;
var reader = new OpenApiStringReader(new OpenApiReaderSettings
{
BaseUrl = new Uri("https://bing.com/foo")
@@ -144,15 +150,16 @@ public void JustSchemeWithCustomHost()
[Fact]
public void JustSchemeWithCustomHostWithEmptyPath()
{
- var input = @"
-swagger: 2.0
-info:
- title: test
- version: 1.0.0
-schemes:
- - http
-paths: {}
-";
+ var input =
+ """
+ swagger: 2.0
+ info:
+ title: test
+ version: 1.0.0
+ schemes:
+ - http
+ paths: {}
+ """;
var reader = new OpenApiStringReader(new OpenApiReaderSettings
{
BaseUrl = new Uri("https://bing.com")
@@ -168,14 +175,15 @@ public void JustSchemeWithCustomHostWithEmptyPath()
[Fact]
public void JustBasePathWithCustomHost()
{
- var input = @"
-swagger: 2.0
-info:
- title: test
- version: 1.0.0
-basePath: /api
-paths: {}
-";
+ var input =
+ """
+ swagger: 2.0
+ info:
+ title: test
+ version: 1.0.0
+ basePath: /api
+ paths: {}
+ """;
var reader = new OpenApiStringReader(new OpenApiReaderSettings
{
BaseUrl = new Uri("https://bing.com")
@@ -191,14 +199,15 @@ public void JustBasePathWithCustomHost()
[Fact]
public void JustHostWithCustomHost()
{
- var input = @"
-swagger: 2.0
-info:
- title: test
- version: 1.0.0
-host: www.example.com
-paths: {}
-";
+ var input =
+ """
+ swagger: 2.0
+ info:
+ title: test
+ version: 1.0.0
+ host: www.example.com
+ paths: {}
+ """;
var reader = new OpenApiStringReader(new OpenApiReaderSettings
{
BaseUrl = new Uri("https://bing.com")
@@ -214,14 +223,15 @@ public void JustHostWithCustomHost()
[Fact]
public void JustHostWithCustomHostWithApi()
{
- var input = @"
-swagger: 2.0
-info:
- title: test
- version: 1.0.0
-host: prod.bing.com
-paths: {}
-";
+ var input =
+ """
+ swagger: 2.0
+ info:
+ title: test
+ version: 1.0.0
+ host: prod.bing.com
+ paths: {}
+ """;
var reader = new OpenApiStringReader(new OpenApiReaderSettings
{
BaseUrl = new Uri("https://dev.bing.com/api/description.yaml")
@@ -237,16 +247,17 @@ public void JustHostWithCustomHostWithApi()
[Fact]
public void MultipleServers()
{
- var input = @"
-swagger: 2.0
-info:
- title: test
- version: 1.0.0
-schemes:
- - http
- - https
-paths: {}
-";
+ var input =
+ """
+ swagger: 2.0
+ info:
+ title: test
+ version: 1.0.0
+ schemes:
+ - http
+ - https
+ paths: {}
+ """;
var reader = new OpenApiStringReader(new OpenApiReaderSettings
{
BaseUrl = new Uri("https://dev.bing.com/api")
@@ -263,14 +274,15 @@ public void MultipleServers()
[Fact]
public void LocalHostWithCustomHost()
{
- var input = @"
-swagger: 2.0
-info:
- title: test
- version: 1.0.0
-host: localhost:23232
-paths: {}
-";
+ var input =
+ """
+ swagger: 2.0
+ info:
+ title: test
+ version: 1.0.0
+ host: localhost:23232
+ paths: {}
+ """;
var reader = new OpenApiStringReader(new OpenApiReaderSettings
{
BaseUrl = new Uri("https://bing.com")
@@ -286,14 +298,15 @@ public void LocalHostWithCustomHost()
[Fact]
public void InvalidHostShouldYieldError()
{
- var input = @"
-swagger: 2.0
-info:
- title: test
- version: 1.0.0
-host: http://test.microsoft.com
-paths: {}
-";
+ var input =
+ """
+ swagger: 2.0
+ info:
+ title: test
+ version: 1.0.0
+ host: http://test.microsoft.com
+ paths: {}
+ """;
var reader = new OpenApiStringReader(new OpenApiReaderSettings
{
BaseUrl = new Uri("https://bing.com")
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiContactTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiContactTests.cs
index be78f942b..7e4cfad75 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiContactTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiContactTests.cs
@@ -13,13 +13,14 @@ public class OpenApiContactTests
[Fact]
public void ParseStringContactFragmentShouldSucceed()
{
- var input = @"
-{
- ""name"": ""API Support"",
- ""url"": ""http://www.swagger.io/support"",
- ""email"": ""support@swagger.io""
-}
-";
+ var input =
+ """
+ {
+ "name": "API Support",
+ "url": "http://www.swagger.io/support",
+ "email": "support@swagger.io"
+ }
+ """;
var reader = new OpenApiStringReader();
var diagnostic = new OpenApiDiagnostic();
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs
index 85a686e49..b4f1a16ff 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs
@@ -84,12 +84,14 @@ public OpenApiDocumentTests(ITestOutputHelper output)
public void ParseDocumentFromInlineStringShouldSucceed()
{
var openApiDoc = new OpenApiStringReader().Read(
- @"
-openapi : 3.0.0
-info:
- title: Simple Document
- version: 0.9.1
-paths: {}",
+ """
+
+ openapi : 3.0.0
+ info:
+ title: Simple Document
+ version: 0.9.1
+ paths: {}
+ """,
out var context);
openApiDoc.Should().BeEquivalentTo(
@@ -119,23 +121,24 @@ public void ParseDocumentWithDifferentCultureShouldSucceed(string culture)
Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);
var openApiDoc = new OpenApiStringReader().Read(
- @"
-openapi : 3.0.0
-info:
- title: Simple Document
- version: 0.9.1
-components:
- schemas:
- sampleSchema:
- type: object
- properties:
- sampleProperty:
- type: double
- minimum: 100.54
- maximum: 60000000.35
- exclusiveMaximum: true
- exclusiveMinimum: false
-paths: {}",
+ """
+ openapi : 3.0.0
+ info:
+ title: Simple Document
+ version: 0.9.1
+ components:
+ schemas:
+ sampleSchema:
+ type: object
+ properties:
+ sampleProperty:
+ type: double
+ minimum: 100.54
+ maximum: 60000000.35
+ exclusiveMaximum: true
+ exclusiveMinimum: false
+ paths: {}
+ """,
out var context);
openApiDoc.Should().BeEquivalentTo(
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs
index 54553d5a5..087a61fef 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs
@@ -74,12 +74,14 @@ public void ParsePrimitiveSchemaFragmentShouldSucceed()
[Fact]
public void ParsePrimitiveStringSchemaFragmentShouldSucceed()
{
- var input = @"
-{ ""type"": ""integer"",
-""format"": ""int64"",
-""default"": 88
-}
-";
+ var input =
+ """
+ {
+ "type": "integer",
+ "format": "int64",
+ "default": 88
+ }
+ """;
var reader = new OpenApiStringReader();
var diagnostic = new OpenApiDiagnostic();
@@ -101,11 +103,13 @@ public void ParsePrimitiveStringSchemaFragmentShouldSucceed()
[Fact]
public void ParseExampleStringFragmentShouldSucceed()
{
- var input = @"
-{
- ""foo"": ""bar"",
- ""baz"": [ 1,2]
-}";
+ var input =
+ """
+ {
+ "foo": "bar",
+ "baz": [ 1,2]
+ }
+ """;
var reader = new OpenApiStringReader();
var diagnostic = new OpenApiDiagnostic();
@@ -130,11 +134,13 @@ public void ParseExampleStringFragmentShouldSucceed()
[Fact]
public void ParseEnumFragmentShouldSucceed()
{
- var input = @"
-[
- ""foo"",
- ""baz""
-]";
+ var input =
+ """
+ [
+ "foo",
+ "baz"
+ ]
+ """;
var reader = new OpenApiStringReader();
var diagnostic = new OpenApiDiagnostic();
@@ -205,13 +211,14 @@ public void ParseSimpleSchemaShouldSucceed()
[Fact]
public void ParsePathFragmentShouldSucceed()
{
- var input = @"
-summary: externally referenced path item
-get:
- responses:
- '200':
- description: Ok
-";
+ var input =
+ """
+ summary: externally referenced path item
+ get:
+ responses:
+ '200':
+ description: Ok
+ """;
var reader = new OpenApiStringReader();
var diagnostic = new OpenApiDiagnostic();
diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs
index 46a6bb772..879e89cef 100644
--- a/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs
@@ -286,41 +286,44 @@ public void SerializeBasicComponentsAsYamlWorks()
public void SerializeAdvancedComponentsAsJsonV3Works()
{
// Arrange
- var expected = @"{
- ""schemas"": {
- ""schema1"": {
- ""properties"": {
- ""property2"": {
- ""type"": ""integer""
- },
- ""property3"": {
- ""maxLength"": 15,
- ""type"": ""string""
- }
- }
- }
- },
- ""securitySchemes"": {
- ""securityScheme1"": {
- ""type"": ""oauth2"",
- ""description"": ""description1"",
- ""flows"": {
- ""implicit"": {
- ""authorizationUrl"": ""https://example.com/api/oauth"",
- ""scopes"": {
- ""operation1:object1"": ""operation 1 on object 1"",
- ""operation2:object2"": ""operation 2 on object 2""
- }
- }
- }
- },
- ""securityScheme2"": {
- ""type"": ""openIdConnect"",
- ""description"": ""description1"",
- ""openIdConnectUrl"": ""https://example.com/openIdConnect""
- }
- }
-}";
+ var expected =
+ """
+ {
+ "schemas": {
+ "schema1": {
+ "properties": {
+ "property2": {
+ "type": "integer"
+ },
+ "property3": {
+ "maxLength": 15,
+ "type": "string"
+ }
+ }
+ }
+ },
+ "securitySchemes": {
+ "securityScheme1": {
+ "type": "oauth2",
+ "description": "description1",
+ "flows": {
+ "implicit": {
+ "authorizationUrl": "https://example.com/api/oauth",
+ "scopes": {
+ "operation1:object1": "operation 1 on object 1",
+ "operation2:object2": "operation 2 on object 2"
+ }
+ }
+ }
+ },
+ "securityScheme2": {
+ "type": "openIdConnect",
+ "description": "description1",
+ "openIdConnectUrl": "https://example.com/openIdConnect"
+ }
+ }
+ }
+ """;
// Act
var actual = AdvancedComponents.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0);
@@ -335,47 +338,50 @@ public void SerializeAdvancedComponentsAsJsonV3Works()
public void SerializeAdvancedComponentsWithReferenceAsJsonV3Works()
{
// Arrange
- var expected = @"{
- ""schemas"": {
- ""schema1"": {
- ""properties"": {
- ""property2"": {
- ""type"": ""integer""
- },
- ""property3"": {
- ""$ref"": ""#/components/schemas/schema2""
- }
- }
- },
- ""schema2"": {
- ""properties"": {
- ""property2"": {
- ""type"": ""integer""
- }
- }
- }
- },
- ""securitySchemes"": {
- ""securityScheme1"": {
- ""type"": ""oauth2"",
- ""description"": ""description1"",
- ""flows"": {
- ""implicit"": {
- ""authorizationUrl"": ""https://example.com/api/oauth"",
- ""scopes"": {
- ""operation1:object1"": ""operation 1 on object 1"",
- ""operation2:object2"": ""operation 2 on object 2""
- }
- }
- }
- },
- ""securityScheme2"": {
- ""type"": ""openIdConnect"",
- ""description"": ""description1"",
- ""openIdConnectUrl"": ""https://example.com/openIdConnect""
- }
- }
-}";
+ var expected =
+ """
+ {
+ "schemas": {
+ "schema1": {
+ "properties": {
+ "property2": {
+ "type": "integer"
+ },
+ "property3": {
+ "$ref": "#/components/schemas/schema2"
+ }
+ }
+ },
+ "schema2": {
+ "properties": {
+ "property2": {
+ "type": "integer"
+ }
+ }
+ }
+ },
+ "securitySchemes": {
+ "securityScheme1": {
+ "type": "oauth2",
+ "description": "description1",
+ "flows": {
+ "implicit": {
+ "authorizationUrl": "https://example.com/api/oauth",
+ "scopes": {
+ "operation1:object1": "operation 1 on object 1",
+ "operation2:object2": "operation 2 on object 2"
+ }
+ }
+ }
+ },
+ "securityScheme2": {
+ "type": "openIdConnect",
+ "description": "description1",
+ "openIdConnectUrl": "https://example.com/openIdConnect"
+ }
+ }
+ }
+ """;
// Act
var actual = AdvancedComponentsWithReference.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0);
@@ -390,28 +396,31 @@ public void SerializeAdvancedComponentsWithReferenceAsJsonV3Works()
public void SerializeAdvancedComponentsAsYamlV3Works()
{
// Arrange
- var expected = @"schemas:
- schema1:
- properties:
- property2:
- type: integer
- property3:
- maxLength: 15
- type: string
-securitySchemes:
- securityScheme1:
- type: oauth2
- description: description1
- flows:
- implicit:
- authorizationUrl: https://example.com/api/oauth
- scopes:
- operation1:object1: operation 1 on object 1
- operation2:object2: operation 2 on object 2
- securityScheme2:
- type: openIdConnect
- description: description1
- openIdConnectUrl: https://example.com/openIdConnect";
+ var expected =
+ """
+ schemas:
+ schema1:
+ properties:
+ property2:
+ type: integer
+ property3:
+ maxLength: 15
+ type: string
+ securitySchemes:
+ securityScheme1:
+ type: oauth2
+ description: description1
+ flows:
+ implicit:
+ authorizationUrl: https://example.com/api/oauth
+ scopes:
+ operation1:object1: operation 1 on object 1
+ operation2:object2: operation 2 on object 2
+ securityScheme2:
+ type: openIdConnect
+ description: description1
+ openIdConnectUrl: https://example.com/openIdConnect
+ """;
// Act
var actual = AdvancedComponents.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0);
@@ -426,31 +435,34 @@ public void SerializeAdvancedComponentsAsYamlV3Works()
public void SerializeAdvancedComponentsWithReferenceAsYamlV3Works()
{
// Arrange
- var expected = @"schemas:
- schema1:
- properties:
- property2:
- type: integer
- property3:
- $ref: '#/components/schemas/schema2'
- schema2:
- properties:
- property2:
- type: integer
-securitySchemes:
- securityScheme1:
- type: oauth2
- description: description1
- flows:
- implicit:
- authorizationUrl: https://example.com/api/oauth
- scopes:
- operation1:object1: operation 1 on object 1
- operation2:object2: operation 2 on object 2
- securityScheme2:
- type: openIdConnect
- description: description1
- openIdConnectUrl: https://example.com/openIdConnect";
+ var expected =
+ """
+ schemas:
+ schema1:
+ properties:
+ property2:
+ type: integer
+ property3:
+ $ref: '#/components/schemas/schema2'
+ schema2:
+ properties:
+ property2:
+ type: integer
+ securitySchemes:
+ securityScheme1:
+ type: oauth2
+ description: description1
+ flows:
+ implicit:
+ authorizationUrl: https://example.com/api/oauth
+ scopes:
+ operation1:object1: operation 1 on object 1
+ operation2:object2: operation 2 on object 2
+ securityScheme2:
+ type: openIdConnect
+ description: description1
+ openIdConnectUrl: https://example.com/openIdConnect
+ """;
// Act
var actual = AdvancedComponentsWithReference.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0);
@@ -465,27 +477,30 @@ public void SerializeAdvancedComponentsWithReferenceAsYamlV3Works()
public void SerializeBrokenComponentsAsJsonV3Works()
{
// Arrange
- var expected = @"{
- ""schemas"": {
- ""schema1"": {
- ""type"": ""string""
- },
- ""schema2"": null,
- ""schema3"": null,
- ""schema4"": {
- ""type"": ""string"",
- ""allOf"": [
- null,
- null,
- {
- ""type"": ""string""
- },
- null,
- null
- ]
- }
- }
-}";
+ var expected =
+ """
+ {
+ "schemas": {
+ "schema1": {
+ "type": "string"
+ },
+ "schema2": null,
+ "schema3": null,
+ "schema4": {
+ "type": "string",
+ "allOf": [
+ null,
+ null,
+ {
+ "type": "string"
+ },
+ null,
+ null
+ ]
+ }
+ }
+ }
+ """;
// Act
var actual = BrokenComponents.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0);
@@ -500,19 +515,22 @@ public void SerializeBrokenComponentsAsJsonV3Works()
public void SerializeBrokenComponentsAsYamlV3Works()
{
// Arrange
- var expected = @"schemas:
- schema1:
- type: string
- schema2:
- schema3:
- schema4:
- type: string
- allOf:
- -
- -
- - type: string
- -
- - ";
+ var expected =
+ """
+ schemas:
+ schema1:
+ type: string
+ schema2:
+ schema3:
+ schema4:
+ type: string
+ allOf:
+ -
+ -
+ - type: string
+ -
+ -
+ """;
// Act
var actual = BrokenComponents.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0);
@@ -527,14 +545,17 @@ public void SerializeBrokenComponentsAsYamlV3Works()
public void SerializeTopLevelReferencingComponentsAsYamlV3Works()
{
// Arrange
- var expected = @"schemas:
- schema1:
- $ref: '#/components/schemas/schema2'
- schema2:
- type: object
- properties:
- property1:
- type: string";
+ var expected =
+ """
+ schemas:
+ schema1:
+ $ref: '#/components/schemas/schema2'
+ schema2:
+ type: object
+ properties:
+ property1:
+ type: string
+ """;
// Act
var actual = TopLevelReferencingComponents.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0);
@@ -549,8 +570,11 @@ public void SerializeTopLevelReferencingComponentsAsYamlV3Works()
public void SerializeTopLevelSelfReferencingComponentsAsYamlV3Works()
{
// Arrange
- var expected = @"schemas:
- schema1: { }";
+ var expected =
+ """
+ schemas:
+ schema1: { }
+ """;
// Act
var actual = TopLevelSelfReferencingComponents.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0);
@@ -565,17 +589,20 @@ public void SerializeTopLevelSelfReferencingComponentsAsYamlV3Works()
public void SerializeTopLevelSelfReferencingWithOtherPropertiesComponentsAsYamlV3Works()
{
// Arrange
- var expected = @"schemas:
- schema1:
- type: object
- properties:
- property1:
- type: string
- schema2:
- type: object
- properties:
- property1:
- type: string";
+ var expected =
+ """
+ schemas:
+ schema1:
+ type: object
+ properties:
+ property1:
+ type: string
+ schema2:
+ type: object
+ properties:
+ property1:
+ type: string
+ """;
// Act
var actual = TopLevelSelfReferencingComponentsWithOtherProperties.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0);
diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs
index 1a99241d1..d1ffab249 100644
--- a/test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs
@@ -54,12 +54,14 @@ public void SerializeAdvanceContactAsJsonWorks(OpenApiSpecVersion version)
{
// Arrange
var expected =
- @"{
- ""name"": ""API Support"",
- ""url"": ""http://www.example.com/support"",
- ""email"": ""support@example.com"",
- ""x-internal-id"": 42
-}";
+ """
+ {
+ "name": "API Support",
+ "url": "http://www.example.com/support",
+ "email": "support@example.com",
+ "x-internal-id": 42
+ }
+ """;
// Act
var actual = AdvanceContact.SerializeAsJson(version);
@@ -77,10 +79,12 @@ public void SerializeAdvanceContactAsYamlWorks(OpenApiSpecVersion version)
{
// Arrange
var expected =
- @"name: API Support
-url: http://www.example.com/support
-email: support@example.com
-x-internal-id: 42";
+ """
+ name: API Support
+ url: http://www.example.com/support
+ email: support@example.com
+ x-internal-id: 42
+ """;
// Act
var actual = AdvanceContact.SerializeAsYaml(version);
diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs
index becc91d97..4fb3686fa 100644
--- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs
@@ -1410,18 +1410,21 @@ public async Task SerializeAdvancedDocumentWithReferenceAsV2JsonWorks(bool produ
public void SerializeSimpleDocumentWithTopLevelReferencingComponentsAsYamlV2Works()
{
// Arrange
- var expected = @"swagger: '2.0'
-info:
- version: 1.0.0
-paths: { }
-definitions:
- schema1:
- $ref: '#/definitions/schema2'
- schema2:
- type: object
- properties:
- property1:
- type: string";
+ var expected =
+ """
+ swagger: '2.0'
+ info:
+ version: 1.0.0
+ paths: { }
+ definitions:
+ schema1:
+ $ref: '#/definitions/schema2'
+ schema2:
+ type: object
+ properties:
+ property1:
+ type: string
+ """;
// Act
var actual = SimpleDocumentWithTopLevelReferencingComponents.SerializeAsYaml(OpenApiSpecVersion.OpenApi2_0);
@@ -1436,12 +1439,15 @@ public void SerializeSimpleDocumentWithTopLevelReferencingComponentsAsYamlV2Work
public void SerializeSimpleDocumentWithTopLevelSelfReferencingComponentsAsYamlV3Works()
{
// Arrange
- var expected = @"swagger: '2.0'
-info:
- version: 1.0.0
-paths: { }
-definitions:
- schema1: { }";
+ var expected =
+ """
+ swagger: '2.0'
+ info:
+ version: 1.0.0
+ paths: { }
+ definitions:
+ schema1: { }
+ """;
// Act
var actual = SimpleDocumentWithTopLevelSelfReferencingComponents.SerializeAsYaml(OpenApiSpecVersion.OpenApi2_0);
@@ -1456,21 +1462,24 @@ public void SerializeSimpleDocumentWithTopLevelSelfReferencingComponentsAsYamlV3
public void SerializeSimpleDocumentWithTopLevelSelfReferencingWithOtherPropertiesComponentsAsYamlV3Works()
{
// Arrange
- var expected = @"swagger: '2.0'
-info:
- version: 1.0.0
-paths: { }
-definitions:
- schema1:
- type: object
- properties:
- property1:
- type: string
- schema2:
- type: object
- properties:
- property1:
- type: string";
+ var expected =
+ """
+ swagger: '2.0'
+ info:
+ version: 1.0.0
+ paths: { }
+ definitions:
+ schema1:
+ type: object
+ properties:
+ property1:
+ type: string
+ schema2:
+ type: object
+ properties:
+ property1:
+ type: string
+ """;
// Act
var actual = SimpleDocumentWithTopLevelSelfReferencingComponentsWithOtherProperties.SerializeAsYaml(OpenApiSpecVersion.OpenApi2_0);
@@ -1541,11 +1550,13 @@ public void SerializeRelativePathAsV2JsonWorks()
{
// Arrange
var expected =
- @"swagger: '2.0'
-info:
- version: 1.0.0
-basePath: /server1
-paths: { }";
+ """
+ swagger: '2.0'
+ info:
+ version: 1.0.0
+ basePath: /server1
+ paths: { }
+ """;
var doc = new OpenApiDocument
{
Info = new OpenApiInfo { Version = "1.0.0" },
@@ -1572,12 +1583,14 @@ public void SerializeRelativePathWithHostAsV2JsonWorks()
{
// Arrange
var expected =
- @"swagger: '2.0'
-info:
- version: 1.0.0
-host: //example.org
-basePath: /server1
-paths: { }";
+ """
+ swagger: '2.0'
+ info:
+ version: 1.0.0
+ host: //example.org
+ basePath: /server1
+ paths: { }
+ """;
var doc = new OpenApiDocument
{
Info = new OpenApiInfo { Version = "1.0.0" },
@@ -1604,11 +1617,13 @@ public void SerializeRelativeRootPathWithHostAsV2JsonWorks()
{
// Arrange
var expected =
- @"swagger: '2.0'
-info:
- version: 1.0.0
-host: //example.org
-paths: { }";
+ """
+ swagger: '2.0'
+ info:
+ version: 1.0.0
+ host: //example.org
+ paths: { }
+ """;
var doc = new OpenApiDocument
{
Info = new OpenApiInfo { Version = "1.0.0" },
@@ -1683,15 +1698,18 @@ private static OpenApiDocument ParseInputFile(string filePath)
public void SerializeV2DocumentWithNonArraySchemaTypeDoesNotWriteOutCollectionFormat()
{
// Arrange
- var expected = @"swagger: '2.0'
-info: { }
-paths:
- /foo:
- get:
- parameters:
- - in: query
- type: string
- responses: { }";
+ var expected =
+ """
+ swagger: '2.0'
+ info: { }
+ paths:
+ /foo:
+ get:
+ parameters:
+ - in: query
+ type: string
+ responses: { }
+ """;
var doc = new OpenApiDocument
{
@@ -1735,27 +1753,30 @@ public void SerializeV2DocumentWithNonArraySchemaTypeDoesNotWriteOutCollectionFo
public void SerializeV2DocumentWithStyleAsNullDoesNotWriteOutStyleValue()
{
// Arrange
- var expected = @"openapi: 3.0.1
-info:
- title: magic style
- version: 1.0.0
-paths:
- /foo:
- get:
- parameters:
- - name: id
- in: query
- schema:
- type: object
- additionalProperties:
- type: integer
- responses:
- '200':
- description: foo
- content:
- text/plain:
- schema:
- type: string";
+ var expected =
+ """
+ openapi: 3.0.1
+ info:
+ title: magic style
+ version: 1.0.0
+ paths:
+ /foo:
+ get:
+ parameters:
+ - name: id
+ in: query
+ schema:
+ type: object
+ additionalProperties:
+ type: integer
+ responses:
+ '200':
+ description: foo
+ content:
+ text/plain:
+ schema:
+ type: string
+ """;
var doc = new OpenApiDocument
{
diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiEncodingTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiEncodingTests.cs
index 24bfca242..9f273f280 100644
--- a/test/Microsoft.OpenApi.Tests/Models/OpenApiEncodingTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiEncodingTests.cs
@@ -40,12 +40,14 @@ public void SerializeAdvanceEncodingAsV3JsonWorks()
{
// Arrange
var expected =
- @"{
- ""contentType"": ""image/png, image/jpeg"",
- ""style"": ""simple"",
- ""explode"": true,
- ""allowReserved"": true
-}";
+ """
+ {
+ "contentType": "image/png, image/jpeg",
+ "style": "simple",
+ "explode": true,
+ "allowReserved": true
+ }
+ """;
// Act
var actual = AdvanceEncoding.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0);
@@ -61,10 +63,12 @@ public void SerializeAdvanceEncodingAsV3YamlWorks()
{
// Arrange
var expected =
- @"contentType: 'image/png, image/jpeg'
-style: simple
-explode: true
-allowReserved: true";
+ """
+ contentType: 'image/png, image/jpeg'
+ style: simple
+ explode: true
+ allowReserved: true
+ """;
// Act
var actual = AdvanceEncoding.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0);
diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExternalDocsTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiExternalDocsTests.cs
index 7d37fc9a4..a9ba66e88 100644
--- a/test/Microsoft.OpenApi.Tests/Models/OpenApiExternalDocsTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExternalDocsTests.cs
@@ -41,10 +41,12 @@ public void SerializeAdvanceExDocsAsV3JsonWorks()
{
// Arrange
var expected =
- @"{
- ""description"": ""Find more info here"",
- ""url"": ""https://example.com""
-}";
+ """
+ {
+ "description": "Find more info here",
+ "url": "https://example.com"
+ }
+ """;
// Act
var actual = AdvanceExDocs.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0);
@@ -60,8 +62,10 @@ public void SerializeAdvanceExDocsAsV3YamlWorks()
{
// Arrange
var expected =
- @"description: Find more info here
-url: https://example.com";
+ """
+ description: Find more info here
+ url: https://example.com
+ """;
// Act
var actual = AdvanceExDocs.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0);
diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs
index b2395a9ed..a28ea2598 100644
--- a/test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs
@@ -43,10 +43,12 @@ public static IEnumerable