1、 What is? Swagger
Swagger Is a specification and complete framework , Used to generate 、 describe 、 Invocation and visualization RESTful Style Web service . The overall goal is to have the client and file system update at the same speed as the server . Method of file , Parameters and models are tightly integrated into server-side code , allow API To stay in sync at all times .Swagger Let deployment management and use powerful API It's very simple .
Swagger use Open API standard ,Open API Regulate this kind of API Defining languages can help you to be simpler 、 Express quickly API, Especially in API The design phase of the project is particularly prominent . Once it's written ,API Documents can be used as :
· The basis for description of requirements and system characteristics
· Front desk and back desk 、 Discuss 、 The basis of self-test
· Part or all of the code is automatically generated based on
· Other important functions , For example, the open platform developer's Manual
2、 How to write API file
1)、 Definition YAML file , You can then generate code frameworks for various languages , For background programmers , Fewer people would like to write a bunch of YAML Format .
2)、 Definition JSON Format file , according to swagger Document writing standard writing document , and YAML The same is just two different formats .
3)、 adopt swagger Plug ins in various languages , Can be configured and a small amount of code , Generate interface document and test interface . adopt yaml or json Writing static documents , After completion, the interface document can be displayed through the visual page . But to complete the interface documentation of the whole project is also very time-consuming , If it's background development , The automatic generation of documents can be realized by simple configuration .
3、Swagger stay API Application in the project
Eolinker It is an integrated interface management tool used in our company , Including development 、 Test and documentation functions , The packaged architecture also reduces a lot of code input work . Let's use it to demonstrate and Swagger Docking .
website :www.eolilnker.comhttps://datayi.cn/w/nomk4MvR
1)、 stay Eolinker The interface is imported directly json Format Swagger file ;
2)、 Test the written interface directly ;
You can modify the parameters of a single interface directly in the details , And the content of the interface document changes in real time with the interface changes . Relative to static documents, every change needs to be developed and updated , This is undoubtedly a very good solution .
3)、 You can export multiple formats of documents ;
Sometimes external projects are connected , It's not for the other person Swagger, It can also be exported to other formats , This is my surprise point .