How it works
Created by SmartBear Software, Swagger originated as the initial API description format in 2011. In 2015, SmartBear donated the specification format to the Linux Foundation, renaming it the OpenAPI Specification. Today, 'Swagger' refers specifically to the toolset used to render interactive documentation, edit specifications, and generate client/server code stubs.
Example
HTML
<!-- Embedding Swagger UI in HTML -->
<div id="swagger-ui"></div>
<script src="https://unpkg.com/swagger-ui-dist/swagger-ui-bundle.js"></script>
<script>
SwaggerUIBundle({
url: "https://api.example.com/openapi.json",
dom_id: '#swagger-ui'
});
</script>Common mistakes
- Using 'Swagger' to refer to OpenAPI 3.1 specifications
- Assuming Swagger UI performs full server-side schema validation