swashbuckle

Swashbuckle Hide unreferenced model

时光毁灭记忆、已成空白 提交于 2020-04-11 08:48:07
问题 I'm having a problem with Swashbuckle when hiding a call the definition of the model linked to the call remains in the definition in the JSON generated. Using the Document filter, I'm able to remove the call from the interface. The calls remain in the JSON generated but are invisible in Swagger UI. We can also see the definition for the Model and Enum linked to theses calls. Theses are internal calls and need to be hidden from external eyes in the JSON. How can I hide all the calls and their

Swagger (Swashbuckle for C#) shows Mongo ObjectId as several fields instead of single string

人走茶凉 提交于 2020-03-03 07:29:31
问题 I have controller method with ObjectId params: [ProducesResponseType(200, Type = typeof(Test))] [HttpGet] [Route("{id}")] public IActionResult Get(ObjectId id) {... For this API method swagger generates a form with both of complex ObjectId model and string Id instead of single string param: How I can remove extra fields and keep only string Id? 回答1: Find out what answer from another story also adresses this issue: services.AddMvc(options => { ... options.ModelMetadataDetailsProviders.Add( new

How do I set “Parameter content type” using Swashbuckle?

最后都变了- 提交于 2020-03-01 01:37:12
问题 My swagger ui shows "Parameter content type" with various entries: "application/json-patch+json" , "text/json" , "application/json" , and "application/*+json" . I only want "application/json" . There's a similar unsolved issue on the repo, which uses this visual (older ui, but same idea): Is there some way to set this? Swashbuckle.AspNetCore version 4.0.1 Swashbuckle.AspNetCore.Filters version 4.5.5 回答1: Use the [Produces] and [Consumes] attributes. Swashbuckle (and others, like NSwag) will

How can i specify the default opening version of swagger?

岁酱吖の 提交于 2020-02-16 05:27:51
问题 I have a C# web API that is using Swagger as API documentation. I have used the Swashbuckle packages. The swagger environment is working with multiple versions that i specify in the controllers. Today i introduced a new future version (1.2) that is still under development. I would like to open swagger on the version 1.1 version by default but still keep the correct sorting order in the dropdown in the top right (e.g. v1, v1.1, v1.2). Currently it always opens the top version in the drop down.

How do you add a swagger comment to the “Request and Response Model”?

≡放荡痞女 提交于 2020-02-02 06:28:27
问题 You can add a comment on the methods like the example below but what about adding comments to the request and response model? /// <summary> /// my summary /// </summary> /// <remarks> /// remark goes here. /// </remarks> /// <param name="somepara">Required parameter: Example: </param> /// <return>Returns comment</return> /// <response code="200">Ok</response> 回答1: Yes just like Dimitar said, you can add comments to the responses with SwaggerResponse , the request is a bit different, just like

How do you add a swagger comment to the “Request and Response Model”?

本小妞迷上赌 提交于 2020-02-02 06:26:22
问题 You can add a comment on the methods like the example below but what about adding comments to the request and response model? /// <summary> /// my summary /// </summary> /// <remarks> /// remark goes here. /// </remarks> /// <param name="somepara">Required parameter: Example: </param> /// <return>Returns comment</return> /// <response code="200">Ok</response> 回答1: Yes just like Dimitar said, you can add comments to the responses with SwaggerResponse , the request is a bit different, just like

Swagger UI ignoring x-tokenName extension

有些话、适合烂在心里 提交于 2020-01-25 06:13:08
问题 Im using Swashbuckle v5.0.0 in a .net-core 2.1 application to generate my api-documentation. I've added this security definition: cfg.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme { Name = "oauth2", Type = SecuritySchemeType.OAuth2, Scheme = IdentityServerAuthenticationDefaults.AuthenticationScheme, Extensions = new Dictionary<string, IOpenApiExtension> { { "x-tokenName", new OpenApiString("token id_token") } }, Flows = new OpenApiOAuthFlows() { Implicit = new OpenApiOAuthFlow() {

Swashbuckle C# swagger plugin how to use my own personal swagger.json by default instead of relying on one it generates?

守給你的承諾、 提交于 2020-01-23 17:13:11
问题 I ran into an issue on a project I am on where for various reasons we were unable to rely on swashbuckle to generate the swagger.json we needed for the project and had to write it ourselves by hand. I have been searching all over the place but have been unable to figure out how to configure it so that when people type /swagger in the home url, it defaults to my swagger.json file instead of the one auto-generated by swashbuckle that will not work for us. Users are forced to manually change to

Customize generated model names - Swagger UI

孤街浪徒 提交于 2020-01-23 05:51:12
问题 I'm trying to adjust the "displayName" of the model being used in an automatically generated Swagger definition. This will only affect the Swagger names, meaning the namespace in code would be left untouched, whilst when looking at the model from Swagger UI, you'd see a custom name. Currently, the model name being returned from code is a namespace and looks something like this: b.c.d.e.f , I would like to add an attribute to the code and "mask" the name for the Swagger docs, so that when the

Enable bearer token in Swashbuckle (Swagger document)

北城以北 提交于 2020-01-22 04:35:51
问题 I created an asp.net webapi application which is using Individual Account Security so that the Bearer token is enabled by default. It's working fine so that I am able to test them in Postman without problem. Here comes the question when I'm trying to integrate the Swagger UI by Swashbuckle. I installed the Swashbuckle by: Install-Package Swashbuckle Then change the SwaggerConfig.cs : GlobalConfiguration.Configuration .EnableSwagger(c => { c.ApiKey("Token") .Description("Filling bearer token