diff --git a/packages/insomnia-importers/src/__tests__/fixtures/openapi3/petstore-input.json b/packages/insomnia-importers/src/__tests__/fixtures/openapi3/petstore-input.json index 4389e9505f..b233fc6537 100644 --- a/packages/insomnia-importers/src/__tests__/fixtures/openapi3/petstore-input.json +++ b/packages/insomnia-importers/src/__tests__/fixtures/openapi3/petstore-input.json @@ -19,7 +19,7 @@ }, "servers": [ { - "url": "http://petstore.swagger.io/v2" + "url": "http://petstore.swagger.io/v2/" } ], "tags": [], diff --git a/packages/insomnia-importers/src/importers/openapi3.js b/packages/insomnia-importers/src/importers/openapi3.js index 543032a230..cfdfb09b97 100644 --- a/packages/insomnia-importers/src/importers/openapi3.js +++ b/packages/insomnia-importers/src/importers/openapi3.js @@ -67,6 +67,10 @@ module.exports.convert = async function(rawData) { ); const protocol = defaultServer.protocol || ''; + + // Base path is pulled out of the URL, and the trailing slash is removed + const basePath = (defaultServer.pathname || '').replace(/\/$/, ''); + const openapiEnv = { _type: 'environment', _id: `env___BASE_ENVIRONMENT_ID___sub`, @@ -75,7 +79,7 @@ module.exports.convert = async function(rawData) { data: { // note: `URL.protocol` returns with trailing `:` (i.e. "https:") scheme: protocol.replace(/:$/, '') || ['http'], - base_path: defaultServer.pathname || '', + base_path: basePath, host: defaultServer.host || '', ...securityVariables, },