Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

joi-to-swagger

Package Overview
Dependencies
Maintainers
2
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

joi-to-swagger - npm Package Compare versions

Comparing version 5.2.0 to 6.0.0

11

CHANGELOG.md

@@ -0,5 +1,14 @@

6.0.0 / 2021-07-30
=================
BREAKING CHANGE: override will now also be applied if className is used
BREAKING CHANGE: swaggerOverride will not ignore className anymore
* result object will always contain components object now
* Add support for @joi/date usage with format YYYY-MM-DD (thanks @vikaskanani)
* update dependencies
5.2.0 / 2020-12-29
==================
* Add option to override the Joi schema which generates swagger.
* Add option to override the Joi schema which generates swagger (thanks @melchii)

@@ -6,0 +15,0 @@ 5.1.0 / 2020-10-17

37

index.js

@@ -194,3 +194,9 @@ 'use strict';

},
date: (/* schema */) => ({ type: 'string', format: 'date-time' }),
date: (schema) => {
const swagger = { type: 'string', format: 'date-time' };
if (get(schema, '_flags.format') === 'YYYY-MM-DD') {
swagger.format = 'date';
}
return swagger;
},
boolean: (/* schema */) => ({ type: 'boolean' }),

@@ -326,14 +332,23 @@ alternatives: (schema, existingComponents, newComponentsByRef) => {

const components = {};
const metaDefName = flattenMeta.className;
const metaDefType = flattenMeta.classTarget || 'schemas';
const getReturnValue = (swagger) => {
if (metaDefName) {
set(components, [ metaDefType, metaDefName ], swagger);
return { swagger: refDef(metaDefType, metaDefName), components };
}
return { swagger, components };
};
const override = flattenMeta.swagger;
if (override && flattenMeta.swaggerOverride) {
return { swagger: override, components: {} };
return getReturnValue(override);
}
const metaDefName = flattenMeta.className;
const metaDefType = flattenMeta.classTarget || 'schemas';
// if the schema has a definition class name, and that
// definition is already defined, just use that definition
if (metaDefName && get(existingComponents, [ metaDefType, metaDefName ])) {
return { swagger: refDef(metaDefType, metaDefName) };
return { swagger: refDef(metaDefType, metaDefName), components };
}

@@ -351,4 +366,3 @@

const components = {};
const swagger = parseAsType[type](schema, existingComponents, components);
const swagger = parseAsType[type](schema, existingComponents, components);
if (get(schema, '$_terms.whens')) {

@@ -387,7 +401,2 @@ Object.assign(swagger, parseWhens(schema, existingComponents, components));

if (metaDefName) {
set(components, [ metaDefType, metaDefName ], swagger);
return { swagger: refDef(metaDefType, metaDefName), components };
}
if (override) {

@@ -397,3 +406,3 @@ Object.assign(swagger, override);

return { swagger, components };
return getReturnValue(swagger);
}

@@ -400,0 +409,0 @@

{
"name": "joi-to-swagger",
"version": "5.2.0",
"description": "",
"version": "6.0.0",
"description": "Conversion library for transforming joi schema objects into swagger / OpenApi OAS 3.0 schema definitions.",
"main": "index.js",

@@ -9,2 +9,3 @@ "types": "index.d.ts",

"test": "tap tests.js",
"test:coverage:html": "tap --coverage-report=html tests.js",
"test:debug": "tap --node-arg=--inspect --no-timeout tests.js",

@@ -37,3 +38,4 @@ "test:travis": "tap --reporter=tap tests.js",

"joi": "^17.2.0",
"tap": "^14.7.3",
"@joi/date": "^2.1.0",
"tap": "^15.0.9",
"tapsuite": "^2.0.1"

@@ -49,4 +51,4 @@ },

"dependencies": {
"lodash": "^4.17.20"
"lodash": "^4.17.21"
}
}

@@ -9,3 +9,3 @@ joi-to-swagger

Conversion library for transforming [Joi](http://npm.im/joi) schema objects into [Swagger](http://swagger.io) schema definitions.
Conversion library for transforming [Joi](http://npm.im/joi) schema objects into [Swagger](http://swagger.io) OAS 3.0 schema definitions.

@@ -12,0 +12,0 @@ ```js

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc