swagger-routes-express
Version:
Connect Express route controllers to restful paths using a Swagger 2 or OpenAPI 3 definition file
14 lines (10 loc) • 427 B
JavaScript
const normalisePath = require('../../normalise/normalisePath')
const prependPath = (base, path) =>
base.endsWith('/') ? `${base.slice(0, -1)}${path}` : `${base}${path}`
const detailSummariser =
base =>
(path, { servers }) =>
Array.isArray(servers) && servers.length
? `${prependPath(servers[0].url, normalisePath(path))}`
: `${prependPath(base, normalisePath(path))}`
module.exports = detailSummariser