Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/orangewise/openapi-utils-param-to-schema
Convert a param into a schema.
https://github.com/orangewise/openapi-utils-param-to-schema
Last synced: 8 days ago
JSON representation
Convert a param into a schema.
- Host: GitHub
- URL: https://github.com/orangewise/openapi-utils-param-to-schema
- Owner: orangewise
- Created: 2016-11-07T19:52:16.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-11T11:55:41.000Z (almost 8 years ago)
- Last Synced: 2024-10-31T19:48:09.222Z (16 days ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# openapi-utils-param-to-schema
[![npm version][npm-badge]][npm-url]
[![Build Status][travis-badge]][travis-url]
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)Convert a param into a schema.
# Installation
```
npm install --save openapi-utils-param-to-schema
```# Usage
```javascript
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}$"
}
}
}
*/
```[npm-badge]: https://badge.fury.io/js/openapi-utils-param-to-schema.svg
[npm-url]: https://badge.fury.io/js/openapi-utils-param-to-schema
[travis-badge]: https://travis-ci.org/orangewise/openapi-utils-param-to-schema.svg?branch=master
[travis-url]: https://travis-ci.org/orangewise/openapi-utils-param-to-schema