Postman Collections
Follow this tutorial if:
- You don't have an OpenAPI Spec (OAS)
- You are using Postman Collections
The output of konfig p2o
is low quality and should not be used to publish
SDKs. To ensure Konfig can generate high quality SDKs you must make sure
your OAS passes Konfig's linter. Follow directions on how to run Konfig's
linter here and quickly fix your
OAS
1. Save Example Responses in Postman
Example responses are needed for automatically generating OpenAPI schemas with konfig fix. Do the following 4 steps for all your endpoints before exporting.
The more examples your provide the better quality your OpenAPI Specification
will be. Especially if you are running the output through konfig fix
as we
use the examples to determine your schemas.
a) Send Request
Click Send
to retrieve an example response. You can do repeat these steps for diferent inputs to save multiple example responses.
b) Click "Save Response"
Open the menu for saving the response.
c) Click "Save as example"
Save the retrieved response as an example in your collection.
d) Example should be shown in menu
You should see a list of examples saved in the left-side menu.
2. Export Postman Collection to JSON
Click the settings for the target Postman Collection and click "export":
Choose Collection v2.1
and click Export
.
3. Setup Konfig CLI
Ensure you have the konfig-cli
installed by running
_10npm install -g konfig-cli
4. Convert Exported Postman Collection to OpenAPI Spec
Once you have exported your collection to a .json
file you can not convert it to an OAS .yaml
file.
To do this simply run:
_10konfig p2o -p <path_to_your_exported_postman_collection>.json -o oas.yaml
You will see an output that looks something like this:
Example Output
_55openapi: 3.0.0_55info:_55 title: Slack Web API_55 version: 1.0.0_55servers:_55 - url: http://{{baseurl}}_55components:_55 securitySchemes:_55 bearerAuth:_55 type: http_55 scheme: bearer_55security:_55 - bearerAuth: []_55tags:_55 - name: Admin API_55 description: >-_55 Use approval and provisioning APIs to help Slack Admins work more_55 effectively._55# ... unnecessary details omitted_55paths:_55 /admin.users.setOwner:_55 post:_55 tags:_55 - Admin API_55 summary: admin users set Owner_55 description: >-_55 Set an existing guest, regular user, or admin user to be a workspace_55 owner._55 requestBody:_55 content:_55 application/x-www-form-urlencoded:_55 schema:_55 type: object_55 properties:_55 team_id:_55 type: string_55 description: The ID (`T1234`) of the workspace._55 example: <string>_55 user_id:_55 type: string_55 description: Id of the user to promote to owner._55 example: <string>_55 parameters:_55 - name: token_55 in: header_55 schema:_55 type: string_55 description: "(Required) Authentication token. Requires scope: `admin.users:write`"_55 example: <string>_55 - name: Content-Type_55 in: header_55 schema:_55 type: string_55 example: application/x-www-form-urlencoded_55# ... unnecessary details omitted