Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/yolopunk/joi2json

Joi ⇄ JSON-Schema Converter
https://github.com/yolopunk/joi2json

joi json-schema

Last synced: about 2 months ago
JSON representation

Joi ⇄ JSON-Schema Converter

Awesome Lists containing this project

README

        

# Joi ⇄ JSON-Schema Converter

[![JavaScript Style Guide][style-image]][style-url]
[![Build Status][travis-image]][travis-url]
[![npm download][download-image]][download-url]

[style-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
[style-url]: https://standardjs.com
[travis-image]: https://travis-ci.org/yolopunk/joi2json.svg?branch=master
[travis-url]: https://travis-ci.org/yolopunk/joi2json
[download-image]: https://img.shields.io/npm/dm/joi2json.svg?style=flat-square
[download-url]: https://npmjs.org/package/joi2json

[JSON Schema](https://github.com/json-schema-org/json-schema-spec) and [Joi](https://github.com/hapijs/joi) converter
Forked from [joi-to-json-schema](https://github.com/lightsofapollo/joi-to-json-schema) and [enjoi](https://github.com/tlivings/enjoi)

## Install
```bash
$ npm install joi2json --save
```

## Usage
```js
const parser = require('joi2json')

const schema = {
"title": "Person",
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"description": "Age in years",
"type": "integer",
"minimum": 0
}
},
"required": ["firstName", "lastName"]
}

// JSON Schema to Joi
const joiObj = parser.enjoi(schema)

// Joi to JSON Schema
const jsonSchema = parser.dejoi(joiObj)
```