From 2efb78ffd9a909a14729b4f8b74eb23de9336ada Mon Sep 17 00:00:00 2001 From: Gaston Lodieu Date: Wed, 5 Oct 2016 11:04:46 -0300 Subject: [PATCH] closes #32 --- lib/exporters/baseraml.js | 9 ++++++--- lib/helpers/raml.js | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/exporters/baseraml.js b/lib/exporters/baseraml.js index da901588..9f100b21 100644 --- a/lib/exporters/baseraml.js +++ b/lib/exporters/baseraml.js @@ -365,8 +365,7 @@ RAML.prototype.convertRefFromModel = function(object) { object[id] = { type: 'string' }; - } - if (val.format == 'date') { + } else if (val.format == 'date') { object[id] = { type: 'date-only' }; @@ -375,7 +374,11 @@ RAML.prototype.convertRefFromModel = function(object) { type: 'datetime', format: 'rfc3339' }; - } + } else { //remove invalid format. + if (ramlHelper.getValidFormat.indexOf(val.format) < 0) { + delete object[id].format; + } + } } else { object[id] = this.convertRefFromModel(val); } diff --git a/lib/helpers/raml.js b/lib/helpers/raml.js index 5c6075a1..43191706 100644 --- a/lib/helpers/raml.js +++ b/lib/helpers/raml.js @@ -3,6 +3,8 @@ var _ = require('lodash'); module.exports = { getScalarTypes: ['string', 'number', 'integer', 'boolean', 'date', 'datetime', 'date-only', 'file', 'array', 'nilValue'], + + getValidFormat: [ 'byte', 'binary', 'password', 'date', 'date-time' ], parameterMappings: {},