UNPKG

parse-openapi

Version:

OpenAPI v3 parser

16 lines (15 loc) 512 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getServer = void 0; const getServer = (openApi) => { const server = openApi.servers?.[0]; const variables = server?.variables || {}; let url = server?.url || ''; for (const variable in variables) { if (variables.hasOwnProperty(variable)) { url = url.replace(`{${variable}}`, variables[variable].default); } } return url.replace(/\/$/g, ''); }; exports.getServer = getServer;