In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
 
            
                     
                
2025-10-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how Swagger accesses API with permission verification in Ocelot". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how Swagger accesses API with permission verification in Ocelot".
Highlight the source code first: https://github.com/axzxs2001/Asp.NetCoreExperiment/tree/master/Asp.NetCoreExperiment/SwaggerDemo
This post is not an introduction to the use of Swagger in asp.net core, as the community blog explains it in detail.
Today, we will mainly talk about the access of Swagger in Ocelot gateway permission verification mode and the data format of Swagger request and reply.
Start by creating four projects:
SwaggerOcelot:asp.net core web api type, api gateway project
SwaggerAuthorize:asp.net core web api type, user authentication project
SwaggerAPI01:asp.net core web api type, api 1 project
SWaggerAPI02:asp.net core web api type, api 2 project
First add Jwt-based Toekn certification to the four projects, see https://www.cnblogs.com/axzxs2001/p/9250588.html
Then introduce Swashbuckle.AspNetCore into the four project Nuget. My Demo uses 2.5.0, and then configure Swagger separately.
SwaggerAuthorize Starup.cs configuration
 
SwaggerAPI01,SwaggerAPI02 is similar to Starup.cs configuration, in which Swagger pays Token verification to add Swagger configuration in this part.
 
SwaggerOcelot,Starup.cs configuration
Next, access the Web API project for Swagger and add the request return format. By default, Swagger supports Json. Next, add support for XML format.
First step, add support for XML format
The second step is to add the ProducesResponseType feature to the corresponding Action to support the conversion
Running effect:
Let's look at login first.
Let's take a look at api access
Thank you for your reading, the above is the content of "how Swagger accesses API with permission verification in Ocelot". After the study of this article, I believe you have a deeper understanding of how Swagger accesses API with authority verification in Ocelot. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about

The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r


A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from

Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





 
             
            About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.