joi-openapi

3.2.1 • Public • Published

joi-openapi

This is a fork of joi-to-openapi with some new options. In short, in this package I've added joi extensions as supported type.

Now the library support to outputs for converted joi: standard output and file.

examples

const Joi = require("joi");
const { convert } = require("joi-openapi");

let joi = Joi.extend((joi) => ({
  base: joi
    .string()
    .isoDate()
    .description("Date in ISO format"),
  name: "date_start",
  language: {},
  rules: [],
}));

console.log(convert(joi.date_start()));

will output

{
  "type": "string",
  "format": "date-time",
  "description": "Date in ISO format"
}

to write the output on a file

const Joi = require("joi");
const { convertToFile } = require("joi-openapi");

let joi = Joi.extend((joi) => ({
  base: joi
    .string()
    .isoDate()
    .description("Date in ISO format"),
  name: "date_start",
  language: {},
  rules: [],
}));

convertToFile(joi.date_start(), "./");

will output

{
  "type": "string",
  "format": "date-time",
  "description": "Date in ISO format"
}

in the date_start.json file (the file will be created by joi type plust json format).

Package Sidebar

Install

npm i joi-openapi

Weekly Downloads

354

Version

3.2.1

License

MIT

Unpacked Size

251 kB

Total Files

52

Last publish

Collaborators

  • sdrubolo