|
| 1 | +import testRule from './__helpers__/testRule'; |
| 2 | +import { DiagnosticSeverity } from '@stoplight/types'; |
| 3 | + |
| 4 | +testRule('xgen-IPA-117-description-should-not-use-inline-tables', [ |
| 5 | + { |
| 6 | + name: 'valid description', |
| 7 | + document: { |
| 8 | + components: { |
| 9 | + schemas: { |
| 10 | + Schema: { |
| 11 | + properties: { |
| 12 | + valid: { |
| 13 | + description: 'Description.', |
| 14 | + }, |
| 15 | + validWithVerticalBar: { |
| 16 | + description: 'Must be true | false', |
| 17 | + }, |
| 18 | + }, |
| 19 | + }, |
| 20 | + }, |
| 21 | + }, |
| 22 | + }, |
| 23 | + errors: [], |
| 24 | + }, |
| 25 | + { |
| 26 | + name: 'invalid descriptions', |
| 27 | + document: { |
| 28 | + components: { |
| 29 | + schemas: { |
| 30 | + Schema: { |
| 31 | + properties: { |
| 32 | + table: { |
| 33 | + description: '|Title|\n|-----|\n|Description|', |
| 34 | + }, |
| 35 | + tableLeftAlignment: { |
| 36 | + description: '|Title|\n|:-----|\n|Description|', |
| 37 | + }, |
| 38 | + tableCenterAlignment: { |
| 39 | + description: '|Title|\n|:-----:|\n|Description|', |
| 40 | + }, |
| 41 | + tableRightAlignment: { |
| 42 | + description: '|Title|\n|-----:|\n|Description|', |
| 43 | + }, |
| 44 | + largeTable: { |
| 45 | + description: '|Title|H1|H2|H3\n|-----|\n|Description|Description1|Description2|Description3|', |
| 46 | + }, |
| 47 | + }, |
| 48 | + }, |
| 49 | + }, |
| 50 | + }, |
| 51 | + }, |
| 52 | + errors: [ |
| 53 | + { |
| 54 | + code: 'xgen-IPA-117-description-should-not-use-inline-tables', |
| 55 | + message: |
| 56 | + 'Descriptions should not include inline tables. Tables may not work well with all tools, in particular generated client code.', |
| 57 | + path: ['components', 'schemas', 'Schema', 'properties', 'table'], |
| 58 | + severity: DiagnosticSeverity.Warning, |
| 59 | + }, |
| 60 | + { |
| 61 | + code: 'xgen-IPA-117-description-should-not-use-inline-tables', |
| 62 | + message: |
| 63 | + 'Descriptions should not include inline tables. Tables may not work well with all tools, in particular generated client code.', |
| 64 | + path: ['components', 'schemas', 'Schema', 'properties', 'tableLeftAlignment'], |
| 65 | + severity: DiagnosticSeverity.Warning, |
| 66 | + }, |
| 67 | + { |
| 68 | + code: 'xgen-IPA-117-description-should-not-use-inline-tables', |
| 69 | + message: |
| 70 | + 'Descriptions should not include inline tables. Tables may not work well with all tools, in particular generated client code.', |
| 71 | + path: ['components', 'schemas', 'Schema', 'properties', 'tableCenterAlignment'], |
| 72 | + severity: DiagnosticSeverity.Warning, |
| 73 | + }, |
| 74 | + { |
| 75 | + code: 'xgen-IPA-117-description-should-not-use-inline-tables', |
| 76 | + message: |
| 77 | + 'Descriptions should not include inline tables. Tables may not work well with all tools, in particular generated client code.', |
| 78 | + path: ['components', 'schemas', 'Schema', 'properties', 'tableRightAlignment'], |
| 79 | + severity: DiagnosticSeverity.Warning, |
| 80 | + }, |
| 81 | + { |
| 82 | + code: 'xgen-IPA-117-description-should-not-use-inline-tables', |
| 83 | + message: |
| 84 | + 'Descriptions should not include inline tables. Tables may not work well with all tools, in particular generated client code.', |
| 85 | + path: ['components', 'schemas', 'Schema', 'properties', 'largeTable'], |
| 86 | + severity: DiagnosticSeverity.Warning, |
| 87 | + }, |
| 88 | + ], |
| 89 | + }, |
| 90 | + { |
| 91 | + name: 'invalid descriptions with exceptions', |
| 92 | + document: { |
| 93 | + components: { |
| 94 | + schemas: { |
| 95 | + Schema: { |
| 96 | + properties: { |
| 97 | + table: { |
| 98 | + description: '|Title|\n|-----|\n|Description|', |
| 99 | + 'x-xgen-IPA-exception': { |
| 100 | + 'xgen-IPA-117-description-should-not-use-inline-tables': 'reason', |
| 101 | + }, |
| 102 | + }, |
| 103 | + tableLeftAlignment: { |
| 104 | + description: '|Title|\n|:-----|\n|Description|', |
| 105 | + 'x-xgen-IPA-exception': { |
| 106 | + 'xgen-IPA-117-description-should-not-use-inline-tables': 'reason', |
| 107 | + }, |
| 108 | + }, |
| 109 | + tableCenterAlignment: { |
| 110 | + description: '|Title|\n|:-----:|\n|Description|', |
| 111 | + 'x-xgen-IPA-exception': { |
| 112 | + 'xgen-IPA-117-description-should-not-use-inline-tables': 'reason', |
| 113 | + }, |
| 114 | + }, |
| 115 | + tableRightAlignment: { |
| 116 | + description: '|Title|\n|-----:|\n|Description|', |
| 117 | + 'x-xgen-IPA-exception': { |
| 118 | + 'xgen-IPA-117-description-should-not-use-inline-tables': 'reason', |
| 119 | + }, |
| 120 | + }, |
| 121 | + largeTable: { |
| 122 | + description: '|Title|H1|H2|H3\n|--------------|\n|Description|Description1|Description2|Description3|', |
| 123 | + 'x-xgen-IPA-exception': { |
| 124 | + 'xgen-IPA-117-description-should-not-use-inline-tables': 'reason', |
| 125 | + }, |
| 126 | + }, |
| 127 | + }, |
| 128 | + }, |
| 129 | + }, |
| 130 | + }, |
| 131 | + }, |
| 132 | + errors: [], |
| 133 | + }, |
| 134 | +]); |
0 commit comments