diff --git a/lib/exporters/baseraml.js b/lib/exporters/baseraml.js index 369f665f..5fef0b5e 100644 --- a/lib/exporters/baseraml.js +++ b/lib/exporters/baseraml.js @@ -368,8 +368,7 @@ RAML.prototype.convertRefFromModel = function(object) { object[id] = { type: 'string' }; - } - if (val.format == 'date') { + } else if (val.format == 'date') { object[id] = { type: 'date-only' }; @@ -378,7 +377,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: {}, diff --git a/test/data/swagger-import/raml/bitbucket.yaml b/test/data/swagger-import/raml/bitbucket.yaml index 503bdd22..d59b36d1 100644 --- a/test/data/swagger-import/raml/bitbucket.yaml +++ b/test/data/swagger-import/raml/bitbucket.yaml @@ -3681,42 +3681,36 @@ types: additionalProperties: false properties: href: - format: uri type: string type: object followers: additionalProperties: false properties: href: - format: uri type: string type: object following: additionalProperties: false properties: href: - format: uri type: string type: object html: additionalProperties: false properties: href: - format: uri type: string type: object repositories: additionalProperties: false properties: href: - format: uri type: string type: object self: additionalProperties: false properties: href: - format: uri type: string type: object type: object @@ -3791,7 +3785,6 @@ types: additionalProperties: false properties: href: - format: uri type: string type: object type: object @@ -3818,49 +3811,42 @@ types: additionalProperties: false properties: href: - format: uri type: string type: object comments: additionalProperties: false properties: href: - format: uri type: string type: object diff: additionalProperties: false properties: href: - format: uri type: string type: object html: additionalProperties: false properties: href: - format: uri type: string type: object patch: additionalProperties: false properties: href: - format: uri type: string type: object self: additionalProperties: false properties: href: - format: uri type: string type: object statuses: additionalProperties: false properties: href: - format: uri type: string type: object type: object @@ -3901,14 +3887,12 @@ types: additionalProperties: false properties: href: - format: uri type: string type: object self: additionalProperties: false properties: href: - format: uri type: string type: object type: object @@ -3952,7 +3936,6 @@ types: additionalProperties: false properties: href: - format: uri type: string type: object type: object @@ -3993,14 +3976,12 @@ types: additionalProperties: false properties: href: - format: uri type: string type: object self: additionalProperties: false properties: href: - format: uri type: string type: object type: object @@ -4117,42 +4098,36 @@ types: additionalProperties: false properties: href: - format: uri type: string type: object comments: additionalProperties: false properties: href: - format: uri type: string type: object html: additionalProperties: false properties: href: - format: uri type: string type: object self: additionalProperties: false properties: href: - format: uri type: string type: object vote: additionalProperties: false properties: href: - format: uri type: string type: object watch: additionalProperties: false properties: href: - format: uri type: string type: object type: object @@ -4212,7 +4187,6 @@ types: additionalProperties: false properties: href: - format: uri type: string type: object type: object @@ -4235,7 +4209,6 @@ types: additionalProperties: false properties: href: - format: uri type: string type: object type: object @@ -4257,7 +4230,6 @@ types: properties: next: description: Link to the next page if it exists. The last page of a collection does not have this value. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false page: @@ -4272,7 +4244,6 @@ types: required: false previous: description: Link to previous page if it exists. A collections first page does not have this value. This is an optional element that is not provided in all responses. Some result sets strictly support forward navigation and never provide previous links. Clients must anticipate that backwards navigation is not always available. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false size: @@ -4286,7 +4257,6 @@ types: properties: next: description: Link to the next page if it exists. The last page of a collection does not have this value. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false page: @@ -4301,7 +4271,6 @@ types: required: false previous: description: Link to previous page if it exists. A collections first page does not have this value. This is an optional element that is not provided in all responses. Some result sets strictly support forward navigation and never provide previous links. Clients must anticipate that backwards navigation is not always available. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false size: @@ -4322,7 +4291,6 @@ types: properties: next: description: Link to the next page if it exists. The last page of a collection does not have this value. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false page: @@ -4337,7 +4305,6 @@ types: required: false previous: description: Link to previous page if it exists. A collections first page does not have this value. This is an optional element that is not provided in all responses. Some result sets strictly support forward navigation and never provide previous links. Clients must anticipate that backwards navigation is not always available. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false size: @@ -4358,7 +4325,6 @@ types: properties: next: description: Link to the next page if it exists. The last page of a collection does not have this value. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false page: @@ -4373,7 +4339,6 @@ types: required: false previous: description: Link to previous page if it exists. A collections first page does not have this value. This is an optional element that is not provided in all responses. Some result sets strictly support forward navigation and never provide previous links. Clients must anticipate that backwards navigation is not always available. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false size: @@ -4394,7 +4359,6 @@ types: properties: next: description: Link to the next page if it exists. The last page of a collection does not have this value. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false page: @@ -4409,7 +4373,6 @@ types: required: false previous: description: Link to previous page if it exists. A collections first page does not have this value. This is an optional element that is not provided in all responses. Some result sets strictly support forward navigation and never provide previous links. Clients must anticipate that backwards navigation is not always available. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false size: @@ -4430,7 +4393,6 @@ types: properties: next: description: Link to the next page if it exists. The last page of a collection does not have this value. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false page: @@ -4445,7 +4407,6 @@ types: required: false previous: description: Link to previous page if it exists. A collections first page does not have this value. This is an optional element that is not provided in all responses. Some result sets strictly support forward navigation and never provide previous links. Clients must anticipate that backwards navigation is not always available. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false size: @@ -4465,7 +4426,6 @@ types: properties: next: description: Link to the next page if it exists. The last page of a collection does not have this value. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false page: @@ -4480,7 +4440,6 @@ types: required: false previous: description: Link to previous page if it exists. A collections first page does not have this value. This is an optional element that is not provided in all responses. Some result sets strictly support forward navigation and never provide previous links. Clients must anticipate that backwards navigation is not always available. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false size: @@ -4501,7 +4460,6 @@ types: properties: next: description: Link to the next page if it exists. The last page of a collection does not have this value. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false page: @@ -4516,7 +4474,6 @@ types: required: false previous: description: Link to previous page if it exists. A collections first page does not have this value. This is an optional element that is not provided in all responses. Some result sets strictly support forward navigation and never provide previous links. Clients must anticipate that backwards navigation is not always available. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false size: @@ -4537,7 +4494,6 @@ types: properties: next: description: Link to the next page if it exists. The last page of a collection does not have this value. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false page: @@ -4552,7 +4508,6 @@ types: required: false previous: description: Link to previous page if it exists. A collections first page does not have this value. This is an optional element that is not provided in all responses. Some result sets strictly support forward navigation and never provide previous links. Clients must anticipate that backwards navigation is not always available. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false size: @@ -4573,7 +4528,6 @@ types: properties: next: description: Link to the next page if it exists. The last page of a collection does not have this value. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false page: @@ -4588,7 +4542,6 @@ types: required: false previous: description: Link to previous page if it exists. A collections first page does not have this value. This is an optional element that is not provided in all responses. Some result sets strictly support forward navigation and never provide previous links. Clients must anticipate that backwards navigation is not always available. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false size: @@ -4609,7 +4562,6 @@ types: properties: next: description: Link to the next page if it exists. The last page of a collection does not have this value. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false page: @@ -4624,7 +4576,6 @@ types: required: false previous: description: Link to previous page if it exists. A collections first page does not have this value. This is an optional element that is not provided in all responses. Some result sets strictly support forward navigation and never provide previous links. Clients must anticipate that backwards navigation is not always available. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false size: @@ -4645,7 +4596,6 @@ types: properties: next: description: Link to the next page if it exists. The last page of a collection does not have this value. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false page: @@ -4660,7 +4610,6 @@ types: required: false previous: description: Link to previous page if it exists. A collections first page does not have this value. This is an optional element that is not provided in all responses. Some result sets strictly support forward navigation and never provide previous links. Clients must anticipate that backwards navigation is not always available. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false size: @@ -4680,7 +4629,6 @@ types: properties: next: description: Link to the next page if it exists. The last page of a collection does not have this value. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false page: @@ -4695,7 +4643,6 @@ types: required: false previous: description: Link to previous page if it exists. A collections first page does not have this value. This is an optional element that is not provided in all responses. Some result sets strictly support forward navigation and never provide previous links. Clients must anticipate that backwards navigation is not always available. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false size: @@ -4716,7 +4663,6 @@ types: properties: next: description: Link to the next page if it exists. The last page of a collection does not have this value. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false page: @@ -4731,7 +4677,6 @@ types: required: false previous: description: Link to previous page if it exists. A collections first page does not have this value. This is an optional element that is not provided in all responses. Some result sets strictly support forward navigation and never provide previous links. Clients must anticipate that backwards navigation is not always available. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false size: @@ -4752,7 +4697,6 @@ types: properties: next: description: Link to the next page if it exists. The last page of a collection does not have this value. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false page: @@ -4767,7 +4711,6 @@ types: required: false previous: description: Link to previous page if it exists. A collections first page does not have this value. This is an optional element that is not provided in all responses. Some result sets strictly support forward navigation and never provide previous links. Clients must anticipate that backwards navigation is not always available. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false size: @@ -4788,7 +4731,6 @@ types: properties: next: description: Link to the next page if it exists. The last page of a collection does not have this value. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false page: @@ -4803,7 +4745,6 @@ types: required: false previous: description: Link to previous page if it exists. A collections first page does not have this value. This is an optional element that is not provided in all responses. Some result sets strictly support forward navigation and never provide previous links. Clients must anticipate that backwards navigation is not always available. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false size: @@ -4824,7 +4765,6 @@ types: properties: next: description: Link to the next page if it exists. The last page of a collection does not have this value. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false page: @@ -4839,7 +4779,6 @@ types: required: false previous: description: Link to previous page if it exists. A collections first page does not have this value. This is an optional element that is not provided in all responses. Some result sets strictly support forward navigation and never provide previous links. Clients must anticipate that backwards navigation is not always available. Use this link to navigate the result set and refrain from constructing your own URLs. - format: uri type: string required: false size: @@ -4902,14 +4841,12 @@ types: additionalProperties: false properties: href: - format: uri type: string type: object html: additionalProperties: false properties: href: - format: uri type: string type: object type: object @@ -4947,63 +4884,54 @@ types: additionalProperties: false properties: href: - format: uri type: string type: object approve: additionalProperties: false properties: href: - format: uri type: string type: object comments: additionalProperties: false properties: href: - format: uri type: string type: object commits: additionalProperties: false properties: href: - format: uri type: string type: object decline: additionalProperties: false properties: href: - format: uri type: string type: object diff: additionalProperties: false properties: href: - format: uri type: string type: object html: additionalProperties: false properties: href: - format: uri type: string type: object merge: additionalProperties: false properties: href: - format: uri type: string type: object self: additionalProperties: false properties: href: - format: uri type: string type: object type: object @@ -5069,70 +4997,60 @@ types: additionalProperties: false properties: href: - format: uri type: string type: object clone: additionalProperties: false properties: href: - format: uri type: string type: object commits: additionalProperties: false properties: href: - format: uri type: string type: object downloads: additionalProperties: false properties: href: - format: uri type: string type: object forks: additionalProperties: false properties: href: - format: uri type: string type: object hooks: additionalProperties: false properties: href: - format: uri type: string type: object html: additionalProperties: false properties: href: - format: uri type: string type: object pullrequests: additionalProperties: false properties: href: - format: uri type: string type: object self: additionalProperties: false properties: href: - format: uri type: string type: object watchers: additionalProperties: false properties: href: - format: uri type: string type: object type: object @@ -5214,14 +5132,12 @@ types: additionalProperties: false properties: href: - format: uri type: string type: object self: additionalProperties: false properties: href: - format: uri type: string type: object type: object @@ -5241,21 +5157,18 @@ types: additionalProperties: false properties: href: - format: uri type: string type: object html: additionalProperties: false properties: href: - format: uri type: string type: object self: additionalProperties: false properties: href: - format: uri type: string type: object type: object @@ -5276,7 +5189,6 @@ types: additionalProperties: false properties: href: - format: uri type: string type: object type: object @@ -5288,7 +5200,6 @@ types: additionalProperties: false properties: href: - format: uri type: string type: object type: object @@ -5300,7 +5211,6 @@ types: additionalProperties: false properties: href: - format: uri type: string type: object type: object @@ -5328,7 +5238,6 @@ types: additionalProperties: false properties: href: - format: uri type: string type: object type: object @@ -5395,7 +5304,6 @@ types: required: false url: description: The URL events get delivered to. - format: uri type: string required: false uuid: