its easier than you would expect to create a project collection…
Postman API Feature:
you can create collection , mock servers, documentation in click of a button by using postman API definition feature.
Lets see how to do it!!
- Get the API definition:
postman supports following API definitions:
so what is API definitions ?
API definitions, or API specifications or description formats (all are the same) defines your API . It is like a live documentation on what is available, what it can do , what is supported etc . In short a comprehensive live documentation that can help consumers understand what your API can do.
- Help internal folks understand the API and agree on its attributes
- Help external folks understand the API and what it can do
- Act as live documentation on what all endpoints are available, what methods are supported, what attributes are expected etc.
Why You Should Create an API Definition and How To Do It
So you've set out to build an awesome API... great! Or you already have an API... even better!Creating a definition for…
How to get API definition ?
Most APIs visualizes the API definition using swagger UI. Which creates a user interactable representation of your API from the API definition file.
In mostcases the swagger UI will have link to the definition file or you can goto network tab and search for it
lets take https://petstore.swagger.io/ as example.
you can see the link to the definition file, it can be in yaml or json format. just click the link and copy the content.
you can see the version is swagger 2.0 meaning its open api v2
2. Create API in Postman
click API section and click the add icon or create new API link
Now give the below details:
name,version , open api v2.0 and json , and click create
Now paste the swagger definition we copied from pet store:
you can press ctrl+b to format the json properly after pasting:
3. Now Generate collection from this swagger definition:
click generate collection:
click show advanced settings:
Give the below settings:
Now click Generate collection and goto your collections once the collection generation completes
4. Mock server , documentation and other things
so the generated collection will have documentation and examples as per the API definition file provided so you don’t have to generate documentation separately!!
And for mockserver, you can directly create a mock server from the collection as the examples are already available.
5. Publishing your documentation and adding animation to your documentation
Click the collection and click view documentation , and click publish
Now you have the documentation available in public domain for your customers.
This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io)…
To unpublish follow the same procedure and click edit documentation and click unpublish
you can add gif to your documentation , to do that use :
copy the absolute url of your gif:
provide it in documentation as :
so when you click outside it will be resolved as