ColdFusion API Manager supports importing an API from Swagger. In the last article we read How To Create Manual API In ColdFusion API Manager. In this article we will see how a swagger doc can be imported to create an API.
What is Swagger?
Swagger is a specification for describing, producing, consuming, and visualizing RESTful web services. On 1 January 2016 Swagger was renamed the OpenAPI Specification
This is a sample swagger doc which is representing a petstore restful web service. It contains description of service, its endpoint, its resources etc etc. Each ‘path’ contains sub-resources and each sub-resource will further have different HTTP verbs like get,post etc.
You can read more about swagger here
Importing API from Swagger
So lets see how can we use these Swagger docs to import APIs into our API manager.
In the Create API page, click Import REST API from Swagger.
Enter the URL of the Swagger doc. In this example, use petstore’s swagger doc.
After clicking Import , the REST API is generated using this Swagger doc. Details like version, description, and so on are fetched from the Swagger doc.
In the Resources section, you can view all the resources of the Petstore Swagger doc.
To publish the API, click Publish.
Test the API.
So with simple steps we have imported an API from a swagger doc. ColdFusion APIM supports both versions of swagger – swagger 1.2 as well as swagger 2.0