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 6.1.1 to 6.2.0

0

index.d.ts

@@ -0,0 +0,0 @@ import { Schema } from 'joi';

10

index.js

@@ -108,2 +108,8 @@ 'use strict';

function getRefValue (ref, schema, fallback) {
const refValues = meta(schema, 'refValues') || {};
const refKey = ref.toString().replace(/^ref:/, '');
return refValues[refKey] || fallback;
}
const parseAsType = {

@@ -135,3 +141,3 @@ number: (schema) => {

if (min) {
swagger.minimum = min.args.limit;
swagger.minimum = joi.isRef(min.args.limit) ? getRefValue(min.args.limit, schema, 0) : min.args.limit;
}

@@ -141,3 +147,3 @@

if (max) {
swagger.maximum = max.args.limit;
swagger.maximum = joi.isRef(max.args.limit) ? getRefValue(max.args.limit, schema, 0) : max.args.limit;
}

@@ -144,0 +150,0 @@

@@ -0,0 +0,0 @@ joi-to-swagger

{
"name": "joi-to-swagger",
"version": "6.1.1",
"version": "6.2.0",
"description": "Conversion library for transforming joi schema objects into swagger / OpenApi OAS 3.0 schema definitions.",

@@ -35,6 +35,6 @@ "main": "index.js",

"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.0.0",
"joi": "^17.6.0",
"eslint-plugin-promise": "^6.1.1",
"joi": "^17.7.0",
"@joi/date": "^2.1.0",
"tap": "^16.3.0",
"tap": "^16.3.2",
"tapsuite": "^2.0.1"

@@ -41,0 +41,0 @@ },

@@ -87,4 +87,4 @@ joi-to-swagger

- `.allow(null)` -> `"nullable": true`
- `.min(5)` -> `"minimum": 5`
- `.max(10)` -> `"maximum": 10`
- `.min(5)` -> `"minimum": 5` (joi.ref is supported and will fallback to 0 if not provided via refValues metadata)
- `.max(10)` -> `"maximum": 10` (joi.ref is supported and will fallback to 0 if not provided via refValues metadata)
- `.positive()` -> `"minimum": 1`

@@ -174,2 +174,11 @@ - `.negative()` -> `"maximum": -1`

**refValues**: The possibility to give exact values when using joi.ref()
```
joi.object({
durationFrom: joi.number().integer().min(5).max(10),
durationTo: joi.number().integer().min(joi.ref('durationFrom')).max(20)
.meta({ refValues: { durationFrom: 5 } }),
})
```
## Custom Types (joi.extend)

@@ -176,0 +185,0 @@

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