Package detail

openapi-jsonschema-parameters

kogosoftwarellc475.3kMIT12.1.3

Converts openapi parameters to a jsonschema format.

openapi, parameters, jsonschema, convert

readme

openapi-jsonschema-parameters NPM version Downloads Coveralls Status

Converts openapi parameters to a jsonschema format.

Highlights

  • No validation on the input or the output. It is expected that you'll do this with some other library.
  • Performant.
  • Extensively tested.
  • Small footprint.

Example

See ./test/data-driven for more examples.

import { convertParametersToJSONSchema } from 'openapi-jsonschema-parameters';

const parametersSchemas = convertParametersToJSONSchema([
  {
    in: 'body',
    name: 'wow',
    schema: {
      $ref: '#/definitions/SomeDefinition'
    }
  },

  {
    in: 'header',
    name: 'Accept',
    type: 'string'
  },

  {
    in: 'path',
    name: 'boo',
    type: 'string'
  },

  {
    in: 'query',
    name: 'foo',
    required: true,
    type: 'string'
  }
]);

console.log(parametersSchema); //=>
// {
//   body: {
//     $ref: '#/definitions/SomeDefinition'
//   },
//
//   headers: {
//     properties: {
//       Accept: {
//         type: 'string'
//       }
//     }
//   },
//
//   path: {
//     properties: {
//       boo: {
//         type: 'string'
//       }
//     }
//   },
//
//   query: {
//     properties: {
//       foo: {
//         type: 'string'
//       }
//     },
//     required: ['foo']
//   }
// }

LICENSE

The MIT License (MIT)

Copyright (c) 2016 Kogo Software LLC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

changelog

openapi-jsonschema-parameters Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

1.2.0 - 2019-10-21

Aded

  • Added support for 'examples' (fixes #513) (#514)

Fixed

  • remove extra parens from example code (#550)

1.1.2 - 2019-06-21

Fixed

  • Adds example keyword (fixes #455) (#456)

1.1.1 - 2019-01-31

Fixed

  • openapi-types: OpenAPIV3: relax security requirement object types (#327)

1.1.0 - 2019-01-10

Fixed

  • retrieving validation keywords in both root and schema attribute of a definition for all types of parameters (fixes #301)

1.0.3 - 2018-10-06

Fixed

  • Stop outputting parameters of type: 'file'.

    This was causing issues in downstream projects that were attempting to use these parameters with a jsonschema validator. type: 'file' isn't valid in jsonschema, and OpenAPI V3 has entirely removed it as a type. downstream projects should therefore handle file validation independently of the schemas outputted by this package.j

1.0.2 - 2018-10-03

Fixed

  • Updating .npmignore to publish dist

1.0.1 - 2018-09-29

Fixed

  • Using OpenAPI.Parameters from openapi-types instead of duplicated type definition.

1.0.0 - 2018-09-29

Added

  • export interface OpenAPIParametersAsJSONSchema
  • Typings for exports.

Changed

  • module.exports has been replaced with export convertParametersToJSONSchema