openapi-utils-param-to-schema

0.0.9 • Public • Published

openapi-utils-param-to-schema

npm version Build Status JavaScript Style Guide

Convert a param into a schema.

Installation

npm install --save openapi-utils-param-to-schema

Usage

var openApiUtils = require('openapi-utils-param-to-schema')
 
var postalCodeParam = {
  "name": "postalCode",
  "in": "query",
  "required": true,
  "type": "string",
  "pattern": "^[1-9][0-9]{3} ?(?!sa|sd|ss)[A-Z]{2}$"
}
 
var schema1 = openApiUtils.paramToSchema(postalCodeParam)
console.log(schema1)
/*
{
  "required": ["postalCode"],
  "properties": {
    "postalCode": {
      "type": "string",
      "pattern": "^[1-9][0-9]{3} ?(?!sa|sd|ss)[A-Z]{2}$"
    }
  }
}
*/

/openapi-utils-param-to-schema/

    Package Sidebar

    Install

    npm i openapi-utils-param-to-schema

    Weekly Downloads

    12

    Version

    0.0.9

    License

    ISC

    Last publish

    Collaborators

    • robodo