joolfe / postman-to-openapi

🛸 Convert postman collection to OpenAPI
MIT License
577 stars 99 forks source link

feat: adding support for server variables #242

Closed erunion closed 1 year ago

erunion commented 1 year ago

👋 Hello! We're going to be integrating this library into our product soon to allow customers to upload Postman collections to us and I noticed an issue where if I import the OpenAPI Petstore example into Postman and then export it out the global server gets set to a baseUrl variable in Postman but that variable never received its default of http://petstore.swagger.io/v2.

After digging into it I found that this library currently did not support server variables.

🧰 Changes


📝 OpenAPI Petstore -> Postman export example ```json { "info": { "_postman_id": "0b2e8577-2899-4229-bb1c-4cb031108c2f", "name": "Swagger Petstore", "description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.\n\nContact Support:\n Email: apiteam@swagger.io", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "item": [ { "name": "pet", "item": [ { "name": "{pet Id}", "item": [ { "name": "Find pet by ID", "request": { "auth": { "type": "apikey", "apikey": [ { "key": "key", "value": "api_key", "type": "string" }, { "key": "value", "value": "", "type": "string" }, { "key": "in", "value": "header", "type": "string" } ] }, "method": "GET", "header": [ { "key": "Accept", "value": "application/xml" } ], "url": { "raw": "{{baseUrl}}/pet/:petId", "host": ["{{baseUrl}}"], "path": ["pet", ":petId"], "variable": [ { "key": "petId", "value": "-53776022", "description": "(Required) ID of pet to return" } ] }, "description": "Returns a single pet" }, "response": [ { "name": "successful operation", "originalRequest": { "method": "GET", "header": [ { "description": "Added as a part of security scheme: apikey", "key": "api_key", "value": "" } ], "url": { "raw": "{{baseUrl}}/pet/:petId", "host": ["{{baseUrl}}"], "path": ["pet", ":petId"], "variable": [ { "key": "petId", "value": "-53776022", "description": "(Required) ID of pet to return" } ] } }, "status": "OK", "code": 200, "_postman_previewlanguage": "json", "header": [ { "key": "Content-Type", "value": "application/json" } ], "cookie": [], "body": "{\n \"name\": \"doggie\",\n \"photoUrls\": [\n \"https://example.com/photo.png\",\n \"https://example.com/photo.png\"\n ],\n \"id\": 25,\n \"category\": {\n \"id\": -66648423,\n \"name\": \"sint proident voluptate nostrud\"\n },\n \"tags\": [\n {\n \"id\": -36713801,\n \"name\": \"cupidatat laboris\"\n },\n {\n \"id\": 88956444,\n \"name\": \"sed\"\n }\n ],\n \"status\": \"available\"\n}" }, { "name": "Invalid ID supplied", "originalRequest": { "method": "GET", "header": [ { "description": "Added as a part of security scheme: apikey", "key": "api_key", "value": "" } ], "url": { "raw": "{{baseUrl}}/pet/:petId", "host": ["{{baseUrl}}"], "path": ["pet", ":petId"], "variable": [ { "key": "petId", "value": "-53776022", "description": "(Required) ID of pet to return" } ] } }, "status": "Bad Request", "code": 400, "_postman_previewlanguage": "text", "header": [ { "key": "Content-Type", "value": "text/plain" } ], "cookie": [], "body": "" }, { "name": "Pet not found", "originalRequest": { "method": "GET", "header": [ { "description": "Added as a part of security scheme: apikey", "key": "api_key", "value": "" } ], "url": { "raw": "{{baseUrl}}/pet/:petId", "host": ["{{baseUrl}}"], "path": ["pet", ":petId"], "variable": [ { "key": "petId", "value": "-53776022", "description": "(Required) ID of pet to return" } ] } }, "status": "Not Found", "code": 404, "_postman_previewlanguage": "text", "header": [ { "key": "Content-Type", "value": "text/plain" } ], "cookie": [], "body": "" }, { "name": "successful response", "originalRequest": { "method": "GET", "header": [ { "description": "Added as a part of security scheme: apikey", "key": "api_key", "value": "" } ], "url": { "raw": "{{baseUrl}}/pet/:petId", "host": ["{{baseUrl}}"], "path": ["pet", ":petId"], "variable": [ { "key": "petId", "value": "-53776022", "description": "(Required) ID of pet to return" } ] } }, "status": "Internal Server Error", "code": 500, "_postman_previewlanguage": "text", "header": [ { "key": "Content-Type", "value": "text/plain" } ], "cookie": [], "body": "" } ] }, { "name": "Updates a pet in the store with form data", "request": { "auth": { "type": "oauth2", "oauth2": [ { "key": "scope", "value": "write:pets read:pets", "type": "string" }, { "key": "authUrl", "value": "http://petstore.swagger.io/oauth/dialog", "type": "string" }, { "key": "grant_type", "value": "implicit", "type": "string" } ] }, "method": "POST", "header": [ { "key": "Content-Type", "value": "application/x-www-form-urlencoded" } ], "body": { "mode": "urlencoded", "urlencoded": [ { "key": "name", "value": "dolore magna", "description": "Updated name of the pet" }, { "key": "status", "value": "et incididunt", "description": "Updated status of the pet" } ] }, "url": { "raw": "{{baseUrl}}/pet/:petId", "host": ["{{baseUrl}}"], "path": ["pet", ":petId"], "variable": [ { "key": "petId", "value": "-53776022", "description": "(Required) ID of pet that needs to be updated" } ] } }, "response": [ { "name": "Invalid input", "originalRequest": { "method": "POST", "header": [ { "description": "Added as a part of security scheme: oauth2", "key": "Authorization", "value": "" } ], "body": { "mode": "urlencoded", "urlencoded": [ { "key": "name", "value": "dolore magna", "description": "Updated name of the pet" }, { "key": "status", "value": "et incididunt", "description": "Updated status of the pet" } ] }, "url": { "raw": "{{baseUrl}}/pet/:petId", "host": ["{{baseUrl}}"], "path": ["pet", ":petId"], "variable": [ { "key": "petId", "value": "-53776022", "description": "(Required) ID of pet that needs to be updated" } ] } }, "status": "Method Not Allowed", "code": 405, "_postman_previewlanguage": "text", "header": [ { "key": "Content-Type", "value": "text/plain" } ], "cookie": [], "body": "" } ] }, { "name": "Deletes a pet", "request": { "auth": { "type": "oauth2", "oauth2": [ { "key": "scope", "value": "write:pets read:pets", "type": "string" }, { "key": "authUrl", "value": "http://petstore.swagger.io/oauth/dialog", "type": "string" }, { "key": "grant_type", "value": "implicit", "type": "string" } ] }, "method": "DELETE", "header": [ { "key": "api_key", "value": "dolore est" } ], "url": { "raw": "{{baseUrl}}/pet/:petId", "host": ["{{baseUrl}}"], "path": ["pet", ":petId"], "variable": [ { "key": "petId", "value": "-53776022", "description": "(Required) Pet id to delete" } ] } }, "response": [ { "name": "Invalid ID supplied", "originalRequest": { "method": "DELETE", "header": [ { "description": "Added as a part of security scheme: oauth2", "key": "Authorization", "value": "" }, { "key": "api_key", "value": "dolore est" } ], "url": { "raw": "{{baseUrl}}/pet/:petId", "host": ["{{baseUrl}}"], "path": ["pet", ":petId"], "variable": [ { "key": "petId", "value": "-53776022", "description": "(Required) Pet id to delete" } ] } }, "status": "Bad Request", "code": 400, "_postman_previewlanguage": "text", "header": [ { "key": "Content-Type", "value": "text/plain" } ], "cookie": [], "body": "" }, { "name": "Pet not found", "originalRequest": { "method": "DELETE", "header": [ { "description": "Added as a part of security scheme: oauth2", "key": "Authorization", "value": "" }, { "key": "api_key", "value": "dolore est" } ], "url": { "raw": "{{baseUrl}}/pet/:petId", "host": ["{{baseUrl}}"], "path": ["pet", ":petId"], "variable": [ { "key": "petId", "value": "-53776022", "description": "(Required) Pet id to delete" } ] } }, "status": "Not Found", "code": 404, "_postman_previewlanguage": "text", "header": [ { "key": "Content-Type", "value": "text/plain" } ], "cookie": [], "body": "" } ] }, { "name": "Uploads an image", "request": { "auth": { "type": "oauth2", "oauth2": [ { "key": "scope", "value": "write:pets read:pets", "type": "string" }, { "key": "authUrl", "value": "http://petstore.swagger.io/oauth/dialog", "type": "string" }, { "key": "grant_type", "value": "implicit", "type": "string" } ] }, "method": "POST", "header": [ { "key": "Content-Type", "value": "multipart/form-data" }, { "key": "Accept", "value": "application/json" } ], "body": { "mode": "formdata", "formdata": [ { "key": "additionalMetadata", "value": "voluptate cillum", "description": "Additional data to pass to server", "type": "text" }, { "key": "file", "description": "file to upload", "type": "file", "src": [] } ] }, "url": { "raw": "{{baseUrl}}/pet/:petId/uploadImage", "host": ["{{baseUrl}}"], "path": ["pet", ":petId", "uploadImage"], "variable": [ { "key": "petId", "value": "-53776022", "description": "(Required) ID of pet to update" } ] } }, "response": [ { "name": "successful operation", "originalRequest": { "method": "POST", "header": [ { "description": "Added as a part of security scheme: oauth2", "key": "Authorization", "value": "" } ], "body": { "mode": "formdata", "formdata": [ { "key": "additionalMetadata", "value": "voluptate cillum", "description": "Additional data to pass to server", "type": "text" }, { "key": "file", "description": "file to upload", "type": "file", "src": [] } ] }, "url": { "raw": "{{baseUrl}}/pet/:petId/uploadImage", "host": ["{{baseUrl}}"], "path": ["pet", ":petId", "uploadImage"], "variable": [ { "key": "petId", "value": "-53776022", "description": "(Required) ID of pet to update" } ] } }, "status": "OK", "code": 200, "_postman_previewlanguage": "json", "header": [ { "key": "Content-Type", "value": "application/json" } ], "cookie": [], "body": "{\n \"code\": -15164975,\n \"type\": \"Excepteur\",\n \"message\": \"ut Lorem dolor officia incididunt\"\n}" } ] } ] }, { "name": "Add a new pet to the store", "request": { "auth": { "type": "oauth2", "oauth2": [ { "key": "scope", "value": "write:pets read:pets", "type": "string" }, { "key": "authUrl", "value": "http://petstore.swagger.io/oauth/dialog", "type": "string" }, { "key": "grant_type", "value": "implicit", "type": "string" } ] }, "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "{\n \"name\": \"doggie\",\n \"photoUrls\": [\n \"https://example.com/photo.png\",\n \"https://example.com/photo.png\"\n ],\n \"category\": {\n \"id\": -98206889,\n \"name\": \"ut\"\n },\n \"tags\": [\n {\n \"id\": -66696067,\n \"name\": \"laboris dolore pariatur qui\"\n },\n {\n \"id\": -22260355,\n \"name\": \"qui reprehenderit aliqua sint velit\"\n }\n ],\n \"status\": \"available\"\n}", "options": { "raw": { "language": "json" } } }, "url": { "raw": "{{baseUrl}}/pet", "host": ["{{baseUrl}}"], "path": ["pet"] } }, "response": [ { "name": "Invalid input", "originalRequest": { "method": "POST", "header": [ { "description": "Added as a part of security scheme: oauth2", "key": "Authorization", "value": "" } ], "url": { "raw": "{{baseUrl}}/pet", "host": ["{{baseUrl}}"], "path": ["pet"] } }, "status": "Method Not Allowed", "code": 405, "_postman_previewlanguage": "text", "header": [ { "key": "Content-Type", "value": "text/plain" } ], "cookie": [], "body": "" } ] }, { "name": "Update an existing pet", "request": { "auth": { "type": "oauth2", "oauth2": [ { "key": "scope", "value": "write:pets read:pets", "type": "string" }, { "key": "authUrl", "value": "http://petstore.swagger.io/oauth/dialog", "type": "string" }, { "key": "grant_type", "value": "implicit", "type": "string" } ] }, "method": "PUT", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "{\n \"name\": \"doggie\",\n \"photoUrls\": [\n \"https://example.com/photo.png\",\n \"https://example.com/photo.png\"\n ],\n \"category\": {\n \"id\": 45108667,\n \"name\": \"elit\"\n },\n \"tags\": [\n {\n \"id\": -90871361,\n \"name\": \"tempor ullamco\"\n },\n {\n \"id\": 41541088,\n \"name\": \"commodo irure in dolor fugiat\"\n }\n ],\n \"status\": \"sold\"\n}", "options": { "raw": { "language": "json" } } }, "url": { "raw": "{{baseUrl}}/pet", "host": ["{{baseUrl}}"], "path": ["pet"] } }, "response": [ { "name": "Invalid ID supplied", "originalRequest": { "method": "PUT", "header": [ { "description": "Added as a part of security scheme: oauth2", "key": "Authorization", "value": "" } ], "url": { "raw": "{{baseUrl}}/pet", "host": ["{{baseUrl}}"], "path": ["pet"] } }, "status": "Bad Request", "code": 400, "_postman_previewlanguage": "text", "header": [ { "key": "Content-Type", "value": "text/plain" } ], "cookie": [], "body": "" }, { "name": "Pet not found", "originalRequest": { "method": "PUT", "header": [ { "description": "Added as a part of security scheme: oauth2", "key": "Authorization", "value": "" } ], "url": { "raw": "{{baseUrl}}/pet", "host": ["{{baseUrl}}"], "path": ["pet"] } }, "status": "Not Found", "code": 404, "_postman_previewlanguage": "text", "header": [ { "key": "Content-Type", "value": "text/plain" } ], "cookie": [], "body": "" }, { "name": "Validation exception", "originalRequest": { "method": "PUT", "header": [ { "description": "Added as a part of security scheme: oauth2", "key": "Authorization", "value": "" } ], "url": { "raw": "{{baseUrl}}/pet", "host": ["{{baseUrl}}"], "path": ["pet"] } }, "status": "Method Not Allowed", "code": 405, "_postman_previewlanguage": "text", "header": [ { "key": "Content-Type", "value": "text/plain" } ], "cookie": [], "body": "" } ] }, { "name": "Finds Pets by status", "request": { "auth": { "type": "oauth2", "oauth2": [ { "key": "scope", "value": "write:pets read:pets", "type": "string" }, { "key": "authUrl", "value": "http://petstore.swagger.io/oauth/dialog", "type": "string" }, { "key": "grant_type", "value": "implicit", "type": "string" } ] }, "method": "GET", "header": [ { "key": "Accept", "value": "application/xml" } ], "url": { "raw": "{{baseUrl}}/pet/findByStatus?status=available&status=available", "host": ["{{baseUrl}}"], "path": ["pet", "findByStatus"], "query": [ { "key": "status", "value": "available", "description": "(Required) Status values that need to be considered for filter" }, { "key": "status", "value": "available", "description": "(Required) Status values that need to be considered for filter" } ] }, "description": "Multiple status values can be provided with comma separated strings" }, "response": [ { "name": "successful operation", "originalRequest": { "method": "GET", "header": [ { "description": "Added as a part of security scheme: oauth2", "key": "Authorization", "value": "" } ], "url": { "raw": "{{baseUrl}}/pet/findByStatus?status=available&status=available", "host": ["{{baseUrl}}"], "path": ["pet", "findByStatus"], "query": [ { "key": "status", "value": "available" }, { "key": "status", "value": "available" } ] } }, "status": "OK", "code": 200, "_postman_previewlanguage": "json", "header": [ { "key": "Content-Type", "value": "application/json" } ], "cookie": [], "body": "[\n {\n \"name\": \"doggie\",\n \"photoUrls\": [\n \"https://example.com/photo.png\",\n \"https://example.com/photo.png\"\n ],\n \"id\": 25,\n \"category\": {\n \"id\": -10731015,\n \"name\": \"consectetur proident\"\n },\n \"tags\": [\n {\n \"id\": -87509155,\n \"name\": \"dolor nulla Ut\"\n },\n {\n \"id\": -19458248,\n \"name\": \"elit\"\n }\n ],\n \"status\": \"pending\"\n },\n {\n \"name\": \"doggie\",\n \"photoUrls\": [\n \"https://example.com/photo.png\",\n \"https://example.com/photo.png\"\n ],\n \"id\": 25,\n \"category\": {\n \"id\": 38511362,\n \"name\": \"a\"\n },\n \"tags\": [\n {\n \"id\": 26246913,\n \"name\": \"pariatur\"\n },\n {\n \"id\": 65442833,\n \"name\": \"dolor irure consectetur\"\n }\n ],\n \"status\": \"pending\"\n }\n]" }, { "name": "Invalid status value", "originalRequest": { "method": "GET", "header": [ { "description": "Added as a part of security scheme: oauth2", "key": "Authorization", "value": "" } ], "url": { "raw": "{{baseUrl}}/pet/findByStatus?status=available&status=available", "host": ["{{baseUrl}}"], "path": ["pet", "findByStatus"], "query": [ { "key": "status", "value": "available" }, { "key": "status", "value": "available" } ] } }, "status": "Bad Request", "code": 400, "_postman_previewlanguage": "text", "header": [ { "key": "Content-Type", "value": "text/plain" } ], "cookie": [], "body": "" } ] }, { "name": "Finds Pets by tags", "request": { "auth": { "type": "oauth2", "oauth2": [ { "key": "scope", "value": "write:pets read:pets", "type": "string" }, { "key": "authUrl", "value": "http://petstore.swagger.io/oauth/dialog", "type": "string" }, { "key": "grant_type", "value": "implicit", "type": "string" } ] }, "method": "GET", "header": [ { "key": "Accept", "value": "application/xml" } ], "url": { "raw": "{{baseUrl}}/pet/findByTags?tags=enim nostrud consequat&tags=culpa quis dolor laboris", "host": ["{{baseUrl}}"], "path": ["pet", "findByTags"], "query": [ { "key": "tags", "value": "enim nostrud consequat", "description": "(Required) Tags to filter by" }, { "key": "tags", "value": "culpa quis dolor laboris", "description": "(Required) Tags to filter by" } ] }, "description": "Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing." }, "response": [ { "name": "successful operation", "originalRequest": { "method": "GET", "header": [ { "description": "Added as a part of security scheme: oauth2", "key": "Authorization", "value": "" } ], "url": { "raw": "{{baseUrl}}/pet/findByTags?tags=sed occaecat anim veniam ex&tags=anim reprehenderit magna", "host": ["{{baseUrl}}"], "path": ["pet", "findByTags"], "query": [ { "key": "tags", "value": "sed occaecat anim veniam ex" }, { "key": "tags", "value": "anim reprehenderit magna" } ] } }, "status": "OK", "code": 200, "_postman_previewlanguage": "json", "header": [ { "key": "Content-Type", "value": "application/json" } ], "cookie": [], "body": "[\n {\n \"name\": \"doggie\",\n \"photoUrls\": [\n \"https://example.com/photo.png\",\n \"https://example.com/photo.png\"\n ],\n \"id\": 25,\n \"category\": {\n \"id\": -10731015,\n \"name\": \"consectetur proident\"\n },\n \"tags\": [\n {\n \"id\": -87509155,\n \"name\": \"dolor nulla Ut\"\n },\n {\n \"id\": -19458248,\n \"name\": \"elit\"\n }\n ],\n \"status\": \"pending\"\n },\n {\n \"name\": \"doggie\",\n \"photoUrls\": [\n \"https://example.com/photo.png\",\n \"https://example.com/photo.png\"\n ],\n \"id\": 25,\n \"category\": {\n \"id\": 38511362,\n \"name\": \"a\"\n },\n \"tags\": [\n {\n \"id\": 26246913,\n \"name\": \"pariatur\"\n },\n {\n \"id\": 65442833,\n \"name\": \"dolor irure consectetur\"\n }\n ],\n \"status\": \"pending\"\n }\n]" }, { "name": "Invalid tag value", "originalRequest": { "method": "GET", "header": [ { "description": "Added as a part of security scheme: oauth2", "key": "Authorization", "value": "" } ], "url": { "raw": "{{baseUrl}}/pet/findByTags?tags=sed occaecat anim veniam ex&tags=anim reprehenderit magna", "host": ["{{baseUrl}}"], "path": ["pet", "findByTags"], "query": [ { "key": "tags", "value": "sed occaecat anim veniam ex" }, { "key": "tags", "value": "anim reprehenderit magna" } ] } }, "status": "Bad Request", "code": 400, "_postman_previewlanguage": "text", "header": [ { "key": "Content-Type", "value": "text/plain" } ], "cookie": [], "body": "" } ] } ] }, { "name": "store", "item": [ { "name": "order", "item": [ { "name": "{order Id}", "item": [ { "name": "Find purchase order by ID", "request": { "method": "GET", "header": [ { "key": "Accept", "value": "application/xml" } ], "url": { "raw": "{{baseUrl}}/store/order/:orderId", "host": ["{{baseUrl}}"], "path": ["store", "order", ":orderId"], "variable": [ { "key": "orderId", "value": "7", "description": "(Required) ID of pet that needs to be fetched" } ] }, "description": "For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions" }, "response": [ { "name": "successful operation", "originalRequest": { "method": "GET", "header": [], "url": { "raw": "{{baseUrl}}/store/order/:orderId", "host": ["{{baseUrl}}"], "path": ["store", "order", ":orderId"], "variable": [ { "key": "orderId", "value": "7", "description": "(Required) ID of pet that needs to be fetched" } ] } }, "status": "OK", "code": 200, "_postman_previewlanguage": "json", "header": [ { "key": "Content-Type", "value": "application/json" } ], "cookie": [], "body": "{\n \"id\": -15329310,\n \"petId\": -50620843,\n \"quantity\": 78361352,\n \"shipDate\": \"2018-08-08T02:36:45.934Z\",\n \"status\": \"delivered\",\n \"complete\": false\n}" }, { "name": "Invalid ID supplied", "originalRequest": { "method": "GET", "header": [], "url": { "raw": "{{baseUrl}}/store/order/:orderId", "host": ["{{baseUrl}}"], "path": ["store", "order", ":orderId"], "variable": [ { "key": "orderId", "value": "7", "description": "(Required) ID of pet that needs to be fetched" } ] } }, "status": "Bad Request", "code": 400, "_postman_previewlanguage": "text", "header": [ { "key": "Content-Type", "value": "text/plain" } ], "cookie": [], "body": "" }, { "name": "Order not found", "originalRequest": { "method": "GET", "header": [], "url": { "raw": "{{baseUrl}}/store/order/:orderId", "host": ["{{baseUrl}}"], "path": ["store", "order", ":orderId"], "variable": [ { "key": "orderId", "value": "7", "description": "(Required) ID of pet that needs to be fetched" } ] } }, "status": "Not Found", "code": 404, "_postman_previewlanguage": "text", "header": [ { "key": "Content-Type", "value": "text/plain" } ], "cookie": [], "body": "" } ] }, { "name": "Delete purchase order by ID", "request": { "method": "DELETE", "header": [], "url": { "raw": "{{baseUrl}}/store/order/:orderId", "host": ["{{baseUrl}}"], "path": ["store", "order", ":orderId"], "variable": [ { "key": "orderId", "value": "32526146", "description": "(Required) ID of the order that needs to be deleted" } ] }, "description": "For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors" }, "response": [ { "name": "Invalid ID supplied", "originalRequest": { "method": "DELETE", "header": [], "url": { "raw": "{{baseUrl}}/store/order/:orderId", "host": ["{{baseUrl}}"], "path": ["store", "order", ":orderId"], "variable": [ { "key": "orderId", "value": "32526146", "description": "(Required) ID of the order that needs to be deleted" } ] } }, "status": "Bad Request", "code": 400, "_postman_previewlanguage": "text", "header": [ { "key": "Content-Type", "value": "text/plain" } ], "cookie": [], "body": "" }, { "name": "Order not found", "originalRequest": { "method": "DELETE", "header": [], "url": { "raw": "{{baseUrl}}/store/order/:orderId", "host": ["{{baseUrl}}"], "path": ["store", "order", ":orderId"], "variable": [ { "key": "orderId", "value": "32526146", "description": "(Required) ID of the order that needs to be deleted" } ] } }, "status": "Not Found", "code": 404, "_postman_previewlanguage": "text", "header": [ { "key": "Content-Type", "value": "text/plain" } ], "cookie": [], "body": "" } ] } ] }, { "name": "Place an order for a pet", "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, { "key": "Accept", "value": "application/xml" } ], "body": { "mode": "raw", "raw": "{\n \"id\": -15329310,\n \"petId\": -50620843,\n \"quantity\": 78361352,\n \"shipDate\": \"2018-08-08T02:36:45.934Z\",\n \"status\": \"delivered\",\n \"complete\": false\n}", "options": { "raw": { "language": "json" } } }, "url": { "raw": "{{baseUrl}}/store/order", "host": ["{{baseUrl}}"], "path": ["store", "order"] } }, "response": [ { "name": "successful operation", "originalRequest": { "method": "POST", "header": [], "body": { "mode": "raw", "raw": "{\n \"id\": -15329310,\n \"petId\": -50620843,\n \"quantity\": 78361352,\n \"shipDate\": \"2018-08-08T02:36:45.934Z\",\n \"status\": \"delivered\",\n \"complete\": false\n}", "options": { "raw": { "language": "json" } } }, "url": { "raw": "{{baseUrl}}/store/order", "host": ["{{baseUrl}}"], "path": ["store", "order"] } }, "status": "OK", "code": 200, "_postman_previewlanguage": "json", "header": [ { "key": "Content-Type", "value": "application/json" } ], "cookie": [], "body": "{\n \"id\": -15329310,\n \"petId\": -50620843,\n \"quantity\": 78361352,\n \"shipDate\": \"2018-08-08T02:36:45.934Z\",\n \"status\": \"delivered\",\n \"complete\": false\n}" }, { "name": "Invalid Order", "originalRequest": { "method": "POST", "header": [], "body": { "mode": "raw", "raw": "{\n \"id\": -15329310,\n \"petId\": -50620843,\n \"quantity\": 78361352,\n \"shipDate\": \"2018-08-08T02:36:45.934Z\",\n \"status\": \"delivered\",\n \"complete\": false\n}", "options": { "raw": { "language": "json" } } }, "url": { "raw": "{{baseUrl}}/store/order", "host": ["{{baseUrl}}"], "path": ["store", "order"] } }, "status": "Bad Request", "code": 400, "_postman_previewlanguage": "text", "header": [ { "key": "Content-Type", "value": "text/plain" } ], "cookie": [], "body": "" } ] } ] }, { "name": "Returns pet inventories by status", "request": { "auth": { "type": "apikey", "apikey": [ { "key": "key", "value": "api_key", "type": "string" }, { "key": "value", "value": "", "type": "string" }, { "key": "in", "value": "header", "type": "string" } ] }, "method": "GET", "header": [ { "key": "Accept", "value": "application/json" } ], "url": { "raw": "{{baseUrl}}/store/inventory", "host": ["{{baseUrl}}"], "path": ["store", "inventory"] }, "description": "Returns a map of status codes to quantities" }, "response": [ { "name": "successful operation", "originalRequest": { "method": "GET", "header": [ { "description": "Added as a part of security scheme: apikey", "key": "api_key", "value": "" } ], "url": { "raw": "{{baseUrl}}/store/inventory", "host": ["{{baseUrl}}"], "path": ["store", "inventory"] } }, "status": "OK", "code": 200, "_postman_previewlanguage": "json", "header": [ { "key": "Content-Type", "value": "application/json" } ], "cookie": [], "body": "{\n \"dolor_4\": -59651882,\n \"dolor__10\": 76938793\n}" } ] } ] }, { "name": "user", "item": [ { "name": "{username}", "item": [ { "name": "Get user by user name", "request": { "method": "GET", "header": [ { "key": "Accept", "value": "application/xml" } ], "url": { "raw": "{{baseUrl}}/user/:username", "host": ["{{baseUrl}}"], "path": ["user", ":username"], "variable": [ { "key": "username", "value": "dolore est", "description": "(Required) The name that needs to be fetched. Use user1 for testing. " } ] } }, "response": [ { "name": "successful operation", "originalRequest": { "method": "GET", "header": [], "url": { "raw": "{{baseUrl}}/user/:username", "host": ["{{baseUrl}}"], "path": ["user", ":username"], "variable": [ { "key": "username", "value": "dolore est", "description": "(Required) The name that needs to be fetched. Use user1 for testing. " } ] } }, "status": "OK", "code": 200, "_postman_previewlanguage": "json", "header": [ { "key": "Content-Type", "value": "application/json" } ], "cookie": [], "body": "{\n \"id\": -70409270,\n \"username\": \"do ea nisi\",\n \"firstName\": \"occaecat dolor in dolore\",\n \"lastName\": \"laborum sit ullamco\",\n \"email\": \"nostrud Ut\",\n \"password\": \"officia occaecat enim l\",\n \"phone\": \"in elit officia sint\",\n \"userStatus\": 86291576\n}" }, { "name": "Invalid username supplied", "originalRequest": { "method": "GET", "header": [], "url": { "raw": "{{baseUrl}}/user/:username", "host": ["{{baseUrl}}"], "path": ["user", ":username"], "variable": [ { "key": "username", "value": "dolore est", "description": "(Required) The name that needs to be fetched. Use user1 for testing. " } ] } }, "status": "Bad Request", "code": 400, "_postman_previewlanguage": "text", "header": [ { "key": "Content-Type", "value": "text/plain" } ], "cookie": [], "body": "" }, { "name": "User not found", "originalRequest": { "method": "GET", "header": [], "url": { "raw": "{{baseUrl}}/user/:username", "host": ["{{baseUrl}}"], "path": ["user", ":username"], "variable": [ { "key": "username", "value": "dolore est", "description": "(Required) The name that needs to be fetched. Use user1 for testing. " } ] } }, "status": "Not Found", "code": 404, "_postman_previewlanguage": "text", "header": [ { "key": "Content-Type", "value": "text/plain" } ], "cookie": [], "body": "" } ] }, { "name": "Updated user", "request": { "method": "PUT", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "{\n \"id\": -70409270,\n \"username\": \"do ea nisi\",\n \"firstName\": \"occaecat dolor in dolore\",\n \"lastName\": \"laborum sit ullamco\",\n \"email\": \"nostrud Ut\",\n \"password\": \"officia occaecat enim l\",\n \"phone\": \"in elit officia sint\",\n \"userStatus\": 86291576\n}", "options": { "raw": { "language": "json" } } }, "url": { "raw": "{{baseUrl}}/user/:username", "host": ["{{baseUrl}}"], "path": ["user", ":username"], "variable": [ { "key": "username", "value": "dolore est", "description": "(Required) name that need to be updated" } ] }, "description": "This can only be done by the logged in user." }, "response": [ { "name": "Invalid user supplied", "originalRequest": { "method": "PUT", "header": [], "body": { "mode": "raw", "raw": "{\n \"id\": -70409270,\n \"username\": \"do ea nisi\",\n \"firstName\": \"occaecat dolor in dolore\",\n \"lastName\": \"laborum sit ullamco\",\n \"email\": \"nostrud Ut\",\n \"password\": \"officia occaecat enim l\",\n \"phone\": \"in elit officia sint\",\n \"userStatus\": 86291576\n}", "options": { "raw": { "language": "json" } } }, "url": { "raw": "{{baseUrl}}/user/:username", "host": ["{{baseUrl}}"], "path": ["user", ":username"], "variable": [ { "key": "username", "value": "dolore est", "description": "(Required) name that need to be updated" } ] } }, "status": "Bad Request", "code": 400, "_postman_previewlanguage": "text", "header": [ { "key": "Content-Type", "value": "text/plain" } ], "cookie": [], "body": "" }, { "name": "User not found", "originalRequest": { "method": "PUT", "header": [], "body": { "mode": "raw", "raw": "{\n \"id\": -70409270,\n \"username\": \"do ea nisi\",\n \"firstName\": \"occaecat dolor in dolore\",\n \"lastName\": \"laborum sit ullamco\",\n \"email\": \"nostrud Ut\",\n \"password\": \"officia occaecat enim l\",\n \"phone\": \"in elit officia sint\",\n \"userStatus\": 86291576\n}", "options": { "raw": { "language": "json" } } }, "url": { "raw": "{{baseUrl}}/user/:username", "host": ["{{baseUrl}}"], "path": ["user", ":username"], "variable": [ { "key": "username", "value": "dolore est", "description": "(Required) name that need to be updated" } ] } }, "status": "Not Found", "code": 404, "_postman_previewlanguage": "text", "header": [ { "key": "Content-Type", "value": "text/plain" } ], "cookie": [], "body": "" } ] }, { "name": "Delete user", "request": { "method": "DELETE", "header": [], "url": { "raw": "{{baseUrl}}/user/:username", "host": ["{{baseUrl}}"], "path": ["user", ":username"], "variable": [ { "key": "username", "value": "dolore est", "description": "(Required) The name that needs to be deleted" } ] }, "description": "This can only be done by the logged in user." }, "response": [ { "name": "Invalid username supplied", "originalRequest": { "method": "DELETE", "header": [], "url": { "raw": "{{baseUrl}}/user/:username", "host": ["{{baseUrl}}"], "path": ["user", ":username"], "variable": [ { "key": "username", "value": "dolore est", "description": "(Required) The name that needs to be deleted" } ] } }, "status": "Bad Request", "code": 400, "_postman_previewlanguage": "text", "header": [ { "key": "Content-Type", "value": "text/plain" } ], "cookie": [], "body": "" }, { "name": "User not found", "originalRequest": { "method": "DELETE", "header": [], "url": { "raw": "{{baseUrl}}/user/:username", "host": ["{{baseUrl}}"], "path": ["user", ":username"], "variable": [ { "key": "username", "value": "dolore est", "description": "(Required) The name that needs to be deleted" } ] } }, "status": "Not Found", "code": 404, "_postman_previewlanguage": "text", "header": [ { "key": "Content-Type", "value": "text/plain" } ], "cookie": [], "body": "" } ] } ] }, { "name": "Create user", "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "{\n \"id\": -70409270,\n \"username\": \"do ea nisi\",\n \"firstName\": \"occaecat dolor in dolore\",\n \"lastName\": \"laborum sit ullamco\",\n \"email\": \"nostrud Ut\",\n \"password\": \"officia occaecat enim l\",\n \"phone\": \"in elit officia sint\",\n \"userStatus\": 86291576\n}", "options": { "raw": { "language": "json" } } }, "url": { "raw": "{{baseUrl}}/user", "host": ["{{baseUrl}}"], "path": ["user"] }, "description": "This can only be done by the logged in user." }, "response": [ { "name": "successful operation", "originalRequest": { "method": "POST", "header": [], "body": { "mode": "raw", "raw": "{\n \"id\": -70409270,\n \"username\": \"do ea nisi\",\n \"firstName\": \"occaecat dolor in dolore\",\n \"lastName\": \"laborum sit ullamco\",\n \"email\": \"nostrud Ut\",\n \"password\": \"officia occaecat enim l\",\n \"phone\": \"in elit officia sint\",\n \"userStatus\": 86291576\n}", "options": { "raw": { "language": "json" } } }, "url": { "raw": "{{baseUrl}}/user", "host": ["{{baseUrl}}"], "path": ["user"] } }, "status": "Internal Server Error", "code": 500, "_postman_previewlanguage": "text", "header": [ { "key": "Content-Type", "value": "text/plain" } ], "cookie": [], "body": "" } ] }, { "name": "Creates list of users with given input array", "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "[\n {\n \"id\": -95496632,\n \"username\": \"reprehenderit Duis\",\n \"firstName\": \"ipsum enim\",\n \"lastName\": \"sit incididunt quis su\",\n \"email\": \"esse in nostrud\",\n \"password\": \"dolore\",\n \"phone\": \"ea tempor sed eiusmod\",\n \"userStatus\": 23456761\n },\n {\n \"id\": -17610454,\n \"username\": \"occaecat in laboris voluptate\",\n \"firstName\": \"consectetur fugiat\",\n \"lastName\": \"est consectet\",\n \"email\": \"ea qui\",\n \"password\": \"dolor aliquip\",\n \"phone\": \"nulla eu veniam\",\n \"userStatus\": -56036685\n }\n]", "options": { "raw": { "language": "json" } } }, "url": { "raw": "{{baseUrl}}/user/createWithArray", "host": ["{{baseUrl}}"], "path": ["user", "createWithArray"] } }, "response": [ { "name": "successful operation", "originalRequest": { "method": "POST", "header": [], "url": { "raw": "{{baseUrl}}/user/createWithArray", "host": ["{{baseUrl}}"], "path": ["user", "createWithArray"] } }, "status": "Internal Server Error", "code": 500, "_postman_previewlanguage": "text", "header": [ { "key": "Content-Type", "value": "text/plain" } ], "cookie": [], "body": "" } ] }, { "name": "Creates list of users with given input array", "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "[\n {\n \"id\": -17453134,\n \"username\": \"est veniam proident\",\n \"firstName\": \"adipisic\",\n \"lastName\": \"ea nisi ut anim\",\n \"email\": \"culpa voluptate laborum ut\",\n \"password\": \"veniam id enim voluptate\",\n \"phone\": \"enim sed\",\n \"userStatus\": 31329378\n },\n {\n \"id\": -97425969,\n \"username\": \"velit sint ea ad reprehend\",\n \"firstName\": \"reprehenderit do aliquip\",\n \"lastName\": \"anim mollit\",\n \"email\": \"minim qui laborum in\",\n \"password\": \"exercitation quis\",\n \"phone\": \"irure\",\n \"userStatus\": -62781043\n }\n]", "options": { "raw": { "language": "json" } } }, "url": { "raw": "{{baseUrl}}/user/createWithList", "host": ["{{baseUrl}}"], "path": ["user", "createWithList"] } }, "response": [ { "name": "successful operation", "originalRequest": { "method": "POST", "header": [], "url": { "raw": "{{baseUrl}}/user/createWithList", "host": ["{{baseUrl}}"], "path": ["user", "createWithList"] } }, "status": "Internal Server Error", "code": 500, "_postman_previewlanguage": "text", "header": [ { "key": "Content-Type", "value": "text/plain" } ], "cookie": [], "body": "" } ] }, { "name": "Logs user into the system", "request": { "method": "GET", "header": [ { "key": "Accept", "value": "application/xml" } ], "url": { "raw": "{{baseUrl}}/user/login?username=dolore est&password=dolore est", "host": ["{{baseUrl}}"], "path": ["user", "login"], "query": [ { "key": "username", "value": "dolore est", "description": "(Required) The user name for login" }, { "key": "password", "value": "dolore est", "description": "(Required) The password for login in clear text" } ] } }, "response": [ { "name": "successful operation", "originalRequest": { "method": "GET", "header": [], "url": { "raw": "{{baseUrl}}/user/login?username=dolore est&password=dolore est", "host": ["{{baseUrl}}"], "path": ["user", "login"], "query": [ { "key": "username", "value": "dolore est" }, { "key": "password", "value": "dolore est" } ] } }, "status": "OK", "code": 200, "_postman_previewlanguage": "json", "header": [ { "key": "X-Rate-Limit", "value": "-71676539", "description": "calls per hour allowed by the user" }, { "key": "X-Expires-After", "value": "1966-01-28T06:32:02.771Z", "description": "date in UTC when token expires" }, { "key": "Content-Type", "value": "application/json" } ], "cookie": [], "body": "\"dolore est\"" }, { "name": "Invalid username/password supplied", "originalRequest": { "method": "GET", "header": [], "url": { "raw": "{{baseUrl}}/user/login?username=dolore est&password=dolore est", "host": ["{{baseUrl}}"], "path": ["user", "login"], "query": [ { "key": "username", "value": "dolore est" }, { "key": "password", "value": "dolore est" } ] } }, "status": "Bad Request", "code": 400, "_postman_previewlanguage": "text", "header": [ { "key": "Content-Type", "value": "text/plain" } ], "cookie": [], "body": "" } ] }, { "name": "Logs out current logged in user session", "request": { "method": "GET", "header": [], "url": { "raw": "{{baseUrl}}/user/logout", "host": ["{{baseUrl}}"], "path": ["user", "logout"] } }, "response": [ { "name": "successful operation", "originalRequest": { "method": "GET", "header": [], "url": { "raw": "{{baseUrl}}/user/logout", "host": ["{{baseUrl}}"], "path": ["user", "logout"] } }, "status": "Internal Server Error", "code": 500, "_postman_previewlanguage": "text", "header": [ { "key": "Content-Type", "value": "text/plain" } ], "cookie": [], "body": "" } ] } ] } ], "variable": [ { "key": "baseUrl", "value": "http://petstore.swagger.io/v2", "type": "string" } ] } ```
joolfe commented 1 year ago

Hi @erunion,

I think that you are missing some features from the library:

👋 Hello! We're going to be integrating this library into our product soon to allow customers to upload Postman collections to us and I noticed an issue where if I import the OpenAPI Petstore example into Postman and then export it out the global server gets set to a baseUrl variable in Postman but that variable never received its default of http://petstore.swagger.io/v2.

If you want the library to automatically replace vars from Postman you need to activate the feature using the option replaceVars please have a look to the documentation, the Postman collection that you have attached works just activating this flag because the library get the baseUrl and replace automatically.

After digging into it I found that this library currently did not support server variables.

Servers are automatically extracted from the API URL and if you use variables and activate replaceVars are also extracted, complementary you can provide additional servers, for example to indicate Sandbox or Production environments, this can be carry on using the servers option, have a look to the documentation and test to see how it works but is very straight fordward.

Best Regards.

erunion commented 1 year ago

Wow this is embarrassing, you're totally right. My bad! Thanks for the help.