@@ -68,69 +68,51 @@ module.exports.validate = function({ resolvedSpec }, config) {
6868 // - paths that do not end with param has a GET and POST operation
6969 // - paths that end with param has a GET, DELETE, POST, PUT or PATCH.
7070
71- let checkPassed = true ;
7271 const verbs = [ ] ;
7372
7473 if ( ! pathEndsWithParam ) {
7574 // operationId for GET should starts with "list"
76- if ( opKey === 'get' && ! operationId . match ( / ^ l i s t [ a - z A - Z 0 - 9 _ ] + / m) ) {
77- checkPassed = false ;
75+ if ( opKey === 'get' ) {
7876 verbs . push ( 'list' ) ;
7977 }
80-
8178 // operationId for POST should starts with "create" or "add"
82- else if (
83- opKey === 'post' &&
84- ! operationId . match ( / ^ ( a d d | c r e a t e ) [ a - z A - Z 0 - 9 _ ] + / m)
85- ) {
86- checkPassed = false ;
79+ else if ( opKey === 'post' ) {
8780 verbs . push ( 'add' ) ;
8881 verbs . push ( 'create' ) ;
8982 }
9083 } else {
9184 // operationId for GET should starts with "get"
92- if ( opKey === 'get' && ! operationId . match ( / ^ g e t [ a - z A - Z 0 - 9 _ ] + / m) ) {
93- checkPassed = false ;
85+ if ( opKey === 'get' ) {
9486 verbs . push ( 'get' ) ;
9587 }
96-
9788 // operationId for DELETE should starts with "delete"
98- else if (
99- opKey === 'delete' &&
100- ! operationId . match ( / ^ d e l e t e [ a - z A - Z 0 - 9 _ ] + / m)
101- ) {
102- checkPassed = false ;
89+ else if ( opKey === 'delete' ) {
10390 verbs . push ( 'delete' ) ;
10491 }
105-
10692 // operationId for PATCH should starts with "update"
107- else if (
108- opKey === 'patch' &&
109- ! operationId . match ( / ^ u p d a t e [ a - z A - Z 0 - 9 _ ] + / m)
110- ) {
111- checkPassed = false ;
93+ else if ( opKey === 'patch' ) {
11294 verbs . push ( 'update' ) ;
113- } else if ( opKey === 'post' ) {
114- // If PATCH operation doesn't exist for path, POST operationId should start with "update"
115- if (
116- ! allPathOperations . includes ( 'patch' ) &&
117- ! operationId . match ( / ^ u p d a t e [ a - z A - Z 0 - 9 _ ] + / m)
118- ) {
119- checkPassed = false ;
95+ }
96+ // If PATCH operation doesn't exist for path, POST operationId should start with "update"
97+ else if ( opKey === 'post' ) {
98+ if ( ! allPathOperations . includes ( 'patch' ) ) {
12099 verbs . push ( 'update' ) ;
121100 }
122101 }
123-
124102 // operationId for PUT should starts with "replace"
125- else if (
126- opKey === 'put' &&
127- ! operationId . match ( / ^ r e p l a c e [ a - z A - Z 0 - 9 _ ] + / m)
128- ) {
129- checkPassed = false ;
103+ else if ( opKey === 'put' ) {
130104 verbs . push ( 'replace' ) ;
131105 }
132106 }
133- return { checkPassed, verbs } ;
107+
108+ if ( verbs . length > 0 ) {
109+ const checkPassed = verbs
110+ . map ( verb => operationId . startsWith ( verb ) )
111+ . some ( v => v ) ;
112+ return { checkPassed, verbs } ;
113+ }
114+
115+ return { checkPassed : true } ;
134116 } ;
135117
136118 operations . forEach ( op => {
0 commit comments