swagger-enforcer
Advanced tools
Comparing version 1.3.7 to 1.3.8
@@ -21,3 +21,3 @@ /** | ||
module.exports = function(schema, definitions, options, value) { | ||
options = Object.assign({ defaultsUseParams: false, useTemplates: false }, options); | ||
options = Object.assign({ defaultsUseParams: false, ignoreMissingRequired: false, useTemplates: false }, options); | ||
@@ -24,0 +24,0 @@ if (arguments.length > 3) { |
@@ -35,2 +35,3 @@ /** | ||
module.exports = function (schema, definitions, params, options, initialValue) { | ||
if (!schema) schema = {}; | ||
if (!definitions) definitions = {}; | ||
@@ -46,3 +47,2 @@ if (!options) options = {}; | ||
console.log("TEMPLATE OPTIONS", options); | ||
if (options.useDefaults || options.useTemplates || options.useVariables) { | ||
@@ -64,2 +64,3 @@ return arguments.length < 5 | ||
defaultsUseParams: true, | ||
ignoreMissingRequired: true, | ||
useDefaults: true, | ||
@@ -253,7 +254,9 @@ useTemplates: true, | ||
// if missing a required then don't send back defaults (which may have caused the required error) | ||
const requiresLength = requires.length; | ||
for (let i = 0; i < requiresLength; i++) { | ||
if (!result.hasOwnProperty(requires[i])) { | ||
setDefault = false; | ||
break; | ||
if (!options.ignoreMissingRequired) { | ||
const requiresLength = requires.length; | ||
for (let i = 0; i < requiresLength; i++) { | ||
if (!result.hasOwnProperty(requires[i])) { | ||
setDefault = false; | ||
break; | ||
} | ||
} | ||
@@ -260,0 +263,0 @@ } |
{ | ||
"name": "swagger-enforcer", | ||
"version": "1.3.7", | ||
"version": "1.3.8", | ||
"description": "Automatically validate a value against the swagger schema while you build it. Alternatively you can validate the final value.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -269,4 +269,8 @@ [![Build Status](https://travis-ci.org/byu-oit/swagger-enforcer.svg?branch=master)](https://travis-ci.org/byu-oit/swagger-enforcer) | ||
- *defaultsUseParams* - If applying `useDefaults` is set to true and this property is set to true then parameter replacement will also be set for defaults. | ||
- *autoFormat* - Any value set using `x-variable` will will automatically by type cast and formatted when possible to match the schema. Defaults to `true`. | ||
- *defaultsUseParams* - If applying `useDefaults` is set to true and this property is set to true then parameter replacement will also be set for defaults. Defaults to `true`. | ||
- *ignoreMissingRequired* - If set to `false` and any requires are missing in the schema then that part of the template will not be stampped. Defaults to `true` | ||
- *replacement* - Set the parameter replacement style to one of `colon`, `doubleHandlebar`, `handlebar`, or a custom `Function`. Defaults to `handlebar`. | ||
@@ -276,3 +280,5 @@ | ||
- *useTemplates* - Set to `true` to use the `x-template` property to produce replacements | ||
- *useTemplates* - Set to `true` to use the `x-template` property to produce string replacements. Defaults to `true`. | ||
- *useVariables* - Set to `true` to use the `x-variable` property to place values. Defaults to `true`. | ||
@@ -301,2 +307,7 @@ * *initialValue* - An optional value to start building the object from. If provided it must match the schema's type. | ||
}, | ||
birthday: { | ||
type: 'string', | ||
format: 'date', | ||
'x-variable': 'birthday' | ||
}, | ||
roles: { | ||
@@ -313,2 +324,3 @@ type: 'array', | ||
const params = { | ||
birthday: new Date(), | ||
firstName: 'Bob', | ||
@@ -324,2 +336,3 @@ lastName: 'Smith' | ||
// lastName: 'Smith', | ||
// birthday: '2000-01-01' | ||
// roles: [] | ||
@@ -326,0 +339,0 @@ // } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
194401
3821
816