In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains the principle and application of Swagger. The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn the principle and application of Swagger.
The OpenAPI specification is a project of the Linux Foundation that attempts to standardize the RESTful service development process by defining a language that describes the API format or API definition.
Swagger is the world's largest OpenAPI specification API development tool framework that supports development from design to documentation to testing and deployment to the entire API lifecycle. Spring Boot can integrate Swagger to generate Swagger interface.
Add an annotation of Swagger to the Java class to generate the Swagger interface.
Common Swagger comments:
@ Api: decorates the entire class, describing the role of Controller
ApiOperation: describes a method, or interface, of a class
@ ApiParam: single parameter description
@ ApiModel: use an object to receive parameters
@ ApiModelProperty: a field that describes an object when receiving parameters with an object
@ ApiResponse:HTTP responds to one of the descriptions
@ ApiResponses:HTTP response overall description
@ ApiIgnore: use this annotation to ignore this API
How Swagger interface generation works:
1. Scan the configuration class of Swagger when the system starts.
2. Specify the path of the package to be scanned in this class, and find the controller class that marks the @ RestController annotation under this package and under the subpackage
3. Generate the interface document according to the Swagger annotation in the controller class
Start the project, visit the project virtual path / swagger-ui, and view the generated project
@ ApiError: send the message returned by the error
@ ApiImplicitParam: a request parameter
@ ApiImplicitParams: multiple request parameters
Thank you for your reading, the above is the content of "the principle and Application of Swagger". After the study of this article, I believe you have a deeper understanding of the principle and application of Swagger, and the specific use needs to be verified in practice. 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.