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