Posts

Showing posts with the label nswag

NSwag: Generate C# Client from multiple Versions of an API

Image
NSwag: Generate C# Client from multiple Versions of an API We are versioning our API and generating the Swagger specification using Swashbuckle in ASP.NET Core 1.1. We can generate two API docs based on those JSON specification files: <!-- language: c# --> services.AddSwaggerGen(setupAction => { setupAction.SwaggerDoc("0.1", new Info { Title = "Api", Version = "0.1", Description = "API v0.1" }); setupAction.SwaggerDoc("0.2", new Info { Title = "Api", Version = "0.2", Description = "API v0.2" }); // more configuration omitted } We are including all actions in both spec files, unless it is mapped to a specific version using the [MapToApiVersion] and ApiExplorerSettings(GroupName ="<version>")] attributes. Methods belonging to an older version only are also decorated with the [Obsolete] attribute: [MapToApiVersion] ApiExplorerSettings(GroupName ="<version>...

ASP.NET Core 2 - Angular & JWT Authentication

ASP.NET Core 2 - Angular & JWT Authentication Problem : I seem unable to fetch the User or any user-related data (e.g. UserID ) in any controller after the token has been recorded to browser local storage. User UserID I've set a breakpoint and studied HttpContext member of ControllerBase instance (the client app makes request + the auth_token is kept in local storage at this stage). HttpContext ControllerBase auth_token You only can extract the referrer url from Headers but there's no info about tokens . Headers tokens Even if you create a cookie for the token - the Request doesn't have it (0 cookies found at all). Request Perhaps I misunderstand the concept of how authorization works. Here's the bit I misunderstand most - how does ASP.NET Core fetch the token from the request made by client app - it must be kept in headers? ASP.NET Core token Also, could anyone share a working example of JWT Authentication where Angular & ASP.NET Core are separate sol...