openapi-utils-schema-from-api
Version:
Extract schema from openapi definition
37 lines (28 loc) • 701 B
Markdown
# openapi-utils-schema-from-api
[](http://standardjs.com/)
Extract schema from openapi definition.
# Installation
```
npm install --save openapi-utils-schema-from-api
```
# Usage
```javascript
var openApiUtils = require('openapi-utils-schema-from-api')
var api = {
"definitions": {
"Cat": {
"type": "object",
"properties": {
"id": {
"type": "string"
}
}
}
}
}
var schema = openApiUtils.schemaFromApi(api, { 'schema': { '$ref': '#/definitions/Cat' } } )
console.log(schema)
/*
{ type: 'object', properties: { id: { type: 'string' } } }
*/
```