Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/yolopunk/joi2json
- Owner: yolopunk
- Created: 2018-01-03T03:42:38.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-07-11T01:57:49.000Z (over 1 year ago)
- Last Synced: 2024-09-19T13:08:45.039Z (3 months ago)
- Topics: joi, json-schema
- Language: JavaScript
- Homepage:
- Size: 287 KB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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)
```