|
| 1 | +import testRule from './__helpers__/testRule'; |
| 2 | +import { DiagnosticSeverity } from '@stoplight/types'; |
| 3 | + |
| 4 | +testRule('xgen-IPA-109-custom-method-must-be-GET-or-POST', [ |
| 5 | + { |
| 6 | + name: 'valid methods', |
| 7 | + document: { |
| 8 | + paths: { |
| 9 | + '/a/{exampleId}:method': { |
| 10 | + post: {}, |
| 11 | + }, |
| 12 | + '/a:method': { |
| 13 | + post: {}, |
| 14 | + }, |
| 15 | + '/b/{exampleId}:method': { |
| 16 | + get: {}, |
| 17 | + }, |
| 18 | + '/b:method': { |
| 19 | + get: {}, |
| 20 | + }, |
| 21 | + '/c/{exampleId}:method': { |
| 22 | + get: {}, |
| 23 | + 'x-xgen-IPA-exception': {}, |
| 24 | + }, |
| 25 | + '/c:method': { |
| 26 | + get: {}, |
| 27 | + 'x-xgen-IPA-exception': {}, |
| 28 | + }, |
| 29 | + }, |
| 30 | + }, |
| 31 | + errors: [], |
| 32 | + }, |
| 33 | + { |
| 34 | + name: 'invalid methods', |
| 35 | + document: { |
| 36 | + paths: { |
| 37 | + '/a/{exampleId}:method': { |
| 38 | + put: {}, |
| 39 | + }, |
| 40 | + '/a:method': { |
| 41 | + put: {}, |
| 42 | + }, |
| 43 | + '/b/{exampleId}:method': { |
| 44 | + get: {}, |
| 45 | + put: {}, |
| 46 | + }, |
| 47 | + '/b:method': { |
| 48 | + get: {}, |
| 49 | + put: {}, |
| 50 | + }, |
| 51 | + '/c/{exampleId}:method': { |
| 52 | + post: {}, |
| 53 | + get: {}, |
| 54 | + put: {}, |
| 55 | + }, |
| 56 | + '/c:method': { |
| 57 | + post: {}, |
| 58 | + get: {}, |
| 59 | + put: {}, |
| 60 | + }, |
| 61 | + '/d/{exampleId}:method': { |
| 62 | + post: {}, |
| 63 | + get: {}, |
| 64 | + }, |
| 65 | + '/d:method': { |
| 66 | + post: {}, |
| 67 | + get: {}, |
| 68 | + }, |
| 69 | + }, |
| 70 | + }, |
| 71 | + errors: [ |
| 72 | + { |
| 73 | + code: 'xgen-IPA-109-custom-method-must-be-GET-or-POST', |
| 74 | + message: 'The HTTP method for custom methods must be GET or POST. http://go/ipa/109', |
| 75 | + path: ['paths', '/a/{exampleId}:method'], |
| 76 | + severity: DiagnosticSeverity.Warning, |
| 77 | + }, |
| 78 | + { |
| 79 | + code: 'xgen-IPA-109-custom-method-must-be-GET-or-POST', |
| 80 | + message: 'The HTTP method for custom methods must be GET or POST. http://go/ipa/109', |
| 81 | + path: ['paths', '/a:method'], |
| 82 | + severity: DiagnosticSeverity.Warning, |
| 83 | + }, |
| 84 | + { |
| 85 | + code: 'xgen-IPA-109-custom-method-must-be-GET-or-POST', |
| 86 | + message: 'The HTTP method for custom methods must be GET or POST. http://go/ipa/109', |
| 87 | + path: ['paths', '/b/{exampleId}:method'], |
| 88 | + severity: DiagnosticSeverity.Warning, |
| 89 | + }, |
| 90 | + { |
| 91 | + code: 'xgen-IPA-109-custom-method-must-be-GET-or-POST', |
| 92 | + message: 'The HTTP method for custom methods must be GET or POST. http://go/ipa/109', |
| 93 | + path: ['paths', '/b:method'], |
| 94 | + severity: DiagnosticSeverity.Warning, |
| 95 | + }, |
| 96 | + { |
| 97 | + code: 'xgen-IPA-109-custom-method-must-be-GET-or-POST', |
| 98 | + message: 'The HTTP method for custom methods must be GET or POST. http://go/ipa/109', |
| 99 | + path: ['paths', '/c/{exampleId}:method'], |
| 100 | + severity: DiagnosticSeverity.Warning, |
| 101 | + }, |
| 102 | + { |
| 103 | + code: 'xgen-IPA-109-custom-method-must-be-GET-or-POST', |
| 104 | + message: 'The HTTP method for custom methods must be GET or POST. http://go/ipa/109', |
| 105 | + path: ['paths', '/c:method'], |
| 106 | + severity: DiagnosticSeverity.Warning, |
| 107 | + }, |
| 108 | + { |
| 109 | + code: 'xgen-IPA-109-custom-method-must-be-GET-or-POST', |
| 110 | + message: 'The HTTP method for custom methods must be GET or POST. http://go/ipa/109', |
| 111 | + path: ['paths', '/d/{exampleId}:method'], |
| 112 | + severity: DiagnosticSeverity.Warning, |
| 113 | + }, |
| 114 | + { |
| 115 | + code: 'xgen-IPA-109-custom-method-must-be-GET-or-POST', |
| 116 | + message: 'The HTTP method for custom methods must be GET or POST. http://go/ipa/109', |
| 117 | + path: ['paths', '/d:method'], |
| 118 | + severity: DiagnosticSeverity.Warning, |
| 119 | + }, |
| 120 | + ], |
| 121 | + }, |
| 122 | +]); |
0 commit comments