Skip to content

Commit 9e2c89a

Browse files
outdooracornjakobw
authored andcommitted
CRUD: Reduce the number of OpenAPI source files
The built OpenAPI Document at `repo/rest-api/src/openapi.json` is not modified Bug: T379912 Change-Id: I3edaba64eb53beaecb78fd59ec1ee9c2e233f4ca
1 parent 9265798 commit 9e2c89a

35 files changed

+961
-1084
lines changed

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

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,35 @@
11
'use strict';
22

33
const requests = require( './requests' );
4-
const responses = require( './responses' );
4+
5+
const ItemAliasesInLanguageResponse = {
6+
"description": "Item's aliases in a specific language",
7+
"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+
}
22+
},
23+
"content": {
24+
"application/json": {
25+
"schema": {
26+
"type": "array",
27+
"items": { "type": "string" }
28+
},
29+
"example": [ "Jane M. Doe", "JD" ]
30+
}
31+
}
32+
};
533

634
module.exports = {
735
"get": {
@@ -18,7 +46,7 @@ module.exports = {
1846
{ "$ref": "#/components/parameters/Authorization" }
1947
],
2048
"responses": {
21-
"200": responses.ItemAliasesInLanguage,
49+
"200": ItemAliasesInLanguageResponse,
2250
"304": { "$ref": "#/components/responses/NotModified" },
2351
"308": { "$ref": "#/components/responses/MovedPermanently" },
2452
"400": { "$ref": "#/components/responses/InvalidTermByLanguageInput" },
@@ -57,11 +85,11 @@ module.exports = {
5785
},
5886
"responses": {
5987
"200": {
60-
...responses.ItemAliasesInLanguage,
88+
...ItemAliasesInLanguageResponse,
6189
"description": "The updated list of aliases in a specific language",
6290
},
6391
"201": {
64-
...responses.ItemAliasesInLanguage,
92+
...ItemAliasesInLanguageResponse,
6593
"description": "The newly created list of aliases in a specific language",
6694
},
6795
"304": { "$ref": "#/components/responses/NotModified" },

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

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,36 @@
11
'use strict';
22

3-
const responses = require( './responses' );
43
const requests = require( './requests' );
54

5+
const PropertyAliasesInLanguageResponse = {
6+
"description": "Property's aliases in a specific language",
7+
"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+
}
22+
},
23+
"content": {
24+
"application/json": {
25+
"schema": {
26+
"type": "array",
27+
"items": { "type": "string" }
28+
},
29+
"example": [ "is a", "is an" ]
30+
}
31+
}
32+
};
33+
634
module.exports = {
735
"get": {
836
"operationId": "getPropertyAliasesInLanguage",
@@ -18,7 +46,7 @@ module.exports = {
1846
{ "$ref": "#/components/parameters/Authorization" }
1947
],
2048
"responses": {
21-
"200": responses.PropertyAliasesInLanguage,
49+
"200": PropertyAliasesInLanguageResponse,
2250
"304": { "$ref": "#/components/responses/NotModified" },
2351
"400": { "$ref": "#/components/responses/InvalidTermByLanguageInput" },
2452
"404": { "$ref": "#/components/responses/ResourceNotFound" },
@@ -56,11 +84,11 @@ module.exports = {
5684
},
5785
"responses": {
5886
"200": {
59-
...responses.PropertyAliasesInLanguage,
87+
...PropertyAliasesInLanguageResponse,
6088
"description": "The updated list of aliases in a specific language"
6189
},
6290
"201": {
63-
...responses.PropertyAliasesInLanguage,
91+
...PropertyAliasesInLanguageResponse,
6492
"description": "The newly created list of aliases in a specific language"
6593
},
6694
"304": { "$ref": "#/components/responses/NotModified" },

repo/domains/crud/specs/resources/aliases/examples.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

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

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,47 @@
11
'use strict';
22

33
const requestParts = require( '../../global/request-parts' );
4-
const responses = require( './responses' );
5-
const examples = require( './examples' );
4+
5+
const PatchItemAliasesRequestContent = {
6+
"schema": requestParts.PatchRequest,
7+
"example": {
8+
"patch": [
9+
{ "op": "add", "path": "/en/-", "value": "JD" }
10+
],
11+
"tags": [],
12+
"bot": false,
13+
"comment": "Add English alias"
14+
}
15+
};
16+
17+
const ItemAliasesResponse = {
18+
"description": "Item's aliases by language",
19+
"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+
}
34+
},
35+
"content": {
36+
"application/json": {
37+
"schema": { "$ref": "#/components/schemas/Aliases" },
38+
"example": {
39+
"en": [ "Jane M. Doe", "JD" ],
40+
"ru": [ "Джейн М. Доу" ]
41+
}
42+
}
43+
}
44+
};
645

746
module.exports = {
847
"get": {
@@ -18,7 +57,7 @@ module.exports = {
1857
{ "$ref": "#/components/parameters/Authorization" }
1958
],
2059
"responses": {
21-
"200": responses.ItemAliases,
60+
"200": ItemAliasesResponse,
2261
"304": { "$ref": "#/components/responses/NotModified" },
2362
"308": { "$ref": "#/components/responses/MovedPermanently" },
2463
"400": { "$ref": "#/components/responses/InvalidEntityIdInput" },
@@ -41,18 +80,12 @@ module.exports = {
4180
"description": "Payload containing a JSON Patch document to be applied to an Item's aliases and edit metadata",
4281
"required": true,
4382
"content": {
44-
"application/json-patch+json": {
45-
"schema": requestParts.PatchRequest,
46-
"example": examples.PatchItemAliases
47-
},
48-
"application/json": {
49-
"schema": requestParts.PatchRequest,
50-
"example": examples.PatchItemAliases
51-
},
83+
"application/json-patch+json": PatchItemAliasesRequestContent,
84+
"application/json": PatchItemAliasesRequestContent,
5285
}
5386
},
5487
"responses": {
55-
"200": responses.ItemAliases,
88+
"200": ItemAliasesResponse,
5689
"400": { "$ref": "#/components/responses/InvalidPatch" },
5790
"403": { "$ref": "#/components/responses/PermissionDenied" },
5891
"404": { "$ref": "#/components/responses/ResourceNotFound" },

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

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,47 @@
11
'use strict';
22

33
const requestParts = require( '../../global/request-parts' );
4-
const responses = require( './responses' );
5-
const examples = require( './examples' );
4+
5+
const PatchPropertyAliasesRequestContent = {
6+
"schema": requestParts.PatchRequest,
7+
"example": {
8+
"patch": [
9+
{ "op": "add", "path": "/en/-", "value": "is an" }
10+
],
11+
"tags": [],
12+
"bot": false,
13+
"comment": "Add English alias"
14+
}
15+
};
16+
17+
const PropertyAliasesResponse = {
18+
"description": "Property's aliases by language",
19+
"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+
}
34+
},
35+
"content": {
36+
"application/json": {
37+
"schema": { "$ref": "#/components/schemas/Aliases" },
38+
"example": {
39+
"en": [ "is a", "is an" ],
40+
"ru": [ "представляет собой", "является" ]
41+
}
42+
}
43+
}
44+
};
645

746
module.exports = {
847
"get": {
@@ -18,7 +57,7 @@ module.exports = {
1857
{ "$ref": "#/components/parameters/Authorization" }
1958
],
2059
"responses": {
21-
"200": responses.PropertyAliases,
60+
"200": PropertyAliasesResponse,
2261
"304": { "$ref": "#/components/responses/NotModified" },
2362
"400": { "$ref": "#/components/responses/InvalidEntityIdInput" },
2463
"404": { "$ref": "#/components/responses/ResourceNotFound" },
@@ -40,18 +79,12 @@ module.exports = {
4079
"description": "Payload containing a JSON Patch document to be applied to a Property's aliases and edit metadata",
4180
"required": true,
4281
"content": {
43-
"application/json-patch+json": {
44-
"schema": requestParts.PatchRequest,
45-
"example": examples.PatchPropertyAliases
46-
},
47-
"application/json": {
48-
"schema": requestParts.PatchRequest,
49-
"example": examples.PatchPropertyAliases
50-
}
82+
"application/json-patch+json": PatchPropertyAliasesRequestContent,
83+
"application/json": PatchPropertyAliasesRequestContent
5184
}
5285
},
5386
"responses": {
54-
"200": responses.PropertyAliases,
87+
"200": PropertyAliasesResponse,
5588
"400": { "$ref": "#/components/responses/InvalidPatch" },
5689
"403": { "$ref": "#/components/responses/PermissionDenied" },
5790
"404": { "$ref": "#/components/responses/ResourceNotFound" },

0 commit comments

Comments
 (0)