Skip to content

Commit 150f63c

Browse files
Merge branch 'main' into CLOUDP-308270
2 parents b9d5607 + 34ca221 commit 150f63c

11 files changed

+287
-4
lines changed

tools/spectral/ipa/__tests__/IPA117DescriptionEndsWithPeriod.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ testRule('xgen-IPA-117-description-ends-with-period', [
88
components: {
99
schemas: {
1010
Schema: {
11+
description: 'Description.',
1112
properties: {
1213
id: {
1314
description: 'Description.',
@@ -25,6 +26,7 @@ testRule('xgen-IPA-117-description-ends-with-period', [
2526
components: {
2627
schemas: {
2728
Schema: {
29+
description: 'Description',
2830
properties: {
2931
noPeriod: {
3032
description: 'Description',
@@ -35,6 +37,12 @@ testRule('xgen-IPA-117-description-ends-with-period', [
3537
},
3638
},
3739
errors: [
40+
{
41+
code: 'xgen-IPA-117-description-ends-with-period',
42+
message: 'Descriptions must end with a full stop(.).',
43+
path: ['components', 'schemas', 'Schema'],
44+
severity: DiagnosticSeverity.Error,
45+
},
3846
{
3947
code: 'xgen-IPA-117-description-ends-with-period',
4048
message: 'Descriptions must end with a full stop(.).',
@@ -49,6 +57,7 @@ testRule('xgen-IPA-117-description-ends-with-period', [
4957
components: {
5058
schemas: {
5159
Schema: {
60+
description: 'Description\n| Table |',
5261
properties: {
5362
noPeriod: {
5463
description: 'Description\n| Table |',
@@ -66,6 +75,10 @@ testRule('xgen-IPA-117-description-ends-with-period', [
6675
components: {
6776
schemas: {
6877
Schema: {
78+
description: 'Description',
79+
'x-xgen-IPA-exception': {
80+
'xgen-IPA-117-description-ends-with-period': 'reason',
81+
},
6982
properties: {
7083
noPeriod: {
7184
description: 'Description',

tools/spectral/ipa/__tests__/IPA117DescriptionMustNotUseHtml.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ testRule('xgen-IPA-117-description-must-not-use-html', [
77
document: {
88
components: {
99
schemas: {
10+
description: 'Must be < 250 characters.',
1011
Schema: {
1112
properties: {
1213
valid: {
@@ -31,6 +32,7 @@ testRule('xgen-IPA-117-description-must-not-use-html', [
3132
components: {
3233
schemas: {
3334
Schema: {
35+
description: '<a>Description</a>',
3436
properties: {
3537
html: {
3638
description: '<a>Description</a>',
@@ -50,6 +52,12 @@ testRule('xgen-IPA-117-description-must-not-use-html', [
5052
},
5153
},
5254
errors: [
55+
{
56+
code: 'xgen-IPA-117-description-must-not-use-html',
57+
message: 'Descriptions must not use raw HTML.',
58+
path: ['components', 'schemas', 'Schema'],
59+
severity: DiagnosticSeverity.Error,
60+
},
5361
{
5462
code: 'xgen-IPA-117-description-must-not-use-html',
5563
message: 'Descriptions must not use raw HTML.',
@@ -83,6 +91,10 @@ testRule('xgen-IPA-117-description-must-not-use-html', [
8391
components: {
8492
schemas: {
8593
Schema: {
94+
description: '<a>Description</a>',
95+
'x-xgen-IPA-exception': {
96+
'xgen-IPA-117-description-must-not-use-html': 'reason',
97+
},
8698
properties: {
8799
html: {
88100
description: '<a>Description</a>',

tools/spectral/ipa/__tests__/IPA117DescriptionShouldNotUseLinks.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ testRule('xgen-IPA-117-description-should-not-use-inline-links', [
88
components: {
99
schemas: {
1010
Schema: {
11+
description: 'Description.',
1112
properties: {
1213
valid: {
1314
description: 'Description.',
@@ -37,6 +38,7 @@ testRule('xgen-IPA-117-description-should-not-use-inline-links', [
3738
components: {
3839
schemas: {
3940
Schema: {
41+
description: 'Hello [world](https://www.mongodb.com).',
4042
properties: {
4143
invalidLink: {
4244
description: 'Hello [world](https://www.mongodb.com).',
@@ -50,6 +52,13 @@ testRule('xgen-IPA-117-description-should-not-use-inline-links', [
5052
},
5153
},
5254
errors: [
55+
{
56+
code: 'xgen-IPA-117-description-should-not-use-inline-links',
57+
message:
58+
'Descriptions should not include inline links. Use the externalDocumentation property instead, see https://swagger.io/specification/#external-documentation-object.',
59+
path: ['components', 'schemas', 'Schema'],
60+
severity: DiagnosticSeverity.Error,
61+
},
5362
{
5463
code: 'xgen-IPA-117-description-should-not-use-inline-links',
5564
message:
@@ -72,6 +81,10 @@ testRule('xgen-IPA-117-description-should-not-use-inline-links', [
7281
components: {
7382
schemas: {
7483
Schema: {
84+
description: 'Hello [world](https://www.mongodb.com).',
85+
'x-xgen-IPA-exception': {
86+
'xgen-IPA-117-description-should-not-use-inline-links': 'reason',
87+
},
7588
properties: {
7689
invalidLink: {
7790
description: 'Hello [world](https://www.mongodb.com).',

tools/spectral/ipa/__tests__/IPA117DescriptionShouldNotUseTables.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ testRule('xgen-IPA-117-description-should-not-use-inline-tables', [
88
components: {
99
schemas: {
1010
Schema: {
11+
description: 'Schema for request | response',
1112
properties: {
1213
valid: {
1314
description: 'Description.',
@@ -28,6 +29,7 @@ testRule('xgen-IPA-117-description-should-not-use-inline-tables', [
2829
components: {
2930
schemas: {
3031
Schema: {
32+
description: '|Title|\n|-----|\n|Description|',
3133
properties: {
3234
table: {
3335
description: '|Title|\n|-----|\n|Description|',
@@ -50,6 +52,13 @@ testRule('xgen-IPA-117-description-should-not-use-inline-tables', [
5052
},
5153
},
5254
errors: [
55+
{
56+
code: 'xgen-IPA-117-description-should-not-use-inline-tables',
57+
message:
58+
'Descriptions should not include inline tables. Tables may not work well with all tools, in particular generated client code.',
59+
path: ['components', 'schemas', 'Schema'],
60+
severity: DiagnosticSeverity.Error,
61+
},
5362
{
5463
code: 'xgen-IPA-117-description-should-not-use-inline-tables',
5564
message:
@@ -93,6 +102,10 @@ testRule('xgen-IPA-117-description-should-not-use-inline-tables', [
93102
components: {
94103
schemas: {
95104
Schema: {
105+
description: '|Title|\n|-----|\n|Description|',
106+
'x-xgen-IPA-exception': {
107+
'xgen-IPA-117-description-should-not-use-inline-tables': 'reason',
108+
},
96109
properties: {
97110
table: {
98111
description: '|Title|\n|-----|\n|Description|',

tools/spectral/ipa/__tests__/IPA117DescriptionStartsWithUpperCase.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ testRule('xgen-IPA-117-description-starts-with-uppercase', [
88
components: {
99
schemas: {
1010
Schema: {
11+
description: 'Description',
1112
properties: {
1213
id: {
1314
description: 'Description',
@@ -25,6 +26,7 @@ testRule('xgen-IPA-117-description-starts-with-uppercase', [
2526
components: {
2627
schemas: {
2728
Schema: {
29+
description: 'description',
2830
properties: {
2931
noUpperCase: {
3032
description: 'description',
@@ -35,6 +37,12 @@ testRule('xgen-IPA-117-description-starts-with-uppercase', [
3537
},
3638
},
3739
errors: [
40+
{
41+
code: 'xgen-IPA-117-description-starts-with-uppercase',
42+
message: 'Descriptions must start with Uppercase.',
43+
path: ['components', 'schemas', 'Schema'],
44+
severity: DiagnosticSeverity.Error,
45+
},
3846
{
3947
code: 'xgen-IPA-117-description-starts-with-uppercase',
4048
message: 'Descriptions must start with Uppercase.',
@@ -49,6 +57,10 @@ testRule('xgen-IPA-117-description-starts-with-uppercase', [
4957
components: {
5058
schemas: {
5159
Schema: {
60+
description: 'description',
61+
'x-xgen-IPA-exception': {
62+
'xgen-IPA-117-description-starts-with-uppercase': 'reason',
63+
},
5264
properties: {
5365
noUpperCase: {
5466
description: 'description',
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
import testRule from './__helpers__/testRule.js';
2+
import { DiagnosticSeverity } from '@stoplight/types';
3+
4+
testRule('xgen-IPA-125-discriminator-must-accompany-oneOf-anyOf-allOf', [
5+
{
6+
name: 'valid schemas',
7+
document: {
8+
components: {
9+
schemas: {
10+
SchemaOneOf: {
11+
discriminator: {
12+
propertyName: 'type',
13+
},
14+
oneOf: [{}],
15+
},
16+
SchemaAnyOf: {
17+
discriminator: {
18+
propertyName: 'type',
19+
},
20+
anyOf: [{}],
21+
},
22+
SchemaAllOf: {
23+
discriminator: {
24+
propertyName: 'type',
25+
},
26+
allOf: [{}],
27+
},
28+
},
29+
},
30+
},
31+
errors: [],
32+
},
33+
{
34+
name: 'invalid schemas',
35+
document: {
36+
components: {
37+
schemas: {
38+
Schema: {
39+
discriminator: {
40+
propertyName: 'type',
41+
},
42+
properties: {
43+
type: {
44+
type: 'string',
45+
},
46+
},
47+
},
48+
NestedSchema: {
49+
properties: {
50+
name: {
51+
type: 'object',
52+
discriminator: {
53+
propertyName: 'first',
54+
},
55+
properties: {
56+
first: {
57+
type: 'string',
58+
},
59+
},
60+
},
61+
address: {
62+
type: 'string',
63+
},
64+
},
65+
},
66+
},
67+
},
68+
},
69+
errors: [
70+
{
71+
code: 'xgen-IPA-125-discriminator-must-accompany-oneOf-anyOf-allOf',
72+
message: "Each discriminator property must be accompanied by a 'oneOf', 'anyOf' or 'allOf' property.",
73+
path: ['components', 'schemas', 'Schema'],
74+
severity: DiagnosticSeverity.Warning,
75+
},
76+
{
77+
code: 'xgen-IPA-125-discriminator-must-accompany-oneOf-anyOf-allOf',
78+
message: "Each discriminator property must be accompanied by a 'oneOf', 'anyOf' or 'allOf' property.",
79+
path: ['components', 'schemas', 'NestedSchema', 'properties', 'name'],
80+
severity: DiagnosticSeverity.Warning,
81+
},
82+
],
83+
},
84+
{
85+
name: 'invalid schemas with exceptions',
86+
document: {
87+
components: {
88+
schemas: {
89+
Schema: {
90+
discriminator: {
91+
propertyName: 'type',
92+
},
93+
properties: {
94+
type: {
95+
type: 'string',
96+
},
97+
},
98+
'x-xgen-IPA-exception': {
99+
'xgen-IPA-125-discriminator-must-accompany-oneOf-anyOf-allOf': 'reason',
100+
},
101+
},
102+
NestedSchema: {
103+
properties: {
104+
name: {
105+
type: 'object',
106+
discriminator: {
107+
propertyName: 'first',
108+
},
109+
properties: {
110+
first: {
111+
type: 'string',
112+
},
113+
},
114+
'x-xgen-IPA-exception': {
115+
'xgen-IPA-125-discriminator-must-accompany-oneOf-anyOf-allOf': 'reason',
116+
},
117+
},
118+
address: {
119+
type: 'string',
120+
},
121+
},
122+
},
123+
},
124+
},
125+
},
126+
errors: [],
127+
},
128+
]);

tools/spectral/ipa/ipa-spectral.yaml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,45 @@ overrides:
135135
- '**#/components/schemas/DataLakeHTTPStore/allOf/1/properties/urls' # external field, to be covered by CLOUDP-293178
136136
rules:
137137
xgen-IPA-124-array-max-items: 'off'
138-
- files: # To be removed in CLOUDP-337392
138+
- files: # To be removed in CLOUDP-338425
139139
- '**#/paths/~1api~1atlas~1v2~1orgs~1%7BorgId%7D~1groups'
140140
- '**#/paths/~1api~1atlas~1v2~1groups~1%7BgroupId%7D'
141141
rules:
142142
xgen-IPA-104-get-method-response-has-no-input-fields: 'off'
143-
- files: # To be removed in CLOUDP-337392
143+
- files: # To be removed in CLOUDP-338425
144144
- '**#/paths/~1api~1atlas~1v2~1groups~1%7BgroupId%7D~1pushBasedLogExport'
145145
rules:
146146
xgen-IPA-106-create-method-request-has-no-readonly-fields: 'off'
147-
- files: # To be removed in CLOUDP-337392
147+
- files: # To be removed in CLOUDP-338425
148148
- '**#/components/schemas/AWSHardwareSpec20240805/properties/ebsVolumeType'
149149
rules:
150150
xgen-IPA-112-field-names-are-camel-case: 'off'
151+
- files: # To be removed in CLOUDP-338425
152+
- '**#/components/schemas/AtlasResourcePolicyAuditForNdsGroup'
153+
- '**#/components/schemas/AtlasResourcePolicyAuditForOrg'
154+
- '**#/components/schemas/ChartsAudit'
155+
- '**#/components/schemas/DefaultLimit'
156+
- '**#/components/schemas/ObjectCreated'
157+
- '**#/components/schemas/PinnedNamespaces'
158+
- '**#/components/schemas/RequestAccepted'
159+
- '**#/components/schemas/StreamsStartStreamProcessorWith'
160+
- '**#/components/schemas/TextSearchIndexCreateRequest'
161+
- '**#/components/schemas/VectorSearchIndexCreateRequest'
162+
- '**#/components/schemas/AtlasTenantClusterUpgradeRequest20240805'
163+
- '**#/components/schemas/StreamsModifyStreamProcessor'
164+
- '**#/components/schemas/EventTypeDetails'
165+
- '**#/components/schemas/LegacyAtlasTenantClusterUpgradeRequest'
166+
rules:
167+
xgen-IPA-117-description-ends-with-period: 'off'
168+
- files: # To be removed in CLOUDP-338425
169+
- '**#/components/schemas/CustomCriteriaView'
170+
- '**#/components/schemas/ExtraRetentionSetting'
171+
- '**#/components/schemas/MetricDataPoint'
172+
- '**#/components/schemas/MetricDataPoint_Atlas'
173+
- '**#/components/schemas/DateCriteriaView'
174+
rules:
175+
xgen-IPA-117-description-starts-with-uppercase: 'off'
176+
- files: # To be removed in CLOUDP-338425
177+
- '**#/components/schemas/NewRelic'
178+
rules:
179+
xgen-IPA-117-description-must-not-use-html: 'off'

0 commit comments

Comments
 (0)