Skip to content

Commit 6266a94

Browse files
docs change
1 parent f1d7988 commit 6266a94

File tree

3 files changed

+36
-34
lines changed

3 files changed

+36
-34
lines changed

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

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,37 @@ import testRule from './__helpers__/testRule';
22
import { DiagnosticSeverity } from '@stoplight/types';
33

44
const componentSchemas = {
5-
Resource: {
6-
type: 'object',
7-
},
8-
PaginatedResourceList: {
9-
type: 'object',
10-
properties: {
11-
totalCount: {
12-
type: 'integer',
13-
},
14-
results: {
15-
type: 'array',
16-
items: {
17-
$ref: '#/components/schemas/Resource',
18-
},
5+
Resource: {
6+
type: 'object',
7+
},
8+
PaginatedResourceList: {
9+
type: 'object',
10+
properties: {
11+
totalCount: {
12+
type: 'integer',
13+
},
14+
results: {
15+
type: 'array',
16+
items: {
17+
$ref: '#/components/schemas/Resource',
1918
},
2019
},
2120
},
22-
ResourceList: {
23-
type: 'object',
24-
properties: {
25-
totalCount: {
26-
type: 'integer',
27-
},
28-
results: {
29-
type: 'array',
30-
items: {
31-
$ref: '#/components/schemas/Resource',
32-
},
21+
},
22+
ResourceList: {
23+
type: 'object',
24+
properties: {
25+
totalCount: {
26+
type: 'integer',
27+
},
28+
results: {
29+
type: 'array',
30+
items: {
31+
$ref: '#/components/schemas/Resource',
3332
},
3433
},
3534
},
35+
},
3636
NonPaginatedList: {
3737
type: 'object',
3838
properties: {
@@ -86,7 +86,7 @@ testRule('xgen-IPA-110-collections-use-paginated-schema', [
8686
},
8787
},
8888
components: {
89-
schemas: componentSchemas
89+
schemas: componentSchemas,
9090
},
9191
},
9292
errors: [],
@@ -115,7 +115,7 @@ testRule('xgen-IPA-110-collections-use-paginated-schema', [
115115
},
116116
},
117117
components: {
118-
schemas: componentSchemas
118+
schemas: componentSchemas,
119119
},
120120
},
121121
errors: [],
@@ -144,8 +144,8 @@ testRule('xgen-IPA-110-collections-use-paginated-schema', [
144144
},
145145
},
146146
components: {
147-
schemas : componentSchemas,
148-
}
147+
schemas: componentSchemas,
148+
},
149149
},
150150
errors: [
151151
{
@@ -194,7 +194,7 @@ testRule('xgen-IPA-110-collections-use-paginated-schema', [
194194
},
195195
},
196196
},
197-
}
197+
},
198198
},
199199
},
200200
errors: [
@@ -288,7 +288,7 @@ testRule('xgen-IPA-110-collections-use-paginated-schema', [
288288
},
289289
},
290290
components: {
291-
schemas: componentSchemas
291+
schemas: componentSchemas,
292292
},
293293
},
294294
errors: [
@@ -328,7 +328,7 @@ testRule('xgen-IPA-110-collections-use-paginated-schema', [
328328
},
329329
},
330330
components: {
331-
schemas: componentSchemas
331+
schemas: componentSchemas,
332332
},
333333
},
334334
errors: [],

tools/spectral/ipa/rulesets/IPA-110.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ rules:
1212
##### Implementation details
1313
Rule checks for the following conditions:
1414
- Only applies to List methods (GET operations that return collections of resources)
15-
- Checks that the 200 response schema references a schema with a name starting with "Paginated"
15+
- Checks that the 200 response schema references a schema with a name starting with either a name starting with "Paginated" or contain both "totalCount" (integer) and "results" (array) fields
16+
- If the referenced schema name has "Paginated" prefix, the rule assumes that the schema is paginated and does not check for "totalCount" and "results" fields
1617
message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-110-list-methods-must-use-paginated-schema'
1718
severity: warn
1819
given: '$.paths[*].get.responses.200.content'

tools/spectral/ipa/rulesets/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,8 @@ APIs that return collections of resources must use a paginated response schema.
459459
##### Implementation details
460460
Rule checks for the following conditions:
461461
- Only applies to List methods (GET operations that return collections of resources)
462-
- Checks that the 200 response schema references a schema with a name starting with "Paginated"
462+
- Checks that the 200 response schema references a schema with a name starting with either a name starting with "Paginated" or contain both "totalCount" (integer) and "results" (array) fields
463+
- If the referenced schema name has "Paginated" prefix, the rule assumes that the schema is paginated and does not check for "totalCount" and "results" fields
463464

464465

465466

0 commit comments

Comments
 (0)