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