mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Change validation input when version is 3.1.x
if the option includeWebhooks is false and there are no paths (only webhooks or componentes) throw error.
This commit is contained in:
@@ -6,10 +6,11 @@ module.exports = {
|
||||
* OpenAPI 3.1 only openapi and info are always required,
|
||||
* but the document must also contain at least one of paths or webhooks or components.
|
||||
* @param {Object} spec OpenAPI spec
|
||||
* @param {Object} options computed process options
|
||||
* @return {Object} Validation result
|
||||
*/
|
||||
validateSpec: function (spec) {
|
||||
|
||||
validateSpec: function (spec, options) {
|
||||
const includeWebhooksOption = options.includeWebhooks;
|
||||
if (!spec.hasOwnProperty('openapi')) {
|
||||
return {
|
||||
result: false,
|
||||
@@ -24,7 +25,15 @@ module.exports = {
|
||||
};
|
||||
}
|
||||
|
||||
if (!spec.hasOwnProperty('paths') && !spec.hasOwnProperty('webhooks') && !spec.hasOwnProperty('components')) {
|
||||
if (!spec.hasOwnProperty('paths') && !includeWebhooksOption) {
|
||||
return {
|
||||
result: false,
|
||||
reason: 'Specification must contain Paths Object for the available operational paths'
|
||||
};
|
||||
}
|
||||
|
||||
if (includeWebhooksOption && !spec.hasOwnProperty('paths') &&
|
||||
!spec.hasOwnProperty('webhooks') && !spec.hasOwnProperty('components')) {
|
||||
return {
|
||||
result: false,
|
||||
reason: 'Specification must contain either Paths, Webhooks or Components sections'
|
||||
|
||||
Reference in New Issue
Block a user