. Net WEBAPI Swagger Add login functionality

Source: Internet
Author: User

This article copyright belongs to the blog park and the author Wu Di I common all reprint and crawler please specify the original address Www.cnblogs.com/tdws

write in front

Recall last year two essays to share, in the work or have a certain reference to their own, each need to swagger, can not remember how to modify and optimize before, fortunately, can look back. But to see their own title, or feel blush, what is the skin thick, up to such two headings.

. Net WebApi Swagger Interface document mid-degree optimization

. Net WebApi Swagger Interface Document Depth optimization

Today, I suddenly see a new comment before the article, think of swagger, this article on the record, the first few weeks by modifying the source code to add Swagger login function, in order to facilitate the authorization token put into the authorization header, To enter the authorize action through authentication.

Start modifying

On the page is relatively simple, in JS can be append into a div, just like the right landing box, do good looking and bad look on their own.

Or first look at the swagger front-end source of the structure, the outside of the two JS are more than 30,000 lines, it seems very anxious ah, like a few days can not find the code, so you can only search some key words, ajax,xmlhttprequest, toss, finally found the request backstage position.

Probably in the swagger-ui-ext.js of 30744 rows or so, find the location is very simple, the token in the Requestheader in a put on the line. The rest of the content is your own login code. That's it.

. Net WEBAPI Swagger Add login functionality

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.