- Java EE 8 and Angular
- Prashant Padmanabhan
- 386字
- 2021-07-02 19:22:38
Document it
The service must be well-documented for it to be useful. The Web API contract of a service can be published via documents which are manually built or generated automatically using various build tools. SOAP APIs have a WebService Description Language (WSDL) used to describe the service, but REST APIs do not have an equivalent. Given the growing popularity of REST, there are other solutions that have come up to fill this gap. A possible choice for documenting REST resources is Swagger. There is the Open API Initiative (OAI) that is working to standardize REST API documentation. The specification is based on Swagger, which defines the metadata that is used for documenting APIs.
Developers can make use of the maven Swagger plugin to generate an API document for their microservice. There are other options to generate or document your APIs, but Swagger does bring compelling features that make it an appealing choice. It potentially frees up the developer from having to update the documents manually. There are some goodies it offers, such as the ability to generate API information in a readable format that contains the REST resource name, URL, HTTP method, and request and response formats. It also generates JSON or YAML files which can be used by other tools to provide easy generation of client libraries tailored to the service.
Some good qualities to have in documentation are:
- It should be easy to generate and rely on the code itself, which is the best source of truth.
- The presentation of the document should be readable for humans and available over the web for browsing.
- Should contain samples, describing the service.
- The ability to try out a service based on its documentation can be a valuable addition.
- Separation should be maintained between what is public API and what is private API. Things which are to be used by others can be termed public API, but APIs that are internal to a service should be flagged accordingly.
- Clearly state the current and previous versions of the APIs published.
When using document generation tools, the generated documentation can itself be hosted in some source repository or Docker registry (more on this later). This allows it to be versioned and referenced by the team when required.
References:
- Swagger: http://swagger.io/
- Open API Initiative (OAI): https://www.openapis.org/
- Maven plugin: https://github.com/kongchen/swagger-maven-plugin
- PyTorch Artificial Intelligence Fundamentals
- JavaScript前端開發與實例教程(微課視頻版)
- 數據結構案例教程(C/C++版)
- C++面向對象程序設計習題解答與上機指導(第三版)
- Oracle 18c 必須掌握的新特性:管理與實戰
- OpenGL Data Visualization Cookbook
- UNIX Linux程序設計教程
- Android傳感器開發與智能設備案例實戰
- 平面設計經典案例教程:CorelDRAW X6
- ActionScript 3.0從入門到精通(視頻實戰版)
- 從程序員角度學習數據庫技術(藍橋杯軟件大賽培訓教材-Java方向)
- 網絡數據采集技術:Java網絡爬蟲實戰
- Learning C++ by Creating Games with UE4
- Ionic3與CodePush初探:支持跨平臺與熱更新的App開發技術
- Joomla!Search Engine Optimization