From 2eecf1c8d3613b79cf4a261ea5c4aed3a271c705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D1=80=D0=B8=D0=B9=20=D0=A2=D1=83=D1=80=D0=B1=D0=B8?= =?UTF-8?q?=D0=BD?= Date: Tue, 21 May 2024 00:32:21 +0300 Subject: [PATCH] Base editorconfig + format --- .editorconfig | 298 ++++++++++++++++++ .gitignore | 1 + Saunter.sln | 3 +- examples/StreetlightsAPI/API.cs | 10 +- examples/StreetlightsAPI/Messaging.cs | 4 +- examples/StreetlightsAPI/Program.cs | 2 +- .../AsyncApiEndpointRouteBuilderExtensions.cs | 4 +- src/Saunter/AsyncApiMiddleware.cs | 8 +- src/Saunter/AsyncApiOptions.cs | 2 +- .../AsyncApiSchema/v2/AsyncApiDocument.cs | 4 +- .../v2/Bindings/Amqp/AmqpChannelBinding.cs | 4 +- .../v2/Bindings/Amqp/AmqpMessageBinding.cs | 4 +- .../v2/Bindings/Amqp/AmqpOperationBinding.cs | 4 +- .../v2/Bindings/Amqp/AmqpServerBinding.cs | 4 +- .../v2/Bindings/ChannelBindings.cs | 6 +- .../v2/Bindings/Kafka/KafkaServerBinding.cs | 2 +- .../v2/Bindings/MessageBindings.cs | 4 +- .../v2/Bindings/Mqtt/MqttChannelBinding.cs | 2 +- .../v2/Bindings/Mqtt/MqttMessageBinding.cs | 2 +- .../v2/Bindings/Mqtt/MqttOperationBinding.cs | 2 +- .../v2/Bindings/Mqtt/MqttServerBinding.cs | 2 +- .../v2/Bindings/OperationBindings.cs | 8 +- .../v2/Bindings/ServerBindings.cs | 4 +- src/Saunter/AsyncApiSchema/v2/ChannelItem.cs | 4 +- src/Saunter/AsyncApiSchema/v2/Components.cs | 10 +- .../AsyncApiSchema/v2/CorrelationId.cs | 8 +- .../v2/ExternalDocumentation.cs | 6 +- src/Saunter/AsyncApiSchema/v2/Info.cs | 13 +- src/Saunter/AsyncApiSchema/v2/Message.cs | 16 +- src/Saunter/AsyncApiSchema/v2/OAuthFlows.cs | 6 +- src/Saunter/AsyncApiSchema/v2/Operation.cs | 6 +- src/Saunter/AsyncApiSchema/v2/Parameter.cs | 6 +- src/Saunter/AsyncApiSchema/v2/Reference.cs | 6 +- .../AsyncApiSchema/v2/SecurityScheme.cs | 20 +- src/Saunter/AsyncApiSchema/v2/Server.cs | 6 +- src/Saunter/AsyncApiSchema/v2/Tag.cs | 4 +- .../AsyncApiSchema/v2/Traits/MessageTrait.cs | 14 +- .../v2/Traits/OperationTrait.cs | 8 +- .../AsyncApiServiceCollectionExtensions.cs | 4 +- src/Saunter/Attributes/AsyncApiAttribute.cs | 6 +- src/Saunter/Attributes/ChannelAttribute.cs | 4 +- .../Attributes/ChannelParameterAttribute.cs | 4 +- src/Saunter/Attributes/MessageAttribute.cs | 8 +- .../Generation/AsyncApiDocumentProvider.cs | 4 +- src/Saunter/Generation/DocumentGenerator.cs | 38 +-- .../Generation/Filters/IChannelItemFilter.cs | 6 +- .../Generation/Filters/IDocumentFilter.cs | 6 +- .../Generation/Filters/IOperationFilter.cs | 6 +- src/Saunter/Generation/IDocumentGenerator.cs | 4 +- .../AsyncApiSchemaResolver.cs | 8 +- src/Saunter/IAsyncApiDocumentProvider.cs | 4 +- src/Saunter/Properties/AssemblyInfo.cs | 4 +- .../IAsyncApiDocumentSerializer.cs | 6 +- .../NewtonsoftAsyncApiDocumentSerializer.cs | 6 +- src/Saunter/UI/AsyncApiUiMiddleware.cs | 8 +- src/Saunter/Utils/ChannelItemExtensions.cs | 2 +- src/Saunter/Utils/Reflection.cs | 4 +- .../Program.cs | 4 +- test/Saunter.Tests.MarkerTypeTests/Broker.cs | 6 +- .../Saunter.Tests/ActivatorServiceProvider.cs | 2 +- .../ClassAttributesTests.cs | 44 +-- .../MethodAttributesTests.cs | 26 +- .../AsyncApiTypesTests.cs | 2 +- .../Generation/Filters/DocumentFilterTests.cs | 6 +- .../Generation/OperationTraitsTests.cs | 4 +- .../SchemaGeneration/SchemaGenerationTests.cs | 4 +- test/Saunter.Tests/ServiceCollectionTests.cs | 6 +- .../Saunter.Tests/UI/EmbeddedResourceTests.cs | 2 +- test/Saunter.Tests/Utils/ReflectionTests.cs | 4 +- 69 files changed, 530 insertions(+), 229 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..fe3bd5da --- /dev/null +++ b/.editorconfig @@ -0,0 +1,298 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Don't use tabs for indentation. +[*] +indent_style = space +# (Please don't specify an indent_size here; that has too many unintended consequences.) +spelling_exclusion_path = SpellingExclusions.dic + +# Code files +[*.{cs,csx,vb,vbx}] +indent_size = 4 +insert_final_newline = true +charset = utf-8-bom + +# XML project files +[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] +indent_size = 4 + +# XML config files +[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}] +indent_size = 2 + +# JSON files +[*.json] +indent_size = 2 + +# Powershell files +[*.ps1] +indent_size = 2 + +# Shell script files +[*.sh] +end_of_line = lf +indent_size = 2 + +# Dotnet code style settings: +[*.{cs,vb}] + +# Sort using and Import directives with System.* appearing first +dotnet_sort_system_directives_first = true +dotnet_separate_import_directive_groups = false +# Avoid "this." and "Me." if not necessary +dotnet_style_qualification_for_field = false:refactoring +dotnet_style_qualification_for_property = false:refactoring +dotnet_style_qualification_for_method = false:refactoring +dotnet_style_qualification_for_event = false:refactoring + +# Use language keywords instead of framework type names for type references +dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion +dotnet_style_predefined_type_for_member_access = true:suggestion + +# Suggest more modern language features when available +dotnet_style_object_initializer = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_null_propagation = true:suggestion +dotnet_style_explicit_tuple_names = true:suggestion + +# Whitespace options +dotnet_style_allow_multiple_blank_lines_experimental = false + +# Non-private static fields are PascalCase +dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.symbols = non_private_static_fields +dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.style = non_private_static_field_style + +dotnet_naming_symbols.non_private_static_fields.applicable_kinds = field +dotnet_naming_symbols.non_private_static_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected +dotnet_naming_symbols.non_private_static_fields.required_modifiers = static + +dotnet_naming_style.non_private_static_field_style.capitalization = pascal_case + +# Non-private readonly fields are PascalCase +dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.symbols = non_private_readonly_fields +dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.style = non_private_static_field_style + +dotnet_naming_symbols.non_private_readonly_fields.applicable_kinds = field +dotnet_naming_symbols.non_private_readonly_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected +dotnet_naming_symbols.non_private_readonly_fields.required_modifiers = readonly + +dotnet_naming_style.non_private_readonly_field_style.capitalization = pascal_case + +# Constants are PascalCase +dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.constants_should_be_pascal_case.symbols = constants +dotnet_naming_rule.constants_should_be_pascal_case.style = non_private_static_field_style + +dotnet_naming_symbols.constants.applicable_kinds = field, local +dotnet_naming_symbols.constants.required_modifiers = const + +dotnet_naming_style.constant_style.capitalization = pascal_case + +# Static fields are camelCase and start with s_ +dotnet_naming_rule.static_fields_should_be_camel_case.severity = suggestion +dotnet_naming_rule.static_fields_should_be_camel_case.symbols = static_fields +dotnet_naming_rule.static_fields_should_be_camel_case.style = static_field_style + +dotnet_naming_symbols.static_fields.applicable_kinds = field +dotnet_naming_symbols.static_fields.required_modifiers = static + +dotnet_naming_style.static_field_style.capitalization = camel_case +dotnet_naming_style.static_field_style.required_prefix = s_ + +# Instance fields are camelCase and start with _ +dotnet_naming_rule.instance_fields_should_be_camel_case.severity = suggestion +dotnet_naming_rule.instance_fields_should_be_camel_case.symbols = instance_fields +dotnet_naming_rule.instance_fields_should_be_camel_case.style = instance_field_style + +dotnet_naming_symbols.instance_fields.applicable_kinds = field + +dotnet_naming_style.instance_field_style.capitalization = camel_case +dotnet_naming_style.instance_field_style.required_prefix = _ + +# Locals and parameters are camelCase +dotnet_naming_rule.locals_should_be_camel_case.severity = suggestion +dotnet_naming_rule.locals_should_be_camel_case.symbols = locals_and_parameters +dotnet_naming_rule.locals_should_be_camel_case.style = camel_case_style + +dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter, local + +dotnet_naming_style.camel_case_style.capitalization = camel_case + +# Local functions are PascalCase +dotnet_naming_rule.local_functions_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.local_functions_should_be_pascal_case.symbols = local_functions +dotnet_naming_rule.local_functions_should_be_pascal_case.style = non_private_static_field_style + +dotnet_naming_symbols.local_functions.applicable_kinds = local_function + +dotnet_naming_style.local_function_style.capitalization = pascal_case + +# By default, name items with PascalCase +dotnet_naming_rule.members_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.members_should_be_pascal_case.symbols = all_members +dotnet_naming_rule.members_should_be_pascal_case.style = non_private_static_field_style + +dotnet_naming_symbols.all_members.applicable_kinds = * + +dotnet_naming_style.pascal_case_style.capitalization = pascal_case + +file_header_template = Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license.\nSee the LICENSE file in the project root for more information. + +# RS0016: Only enable if API files are present +dotnet_public_api_analyzer.require_api_files = true + +# IDE0055: Fix formatting +# Workaround for https://github.com/dotnet/roslyn/issues/70570 +dotnet_diagnostic.IDE0055.severity = warning +dotnet_style_operator_placement_when_wrapping = beginning_of_line +tab_width = 4 +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion +dotnet_style_prefer_auto_properties = true:silent +dotnet_style_prefer_simplified_boolean_expressions = true:suggestion +dotnet_style_prefer_conditional_expression_over_assignment = true:silent +dotnet_style_prefer_conditional_expression_over_return = true:silent +dotnet_style_prefer_inferred_tuple_names = true:suggestion +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion +dotnet_style_prefer_compound_assignment = true:suggestion +dotnet_style_prefer_simplified_interpolation = true:suggestion +dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion + +# CSharp code style settings: +[*.cs] +# Newline settings +csharp_new_line_before_open_brace = all +csharp_new_line_before_else = true +csharp_new_line_before_catch = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_between_query_expression_clauses = true + +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = true +csharp_indent_switch_labels = true +csharp_indent_labels = flush_left + +# Whitespace options +csharp_style_allow_embedded_statements_on_same_line_experimental = false +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false +csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = false +csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = false + +# Prefer "var" everywhere +csharp_style_var_for_built_in_types = true:suggestion +csharp_style_var_when_type_is_apparent = true:suggestion +csharp_style_var_elsewhere = true:suggestion + +# Prefer method-like constructs to have a block body +csharp_style_expression_bodied_methods = false:none +csharp_style_expression_bodied_constructors = false:none +csharp_style_expression_bodied_operators = false:none + +# Prefer property-like constructs to have an expression-body +csharp_style_expression_bodied_properties = true:none +csharp_style_expression_bodied_indexers = true:none +csharp_style_expression_bodied_accessors = true:none + +# Suggest more modern language features when available +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion +csharp_style_throw_expression = true:suggestion +csharp_style_conditional_delegate_call = true:suggestion +csharp_style_prefer_extended_property_pattern = true:suggestion + +# Space preferences +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = do_not_ignore +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_name_and_open_parenthesis = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false + +# Blocks are allowed +csharp_prefer_braces = true:silent +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true + +# IDE0060: Remove unused parameter +dotnet_diagnostic.IDE0060.severity = warning + +[src/{Compilers,ExpressionEvaluator,Scripting}/**Test**/*.{cs,vb}] + +# IDE0060: Remove unused parameter +dotnet_diagnostic.IDE0060.severity = none + +[src/{Analyzers,CodeStyle,Features,Workspaces,EditorFeatures,VisualStudio}/**/*.{cs,vb}] + +# IDE0011: Add braces +csharp_prefer_braces = when_multiline:warning +# NOTE: We need the below severity entry for Add Braces due to https://github.com/dotnet/roslyn/issues/44201 +dotnet_diagnostic.IDE0011.severity = warning + +# IDE0040: Add accessibility modifiers +dotnet_diagnostic.IDE0040.severity = warning + +# IDE0052: Remove unread private member +dotnet_diagnostic.IDE0052.severity = warning + +# IDE0059: Unnecessary assignment to a value +dotnet_diagnostic.IDE0059.severity = warning + +# CA1012: Abstract types should not have public constructors +dotnet_diagnostic.CA1012.severity = warning + +# CA1822: Make member static +dotnet_diagnostic.CA1822.severity = warning + +# Prefer "var" everywhere +dotnet_diagnostic.IDE0007.severity = warning +csharp_style_var_for_built_in_types = true:warning +csharp_style_var_when_type_is_apparent = true:warning +csharp_style_var_elsewhere = true:warning + +# csharp_style_allow_embedded_statements_on_same_line_experimental +dotnet_diagnostic.IDE2001.severity = warning + +# csharp_style_allow_blank_lines_between_consecutive_braces_experimental +dotnet_diagnostic.IDE2002.severity = warning + +# csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental +dotnet_diagnostic.IDE2004.severity = warning + +# csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental +dotnet_diagnostic.IDE2005.severity = warning + +# csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental +dotnet_diagnostic.IDE2006.severity = warning + +[src/{VisualStudio}/**/*.{cs,vb}] +# CA1822: Make member static +# There is a risk of accidentally breaking an internal API that partners rely on though IVT. +dotnet_code_quality.CA1822.api_surface = private \ No newline at end of file diff --git a/.gitignore b/.gitignore index 0b6d6153..758b4e30 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .idea/ build/ +**/Properties/* # Created by https://www.gitignore.io/api/csharp,jetbrains,visualstudio # Edit at https://www.gitignore.io/?templates=csharp,jetbrains,visualstudio diff --git a/Saunter.sln b/Saunter.sln index 71b9bc21..46277661 100644 --- a/Saunter.sln +++ b/Saunter.sln @@ -17,6 +17,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StreetlightsAPI", "examples EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E0D34C77-924E-4F6B-9289-5A2F07D125A8}" ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig CHANGELOG.md = CHANGELOG.md .github\workflows\ci.yaml = .github\workflows\ci.yaml README.md = README.md @@ -25,7 +26,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Saunter.IntegrationTests.ReverseProxy", "test\Saunter.IntegrationTests.ReverseProxy\Saunter.IntegrationTests.ReverseProxy.csproj", "{7CD09B89-130A-41AF-ADAE-2166C4ED695B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Saunter.Tests.MarkerTypeTests", "test\Saunter.Tests.MarkerTypeTests\Saunter.Tests.MarkerTypeTests.csproj", "{02284473-6DE7-4EE0-8433-2AC295045549}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Saunter.Tests.MarkerTypeTests", "test\Saunter.Tests.MarkerTypeTests\Saunter.Tests.MarkerTypeTests.csproj", "{02284473-6DE7-4EE0-8433-2AC295045549}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/examples/StreetlightsAPI/API.cs b/examples/StreetlightsAPI/API.cs index 7e496ccd..978a0dea 100644 --- a/examples/StreetlightsAPI/API.cs +++ b/examples/StreetlightsAPI/API.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text.Json; @@ -14,7 +14,7 @@ public class Streetlight /// Id of the streetlight. /// public int Id { get; set; } - + /// /// Lat-Long coordinates of the streetlight. /// @@ -58,7 +58,7 @@ public class StreetlightsController { new Streetlight { Id = 1, Position = new [] { -36.320320, 175.485986 }, LightIntensity = new() }, }; - + private readonly IStreetlightMessageBus _streetlightMessageBus; private readonly ILogger _logger; @@ -67,7 +67,7 @@ public StreetlightsController(IStreetlightMessageBus streetlightMessageBus, ILog _streetlightMessageBus = streetlightMessageBus; _logger = loggerFactory.CreateLogger(); } - + /// /// Get all streetlights /// @@ -90,7 +90,7 @@ public Streetlight Add([FromBody] Streetlight streetlight) /// /// Inform about environmental lighting conditions for a particular streetlight. /// - [Channel(PublishLightMeasuredTopic, Servers = new []{"webapi"})] + [Channel(PublishLightMeasuredTopic, Servers = new[] { "webapi" })] [PublishOperation(typeof(LightMeasuredEvent), "Light")] [HttpPost] [Route(PublishLightMeasuredTopic)] diff --git a/examples/StreetlightsAPI/Messaging.cs b/examples/StreetlightsAPI/Messaging.cs index e39628ea..00b9e679 100644 --- a/examples/StreetlightsAPI/Messaging.cs +++ b/examples/StreetlightsAPI/Messaging.cs @@ -1,4 +1,4 @@ -using System.Text.Json; +using System.Text.Json; using Microsoft.Extensions.Logging; using Saunter.Attributes; @@ -33,4 +33,4 @@ public void PublishLightMeasurement(LightMeasuredEvent lightMeasuredEvent) _logger.LogInformation("Publishing message {Payload} to test.mosquitto.org/{Topic}", payload, SubscribeLightMeasuredTopic); } } -} \ No newline at end of file +} diff --git a/examples/StreetlightsAPI/Program.cs b/examples/StreetlightsAPI/Program.cs index 40ff3a92..aa3f77ad 100644 --- a/examples/StreetlightsAPI/Program.cs +++ b/examples/StreetlightsAPI/Program.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting.Server.Features; diff --git a/src/Saunter/AsyncApiEndpointRouteBuilderExtensions.cs b/src/Saunter/AsyncApiEndpointRouteBuilderExtensions.cs index 4473e4e8..9383fb92 100644 --- a/src/Saunter/AsyncApiEndpointRouteBuilderExtensions.cs +++ b/src/Saunter/AsyncApiEndpointRouteBuilderExtensions.cs @@ -1,4 +1,4 @@ -using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.DependencyInjection; @@ -48,4 +48,4 @@ public static IEndpointConventionBuilder MapAsyncApiUi(this IEndpointRouteBuilde return endpoints.MapGet(route, pipeline); } } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiMiddleware.cs b/src/Saunter/AsyncApiMiddleware.cs index e260d8b7..eb9169f7 100644 --- a/src/Saunter/AsyncApiMiddleware.cs +++ b/src/Saunter/AsyncApiMiddleware.cs @@ -1,4 +1,4 @@ -using System.Net; +using System.Net; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Options; @@ -39,10 +39,10 @@ public async Task Invoke(HttpContext context) var asyncApiSchema = _asyncApiDocumentProvider.GetDocument(_options, prototype); - await RespondWithAsyncApiSchemaJson(context.Response, asyncApiSchema, _asyncApiDocumentSerializer, _options); + await RespondWithAsyncApiSchemaJson(context.Response, asyncApiSchema, _asyncApiDocumentSerializer); } - private static async Task RespondWithAsyncApiSchemaJson(HttpResponse response, AsyncApiSchema.v2.AsyncApiDocument asyncApiSchema, IAsyncApiDocumentSerializer asyncApiDocumentSerializer, AsyncApiOptions options) + private static async Task RespondWithAsyncApiSchemaJson(HttpResponse response, AsyncApiSchema.v2.AsyncApiDocument asyncApiSchema, IAsyncApiDocumentSerializer asyncApiDocumentSerializer) { var asyncApiSchemaJson = asyncApiDocumentSerializer.Serialize(asyncApiSchema); response.StatusCode = (int)HttpStatusCode.OK; @@ -56,4 +56,4 @@ private bool IsRequestingAsyncApiSchema(HttpRequest request) return HttpMethods.IsGet(request.Method) && request.Path.IsMatchingRoute(_options.Middleware.Route); } } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiOptions.cs b/src/Saunter/AsyncApiOptions.cs index f246ff18..cc64cc55 100644 --- a/src/Saunter/AsyncApiOptions.cs +++ b/src/Saunter/AsyncApiOptions.cs @@ -120,4 +120,4 @@ public class AsyncApiMiddlewareOptions /// public string UiTitle { get; set; } = "AsyncAPI"; } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/AsyncApiDocument.cs b/src/Saunter/AsyncApiSchema/v2/AsyncApiDocument.cs index dc7f15c8..ed38829a 100644 --- a/src/Saunter/AsyncApiSchema/v2/AsyncApiDocument.cs +++ b/src/Saunter/AsyncApiSchema/v2/AsyncApiDocument.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; @@ -105,4 +105,4 @@ object ICloneable.Clone() return Clone(); } } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/Bindings/Amqp/AmqpChannelBinding.cs b/src/Saunter/AsyncApiSchema/v2/Bindings/Amqp/AmqpChannelBinding.cs index b5b52377..b27cf426 100644 --- a/src/Saunter/AsyncApiSchema/v2/Bindings/Amqp/AmqpChannelBinding.cs +++ b/src/Saunter/AsyncApiSchema/v2/Bindings/Amqp/AmqpChannelBinding.cs @@ -1,4 +1,4 @@ -using System.Runtime.Serialization; +using System.Runtime.Serialization; using Newtonsoft.Json; using Newtonsoft.Json.Converters; @@ -130,4 +130,4 @@ public enum AmqpChannelBindingExchangeType [EnumMember(Value = "headers")] Headers, } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/Bindings/Amqp/AmqpMessageBinding.cs b/src/Saunter/AsyncApiSchema/v2/Bindings/Amqp/AmqpMessageBinding.cs index 1b51fe96..780895f2 100644 --- a/src/Saunter/AsyncApiSchema/v2/Bindings/Amqp/AmqpMessageBinding.cs +++ b/src/Saunter/AsyncApiSchema/v2/Bindings/Amqp/AmqpMessageBinding.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; namespace Saunter.AsyncApiSchema.v2.Bindings.Amqp { @@ -25,4 +25,4 @@ public class AmqpMessageBinding [JsonProperty("bindingVersion", NullValueHandling = NullValueHandling.Ignore)] public string BindingVersion { get; set; } } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/Bindings/Amqp/AmqpOperationBinding.cs b/src/Saunter/AsyncApiSchema/v2/Bindings/Amqp/AmqpOperationBinding.cs index c138f985..d02d26a7 100644 --- a/src/Saunter/AsyncApiSchema/v2/Bindings/Amqp/AmqpOperationBinding.cs +++ b/src/Saunter/AsyncApiSchema/v2/Bindings/Amqp/AmqpOperationBinding.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Newtonsoft.Json; namespace Saunter.AsyncApiSchema.v2.Bindings.Amqp @@ -74,4 +74,4 @@ public class AmqpOperationBinding [JsonProperty("bindingVersion", NullValueHandling = NullValueHandling.Ignore)] public string BindingVersion { get; set; } } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/Bindings/Amqp/AmqpServerBinding.cs b/src/Saunter/AsyncApiSchema/v2/Bindings/Amqp/AmqpServerBinding.cs index 7f1bb979..e8276cb2 100644 --- a/src/Saunter/AsyncApiSchema/v2/Bindings/Amqp/AmqpServerBinding.cs +++ b/src/Saunter/AsyncApiSchema/v2/Bindings/Amqp/AmqpServerBinding.cs @@ -1,4 +1,4 @@ -namespace Saunter.AsyncApiSchema.v2.Bindings.Amqp +namespace Saunter.AsyncApiSchema.v2.Bindings.Amqp { /// /// This object MUST NOT contain any properties. Its name is reserved for future use. @@ -9,4 +9,4 @@ namespace Saunter.AsyncApiSchema.v2.Bindings.Amqp public class AmqpServerBinding { } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/Bindings/ChannelBindings.cs b/src/Saunter/AsyncApiSchema/v2/Bindings/ChannelBindings.cs index f4053301..5d79e428 100644 --- a/src/Saunter/AsyncApiSchema/v2/Bindings/ChannelBindings.cs +++ b/src/Saunter/AsyncApiSchema/v2/Bindings/ChannelBindings.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using Saunter.AsyncApiSchema.v2.Bindings.Amqp; using Saunter.AsyncApiSchema.v2.Bindings.Http; using Saunter.AsyncApiSchema.v2.Bindings.Kafka; @@ -9,7 +9,7 @@ namespace Saunter.AsyncApiSchema.v2.Bindings /// /// ChannelBindings can be either a the bindings or a reference to the bindings. /// - public interface IChannelBindings {} + public interface IChannelBindings { } /// /// A reference to the ChannelBindings within the AsyncAPI components. @@ -33,4 +33,4 @@ public class ChannelBindings : IChannelBindings [JsonProperty("mqtt", NullValueHandling = NullValueHandling.Ignore)] public MqttChannelBinding Mqtt { get; set; } } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/Bindings/Kafka/KafkaServerBinding.cs b/src/Saunter/AsyncApiSchema/v2/Bindings/Kafka/KafkaServerBinding.cs index e10b591b..d000026b 100644 --- a/src/Saunter/AsyncApiSchema/v2/Bindings/Kafka/KafkaServerBinding.cs +++ b/src/Saunter/AsyncApiSchema/v2/Bindings/Kafka/KafkaServerBinding.cs @@ -10,4 +10,4 @@ namespace Saunter.AsyncApiSchema.v2.Bindings.Kafka public class KafkaServerBinding { } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/Bindings/MessageBindings.cs b/src/Saunter/AsyncApiSchema/v2/Bindings/MessageBindings.cs index d3218398..130fd8b7 100644 --- a/src/Saunter/AsyncApiSchema/v2/Bindings/MessageBindings.cs +++ b/src/Saunter/AsyncApiSchema/v2/Bindings/MessageBindings.cs @@ -9,7 +9,7 @@ namespace Saunter.AsyncApiSchema.v2.Bindings /// /// MessageBindings can be either a the bindings or a reference to the bindings. /// - public interface IMessageBindings {} + public interface IMessageBindings { } /// /// A reference to the MessageBindings within the AsyncAPI components. @@ -33,4 +33,4 @@ public class MessageBindings : IMessageBindings [JsonProperty("mqtt", NullValueHandling = NullValueHandling.Ignore)] public MqttMessageBinding Mqtt { get; set; } } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/Bindings/Mqtt/MqttChannelBinding.cs b/src/Saunter/AsyncApiSchema/v2/Bindings/Mqtt/MqttChannelBinding.cs index ccd752d4..099222a8 100644 --- a/src/Saunter/AsyncApiSchema/v2/Bindings/Mqtt/MqttChannelBinding.cs +++ b/src/Saunter/AsyncApiSchema/v2/Bindings/Mqtt/MqttChannelBinding.cs @@ -9,4 +9,4 @@ public class MqttChannelBinding { } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/Bindings/Mqtt/MqttMessageBinding.cs b/src/Saunter/AsyncApiSchema/v2/Bindings/Mqtt/MqttMessageBinding.cs index 616f01f5..ac5eab33 100644 --- a/src/Saunter/AsyncApiSchema/v2/Bindings/Mqtt/MqttMessageBinding.cs +++ b/src/Saunter/AsyncApiSchema/v2/Bindings/Mqtt/MqttMessageBinding.cs @@ -13,4 +13,4 @@ public class MqttMessageBinding [JsonProperty("bindingVersion", NullValueHandling = NullValueHandling.Ignore)] public string BindingVersion { get; set; } } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/Bindings/Mqtt/MqttOperationBinding.cs b/src/Saunter/AsyncApiSchema/v2/Bindings/Mqtt/MqttOperationBinding.cs index 9c8087a3..140694f4 100644 --- a/src/Saunter/AsyncApiSchema/v2/Bindings/Mqtt/MqttOperationBinding.cs +++ b/src/Saunter/AsyncApiSchema/v2/Bindings/Mqtt/MqttOperationBinding.cs @@ -26,4 +26,4 @@ public class MqttOperationBinding [JsonProperty("bindingVersion", NullValueHandling = NullValueHandling.Ignore)] public string BindingVersion { get; set; } } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/Bindings/Mqtt/MqttServerBinding.cs b/src/Saunter/AsyncApiSchema/v2/Bindings/Mqtt/MqttServerBinding.cs index 7917c264..930c5a46 100644 --- a/src/Saunter/AsyncApiSchema/v2/Bindings/Mqtt/MqttServerBinding.cs +++ b/src/Saunter/AsyncApiSchema/v2/Bindings/Mqtt/MqttServerBinding.cs @@ -64,4 +64,4 @@ public class MqttServerBindingLastWill [JsonProperty("retain", NullValueHandling = NullValueHandling.Ignore)] public bool? Retain { get; set; } } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/Bindings/OperationBindings.cs b/src/Saunter/AsyncApiSchema/v2/Bindings/OperationBindings.cs index 69b5d096..9116d43d 100644 --- a/src/Saunter/AsyncApiSchema/v2/Bindings/OperationBindings.cs +++ b/src/Saunter/AsyncApiSchema/v2/Bindings/OperationBindings.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using Saunter.AsyncApiSchema.v2.Bindings.Amqp; using Saunter.AsyncApiSchema.v2.Bindings.Http; using Saunter.AsyncApiSchema.v2.Bindings.Kafka; @@ -9,7 +9,7 @@ namespace Saunter.AsyncApiSchema.v2.Bindings /// /// OperationBindings can be either a the bindings or a reference to the bindings. /// - public interface IOperationBindings {} + public interface IOperationBindings { } /// /// A reference to the OperationBindings within the AsyncAPI components. @@ -20,7 +20,7 @@ public OperationBindingsReference(string id) : base(id, "#/components/operationB } public class OperationBindings : IOperationBindings - { + { [JsonProperty("http", NullValueHandling = NullValueHandling.Ignore)] public HttpOperationBinding Http { get; set; } @@ -33,4 +33,4 @@ public class OperationBindings : IOperationBindings [JsonProperty("mqtt", NullValueHandling = NullValueHandling.Ignore)] public MqttOperationBinding Mqtt { get; set; } } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/Bindings/ServerBindings.cs b/src/Saunter/AsyncApiSchema/v2/Bindings/ServerBindings.cs index 3e07a5c9..7484fdec 100644 --- a/src/Saunter/AsyncApiSchema/v2/Bindings/ServerBindings.cs +++ b/src/Saunter/AsyncApiSchema/v2/Bindings/ServerBindings.cs @@ -9,7 +9,7 @@ namespace Saunter.AsyncApiSchema.v2.Bindings /// /// ServerBindings can be either a the bindings or a reference to the bindings. /// - public interface IServerBindings {} + public interface IServerBindings { } /// /// A reference to the OperationBindings within the AsyncAPI components. @@ -33,4 +33,4 @@ public class ServerBindings : IServerBindings [JsonProperty("mqtt", NullValueHandling = NullValueHandling.Ignore)] public MqttServerBinding Mqtt { get; set; } } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/ChannelItem.cs b/src/Saunter/AsyncApiSchema/v2/ChannelItem.cs index 2fc151af..ca5455e3 100644 --- a/src/Saunter/AsyncApiSchema/v2/ChannelItem.cs +++ b/src/Saunter/AsyncApiSchema/v2/ChannelItem.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.ComponentModel; using Newtonsoft.Json; using Saunter.AsyncApiSchema.v2.Bindings; @@ -63,4 +63,4 @@ public bool ShouldSerializeServers() return Servers != null && Servers.Count > 0; } } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/Components.cs b/src/Saunter/AsyncApiSchema/v2/Components.cs index 9c23d9bd..ccff4467 100644 --- a/src/Saunter/AsyncApiSchema/v2/Components.cs +++ b/src/Saunter/AsyncApiSchema/v2/Components.cs @@ -1,8 +1,8 @@ -using System; -using NJsonSchema; +using System; using System.Collections.Generic; using System.Linq; using Newtonsoft.Json; +using NJsonSchema; using Saunter.AsyncApiSchema.v2.Bindings; using Saunter.AsyncApiSchema.v2.Traits; @@ -39,7 +39,7 @@ public class Components : ICloneable /// [JsonProperty("correlationIds", DefaultValueHandling = DefaultValueHandling.Ignore)] public IDictionary CorrelationIds { get; set; } = new Dictionary(); - + /// /// An object to hold reusable Server Binding Objects. /// @@ -64,7 +64,7 @@ public class Components : ICloneable [JsonProperty("messageBindings", DefaultValueHandling = DefaultValueHandling.Ignore)] public IDictionary MessageBindings { get; set; } = new Dictionary(); - + /// /// An object to hold reusable Operation Trait Objects. /// @@ -158,4 +158,4 @@ public Components Clone() return clone; } } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/CorrelationId.cs b/src/Saunter/AsyncApiSchema/v2/CorrelationId.cs index 6883d01d..eaed5070 100644 --- a/src/Saunter/AsyncApiSchema/v2/CorrelationId.cs +++ b/src/Saunter/AsyncApiSchema/v2/CorrelationId.cs @@ -1,4 +1,4 @@ -using System; +using System; using Newtonsoft.Json; namespace Saunter.AsyncApiSchema.v2 @@ -7,7 +7,7 @@ namespace Saunter.AsyncApiSchema.v2 /// Can be either a or a to a CorrelationId. /// public interface ICorrelationId { } - + /// /// A reference to a CorrelationId within the AsyncAPI components. /// @@ -15,7 +15,7 @@ public class CorrelationIdReference : Reference, ICorrelationId { public CorrelationIdReference(string id) : base(id, "#/components/correlationIds/{0}") { } } - + public class CorrelationId : ICorrelationId { @@ -38,4 +38,4 @@ public CorrelationId(string location) public string Location { get; } } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/ExternalDocumentation.cs b/src/Saunter/AsyncApiSchema/v2/ExternalDocumentation.cs index 0db6651b..ba0e54c8 100644 --- a/src/Saunter/AsyncApiSchema/v2/ExternalDocumentation.cs +++ b/src/Saunter/AsyncApiSchema/v2/ExternalDocumentation.cs @@ -1,4 +1,4 @@ -using System; +using System; using Newtonsoft.Json; namespace Saunter.AsyncApiSchema.v2 @@ -16,7 +16,7 @@ public ExternalDocumentation(string url) /// [JsonProperty("description")] public string Description { get; set; } - + /// /// The URL for the target documentation. /// Value MUST be in the format of a URL. @@ -24,4 +24,4 @@ public ExternalDocumentation(string url) [JsonProperty("url")] public string Url { get; } } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/Info.cs b/src/Saunter/AsyncApiSchema/v2/Info.cs index 0b04d986..a73e86f1 100644 --- a/src/Saunter/AsyncApiSchema/v2/Info.cs +++ b/src/Saunter/AsyncApiSchema/v2/Info.cs @@ -1,7 +1,8 @@ -using System; +using System; using Newtonsoft.Json; -namespace Saunter.AsyncApiSchema.v2 { +namespace Saunter.AsyncApiSchema.v2 +{ public class Info { public Info(string title, string version) @@ -49,7 +50,7 @@ public Info(string title, string version) [JsonProperty("license", NullValueHandling = NullValueHandling.Ignore)] public License License { get; set; } } - + public class Contact { /// @@ -72,14 +73,14 @@ public class Contact [JsonProperty("email")] public string Email { get; set; } } - + public class License { public License(string name) { Name = name; } - + /// /// The license name used for the API. /// @@ -93,4 +94,4 @@ public License(string name) [JsonProperty("url")] public string Url { get; set; } } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/Message.cs b/src/Saunter/AsyncApiSchema/v2/Message.cs index 07ed9c23..4d86b61f 100644 --- a/src/Saunter/AsyncApiSchema/v2/Message.cs +++ b/src/Saunter/AsyncApiSchema/v2/Message.cs @@ -1,6 +1,6 @@ -using NJsonSchema; -using System.Collections.Generic; +using System.Collections.Generic; using Newtonsoft.Json; +using NJsonSchema; using Saunter.AsyncApiSchema.v2.Bindings; using Saunter.AsyncApiSchema.v2.Traits; @@ -9,8 +9,8 @@ namespace Saunter.AsyncApiSchema.v2 /// /// Message can either be a list of messages, a single message, or a reference to a message. /// - public interface IMessage {} - + public interface IMessage { } + /// /// A reference to a Message within the AsyncAPI components. /// @@ -18,13 +18,13 @@ public class MessageReference : Reference, IMessage { public MessageReference(string id) : base(id, "#/components/messages/{0}") { } } - + public class Messages : IMessage { [JsonProperty("oneOf")] public List OneOf { get; set; } = new List(); } - + public class Message : IMessage { /// @@ -121,7 +121,7 @@ public bool ShouldSerializeTags() /// [JsonProperty("examples")] public IList Examples { get; set; } = new List(); - + public bool ShouldSerializeExamples() { return Examples != null && Examples.Count > 0; @@ -168,4 +168,4 @@ public class MessageExample [JsonProperty("payload", NullValueHandling = NullValueHandling.Ignore)] public object Payload { get; set; } } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/OAuthFlows.cs b/src/Saunter/AsyncApiSchema/v2/OAuthFlows.cs index e34c8684..123b160d 100644 --- a/src/Saunter/AsyncApiSchema/v2/OAuthFlows.cs +++ b/src/Saunter/AsyncApiSchema/v2/OAuthFlows.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Newtonsoft.Json; namespace Saunter.AsyncApiSchema.v2 @@ -17,7 +17,7 @@ public class OAuthFlows [JsonProperty("authorizationCode")] public OAuthFlow AuthorizationCode { get; set; } } - + public class OAuthFlow { [JsonProperty("authorizationUrl")] @@ -32,4 +32,4 @@ public class OAuthFlow [JsonProperty("scopes")] public IDictionary Scopes { get; set; } = new Dictionary(); } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/Operation.cs b/src/Saunter/AsyncApiSchema/v2/Operation.cs index 33425aef..4530bfb6 100644 --- a/src/Saunter/AsyncApiSchema/v2/Operation.cs +++ b/src/Saunter/AsyncApiSchema/v2/Operation.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Newtonsoft.Json; using Saunter.AsyncApiSchema.v2.Bindings; using Saunter.AsyncApiSchema.v2.Traits; @@ -57,7 +57,7 @@ public bool ShouldSerializeTags() /// [JsonProperty("bindings", NullValueHandling = NullValueHandling.Ignore)] public IOperationBindings Bindings { get; set; } - + /// /// A definition of the message that will be published or received on this channel. /// oneOf is allowed here to specify multiple messages, however, a message MUST be @@ -79,4 +79,4 @@ public bool ShouldSerializeTraits() return Traits != null && Traits.Count > 0; } } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/Parameter.cs b/src/Saunter/AsyncApiSchema/v2/Parameter.cs index b6e21606..8df06c95 100644 --- a/src/Saunter/AsyncApiSchema/v2/Parameter.cs +++ b/src/Saunter/AsyncApiSchema/v2/Parameter.cs @@ -1,5 +1,5 @@ +using Newtonsoft.Json; using NJsonSchema; -using Newtonsoft.Json; namespace Saunter.AsyncApiSchema.v2 { @@ -22,7 +22,7 @@ public ParameterReference(string id, AsyncApiDocument document) : base(id, "#/co [JsonIgnore] public Parameter Value => _document.Components.Parameters[Id]; } - + public class Parameter : IParameter { /// @@ -50,4 +50,4 @@ public class Parameter : IParameter [JsonIgnore] public string Name { get; set; } } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/Reference.cs b/src/Saunter/AsyncApiSchema/v2/Reference.cs index 044a5fb4..7a7cd58f 100644 --- a/src/Saunter/AsyncApiSchema/v2/Reference.cs +++ b/src/Saunter/AsyncApiSchema/v2/Reference.cs @@ -1,4 +1,4 @@ -using System; +using System; using Newtonsoft.Json; using Saunter.AsyncApiSchema.v2.Traits; @@ -20,8 +20,8 @@ public Reference(string id, string path) [JsonProperty("$ref")] public string Ref => string.Format(_path, _id); - + [JsonIgnore()] public string Id => _id; } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/SecurityScheme.cs b/src/Saunter/AsyncApiSchema/v2/SecurityScheme.cs index 97d62c1e..d577b045 100644 --- a/src/Saunter/AsyncApiSchema/v2/SecurityScheme.cs +++ b/src/Saunter/AsyncApiSchema/v2/SecurityScheme.cs @@ -1,4 +1,4 @@ -using System.Runtime.Serialization; +using System.Runtime.Serialization; using Newtonsoft.Json; using Newtonsoft.Json.Converters; @@ -62,34 +62,34 @@ public SecurityScheme(SecuritySchemeType type) [JsonProperty("openIdConnectUrl")] public string OpenIdConnectUrl { get; set; } } - + [JsonConverter(typeof(StringEnumConverter))] public enum SecuritySchemeType { [EnumMember(Value = "userPassword")] UserPassword, - + [EnumMember(Value = "apiKey")] ApiKey, - + [EnumMember(Value = "X509")] X509, - + [EnumMember(Value = "symmetricEncryption")] SymmetricEncryption, - + [EnumMember(Value = "asymmetricEncryption")] AsymmetricEncryption, - + [EnumMember(Value = "httpApiKey")] HttpApiKey, [EnumMember(Value = "http")] Http, - + [EnumMember(Value = "oauth2")] OAuth2, - + [EnumMember(Value = "openIdConnect")] OpenIdConnect, @@ -105,4 +105,4 @@ public enum SecuritySchemeType [EnumMember(Value = "gssapi")] GSSAPI, } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/Server.cs b/src/Saunter/AsyncApiSchema/v2/Server.cs index 86aa265e..982fdaa4 100644 --- a/src/Saunter/AsyncApiSchema/v2/Server.cs +++ b/src/Saunter/AsyncApiSchema/v2/Server.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using Newtonsoft.Json; using Saunter.AsyncApiSchema.v2.Bindings; @@ -67,7 +67,7 @@ public Server(string url, string protocol) [JsonProperty("bindings", NullValueHandling = NullValueHandling.Ignore)] public IServerBindings Bindings { get; set; } } - + public class ServerVariable { /// @@ -124,4 +124,4 @@ public static class ServerProtocol public const string Wss = "wss"; } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/Tag.cs b/src/Saunter/AsyncApiSchema/v2/Tag.cs index 9bb705a3..714cedc3 100644 --- a/src/Saunter/AsyncApiSchema/v2/Tag.cs +++ b/src/Saunter/AsyncApiSchema/v2/Tag.cs @@ -1,4 +1,4 @@ -using System; +using System; using Newtonsoft.Json; namespace Saunter.AsyncApiSchema.v2 @@ -33,4 +33,4 @@ public static implicit operator Tag(string s) return new Tag(s); } } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/Traits/MessageTrait.cs b/src/Saunter/AsyncApiSchema/v2/Traits/MessageTrait.cs index dc932a3f..4831eb5c 100644 --- a/src/Saunter/AsyncApiSchema/v2/Traits/MessageTrait.cs +++ b/src/Saunter/AsyncApiSchema/v2/Traits/MessageTrait.cs @@ -1,6 +1,6 @@ -using NJsonSchema; -using System.Collections.Generic; +using System.Collections.Generic; using Newtonsoft.Json; +using NJsonSchema; using Saunter.AsyncApiSchema.v2.Bindings; namespace Saunter.AsyncApiSchema.v2.Traits @@ -9,7 +9,7 @@ namespace Saunter.AsyncApiSchema.v2.Traits /// Can be either a or reference to a message trait. /// public interface IMessageTrait { } - + /// /// A reference to a MessageTrait within the AsyncAPI components. /// @@ -17,7 +17,7 @@ public class MessageTraitReference : Reference, IMessageTrait { public MessageTraitReference(string id) : base(id, "#/components/messageTraits/{0}") { } } - + public class MessageTrait : IMessageTrait { /// @@ -78,8 +78,8 @@ public class MessageTrait : IMessageTrait /// Tags can be used for logical grouping of messages. /// [JsonProperty("tags")] - public ISet Tags { get; set; } - + public ISet Tags { get; set; } + /// /// Additional external documentation for this message. /// @@ -99,4 +99,4 @@ public class MessageTrait : IMessageTrait [JsonProperty("examples")] public IList> Examples { get; set; } } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiSchema/v2/Traits/OperationTrait.cs b/src/Saunter/AsyncApiSchema/v2/Traits/OperationTrait.cs index 3a4a73da..36f1b9da 100644 --- a/src/Saunter/AsyncApiSchema/v2/Traits/OperationTrait.cs +++ b/src/Saunter/AsyncApiSchema/v2/Traits/OperationTrait.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Newtonsoft.Json; using Saunter.AsyncApiSchema.v2.Bindings; @@ -8,7 +8,7 @@ namespace Saunter.AsyncApiSchema.v2.Traits /// Can be either an or an reference to an operation trait. /// public interface IOperationTrait { } - + /// /// A reference to an OperationTrait within the AsyncAPI components. /// @@ -16,7 +16,7 @@ public class OperationTraitReference : Reference, IOperationTrait { public OperationTraitReference(string id) : base(id, "#/components/operationTraits/{0}") { } } - + public class OperationTrait : IOperationTrait { /// @@ -60,4 +60,4 @@ public class OperationTrait : IOperationTrait [JsonProperty("bindings", NullValueHandling = NullValueHandling.Ignore)] public IOperationBindings Bindings { get; set; } } -} \ No newline at end of file +} diff --git a/src/Saunter/AsyncApiServiceCollectionExtensions.cs b/src/Saunter/AsyncApiServiceCollectionExtensions.cs index 700e35e6..288001cb 100644 --- a/src/Saunter/AsyncApiServiceCollectionExtensions.cs +++ b/src/Saunter/AsyncApiServiceCollectionExtensions.cs @@ -1,4 +1,4 @@ -using System; +using System; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; @@ -57,4 +57,4 @@ public static IServiceCollection ConfigureNamedAsyncApi(this IServiceCollection return services; } } -} \ No newline at end of file +} diff --git a/src/Saunter/Attributes/AsyncApiAttribute.cs b/src/Saunter/Attributes/AsyncApiAttribute.cs index 08c081b6..a8869664 100644 --- a/src/Saunter/Attributes/AsyncApiAttribute.cs +++ b/src/Saunter/Attributes/AsyncApiAttribute.cs @@ -1,4 +1,4 @@ -using System; +using System; namespace Saunter.Attributes { @@ -9,10 +9,10 @@ namespace Saunter.Attributes public sealed class AsyncApiAttribute : Attribute { public string DocumentName { get; } - + public AsyncApiAttribute(string documentName = null) { DocumentName = documentName; } } -} \ No newline at end of file +} diff --git a/src/Saunter/Attributes/ChannelAttribute.cs b/src/Saunter/Attributes/ChannelAttribute.cs index 246de376..b7ea022a 100644 --- a/src/Saunter/Attributes/ChannelAttribute.cs +++ b/src/Saunter/Attributes/ChannelAttribute.cs @@ -1,4 +1,4 @@ -using System; +using System; namespace Saunter.Attributes { @@ -37,4 +37,4 @@ public ChannelAttribute(string name) Name = name ?? throw new ArgumentNullException(nameof(name)); } } -} \ No newline at end of file +} diff --git a/src/Saunter/Attributes/ChannelParameterAttribute.cs b/src/Saunter/Attributes/ChannelParameterAttribute.cs index 458c29aa..d4301da4 100644 --- a/src/Saunter/Attributes/ChannelParameterAttribute.cs +++ b/src/Saunter/Attributes/ChannelParameterAttribute.cs @@ -1,4 +1,4 @@ -using System; +using System; namespace Saunter.Attributes { @@ -19,4 +19,4 @@ public ChannelParameterAttribute(string name, Type type) public string Location { get; set; } } -} \ No newline at end of file +} diff --git a/src/Saunter/Attributes/MessageAttribute.cs b/src/Saunter/Attributes/MessageAttribute.cs index 19eedb6f..86cf877a 100644 --- a/src/Saunter/Attributes/MessageAttribute.cs +++ b/src/Saunter/Attributes/MessageAttribute.cs @@ -1,4 +1,4 @@ -using System; +using System; namespace Saunter.Attributes { @@ -9,13 +9,13 @@ public MessageAttribute(Type payloadType) { PayloadType = payloadType; } - + public MessageAttribute(Type payloadType, params string[] tags) { PayloadType = payloadType; Tags = tags; } - + /// /// The type to use to generate the message payload schema. /// @@ -67,4 +67,4 @@ public MessageAttribute(Type payloadType, params string[] tags) /// public string[] Tags { get; } } -} \ No newline at end of file +} diff --git a/src/Saunter/Generation/AsyncApiDocumentProvider.cs b/src/Saunter/Generation/AsyncApiDocumentProvider.cs index b370d8d0..6bce8fbb 100644 --- a/src/Saunter/Generation/AsyncApiDocumentProvider.cs +++ b/src/Saunter/Generation/AsyncApiDocumentProvider.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using System.Reflection; using Saunter.AsyncApiSchema.v2; @@ -45,4 +45,4 @@ private static TypeInfo[] GetAsyncApiTypes(AsyncApiOptions options, AsyncApiDocu return asyncApiTypes; } } -} \ No newline at end of file +} diff --git a/src/Saunter/Generation/DocumentGenerator.cs b/src/Saunter/Generation/DocumentGenerator.cs index 6b381c1e..d19bfe81 100644 --- a/src/Saunter/Generation/DocumentGenerator.cs +++ b/src/Saunter/Generation/DocumentGenerator.cs @@ -1,3 +1,7 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; using Microsoft.Extensions.DependencyInjection; using Namotion.Reflection; using NJsonSchema.Generation; @@ -7,10 +11,6 @@ using Saunter.Generation.Filters; using Saunter.Generation.SchemaGeneration; using Saunter.Utils; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; namespace Saunter.Generation { @@ -28,7 +28,7 @@ public AsyncApiSchema.v2.AsyncApiDocument GenerateDocument(TypeInfo[] asyncApiTy var generator = new JsonSchemaGenerator(options.SchemaOptions); asyncApiSchema.Channels = GenerateChannels(asyncApiTypes, schemaResolver, options, generator, serviceProvider); - + var filterContext = new DocumentFilterContext(asyncApiTypes, schemaResolver, generator); foreach (var filterType in options.DocumentFilters) { @@ -45,7 +45,7 @@ public AsyncApiSchema.v2.AsyncApiDocument GenerateDocument(TypeInfo[] asyncApiTy private static IDictionary GenerateChannels(TypeInfo[] asyncApiTypes, AsyncApiSchemaResolver schemaResolver, AsyncApiOptions options, JsonSchemaGenerator jsonSchemaGenerator, IServiceProvider serviceProvider) { var channels = new Dictionary(); - + channels.AddRange(GenerateChannelsFromMethods(asyncApiTypes, schemaResolver, options, jsonSchemaGenerator, serviceProvider)); channels.AddRange(GenerateChannelsFromClasses(asyncApiTypes, schemaResolver, options, jsonSchemaGenerator, serviceProvider)); return channels; @@ -71,7 +71,7 @@ private static IDictionary GenerateChannelsFromMethods(IEnu foreach (var mc in methodsWithChannelAttribute) { if (mc.Channel == null) continue; - + var channelItem = new ChannelItem { Description = mc.Channel.Description, @@ -80,9 +80,9 @@ private static IDictionary GenerateChannelsFromMethods(IEnu Subscribe = GenerateOperationFromMethod(mc.Method, schemaResolver, OperationType.Subscribe, options, jsonSchemaGenerator, serviceProvider), Bindings = mc.Channel.BindingsRef != null ? new ChannelBindingsReference(mc.Channel.BindingsRef) : null, Servers = mc.Channel.Servers?.ToList(), - }; + }; channels.AddOrAppend(mc.Channel.Name, channelItem); - + var context = new ChannelItemFilterContext(mc.Method, schemaResolver, jsonSchemaGenerator, mc.Channel); foreach (var filterType in options.ChannelItemFilters) { @@ -113,7 +113,7 @@ private static IDictionary GenerateChannelsFromClasses(IEnu foreach (var cc in classesWithChannelAttribute) { if (cc.Channel == null) continue; - + var channelItem = new ChannelItem { Description = cc.Channel.Description, @@ -123,9 +123,9 @@ private static IDictionary GenerateChannelsFromClasses(IEnu Bindings = cc.Channel.BindingsRef != null ? new ChannelBindingsReference(cc.Channel.BindingsRef) : null, Servers = cc.Channel.Servers?.ToList(), }; - + channels.AddOrAppend(cc.Channel.Name, channelItem); - + var context = new ChannelItemFilterContext(cc.Type, schemaResolver, jsonSchemaGenerator, cc.Channel); foreach (var filterType in options.ChannelItemFilters) { @@ -152,7 +152,7 @@ private static Operation GenerateOperationFromMethod(MethodInfo method, AsyncApi var message = messageAttributes.Any() ? GenerateMessageFromAttributes(messageAttributes, schemaResolver, jsonSchemaGenerator) : GenerateMessageFromType(operationAttribute.MessagePayloadType, schemaResolver, jsonSchemaGenerator); - + var operation = new Operation { OperationId = operationAttribute.OperationId ?? method.Name, @@ -192,7 +192,7 @@ private static Operation GenerateOperationFromClass(TypeInfo type, AsyncApiSchem Description = operationAttribute.Description ?? (type.GetXmlDocsRemarks() != "" ? type.GetXmlDocsRemarks() : null), Message = messages, Bindings = operationAttribute.BindingsRef != null ? new OperationBindingsReference(operationAttribute.BindingsRef) : null, - Tags = new HashSet( operationAttribute.Tags?.Select(x => new Tag(x)) ?? new List()) + Tags = new HashSet(operationAttribute.Tags?.Select(x => new Tag(x)) ?? new List()) }; var methodsWithMessageAttribute = type.DeclaredMethods @@ -226,11 +226,11 @@ private static OperationAttribute GetOperationAttribute(MemberInfo typeOrMethod, { case OperationType.Publish: var publishOperationAttribute = typeOrMethod.GetCustomAttribute(); - return (OperationAttribute) publishOperationAttribute; + return (OperationAttribute)publishOperationAttribute; case OperationType.Subscribe: var subscribeOperationAttribute = typeOrMethod.GetCustomAttribute(); - return (OperationAttribute) subscribeOperationAttribute; + return (OperationAttribute)subscribeOperationAttribute; default: return null; @@ -284,7 +284,7 @@ private static IMessage GenerateMessageFromAttribute(MessageAttribute messageAtt return schemaResolver.GetMessageOrReference(message); } - + private static IMessage GenerateMessageFromType(Type payloadType, AsyncApiSchemaResolver schemaResolver, JsonSchemaGenerator jsonSchemaGenerator) { @@ -317,7 +317,7 @@ private static IDictionary GetChannelParametersFromAttribute Schema = jsonSchemaGenerator.Generate(attribute.Type, schemaResolver), Location = attribute.Location, }); - + parameters.Add(attribute.Name, parameter); } } @@ -325,4 +325,4 @@ private static IDictionary GetChannelParametersFromAttribute return parameters; } } -} \ No newline at end of file +} diff --git a/src/Saunter/Generation/Filters/IChannelItemFilter.cs b/src/Saunter/Generation/Filters/IChannelItemFilter.cs index 2b01f3de..7f372331 100644 --- a/src/Saunter/Generation/Filters/IChannelItemFilter.cs +++ b/src/Saunter/Generation/Filters/IChannelItemFilter.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using NJsonSchema.Generation; using Saunter.AsyncApiSchema.v2; using Saunter.Attributes; @@ -19,7 +19,7 @@ public ChannelItemFilterContext(MemberInfo member, JsonSchemaResolver schemaReso SchemaGenerator = schemaGenerator; Channel = channel; } - + public MemberInfo Member { get; } public JsonSchemaResolver SchemaResolver { get; } @@ -28,4 +28,4 @@ public ChannelItemFilterContext(MemberInfo member, JsonSchemaResolver schemaReso public ChannelAttribute Channel { get; } } -} \ No newline at end of file +} diff --git a/src/Saunter/Generation/Filters/IDocumentFilter.cs b/src/Saunter/Generation/Filters/IDocumentFilter.cs index 0f50082c..9627c44c 100644 --- a/src/Saunter/Generation/Filters/IDocumentFilter.cs +++ b/src/Saunter/Generation/Filters/IDocumentFilter.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using NJsonSchema.Generation; using Saunter.AsyncApiSchema.v2; @@ -19,7 +19,7 @@ public DocumentFilterContext(IEnumerable asyncApiTypes, JsonSchemaResolver SchemaResolver = schemaResolver; SchemaGenerator = schemaGenerator; } - + public IEnumerable AsyncApiTypes { get; } public JsonSchemaResolver SchemaResolver { get; } @@ -27,4 +27,4 @@ public DocumentFilterContext(IEnumerable asyncApiTypes, JsonSchemaResolver public JsonSchemaGenerator SchemaGenerator { get; } } -} \ No newline at end of file +} diff --git a/src/Saunter/Generation/Filters/IOperationFilter.cs b/src/Saunter/Generation/Filters/IOperationFilter.cs index 480ef392..d76810ba 100644 --- a/src/Saunter/Generation/Filters/IOperationFilter.cs +++ b/src/Saunter/Generation/Filters/IOperationFilter.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Reflection; using NJsonSchema.Generation; using Saunter.AsyncApiSchema.v2; @@ -21,7 +21,7 @@ public OperationFilterContext(MethodInfo method, JsonSchemaResolver schemaResolv SchemaGenerator = schemaGenerator; Operation = operation; } - + public MethodInfo Method { get; } public JsonSchemaResolver SchemaResolver { get; } @@ -30,4 +30,4 @@ public OperationFilterContext(MethodInfo method, JsonSchemaResolver schemaResolv public OperationAttribute Operation { get; } } -} \ No newline at end of file +} diff --git a/src/Saunter/Generation/IDocumentGenerator.cs b/src/Saunter/Generation/IDocumentGenerator.cs index e8cb11a5..6c9935dc 100644 --- a/src/Saunter/Generation/IDocumentGenerator.cs +++ b/src/Saunter/Generation/IDocumentGenerator.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Reflection; using Saunter.AsyncApiSchema.v2; @@ -8,4 +8,4 @@ public interface IDocumentGenerator { AsyncApiDocument GenerateDocument(TypeInfo[] asyncApiTypes, AsyncApiOptions options, AsyncApiDocument prototype, IServiceProvider serviceProvider); } -} \ No newline at end of file +} diff --git a/src/Saunter/Generation/SchemaGeneration/AsyncApiSchemaResolver.cs b/src/Saunter/Generation/SchemaGeneration/AsyncApiSchemaResolver.cs index ce538923..39447766 100644 --- a/src/Saunter/Generation/SchemaGeneration/AsyncApiSchemaResolver.cs +++ b/src/Saunter/Generation/SchemaGeneration/AsyncApiSchemaResolver.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using NJsonSchema; using NJsonSchema.Generation; @@ -11,7 +11,7 @@ public class AsyncApiSchemaResolver : JsonSchemaResolver private readonly AsyncApiDocument _document; private readonly JsonSchemaGeneratorSettings _settings; - public AsyncApiSchemaResolver(AsyncApiDocument document, AsyncApiSchemaOptions settings) + public AsyncApiSchemaResolver(AsyncApiDocument document, AsyncApiSchemaOptions settings) : base(document, settings) { _document = document; @@ -24,7 +24,7 @@ public override void AppendSchema(JsonSchema schema, string typeNameHint) throw new ArgumentNullException(nameof(schema)); if (schema == RootObject) throw new ArgumentException("The root schema cannot be appended."); - + if (!_document.Components.Schemas.Values.Contains(schema)) { var schemaId = _settings.TypeNameGenerator.Generate(schema, typeNameHint, _document.Components.Schemas.Keys.Select(k => k.ToString())); @@ -86,4 +86,4 @@ public IParameter GetParameterOrReference(Parameter parameter) return new ParameterReference(id, _document); } } -} \ No newline at end of file +} diff --git a/src/Saunter/IAsyncApiDocumentProvider.cs b/src/Saunter/IAsyncApiDocumentProvider.cs index 1726d56f..a3f9814a 100644 --- a/src/Saunter/IAsyncApiDocumentProvider.cs +++ b/src/Saunter/IAsyncApiDocumentProvider.cs @@ -1,4 +1,4 @@ -using Saunter.AsyncApiSchema.v2; +using Saunter.AsyncApiSchema.v2; namespace Saunter { @@ -6,4 +6,4 @@ public interface IAsyncApiDocumentProvider { AsyncApiDocument GetDocument(AsyncApiOptions options, AsyncApiDocument prototype); } -} \ No newline at end of file +} diff --git a/src/Saunter/Properties/AssemblyInfo.cs b/src/Saunter/Properties/AssemblyInfo.cs index e4e00e63..e96b75e3 100644 --- a/src/Saunter/Properties/AssemblyInfo.cs +++ b/src/Saunter/Properties/AssemblyInfo.cs @@ -1,3 +1,3 @@ -using System.Runtime.CompilerServices; +using System.Runtime.CompilerServices; -[assembly: InternalsVisibleTo("Saunter.Tests")] \ No newline at end of file +[assembly: InternalsVisibleTo("Saunter.Tests")] diff --git a/src/Saunter/Serialization/IAsyncApiDocumentSerializer.cs b/src/Saunter/Serialization/IAsyncApiDocumentSerializer.cs index 1170d0fd..05562c33 100644 --- a/src/Saunter/Serialization/IAsyncApiDocumentSerializer.cs +++ b/src/Saunter/Serialization/IAsyncApiDocumentSerializer.cs @@ -1,6 +1,6 @@ -using Saunter.AsyncApiSchema.v2; -using System.Threading; +using System.Threading; using System.Threading.Tasks; +using Saunter.AsyncApiSchema.v2; namespace Saunter.Serialization { @@ -12,4 +12,4 @@ public interface IAsyncApiDocumentSerializer Task DeserializeAsync(string data, CancellationToken cancellationToken); } -} \ No newline at end of file +} diff --git a/src/Saunter/Serialization/NewtonsoftAsyncApiDocumentSerializer.cs b/src/Saunter/Serialization/NewtonsoftAsyncApiDocumentSerializer.cs index 51085d6b..40a4d069 100644 --- a/src/Saunter/Serialization/NewtonsoftAsyncApiDocumentSerializer.cs +++ b/src/Saunter/Serialization/NewtonsoftAsyncApiDocumentSerializer.cs @@ -1,10 +1,10 @@ -using Newtonsoft.Json; +using System.Threading; +using System.Threading.Tasks; +using Newtonsoft.Json; using NJsonSchema; using NJsonSchema.Infrastructure; using Saunter.AsyncApiSchema.v2; using Saunter.Generation.SchemaGeneration; -using System.Threading; -using System.Threading.Tasks; namespace Saunter.Serialization { diff --git a/src/Saunter/UI/AsyncApiUiMiddleware.cs b/src/Saunter/UI/AsyncApiUiMiddleware.cs index c5b8e2b0..25af8a7d 100644 --- a/src/Saunter/UI/AsyncApiUiMiddleware.cs +++ b/src/Saunter/UI/AsyncApiUiMiddleware.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Net; @@ -51,7 +51,7 @@ public async Task Invoke(HttpContext context) { if (IsRequestingUiBase(context.Request)) { - context.Response.StatusCode = (int) HttpStatusCode.MovedPermanently; + context.Response.StatusCode = (int)HttpStatusCode.MovedPermanently; if (context.TryGetDocument(out var document)) { @@ -76,7 +76,7 @@ public async Task Invoke(HttpContext context) } return; } - + if (!context.TryGetDocument(out var documentName)) { await _staticFiles.Invoke(context); @@ -121,7 +121,7 @@ private bool IsRequestingUiBase(HttpRequest request) { return HttpMethods.IsGet(request.Method) && request.Path.IsMatchingRoute(UiBaseRoute); } - + private bool IsRequestingAsyncApiUi(HttpRequest request) { return HttpMethods.IsGet(request.Method) && request.Path.IsMatchingRoute(UiIndexRoute); diff --git a/src/Saunter/Utils/ChannelItemExtensions.cs b/src/Saunter/Utils/ChannelItemExtensions.cs index 5ba11a89..dac1e97a 100644 --- a/src/Saunter/Utils/ChannelItemExtensions.cs +++ b/src/Saunter/Utils/ChannelItemExtensions.cs @@ -25,7 +25,7 @@ public static void AddOrAppend(this IDictionary source, str { if (existing.Publish != null && channel.Publish != null) throw new ArgumentException("An item with the same key and with an existing publish operation has already been added to the channel collection."); - + if (existing.Subscribe != null && channel.Subscribe != null) throw new ArgumentException("An item with the same key and with an existing subscribe operation has already been added to the channel collection."); diff --git a/src/Saunter/Utils/Reflection.cs b/src/Saunter/Utils/Reflection.cs index 9e38a498..3f348a10 100644 --- a/src/Saunter/Utils/Reflection.cs +++ b/src/Saunter/Utils/Reflection.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Reflection; namespace Saunter.Utils @@ -10,4 +10,4 @@ public static bool HasCustomAttribute(this TypeInfo typeInfo) where T : Attri return typeInfo.GetCustomAttribute() != null; } } -} \ No newline at end of file +} diff --git a/test/Saunter.IntegrationTests.ReverseProxy/Program.cs b/test/Saunter.IntegrationTests.ReverseProxy/Program.cs index a176ba42..0cdfb927 100644 --- a/test/Saunter.IntegrationTests.ReverseProxy/Program.cs +++ b/test/Saunter.IntegrationTests.ReverseProxy/Program.cs @@ -46,7 +46,7 @@ public void ConfigureServices(IServiceCollection services) { services.AddAsyncApiSchemaGeneration(options => { - options.AssemblyMarkerTypes = new[] {typeof(StreetlightsController)}; + options.AssemblyMarkerTypes = new[] { typeof(StreetlightsController) }; options.AsyncApi = new AsyncApiDocument { @@ -104,7 +104,7 @@ public class StreetlightsController { [Channel("publish/light/measured"), PublishOperation(typeof(LightMeasuredEvent))] [HttpPost, Route("publish/light/measured")] - public void MeasureLight([FromBody] LightMeasuredEvent lightMeasuredEvent) + public void MeasureLight([FromBody] LightMeasuredEvent _) { } } diff --git a/test/Saunter.Tests.MarkerTypeTests/Broker.cs b/test/Saunter.Tests.MarkerTypeTests/Broker.cs index 8cc9902d..64cc4973 100644 --- a/test/Saunter.Tests.MarkerTypeTests/Broker.cs +++ b/test/Saunter.Tests.MarkerTypeTests/Broker.cs @@ -8,7 +8,7 @@ namespace Saunter.Tests.MarkerTypeTests public class AnotherSamplePublisher { [Message(typeof(AnotherSampleMesssage))] - public void PublishTenantCreated(AnotherSampleMesssage @event) { } + public void PublishTenantCreated(AnotherSampleMesssage _) { } } [AsyncApi] @@ -17,9 +17,9 @@ public void PublishTenantCreated(AnotherSampleMesssage @event) { } public class SampleConsumer { [Message(typeof(SampleMessage))] - public void SubscribeSampleMessage(SampleMessage evnt) { } + public void SubscribeSampleMessage(SampleMessage _) { } } public class SampleMessage { } public class AnotherSampleMesssage { } -} \ No newline at end of file +} diff --git a/test/Saunter.Tests/ActivatorServiceProvider.cs b/test/Saunter.Tests/ActivatorServiceProvider.cs index 4816f184..e49bae96 100644 --- a/test/Saunter.Tests/ActivatorServiceProvider.cs +++ b/test/Saunter.Tests/ActivatorServiceProvider.cs @@ -11,4 +11,4 @@ public object GetService(Type serviceType) return Activator.CreateInstance(serviceType); } } -} \ No newline at end of file +} diff --git a/test/Saunter.Tests/Generation/DocumentGeneratorTests/ClassAttributesTests.cs b/test/Saunter.Tests/Generation/DocumentGeneratorTests/ClassAttributesTests.cs index 5df8628c..2e59b360 100644 --- a/test/Saunter.Tests/Generation/DocumentGeneratorTests/ClassAttributesTests.cs +++ b/test/Saunter.Tests/Generation/DocumentGeneratorTests/ClassAttributesTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Reflection; @@ -18,7 +18,7 @@ public void GetDocument_GeneratesDocumentWithMultipleMessagesPerChannel() // Arrange var options = new AsyncApiOptions(); var documentGenerator = new DocumentGenerator(); - + // Act var document = documentGenerator.GenerateDocument(new[] { typeof(TenantMessageConsumer).GetTypeInfo() }, options, options.AsyncApi, ActivatorServiceProvider.Instance); @@ -52,7 +52,7 @@ public void GenerateDocument_GeneratesDocumentWithMultipleMessagesPerChannelInTh var documentGenerator = new DocumentGenerator(); // Act - var document = documentGenerator.GenerateDocument(new []{ typeof(TenantGenericMessagePublisher).GetTypeInfo() }, options, options.AsyncApi, ActivatorServiceProvider.Instance); + var document = documentGenerator.GenerateDocument(new[] { typeof(TenantGenericMessagePublisher).GetTypeInfo() }, options, options.AsyncApi, ActivatorServiceProvider.Instance); // Assert document.ShouldNotBeNull(); @@ -69,7 +69,7 @@ public void GenerateDocument_GeneratesDocumentWithMultipleMessagesPerChannelInTh var messages = publish.Message.ShouldBeOfType(); messages.OneOf.Count.ShouldBe(3); - + messages.OneOf.OfType().ShouldContain(m => m.Id == "anyTenantCreated"); messages.OneOf.OfType().ShouldContain(m => m.Id == "anyTenantUpdated"); messages.OneOf.OfType().ShouldContain(m => m.Id == "anyTenantRemoved"); @@ -84,7 +84,7 @@ public void GenerateDocument_GeneratesDocumentWithSingleMessage() var documentGenerator = new DocumentGenerator(); // Act - var document = documentGenerator.GenerateDocument(new []{ typeof(TenantSingleMessagePublisher).GetTypeInfo() }, options, options.AsyncApi, ActivatorServiceProvider.Instance); + var document = documentGenerator.GenerateDocument(new[] { typeof(TenantSingleMessagePublisher).GetTypeInfo() }, options, options.AsyncApi, ActivatorServiceProvider.Instance); // Assert document.ShouldNotBeNull(); @@ -93,7 +93,7 @@ public void GenerateDocument_GeneratesDocumentWithSingleMessage() var channel = document.Channels.First(); channel.Key.ShouldBe("asw.tenant_service.tenants_history"); channel.Value.Description.ShouldBe("Tenant events."); - + var publish = channel.Value.Publish; publish.ShouldNotBeNull(); publish.OperationId.ShouldBe("TenantSingleMessagePublisher"); @@ -161,7 +161,7 @@ public void GenerateDocument_GeneratesDocumentWithChannelParameters() var documentGenerator = new DocumentGenerator(); // Act - var document = documentGenerator.GenerateDocument(new []{ typeof(OneTenantMessageConsumer).GetTypeInfo() }, options, options.AsyncApi, ActivatorServiceProvider.Instance); + var document = documentGenerator.GenerateDocument(new[] { typeof(OneTenantMessageConsumer).GetTypeInfo() }, options, options.AsyncApi, ActivatorServiceProvider.Instance); // Assert document.ShouldNotBeNull(); @@ -173,7 +173,7 @@ public void GenerateDocument_GeneratesDocumentWithChannelParameters() channel.Value.Parameters.Count.ShouldBe(2); channel.Value.Parameters.Values.OfType().ShouldContain(p => p.Id == "tenant_id" && p.Value.Schema != null && p.Value.Description == "The tenant identifier."); channel.Value.Parameters.Values.OfType().ShouldContain(p => p.Id == "tenant_status" && p.Value.Schema != null && p.Value.Description == "The tenant status."); - + var subscribe = channel.Value.Subscribe; subscribe.ShouldNotBeNull(); subscribe.OperationId.ShouldBe("OneTenantMessageConsumer"); @@ -181,7 +181,7 @@ public void GenerateDocument_GeneratesDocumentWithChannelParameters() var messages = subscribe.Message.ShouldBeOfType(); messages.OneOf.Count.ShouldBe(3); - + messages.OneOf.OfType().ShouldContain(m => m.Id == "tenantCreated"); messages.OneOf.OfType().ShouldContain(m => m.Id == "tenantUpdated"); messages.OneOf.OfType().ShouldContain(m => m.Id == "tenantRemoved"); @@ -197,7 +197,7 @@ public void GenerateDocument_GeneratesDocumentWithMessageHeader() // Act var document = documentGenerator.GenerateDocument(new[] { typeof(MyMessagePublisher).GetTypeInfo() }, options, options.AsyncApi, ActivatorServiceProvider.Instance); - + // Assert document.ShouldNotBeNull(); @@ -222,13 +222,13 @@ public void PublishMyMessage() { } public class TenantMessageConsumer { [Message(typeof(TenantCreated))] - public void SubscribeTenantCreatedEvent(Guid tenantId, TenantCreated evnt) { } + public void SubscribeTenantCreatedEvent(Guid _, TenantCreated __) { } [Message(typeof(TenantUpdated))] - public void SubscribeTenantUpdatedEvent(Guid tenantId, TenantUpdated evnt) { } + public void SubscribeTenantUpdatedEvent(Guid _, TenantUpdated __) { } [Message(typeof(TenantRemoved))] - public void SubscribeTenantRemovedEvent(Guid tenantId, TenantRemoved evnt) { } + public void SubscribeTenantRemovedEvent(Guid _, TenantRemoved __) { } } [AsyncApi] @@ -237,13 +237,13 @@ public void SubscribeTenantRemovedEvent(Guid tenantId, TenantRemoved evnt) { } public class TenantMessagePublisher { [Message(typeof(TenantCreated))] - public void PublishTenantCreatedEvent(Guid tenantId, TenantCreated evnt) { } + public void PublishTenantCreatedEvent(Guid _, TenantCreated __) { } [Message(typeof(TenantUpdated))] - public void PublishTenantUpdatedEvent(Guid tenantId, TenantUpdated evnt) { } + public void PublishTenantUpdatedEvent(Guid _, TenantUpdated __) { } [Message(typeof(TenantRemoved))] - public void PublishTenantRemovedEvent(Guid tenantId, TenantRemoved evnt) { } + public void PublishTenantRemovedEvent(Guid _, TenantRemoved __) { } } [AsyncApi] @@ -254,7 +254,7 @@ public class TenantGenericMessagePublisher [Message(typeof(AnyTenantCreated))] [Message(typeof(AnyTenantUpdated))] [Message(typeof(AnyTenantRemoved))] - public void PublishTenantEvent(Guid tenantId, TEvent @event) + public void PublishTenantEvent(Guid _, TEvent __) where TEvent : IEvent { } @@ -266,7 +266,7 @@ public void PublishTenantEvent(Guid tenantId, TEvent @event) public class TenantSingleMessagePublisher { [Message(typeof(AnyTenantCreated))] - public void PublishTenantCreated(Guid tenantId, AnyTenantCreated @event) + public void PublishTenantCreated(Guid _, AnyTenantCreated __) { } } @@ -279,13 +279,13 @@ public void PublishTenantCreated(Guid tenantId, AnyTenantCreated @event) public class OneTenantMessageConsumer { [Message(typeof(TenantCreated))] - public void SubscribeTenantCreatedEvent(Guid tenantId, TenantCreated evnt) {} + public void SubscribeTenantCreatedEvent(Guid _, TenantCreated __) { } [Message(typeof(TenantUpdated))] - public void SubscribeTenantUpdatedEvent(Guid tenantId, TenantUpdated evnt) {} + public void SubscribeTenantUpdatedEvent(Guid _, TenantUpdated __) { } [Message(typeof(TenantRemoved))] - public void SubscribeTenantRemovedEvent(Guid tenantId, TenantRemoved evnt) {} + public void SubscribeTenantRemovedEvent(Guid _, TenantRemoved __) { } } } @@ -303,4 +303,4 @@ public class MyMessageHeader public string StringHeader { get; set; } public int? NullableIntHeader { get; set; } } -} \ No newline at end of file +} diff --git a/test/Saunter.Tests/Generation/DocumentGeneratorTests/MethodAttributesTests.cs b/test/Saunter.Tests/Generation/DocumentGeneratorTests/MethodAttributesTests.cs index 4368b629..c9df1034 100644 --- a/test/Saunter.Tests/Generation/DocumentGeneratorTests/MethodAttributesTests.cs +++ b/test/Saunter.Tests/Generation/DocumentGeneratorTests/MethodAttributesTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using System.Reflection; using Microsoft.Extensions.Options; @@ -20,8 +20,8 @@ public void GenerateDocument_GeneratesDocumentWithMultipleMessagesPerChannel() var documentGenerator = new DocumentGenerator(); // Act - var document = documentGenerator.GenerateDocument(new []{ typeof(TenantMessagePublisher).GetTypeInfo() }, options, options.AsyncApi, ActivatorServiceProvider.Instance); - + var document = documentGenerator.GenerateDocument(new[] { typeof(TenantMessagePublisher).GetTypeInfo() }, options, options.AsyncApi, ActivatorServiceProvider.Instance); + // Assert document.ShouldNotBeNull(); document.Channels.Count.ShouldBe(1); @@ -29,7 +29,7 @@ public void GenerateDocument_GeneratesDocumentWithMultipleMessagesPerChannel() var channel = document.Channels.First(); channel.Key.ShouldBe("asw.tenant_service.tenants_history"); channel.Value.Description.ShouldBe("Tenant events."); - + var publish = channel.Value.Publish; publish.ShouldNotBeNull(); publish.OperationId.ShouldBe("TenantMessagePublisher"); @@ -37,7 +37,7 @@ public void GenerateDocument_GeneratesDocumentWithMultipleMessagesPerChannel() var messages = publish.Message.ShouldBeOfType(); messages.OneOf.Count.ShouldBe(3); - + messages.OneOf.OfType().ShouldContain(m => m.Id == "anyTenantCreated"); messages.OneOf.OfType().ShouldContain(m => m.Id == "anyTenantUpdated"); messages.OneOf.OfType().ShouldContain(m => m.Id == "anyTenantRemoved"); @@ -58,17 +58,17 @@ public void PublishTenantEvent(Guid tenantId, TEvent @event) } } - public class AnyTenantCreated : IEvent {} - - public class AnyTenantUpdated : IEvent {} - - public class AnyTenantRemoved : IEvent {} + public class AnyTenantCreated : IEvent { } + + public class AnyTenantUpdated : IEvent { } + + public class AnyTenantRemoved : IEvent { } + + public interface IEvent { } - public interface IEvent {} - public interface ITenantMessagePublisher { void PublishTenantEvent(Guid tenantId, TEvent @event) where TEvent : IEvent; } -} \ No newline at end of file +} diff --git a/test/Saunter.Tests/Generation/DocumentProviderTests/AsyncApiTypesTests.cs b/test/Saunter.Tests/Generation/DocumentProviderTests/AsyncApiTypesTests.cs index d26579bf..c3692640 100644 --- a/test/Saunter.Tests/Generation/DocumentProviderTests/AsyncApiTypesTests.cs +++ b/test/Saunter.Tests/Generation/DocumentProviderTests/AsyncApiTypesTests.cs @@ -33,6 +33,6 @@ public void GetDocument_GeneratesDocumentWithMultipleMessagesPerChannel() } } - + } } diff --git a/test/Saunter.Tests/Generation/Filters/DocumentFilterTests.cs b/test/Saunter.Tests/Generation/Filters/DocumentFilterTests.cs index 3640ca16..c2074cc8 100644 --- a/test/Saunter.Tests/Generation/Filters/DocumentFilterTests.cs +++ b/test/Saunter.Tests/Generation/Filters/DocumentFilterTests.cs @@ -43,8 +43,8 @@ public void DocumentNameIsAppliedToAsyncApiDocument() // Assert document.ShouldNotBeNull(); document.DocumentName.ShouldBe(documentName); - } - + } + private class ExampleDocumentFilter : IDocumentFilter { public void Apply(AsyncApiDocument document, DocumentFilterContext context) @@ -58,4 +58,4 @@ public void Apply(AsyncApiDocument document, DocumentFilterContext context) } } } -} \ No newline at end of file +} diff --git a/test/Saunter.Tests/Generation/OperationTraitsTests.cs b/test/Saunter.Tests/Generation/OperationTraitsTests.cs index 93e038df..56ee526a 100644 --- a/test/Saunter.Tests/Generation/OperationTraitsTests.cs +++ b/test/Saunter.Tests/Generation/OperationTraitsTests.cs @@ -1,4 +1,4 @@ -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Saunter.AsyncApiSchema.v2; using Saunter.AsyncApiSchema.v2.Traits; @@ -53,4 +53,4 @@ public void Apply(Operation publishOperation, OperationFilterContext context) } } } -} \ No newline at end of file +} diff --git a/test/Saunter.Tests/Generation/SchemaGeneration/SchemaGenerationTests.cs b/test/Saunter.Tests/Generation/SchemaGeneration/SchemaGenerationTests.cs index 3809a1a2..41d11a8c 100644 --- a/test/Saunter.Tests/Generation/SchemaGeneration/SchemaGenerationTests.cs +++ b/test/Saunter.Tests/Generation/SchemaGeneration/SchemaGenerationTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Runtime.Serialization; @@ -242,4 +242,4 @@ public class Dog : Pet { public string PackSize { get; set; } } -} \ No newline at end of file +} diff --git a/test/Saunter.Tests/ServiceCollectionTests.cs b/test/Saunter.Tests/ServiceCollectionTests.cs index 82dffb9b..1d097c7b 100644 --- a/test/Saunter.Tests/ServiceCollectionTests.cs +++ b/test/Saunter.Tests/ServiceCollectionTests.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Microsoft.Extensions.DependencyInjection; using Saunter.AsyncApiSchema.v2; using Saunter.Generation; @@ -37,8 +37,8 @@ public void TestAddAsyncApiSchemaGeneration() Tags = { "example", "event" }, Servers = { - { - "development", + { + "development", new Server("rabbitmq.dev.mwild.me", "amqp") { Security = new List>> { new Dictionary> { { "user-password", new List() } }} diff --git a/test/Saunter.Tests/UI/EmbeddedResourceTests.cs b/test/Saunter.Tests/UI/EmbeddedResourceTests.cs index 029979e9..2e1f1f52 100644 --- a/test/Saunter.Tests/UI/EmbeddedResourceTests.cs +++ b/test/Saunter.Tests/UI/EmbeddedResourceTests.cs @@ -23,4 +23,4 @@ public void SaunterBinaryContainsEmbeddedResourcesFromNpm() resources.ShouldContain("Saunter.UI.index.js", customMessage: err); } } -} \ No newline at end of file +} diff --git a/test/Saunter.Tests/Utils/ReflectionTests.cs b/test/Saunter.Tests/Utils/ReflectionTests.cs index 1610f809..935fc0e0 100644 --- a/test/Saunter.Tests/Utils/ReflectionTests.cs +++ b/test/Saunter.Tests/Utils/ReflectionTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; @@ -35,4 +35,4 @@ public void HasCustomAttribute_False_WhenTypeDoesNotHaveCustomAttribute() type.HasCustomAttribute().ShouldBeFalse(); } } -} \ No newline at end of file +}