swashbuckle

Restrict access to certain API controllers in Swagger using Swashbuckle and ASP.NET Identity

老子叫甜甜 提交于 2019-11-27 23:59:29
问题 So, I started using Swagger. I'm absolutely in love with it's features, but I have some doubts on availability of all methods to public. As far as I understood - all included in Swaschbuclke "auth" methods are actually about APIs itself, but I don't need help there - all of my APIs are protected by API id/key pair. I would like to somehow utilise ASP.NET Identity (login system) to restrict access to API page (/swagger/ui/index). Is there any way? Any methods in Swaschbuckle? Any routes

How to redirect from root url to /swagger/ui/index?

落花浮王杯 提交于 2019-11-27 20:46:53
问题 I have a WebApi project with Swashbuckle installed onto it. In default setup, I must open in browser http://localhost:56131/swagger/ui/index to view my operations description and test page. I want it to be accessible from root of the site: http://localhost:56131/ . How can I achieve this? 回答1: Influenced by this answer to similar question, slightly modified code: public class WebApiConfig { public static void Configure(IAppBuilder app) { var httpConfig = new HttpConfiguration(); // Attribute

swagger-ui returns 500 after deployment

妖精的绣舞 提交于 2019-11-27 19:13:10
Out of the box configuration works perfectly on my machine, no problems at all. But when I deploy to our test environment - I get the following message 500 : { "Message": "An error has occurred." } /api/swagger/docs/v1 The deployment is to default web site/api Im guessing it has something to do with the baseUrl or something like that, but I have no idea of even where to begin. My routes work fine within the project - I can call all my webapi endpoints and they respond correctly. any help would be much appreciated When debugging I was using the debug config (Which I had generated XmlComments

How to show WebApi OAuth token endpoint in Swagger

对着背影说爱祢 提交于 2019-11-27 14:42:27
问题 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

Swagger/Swashbuckle: OAuth2 with Resource Owner Password Credentials Grant

雨燕双飞 提交于 2019-11-27 11:34:39
问题 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? 回答1: 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

How to configure Swashbuckle to ignore property on model

大憨熊 提交于 2019-11-27 10:48:10
问题 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

Swagger UI Web Api documentation Present enums as strings?

扶醉桌前 提交于 2019-11-27 09:39:13
问题 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

Swashbuckle set manualy operationId, mutiple opertaions with same verb

早过忘川 提交于 2019-11-27 03:20:14
问题 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

swagger-ui returns 500 after deployment

牧云@^-^@ 提交于 2019-11-26 19:47:28
问题 Out of the box configuration works perfectly on my machine, no problems at all. But when I deploy to our test environment - I get the following message 500 : { "Message": "An error has occurred." } /api/swagger/docs/v1 The deployment is to default web site/api Im guessing it has something to do with the baseUrl or something like that, but I have no idea of even where to begin. My routes work fine within the project - I can call all my webapi endpoints and they respond correctly. any help