How do I generate API documentation for SignalR

Here’s a Nuget package which can help you. Nuget link: https://www.nuget.org/packages/SignalRSwaggerGen/ Github link: https://github.com/essencebit/SignalRSwaggerGen/wiki First you need to decorate your SignalR hubs with attributes from SignalRSwaggerGen.Attributes namespace: [SignalRHub] public class SomeHub : Hub { } Then you add SignalRSwaggerGen to Swagger generator: services.AddSwaggerGen(options => { options.SwaggerDoc(“v1”, new OpenApiInfo { Title = “Some API v1”, Version … Read more

Enable bearer token in Swashbuckle (Swagger document)

Update The issue detailed below is now resolved in Swashbuckle v5.5.0. Issue Just ran into the exact same issue. I think the root cause is this line in Swashbuckle’s source code: var key = encodeURIComponent($(‘#input_apiKey’)[0].value); This is where the value from the HTML input field goes through URL encoding turning the space into %20. I’m … Read more

swagger .net core API ambiguous HTTP method for Action Error

This can occur when a method is declared public in a controller, but without REST attributes. Changing the method to protected may address the issue. I have seen this kind of error before and usually the error message points to the culprit: EBisAPI.Controllers._class.HandleError I guess HandleError is a public method in your base class, right? … Read more

What is Swagger, Swashbuckle and Swashbuckle UI

Swagger is a notation/rules to write documentation. But why is it called a framework(Like angular/MVC)? It is probably called a “framework” because its’ purpose is to offer a systematic way of notating the interface of any RESTful service under the OpenAPI Specification. This is a big deal to developers because the spec is overseen by … Read more

How to add method description in Swagger UI in WebAPI Application

This is well documented in the project: https://github.com/domaindrivendev/Swashbuckle.AspNetCore#include-descriptions-from-xml-comments Include Descriptions from XML Comments To enhance the generated docs with human-friendly descriptions, you can annotate controller actions and models with Xml Comments and configure Swashbuckle to incorporate those comments into the outputted Swagger JSON: 1 – Open the Properties dialog for your project, click the “Build” … Read more

JWT Authentication and Swagger with .NET Core 3.0

After some research, I eventually found the answer here Before seeing this page, I knew that I should use AddSecurityRequirement after AddSecurityDefinition because of many samples, but it was a problem that the function parameters have changed on .NET Core 3.0. By the way, the final answer is as below: services.AddSwaggerGen(c => { c.SwaggerDoc(“v1”, new … Read more

Can’t read from file issue in Swagger UI

I am guessing “http://MYIP/swagger/docs/v1” is not publicly accessible. By default swagger ui uses an online validator: online.swagger.io. If it cannot access your swagger url then you will see that error message. Possible solutions: Disable validation: config.EnableSwagger().EnableSwaggerUi(c => c.DisableValidator()); Make your site publicly accessible Host the validator locally: You can get the validator from: https://github.com/swagger-api/validator-badge#running-locally You … Read more

How to configure Swashbuckle to ignore property on model

If you need to do this but without using JsonIgnore (maybe you still need to serialize/deserialize the property) then just create a custom attribute. [AttributeUsage(AttributeTargets.Property)] public class SwaggerExcludeAttribute : Attribute { } Then a schema filter similar to Johng’s public class SwaggerExcludeFilter : ISchemaFilter { #region ISchemaFilter Members public void Apply(Schema schema, SchemaRegistry schemaRegistry, Type … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)