From c7e2d1f366320bf887bb62ce675355c8ca009ae1 Mon Sep 17 00:00:00 2001 From: Marko Lahma Date: Sat, 23 Nov 2024 20:33:56 +0200 Subject: [PATCH] Fix some code formatting issues --- Directory.Build.props | 7 ++--- .../NSwagServiceCollectionExtensions.cs | 2 +- .../ArrayParameterTests.cs | 2 +- .../CSharpClientSettingsTests.cs | 10 +++---- .../WrapResponsesTests.cs | 3 +- .../CSharpGeneratorBase.cs | 2 +- .../Models/CSharpClientTemplateModel.cs | 6 ++-- .../Models/CSharpTemplateModelBase.cs | 6 ++-- .../AngularTests.cs | 4 +-- .../JQueryCallbacksTests.cs | 10 +++---- .../JQueryPromisesTests.cs | 10 +++---- .../TypeScriptDiscriminatorTests.cs | 8 ++--- .../TypeScriptOperationParameterTests.cs | 2 +- .../Models/OperationModelBase.cs | 2 +- ...sFromPathSegmentsOperationNameGenerator.cs | 4 +-- ...tFromPathSegmentsOperationNameGenerator.cs | 4 +-- .../AspNetCore/AspNetCoreToOpenApiCommand.cs | 2 +- .../Generation/AspNetCore/ProjectMetadata.cs | 2 +- src/NSwag.Commands/NSwagCommandProcessor.cs | 2 +- src/NSwag.Commands/NSwagDocument.cs | 1 - src/NSwag.Commands/NSwagDocumentBase.cs | 2 +- src/NSwag.Commands/NewLineBehavior.cs | 4 +-- .../MediaTypesSerializationTests.cs | 4 +-- .../YamlDocumentTests.cs | 22 +++++++------- src/NSwag.Core.Yaml/OpenApiYamlDocument.cs | 2 +- .../Collections/ObservableDictionary.cs | 8 ++--- src/NSwag.Core/OpenApiOperationDescription.cs | 2 +- src/NSwag.Core/OpenApiRequestBody.cs | 2 +- src/NSwag.Core/OpenApiResponse.cs | 2 +- .../ComplexQueryParametersController.cs | 2 +- .../Parameters/FileUploadController.cs | 4 +-- .../Responses/WrappedResponseController.cs | 19 ++++++------ .../AspNetCoreToSwaggerGenerationTests.cs | 6 ++-- .../Responses/ProducesTests.cs | 2 +- .../Responses/WrappedResponseTests.cs | 30 ++++++++++--------- .../SystemTextJsonTests.cs | 2 +- .../AspNetCoreOpenApiDocumentGenerator.cs | 2 +- ...tionSummaryAndDescriptionProcessorTests.cs | 12 ++++---- .../Processors/OperationParameterProcessor.cs | 4 +-- .../WebApiOpenApiDocumentGenerator.cs | 2 +- .../OpenApiSchemaGenerator.cs | 2 +- src/NSwag.Sample.NET80Minimal/Program.cs | 10 +++---- src/NSwag.Sample.NET90Minimal/Program.cs | 17 +++++------ 43 files changed, 123 insertions(+), 128 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 563f7fbb4d..2d97971095 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -57,11 +57,9 @@ [IDE0039] Use local function [IDE0045] 'if' statement can be simplified [IDE0046] 'if' statement can be simplified - [IDE0055] Fix formatting [IDE0056] Indexing can be simplified [IDE0057] Substring can be simplified [IDE0060] Remove unused parameter - [IDE0061] Use block body for local function [IDE0090] 'new' expression can be simplified [IDE0130] Namespace does not match folder structure [IDE0160] Convert to block scoped namespace @@ -77,14 +75,13 @@ [CA1720] Identifier 'xxx' contains type name [CA1725] Overriden parameter name mismatch [CA1845] Use span-based 'string.Concat' and 'AsSpan' instead of 'Substring' - [CA1861] Prefer 'static readonly' fields over constant array arguments [CA1870] Use a cached 'SearchValues' instance for improved searching performance [CA2263] Prefer the generic overload 'System.Enum.GetValues()' [SYSLIB0012] 'Assembly.CodeBase' is obsolete --> - $(NoWarn);IDE0005;IDE0008;IDE0017;IDE0021;IDE0022;IDE0029;IDE0032;IDE0039;IDE0045;IDE0046;IDE0055;IDE0056;IDE0057;IDE0060;IDE0061;IDE0090;IDE0130;IDE0160;IDE0200;IDE0270;IDE0290;IDE0330 - $(NoWarn);CA1200;CA1510;CA1514;CA1710;CA1716;CA1720;CA1725;CA1845;CA1861;CA1870;CA2263;SYSLIB0012 + $(NoWarn);IDE0005;IDE0008;IDE0017;IDE0021;IDE0022;IDE0029;IDE0032;IDE0039;IDE0045;IDE0046;IDE0056;IDE0057;IDE0060;IDE0090;IDE0130;IDE0160;IDE0200;IDE0270;IDE0290;IDE0330 + $(NoWarn);CA1200;CA1510;CA1514;CA1710;CA1716;CA1720;CA1725;CA1845;CA1870;CA2263;SYSLIB0012 diff --git a/src/NSwag.AspNetCore/Extensions/NSwagServiceCollectionExtensions.cs b/src/NSwag.AspNetCore/Extensions/NSwagServiceCollectionExtensions.cs index 8f17aad2ed..5e0bb0ceb9 100644 --- a/src/NSwag.AspNetCore/Extensions/NSwagServiceCollectionExtensions.cs +++ b/src/NSwag.AspNetCore/Extensions/NSwagServiceCollectionExtensions.cs @@ -81,7 +81,7 @@ public static IServiceCollection AddSwaggerDocument(this IServiceCollection serv if (newtonsoftSettings != null && !hasSystemTextJsonOutputFormatter) { settings.ApplySettings(new NewtonsoftJsonSchemaGeneratorSettings { SerializerSettings = newtonsoftSettings }, mvcOptions.Value); - } + } else if (systemTextJsonOptions != null) { settings.ApplySettings(new SystemTextJsonSchemaGeneratorSettings { SerializerOptions = systemTextJsonOptions }, mvcOptions.Value); diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/ArrayParameterTests.cs b/src/NSwag.CodeGeneration.CSharp.Tests/ArrayParameterTests.cs index 8bbacbd2b3..50fef82b6b 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/ArrayParameterTests.cs +++ b/src/NSwag.CodeGeneration.CSharp.Tests/ArrayParameterTests.cs @@ -67,7 +67,7 @@ public async Task When_parameter_is_array_then_CSharp_is_correct() // Assert Assert.Contains(@"foreach (var item_ in elementId) { urlBuilder_.Append(System.Uri.EscapeDataString(""elementId"")).Append('=').Append(System.Uri.EscapeDataString(ConvertToString(item_, System.Globalization.CultureInfo.InvariantCulture))).Append('&'); }", code); } - + [Fact] public async Task when_content_is_formdata_with_property_array_then_content_should_be_added_in_foreach_in_csharp() { diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/CSharpClientSettingsTests.cs b/src/NSwag.CodeGeneration.CSharp.Tests/CSharpClientSettingsTests.cs index c76eb56fb6..20cb289665 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/CSharpClientSettingsTests.cs +++ b/src/NSwag.CodeGeneration.CSharp.Tests/CSharpClientSettingsTests.cs @@ -47,7 +47,7 @@ public async Task When_UseHttpRequestMessageCreationMethod_is_set_then_CreateReq { SchemaSettings = new NewtonsoftJsonSchemaGeneratorSettings() }); - + var document = await swaggerGenerator.GenerateForControllerAsync(); var generator = new CSharpClientGenerator(document, new CSharpClientGeneratorSettings { @@ -95,7 +95,7 @@ public async Task When_parameter_name_is_reserved_keyword_then_it_is_appended_wi { SchemaSettings = new NewtonsoftJsonSchemaGeneratorSettings() }); - + var document = await swaggerGenerator.GenerateForControllerAsync(); var generator = new CSharpClientGenerator(document, new CSharpClientGeneratorSettings()); @@ -114,7 +114,7 @@ public async Task When_code_is_generated_then_by_default_the_system_httpclient_i { SchemaSettings = new NewtonsoftJsonSchemaGeneratorSettings() }); - + var document = await swaggerGenerator.GenerateForControllerAsync(); var generator = new CSharpClientGenerator(document, new CSharpClientGeneratorSettings { @@ -212,7 +212,7 @@ public async Task When_client_class_generation_is_enabled_and_suppressed_then_cl SuppressClientClassesOutput = true, GenerateClientInterfaces = true, // SuppressClientInterfacesOutput = false, // default - }); + }); // Act var code = generator.GenerateFile(); @@ -238,7 +238,7 @@ public async Task When_client_interface_generation_is_enabled_and_suppressed_the // SuppressClientClassesOutput = false, // default GenerateClientInterfaces = true, SuppressClientInterfacesOutput = true, - }); + }); // Act var code = generator.GenerateFile(); diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/WrapResponsesTests.cs b/src/NSwag.CodeGeneration.CSharp.Tests/WrapResponsesTests.cs index e1aa72435a..28feb6d709 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/WrapResponsesTests.cs +++ b/src/NSwag.CodeGeneration.CSharp.Tests/WrapResponsesTests.cs @@ -60,7 +60,7 @@ public async Task When_success_responses_are_wrapped_then_SwaggerResponse_is_ret WrapResponses = true }); var code = codeGen.GenerateFile(); - + // Assert Assert.Contains("Task>", code); Assert.Contains("Task", code); @@ -81,7 +81,6 @@ public async Task When_success_responses_are_wrapped_then_SwaggerResponse_is_ret var codeGen = new CSharpControllerGenerator(document, new CSharpControllerGeneratorSettings { WrapResponses = true, - }); var code = codeGen.GenerateFile(); diff --git a/src/NSwag.CodeGeneration.CSharp/CSharpGeneratorBase.cs b/src/NSwag.CodeGeneration.CSharp/CSharpGeneratorBase.cs index 0d2f6cf905..54c8431ced 100644 --- a/src/NSwag.CodeGeneration.CSharp/CSharpGeneratorBase.cs +++ b/src/NSwag.CodeGeneration.CSharp/CSharpGeneratorBase.cs @@ -60,7 +60,7 @@ public override string GetTypeName(JsonSchema schema, bool isNullable, string ty /// FileResponse by default, FileResult if ControllerTarger parameter is AspNetCore public override string GetBinaryResponseTypeName() { - if (_settings is CSharpControllerGeneratorSettings controllerSettings + if (_settings is CSharpControllerGeneratorSettings controllerSettings && controllerSettings.ControllerTarget == CSharpControllerTarget.AspNetCore) { return "FileResult"; diff --git a/src/NSwag.CodeGeneration.CSharp/Models/CSharpClientTemplateModel.cs b/src/NSwag.CodeGeneration.CSharp/Models/CSharpClientTemplateModel.cs index bdc31af5cf..27d4741384 100644 --- a/src/NSwag.CodeGeneration.CSharp/Models/CSharpClientTemplateModel.cs +++ b/src/NSwag.CodeGeneration.CSharp/Models/CSharpClientTemplateModel.cs @@ -163,7 +163,7 @@ public string JsonSerializerParameterCode get { var parameterCode = CSharpJsonSerializerGenerator.GenerateJsonSerializerParameterCode( - _settings.CSharpGeneratorSettings, RequiresJsonExceptionConverter ? new[] { "JsonExceptionConverter" } : null); + _settings.CSharpGeneratorSettings, RequiresJsonExceptionConverter ? jsonExceptionConverterArray : null); if (!parameterCode.Contains("new Newtonsoft.Json.JsonSerializerSettings")) { @@ -178,7 +178,7 @@ public string JsonSerializerParameterCode /// Gets the JSON converters array code. public string JsonConvertersArrayCode - => CSharpJsonSerializerGenerator.GenerateJsonConvertersArrayCode(_settings.CSharpGeneratorSettings, RequiresJsonExceptionConverter ? new[] { "JsonExceptionConverter" } : null); + => CSharpJsonSerializerGenerator.GenerateJsonConvertersArrayCode(_settings.CSharpGeneratorSettings, RequiresJsonExceptionConverter ? jsonExceptionConverterArray : null); /// Gets the Title. public string Title => _document.Info.Title; @@ -196,5 +196,7 @@ public string JsonConvertersArrayCode _settings.CSharpGeneratorSettings.JsonLibrary == CSharpJsonLibrary.NewtonsoftJson && _settings.CSharpGeneratorSettings.ExcludedTypeNames?.Contains("JsonExceptionConverter") != true && _document.Operations.Any(o => o.Operation.ActualResponses.Any(r => r.Value.Schema?.InheritsSchema(_exceptionSchema) == true)); + + private static readonly string[] jsonExceptionConverterArray = ["JsonExceptionConverter"]; } } \ No newline at end of file diff --git a/src/NSwag.CodeGeneration.CSharp/Models/CSharpTemplateModelBase.cs b/src/NSwag.CodeGeneration.CSharp/Models/CSharpTemplateModelBase.cs index d4d27e6004..e30f388a7b 100644 --- a/src/NSwag.CodeGeneration.CSharp/Models/CSharpTemplateModelBase.cs +++ b/src/NSwag.CodeGeneration.CSharp/Models/CSharpTemplateModelBase.cs @@ -38,8 +38,8 @@ protected CSharpTemplateModelBase(string controllerName, CSharpGeneratorBaseSett public bool UseSystemTextJson => _settings.CSharpGeneratorSettings.JsonLibrary == CSharpJsonLibrary.SystemTextJson; /// Gets the JSON serializer settings type. - public string JsonSerializerSettingsType => _settings.CSharpGeneratorSettings.JsonLibrary == CSharpJsonLibrary.SystemTextJson ? - "System.Text.Json.JsonSerializerOptions" : - "Newtonsoft.Json.JsonSerializerSettings"; + public string JsonSerializerSettingsType => _settings.CSharpGeneratorSettings.JsonLibrary == CSharpJsonLibrary.SystemTextJson + ? "System.Text.Json.JsonSerializerOptions" + : "Newtonsoft.Json.JsonSerializerSettings"; } } diff --git a/src/NSwag.CodeGeneration.TypeScript.Tests/AngularTests.cs b/src/NSwag.CodeGeneration.TypeScript.Tests/AngularTests.cs index 9ea6574c29..1a4a48a116 100644 --- a/src/NSwag.CodeGeneration.TypeScript.Tests/AngularTests.cs +++ b/src/NSwag.CodeGeneration.TypeScript.Tests/AngularTests.cs @@ -18,7 +18,7 @@ public class Foo public class DiscussionController : Controller { [HttpPost] - public void AddMessage([FromBody, Required]Foo message) + public void AddMessage([FromBody, Required] Foo message) { } @@ -66,7 +66,7 @@ public class UrlEncodedRequestConsumingController : Controller { [HttpPost] [Consumes("application/x-www-form-urlencoded")] - public void AddMessage([FromForm]Foo message, [FromForm]string messageId) + public void AddMessage([FromForm] Foo message, [FromForm] string messageId) { } } diff --git a/src/NSwag.CodeGeneration.TypeScript.Tests/JQueryCallbacksTests.cs b/src/NSwag.CodeGeneration.TypeScript.Tests/JQueryCallbacksTests.cs index dba038aead..83d2a40f0f 100644 --- a/src/NSwag.CodeGeneration.TypeScript.Tests/JQueryCallbacksTests.cs +++ b/src/NSwag.CodeGeneration.TypeScript.Tests/JQueryCallbacksTests.cs @@ -16,16 +16,16 @@ public class Foo public class DiscussionController : Controller { [HttpPost] - public void AddMessage([FromBody]Foo message) + public void AddMessage([FromBody] Foo message) { } } - - public class UrlEncodedRequestConsumingController: Controller + + public class UrlEncodedRequestConsumingController : Controller { [HttpPost] [Consumes("application/x-www-form-urlencoded")] - public void AddMessage([FromForm]Foo message, [FromForm]string messageId) + public void AddMessage([FromForm] Foo message, [FromForm] string messageId) { } } @@ -91,7 +91,7 @@ public async Task When_export_types_is_false_then_dont_add_export_before_classes Assert.DoesNotContain("export class DiscussionClient", code); Assert.DoesNotContain("export interface IDiscussionClient", code); } - + [Fact] public async Task When_consumes_is_url_encoded_then_construct_url_encoded_request() { diff --git a/src/NSwag.CodeGeneration.TypeScript.Tests/JQueryPromisesTests.cs b/src/NSwag.CodeGeneration.TypeScript.Tests/JQueryPromisesTests.cs index a344126cb9..5f2ece96ce 100644 --- a/src/NSwag.CodeGeneration.TypeScript.Tests/JQueryPromisesTests.cs +++ b/src/NSwag.CodeGeneration.TypeScript.Tests/JQueryPromisesTests.cs @@ -16,16 +16,16 @@ public class Foo public class DiscussionController : Controller { [HttpPost] - public void AddMessage([FromBody]Foo message) + public void AddMessage([FromBody] Foo message) { } } - - public class UrlEncodedRequestConsumingController: Controller + + public class UrlEncodedRequestConsumingController : Controller { [HttpPost] [Consumes("application/x-www-form-urlencoded")] - public void AddMessage([FromForm]Foo message, [FromForm]string messageId) + public void AddMessage([FromForm] Foo message, [FromForm] string messageId) { } } @@ -91,7 +91,7 @@ public async Task When_export_types_is_false_then_dont_add_export_before_classes Assert.DoesNotContain("export class DiscussionClient", code); Assert.DoesNotContain("export interface IDiscussionClient", code); } - + [Fact] public async Task When_consumes_is_url_encoded_then_construct_url_encoded_request() { diff --git a/src/NSwag.CodeGeneration.TypeScript.Tests/TypeScriptDiscriminatorTests.cs b/src/NSwag.CodeGeneration.TypeScript.Tests/TypeScriptDiscriminatorTests.cs index c466101b8f..b52fe2a825 100644 --- a/src/NSwag.CodeGeneration.TypeScript.Tests/TypeScriptDiscriminatorTests.cs +++ b/src/NSwag.CodeGeneration.TypeScript.Tests/TypeScriptDiscriminatorTests.cs @@ -39,7 +39,7 @@ public class SecondChild : Base public class Nested { public Base Child { get; set; } - + public ICollection ChildCollection { get; set; } } @@ -50,19 +50,19 @@ public string TestLeaf(Base param) { return null; } - + [Route("foo-arr")] public string TestLeafArr(ICollection param) { return null; } - + [Route("bar")] public string Test(OneChild param) { return null; } - + [Route("baz")] public string TestNested(Nested param) { diff --git a/src/NSwag.CodeGeneration.TypeScript.Tests/TypeScriptOperationParameterTests.cs b/src/NSwag.CodeGeneration.TypeScript.Tests/TypeScriptOperationParameterTests.cs index 7c6f38c8f0..c65c5799e3 100644 --- a/src/NSwag.CodeGeneration.TypeScript.Tests/TypeScriptOperationParameterTests.cs +++ b/src/NSwag.CodeGeneration.TypeScript.Tests/TypeScriptOperationParameterTests.cs @@ -41,7 +41,7 @@ public async Task When_parameter_is_nullable_and_ts20_then_it_is_a_union_type_wi { TypeScriptGeneratorSettings = { - TypeScriptVersion = 2.0m, + TypeScriptVersion = 2.0m, NullValue = TypeScriptNullValue.Undefined } }); diff --git a/src/NSwag.CodeGeneration/Models/OperationModelBase.cs b/src/NSwag.CodeGeneration/Models/OperationModelBase.cs index 34f7232f1c..bd4393668b 100644 --- a/src/NSwag.CodeGeneration/Models/OperationModelBase.cs +++ b/src/NSwag.CodeGeneration/Models/OperationModelBase.cs @@ -345,7 +345,7 @@ protected IList GetActualParameters() var formDataSchema = _operation?.ActualRequestBody?.Content?.ContainsKey("multipart/form-data") == true ? - _operation.ActualRequestBody.Content["multipart/form-data"]?.Schema.ActualSchema: null; + _operation.ActualRequestBody.Content["multipart/form-data"]?.Schema.ActualSchema : null; if (formDataSchema != null && formDataSchema.ActualProperties.Count > 0) { diff --git a/src/NSwag.CodeGeneration/OperationNameGenerators/MultipleClientsFromPathSegmentsOperationNameGenerator.cs b/src/NSwag.CodeGeneration/OperationNameGenerators/MultipleClientsFromPathSegmentsOperationNameGenerator.cs index 2b8e199f22..c3daf43f57 100644 --- a/src/NSwag.CodeGeneration/OperationNameGenerators/MultipleClientsFromPathSegmentsOperationNameGenerator.cs +++ b/src/NSwag.CodeGeneration/OperationNameGenerators/MultipleClientsFromPathSegmentsOperationNameGenerator.cs @@ -43,8 +43,8 @@ public virtual string GetOperationName(OpenApiDocument document, string path, st var hasNameConflict = document.Paths .SelectMany(pair => pair.Value.ActualPathItem .Select(p => new { Path = pair.Key.Trim('/'), HttpMethod = p.Key, Operation = p.Value })) - .Where(op => - GetClientName(document, op.Path, op.HttpMethod, op.Operation) == GetClientName(document, path, httpMethod, operation) && + .Where(op => + GetClientName(document, op.Path, op.HttpMethod, op.Operation) == GetClientName(document, path, httpMethod, operation) && ConvertPathToName(op.Path) == operationName ).ToList() .Count > 1; diff --git a/src/NSwag.CodeGeneration/OperationNameGenerators/SingleClientFromPathSegmentsOperationNameGenerator.cs b/src/NSwag.CodeGeneration/OperationNameGenerators/SingleClientFromPathSegmentsOperationNameGenerator.cs index 0a7bfde57f..501de49887 100644 --- a/src/NSwag.CodeGeneration/OperationNameGenerators/SingleClientFromPathSegmentsOperationNameGenerator.cs +++ b/src/NSwag.CodeGeneration/OperationNameGenerators/SingleClientFromPathSegmentsOperationNameGenerator.cs @@ -39,8 +39,8 @@ public virtual string GetOperationName(OpenApiDocument document, string path, st var hasNameConflict = document.Paths .SelectMany(pair => pair.Value.ActualPathItem .Select(p => new { Path = pair.Key.Trim('/'), HttpMethod = p.Key, Operation = p.Value })) - .Where(op => - GetClientName(document, op.Path, op.HttpMethod, op.Operation) == GetClientName(document, path, httpMethod, operation) && + .Where(op => + GetClientName(document, op.Path, op.HttpMethod, op.Operation) == GetClientName(document, path, httpMethod, operation) && ConvertPathToName(op.Path) == operationName ) .ToList().Count > 1; diff --git a/src/NSwag.Commands/Commands/Generation/AspNetCore/AspNetCoreToOpenApiCommand.cs b/src/NSwag.Commands/Commands/Generation/AspNetCore/AspNetCoreToOpenApiCommand.cs index 555a66ce46..8f47fb722f 100644 --- a/src/NSwag.Commands/Commands/Generation/AspNetCore/AspNetCoreToOpenApiCommand.cs +++ b/src/NSwag.Commands/Commands/Generation/AspNetCore/AspNetCoreToOpenApiCommand.cs @@ -153,7 +153,7 @@ public override async Task RunAsync(CommandLineProcessor processor, ICon var binaryName = LauncherBinaryName + ".dll"; var executorBinary = Path.Combine(toolDirectory, binaryName); - + if (!File.Exists(executorBinary)) { binaryName = LauncherBinaryName + ".exe"; diff --git a/src/NSwag.Commands/Commands/Generation/AspNetCore/ProjectMetadata.cs b/src/NSwag.Commands/Commands/Generation/AspNetCore/ProjectMetadata.cs index 15fe0894ba..d74197cc72 100644 --- a/src/NSwag.Commands/Commands/Generation/AspNetCore/ProjectMetadata.cs +++ b/src/NSwag.Commands/Commands/Generation/AspNetCore/ProjectMetadata.cs @@ -234,7 +234,7 @@ private static async Task> TryReadingUsingGetProperti { WorkingDirectory = Path.GetDirectoryName(file), FileName = "dotnet", - Arguments = $"{string.Join(" " , args)} --getProperty:{string.Join(";", properties)}", + Arguments = $"{string.Join(" ", args)} --getProperty:{string.Join(";", properties)}", CreateNoWindow = true, RedirectStandardOutput = true, RedirectStandardError = true diff --git a/src/NSwag.Commands/NSwagCommandProcessor.cs b/src/NSwag.Commands/NSwagCommandProcessor.cs index 4840b3afa7..fbec698d12 100644 --- a/src/NSwag.Commands/NSwagCommandProcessor.cs +++ b/src/NSwag.Commands/NSwagCommandProcessor.cs @@ -81,7 +81,7 @@ private void WriteBinDirectory() var getEntryAssemblyMethod = typeof(Assembly).GetRuntimeMethod("GetEntryAssembly", []); if (getEntryAssemblyMethod != null) { - entryAssembly = (Assembly) getEntryAssemblyMethod.Invoke(null, []); + entryAssembly = (Assembly)getEntryAssemblyMethod.Invoke(null, []); } else { diff --git a/src/NSwag.Commands/NSwagDocument.cs b/src/NSwag.Commands/NSwagDocument.cs index cbdab1cd65..52b9b9b0e5 100644 --- a/src/NSwag.Commands/NSwagDocument.cs +++ b/src/NSwag.Commands/NSwagDocument.cs @@ -245,7 +245,6 @@ private string GetArgumentsPrefix() { return "\"" + System.IO.Path.Combine(RootBinaryDirectory, "Net90/dotnet-nswag.dll") + "\" "; } - else #endif return ""; } diff --git a/src/NSwag.Commands/NSwagDocumentBase.cs b/src/NSwag.Commands/NSwagDocumentBase.cs index fa0042fca1..c3d54ca9cd 100644 --- a/src/NSwag.Commands/NSwagDocumentBase.cs +++ b/src/NSwag.Commands/NSwagDocumentBase.cs @@ -263,7 +263,7 @@ public string ToJson() /// The document. protected async Task GenerateSwaggerDocumentAsync() { - return (OpenApiDocument) await SelectedSwaggerGenerator.RunAsync(null, null); + return (OpenApiDocument)await SelectedSwaggerGenerator.RunAsync(null, null); } private static string EscapeJsonString(string value) diff --git a/src/NSwag.Commands/NewLineBehavior.cs b/src/NSwag.Commands/NewLineBehavior.cs index e02525905b..a423f74102 100644 --- a/src/NSwag.Commands/NewLineBehavior.cs +++ b/src/NSwag.Commands/NewLineBehavior.cs @@ -16,12 +16,12 @@ public enum NewLineBehavior /// /// Automatic line ending based on the current OS. /// - Auto, + Auto, /// /// CRLF. /// - CRLF, + CRLF, /// /// LF. diff --git a/src/NSwag.Core.Tests/Serialization/MediaTypesSerializationTests.cs b/src/NSwag.Core.Tests/Serialization/MediaTypesSerializationTests.cs index 88c3c6d917..ff598e624e 100644 --- a/src/NSwag.Core.Tests/Serialization/MediaTypesSerializationTests.cs +++ b/src/NSwag.Core.Tests/Serialization/MediaTypesSerializationTests.cs @@ -159,13 +159,13 @@ private static OpenApiDocument CreateDocument(JsonObjectType type) new OpenApiPathItem { { - OpenApiOperationMethod.Get, + OpenApiOperationMethod.Get, new OpenApiOperation { Responses = { { - "200", + "200", new OpenApiResponse { Examples = 123, diff --git a/src/NSwag.Core.Yaml.Tests/YamlDocumentTests.cs b/src/NSwag.Core.Yaml.Tests/YamlDocumentTests.cs index b6c22aa460..6d09c0b636 100644 --- a/src/NSwag.Core.Yaml.Tests/YamlDocumentTests.cs +++ b/src/NSwag.Core.Yaml.Tests/YamlDocumentTests.cs @@ -59,8 +59,8 @@ public async Task When_yaml_with_custom_property_is_loaded_then_document_is_not_ [Fact] public async Task When_yaml_with_custom_property_which_is_an_object_is_loaded_then_document_is_not_null() { - // Arrange - var yaml = @"swagger: '2.0' + // Arrange + var yaml = @"swagger: '2.0' info: title: foo version: '1.0' @@ -73,15 +73,15 @@ public async Task When_yaml_with_custom_property_which_is_an_object_is_loaded_th '200': description: baz"; - // Act - var document = await OpenApiYamlDocument.FromYamlAsync(yaml); - yaml = document.ToYaml(); + // Act + var document = await OpenApiYamlDocument.FromYamlAsync(yaml); + yaml = document.ToYaml(); - // Assert - Assert.NotNull(document); - Assert.Equal(JObject.Parse(@"{""bar"": ""baz""}"), document.Paths.First().Value.ExtensionData["x-swagger-router-controller"]); - Assert.Equal("baz", document.Paths.First().Value["get"].Responses["200"].Description); - Assert.Contains("bar: baz", yaml); + // Assert + Assert.NotNull(document); + Assert.Equal(JObject.Parse(@"{""bar"": ""baz""}"), document.Paths.First().Value.ExtensionData["x-swagger-router-controller"]); + Assert.Equal("baz", document.Paths.First().Value["get"].Responses["200"].Description); + Assert.Contains("bar: baz", yaml); } } -} +} \ No newline at end of file diff --git a/src/NSwag.Core.Yaml/OpenApiYamlDocument.cs b/src/NSwag.Core.Yaml/OpenApiYamlDocument.cs index 5e9a206dcc..6f23050882 100644 --- a/src/NSwag.Core.Yaml/OpenApiYamlDocument.cs +++ b/src/NSwag.Core.Yaml/OpenApiYamlDocument.cs @@ -57,7 +57,7 @@ public static Task FromYamlAsync(string data, string documentPa /// The JSON reference resolver factory. /// The cancellation token. /// The . - public static async Task FromYamlAsync(string data, string documentPath, SchemaType expectedSchemaType, + public static async Task FromYamlAsync(string data, string documentPath, SchemaType expectedSchemaType, Func referenceResolverFactory, CancellationToken cancellationToken = default) { var deserializer = new DeserializerBuilder().Build(); diff --git a/src/NSwag.Core/Collections/ObservableDictionary.cs b/src/NSwag.Core/Collections/ObservableDictionary.cs index 531ce2b252..7e27d4fd61 100644 --- a/src/NSwag.Core/Collections/ObservableDictionary.cs +++ b/src/NSwag.Core/Collections/ObservableDictionary.cs @@ -309,7 +309,7 @@ public bool Contains(object key) IDictionaryEnumerator IDictionary.GetEnumerator() { - return ((IDictionary) _dictionary).GetEnumerator(); + return ((IDictionary)_dictionary).GetEnumerator(); } /// Removes the specified key. @@ -335,7 +335,7 @@ public bool Contains(KeyValuePair item) /// Index of the array. public void CopyTo(KeyValuePair[] array, int arrayIndex) { - ((IDictionary) _dictionary).CopyTo(array, arrayIndex); + ((IDictionary)_dictionary).CopyTo(array, arrayIndex); } /// Copies to. @@ -356,7 +356,7 @@ public void CopyTo(Array array, int index) public object SyncRoot { get; private set; } /// Gets a value indicating whether the is read-only. - public bool IsReadOnly => ((IDictionary) _dictionary).IsReadOnly; + public bool IsReadOnly => ((IDictionary)_dictionary).IsReadOnly; object IDictionary.this[object key] { @@ -396,7 +396,7 @@ public Dictionary.Enumerator GetEnumerator() IEnumerator IEnumerable.GetEnumerator() { - return ((IDictionary) _dictionary).GetEnumerator(); + return ((IDictionary)_dictionary).GetEnumerator(); } #endregion diff --git a/src/NSwag.Core/OpenApiOperationDescription.cs b/src/NSwag.Core/OpenApiOperationDescription.cs index 27fa19cdf2..fffee59d9f 100644 --- a/src/NSwag.Core/OpenApiOperationDescription.cs +++ b/src/NSwag.Core/OpenApiOperationDescription.cs @@ -15,7 +15,7 @@ public class OpenApiOperationDescription public string Path { get; set; } /// Gets or sets the HTTP method. - public string Method { get; set; } + public string Method { get; set; } /// Gets or sets the operation. public OpenApiOperation Operation { get; set; } diff --git a/src/NSwag.Core/OpenApiRequestBody.cs b/src/NSwag.Core/OpenApiRequestBody.cs index f76527a299..7fe5036df5 100644 --- a/src/NSwag.Core/OpenApiRequestBody.cs +++ b/src/NSwag.Core/OpenApiRequestBody.cs @@ -101,7 +101,7 @@ public int? Position /// Gets the actual name of the request body parameter. [JsonIgnore] public string ActualName => string.IsNullOrEmpty(Name) ? "body" : Name; - + #region Implementation of IJsonReference [JsonIgnore] diff --git a/src/NSwag.Core/OpenApiResponse.cs b/src/NSwag.Core/OpenApiResponse.cs index a81bcab62b..3dce46813d 100644 --- a/src/NSwag.Core/OpenApiResponse.cs +++ b/src/NSwag.Core/OpenApiResponse.cs @@ -17,7 +17,7 @@ namespace NSwag public class OpenApiResponse : JsonReferenceBase, IJsonReference { // (RegexOptions) 0x0008 = Compiled - private static readonly Regex AppJsonRegex = new Regex(@"application\/(\S+?)?\+?json;?(\S+)?", (RegexOptions) 0x0008); + private static readonly Regex AppJsonRegex = new Regex(@"application\/(\S+?)?\+?json;?(\S+)?", (RegexOptions)0x0008); /// Gets or sets the extension data (i.e. additional properties which are not directly defined by the JSON object). [JsonExtensionData] diff --git a/src/NSwag.Generation.AspNetCore.Tests.Web/Controllers/Parameters/ComplexQueryParametersController.cs b/src/NSwag.Generation.AspNetCore.Tests.Web/Controllers/Parameters/ComplexQueryParametersController.cs index a800992058..2ba0c5b582 100644 --- a/src/NSwag.Generation.AspNetCore.Tests.Web/Controllers/Parameters/ComplexQueryParametersController.cs +++ b/src/NSwag.Generation.AspNetCore.Tests.Web/Controllers/Parameters/ComplexQueryParametersController.cs @@ -8,7 +8,7 @@ public class ComplexQueryParametersController : Controller { /// Foo. [HttpGet] - public ActionResult GetList([FromQuery]GetListCommand getListCommand) + public ActionResult GetList([FromQuery] GetListCommand getListCommand) { return Ok(); } diff --git a/src/NSwag.Generation.AspNetCore.Tests.Web/Controllers/Parameters/FileUploadController.cs b/src/NSwag.Generation.AspNetCore.Tests.Web/Controllers/Parameters/FileUploadController.cs index 03c5d12bf0..f1034a734d 100644 --- a/src/NSwag.Generation.AspNetCore.Tests.Web/Controllers/Parameters/FileUploadController.cs +++ b/src/NSwag.Generation.AspNetCore.Tests.Web/Controllers/Parameters/FileUploadController.cs @@ -9,13 +9,13 @@ namespace NSwag.Generation.AspNetCore.Tests.Web.Controllers.Parameters public class FileUploadController : Controller { [HttpPost("UploadFile")] - public ActionResult UploadFile([NotNull] IFormFile file, [FromForm, NotNull]string test) + public ActionResult UploadFile([NotNull] IFormFile file, [FromForm, NotNull] string test) { return Ok(); } [HttpPost("UploadFiles")] - public ActionResult UploadFiles([NotNull, FromForm] IFormFile[] files, [FromForm, NotNull]string test) + public ActionResult UploadFiles([NotNull, FromForm] IFormFile[] files, [FromForm, NotNull] string test) { return Ok(); } diff --git a/src/NSwag.Generation.AspNetCore.Tests.Web/Controllers/Responses/WrappedResponseController.cs b/src/NSwag.Generation.AspNetCore.Tests.Web/Controllers/Responses/WrappedResponseController.cs index fcfded2eb0..59a641d42e 100644 --- a/src/NSwag.Generation.AspNetCore.Tests.Web/Controllers/Responses/WrappedResponseController.cs +++ b/src/NSwag.Generation.AspNetCore.Tests.Web/Controllers/Responses/WrappedResponseController.cs @@ -3,50 +3,49 @@ namespace NSwag.Generation.AspNetCore.Tests.Web.Controllers.Responses { [ApiController] - [Route( "api/wrappedresponse" )] + [Route("api/wrappedresponse")] public class WrappedResponseController : Controller { - - [HttpGet( "task" )] + [HttpGet("task")] public Task Task() { throw new NotImplementedException(); } - [HttpGet( "int" )] + [HttpGet("int")] public int Int() { throw new NotImplementedException(); } - [HttpGet( "taskofint" )] + [HttpGet("taskofint")] public Task TaskOfInt() { throw new NotImplementedException(); } - [HttpGet( "valuetaskofint" )] + [HttpGet("valuetaskofint")] public ValueTask ValueTaskOfInt() { throw new NotImplementedException(); } - [HttpGet( "actionresultofint" )] + [HttpGet("actionresultofint")] public ActionResult ActionResultOfInt() { throw new NotImplementedException(); } - [HttpGet( "taskofactionresultofint" )] + [HttpGet("taskofactionresultofint")] public Task> TaskOfActionResultOfInt() { throw new NotImplementedException(); } - [HttpGet( "valuetaskofactionresultofint" )] + [HttpGet("valuetaskofactionresultofint")] public ValueTask> ValueTaskOfActionResultOfInt() { throw new NotImplementedException(); } } -} +} \ No newline at end of file diff --git a/src/NSwag.Generation.AspNetCore.Tests/AspNetCoreToSwaggerGenerationTests.cs b/src/NSwag.Generation.AspNetCore.Tests/AspNetCoreToSwaggerGenerationTests.cs index 2144b83480..0a8db2edd0 100644 --- a/src/NSwag.Generation.AspNetCore.Tests/AspNetCoreToSwaggerGenerationTests.cs +++ b/src/NSwag.Generation.AspNetCore.Tests/AspNetCoreToSwaggerGenerationTests.cs @@ -907,11 +907,11 @@ private class ProblemDetails { } private class ApiResponseType2_1 : ApiResponseType { -#pragma warning disable 108,114 +#pragma warning disable 108, 114 public bool IsDefaultResponse { get; set; } -#pragma warning restore 108,114 +#pragma warning restore 108, 114 } #endregion } } -#endif +#endif \ No newline at end of file diff --git a/src/NSwag.Generation.AspNetCore.Tests/Responses/ProducesTests.cs b/src/NSwag.Generation.AspNetCore.Tests/Responses/ProducesTests.cs index 3ea84d3674..ed0e05de43 100644 --- a/src/NSwag.Generation.AspNetCore.Tests/Responses/ProducesTests.cs +++ b/src/NSwag.Generation.AspNetCore.Tests/Responses/ProducesTests.cs @@ -24,7 +24,7 @@ public async Task When_produces_is_defined_on_all_operations_then_it_is_added_to Assert.Contains("text/html", operation.ActualProduces); Assert.Null(operation.Produces); } - + [Fact] public async Task When_operation_produces_is_different_in_several_controllers_then_they_are_added_to_the_operation() { diff --git a/src/NSwag.Generation.AspNetCore.Tests/Responses/WrappedResponseTests.cs b/src/NSwag.Generation.AspNetCore.Tests/Responses/WrappedResponseTests.cs index 22bb456c33..22c4a640fe 100644 --- a/src/NSwag.Generation.AspNetCore.Tests/Responses/WrappedResponseTests.cs +++ b/src/NSwag.Generation.AspNetCore.Tests/Responses/WrappedResponseTests.cs @@ -1,7 +1,5 @@ using Xunit; - using NJsonSchema; - using NSwag.Generation.AspNetCore.Tests.Web.Controllers.Responses; using NJsonSchema.NewtonsoftJson.Generation; @@ -25,23 +23,27 @@ public async Task When_response_is_wrapped_in_certain_generic_result_types_then_ var document = await GenerateDocumentAsync(settings, typeof(WrappedResponseController)); // Assert - OpenApiResponse GetOperationResponse(string actionName) => document.Operations - .Where(op => op.Operation.OperationId == $"{nameof(WrappedResponseController) - .Substring(0, nameof(WrappedResponseController).Length - "Controller".Length)}_{actionName}") - .Single().Operation.ActualResponses.Single().Value; + OpenApiResponse GetOperationResponse(string actionName) + { + return document.Operations + .Single(op => op.Operation.OperationId == $"{nameof(WrappedResponseController) + .Substring(0, nameof(WrappedResponseController).Length - "Controller".Length)}_{actionName}").Operation.ActualResponses.Single().Value; + } - JsonObjectType GetOperationResponseSchemaType(string actionName) => - GetOperationResponse(actionName).Schema.Type; + JsonObjectType GetOperationResponseSchemaType(string actionName) + { + return GetOperationResponse(actionName).Schema.Type; + } var intType = NewtonsoftJsonSchemaGenerator.FromType().Type; Assert.Null(GetOperationResponse(nameof(WrappedResponseController.Task)).Schema); - Assert.Equal(intType, GetOperationResponseSchemaType(nameof( WrappedResponseController.Int))); - Assert.Equal(intType, GetOperationResponseSchemaType(nameof( WrappedResponseController.TaskOfInt))); - Assert.Equal(intType, GetOperationResponseSchemaType(nameof( WrappedResponseController.ValueTaskOfInt))); - Assert.Equal(intType, GetOperationResponseSchemaType(nameof( WrappedResponseController.ActionResultOfInt))); - Assert.Equal(intType, GetOperationResponseSchemaType(nameof( WrappedResponseController.TaskOfActionResultOfInt))); - Assert.Equal(intType, GetOperationResponseSchemaType(nameof( WrappedResponseController.ValueTaskOfActionResultOfInt))); + Assert.Equal(intType, GetOperationResponseSchemaType(nameof(WrappedResponseController.Int))); + Assert.Equal(intType, GetOperationResponseSchemaType(nameof(WrappedResponseController.TaskOfInt))); + Assert.Equal(intType, GetOperationResponseSchemaType(nameof(WrappedResponseController.ValueTaskOfInt))); + Assert.Equal(intType, GetOperationResponseSchemaType(nameof(WrappedResponseController.ActionResultOfInt))); + Assert.Equal(intType, GetOperationResponseSchemaType(nameof(WrappedResponseController.TaskOfActionResultOfInt))); + Assert.Equal(intType, GetOperationResponseSchemaType(nameof(WrappedResponseController.ValueTaskOfActionResultOfInt))); } } } \ No newline at end of file diff --git a/src/NSwag.Generation.AspNetCore.Tests/SystemTextJsonTests.cs b/src/NSwag.Generation.AspNetCore.Tests/SystemTextJsonTests.cs index b836e41116..8f5e8dbbda 100644 --- a/src/NSwag.Generation.AspNetCore.Tests/SystemTextJsonTests.cs +++ b/src/NSwag.Generation.AspNetCore.Tests/SystemTextJsonTests.cs @@ -25,7 +25,7 @@ public async Task WhenSystemTextOptionsIsUsed_ThenOptionsAreConverted() var registration = serviceProvider.GetRequiredService(); var generator = new AspNetCoreOpenApiDocumentGenerator(registration.Settings); await generator.GenerateAsync(serviceProvider); - + var settings = generator.Settings; // Assert diff --git a/src/NSwag.Generation.AspNetCore/AspNetCoreOpenApiDocumentGenerator.cs b/src/NSwag.Generation.AspNetCore/AspNetCoreOpenApiDocumentGenerator.cs index a745844d72..cb017ae61e 100644 --- a/src/NSwag.Generation.AspNetCore/AspNetCoreOpenApiDocumentGenerator.cs +++ b/src/NSwag.Generation.AspNetCore/AspNetCoreOpenApiDocumentGenerator.cs @@ -243,7 +243,7 @@ private List GenerateApiGroups( operation = JsonConvert.DeserializeObject(stringBuilder.ToString()); operation.Parameters.Clear(); // clear because parameters are added by the generator - } + } #endif operation.IsDeprecated = IsOperationDeprecated(item.Item1, apiDescription.ActionDescriptor, method); diff --git a/src/NSwag.Generation.Tests/Processors/OperationSummaryAndDescriptionProcessorTests.cs b/src/NSwag.Generation.Tests/Processors/OperationSummaryAndDescriptionProcessorTests.cs index 434e5fdec6..18d17220f9 100644 --- a/src/NSwag.Generation.Tests/Processors/OperationSummaryAndDescriptionProcessorTests.cs +++ b/src/NSwag.Generation.Tests/Processors/OperationSummaryAndDescriptionProcessorTests.cs @@ -16,7 +16,7 @@ public class DocumentedController public void DocumentedMethodWithOpenApiOperationAttribute() { } - + [Description("\r\n\t This method has a description. \r\n\t")] public void DocumentedMethodWithDescriptionAttribute() { @@ -32,7 +32,7 @@ public void DocumentedMethodWithSummary() { } } - + [Fact] public void Process_TrimsWhitespaceFromOpenApiOperationSummary() { @@ -53,7 +53,7 @@ public void Process_TrimsWhitespaceFromOpenApiOperationSummary() var description = context.OperationDescription.Operation.Description; Assert.Equal("This method has a description.", description); } - + [Fact] public void Process_TrimsWhitespaceFromDescription() { @@ -74,7 +74,7 @@ public void Process_TrimsWhitespaceFromDescription() var description = context.OperationDescription.Operation.Description; Assert.Null(description); } - + [Fact] public void Process_TrimsWhitespaceFromSummary() { @@ -95,7 +95,7 @@ public void Process_TrimsWhitespaceFromSummary() var description = context.OperationDescription.Operation.Description; Assert.Equal("This method has a description.", description); } - + private OperationProcessorContext GetContext(Type controllerType, MethodInfo methodInfo) { var document = new OpenApiDocument(); @@ -104,7 +104,7 @@ private OperationProcessorContext GetContext(Type controllerType, MethodInfo met { SchemaSettings = new NewtonsoftJsonSchemaGeneratorSettings() }; - + return new OperationProcessorContext(document, operationDescription, controllerType, methodInfo, null, null, settings, null); } } diff --git a/src/NSwag.Generation.WebApi/Processors/OperationParameterProcessor.cs b/src/NSwag.Generation.WebApi/Processors/OperationParameterProcessor.cs index 720e4a30c8..419b3b64f5 100644 --- a/src/NSwag.Generation.WebApi/Processors/OperationParameterProcessor.cs +++ b/src/NSwag.Generation.WebApi/Processors/OperationParameterProcessor.cs @@ -121,7 +121,7 @@ public bool Process(OperationProcessorContext context) if (context.OperationDescription.Method == OpenApiOperationMethod.Get) { operationParameter = AddPrimitiveParameter(uriParameterName, context, contextualParameter); - } + } else { // Try to find a [WillReadBody] attribute on either the action parameter or the bindingAttribute's class @@ -190,7 +190,7 @@ public bool Process(OperationProcessorContext context) { operationParameter.OriginalName = contextualParameter.ParameterInfo.Name; } - + ((Dictionary)context.Parameters)[contextualParameter.ParameterInfo] = operationParameter; } } diff --git a/src/NSwag.Generation.WebApi/WebApiOpenApiDocumentGenerator.cs b/src/NSwag.Generation.WebApi/WebApiOpenApiDocumentGenerator.cs index 23ce344e0f..c62b03446e 100644 --- a/src/NSwag.Generation.WebApi/WebApiOpenApiDocumentGenerator.cs +++ b/src/NSwag.Generation.WebApi/WebApiOpenApiDocumentGenerator.cs @@ -234,7 +234,7 @@ private bool AddOperationDescriptionsToDocument(OpenApiDocument document, Type c return addedOperations > 0; } - private bool RunOperationProcessors(OpenApiDocument document, Type controllerType, MethodInfo methodInfo, OpenApiOperationDescription operationDescription, + private bool RunOperationProcessors(OpenApiDocument document, Type controllerType, MethodInfo methodInfo, OpenApiOperationDescription operationDescription, List allOperations, OpenApiDocumentGenerator generator, OpenApiSchemaResolver schemaResolver) { var context = new OperationProcessorContext(document, operationDescription, controllerType, diff --git a/src/NSwag.Generation/OpenApiSchemaGenerator.cs b/src/NSwag.Generation/OpenApiSchemaGenerator.cs index bd97c2f18b..0ab6530882 100644 --- a/src/NSwag.Generation/OpenApiSchemaGenerator.cs +++ b/src/NSwag.Generation/OpenApiSchemaGenerator.cs @@ -20,7 +20,7 @@ public class OpenApiSchemaGenerator : JsonSchemaGenerator /// Initializes a new instance of the class. /// The settings. - public OpenApiSchemaGenerator(OpenApiDocumentGeneratorSettings settings) + public OpenApiSchemaGenerator(OpenApiDocumentGeneratorSettings settings) : base(settings.SchemaSettings) { } diff --git a/src/NSwag.Sample.NET80Minimal/Program.cs b/src/NSwag.Sample.NET80Minimal/Program.cs index 62f56f6902..5a9ef2d243 100644 --- a/src/NSwag.Sample.NET80Minimal/Program.cs +++ b/src/NSwag.Sample.NET80Minimal/Program.cs @@ -44,9 +44,9 @@ [Route("examples")] public class ExampleController : ControllerBase { - [HttpGet] - public IActionResult Get() - { - return Ok("Get Method"); - } + [HttpGet] + public IActionResult Get() + { + return Ok("Get Method"); + } } \ No newline at end of file diff --git a/src/NSwag.Sample.NET90Minimal/Program.cs b/src/NSwag.Sample.NET90Minimal/Program.cs index 53ead1cca1..acd42cc296 100644 --- a/src/NSwag.Sample.NET90Minimal/Program.cs +++ b/src/NSwag.Sample.NET90Minimal/Program.cs @@ -29,16 +29,13 @@ .WithName("AbsoluteValue") .WithTags("Calculator"); -app.MapGet("/id:{id}", (int id) =>id) +app.MapGet("/id:{id}", (int id) => id) .WithName("Identity") .WithTags("Calculator"); // Optional: Use controllers app.UseRouting(); -app.UseEndpoints(x => -{ - x.MapControllers(); -}); +app.UseEndpoints(x => { x.MapControllers(); }); app.Run(); @@ -47,9 +44,9 @@ [Route("examples")] public class ExampleController : ControllerBase { - [HttpGet] - public IActionResult Get() - { - return Ok("Get Method"); - } + [HttpGet] + public IActionResult Get() + { + return Ok("Get Method"); + } } \ No newline at end of file