Professional Documents
Culture Documents
Swagger
Swagger
Swagger
What is swagger
Swagger is a open source API documentation framework that helps developers in design,
document, and consume RESTful web services
Swagger reads an API and extract in the form of interactive UI called as Swagger UI
Swagger UI offers HTML view of API with JSON support so that we can directly test our API
It is one of most popular tools for generating interactive documentation from API
It is most widely adopted API documentation framework and it is especially standardized for
REST API services
Huge community for support
It drastically reduce the understanding curve for an API with various automation features
The OpenAPI Specification (OAS) defines a standard, language-agnostic interface to RESTful APIs which
allows both humans and computers to discover and understand the capabilities of the service without
access to source code, documentation, or through network traffic inspection. When properly defined, a
consumer can understand and interact with the remote service with a minimal amount of
implementation logic.
An OpenAPI definition can then be used by documentation generation tools to display the API, code
generation tools to generate servers and clients in various programming languages, testing tools, and
many other use cases.
Swagger Hub: SwaggerHub brings together all of the open source Swagger tooling into one easy-to-use
platform in the cloud. With SwaggerHub, you don’t need to download any additional tools to design,
document, or build your API, although we do offer integrations to other platforms to sync and deploy
your API. SwaggerHub also allows you to save and backup your API in the cloud.
Responses:
Describing Responses
An API specification needs to specify the responses for all API operations. Each operation
must have at least one response defined, usually a successful response. A response is
defined by its HTTP status code and the data returned in the response body and/or
headers. Here is a minimal example:
Note that an API specification does not necessarily need to cover all possible HTTP response
codes, since they may not be known in advance. However, it is expected to cover successful
responses and any known errors. By “known errors” we mean, for example, a 404 Not
Found response for an operation that returns a resource by ID, or a 400 Bad Request
response in case of invalid operation parameters.
Response Body
The schema keyword is used to describe the response body. A schema can define: