From 4b341a04bfcba7242eb7ca424c3ba1e97ee381e5 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 2 Oct 2023 19:18:24 +1100 Subject: [PATCH] remove some redundant braces --- .../Formatters/PowerShellFormatter.cs | 2 +- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 4 +- src/Microsoft.OpenApi.Hidi/Program.cs | 2 +- .../OpenApiYamlDocumentReader.cs | 4 +- .../ParseNodes/MapNode.cs | 4 +- .../V2/OpenApiDocumentDeserializer.cs | 6 +- .../V2/OpenApiOperationDeserializer.cs | 4 +- .../V2/OpenApiPathItemDeserializer.cs | 2 +- .../OpenApiSecurityRequirementDeserializer.cs | 4 +- .../V3/OpenApiDocumentDeserializer.cs | 2 +- .../V3/OpenApiOperationDeserializer.cs | 4 +- .../V3/OpenApiPathItemDeserializer.cs | 2 +- .../V3/OpenApiSchemaDeserializer.cs | 2 +- .../OpenApiSecurityRequirementDeserializer.cs | 4 +- src/Microsoft.OpenApi.Workbench/MainModel.cs | 3 +- .../OpenApiPrimaryErrorMessageExtension.cs | 3 +- .../Services/OpenApiReferenceResolver.cs | 4 +- .../Services/OperationSearch.cs | 2 +- .../Formatters/PowerShellFormatterTests.cs | 15 +- .../Services/OpenApiFilterServiceTests.cs | 7 +- .../Services/OpenApiServiceTests.cs | 6 +- .../UtilityFiles/OpenApiDocumentMock.cs | 134 +++++++++--------- .../OpenApiDiagnosticTests.cs | 2 +- .../OpenApiWorkspaceStreamTests.cs | 4 +- .../ParseNodeTests.cs | 6 +- .../ParseNodes/OpenApiAnyConverterTests.cs | 128 ++++++++--------- .../TryLoadReferenceV2Tests.cs | 4 +- .../TestCustomExtension.cs | 5 +- .../V2Tests/OpenApiDocumentTests.cs | 26 ++-- .../V2Tests/OpenApiHeaderTests.cs | 4 +- .../V2Tests/OpenApiOperationTests.cs | 30 ++-- .../V2Tests/OpenApiParameterTests.cs | 18 +-- .../V2Tests/OpenApiPathItemTests.cs | 8 +- .../V2Tests/OpenApiServerTests.cs | 26 ++-- .../V3Tests/OpenApiCallbackTests.cs | 20 +-- .../V3Tests/OpenApiDocumentTests.cs | 46 +++--- .../V3Tests/OpenApiMediaTypeTests.cs | 4 +- .../V3Tests/OpenApiOperationTests.cs | 4 +- .../V3Tests/OpenApiParameterTests.cs | 4 +- .../V3Tests/OpenApiSchemaTests.cs | 37 ++--- test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs | 2 +- .../GraphTests.cs | 2 +- .../Expressions/RuntimeExpressionTests.cs | 4 +- .../Models/OpenApiComponentsTests.cs | 18 +-- .../Models/OpenApiDocumentTests.cs | 61 ++++---- .../Models/OpenApiOperationTests.cs | 36 ++--- .../Models/OpenApiSchemaTests.cs | 8 +- .../PublicApi/PublicApiTests.cs | 2 +- .../Services/OpenApiUrlTreeNodeTests.cs | 69 ++++----- .../Services/OpenApiValidatorTests.cs | 8 +- .../OpenApiComponentsValidationTests.cs | 2 +- .../OpenApiContactValidationTests.cs | 2 +- .../OpenApiHeaderValidationTests.cs | 26 ++-- .../OpenApiMediaTypeValidationTests.cs | 26 ++-- .../OpenApiParameterValidationTests.cs | 36 ++--- .../OpenApiReferenceValidationTests.cs | 48 +++---- .../OpenApiSchemaValidationTests.cs | 38 ++--- .../Walkers/WalkerLocationTests.cs | 63 ++++---- .../Workspaces/OpenApiReferencableTests.cs | 4 +- .../Workspaces/OpenApiWorkspaceTests.cs | 49 ++++--- .../Writers/OpenApiYamlWriterTests.cs | 30 ++-- 61 files changed, 578 insertions(+), 552 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs b/src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs index 450a05d21..4db55a05e 100644 --- a/src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs +++ b/src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs @@ -179,7 +179,7 @@ private void AddAdditionalPropertiesToSchema(OpenApiSchema schema) { if (schema != null && !_schemaLoop.Contains(schema) && "object".Equals(schema.Type, StringComparison.OrdinalIgnoreCase)) { - schema.AdditionalProperties = new OpenApiSchema() { Type = "object" }; + schema.AdditionalProperties = new OpenApiSchema { Type = "object" }; /* Because 'additionalProperties' are now being walked, * we need a way to keep track of visited schemas to avoid diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index b3e66cfe2..63a8bbb94 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -186,7 +186,7 @@ private static void WriteOpenApi(HidiOptions options, OpenApiFormat openApiForma using var outputStream = options.Output.Create(); using var textWriter = new StreamWriter(outputStream); - var settings = new OpenApiWriterSettings() + var settings = new OpenApiWriterSettings { InlineLocalReferences = options.InlineLocal, InlineExternalReferences = options.InlineExternal @@ -738,7 +738,7 @@ internal static async Task PluginManifest(HidiOptions options, ILogger logger, C WriteOpenApi(options, OpenApiFormat.Json, OpenApiSpecVersion.OpenApi3_0, document, logger); // Create OpenAIPluginManifest from ApiDependency and OpenAPI document - var manifest = new OpenAIPluginManifest() + var manifest = new OpenAIPluginManifest { NameForHuman = document.Info.Title, DescriptionForHuman = document.Info.Description, diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index b8508ab5f..faf09352f 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -22,7 +22,7 @@ static async Task Main(string[] args) internal static RootCommand CreateRootCommand() { - var rootCommand = new RootCommand() { }; + var rootCommand = new RootCommand { }; var commandOptions = new CommandOptions(); diff --git a/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs b/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs index 4a120cbbf..5537366d0 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs @@ -133,7 +133,7 @@ public async Task ReadAsync(YamlDocument input, CancellationToken ca } } - return new ReadResult() + return new ReadResult { OpenApiDocument = document, OpenApiDiagnostic = diagnostic @@ -148,7 +148,7 @@ private async Task LoadExternalRefs(OpenApiDocument document, // Load this root document into the workspace var streamLoader = new DefaultStreamLoader(_settings.BaseUrl); var workspaceLoader = new OpenApiWorkspaceLoader(openApiWorkSpace, _settings.CustomExternalLoader ?? streamLoader, _settings); - return await workspaceLoader.LoadAsync(new OpenApiReference() { ExternalResource = "/" }, document, cancellationToken); + return await workspaceLoader.LoadAsync(new OpenApiReference { ExternalResource = "/" }, document, cancellationToken); } private void ResolveReferences(OpenApiDiagnostic diagnostic, OpenApiDocument document) diff --git a/src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs b/src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs index 0ee5934ce..92c49726b 100644 --- a/src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs +++ b/src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs @@ -120,7 +120,7 @@ public override Dictionary CreateMapWithReference( // If the component isn't a reference to another component, then point it to itself. if (entry.value.Reference == null) { - entry.value.Reference = new OpenApiReference() + entry.value.Reference = new OpenApiReference { Type = referenceType, Id = entry.key @@ -184,7 +184,7 @@ public override string GetRaw() public T GetReferencedObject(ReferenceType referenceType, string referenceId) where T : IOpenApiReferenceable, new() { - return new T() + return new T { UnresolvedReference = true, Reference = Context.VersionService.ConvertToOpenApiReference(referenceId, referenceType) diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiDocumentDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiDocumentDeserializer.cs index fa3aa7224..806c96877 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiDocumentDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiDocumentDeserializer.cs @@ -220,7 +220,7 @@ private static string BuildUrl(string scheme, string host, string basePath) port = int.Parse(pieces.Last(), CultureInfo.InvariantCulture); } - var uriBuilder = new UriBuilder() + var uriBuilder = new UriBuilder { Scheme = scheme, Host = host, @@ -327,10 +327,10 @@ public override void Visit(OpenApiOperation operation) if (body != null) { operation.Parameters.Remove(body); - operation.RequestBody = new OpenApiRequestBody() + operation.RequestBody = new OpenApiRequestBody { UnresolvedReference = true, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id = body.Reference.Id, Type = ReferenceType.RequestBody diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiOperationDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiOperationDeserializer.cs index 1cf5b7ae8..cf54df8c3 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiOperationDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiOperationDeserializer.cs @@ -221,10 +221,10 @@ private static OpenApiTag LoadTagByReference( ParsingContext context, string tagName) { - var tagObject = new OpenApiTag() + var tagObject = new OpenApiTag { UnresolvedReference = true, - Reference = new OpenApiReference() { Id = tagName, Type = ReferenceType.Tag } + Reference = new OpenApiReference { Id = tagName, Type = ReferenceType.Tag } }; return tagObject; diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiPathItemDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiPathItemDeserializer.cs index d905ea42e..d9db5a8d8 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiPathItemDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiPathItemDeserializer.cs @@ -20,7 +20,7 @@ internal static partial class OpenApiV2Deserializer { "$ref", (o, n) => { - o.Reference = new OpenApiReference() { ExternalResource = n.GetScalarValue() }; + o.Reference = new OpenApiReference { ExternalResource = n.GetScalarValue() }; o.UnresolvedReference =true; } }, diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiSecurityRequirementDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiSecurityRequirementDeserializer.cs index c5e0776ee..c8384fb05 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiSecurityRequirementDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiSecurityRequirementDeserializer.cs @@ -45,10 +45,10 @@ private static OpenApiSecurityScheme LoadSecuritySchemeByReference( ParsingContext context, string schemeName) { - var securitySchemeObject = new OpenApiSecurityScheme() + var securitySchemeObject = new OpenApiSecurityScheme { UnresolvedReference = true, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id = schemeName, Type = ReferenceType.SecurityScheme diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiDocumentDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiDocumentDeserializer.cs index df1434cd9..d5c437148 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiDocumentDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiDocumentDeserializer.cs @@ -30,7 +30,7 @@ internal static partial class OpenApiV3Deserializer {"tags", (o, n) => {o.Tags = n.CreateList(LoadTag); foreach (var tag in o.Tags) { - tag.Reference = new OpenApiReference() + tag.Reference = new OpenApiReference { Id = tag.Name, Type = ReferenceType.Tag diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiOperationDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiOperationDeserializer.cs index 16f7a16f4..d6cd2e387 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiOperationDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiOperationDeserializer.cs @@ -112,10 +112,10 @@ private static OpenApiTag LoadTagByReference( ParsingContext context, string tagName) { - var tagObject = new OpenApiTag() + var tagObject = new OpenApiTag { UnresolvedReference = true, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Type = ReferenceType.Tag, Id = tagName diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiPathItemDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiPathItemDeserializer.cs index 371e7da80..698fe64cc 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiPathItemDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiPathItemDeserializer.cs @@ -18,7 +18,7 @@ internal static partial class OpenApiV3Deserializer { "$ref", (o,n) => { - o.Reference = new OpenApiReference() { ExternalResource = n.GetScalarValue() }; + o.Reference = new OpenApiReference { ExternalResource = n.GetScalarValue() }; o.UnresolvedReference =true; } }, diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiSchemaDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiSchemaDeserializer.cs index 60727c4bb..e5482e22f 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiSchemaDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiSchemaDeserializer.cs @@ -280,7 +280,7 @@ public static OpenApiSchema LoadSchema(ParseNode node) if (pointer != null) { - return new OpenApiSchema() + return new OpenApiSchema { UnresolvedReference = true, Reference = node.Context.VersionService.ConvertToOpenApiReference(pointer, ReferenceType.Schema) diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiSecurityRequirementDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiSecurityRequirementDeserializer.cs index b6b80cf7b..ed8322622 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiSecurityRequirementDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiSecurityRequirementDeserializer.cs @@ -44,10 +44,10 @@ private static OpenApiSecurityScheme LoadSecuritySchemeByReference( ParsingContext context, string schemeName) { - var securitySchemeObject = new OpenApiSecurityScheme() + var securitySchemeObject = new OpenApiSecurityScheme { UnresolvedReference = true, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id = schemeName, Type = ReferenceType.SecurityScheme diff --git a/src/Microsoft.OpenApi.Workbench/MainModel.cs b/src/Microsoft.OpenApi.Workbench/MainModel.cs index 70074736b..0d0d689ec 100644 --- a/src/Microsoft.OpenApi.Workbench/MainModel.cs +++ b/src/Microsoft.OpenApi.Workbench/MainModel.cs @@ -313,7 +313,8 @@ private string WriteContents(OpenApiDocument document) outputStream, Version, Format, - new OpenApiWriterSettings() { + new OpenApiWriterSettings + { InlineLocalReferences = InlineLocal, InlineExternalReferences = InlineExternal }); diff --git a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtension.cs b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtension.cs index adcaa85dd..9a92e0d6e 100644 --- a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtension.cs +++ b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtension.cs @@ -37,7 +37,8 @@ public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion) public static OpenApiPrimaryErrorMessageExtension Parse(IOpenApiAny source) { if (source is not OpenApiBoolean rawObject) throw new ArgumentOutOfRangeException(nameof(source)); - return new OpenApiPrimaryErrorMessageExtension() { + return new OpenApiPrimaryErrorMessageExtension + { IsPrimaryErrorMessage = rawObject.Value }; } diff --git a/src/Microsoft.OpenApi/Services/OpenApiReferenceResolver.cs b/src/Microsoft.OpenApi/Services/OpenApiReferenceResolver.cs index 3b431d4b5..dc0fb1c8d 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiReferenceResolver.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiReferenceResolver.cs @@ -206,7 +206,7 @@ private void ResolveTags(IList tags) if (resolvedTag == null) { - resolvedTag = new OpenApiTag() + resolvedTag = new OpenApiTag { Name = tag.Reference.Id }; @@ -291,7 +291,7 @@ private void ResolveTags(IList tags) else { // Leave as unresolved reference - return new T() + return new T { UnresolvedReference = true, Reference = reference diff --git a/src/Microsoft.OpenApi/Services/OperationSearch.cs b/src/Microsoft.OpenApi/Services/OperationSearch.cs index 90e88cc70..8d251ec71 100644 --- a/src/Microsoft.OpenApi/Services/OperationSearch.cs +++ b/src/Microsoft.OpenApi/Services/OperationSearch.cs @@ -43,7 +43,7 @@ public override void Visit(OpenApiPathItem pathItem) if (_predicate(CurrentKeys.Path, operationType, operation)) { - _searchResults.Add(new SearchResult() + _searchResults.Add(new SearchResult { Operation = operation, Parameters = pathItem.Parameters, diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Formatters/PowerShellFormatterTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Formatters/PowerShellFormatterTests.cs index a22348897..c261a8e46 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Formatters/PowerShellFormatterTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Formatters/PowerShellFormatterTests.cs @@ -21,14 +21,15 @@ public class PowerShellFormatterTests public void FormatOperationIdsInOpenAPIDocument(string operationId, string expectedOperationId, OperationType operationType, string path = "/foo") { // Arrange - var openApiDocument = new OpenApiDocument() + var openApiDocument = new OpenApiDocument { Info = new() { Title = "Test", Version = "1.0" }, - Servers = new List() { new() { Url = "https://localhost/" } }, + Servers = new List { new() { Url = "https://localhost/" } }, Paths = new() { { path, new() { - Operations = new Dictionary() { + Operations = new Dictionary + { { operationType, new() { OperationId = operationId } } } } @@ -92,14 +93,14 @@ public void ResolveFunctionParameters() private static OpenApiDocument GetSampleOpenApiDocument() { - return new OpenApiDocument() + return new OpenApiDocument { Info = new() { Title = "Test", Version = "1.0" }, - Servers = new List() { new() { Url = "https://localhost/" } }, + Servers = new List { new() { Url = "https://localhost/" } }, Paths = new() { { "/foo", new() { - Operations = new Dictionary() + Operations = new Dictionary { { OperationType.Get, new() @@ -107,7 +108,7 @@ private static OpenApiDocument GetSampleOpenApiDocument() OperationId = "Foo.GetFoo", Parameters = new List { - new OpenApiParameter() + new OpenApiParameter { Name = "ids", In = ParameterLocation.Query, diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs index 34cdd3a0a..32d3db3b4 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs @@ -70,14 +70,15 @@ public void ReturnFilteredOpenApiDocumentBasedOnPostmanCollection() [Fact] public void TestPredicateFiltersUsingRelativeRequestUrls() { - var openApiDocument = new OpenApiDocument() + var openApiDocument = new OpenApiDocument { Info = new() { Title = "Test", Version = "1.0" }, - Servers = new List() { new() { Url = "https://localhost/" } }, + Servers = new List { new() { Url = "https://localhost/" } }, Paths = new() { {"/foo", new() { - Operations = new Dictionary() { + Operations = new Dictionary + { { OperationType.Get, new() }, { OperationType.Patch, new() }, { OperationType.Post, new() } diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs index 9d73c8db6..fb2349e52 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs @@ -136,7 +136,7 @@ public async Task ShowCommandGeneratesMermaidMarkdownFileWithMermaidDiagram() { // create a dummy ILogger instance for testing - var options = new HidiOptions() + var options = new HidiOptions { OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml"), Output = new FileInfo("sample.md") @@ -151,7 +151,7 @@ public async Task ShowCommandGeneratesMermaidMarkdownFileWithMermaidDiagram() [Fact] public async Task ShowCommandGeneratesMermaidHtmlFileWithMermaidDiagram() { - var options = new HidiOptions() + var options = new HidiOptions { OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml") }; @@ -162,7 +162,7 @@ public async Task ShowCommandGeneratesMermaidHtmlFileWithMermaidDiagram() [Fact] public async Task ShowCommandGeneratesMermaidMarkdownFileFromCsdlWithMermaidDiagram() { - var options = new HidiOptions() + var options = new HidiOptions { Csdl = Path.Combine("UtilityFiles", "Todo.xml"), CsdlFilter = "todos", diff --git a/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs b/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs index 58b85d91d..3fc77fc01 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs @@ -22,9 +22,9 @@ public static OpenApiDocument CreateOpenApiDocument() { var applicationJsonMediaType = "application/json"; - var document = new OpenApiDocument() + var document = new OpenApiDocument { - Info = new OpenApiInfo() + Info = new OpenApiInfo { Title = "People", Version = "v1.0" @@ -36,7 +36,7 @@ public static OpenApiDocument CreateOpenApiDocument() Url = "https://graph.microsoft.com/v1.0" } }, - Paths = new OpenApiPaths() + Paths = new OpenApiPaths { ["/"] = new OpenApiPathItem() // root path { @@ -46,10 +46,10 @@ public static OpenApiDocument CreateOpenApiDocument() OperationType.Get, new OpenApiOperation { OperationId = "graphService.GetGraphService", - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "200",new OpenApiResponse() + "200",new OpenApiResponse { Description = "OK" } @@ -59,7 +59,7 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - ["/reports/microsoft.graph.getTeamsUserActivityCounts(period={period})"] = new OpenApiPathItem() + ["/reports/microsoft.graph.getTeamsUserActivityCounts(period={period})"] = new OpenApiPathItem { Operations = new Dictionary { @@ -69,7 +69,7 @@ public static OpenApiDocument CreateOpenApiDocument() Tags = new List { { - new OpenApiTag() + new OpenApiTag { Name = "reports.Functions" } @@ -80,22 +80,22 @@ public static OpenApiDocument CreateOpenApiDocument() Parameters = new List { { - new OpenApiParameter() + new OpenApiParameter { Name = "period", In = ParameterLocation.Path, Required = true, - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string" } } } }, - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "200", new OpenApiResponse() + "200", new OpenApiResponse { Description = "Success", Content = new Dictionary @@ -120,12 +120,12 @@ public static OpenApiDocument CreateOpenApiDocument() Parameters = new List { { - new OpenApiParameter() + new OpenApiParameter { Name = "period", In = ParameterLocation.Path, Required = true, - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string" } @@ -133,7 +133,7 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - ["/reports/microsoft.graph.getTeamsUserActivityUserDetail(date={date})"] = new OpenApiPathItem() + ["/reports/microsoft.graph.getTeamsUserActivityUserDetail(date={date})"] = new OpenApiPathItem { Operations = new Dictionary { @@ -143,7 +143,7 @@ public static OpenApiDocument CreateOpenApiDocument() Tags = new List { { - new OpenApiTag() + new OpenApiTag { Name = "reports.Functions" } @@ -154,22 +154,22 @@ public static OpenApiDocument CreateOpenApiDocument() Parameters = new List { { - new OpenApiParameter() + new OpenApiParameter { Name = "period", In = ParameterLocation.Path, Required = true, - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string" } } } }, - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "200", new OpenApiResponse() + "200", new OpenApiResponse { Description = "Success", Content = new Dictionary @@ -198,14 +198,14 @@ public static OpenApiDocument CreateOpenApiDocument() Name = "period", In = ParameterLocation.Path, Required = true, - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string" } } } }, - ["/users"] = new OpenApiPathItem() + ["/users"] = new OpenApiPathItem { Operations = new Dictionary { @@ -215,7 +215,7 @@ public static OpenApiDocument CreateOpenApiDocument() Tags = new List { { - new OpenApiTag() + new OpenApiTag { Name = "users.user" } @@ -223,10 +223,10 @@ public static OpenApiDocument CreateOpenApiDocument() }, OperationId = "users.user.ListUser", Summary = "Get entities from users", - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "200", new OpenApiResponse() + "200", new OpenApiResponse { Description = "Retrieved entities", Content = new Dictionary @@ -268,7 +268,7 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - ["/users/{user-id}"] = new OpenApiPathItem() + ["/users/{user-id}"] = new OpenApiPathItem { Operations = new Dictionary { @@ -278,7 +278,7 @@ public static OpenApiDocument CreateOpenApiDocument() Tags = new List { { - new OpenApiTag() + new OpenApiTag { Name = "users.user" } @@ -286,10 +286,10 @@ public static OpenApiDocument CreateOpenApiDocument() }, OperationId = "users.user.GetUser", Summary = "Get entity from users by key", - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "200", new OpenApiResponse() + "200", new OpenApiResponse { Description = "Retrieved entity", Content = new Dictionary @@ -320,7 +320,7 @@ public static OpenApiDocument CreateOpenApiDocument() Tags = new List { { - new OpenApiTag() + new OpenApiTag { Name = "users.user" } @@ -328,10 +328,10 @@ public static OpenApiDocument CreateOpenApiDocument() }, OperationId = "users.user.UpdateUser", Summary = "Update entity in users", - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "204", new OpenApiResponse() + "204", new OpenApiResponse { Description = "Success" } @@ -341,7 +341,7 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - ["/users/{user-id}/messages/{message-id}"] = new OpenApiPathItem() + ["/users/{user-id}/messages/{message-id}"] = new OpenApiPathItem { Operations = new Dictionary { @@ -351,7 +351,7 @@ public static OpenApiDocument CreateOpenApiDocument() Tags = new List { { - new OpenApiTag() + new OpenApiTag { Name = "users.message" } @@ -362,23 +362,23 @@ public static OpenApiDocument CreateOpenApiDocument() Description = "The messages in a mailbox or folder. Read-only. Nullable.", Parameters = new List { - new OpenApiParameter() + new OpenApiParameter { Name = "$select", In = ParameterLocation.Query, Required = true, Description = "Select properties to be returned", - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "array" } // missing explode parameter } }, - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "200", new OpenApiResponse() + "200", new OpenApiResponse { Description = "Retrieved navigation property", Content = new Dictionary @@ -405,7 +405,7 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - ["/administrativeUnits/{administrativeUnit-id}/microsoft.graph.restore"] = new OpenApiPathItem() + ["/administrativeUnits/{administrativeUnit-id}/microsoft.graph.restore"] = new OpenApiPathItem { Operations = new Dictionary { @@ -415,7 +415,7 @@ public static OpenApiDocument CreateOpenApiDocument() Tags = new List { { - new OpenApiTag() + new OpenApiTag { Name = "administrativeUnits.Actions" } @@ -426,23 +426,23 @@ public static OpenApiDocument CreateOpenApiDocument() Parameters = new List { { - new OpenApiParameter() + new OpenApiParameter { Name = "administrativeUnit-id", In = ParameterLocation.Path, Required = true, Description = "key: id of administrativeUnit", - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string" } } } }, - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "200", new OpenApiResponse() + "200", new OpenApiResponse { Description = "Success", Content = new Dictionary @@ -472,7 +472,7 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - ["/applications/{application-id}/logo"] = new OpenApiPathItem() + ["/applications/{application-id}/logo"] = new OpenApiPathItem { Operations = new Dictionary { @@ -482,7 +482,7 @@ public static OpenApiDocument CreateOpenApiDocument() Tags = new List { { - new OpenApiTag() + new OpenApiTag { Name = "applications.application" } @@ -490,10 +490,10 @@ public static OpenApiDocument CreateOpenApiDocument() }, OperationId = "applications.application.UpdateLogo", Summary = "Update media content for application in applications", - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "204", new OpenApiResponse() + "204", new OpenApiResponse { Description = "Success" } @@ -503,7 +503,7 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - ["/security/hostSecurityProfiles"] = new OpenApiPathItem() + ["/security/hostSecurityProfiles"] = new OpenApiPathItem { Operations = new Dictionary { @@ -513,7 +513,7 @@ public static OpenApiDocument CreateOpenApiDocument() Tags = new List { { - new OpenApiTag() + new OpenApiTag { Name = "security.hostSecurityProfile" } @@ -521,10 +521,10 @@ public static OpenApiDocument CreateOpenApiDocument() }, OperationId = "security.ListHostSecurityProfiles", Summary = "Get hostSecurityProfiles from security", - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "200", new OpenApiResponse() + "200", new OpenApiResponse { Description = "Retrieved navigation property", Content = new Dictionary @@ -566,7 +566,7 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - ["/communications/calls/{call-id}/microsoft.graph.keepAlive"] = new OpenApiPathItem() + ["/communications/calls/{call-id}/microsoft.graph.keepAlive"] = new OpenApiPathItem { Operations = new Dictionary { @@ -576,7 +576,7 @@ public static OpenApiDocument CreateOpenApiDocument() Tags = new List { { - new OpenApiTag() + new OpenApiTag { Name = "communications.Actions" } @@ -586,13 +586,13 @@ public static OpenApiDocument CreateOpenApiDocument() Summary = "Invoke action keepAlive", Parameters = new List { - new OpenApiParameter() + new OpenApiParameter { Name = "call-id", In = ParameterLocation.Path, Description = "key: id of call", Required = true, - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string" }, @@ -604,10 +604,10 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "204", new OpenApiResponse() + "204", new OpenApiResponse { Description = "Success" } @@ -623,7 +623,7 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - ["/groups/{group-id}/events/{event-id}/calendar/events/microsoft.graph.delta"] = new OpenApiPathItem() + ["/groups/{group-id}/events/{event-id}/calendar/events/microsoft.graph.delta"] = new OpenApiPathItem { Operations = new Dictionary { @@ -632,7 +632,7 @@ public static OpenApiDocument CreateOpenApiDocument() { Tags = new List { - new OpenApiTag() + new OpenApiTag { Name = "groups.Functions" } @@ -641,13 +641,13 @@ public static OpenApiDocument CreateOpenApiDocument() Summary = "Invoke function delta", Parameters = new List { - new OpenApiParameter() + new OpenApiParameter { Name = "group-id", In = ParameterLocation.Path, Description = "key: id of group", Required = true, - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string" }, @@ -658,13 +658,13 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - new OpenApiParameter() + new OpenApiParameter { Name = "event-id", In = ParameterLocation.Path, Description = "key: id of event", Required = true, - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string" }, @@ -676,10 +676,10 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "200", new OpenApiResponse() + "200", new OpenApiResponse { Description = "Success", Content = new Dictionary @@ -713,7 +713,7 @@ public static OpenApiDocument CreateOpenApiDocument() } } }, - ["/applications/{application-id}/createdOnBehalfOf/$ref"] = new OpenApiPathItem() + ["/applications/{application-id}/createdOnBehalfOf/$ref"] = new OpenApiPathItem { Operations = new Dictionary { @@ -722,7 +722,7 @@ public static OpenApiDocument CreateOpenApiDocument() { Tags = new List { - new OpenApiTag() + new OpenApiTag { Name = "applications.directoryObject" } diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs index 23c23b4d6..5b01e0444 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs @@ -45,7 +45,7 @@ public void DetectedSpecificationVersionShouldBeV3_0() public async Task DiagnosticReportMergedForExternalReference() { // Create a reader that will resolve all references - var reader = new OpenApiStreamReader(new OpenApiReaderSettings() + var reader = new OpenApiStreamReader(new OpenApiReaderSettings { LoadExternalRefs = true, CustomExternalLoader = new ResourceLoader(), diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs index 4a2c2cafe..869d43fab 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs @@ -18,7 +18,7 @@ public class OpenApiWorkspaceStreamTests public async Task LoadingDocumentWithResolveAllReferencesShouldLoadDocumentIntoWorkspace() { // Create a reader that will resolve all references - var reader = new OpenApiStreamReader(new OpenApiReaderSettings() + var reader = new OpenApiStreamReader(new OpenApiReaderSettings { LoadExternalRefs = true, CustomExternalLoader = new MockLoader(), @@ -48,7 +48,7 @@ public async Task LoadingDocumentWithResolveAllReferencesShouldLoadDocumentIntoW public async Task LoadDocumentWithExternalReferenceShouldLoadBothDocumentsIntoWorkspace() { // Create a reader that will resolve all references - var reader = new OpenApiStreamReader(new OpenApiReaderSettings() + var reader = new OpenApiStreamReader(new OpenApiReaderSettings { LoadExternalRefs = true, CustomExternalLoader = new ResourceLoader(), diff --git a/test/Microsoft.OpenApi.Readers.Tests/ParseNodeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/ParseNodeTests.cs index 677232ac4..2ece19537 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/ParseNodeTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/ParseNodeTests.cs @@ -25,7 +25,8 @@ public void BrokenSimpleList() var reader = new OpenApiStringReader(); reader.Read(input, out var diagnostic); - diagnostic.Errors.Should().BeEquivalentTo(new List() { + diagnostic.Errors.Should().BeEquivalentTo(new List + { new OpenApiError(new OpenApiReaderException("Expected a value.") { Pointer = "#line=4" }) @@ -53,7 +54,8 @@ public void BadSchema() var reader = new OpenApiStringReader(); reader.Read(input, out var diagnostic); - diagnostic.Errors.Should().BeEquivalentTo(new List() { + diagnostic.Errors.Should().BeEquivalentTo(new List + { new OpenApiError(new OpenApiReaderException("schema must be a map/object") { Pointer = "#/paths/~1foo/get/responses/200/content/application~1json/schema" }) diff --git a/test/Microsoft.OpenApi.Readers.Tests/ParseNodes/OpenApiAnyConverterTests.cs b/test/Microsoft.OpenApi.Readers.Tests/ParseNodes/OpenApiAnyConverterTests.cs index 7ee8c3439..3875b77b0 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/ParseNodes/OpenApiAnyConverterTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/ParseNodes/OpenApiAnyConverterTests.cs @@ -38,31 +38,31 @@ public void ParseObjectAsAnyShouldSucceed() var anyMap = node.CreateAny(); - var schema = new OpenApiSchema() + var schema = new OpenApiSchema { Type = "object", Properties = { - ["aString"] = new OpenApiSchema() + ["aString"] = new OpenApiSchema { Type = "string" }, - ["aInteger"] = new OpenApiSchema() + ["aInteger"] = new OpenApiSchema { Type = "integer", Format = "int32" }, - ["aDouble"] = new OpenApiSchema() + ["aDouble"] = new OpenApiSchema { Type = "number", Format = "double" }, - ["aDateTime"] = new OpenApiSchema() + ["aDateTime"] = new OpenApiSchema { Type = "string", Format = "date-time" }, - ["aDate"] = new OpenApiSchema() + ["aDate"] = new OpenApiSchema { Type = "string", Format = "date" @@ -124,59 +124,59 @@ public void ParseNestedObjectAsAnyShouldSucceed() var anyMap = node.CreateAny(); - var schema = new OpenApiSchema() + var schema = new OpenApiSchema { Type = "object", Properties = { - ["aString"] = new OpenApiSchema() + ["aString"] = new OpenApiSchema { Type = "string" }, - ["aInteger"] = new OpenApiSchema() + ["aInteger"] = new OpenApiSchema { Type = "integer", Format = "int32" }, - ["aArray"] = new OpenApiSchema() + ["aArray"] = new OpenApiSchema { Type = "array", - Items = new OpenApiSchema() + Items = new OpenApiSchema { Type = "integer", Format = "int64" } }, - ["aNestedArray"] = new OpenApiSchema() + ["aNestedArray"] = new OpenApiSchema { Type = "array", - Items = new OpenApiSchema() + Items = new OpenApiSchema { Type = "object", Properties = { - ["aFloat"] = new OpenApiSchema() + ["aFloat"] = new OpenApiSchema { Type = "number", Format = "float" }, - ["aPassword"] = new OpenApiSchema() + ["aPassword"] = new OpenApiSchema { Type = "string", Format = "password" }, - ["aArray"] = new OpenApiSchema() + ["aArray"] = new OpenApiSchema { Type = "array", - Items = new OpenApiSchema() + Items = new OpenApiSchema { Type = "string", } }, - ["aDictionary"] = new OpenApiSchema() + ["aDictionary"] = new OpenApiSchema { Type = "object", - AdditionalProperties = new OpenApiSchema() + AdditionalProperties = new OpenApiSchema { Type = "integer", Format = "int64" @@ -185,24 +185,24 @@ public void ParseNestedObjectAsAnyShouldSucceed() } } }, - ["aObject"] = new OpenApiSchema() + ["aObject"] = new OpenApiSchema { Type = "array", Properties = { - ["aDate"] = new OpenApiSchema() + ["aDate"] = new OpenApiSchema { Type = "string", Format = "date" } } }, - ["aDouble"] = new OpenApiSchema() + ["aDouble"] = new OpenApiSchema { Type = "number", Format = "double" }, - ["aDateTime"] = new OpenApiSchema() + ["aDateTime"] = new OpenApiSchema { Type = "string", Format = "date-time" @@ -219,44 +219,44 @@ public void ParseNestedObjectAsAnyShouldSucceed() { ["aString"] = new OpenApiString("fooBar"), ["aInteger"] = new OpenApiInteger(10), - ["aArray"] = new OpenApiArray() + ["aArray"] = new OpenApiArray { new OpenApiLong(1), new OpenApiLong(2), new OpenApiLong(3), }, - ["aNestedArray"] = new OpenApiArray() + ["aNestedArray"] = new OpenApiArray { - new OpenApiObject() + new OpenApiObject { ["aFloat"] = new OpenApiFloat(1), ["aPassword"] = new OpenApiPassword("1234"), - ["aArray"] = new OpenApiArray() + ["aArray"] = new OpenApiArray { new OpenApiString("abc"), new OpenApiString("def") }, - ["aDictionary"] = new OpenApiObject() + ["aDictionary"] = new OpenApiObject { ["arbitraryProperty"] = new OpenApiLong(1), ["arbitraryProperty2"] = new OpenApiLong(2), } }, - new OpenApiObject() + new OpenApiObject { ["aFloat"] = new OpenApiFloat((float)1.6), - ["aArray"] = new OpenApiArray() + ["aArray"] = new OpenApiArray { new OpenApiString("123"), }, - ["aDictionary"] = new OpenApiObject() + ["aDictionary"] = new OpenApiObject { ["arbitraryProperty"] = new OpenApiLong(1), ["arbitraryProperty3"] = new OpenApiLong(20), } } }, - ["aObject"] = new OpenApiObject() + ["aObject"] = new OpenApiObject { ["aDate"] = new OpenApiDate(DateTimeOffset.Parse("2017-02-03", CultureInfo.InvariantCulture).Date) }, @@ -304,41 +304,41 @@ public void ParseNestedObjectAsAnyWithPartialSchemaShouldSucceed() var anyMap = node.CreateAny(); - var schema = new OpenApiSchema() + var schema = new OpenApiSchema { Type = "object", Properties = { - ["aString"] = new OpenApiSchema() + ["aString"] = new OpenApiSchema { Type = "string" }, - ["aArray"] = new OpenApiSchema() + ["aArray"] = new OpenApiSchema { Type = "array", - Items = new OpenApiSchema() + Items = new OpenApiSchema { Type = "integer" } }, - ["aNestedArray"] = new OpenApiSchema() + ["aNestedArray"] = new OpenApiSchema { Type = "array", - Items = new OpenApiSchema() + Items = new OpenApiSchema { Type = "object", Properties = { - ["aFloat"] = new OpenApiSchema() + ["aFloat"] = new OpenApiSchema { }, - ["aPassword"] = new OpenApiSchema() + ["aPassword"] = new OpenApiSchema { }, - ["aArray"] = new OpenApiSchema() + ["aArray"] = new OpenApiSchema { Type = "array", - Items = new OpenApiSchema() + Items = new OpenApiSchema { Type = "string", } @@ -346,21 +346,21 @@ public void ParseNestedObjectAsAnyWithPartialSchemaShouldSucceed() } } }, - ["aObject"] = new OpenApiSchema() + ["aObject"] = new OpenApiSchema { Type = "array", Properties = { - ["aDate"] = new OpenApiSchema() + ["aDate"] = new OpenApiSchema { Type = "string" } } }, - ["aDouble"] = new OpenApiSchema() + ["aDouble"] = new OpenApiSchema { }, - ["aDateTime"] = new OpenApiSchema() + ["aDateTime"] = new OpenApiSchema { } } @@ -375,44 +375,44 @@ public void ParseNestedObjectAsAnyWithPartialSchemaShouldSucceed() { ["aString"] = new OpenApiString("fooBar"), ["aInteger"] = new OpenApiInteger(10), - ["aArray"] = new OpenApiArray() + ["aArray"] = new OpenApiArray { new OpenApiInteger(1), new OpenApiInteger(2), new OpenApiInteger(3), }, - ["aNestedArray"] = new OpenApiArray() + ["aNestedArray"] = new OpenApiArray { - new OpenApiObject() + new OpenApiObject { ["aFloat"] = new OpenApiInteger(1), ["aPassword"] = new OpenApiInteger(1234), - ["aArray"] = new OpenApiArray() + ["aArray"] = new OpenApiArray { new OpenApiString("abc"), new OpenApiString("def") }, - ["aDictionary"] = new OpenApiObject() + ["aDictionary"] = new OpenApiObject { ["arbitraryProperty"] = new OpenApiInteger(1), ["arbitraryProperty2"] = new OpenApiInteger(2), } }, - new OpenApiObject() + new OpenApiObject { ["aFloat"] = new OpenApiDouble(1.6), - ["aArray"] = new OpenApiArray() + ["aArray"] = new OpenApiArray { new OpenApiString("123"), }, - ["aDictionary"] = new OpenApiObject() + ["aDictionary"] = new OpenApiObject { ["arbitraryProperty"] = new OpenApiInteger(1), ["arbitraryProperty3"] = new OpenApiInteger(20), } } }, - ["aObject"] = new OpenApiObject() + ["aObject"] = new OpenApiObject { ["aDate"] = new OpenApiString("2017-02-03") }, @@ -468,44 +468,44 @@ public void ParseNestedObjectAsAnyWithoutUsingSchemaShouldSucceed() { ["aString"] = new OpenApiString("fooBar"), ["aInteger"] = new OpenApiInteger(10), - ["aArray"] = new OpenApiArray() + ["aArray"] = new OpenApiArray { new OpenApiInteger(1), new OpenApiInteger(2), new OpenApiInteger(3), }, - ["aNestedArray"] = new OpenApiArray() + ["aNestedArray"] = new OpenApiArray { - new OpenApiObject() + new OpenApiObject { ["aFloat"] = new OpenApiInteger(1), ["aPassword"] = new OpenApiInteger(1234), - ["aArray"] = new OpenApiArray() + ["aArray"] = new OpenApiArray { new OpenApiString("abc"), new OpenApiString("def") }, - ["aDictionary"] = new OpenApiObject() + ["aDictionary"] = new OpenApiObject { ["arbitraryProperty"] = new OpenApiInteger(1), ["arbitraryProperty2"] = new OpenApiInteger(2), } }, - new OpenApiObject() + new OpenApiObject { ["aFloat"] = new OpenApiDouble(1.6), - ["aArray"] = new OpenApiArray() + ["aArray"] = new OpenApiArray { new OpenApiInteger(123), }, - ["aDictionary"] = new OpenApiObject() + ["aDictionary"] = new OpenApiObject { ["arbitraryProperty"] = new OpenApiInteger(1), ["arbitraryProperty3"] = new OpenApiInteger(20), } } }, - ["aObject"] = new OpenApiObject() + ["aObject"] = new OpenApiObject { ["aDate"] = new OpenApiDateTime(DateTimeOffset.Parse("2017-02-03", CultureInfo.InvariantCulture)) }, diff --git a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/TryLoadReferenceV2Tests.cs b/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/TryLoadReferenceV2Tests.cs index a641b7d6f..9469de370 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/TryLoadReferenceV2Tests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/TryLoadReferenceV2Tests.cs @@ -228,11 +228,11 @@ public void LoadResponseAndSchemaReference() Description = "Sample description", Required = new HashSet {"name" }, Properties = { - ["name"] = new OpenApiSchema() + ["name"] = new OpenApiSchema { Type = "string" }, - ["tag"] = new OpenApiSchema() + ["tag"] = new OpenApiSchema { Type = "string" } diff --git a/test/Microsoft.OpenApi.Readers.Tests/TestCustomExtension.cs b/test/Microsoft.OpenApi.Readers.Tests/TestCustomExtension.cs index 88866fd95..89468229a 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/TestCustomExtension.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/TestCustomExtension.cs @@ -24,11 +24,12 @@ public void ParseCustomExtension() baz: hi! paths: {} "; - var settings = new OpenApiReaderSettings() + var settings = new OpenApiReaderSettings { ExtensionParsers = { { "x-foo", (a,v) => { var fooNode = (OpenApiObject)a; - return new FooExtension() { + return new FooExtension + { Bar = (fooNode["bar"] as OpenApiString)?.Value, Baz = (fooNode["baz"] as OpenApiString)?.Value }; diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs index ac5f99a86..4acdb583f 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs @@ -122,16 +122,16 @@ public void ParseDocumentWithDifferentCultureShouldSucceed(string culture) ["x-extension"] = new OpenApiDouble(2.335) } }, - Components = new OpenApiComponents() + Components = new OpenApiComponents { Schemas = { - ["sampleSchema"] = new OpenApiSchema() + ["sampleSchema"] = new OpenApiSchema { Type = "object", Properties = { - ["sampleProperty"] = new OpenApiSchema() + ["sampleProperty"] = new OpenApiSchema { Type = "double", Minimum = (decimal)100.54, @@ -140,7 +140,7 @@ public void ParseDocumentWithDifferentCultureShouldSucceed(string culture) ExclusiveMinimum = false } }, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id = "sampleSchema", Type = ReferenceType.Schema @@ -152,7 +152,7 @@ public void ParseDocumentWithDifferentCultureShouldSucceed(string culture) }); context.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi2_0 }); + new OpenApiDiagnostic { SpecificationVersion = OpenApiSpecVersion.OpenApi2_0 }); } [Fact] @@ -163,7 +163,7 @@ public void ShouldParseProducesInAnyOrder() var reader = new OpenApiStreamReader(); var doc = reader.Read(stream, out var diagnostic); - var okSchema = new OpenApiSchema() + var okSchema = new OpenApiSchema { Reference = new OpenApiReference { @@ -171,9 +171,9 @@ public void ShouldParseProducesInAnyOrder() Id = "Item", HostDocument = doc }, - Properties = new Dictionary() + Properties = new Dictionary { - { "id", new OpenApiSchema() + { "id", new OpenApiSchema { Type = "string", Description = "Item identifier." @@ -182,7 +182,7 @@ public void ShouldParseProducesInAnyOrder() } }; - var errorSchema = new OpenApiSchema() + var errorSchema = new OpenApiSchema { Reference = new OpenApiReference { @@ -190,20 +190,20 @@ public void ShouldParseProducesInAnyOrder() Id = "Error", HostDocument = doc }, - Properties = new Dictionary() + Properties = new Dictionary { - { "code", new OpenApiSchema() + { "code", new OpenApiSchema { Type = "integer", Format = "int32" } }, - { "message", new OpenApiSchema() + { "message", new OpenApiSchema { Type = "string" } }, - { "fields", new OpenApiSchema() + { "fields", new OpenApiSchema { Type = "string" } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs index 7a98c7a6d..eb3bb066c 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs @@ -34,7 +34,7 @@ public void ParseHeaderWithDefaultShouldSucceed() header.Should().BeEquivalentTo( new OpenApiHeader { - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "number", Format = "float", @@ -60,7 +60,7 @@ public void ParseHeaderWithEnumShouldSucceed() header.Should().BeEquivalentTo( new OpenApiHeader { - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "number", Format = "float", diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs index 3b0f32871..76da8a763 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs @@ -330,39 +330,39 @@ public void ParseOperationWithResponseExamplesShouldSucceed() // Assert operation.Should().BeEquivalentTo( - new OpenApiOperation() + new OpenApiOperation { - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { - { "200", new OpenApiResponse() + { "200", new OpenApiResponse { Description = "An array of float response", Content = { - ["application/json"] = new OpenApiMediaType() + ["application/json"] = new OpenApiMediaType { - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "array", - Items = new OpenApiSchema() + Items = new OpenApiSchema { Type = "number", Format = "float" } }, - Example = new OpenApiArray() + Example = new OpenApiArray { new OpenApiFloat(5), new OpenApiFloat(6), new OpenApiFloat(7), } }, - ["application/xml"] = new OpenApiMediaType() + ["application/xml"] = new OpenApiMediaType { - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "array", - Items = new OpenApiSchema() + Items = new OpenApiSchema { Type = "number", Format = "float" @@ -389,18 +389,18 @@ public void ParseOperationWithEmptyProducesArraySetsResponseSchemaIfExists() // Assert operation.Should().BeEquivalentTo( - new OpenApiOperation() + new OpenApiOperation { - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { - { "200", new OpenApiResponse() + { "200", new OpenApiResponse { Description = "OK", Content = { - ["application/octet-stream"] = new OpenApiMediaType() + ["application/octet-stream"] = new OpenApiMediaType { - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Format = "binary", Description = "The content of the file.", diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs index fc4e84f50..3f46f5a2b 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs @@ -155,15 +155,16 @@ public void ParseHeaderParameterShouldSucceed() new OpenApiLong(4), } }, - Default = new OpenApiArray() { + Default = new OpenApiArray + { new OpenApiLong(1), new OpenApiLong(2) }, Enum = new List { - new OpenApiArray() { new OpenApiLong(1), new OpenApiLong(2) }, - new OpenApiArray() { new OpenApiLong(2), new OpenApiLong(3) }, - new OpenApiArray() { new OpenApiLong(3), new OpenApiLong(4) } + new OpenApiArray { new OpenApiLong(1), new OpenApiLong(2) }, + new OpenApiArray { new OpenApiLong(2), new OpenApiLong(3) }, + new OpenApiArray { new OpenApiLong(3), new OpenApiLong(4) } } } }); @@ -207,15 +208,16 @@ public void ParseHeaderParameterWithIncorrectDataTypeShouldSucceed() new OpenApiString("4"), } }, - Default = new OpenApiArray() { + Default = new OpenApiArray + { new OpenApiString("1"), new OpenApiString("2") }, Enum = new List { - new OpenApiArray() { new OpenApiString("1"), new OpenApiString("2") }, - new OpenApiArray() { new OpenApiString("2"), new OpenApiString("3") }, - new OpenApiArray() { new OpenApiString("3"), new OpenApiString("4") } + new OpenApiArray { new OpenApiString("1"), new OpenApiString("2") }, + new OpenApiArray { new OpenApiString("2"), new OpenApiString("3") }, + new OpenApiArray { new OpenApiString("3"), new OpenApiString("4") } } } }); diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs index a11497cdf..c32c15ff4 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs @@ -19,20 +19,20 @@ public class OpenApiPathItemTests { private const string SampleFolderPath = "V2Tests/Samples/OpenApiPathItem/"; - private static readonly OpenApiPathItem _basicPathItemWithFormData = new OpenApiPathItem() + private static readonly OpenApiPathItem _basicPathItemWithFormData = new OpenApiPathItem { Parameters = new List { - new OpenApiParameter() + new OpenApiParameter { Name = "id", In = ParameterLocation.Path, Description = "ID of pet to use", Required = true, - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "array", - Items = new OpenApiSchema() + Items = new OpenApiSchema { Type = "string" } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiServerTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiServerTests.cs index bf0fe7b78..5037007a2 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiServerTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiServerTests.cs @@ -18,7 +18,7 @@ public void NoServer() version: 1.0.0 paths: {} "; - var reader = new OpenApiStringReader(new OpenApiReaderSettings() + var reader = new OpenApiStringReader(new OpenApiReaderSettings { }); @@ -39,7 +39,7 @@ public void JustSchemeNoDefault() - http paths: {} "; - var reader = new OpenApiStringReader(new OpenApiReaderSettings() + var reader = new OpenApiStringReader(new OpenApiReaderSettings { }); @@ -59,7 +59,7 @@ public void JustHostNoDefault() host: www.foo.com paths: {} "; - var reader = new OpenApiStringReader(new OpenApiReaderSettings() + var reader = new OpenApiStringReader(new OpenApiReaderSettings { }); @@ -83,7 +83,7 @@ public void NoBasePath() - http paths: {} "; - var reader = new OpenApiStringReader(new OpenApiReaderSettings() + var reader = new OpenApiStringReader(new OpenApiReaderSettings { BaseUrl = new Uri("https://www.foo.com/spec.yaml") }); @@ -106,7 +106,7 @@ public void JustBasePathNoDefault() basePath: /baz paths: {} "; - var reader = new OpenApiStringReader(new OpenApiReaderSettings() + var reader = new OpenApiStringReader(new OpenApiReaderSettings { }); @@ -129,7 +129,7 @@ public void JustSchemeWithCustomHost() - http paths: {} "; - var reader = new OpenApiStringReader(new OpenApiReaderSettings() + var reader = new OpenApiStringReader(new OpenApiReaderSettings { BaseUrl = new Uri("https://bing.com/foo") }); @@ -153,7 +153,7 @@ public void JustSchemeWithCustomHostWithEmptyPath() - http paths: {} "; - var reader = new OpenApiStringReader(new OpenApiReaderSettings() + var reader = new OpenApiStringReader(new OpenApiReaderSettings { BaseUrl = new Uri("https://bing.com") }); @@ -176,7 +176,7 @@ public void JustBasePathWithCustomHost() basePath: /api paths: {} "; - var reader = new OpenApiStringReader(new OpenApiReaderSettings() + var reader = new OpenApiStringReader(new OpenApiReaderSettings { BaseUrl = new Uri("https://bing.com") }); @@ -199,7 +199,7 @@ public void JustHostWithCustomHost() host: www.example.com paths: {} "; - var reader = new OpenApiStringReader(new OpenApiReaderSettings() + var reader = new OpenApiStringReader(new OpenApiReaderSettings { BaseUrl = new Uri("https://bing.com") }); @@ -222,7 +222,7 @@ public void JustHostWithCustomHostWithApi() host: prod.bing.com paths: {} "; - var reader = new OpenApiStringReader(new OpenApiReaderSettings() + var reader = new OpenApiStringReader(new OpenApiReaderSettings { BaseUrl = new Uri("https://dev.bing.com/api/description.yaml") }); @@ -247,7 +247,7 @@ public void MultipleServers() - https paths: {} "; - var reader = new OpenApiStringReader(new OpenApiReaderSettings() + var reader = new OpenApiStringReader(new OpenApiReaderSettings { BaseUrl = new Uri("https://dev.bing.com/api") }); @@ -271,7 +271,7 @@ public void LocalHostWithCustomHost() host: localhost:23232 paths: {} "; - var reader = new OpenApiStringReader(new OpenApiReaderSettings() + var reader = new OpenApiStringReader(new OpenApiReaderSettings { BaseUrl = new Uri("https://bing.com") }); @@ -294,7 +294,7 @@ public void InvalidHostShouldYieldError() host: http://test.microsoft.com paths: {} "; - var reader = new OpenApiStringReader(new OpenApiReaderSettings() + var reader = new OpenApiStringReader(new OpenApiReaderSettings { BaseUrl = new Uri("https://bing.com") }); diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs index 320f01fae..1a45006db 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs @@ -89,7 +89,7 @@ public void ParseCallbackWithReferenceShouldSucceed() var callback = subscribeOperation.Callbacks["simpleHook"]; diagnostic.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + new OpenApiDiagnostic { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); callback.Should().BeEquivalentTo( new OpenApiCallback @@ -98,7 +98,7 @@ public void ParseCallbackWithReferenceShouldSucceed() { [RuntimeExpression.Build("$request.body#/url")]= new OpenApiPathItem { Operations = { - [OperationType.Post] = new OpenApiOperation() + [OperationType.Post] = new OpenApiOperation { RequestBody = new OpenApiRequestBody { @@ -106,7 +106,7 @@ public void ParseCallbackWithReferenceShouldSucceed() { ["application/json"] = new OpenApiMediaType { - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "object" } @@ -146,7 +146,7 @@ public void ParseMultipleCallbacksWithReferenceShouldSucceed() var subscribeOperation = path.Operations[OperationType.Post]; diagnostic.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + new OpenApiDiagnostic { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); var callback1 = subscribeOperation.Callbacks["simpleHook"]; @@ -157,7 +157,7 @@ public void ParseMultipleCallbacksWithReferenceShouldSucceed() { [RuntimeExpression.Build("$request.body#/url")]= new OpenApiPathItem { Operations = { - [OperationType.Post] = new OpenApiOperation() + [OperationType.Post] = new OpenApiOperation { RequestBody = new OpenApiRequestBody { @@ -165,7 +165,7 @@ public void ParseMultipleCallbacksWithReferenceShouldSucceed() { ["application/json"] = new OpenApiMediaType { - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "object" } @@ -198,7 +198,7 @@ public void ParseMultipleCallbacksWithReferenceShouldSucceed() { [RuntimeExpression.Build("/simplePath")]= new OpenApiPathItem { Operations = { - [OperationType.Post] = new OpenApiOperation() + [OperationType.Post] = new OpenApiOperation { RequestBody = new OpenApiRequestBody { @@ -207,7 +207,7 @@ public void ParseMultipleCallbacksWithReferenceShouldSucceed() { ["application/json"] = new OpenApiMediaType { - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string" } @@ -234,7 +234,7 @@ public void ParseMultipleCallbacksWithReferenceShouldSucceed() { [RuntimeExpression.Build(@"http://example.com?transactionId={$request.body#/id}&email={$request.body#/email}")] = new OpenApiPathItem { Operations = { - [OperationType.Post] = new OpenApiOperation() + [OperationType.Post] = new OpenApiOperation { RequestBody = new OpenApiRequestBody { @@ -242,7 +242,7 @@ public void ParseMultipleCallbacksWithReferenceShouldSucceed() { ["application/xml"] = new OpenApiMediaType { - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "object" } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs index 8a0da3481..85a686e49 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs @@ -36,7 +36,7 @@ public T Clone(T element) where T : IOpenApiSerializable { IOpenApiWriter writer; var streamWriter = new FormattingStreamWriter(stream, CultureInfo.InvariantCulture); - writer = new OpenApiJsonWriter(streamWriter, new OpenApiJsonWriterSettings() + writer = new OpenApiJsonWriter(streamWriter, new OpenApiJsonWriterSettings { InlineLocalReferences = true }); @@ -58,7 +58,7 @@ public OpenApiSecurityScheme CloneSecurityScheme(OpenApiSecurityScheme element) { IOpenApiWriter writer; var streamWriter = new FormattingStreamWriter(stream, CultureInfo.InvariantCulture); - writer = new OpenApiJsonWriter(streamWriter, new OpenApiJsonWriterSettings() + writer = new OpenApiJsonWriter(streamWriter, new OpenApiJsonWriterSettings { InlineLocalReferences = true }); @@ -104,7 +104,7 @@ public void ParseDocumentFromInlineStringShouldSucceed() }); context.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + new OpenApiDiagnostic { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); } [Theory] @@ -146,16 +146,16 @@ public void ParseDocumentWithDifferentCultureShouldSucceed(string culture) Title = "Simple Document", Version = "0.9.1" }, - Components = new OpenApiComponents() + Components = new OpenApiComponents { Schemas = { - ["sampleSchema"] = new OpenApiSchema() + ["sampleSchema"] = new OpenApiSchema { Type = "object", Properties = { - ["sampleProperty"] = new OpenApiSchema() + ["sampleProperty"] = new OpenApiSchema { Type = "double", Minimum = (decimal)100.54, @@ -164,7 +164,7 @@ public void ParseDocumentWithDifferentCultureShouldSucceed(string culture) ExclusiveMinimum = false } }, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id = "sampleSchema", Type = ReferenceType.Schema @@ -176,7 +176,7 @@ public void ParseDocumentWithDifferentCultureShouldSucceed(string culture) }); context.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + new OpenApiDiagnostic { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); } [Fact] @@ -187,7 +187,7 @@ public void ParseBasicDocumentWithMultipleServersShouldSucceed() var openApiDoc = new OpenApiStreamReader().Read(stream, out var diagnostic); diagnostic.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + new OpenApiDiagnostic { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); openApiDoc.Should().BeEquivalentTo( new OpenApiDocument @@ -263,7 +263,7 @@ public void ParseMinimalDocumentShouldSucceed() }); diagnostic.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + new OpenApiDiagnostic { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); } } @@ -694,7 +694,7 @@ public void ParseStandardPetStoreDocumentShouldSucceed() } context.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + new OpenApiDiagnostic { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); } [Fact] @@ -1201,7 +1201,7 @@ public void ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() { Name = "tagName1", Description = "tagDescription1", - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id = "tagName1", Type = ReferenceType.Tag @@ -1227,7 +1227,7 @@ public void ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() } context.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + new OpenApiDiagnostic { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); } [Fact] @@ -1243,7 +1243,7 @@ public void ParsePetStoreExpandedShouldSucceed() } context.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + new OpenApiDiagnostic { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); } [Fact] @@ -1269,7 +1269,7 @@ public void HeaderParameterShouldAllowExample() var exampleHeader = openApiDoc.Components?.Headers?["example-header"]; Assert.NotNull(exampleHeader); exampleHeader.Should().BeEquivalentTo( - new OpenApiHeader() + new OpenApiHeader { Description = "Test header with example", Required = true, @@ -1279,12 +1279,12 @@ public void HeaderParameterShouldAllowExample() Style = ParameterStyle.Simple, Explode = true, Example = new OpenApiString("99391c7e-ad88-49ec-a2ad-99ddcb1f7721"), - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string", Format = "uuid" }, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Type = ReferenceType.Header, Id = "example-header" @@ -1294,7 +1294,7 @@ public void HeaderParameterShouldAllowExample() var examplesHeader = openApiDoc.Components?.Headers?["examples-header"]; Assert.NotNull(examplesHeader); examplesHeader.Should().BeEquivalentTo( - new OpenApiHeader() + new OpenApiHeader { Description = "Test header with example", Required = true, @@ -1303,25 +1303,25 @@ public void HeaderParameterShouldAllowExample() AllowReserved = true, Style = ParameterStyle.Simple, Explode = true, - Examples = new Dictionary() + Examples = new Dictionary { - { "uuid1", new OpenApiExample() + { "uuid1", new OpenApiExample { Value = new OpenApiString("99391c7e-ad88-49ec-a2ad-99ddcb1f7721") } }, - { "uuid2", new OpenApiExample() + { "uuid2", new OpenApiExample { Value = new OpenApiString("99391c7e-ad88-49ec-a2ad-99ddcb1f7721") } } }, - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string", Format = "uuid" }, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Type = ReferenceType.Header, Id = "examples-header" diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs index e62eabb53..47983a9a1 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs @@ -61,11 +61,11 @@ public void ParseMediaTypeWithExamplesShouldSucceed() { Examples = { - ["example1"] = new OpenApiExample() + ["example1"] = new OpenApiExample { Value = new OpenApiFloat(5), }, - ["example2"] = new OpenApiExample() + ["example2"] = new OpenApiExample { Value = new OpenApiFloat((float)7.5), } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiOperationTests.cs index a74c64154..37053c2a4 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiOperationTests.cs @@ -42,14 +42,14 @@ public void ParseOperationWithParameterWithNoLocationShouldSucceed() var operation = OpenApiV3Deserializer.LoadOperation(node); // Assert - operation.Should().BeEquivalentTo(new OpenApiOperation() + operation.Should().BeEquivalentTo(new OpenApiOperation { Tags = { new OpenApiTag { UnresolvedReference = true, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id = "user", Type = ReferenceType.Tag diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs index 44ba3316d..3234195e5 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs @@ -329,11 +329,11 @@ public void ParseParameterWithExamplesShouldSucceed() Required = true, Examples = { - ["example1"] = new OpenApiExample() + ["example1"] = new OpenApiExample { Value = new OpenApiFloat(5), }, - ["example2"] = new OpenApiExample() + ["example2"] = new OpenApiExample { Value = new OpenApiFloat((float)7.5), } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs index 0101d9c6e..54553d5a5 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs @@ -119,7 +119,8 @@ public void ParseExampleStringFragmentShouldSucceed() new OpenApiObject { ["foo"] = new OpenApiString("bar"), - ["baz"] = new OpenApiArray() { + ["baz"] = new OpenApiArray + { new OpenApiInteger(1), new OpenApiInteger(2) } @@ -226,7 +227,7 @@ public void ParsePathFragmentShouldSucceed() Summary = "externally referenced path item", Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation() + [OperationType.Get] = new OpenApiOperation { Responses = new OpenApiResponses { @@ -333,7 +334,7 @@ public void ParseBasicSchemaWithReferenceShouldSucceed() var components = openApiDoc.Components; diagnostic.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + new OpenApiDiagnostic { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); components.Should().BeEquivalentTo( new OpenApiComponents @@ -439,7 +440,7 @@ public void ParseAdvancedSchemaWithReferenceShouldSucceed() var components = openApiDoc.Components; diagnostic.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + new OpenApiDiagnostic { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); components.Should().BeEquivalentTo( new OpenApiComponents @@ -469,7 +470,7 @@ public void ParseAdvancedSchemaWithReferenceShouldSucceed() "name", "petType" }, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id= "Pet", Type = ReferenceType.Schema, @@ -534,7 +535,7 @@ public void ParseAdvancedSchemaWithReferenceShouldSucceed() } } }, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id= "Cat", Type = ReferenceType.Schema, @@ -595,7 +596,7 @@ public void ParseAdvancedSchemaWithReferenceShouldSucceed() } } }, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id= "Dog", Type = ReferenceType.Schema, @@ -620,29 +621,31 @@ public void ParseSelfReferencingSchemaShouldNotStackOverflow() var components = openApiDoc.Components; diagnostic.Should().BeEquivalentTo( - new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + new OpenApiDiagnostic { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); - var schemaExtension = new OpenApiSchema() + var schemaExtension = new OpenApiSchema { - AllOf = { new OpenApiSchema() - { + AllOf = { new OpenApiSchema + { Title = "schemaExtension", Type = "object", Properties = { - ["description"] = new OpenApiSchema() { Type = "string", Nullable = true}, - ["targetTypes"] = new OpenApiSchema() { + ["description"] = new OpenApiSchema { Type = "string", Nullable = true}, + ["targetTypes"] = new OpenApiSchema + { Type = "array", - Items = new OpenApiSchema() { + Items = new OpenApiSchema + { Type = "string" } }, - ["status"] = new OpenApiSchema() { Type = "string"}, - ["owner"] = new OpenApiSchema() { Type = "string"}, + ["status"] = new OpenApiSchema { Type = "string"}, + ["owner"] = new OpenApiSchema { Type = "string"}, ["child"] = null } } }, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Type = ReferenceType.Schema, Id = "microsoft.graph.schemaExtension" diff --git a/test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs b/test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs index 6d2eafc01..efba7b9b0 100644 --- a/test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs +++ b/test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs @@ -28,7 +28,7 @@ public ApisGuruTests(ITestOutputHelper output) static ApisGuruTests() { System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; - _httpClient = new HttpClient(new HttpClientHandler() + _httpClient = new HttpClient(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.GZip }); diff --git a/test/Microsoft.OpenApi.SmokeTests/GraphTests.cs b/test/Microsoft.OpenApi.SmokeTests/GraphTests.cs index de3101e27..b7881a905 100644 --- a/test/Microsoft.OpenApi.SmokeTests/GraphTests.cs +++ b/test/Microsoft.OpenApi.SmokeTests/GraphTests.cs @@ -24,7 +24,7 @@ public GraphTests(ITestOutputHelper output) { _output = output; System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; - _httpClient = new HttpClient(new HttpClientHandler() + _httpClient = new HttpClient(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.GZip }); _httpClient.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("gzip")); diff --git a/test/Microsoft.OpenApi.Tests/Expressions/RuntimeExpressionTests.cs b/test/Microsoft.OpenApi.Tests/Expressions/RuntimeExpressionTests.cs index 5c91249d3..a5b116faa 100644 --- a/test/Microsoft.OpenApi.Tests/Expressions/RuntimeExpressionTests.cs +++ b/test/Microsoft.OpenApi.Tests/Expressions/RuntimeExpressionTests.cs @@ -188,7 +188,7 @@ public void CompositeRuntimeExpressionContainsMultipleExpressions() var compositeExpression = runtimeExpression as CompositeExpression; Assert.Equal(2, compositeExpression.ContainedExpressions.Count); - compositeExpression.ContainedExpressions.Should().BeEquivalentTo(new List() + compositeExpression.ContainedExpressions.Should().BeEquivalentTo(new List { new UrlExpression(), new RequestExpression(new HeaderExpression("foo")) @@ -232,7 +232,7 @@ public void CompositeRuntimeExpressionWithMultipleRuntimeExpressionsAndFakeBrace response.Expression.Should().Be(expression); var compositeExpression = runtimeExpression as CompositeExpression; - compositeExpression.ContainedExpressions.Should().BeEquivalentTo(new List() + compositeExpression.ContainedExpressions.Should().BeEquivalentTo(new List { new UrlExpression(), new RequestExpression(new HeaderExpression("foo")) diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs index 7ba6d132c..46a6bb772 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs @@ -170,13 +170,13 @@ public class OpenApiComponentsTests } }; - public static OpenApiComponents TopLevelReferencingComponents = new OpenApiComponents() + public static OpenApiComponents TopLevelReferencingComponents = new OpenApiComponents { Schemas = { ["schema1"] = new OpenApiSchema { - Reference = new OpenApiReference() + Reference = new OpenApiReference { Type = ReferenceType.Schema, Id = "schema2" @@ -187,7 +187,7 @@ public class OpenApiComponentsTests Type = "object", Properties = { - ["property1"] = new OpenApiSchema() + ["property1"] = new OpenApiSchema { Type = "string" } @@ -196,7 +196,7 @@ public class OpenApiComponentsTests } }; - public static OpenApiComponents TopLevelSelfReferencingComponentsWithOtherProperties = new OpenApiComponents() + public static OpenApiComponents TopLevelSelfReferencingComponentsWithOtherProperties = new OpenApiComponents { Schemas = { @@ -205,12 +205,12 @@ public class OpenApiComponentsTests Type = "object", Properties = { - ["property1"] = new OpenApiSchema() + ["property1"] = new OpenApiSchema { Type = "string" } }, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Type = ReferenceType.Schema, Id = "schema1" @@ -221,7 +221,7 @@ public class OpenApiComponentsTests Type = "object", Properties = { - ["property1"] = new OpenApiSchema() + ["property1"] = new OpenApiSchema { Type = "string" } @@ -230,13 +230,13 @@ public class OpenApiComponentsTests } }; - public static OpenApiComponents TopLevelSelfReferencingComponents = new OpenApiComponents() + public static OpenApiComponents TopLevelSelfReferencingComponents = new OpenApiComponents { Schemas = { ["schema1"] = new OpenApiSchema { - Reference = new OpenApiReference() + Reference = new OpenApiReference { Type = ReferenceType.Schema, Id = "schema1" diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index 924699bdf..becc91d97 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs @@ -24,13 +24,13 @@ namespace Microsoft.OpenApi.Tests.Models [UsesVerify] public class OpenApiDocumentTests { - public static OpenApiComponents TopLevelReferencingComponents = new OpenApiComponents() + public static OpenApiComponents TopLevelReferencingComponents = new OpenApiComponents { Schemas = { ["schema1"] = new OpenApiSchema { - Reference = new OpenApiReference() + Reference = new OpenApiReference { Type = ReferenceType.Schema, Id = "schema2" @@ -41,7 +41,7 @@ public class OpenApiDocumentTests Type = "object", Properties = { - ["property1"] = new OpenApiSchema() + ["property1"] = new OpenApiSchema { Type = "string" } @@ -50,7 +50,7 @@ public class OpenApiDocumentTests } }; - public static OpenApiComponents TopLevelSelfReferencingComponentsWithOtherProperties = new OpenApiComponents() + public static OpenApiComponents TopLevelSelfReferencingComponentsWithOtherProperties = new OpenApiComponents { Schemas = { @@ -59,12 +59,12 @@ public class OpenApiDocumentTests Type = "object", Properties = { - ["property1"] = new OpenApiSchema() + ["property1"] = new OpenApiSchema { Type = "string" } }, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Type = ReferenceType.Schema, Id = "schema1" @@ -75,7 +75,7 @@ public class OpenApiDocumentTests Type = "object", Properties = { - ["property1"] = new OpenApiSchema() + ["property1"] = new OpenApiSchema { Type = "string" } @@ -84,13 +84,13 @@ public class OpenApiDocumentTests } }; - public static OpenApiComponents TopLevelSelfReferencingComponents = new OpenApiComponents() + public static OpenApiComponents TopLevelSelfReferencingComponents = new OpenApiComponents { Schemas = { ["schema1"] = new OpenApiSchema { - Reference = new OpenApiReference() + Reference = new OpenApiReference { Type = ReferenceType.Schema, Id = "schema1" @@ -99,27 +99,27 @@ public class OpenApiDocumentTests } }; - public static OpenApiDocument SimpleDocumentWithTopLevelReferencingComponents = new OpenApiDocument() + public static OpenApiDocument SimpleDocumentWithTopLevelReferencingComponents = new OpenApiDocument { - Info = new OpenApiInfo() + Info = new OpenApiInfo { Version = "1.0.0" }, Components = TopLevelReferencingComponents }; - public static OpenApiDocument SimpleDocumentWithTopLevelSelfReferencingComponentsWithOtherProperties = new OpenApiDocument() + public static OpenApiDocument SimpleDocumentWithTopLevelSelfReferencingComponentsWithOtherProperties = new OpenApiDocument { - Info = new OpenApiInfo() + Info = new OpenApiInfo { Version = "1.0.0" }, Components = TopLevelSelfReferencingComponentsWithOtherProperties }; - public static OpenApiDocument SimpleDocumentWithTopLevelSelfReferencingComponents = new OpenApiDocument() + public static OpenApiDocument SimpleDocumentWithTopLevelSelfReferencingComponents = new OpenApiDocument { - Info = new OpenApiInfo() + Info = new OpenApiInfo { Version = "1.0.0" }, @@ -1485,7 +1485,7 @@ public void SerializeSimpleDocumentWithTopLevelSelfReferencingWithOtherPropertie public void SerializeDocumentWithReferenceButNoComponents() { // Arrange - var document = new OpenApiDocument() + var document = new OpenApiDocument { Info = new OpenApiInfo { @@ -1504,7 +1504,7 @@ public void SerializeDocumentWithReferenceButNoComponents() { ["200"] = new OpenApiResponse { - Content = new Dictionary() + Content = new Dictionary { ["application/json"] = new OpenApiMediaType { @@ -1546,11 +1546,12 @@ public void SerializeRelativePathAsV2JsonWorks() version: 1.0.0 basePath: /server1 paths: { }"; - var doc = new OpenApiDocument() + var doc = new OpenApiDocument { - Info = new OpenApiInfo() { Version = "1.0.0" }, - Servers = new List() { - new OpenApiServer() + Info = new OpenApiInfo { Version = "1.0.0" }, + Servers = new List + { + new OpenApiServer { Url = "/server1" } @@ -1577,11 +1578,12 @@ public void SerializeRelativePathWithHostAsV2JsonWorks() host: //example.org basePath: /server1 paths: { }"; - var doc = new OpenApiDocument() + var doc = new OpenApiDocument { - Info = new OpenApiInfo() { Version = "1.0.0" }, - Servers = new List() { - new OpenApiServer() + Info = new OpenApiInfo { Version = "1.0.0" }, + Servers = new List + { + new OpenApiServer { Url = "//example.org/server1" } @@ -1607,11 +1609,12 @@ public void SerializeRelativeRootPathWithHostAsV2JsonWorks() version: 1.0.0 host: //example.org paths: { }"; - var doc = new OpenApiDocument() + var doc = new OpenApiDocument { - Info = new OpenApiInfo() { Version = "1.0.0" }, - Servers = new List() { - new OpenApiServer() + Info = new OpenApiInfo { Version = "1.0.0" }, + Servers = new List + { + new OpenApiServer { Url = "//example.org/" } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs index de56df52e..11d8dc517 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs @@ -212,70 +212,70 @@ [new OpenApiSecurityScheme }; private static readonly OpenApiOperation _operationWithFormData = - new OpenApiOperation() + new OpenApiOperation { Summary = "Updates a pet in the store with form data", Description = "", OperationId = "updatePetWithForm", - Parameters = new List() + Parameters = new List { - new OpenApiParameter() + new OpenApiParameter { Name = "petId", In = ParameterLocation.Path, Description = "ID of pet that needs to be updated", Required = true, - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string" } } }, - RequestBody = new OpenApiRequestBody() + RequestBody = new OpenApiRequestBody { Content = { - ["application/x-www-form-urlencoded"] = new OpenApiMediaType() + ["application/x-www-form-urlencoded"] = new OpenApiMediaType { - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Properties = { - ["name"] = new OpenApiSchema() + ["name"] = new OpenApiSchema { Description = "Updated name of the pet", Type = "string" }, - ["status"] = new OpenApiSchema() + ["status"] = new OpenApiSchema { Description = "Updated status of the pet", Type = "string" } }, - Required = new HashSet() + Required = new HashSet { "name" } } }, - ["multipart/form-data"] = new OpenApiMediaType() + ["multipart/form-data"] = new OpenApiMediaType { - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Properties = { - ["name"] = new OpenApiSchema() + ["name"] = new OpenApiSchema { Description = "Updated name of the pet", Type = "string" }, - ["status"] = new OpenApiSchema() + ["status"] = new OpenApiSchema { Description = "Updated status of the pet", Type = "string" } }, - Required = new HashSet() + Required = new HashSet { "name" } @@ -283,13 +283,13 @@ [new OpenApiSecurityScheme } } }, - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { - ["200"] = new OpenApiResponse() + ["200"] = new OpenApiResponse { Description = "Pet updated." }, - ["405"] = new OpenApiResponse() + ["405"] = new OpenApiResponse { Description = "Invalid input" } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs index 9d84ab63d..d59c026e3 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs @@ -168,12 +168,12 @@ public class OpenApiSchemaTests public static OpenApiSchema AdvancedSchemaWithRequiredPropertiesObject = new OpenApiSchema { Title = "title1", - Required = new HashSet() { "property1" }, + Required = new HashSet { "property1" }, Properties = new Dictionary { ["property1"] = new OpenApiSchema { - Required = new HashSet() { "property3" }, + Required = new HashSet { "property3" }, Properties = new Dictionary { ["property2"] = new OpenApiSchema @@ -425,7 +425,7 @@ public async Task SerializeSchemaWRequiredPropertiesAsV2JsonWorksAsync(bool prod public void SerializeAsV2ShouldSetFormatPropertyInParentSchemaIfPresentInChildrenSchema() { // Arrange - var schema = new OpenApiSchema() + var schema = new OpenApiSchema { OneOf = new List { @@ -465,7 +465,7 @@ public void SerializeAsV2ShouldSetFormatPropertyInParentSchemaIfPresentInChildre [Fact] public void OpenApiSchemaCopyConstructorSucceeds() { - var baseSchema = new OpenApiSchema() + var baseSchema = new OpenApiSchema { Type = "string", Format = "date" diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApiTests.cs b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApiTests.cs index 418a526d0..8bb4901a0 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApiTests.cs +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApiTests.cs @@ -26,7 +26,7 @@ public void ReviewPublicApiChanges() // It takes a human to read the change, determine if it is breaking and update the PublicApi.approved.txt with the new approved API surface // Arrange - var publicApi = typeof(OpenApiSpecVersion).Assembly.GeneratePublicApi(new ApiGeneratorOptions() { AllowNamespacePrefixes = new[] { "Microsoft.OpenApi" } } ); + var publicApi = typeof(OpenApiSpecVersion).Assembly.GeneratePublicApi(new ApiGeneratorOptions { AllowNamespacePrefixes = new[] { "Microsoft.OpenApi" } } ); // Act var approvedFilePath = Path.Combine("PublicApi", "PublicApi.approved.txt"); diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs index cf9f0b0c6..0110cadf0 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs @@ -15,27 +15,28 @@ namespace Microsoft.OpenApi.Tests.Services [UsesVerify] public class OpenApiUrlTreeNodeTests { - private OpenApiDocument OpenApiDocumentSample_1 => new OpenApiDocument() + private OpenApiDocument OpenApiDocumentSample_1 => new OpenApiDocument { - Paths = new OpenApiPaths() + Paths = new OpenApiPaths { - ["/"] = new OpenApiPathItem() { - Operations = new Dictionary() + ["/"] = new OpenApiPathItem + { + Operations = new Dictionary { [OperationType.Get] = new OpenApiOperation(), } }, - ["/houses"] = new OpenApiPathItem() + ["/houses"] = new OpenApiPathItem { - Operations = new Dictionary() + Operations = new Dictionary { [OperationType.Get] = new OpenApiOperation(), [OperationType.Post] = new OpenApiOperation() } }, - ["/cars"] = new OpenApiPathItem() + ["/cars"] = new OpenApiPathItem { - Operations = new Dictionary() + Operations = new Dictionary { [OperationType.Post] = new OpenApiOperation() } @@ -43,9 +44,9 @@ public class OpenApiUrlTreeNodeTests } }; - private OpenApiDocument OpenApiDocumentSample_2 => new OpenApiDocument() + private OpenApiDocument OpenApiDocumentSample_2 => new OpenApiDocument { - Paths = new OpenApiPaths() + Paths = new OpenApiPaths { ["/"] = new OpenApiPathItem(), ["/hotels"] = new OpenApiPathItem(), @@ -64,9 +65,9 @@ public void CreateUrlSpaceWithoutOpenApiDocument() [Fact] public void CreateSingleRootWorks() { - var doc = new OpenApiDocument() + var doc = new OpenApiDocument { - Paths = new OpenApiPaths() + Paths = new OpenApiPaths { ["/"] = new OpenApiPathItem() } @@ -84,9 +85,9 @@ public void CreateSingleRootWorks() [Fact] public void CreatePathWithoutRootWorks() { - var doc = new OpenApiDocument() + var doc = new OpenApiDocument { - Paths = new OpenApiPaths() + Paths = new OpenApiPaths { ["/houses"] = new OpenApiPathItem() } @@ -154,10 +155,10 @@ public void AttachPathWorks() OperationType.Get, new OpenApiOperation { OperationId = "motorcycles.ListMotorcycle", - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "200", new OpenApiResponse() + "200", new OpenApiResponse { Description = "Retrieved entities" } @@ -179,10 +180,10 @@ public void AttachPathWorks() OperationType.Get, new OpenApiOperation { OperationId = "computers.ListComputer", - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "200", new OpenApiResponse() + "200", new OpenApiResponse { Description = "Retrieved entities" } @@ -207,9 +208,9 @@ public void AttachPathWorks() [Fact] public void CreatePathsWithMultipleSegmentsWorks() { - var doc = new OpenApiDocument() + var doc = new OpenApiDocument { - Paths = new OpenApiPaths() + Paths = new OpenApiPaths { ["/"] = new OpenApiPathItem(), ["/houses/apartments/{apartment-id}"] = new OpenApiPathItem(), @@ -232,13 +233,13 @@ public void CreatePathsWithMultipleSegmentsWorks() [Fact] public void HasOperationsWorks() { - var doc1 = new OpenApiDocument() + var doc1 = new OpenApiDocument { - Paths = new OpenApiPaths() + Paths = new OpenApiPaths { ["/"] = new OpenApiPathItem(), ["/houses"] = new OpenApiPathItem(), - ["/cars/{car-id}"] = new OpenApiPathItem() + ["/cars/{car-id}"] = new OpenApiPathItem { Operations = new Dictionary { @@ -246,10 +247,10 @@ public void HasOperationsWorks() OperationType.Get, new OpenApiOperation { OperationId = "cars.GetCar", - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "200", new OpenApiResponse() + "200", new OpenApiResponse { Description = "Retrieved entity" } @@ -262,11 +263,11 @@ public void HasOperationsWorks() } }; - var doc2 = new OpenApiDocument() + var doc2 = new OpenApiDocument { - Paths = new OpenApiPaths() + Paths = new OpenApiPaths { - ["/cars/{car-id}"] = new OpenApiPathItem() + ["/cars/{car-id}"] = new OpenApiPathItem { Operations = new Dictionary { @@ -274,10 +275,10 @@ public void HasOperationsWorks() OperationType.Get, new OpenApiOperation { OperationId = "cars.GetCar", - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "200", new OpenApiResponse() + "200", new OpenApiResponse { Description = "Retrieved entity" } @@ -289,10 +290,10 @@ public void HasOperationsWorks() OperationType.Put, new OpenApiOperation { OperationId = "cars.UpdateCar", - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { { - "204", new OpenApiResponse() + "204", new OpenApiResponse { Description = "Success." } @@ -326,9 +327,9 @@ public void HasOperationsWorks() [Fact] public void SegmentIsParameterWorks() { - var doc = new OpenApiDocument() + var doc = new OpenApiDocument { - Paths = new OpenApiPaths() + Paths = new OpenApiPaths { ["/"] = new OpenApiPathItem(), ["/houses/apartments/{apartment-id}"] = new OpenApiPathItem() diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs index 45cc9c3d9..813cb9517 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs @@ -30,7 +30,7 @@ public OpenApiValidatorTests(ITestOutputHelper output) public void ResponseMustHaveADescription() { var openApiDocument = new OpenApiDocument(); - openApiDocument.Info = new OpenApiInfo() + openApiDocument.Info = new OpenApiInfo { Title = "foo", Version = "1.2.2" @@ -69,7 +69,7 @@ public void ServersShouldBeReferencedByIndex() { var openApiDocument = new OpenApiDocument { - Info = new OpenApiInfo() + Info = new OpenApiInfo { Title = "foo", Version = "1.2.2" @@ -117,7 +117,7 @@ public void ValidateCustomExtension() var openApiDocument = new OpenApiDocument { - Info = new OpenApiInfo() + Info = new OpenApiInfo { Title = "foo", Version = "1.2.2" @@ -125,7 +125,7 @@ public void ValidateCustomExtension() Paths = new OpenApiPaths() }; - var fooExtension = new FooExtension() + var fooExtension = new FooExtension { Bar = "hey", Baz = "baz" diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiComponentsValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiComponentsValidationTests.cs index d10eaf590..8188d6334 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiComponentsValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiComponentsValidationTests.cs @@ -21,7 +21,7 @@ public void ValidateKeyMustMatchRegularExpressionInComponents() // Arrange const string key = "%@abc"; - OpenApiComponents components = new OpenApiComponents() + OpenApiComponents components = new OpenApiComponents { Responses = new Dictionary { diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiContactValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiContactValidationTests.cs index ec6bba7b5..221c245a5 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiContactValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiContactValidationTests.cs @@ -20,7 +20,7 @@ public void ValidateEmailFieldIsEmailAddressInContact() // Arrange const string testEmail = "support/example.com"; - OpenApiContact contact = new OpenApiContact() + OpenApiContact contact = new OpenApiContact { Email = testEmail }; diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs index 6a082ec0f..429c460a4 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs @@ -22,11 +22,11 @@ public void ValidateExampleShouldNotHaveDataTypeMismatchForSimpleSchema() { // Arrange IEnumerable errors; - var header = new OpenApiHeader() + var header = new OpenApiHeader { Required = true, Example = new OpenApiInteger(55), - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string", } @@ -59,43 +59,43 @@ public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema() // Arrange IEnumerable warnings; - var header = new OpenApiHeader() + var header = new OpenApiHeader { Required = true, - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "object", - AdditionalProperties = new OpenApiSchema() + AdditionalProperties = new OpenApiSchema { Type = "integer", } }, Examples = { - ["example0"] = new OpenApiExample() + ["example0"] = new OpenApiExample { Value = new OpenApiString("1"), }, - ["example1"] = new OpenApiExample() + ["example1"] = new OpenApiExample { - Value = new OpenApiObject() - { + Value = new OpenApiObject + { ["x"] = new OpenApiInteger(2), ["y"] = new OpenApiString("20"), ["z"] = new OpenApiString("200") } }, - ["example2"] = new OpenApiExample() + ["example2"] = new OpenApiExample { Value = - new OpenApiArray() + new OpenApiArray { new OpenApiInteger(3) } }, - ["example3"] = new OpenApiExample() + ["example3"] = new OpenApiExample { - Value = new OpenApiObject() + Value = new OpenApiObject { ["x"] = new OpenApiInteger(4), ["y"] = new OpenApiInteger(40), diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs index bdffaff28..a68d91578 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs @@ -22,10 +22,10 @@ public void ValidateExampleShouldNotHaveDataTypeMismatchForSimpleSchema() { // Arrange IEnumerable warnings; - var mediaType = new OpenApiMediaType() + var mediaType = new OpenApiMediaType { Example = new OpenApiInteger(55), - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string", } @@ -58,42 +58,42 @@ public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema() // Arrange IEnumerable warnings; - var mediaType = new OpenApiMediaType() + var mediaType = new OpenApiMediaType { - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "object", - AdditionalProperties = new OpenApiSchema() + AdditionalProperties = new OpenApiSchema { Type = "integer", } }, Examples = { - ["example0"] = new OpenApiExample() + ["example0"] = new OpenApiExample { Value = new OpenApiString("1"), }, - ["example1"] = new OpenApiExample() + ["example1"] = new OpenApiExample { - Value = new OpenApiObject() - { + Value = new OpenApiObject + { ["x"] = new OpenApiInteger(2), ["y"] = new OpenApiString("20"), ["z"] = new OpenApiString("200") } }, - ["example2"] = new OpenApiExample() + ["example2"] = new OpenApiExample { Value = - new OpenApiArray() + new OpenApiArray { new OpenApiInteger(3) } }, - ["example3"] = new OpenApiExample() + ["example3"] = new OpenApiExample { - Value = new OpenApiObject() + Value = new OpenApiObject { ["x"] = new OpenApiInteger(4), ["y"] = new OpenApiInteger(40), diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs index 89be676c5..24f28e4eb 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs @@ -41,7 +41,7 @@ public void ValidateFieldIsRequiredInParameter() public void ValidateRequiredIsTrueWhenInIsPathInParameter() { // Arrange - var parameter = new OpenApiParameter() + var parameter = new OpenApiParameter { Name = "name", In = ParameterLocation.Path @@ -66,13 +66,13 @@ public void ValidateExampleShouldNotHaveDataTypeMismatchForSimpleSchema() { // Arrange IEnumerable warnings; - var parameter = new OpenApiParameter() + var parameter = new OpenApiParameter { Name = "parameter1", In = ParameterLocation.Path, Required = true, Example = new OpenApiInteger(55), - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string", } @@ -105,45 +105,45 @@ public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema() // Arrange IEnumerable warnings; - var parameter = new OpenApiParameter() + var parameter = new OpenApiParameter { Name = "parameter1", In = ParameterLocation.Path, Required = true, - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "object", - AdditionalProperties = new OpenApiSchema() + AdditionalProperties = new OpenApiSchema { Type = "integer", } }, Examples = { - ["example0"] = new OpenApiExample() + ["example0"] = new OpenApiExample { Value = new OpenApiString("1"), }, - ["example1"] = new OpenApiExample() + ["example1"] = new OpenApiExample { - Value = new OpenApiObject() - { + Value = new OpenApiObject + { ["x"] = new OpenApiInteger(2), ["y"] = new OpenApiString("20"), ["z"] = new OpenApiString("200") } }, - ["example2"] = new OpenApiExample() + ["example2"] = new OpenApiExample { Value = - new OpenApiArray() + new OpenApiArray { new OpenApiInteger(3) } }, - ["example3"] = new OpenApiExample() + ["example3"] = new OpenApiExample { - Value = new OpenApiObject() + Value = new OpenApiObject { ["x"] = new OpenApiInteger(4), ["y"] = new OpenApiInteger(40), @@ -185,12 +185,12 @@ public void PathParameterNotInThePathShouldReturnAnError() // Arrange IEnumerable errors; - var parameter = new OpenApiParameter() + var parameter = new OpenApiParameter { Name = "parameter1", In = ParameterLocation.Path, Required = true, - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string", } @@ -223,12 +223,12 @@ public void PathParameterInThePathShouldBeOk() // Arrange IEnumerable errors; - var parameter = new OpenApiParameter() + var parameter = new OpenApiParameter { Name = "parameter1", In = ParameterLocation.Path, Required = true, - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { Type = "string", } diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs index 3ed365c8d..57f9f2cae 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs @@ -24,7 +24,7 @@ public void ReferencedSchemaShouldOnlyBeValidatedOnce() var sharedSchema = new OpenApiSchema { Type = "string", - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id = "test" }, @@ -32,29 +32,29 @@ public void ReferencedSchemaShouldOnlyBeValidatedOnce() }; OpenApiDocument document = new OpenApiDocument(); - document.Components = new OpenApiComponents() + document.Components = new OpenApiComponents { - Schemas = new Dictionary() + Schemas = new Dictionary { [sharedSchema.Reference.Id] = sharedSchema } }; - document.Paths = new OpenApiPaths() + document.Paths = new OpenApiPaths { - ["/"] = new OpenApiPathItem() + ["/"] = new OpenApiPathItem { Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation() + [OperationType.Get] = new OpenApiOperation { - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { - ["200"] = new OpenApiResponse() + ["200"] = new OpenApiResponse { - Content = new Dictionary() + Content = new Dictionary { - ["application/json"] = new OpenApiMediaType() + ["application/json"] = new OpenApiMediaType { Schema = sharedSchema } @@ -67,7 +67,7 @@ public void ReferencedSchemaShouldOnlyBeValidatedOnce() }; // Act - var errors = document.Validate(new ValidationRuleSet() { new AlwaysFailRule() }); + var errors = document.Validate(new ValidationRuleSet { new AlwaysFailRule() }); // Assert @@ -81,7 +81,7 @@ public void UnresolvedReferenceSchemaShouldNotBeValidated() var sharedSchema = new OpenApiSchema { Type = "string", - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id = "test" }, @@ -89,16 +89,16 @@ public void UnresolvedReferenceSchemaShouldNotBeValidated() }; OpenApiDocument document = new OpenApiDocument(); - document.Components = new OpenApiComponents() + document.Components = new OpenApiComponents { - Schemas = new Dictionary() + Schemas = new Dictionary { [sharedSchema.Reference.Id] = sharedSchema } }; // Act - var errors = document.Validate(new ValidationRuleSet() { new AlwaysFailRule() }); + var errors = document.Validate(new ValidationRuleSet { new AlwaysFailRule() }); // Assert Assert.True(errors.Count() == 0); @@ -111,7 +111,7 @@ public void UnresolvedSchemaReferencedShouldNotBeValidated() var sharedSchema = new OpenApiSchema { - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id = "test" }, @@ -120,21 +120,21 @@ public void UnresolvedSchemaReferencedShouldNotBeValidated() OpenApiDocument document = new OpenApiDocument(); - document.Paths = new OpenApiPaths() + document.Paths = new OpenApiPaths { - ["/"] = new OpenApiPathItem() + ["/"] = new OpenApiPathItem { Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation() + [OperationType.Get] = new OpenApiOperation { - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { - ["200"] = new OpenApiResponse() + ["200"] = new OpenApiResponse { - Content = new Dictionary() + Content = new Dictionary { - ["application/json"] = new OpenApiMediaType() + ["application/json"] = new OpenApiMediaType { Schema = sharedSchema } @@ -147,7 +147,7 @@ public void UnresolvedSchemaReferencedShouldNotBeValidated() }; // Act - var errors = document.Validate(new ValidationRuleSet() { new AlwaysFailRule() }); + var errors = document.Validate(new ValidationRuleSet { new AlwaysFailRule() }); // Assert Assert.True(errors.Count() == 0); diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs index 04acf7737..3ea545af9 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs @@ -22,7 +22,7 @@ public void ValidateDefaultShouldNotHaveDataTypeMismatchForSimpleSchema() { // Arrange IEnumerable warnings; - var schema = new OpenApiSchema() + var schema = new OpenApiSchema { Default = new OpenApiInteger(55), Type = "string", @@ -53,7 +53,7 @@ public void ValidateExampleAndDefaultShouldNotHaveDataTypeMismatchForSimpleSchem { // Arrange IEnumerable warnings; - var schema = new OpenApiSchema() + var schema = new OpenApiSchema { Example = new OpenApiLong(55), Default = new OpenApiPassword("1234"), @@ -87,29 +87,29 @@ public void ValidateEnumShouldNotHaveDataTypeMismatchForSimpleSchema() { // Arrange IEnumerable warnings; - var schema = new OpenApiSchema() + var schema = new OpenApiSchema { Enum = { new OpenApiString("1"), - new OpenApiObject() + new OpenApiObject { ["x"] = new OpenApiInteger(2), ["y"] = new OpenApiString("20"), ["z"] = new OpenApiString("200") }, - new OpenApiArray() + new OpenApiArray { new OpenApiInteger(3) }, - new OpenApiObject() + new OpenApiObject { ["x"] = new OpenApiInteger(4), ["y"] = new OpenApiInteger(40), }, }, Type = "object", - AdditionalProperties = new OpenApiSchema() + AdditionalProperties = new OpenApiSchema { Type = "integer", } @@ -146,54 +146,54 @@ public void ValidateDefaultShouldNotHaveDataTypeMismatchForComplexSchema() { // Arrange IEnumerable warnings; - var schema = new OpenApiSchema() + var schema = new OpenApiSchema { Type = "object", Properties = { - ["property1"] = new OpenApiSchema() + ["property1"] = new OpenApiSchema { Type = "array", - Items = new OpenApiSchema() + Items = new OpenApiSchema { Type = "integer", Format = "int64" } }, - ["property2"] = new OpenApiSchema() + ["property2"] = new OpenApiSchema { Type = "array", - Items = new OpenApiSchema() + Items = new OpenApiSchema { Type = "object", - AdditionalProperties = new OpenApiSchema() + AdditionalProperties = new OpenApiSchema { Type = "boolean" } } }, - ["property3"] = new OpenApiSchema() + ["property3"] = new OpenApiSchema { Type = "string", Format = "password" }, - ["property4"] = new OpenApiSchema() + ["property4"] = new OpenApiSchema { Type = "string" } }, - Default = new OpenApiObject() + Default = new OpenApiObject { - ["property1"] = new OpenApiArray() + ["property1"] = new OpenApiArray { new OpenApiInteger(12), new OpenApiLong(13), new OpenApiString("1"), }, - ["property2"] = new OpenApiArray() + ["property2"] = new OpenApiArray { new OpenApiInteger(2), - new OpenApiObject() + new OpenApiObject { ["x"] = new OpenApiBoolean(true), ["y"] = new OpenApiBoolean(false), diff --git a/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs b/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs index fc947da20..58d4d3d4c 100644 --- a/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs @@ -32,14 +32,15 @@ public void LocateTopLevelObjects() [Fact] public void LocateTopLevelArrayItems() { - var doc = new OpenApiDocument() + var doc = new OpenApiDocument { - Servers = new List() { + Servers = new List + { new OpenApiServer(), new OpenApiServer() }, Paths = new OpenApiPaths(), - Tags = new List() + Tags = new List { new OpenApiTag() } @@ -66,15 +67,15 @@ public void LocatePathOperationContentSchema() { Paths = new OpenApiPaths() }; - doc.Paths.Add("/test", new OpenApiPathItem() + doc.Paths.Add("/test", new OpenApiPathItem { - Operations = new Dictionary() + Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation() + [OperationType.Get] = new OpenApiOperation { - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { - ["200"] = new OpenApiResponse() + ["200"] = new OpenApiResponse { Content = new Dictionary { @@ -117,21 +118,21 @@ public void LocatePathOperationContentSchema() [Fact] public void WalkDOMWithCycles() { - var loopySchema = new OpenApiSchema() + var loopySchema = new OpenApiSchema { Type = "object", - Properties = new Dictionary() + Properties = new Dictionary { - ["name"] = new OpenApiSchema() { Type = "string" } + ["name"] = new OpenApiSchema { Type = "string" } } }; loopySchema.Properties.Add("parent", loopySchema); - var doc = new OpenApiDocument() + var doc = new OpenApiDocument { Paths = new OpenApiPaths(), - Components = new OpenApiComponents() + Components = new OpenApiComponents { Schemas = new Dictionary { @@ -161,9 +162,9 @@ public void WalkDOMWithCycles() public void LocateReferences() { - var baseSchema = new OpenApiSchema() + var baseSchema = new OpenApiSchema { - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id = "base", Type = ReferenceType.Schema @@ -173,8 +174,8 @@ public void LocateReferences() var derivedSchema = new OpenApiSchema { - AnyOf = new List() { baseSchema }, - Reference = new OpenApiReference() + AnyOf = new List { baseSchema }, + Reference = new OpenApiReference { Id = "derived", Type = ReferenceType.Schema @@ -182,10 +183,10 @@ public void LocateReferences() UnresolvedReference = false }; - var testHeader = new OpenApiHeader() + var testHeader = new OpenApiHeader { Schema = derivedSchema, - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id = "test-header", Type = ReferenceType.Header @@ -195,26 +196,26 @@ public void LocateReferences() var doc = new OpenApiDocument { - Paths = new OpenApiPaths() + Paths = new OpenApiPaths { - ["/"] = new OpenApiPathItem() + ["/"] = new OpenApiPathItem { - Operations = new Dictionary() + Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation() + [OperationType.Get] = new OpenApiOperation { - Responses = new OpenApiResponses() + Responses = new OpenApiResponses { - ["200"] = new OpenApiResponse() + ["200"] = new OpenApiResponse { - Content = new Dictionary() + Content = new Dictionary { - ["application/json"] = new OpenApiMediaType() + ["application/json"] = new OpenApiMediaType { Schema = derivedSchema } }, - Headers = new Dictionary() + Headers = new Dictionary { ["test-header"] = testHeader } @@ -224,14 +225,14 @@ public void LocateReferences() } } }, - Components = new OpenApiComponents() + Components = new OpenApiComponents { - Schemas = new Dictionary() + Schemas = new Dictionary { ["derived"] = derivedSchema, ["base"] = baseSchema, }, - Headers = new Dictionary() + Headers = new Dictionary { ["test-header"] = testHeader } diff --git a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiReferencableTests.cs b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiReferencableTests.cs index 2bae02b1f..d3c44c29b 100644 --- a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiReferencableTests.cs +++ b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiReferencableTests.cs @@ -18,7 +18,7 @@ public class OpenApiReferencableTests private static readonly OpenApiCallback _callbackFragment = new OpenApiCallback(); private static readonly OpenApiExample _exampleFragment = new OpenApiExample(); private static readonly OpenApiLink _linkFragment = new OpenApiLink(); - private static readonly OpenApiHeader _headerFragment = new OpenApiHeader() + private static readonly OpenApiHeader _headerFragment = new OpenApiHeader { Schema = new OpenApiSchema(), Examples = new Dictionary @@ -35,7 +35,7 @@ public class OpenApiReferencableTests } }; private static readonly OpenApiRequestBody _requestBodyFragment = new OpenApiRequestBody(); - private static readonly OpenApiResponse _responseFragment = new OpenApiResponse() + private static readonly OpenApiResponse _responseFragment = new OpenApiResponse { Headers = new Dictionary { diff --git a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs index 63045847b..6e1ff7bf8 100644 --- a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs @@ -31,25 +31,27 @@ public void OpenApiWorkspacesAllowDocumentsToReferenceEachOther() { var workspace = new OpenApiWorkspace(); - workspace.AddDocument("root", new OpenApiDocument() { - Paths = new OpenApiPaths() + workspace.AddDocument("root", new OpenApiDocument + { + Paths = new OpenApiPaths { - ["/"] = new OpenApiPathItem() + ["/"] = new OpenApiPathItem { - Operations = new Dictionary() + Operations = new Dictionary { - [OperationType.Get] = new OpenApiOperation() { - Responses = new OpenApiResponses() + [OperationType.Get] = new OpenApiOperation + { + Responses = new OpenApiResponses { - ["200"] = new OpenApiResponse() + ["200"] = new OpenApiResponse { - Content = new Dictionary() + Content = new Dictionary { - ["application/json"] = new OpenApiMediaType() + ["application/json"] = new OpenApiMediaType { - Schema = new OpenApiSchema() + Schema = new OpenApiSchema { - Reference = new OpenApiReference() + Reference = new OpenApiReference { Id = "test", Type = ReferenceType.Schema @@ -64,11 +66,13 @@ public void OpenApiWorkspacesAllowDocumentsToReferenceEachOther() } } }); - workspace.AddDocument("common", new OpenApiDocument() { - Components = new OpenApiComponents() + workspace.AddDocument("common", new OpenApiDocument + { + Components = new OpenApiComponents { Schemas = { - ["test"] = new OpenApiSchema() { + ["test"] = new OpenApiSchema + { Type = "string", Description = "The referenced one" } @@ -84,7 +88,7 @@ public void OpenApiWorkspacesCanResolveExternalReferences() { var workspace = new OpenApiWorkspace(); workspace.AddDocument("common", CreateCommonDocument()); - var schema = workspace.ResolveReference(new OpenApiReference() + var schema = workspace.ResolveReference(new OpenApiReference { Id = "test", Type = ReferenceType.Schema, @@ -109,7 +113,7 @@ public void OpenApiWorkspacesAllowDocumentsToReferenceEachOther_short() { re.Description = "Success"; re.CreateContent("application/json", co => - co.Schema = new OpenApiSchema() + co.Schema = new OpenApiSchema { Reference = new OpenApiReference() // Reference { @@ -165,7 +169,7 @@ public void OpenApiWorkspacesCanResolveReferencesToDocumentFragments() workspace.AddFragment("fragment", schemaFragment); // Act - var schema = workspace.ResolveReference(new OpenApiReference() + var schema = workspace.ResolveReference(new OpenApiReference { ExternalResource = "fragment" }) as OpenApiSchema; @@ -180,7 +184,7 @@ public void OpenApiWorkspacesCanResolveReferencesToDocumentFragmentsWithJsonPoin { // Arrange var workspace = new OpenApiWorkspace(); - var responseFragment = new OpenApiResponse() + var responseFragment = new OpenApiResponse { Headers = new Dictionary { @@ -190,7 +194,7 @@ public void OpenApiWorkspacesCanResolveReferencesToDocumentFragmentsWithJsonPoin workspace.AddFragment("fragment", responseFragment); // Act - var resolvedElement = workspace.ResolveReference(new OpenApiReference() + var resolvedElement = workspace.ResolveReference(new OpenApiReference { Id = "headers/header1", ExternalResource = "fragment" @@ -205,12 +209,13 @@ public void OpenApiWorkspacesCanResolveReferencesToDocumentFragmentsWithJsonPoin private static OpenApiDocument CreateCommonDocument() { - return new OpenApiDocument() + return new OpenApiDocument { - Components = new OpenApiComponents() + Components = new OpenApiComponents { Schemas = { - ["test"] = new OpenApiSchema() { + ["test"] = new OpenApiSchema + { Type = "string", Description = "The referenced one" } diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs index 1a15ea3b4..13f70f1e9 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs @@ -424,7 +424,7 @@ public void WriteInlineSchemaV2() private static OpenApiDocument CreateDocWithSimpleSchemaToInline() { // Arrange - var thingSchema = new OpenApiSchema() + var thingSchema = new OpenApiSchema { Type = "object", UnresolvedReference = false, @@ -435,24 +435,26 @@ private static OpenApiDocument CreateDocWithSimpleSchemaToInline() } }; - var doc = new OpenApiDocument() + var doc = new OpenApiDocument { - Info = new OpenApiInfo() + Info = new OpenApiInfo { Title = "Demo", Version = "1.0.0" }, - Paths = new OpenApiPaths() + Paths = new OpenApiPaths { ["/"] = new OpenApiPathItem { Operations = { - [OperationType.Get] = new OpenApiOperation() { + [OperationType.Get] = new OpenApiOperation + { Responses = { ["200"] = new OpenApiResponse { Description = "OK", Content = { - ["application/json"] = new OpenApiMediaType() { + ["application/json"] = new OpenApiMediaType + { Schema = thingSchema } } @@ -531,7 +533,7 @@ public void WriteInlineRecursiveSchema() private static OpenApiDocument CreateDocWithRecursiveSchemaReference() { - var thingSchema = new OpenApiSchema() + var thingSchema = new OpenApiSchema { Type = "object", UnresolvedReference = false, @@ -543,31 +545,33 @@ private static OpenApiDocument CreateDocWithRecursiveSchemaReference() }; thingSchema.Properties["children"] = thingSchema; - var relatedSchema = new OpenApiSchema() + var relatedSchema = new OpenApiSchema { Type = "integer", }; thingSchema.Properties["related"] = relatedSchema; - var doc = new OpenApiDocument() + var doc = new OpenApiDocument { - Info = new OpenApiInfo() + Info = new OpenApiInfo { Title = "Demo", Version = "1.0.0" }, - Paths = new OpenApiPaths() + Paths = new OpenApiPaths { ["/"] = new OpenApiPathItem { Operations = { - [OperationType.Get] = new OpenApiOperation() { + [OperationType.Get] = new OpenApiOperation + { Responses = { ["200"] = new OpenApiResponse { Description = "OK", Content = { - ["application/json"] = new OpenApiMediaType() { + ["application/json"] = new OpenApiMediaType + { Schema = thingSchema } }