UNPKG

swagger-routes-express

Version:

Connect Express route controllers to restful paths using a Swagger 2 or OpenAPI 3 definition file

11 lines (9 loc) 312 B
const substituteVariables = (str, variables) => { let result = Buffer.from(str).toString() Object.keys(variables).forEach(variable => { const pattern = new RegExp(`{${variable}}`, 'g') result = result.replace(pattern, variables[variable]) }) return result } module.exports = substituteVariables