How do I include subclasses in Swagger API documentation/ OpenAPI specification using Swashbuckle?

It seems Swashbuckle doesn’t implement polymorphism correctly and I understand the point of view of the author about subclasses as parameters (if an action expects an Animal class and behaves differently if you call it with a dog object or a cat object, then you should have 2 different actions…) but as return types I … Read more

How to specify a property can be null or a reference with swagger

OpenAPI 3.1 Define the property as anyOf of the $ref and type: ‘null’. YAML version: foo: anyOf: – type: ‘null’ # Note the quotes around ‘null’ – $ref: ‘#/components/schemas/Foo’ JSON version: “foo”: { “anyOf”: [ { “type”: “null” }, { “$ref”: “#/components/schemas/Foo” } ] } Why use anyOf and not oneOf? oneOf will fail validation … Read more

services.AddSwaggerGen() giving error

I had problem, that IServiceCollection does not contain a definition for ‘AddSwaggerGen’ I turnes out, that I installed Swashbuckle.AspNetCore.Swagger nuget package instead of Swashbuckle.AspNetCore. In .NET Core 3, there’s some issues as discussed here. The solution is to add the following to the project file, replacing the prior version. <PackageReference Include=”Swashbuckle.AspNetCore” Version=”5.0.0-rc2″ /> <PackageReference Include=”Swashbuckle.AspNetCore.SwaggerUI” … Read more

How to convert OpenAPI 2.0 to OpenAPI 3.0? [closed]

Swagger Editor Paste your OpenAPI 2.0 definition into https://editor.swagger.io and select Edit > Convert to OpenAPI 3 from the menu. Swagger Converter Converts OpenAPI 2.0 and Swagger 1.x definitions to OpenAPI 3.0. https://converter.swagger.io/api/convert?url=OAS2_YAML_OR_JSON_URL This gives you JSON. If you want YAML, send the request with the Accept: application/yaml header: curl “https://converter.swagger.io/api/convert?url=OAS2_YAML_OR_JSON_URL” -H “Accept: application/yaml” -o … Read more

How to document GraphQL with Swagger \ OpenAPI?

GraphQL APIs are usually documented through the documentation facilities provided by the GraphQL server itself: The type system and the descriptions on the types and fields. A tool like GraphQL playground lets you explore the API documentation through clicking/searching in a visual document tree or through IDE like features (autocomplete + tooltips). This is mostly … Read more

Describe websocket api via Swagger

It seems to be possible using swagger-socket. Still, it seems that only a Java/Scala server implementation exists for now, which means they are not as much codegens for this that there is for “standard” Swagger REST services. Edit: As pointed out, this project seems to be dead. Unfortunately at the time of updating this answer, … Read more

How to change base url of Swagger in ASP.NET core

For ASP.NET Core 2 (and using Swashbuckle.AspNetCore.Swagger -Version 4.0.1), a couple things can be done for a full configuration of changing the default swagger UI base URL. If you want to add “mycoolapi” to the beginning of your default swagger UI URL, like this: http://<server>/mycoolapi/swagger, then do the following: In your Startup.cs Configure method: app.UseSwagger(c … Read more

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