Add Swagger in ASP .NET Core 5 | Enable Token Bearer functionality in Swagger

preview_player
Показать описание
Step by Step tutorial to add Swagger in .NET Core 5 with Token bearer authentication

Swagger UI offers a web-based UI that provides information about the service, using the generated OpenAPI specification. Both Swashbuckle include an embedded version of Swagger UI, so that it can be hosted in your ASP.NET Core app using a middleware registration call. The web UI looks like this:

Swagger (OpenAPI) is a language-agnostic specification for describing REST APIs. It allows both computers and humans to understand the capabilities of a REST API without direct access to the source code. Its main goals are to:

- Swagger is Library which is used for API testing.
- Minimize the amount of work needed to connect decoupled services.
- Reduce the amount of time needed to accurately document a service.
- Swagger is a standard way to provide specifications for endpoints
- Helpful for Automation Testing

There are three main components to Swashbuckle:

Swashbuckle.AspNetCore.Swagger:
a Swagger object model and middleware to expose SwaggerDocument objects as JSON endpoints.

Swashbuckle.AspNetCore.SwaggerGen:
a Swagger generator that builds SwaggerDocument objects directly from your routes, controllers, and models. It's typically combined with the Swagger endpoint middleware to automatically expose Swagger JSON.

Swashbuckle.AspNetCore.SwaggerUI:
an embedded version of the Swagger UI tool. It interprets Swagger JSON to build a rich, customizable experience for describing the web API functionality. It includes built-in test harnesses for the public methods.

Part 1
ASP .NET Core 5 Web API step by step & Integrate in Angular 11 | Secure API with JWT Token video link is given below

Part 2
ASP .NET Core 5 Web API - Role based Authorization with Angular, Video link given below

Part 3
ASP .NET Core 5 Web API - Role based Authorization with Angular | User with multiples Roles

Part 4
Angular | .NET Core 5 | show spinner on background task | how to show spinner in Angular

#Swagger #netcore5 #Swashbuckle
Рекомендации по теме
Комментарии
Автор

Not exactly what a wanted, but it was very helpful.
Thank you very much sr :)

OTadashi
Автор

Good quality, all things were explained very well

kuba
Автор

Informative video for computer students

zumarmalik
Автор

V informative video thanks for sharing this

khatamitha
Автор

Thanks you explained all the necessary development points! Will Token bearer authenticate only with the Swagger UI, or any api call, like Postman?

surbhiagarwal
Автор

How to make fields mandatory under Authorization in swagger view

sabithathota
Автор

Alguém sabe se tem alguma forma de configurar assim no java? Tipo sem precisar ficar digitando 'Bearer' antes do token
????

elisonaguia
Автор

provided username password from azure ad?

tushar
Автор

but i am able to fetch records without giving token . plzz help me

Muhammadyaseen-hxej
Автор

Delete endpoint

[Authorize(Roles = "Admin")]
[HttpDelete("DeleteUser")]
public async Task<object> DeleteUser([FromBody] string id)
{
try
{
if(id == null)
{
return await Task.FromResult(new ResponseModel(ResponseCode.Error, "Parameters are missing", null));
}

var user = await => x.Id == id);
var result = await

if(result.Succeeded)
{
return await Task.FromResult(new ResponseModel(ResponseCode.OK, "User deleted successfully", user));
}

return await Task.FromResult(new ResponseModel(ResponseCode.Error, "bir şeyler ters gitti lütfen daha sonra tekrar deneyin.", null));
}
catch (Exception ex)
{

return await Task.FromResult(new ResponseModel(ResponseCode.Error, ex.Message, null));
}

}




the id value comes from the string. how can we do this in a way that is int. Why do I want int value. I also want Angular to have an int value to display the user's id value in the User table. How can I do this?

gazihatas