0.0.5 • Published 2 years ago

@kenyip/joi v0.0.5

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
2 years ago

@kenyip/joi

Forked from joi (version 14.3.1). Adding some convenient functions like removeKey, toSwagger ... etc

Installation

// Using NPM
$ npm i @kenyip/joi --save
// Using Yarn
$ yarn add @kenyip/joi

Plugins

A list of plugins added into Joi framework

toSwagger

Convert the Joi schema objects into Swagger OAS 3.0 schema definitions. The library is cloned from joi-to-swagger with a little bit modification. Click here for the usage and the support conventions.

const object = Joi.object({
		hello: Joi.string(),
		world: Joi.string()
});

console.log(JSON.stringify(objectA.toSwagger(), null, 4));

{
	"type": "object",
	"properties": {
		"hello": {
			"type": "string"
		},
		"world": {
			"type": "string"
		}
	}
}

remove

Remove keys from the existing schema

const objectA = Joi.object({
		hello: Joi.string(),
		world: Joi.string(),
});

const objectB = objectA
		.keys({ foo: Joi.string() })
		.remove(["hello"]);

console.log(JSON.stringify(objectB.toSwagger(), null, 4));

// {
// 	"type": "object",
// 	"properties": {
// 		"world": {
// 			"type": "string"
// 		},
// 		"foo": {
// 			"type": "string"
// 		}
// 	}
// }
0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago