Questions tagged [swashbuckle]

Swashbuckle is an open source framework which adds Swagger and Swagger-ui to ASP.NET Web API projects.

Swashbuckle combines ApiExplorer, Swagger and Swagger-ui to provide a rich discovery, documentation and playground experience to your ASP.NET Web API consumers.

Core features:

  • Auto-generated Swagger 2.0
  • Seamless integration of swagger-ui
  • Reflection-based Schema generation for describing API types
  • Extensibility hooks for customizing the generated Swagger doc
  • Extensibility hooks for customizing the swagger-ui
  • Out-of-the-box support for leveraging Xml comments
  • Support for describing ApiKey, Basic Auth and OAuth2 schemes ... including UI support for the Implicit OAuth2 flow

The Swashbuckle tag should be used for questions about:

  • Configuring Swashbuckle
  • Extending Swashbuckle with the interfaces ISchemaFilter, IOperationFilter and IDocumentFilter
  • Customizing the embedded Swagger-UI

Questions specifically addressing Swagger or Swagger-UI should not be tagged with the Swashbuckle tag.

Source code: https://github.com/domaindrivendev/Swashbuckle

1366 questions
13
votes
4 answers

Swagger/Swashbuckle: OAuth2 with Resource Owner Password Credentials Grant

I'm trying to use Swashbuckle 5.0.x with OAuth2. I want to use OAuth2's Resource Owner Password Credentials Grant. I basically only want to ask for a token first and include this token in each request (e.g. no need for scopes). Can anyone help with…
Dunken
  • 8,481
  • 7
  • 54
  • 87
12
votes
3 answers

Swagger is not Working Asp.net Core how to open swagger ui

This is my Startup.cs file This is my ConfigureService method in Startup.cs. I have modified it exactly according to documentation, but it's not working. I have removed the launch Url, so it's just going on the port and I have not set any routing. …
Asad
  • 617
  • 2
  • 8
  • 23
12
votes
4 answers

Use the [Authorize]-attribute on Swagger UI with ASP.NET Core Swashbuckle

In ASP.NET Core, using Swashbuckle.AspNetCore, how do I protect the access to my Swagger UI in the same way as decorating it with the [Authorize]-attribute? I want the (equivalent of) [Authorize]-attribute to execute, like for a normally decorated…
Seb Nilsson
  • 26,200
  • 30
  • 103
  • 130
12
votes
1 answer

.NET Core 2.0 Web API - How to add a custom header parameter in Swagger

As per the title - I've found examples of how to do this using regular .NET E.g: Web Api How to add a Header parameter for all API in Swagger However, I can't find any examples, or documentation, showing how to accomplish the same thing when using…
marcusstarnes
  • 6,393
  • 14
  • 65
  • 112
12
votes
2 answers

Swagger - Web API - Optional query parameters

[HttpGet] [Route("students")] [SwaggerOperation(Tags = new[] { "Student" })] [SwaggerResponse(HttpStatusCode.OK, Type = typeof(ResponseModel>))] [SwaggerResponseExample(HttpStatusCode.OK,…
Gopi
  • 5,656
  • 22
  • 80
  • 146
12
votes
3 answers

Swashbuckle - swagger documentation of returned response?

Swashbuckle would not generate swagger.json with an output of "UserCreateResponse", how do you fix this? [HttpPost] public async Task Update([FromBody]UserCreate Request) { UserCreateResponse response = new…
001
  • 62,807
  • 94
  • 230
  • 350
12
votes
3 answers

Generate yaml swagger using Swashbuckle

I have had no problem getting a json file in my Web API project using Microsoft's tutorial. Due to some requirement I would like to be able to retrieve a yaml file. But the problem is there is no hook I could find to make this possible. Does anyone…
Manny42
  • 588
  • 2
  • 4
  • 21
12
votes
1 answer

Swagger API not refreshing the documentation

I am using the Swagger API for documenting my REST services. Earlier my controller method didn't have the informative comments, so Swagger API was not showing up the description, but now even after updating the comments like I am not getting the…
tRuEsAtM
  • 3,517
  • 6
  • 43
  • 83
12
votes
3 answers

How to secure generated API documentation using swagger swashbuckle

I have implemented API documentation using swagger swashbukle. Now I want to publish generated documentation as a help file in my website. How to secure this link and publish?
Priyanka Mane
  • 517
  • 2
  • 9
  • 23
12
votes
6 answers

swagger UI is not showing anything in webapi

I followed this up to the xml doc part in order to create Swagger documentation using Swashbuckle. It should allow me to view the endpoints via (in my case): http://localhost:51854/swagger/ui/index Unfortunately, I cannot see any endpoints: Any…
cs0815
  • 16,751
  • 45
  • 136
  • 299
11
votes
1 answer

what is the purpose of {documentname} in the RouteTemplate config?

https://github.com/domaindrivendev/Swashbuckle.AspNetCore By default, Swagger JSON will be exposed at the following route - "/swagger/{documentName}/swagger.json". If necessary, you can change this when enabling the Swagger middleware. Custom…
red888
  • 27,709
  • 55
  • 204
  • 392
11
votes
2 answers

Swashbuckle how to add OneOf declaration to OpenAPI 3

I have a request object that can be of 2 string types "A" or "B". Note: This is a simpler example of what I really want. An enum won't work for me here. public class SampleRequest { //Can only be "A" or "B" public string…
Dave Loukola
  • 650
  • 8
  • 14
11
votes
2 answers

Swagger UI shows camelCase parameters instead of PascalCase

I am using NewtonSoft.json in Asp.Net Core 3.1 API with Swashbuckle.AspNetCore version 5.3.3. By default in Asp.Net Web API, 2 input and output parameter case was PascalCase. Now I am migrating to .Net Core API in which default case is camelCase. So…
11
votes
3 answers

ASP Net Core 2.2 add locker icon only to methods that require authorization - Swagger UI

Versions: ASP Net Core Web API - 2.2 Swashbuckle.AspNetCore - 4.0.1 What I currently have? I have implemented swagger in my Web API project. And I am using JWT authorization with [Authorize] attribute on the methods that require it. So I…
G.Dimov
  • 2,173
  • 3
  • 15
  • 40
11
votes
1 answer

How to document Swagger/Swashbuckle parameter descriptions when using [FromQuery]

My api endpoint: [HttpGet] public ActionResult GetSomeData([FromQuery] SomeDataRequest request) { return File(returnImage(), "image/png"); } public class SomeDataRequest { /// /// Description 1 ///
AngryHacker
  • 59,598
  • 102
  • 325
  • 594