swashbuckle

Swashbuckle set manualy operationId

谁都会走 提交于 2019-11-29 03:57:12
I need to know if it's possible to set up custom operationid, or a naming convention, I mean I know that operation filter can be overwritten the way how operationId is generated https://azure.microsoft.com/en-us/documentation/articles/app-service-api-dotnet-swashbuckle-customize/ using Swashbuckle.Swagger; using System.Web.Http.Description; namespace Something { public class MultipleOperationsWithSameVerbFilter : IOperationFilter { public void Apply( Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription) { if (operation.parameters != null) { operation.operationId +=

Replace Swashbuckle UI completely

为君一笑 提交于 2019-11-28 23:37:14
Right now I'm developing an ASP.Net Web API and using Swashbuckle for its documentation. I know that Swashbuckle use Swagger-UI internally, I know that we can modify the layout by injecting our css or javascript file, even change the layout of index.html. I found a good themes for Swagger-UI https://github.com/jensoleg/swagger-ui and trying to implement it but can't make it works. Especially when I want to inject bootstrap.js. Is there anyway I can completely change Swashbuckle Swagger UI implementation so I can use the solution from that repo? Sure you can - in two steps. 1) Include file

How to show WebApi OAuth token endpoint in Swagger

耗尽温柔 提交于 2019-11-28 23:22:43
I've created a new Web Api project, added Asp.Net Identity and configured OAuth like so: OAuthOptions = new OAuthAuthorizationServerOptions { TokenEndpointPath = new PathString("/Token"), Provider = new ApplicationOAuthProvider(PublicClientId), AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"), AccessTokenExpireTimeSpan = TimeSpan.FromDays(14), AllowInsecureHttp = true }; This all works fine, I can call the /Token endpoint and get a bearer token back. The problem is that this is not discoverable in Swagger I assume because it's not on a controller and therefore has no xml

Swagger/Swashbuckle: OAuth2 with Resource Owner Password Credentials Grant

六月ゝ 毕业季﹏ 提交于 2019-11-28 18:56:11
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 this? How do I have to configure swagger/swashbuckle? Thank you @Dunken. Your answer almost solve my problem, but to make it work with latest Swashbuckle version I had to change it a bit like this $('#explore').off(); $('#explore').click(function () { var key = $('#input_apiKey')[0].value; var credentials = key.split(':'); //username:password

How to configure Swashbuckle to ignore property on model

二次信任 提交于 2019-11-28 18:16:28
I'm using Swashbuckle to generate swagger documentation\UI for a webapi2 project. Our models are shared with some legacy interfaces so there are a couple of properties I want to ignore on the models. I can't use JsonIgnore attribute because the legacy interfaces also need to serialize to JSON so I don't want to ignore the properties globally, just in the Swashbuckle configuration. I found a method of doing this documented here: https://github.com/domaindrivendev/Swashbuckle/issues/73 But this appears to be out of date with the current Swashbuckle release. The method recommended for the old

Swagger UI Web Api documentation Present enums as strings?

心不动则不痛 提交于 2019-11-28 16:37:57
Is there a way to display all enums as their string value in swagger instead of their int value? I want to be able to submit POST actions and put enums according to their string value without having to look at the enum every time. I tried DescribeAllEnumsAsStrings but the server then receives strings instead of the enum value which is not what we're looking for. Has anyone solved this? Edit: public class Letter { [Required] public string Content {get; set;} [Required] [EnumDataType(typeof(Priority))] public Priority Priority {get; set;} } public class LettersController : ApiController {

Swashbuckle Swagger - How to annotate content types?

社会主义新天地 提交于 2019-11-28 09:50:25
How do I annotate my ASP.NET WebAPI actions so that the swagger metadata includes the content-types that my resources support? Specifically, I want the documentation to show that one of my resources can return the 'original' application/json and application/xml but also now returns a new format, application/vnd.blah+json or +xml . What you need to do is this; Swagger spec: you need to add your response-type to the list of response-types for that operation "produces": [ "application/json", "text/json" ], This can be done with an OperationFilter Pseudo Code incoming!!! public class

Add individual custom headers in different controllers in web api using Swasbuckle

强颜欢笑 提交于 2019-11-28 09:38:21
问题 How can I add individual headers on different controllers. E.g.: Controller Name: Controller1, Custom header: Header1 Controller Name: Controller2, Custom header: Header2 The headers should be displayed for all the apis under the specific controller 回答1: This can be solved by adding an OperationFilter to your swagger configuration. First you have to provide a class that implements IOperationFilter . The Apply method receives an Operation parameter which contains the controller name in the tag

Data annotations in Swagger

試著忘記壹切 提交于 2019-11-28 02:34:37
问题 I am using ASP.NET and Swagger that exposes a complex type that accepts a POST. It has a number of string fields that have different restricted lengths. How can I reflect that in the Swagger UI? 回答1: You can annotate the properties with the StringLengthAttribute from System.ComponentModel.DataAnnotations . For instance: [StringLength(10)] public String Name {get;set;} will become: "name": { "minLength": 0, "maxLength": 10, "type": "string" } And this: [StringLength(10, MinimumLength = 5)]

SwashBuckle/Swagger - OAuth Resource Owner Password Flow

有些话、适合烂在心里 提交于 2019-11-28 00:49:19
问题 I'm trying to implement swagger into my Asp.Net Web API, and i'm running into a problem. I'm using the password resource owner flow, and i'm having to add a work around in order to do this, which is covered in the following stack overflow question :- Swagger/Swashbuckle: OAuth2 with Resource Owner Password Credentials Grant I've got everything working, the Bearer token is added via javascript to the request header in the current browser window, but the api calls to the controller methods