Questions tagged [swagger-net]

Swagger-Net seamlessly add Swagger to WebApi projects! Combines ApiExplorer and Swagger/swagger-ui(3.x) to provide a rich discovery, documentation and playground experience to your API consumers.

In addition to its Swagger generator, the Swagger-UI is embedded and will automatically serve up once Swagger-Net is installed. This means you can complement your API with a slick discovery UI to assist consumers with their integration efforts.

Swagger-Net Features:

  • Latest and greatest of all dependencies
  • High UnitTest CodeCoverage (99%)
  • Auto-generated Swagger 2.0
  • Seamless integration of swagger-ui (3.x)
  • Reflection-based Schema generation for describing API types
  • Extensibility hooks for customizing the generated Swagger doc and swagger-ui
  • Out-of-the-box support for Xml comments

This tag should be used for questions about:

  • Configuring Swagger-Net
  • Extending Swagger-Net with the provided interfaces
  • Customizing the embedded Swagger-UI

Source code: https://github.com/heldersepu/swagger-net

17 questions
2
votes
0 answers

BasicAuthentication & ApiAuthentication per method in Swagger-Net in .Net MVC 4

As shown in https://petstore.swagger.io/, apis of the PET controller get authenticated by OAuth2, but that of the STORE controller, gets authenticated by ApiKey. I want to achieve the same using IOperationFilter in .Net MVC (and not .Net…
1
vote
0 answers

Swagger-Net Display Request Duration

I'm using Swagger-Net to be able to get Swagger documentation to my API without much hassle. It's going well, but I'm trying to configure it to display execution runtime of my API methods and I'm unable to do it. I've seen a DisplayRequestDuration()…
CMPerez
  • 905
  • 1
  • 10
  • 25
1
vote
1 answer

How to change Swagger-Net root url from "/swagger" to root?

I"m using swagger-net. By default, the swagger UI will be "/swagger", how do I change it to root? Feel like what I'm doing now is a hack public class HomeController : Controller { public ActionResult Index() { return…
JeeShen Lee
  • 3,476
  • 5
  • 39
  • 59
1
vote
1 answer

docs works but ui doesn't have routing?

I'm running my api as an application within a site in IIS. The site's url is "http://api.companyName.local/" and the api's url is "http://api.companyName.local/api". I've got Swagger-Net set up enough that…
zlangner
  • 249
  • 2
  • 7
1
vote
0 answers

Swagger-Net and Bearer Token Authorization

We are using Swagger-Net with Bearer Token Authorization as follows: c.ApiKey("Authorization", "header", "Bearer Token Authentication"); The request needs to be sent in the format "Bearer [bearertoken]", and I have verified this does work correctly…
Patrick
  • 5,526
  • 14
  • 64
  • 101
1
vote
0 answers

Swagger-net breaks when using [FromUri] with a complex EF model

I'm using Swagger-Net in my .NET 4.5.1 WebAPI project and one of my API calls is causing the Swagger UI to spin forever on load before coming back with the error below. Specifically, I found that using [FromUri] in combination with a complex EF…
CodeCheshire
  • 710
  • 1
  • 8
  • 27
0
votes
0 answers

How to rename the generated client SDK project by modifying the input json

I am using the https://editor.swagger.io/ to generate SDK. When I generate the SDK by selecting Generate Client -> CSharp, the SDK project is generated. But the problem is, I could not modify the project-name and namespaces. It by default gives the…
0
votes
1 answer

Swagger with vendor extension at API/controller level

I got an Asp.Net web api project with some controllers, enabled swagger doc with swagger-Net. I have been searching for how to enable vendor extensions or custom swagger doc fields which I can set for each API level. I'm successful at settting…
Afsal
  • 131
  • 6
0
votes
0 answers

.NET Core doesn't return OData metadata in Responses on Swagger

I'm using swagger in order to generate the endpoints for my React app. In order to do that, I need to specify the response objects for my endpoints and one of my endpoints that has [EnableQuery] annotation, which means is an OData endpoint placed…
anthino12
  • 770
  • 1
  • 6
  • 29
0
votes
1 answer

Provide a complex object for a SwaggerExample?

We're using Swagger.Net package to help with our documentation. I'm trying to add request data to be auto-generated into my documentation and was looking at this answer that provides this code block: [SwaggerExample("id", "123456")] public…
LarsTech
  • 80,625
  • 14
  • 153
  • 225
0
votes
0 answers

Swagger show hint for conditionally required nullable field

I need to show in Swagger "nullable: true" where one field of request body is nullable and required conditionally. I've tried following annotation. but doesn't help [RequiredIfAttribute( "IdentificationType", IdentificationType.GROUP_MEMBER…
Emin Hasanov
  • 1,299
  • 1
  • 13
  • 29
0
votes
0 answers

Show fields with null ONLY in Swagger Response

I am using Swagger-Net 8.43.* in .Net 4.8 Web Api Is it possible to show null values in response body (not in Example value) only in Swagger UI without changing SerializerSettings for whole Api? Now I have registered…
Emin Hasanov
  • 1,299
  • 1
  • 13
  • 29
0
votes
1 answer

In Swagger.Net UI, how can I remove the padlock icon from “Anonymous” methods?

I found a similar thread here but that is for .Net Core. I have the same issue with Swagger.Net API(.Net Framework). I am using Swagger.Net API version 8.3.35.101 with .Net framework 4.6.1 and I am getting a lock icon for each and every method in…
prem
  • 3,348
  • 1
  • 25
  • 57
0
votes
1 answer

Why is a Required * path parameter {namespace} getting detected by Swagger?

My .Net MVC project has the below ApiController: But the Swagger UI generates two methods: Observe that the ActionName TestMethod1 is omitted(probably because there is only one HttpGet in this controller)
0
votes
1 answer

Swagger UI Response Example Asp.Net Core Web Api

I'm using Swagger.AspNetCore to document my api. So far i was happy to use xml comments to generate response model examples until i reach the point when i've got to document embeded object. So i have simple model: public class SummaryResult { …
neten
  • 1
  • 1
1
2