UNPKG

openapi3-generator

Version:

Use your API OpenAPI 3 definition to generate code, documentation, and literally anything you need.

18 lines (14 loc) 581 B
const _ = require('lodash'); const Handlebars = require('handlebars'); /** * Checks if a method is a valid HTTP method. */ Handlebars.registerHelper('validMethod', (method, options) => { const authorized_methods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'COPY', 'HEAD', 'OPTIONS', 'LINK', 'UNLIK', 'PURGE', 'LOCK', 'UNLOCK', 'PROPFIND']; if (arguments.length < 3) throw new Error('Handlebars Helper validMethod needs 1 parameter'); if (authorized_methods.indexOf(method.toUpperCase()) === -1) { return options.inverse(this); } return options.fn(this); });