Skip to content

Commit 0257667

Browse files
outdooracornjakobw
authored andcommitted
CRUD: Create and reference response header components in OpenAPI Document
Bug: T379912 Change-Id: I5524a08b8180bdfdeecbe63fae4b31939ffbad9f
1 parent 9e2c89a commit 0257667

File tree

18 files changed

+142
-359
lines changed

18 files changed

+142
-359
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict';
2+
3+
module.exports = {
4+
"Content-Language": {
5+
"description": "Language code of the language in which response is provided",
6+
"schema": { "type": "string" },
7+
"required": true
8+
},
9+
"ETag": {
10+
"description": "Last entity revision number",
11+
"schema": { "type": "string" },
12+
"required": true
13+
},
14+
"Last-Modified": {
15+
"description": "Last modified date",
16+
"schema": { "type": "string" },
17+
"required": true
18+
},
19+
"Location": {
20+
"description": "The URI of the newly created Statement",
21+
"schema": { "type": "string" },
22+
"required": true
23+
},
24+
"X-Authenticated-User": {
25+
"description": "Optional username of the user making the request",
26+
"schema": { "type": "string" }
27+
}
28+
};

repo/domains/crud/specs/global/responses.js

Lines changed: 13 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -526,20 +526,9 @@ module.exports = {
526526
"Item": {
527527
"description": "A single Wikibase Item",
528528
"headers": {
529-
"ETag": {
530-
"description": "Last entity revision number",
531-
"schema": { "type": "string" },
532-
"required": true
533-
},
534-
"Last-Modified": {
535-
"description": "Last modified date",
536-
"schema": { "type": "string" },
537-
"required": true
538-
},
539-
"X-Authenticated-User": {
540-
"description": "Optional username of the user making the request",
541-
"schema": { "type": "string" }
542-
}
529+
"ETag": { "$ref": "#/components/headers/ETag" },
530+
"Last-Modified": { "$ref": "#/components/headers/Last-Modified" },
531+
"X-Authenticated-User": { "$ref": "#/components/headers/X-Authenticated-User" }
543532
},
544533
"content": {
545534
"application/json": {
@@ -668,20 +657,9 @@ module.exports = {
668657
"Sitelinks": {
669658
"description": "A list of Sitelinks by Item id",
670659
"headers": {
671-
"ETag": {
672-
"description": "Last entity revision number",
673-
"schema": { "type": "string" },
674-
"required": true
675-
},
676-
"Last-Modified": {
677-
"description": "Last modified date",
678-
"schema": { "type": "string" },
679-
"required": true
680-
},
681-
"X-Authenticated-User": {
682-
"description": "Optional username of the user making the request",
683-
"schema": { "type": "string" }
684-
}
660+
"ETag": { "$ref": "#/components/headers/ETag" },
661+
"Last-Modified": { "$ref": "#/components/headers/Last-Modified" },
662+
"X-Authenticated-User": { "$ref": "#/components/headers/X-Authenticated-User" }
685663
},
686664
"content": {
687665
"application/json": {
@@ -704,20 +682,9 @@ module.exports = {
704682
"Sitelink": {
705683
"description": "A Sitelink by Item id",
706684
"headers": {
707-
"ETag": {
708-
"description": "Last entity revision number",
709-
"schema": { "type": "string" },
710-
"required": true
711-
},
712-
"Last-Modified": {
713-
"description": "Last modified date",
714-
"schema": { "type": "string" },
715-
"required": true
716-
},
717-
"X-Authenticated-User": {
718-
"description": "Optional username of the user making the request",
719-
"schema": { "type": "string" }
720-
}
685+
"ETag": { "$ref": "#/components/headers/ETag" },
686+
"Last-Modified": { "$ref": "#/components/headers/Last-Modified" },
687+
"X-Authenticated-User": { "$ref": "#/components/headers/X-Authenticated-User" }
721688
},
722689
"content": {
723690
"application/json": {
@@ -733,20 +700,9 @@ module.exports = {
733700
"Property": {
734701
"description": "A single Wikibase Property",
735702
"headers": {
736-
"ETag": {
737-
"description": "Last entity revision number",
738-
"schema": { "type": "string" },
739-
"required": true
740-
},
741-
"Last-Modified": {
742-
"description": "Last modified date",
743-
"schema": { "type": "string" },
744-
"required": true
745-
},
746-
"X-Authenticated-User": {
747-
"description": "Optional username of the user making the request",
748-
"schema": { "type": "string" }
749-
}
703+
"ETag": { "$ref": "#/components/headers/ETag" },
704+
"Last-Modified": { "$ref": "#/components/headers/Last-Modified" },
705+
"X-Authenticated-User": { "$ref": "#/components/headers/X-Authenticated-User" }
750706
},
751707
"content": {
752708
"application/json": {
@@ -798,11 +754,7 @@ module.exports = {
798754
"NotModified": {
799755
"description": "The specified resource has not been modified since last provided revision number or date",
800756
"headers": {
801-
"ETag": {
802-
"description": "Last entity revision number",
803-
"schema": { "type": "string" },
804-
"required": true
805-
}
757+
"ETag": { "$ref": "#/components/headers/ETag" }
806758
}
807759
},
808760
"MovedPermanently": {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ const openapi = {
6565
"parameters": require( './global/parameters' ),
6666
"requestBodies": require( './global/requests' ),
6767
"responses": require( './global/responses' ),
68+
"headers": require( './global/headers' ),
6869
"schemas": require( './global/schemas' ),
6970
"examples": require( './global/examples' ),
7071
},

repo/domains/crud/specs/resources/aliases/aliases-in-language-for-item.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,9 @@ const requests = require( './requests' );
55
const ItemAliasesInLanguageResponse = {
66
"description": "Item's aliases in a specific language",
77
"headers": {
8-
"ETag": {
9-
"description": "Last entity revision number",
10-
"schema": { "type": "string" },
11-
"required": true
12-
},
13-
"Last-Modified": {
14-
"description": "Last modified date",
15-
"schema": { "type": "string" },
16-
"required": true
17-
},
18-
"X-Authenticated-User": {
19-
"description": "Optional username of the user making the request",
20-
"schema": { "type": "string" }
21-
}
8+
"ETag": { "$ref": "#/components/headers/ETag" },
9+
"Last-Modified": { "$ref": "#/components/headers/Last-Modified" },
10+
"X-Authenticated-User": { "$ref": "#/components/headers/X-Authenticated-User" }
2211
},
2312
"content": {
2413
"application/json": {

repo/domains/crud/specs/resources/aliases/aliases-in-language-for-property.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,9 @@ const requests = require( './requests' );
55
const PropertyAliasesInLanguageResponse = {
66
"description": "Property's aliases in a specific language",
77
"headers": {
8-
"ETag": {
9-
"description": "Last entity revision number",
10-
"schema": { "type": "string" },
11-
"required": true
12-
},
13-
"Last-Modified": {
14-
"description": "Last modified date",
15-
"schema": { "type": "string" },
16-
"required": true
17-
},
18-
"X-Authenticated-User": {
19-
"description": "Optional username of the user making the request",
20-
"schema": { "type": "string" }
21-
}
8+
"ETag": { "$ref": "#/components/headers/ETag" },
9+
"Last-Modified": { "$ref": "#/components/headers/Last-Modified" },
10+
"X-Authenticated-User": { "$ref": "#/components/headers/X-Authenticated-User" }
2211
},
2312
"content": {
2413
"application/json": {

repo/domains/crud/specs/resources/aliases/list-for-item.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,9 @@ const PatchItemAliasesRequestContent = {
1717
const ItemAliasesResponse = {
1818
"description": "Item's aliases by language",
1919
"headers": {
20-
"ETag": {
21-
"description": "Last entity revision number",
22-
"schema": { "type": "string" },
23-
"required": true
24-
},
25-
"Last-Modified": {
26-
"description": "Last modified date",
27-
"schema": { "type": "string" },
28-
"required": true
29-
},
30-
"X-Authenticated-User": {
31-
"description": "Optional username of the user making the request",
32-
"schema": { "type": "string" }
33-
}
20+
"ETag": { "$ref": "#/components/headers/ETag" },
21+
"Last-Modified": { "$ref": "#/components/headers/Last-Modified" },
22+
"X-Authenticated-User": { "$ref": "#/components/headers/X-Authenticated-User" }
3423
},
3524
"content": {
3625
"application/json": {

repo/domains/crud/specs/resources/aliases/list-for-property.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,9 @@ const PatchPropertyAliasesRequestContent = {
1717
const PropertyAliasesResponse = {
1818
"description": "Property's aliases by language",
1919
"headers": {
20-
"ETag": {
21-
"description": "Last entity revision number",
22-
"schema": { "type": "string" },
23-
"required": true
24-
},
25-
"Last-Modified": {
26-
"description": "Last modified date",
27-
"schema": { "type": "string" },
28-
"required": true
29-
},
30-
"X-Authenticated-User": {
31-
"description": "Optional username of the user making the request",
32-
"schema": { "type": "string" }
33-
}
20+
"ETag": { "$ref": "#/components/headers/ETag" },
21+
"Last-Modified": { "$ref": "#/components/headers/Last-Modified" },
22+
"X-Authenticated-User": { "$ref": "#/components/headers/X-Authenticated-User" }
3423
},
3524
"content": {
3625
"application/json": {

repo/domains/crud/specs/resources/descriptions/list-for-item.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,9 @@ const PatchItemDescriptionsRequest = {
1717
const ItemDescriptionsResponse = {
1818
"description": "Item's descriptions by language",
1919
"headers": {
20-
"ETag": {
21-
"description": "Last entity revision number",
22-
"schema": { "type": "string" },
23-
"required": true
24-
},
25-
"Last-Modified": {
26-
"description": "Last modified date",
27-
"schema": { "type": "string" },
28-
"required": true
29-
},
30-
"X-Authenticated-User": {
31-
"description": "Optional username of the user making the request",
32-
"schema": { "type": "string" }
33-
}
20+
"ETag": { "$ref": "#/components/headers/ETag" },
21+
"Last-Modified": { "$ref": "#/components/headers/Last-Modified" },
22+
"X-Authenticated-User": { "$ref": "#/components/headers/X-Authenticated-User" }
3423
},
3524
"content": {
3625
"application/json": {

repo/domains/crud/specs/resources/descriptions/list-for-property.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,9 @@ const PatchPropertyDescriptionsRequest = {
1717
const PropertyDescriptionsResponse = {
1818
"description": "Property's descriptions by language",
1919
"headers": {
20-
"ETag": {
21-
"description": "Last entity revision number",
22-
"schema": { "type": "string" },
23-
"required": true
24-
},
25-
"Last-Modified": {
26-
"description": "Last modified date",
27-
"schema": { "type": "string" },
28-
"required": true
29-
},
30-
"X-Authenticated-User": {
31-
"description": "Optional username of the user making the request",
32-
"schema": { "type": "string" }
33-
}
20+
"ETag": { "$ref": "#/components/headers/ETag" },
21+
"Last-Modified": { "$ref": "#/components/headers/Last-Modified" },
22+
"X-Authenticated-User": { "$ref": "#/components/headers/X-Authenticated-User" }
3423
},
3524
"content": {
3625
"application/json": {

repo/domains/crud/specs/resources/descriptions/responses.js

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,9 @@ module.exports = {
44
"ItemDescription": {
55
"description": "Item's description in a specific language",
66
"headers": {
7-
"ETag": {
8-
"description": "Last entity revision number",
9-
"schema": { "type": "string" },
10-
"required": true
11-
},
12-
"Last-Modified": {
13-
"description": "Last modified date",
14-
"schema": { "type": "string" },
15-
"required": true
16-
},
17-
"X-Authenticated-User": {
18-
"description": "Optional username of the user making the request",
19-
"schema": { "type": "string" }
20-
}
7+
"ETag": { "$ref": "#/components/headers/ETag" },
8+
"Last-Modified": { "$ref": "#/components/headers/Last-Modified" },
9+
"X-Authenticated-User": { "$ref": "#/components/headers/X-Authenticated-User" }
2110
},
2211
"content": {
2312
"application/json": {
@@ -29,20 +18,9 @@ module.exports = {
2918
"PropertyDescription": {
3019
"description": "Property's description in a specific language",
3120
"headers": {
32-
"ETag": {
33-
"description": "Last entity revision number",
34-
"schema": { "type": "string" },
35-
"required": true
36-
},
37-
"Last-Modified": {
38-
"description": "Last modified date",
39-
"schema": { "type": "string" },
40-
"required": true
41-
},
42-
"X-Authenticated-User": {
43-
"description": "Optional username of the user making the request",
44-
"schema": { "type": "string" }
45-
}
21+
"ETag": { "$ref": "#/components/headers/ETag" },
22+
"Last-Modified": { "$ref": "#/components/headers/Last-Modified" },
23+
"X-Authenticated-User": { "$ref": "#/components/headers/X-Authenticated-User" }
4624
},
4725
"content": {
4826
"application/json": {
@@ -54,15 +32,8 @@ module.exports = {
5432
"DescriptionDeleted": {
5533
"description": "The description was deleted",
5634
"headers": {
57-
"Content-Language": {
58-
"description": "Language code of the language in which response is provided",
59-
"schema": { "type": "string" },
60-
"required": true
61-
},
62-
"X-Authenticated-User": {
63-
"description": "Optional username of the user making the request",
64-
"schema": { "type": "string" }
65-
}
35+
"Content-Language": { "$ref": "#/components/headers/Content-Language" },
36+
"X-Authenticated-User": { "$ref": "#/components/headers/X-Authenticated-User" }
6637
},
6738
"content": {
6839
"application/json": {

0 commit comments

Comments
 (0)