Skip to content

Commit 649540c

Browse files
committed
Search: Resolve no-unused-components redocly lint issue
`SearchQuery` in parameters.js is only used via imports (`require()`) and not via JSON Schema references (`$ref`). This caused Redocly CLI to complain about unused components, which is accurate. Exporting a `components` object from `parameters.js` which only contains the schemas which are references via `$ref` provides a workaround. Bug: T379912 Change-Id: Iacbb28adc3731b3afbbba098e03d97244ac8b570
1 parent 7face6b commit 649540c

File tree

4 files changed

+54
-54
lines changed

4 files changed

+54
-54
lines changed
Lines changed: 53 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,60 @@
11
'use strict';
22

3-
module.exports = {
4-
"SearchQuery": {
5-
"in": "query",
6-
"name": "q",
7-
"description": "The term to search labels by",
8-
"required": true,
9-
"schema": { "type": "string" }
3+
const SearchQuery = {
4+
"in": "query",
5+
"name": "q",
6+
"description": "The term to search labels by",
7+
"required": true,
8+
"schema": { "type": "string" }
9+
};
10+
11+
const SearchLanguage = {
12+
"in": "query",
13+
"name": "language",
14+
"description": "The language to search labels in",
15+
"required": true,
16+
"schema": {
17+
"type": "string",
18+
"pattern": "^[a-z]{2}[a-z0-9-]*$"
1019
},
11-
"SearchLanguage": {
12-
"in": "query",
13-
"name": "language",
14-
"description": "The language to search labels in",
15-
"required": true,
16-
"schema": {
17-
"type": "string",
18-
"pattern": "^[a-z]{2}[a-z0-9-]*$"
19-
},
20-
"example": "en"
20+
"example": "en"
21+
};
22+
23+
const Limit = {
24+
"in": "query",
25+
"name": "limit",
26+
"description": "The maximum number of results to return",
27+
"required": false,
28+
"schema": {
29+
"type": "integer",
30+
"minimum": 1,
31+
"maximum": 500,
32+
"default": 10
2133
},
22-
"Limit": {
23-
"in": "query",
24-
"name": "limit",
25-
"description": "The maximum number of results to return",
26-
"required": false,
27-
"schema": {
28-
"type": "integer",
29-
"minimum": 1,
30-
"maximum": 500,
31-
"default": 10
32-
},
33-
"example": 20
34+
"example": 20
35+
};
36+
37+
const Offset = {
38+
"in": "query",
39+
"name": "offset",
40+
"description": "The index to start showing results from",
41+
"required": false,
42+
"schema": {
43+
"type": "integer",
44+
"minimum": 0,
45+
"default": 0
3446
},
35-
"Offset": {
36-
"in": "query",
37-
"name": "offset",
38-
"description": "The index to start showing results from",
39-
"required": false,
40-
"schema": {
41-
"type": "integer",
42-
"minimum": 0,
43-
"default": 0
44-
},
45-
"example": 4
47+
"example": 4
48+
};
49+
50+
module.exports = {
51+
SearchQuery,
52+
SearchLanguage,
53+
Limit,
54+
Offset,
55+
components: {
56+
SearchLanguage,
57+
Limit,
58+
Offset,
4659
}
4760
};

repo/domains/search/specs/index.fragment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const openapi = {
6262
}
6363
},
6464
"components": {
65-
"parameters": require( './global/parameters' ),
65+
"parameters": parameters.components,
6666
"responses": require( './global/responses' ),
6767
},
6868
};

repo/rest-api/.redocly.lint-ignore.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,3 @@ specs/openapi-joined.json:
55
- '#/paths/~1v1~1openapi.json/get/responses'
66
- '#/paths/~1v1~1property-data-types/get/responses'
77
- '#/paths/~1v0~1search~1items/get/responses'
8-
9-
# temporarily ignore
10-
no-unused-components:
11-
- '#/components/parameters/SearchQuery'

repo/rest-api/src/openapi.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33632,15 +33632,6 @@
3363233632
},
3363333633
"example": "Bearer mF_9.B5f-4.1JqM"
3363433634
},
33635-
"SearchQuery": {
33636-
"in": "query",
33637-
"name": "q",
33638-
"description": "The term to search labels by",
33639-
"required": true,
33640-
"schema": {
33641-
"type": "string"
33642-
}
33643-
},
3364433635
"SearchLanguage": {
3364533636
"in": "query",
3364633637
"name": "language",

0 commit comments

Comments
 (0)