From 576406e3cc4b8ef149f1a21af9bc8eede09897a5 Mon Sep 17 00:00:00 2001 From: Ollie Date: Wed, 30 Oct 2024 12:32:29 +0000 Subject: [PATCH] REST: Create REST API v1 release and enable with Wikibase extension Release notes added to 1.43 as this commit will be backported to the REL1_43 branch (see T378370) Bug: T378455 Bug: T378175 Change-Id: If3844c596576a2610ab1f7f18fe04964140fde32 --- RELEASE-NOTES-1.43 | 4 +- extension-repo.json | 302 ++++++++++++++++++ repo/rest-api/CHANGELOG.md | 4 + repo/rest-api/README.md | 4 +- .../adr/0007_work_in_progress_endpoints.md | 5 + repo/rest-api/docs/loaders/openapi-loader.js | 2 +- repo/rest-api/routes.dev.json | 2 +- repo/rest-api/specs/openapi.json | 2 +- .../GetItemDescriptionRouteHandler.php | 2 +- .../GetItemLabelRouteHandler.php | 2 +- .../src/RouteHandlers/GetItemRouteHandler.php | 2 +- .../GetItemStatementRouteHandler.php | 2 +- .../GetPropertyDescriptionRouteHandler.php | 2 +- .../GetPropertyLabelRouteHandler.php | 2 +- .../RouteHandlers/GetPropertyRouteHandler.php | 2 +- .../GetPropertyStatementRouteHandler.php | 2 +- repo/rest-api/src/RouteHandlers/openapi.json | 2 +- .../GetItemAliasesInLanguageTest.js | 2 +- .../mocha/api-testing/GetItemAliasesTest.js | 2 +- .../api-testing/GetItemDescriptionTest.js | 2 +- .../api-testing/GetItemDescriptionsTest.js | 2 +- .../mocha/api-testing/GetItemLabelTest.js | 2 +- .../GetItemLabelWithFallbackTest.js | 6 +- .../mocha/api-testing/GetItemLabelsTest.js | 2 +- .../api-testing/GetItemStatementsTest.js | 2 +- .../tests/mocha/api-testing/GetItemTest.js | 2 +- .../GetPropertyDescriptionWithFallbackTest.js | 2 +- .../GetPropertyLabelWithFallbackTest.js | 4 +- .../mocha/api-testing/GetSitelinkTest.js | 2 +- .../mocha/api-testing/GetSitelinksTest.js | 2 +- .../tests/mocha/helpers/RequestBuilder.js | 2 +- .../tests/mocha/openapi-validation/hooks.js | 2 +- .../RouteHandlers/RouteHandlersTest.php | 6 +- .../phpunit/RouteHandlers/RoutesTest.php | 2 +- 34 files changed, 350 insertions(+), 37 deletions(-) diff --git a/RELEASE-NOTES-1.43 b/RELEASE-NOTES-1.43 index aac90194cd1..e90da82841d 100644 --- a/RELEASE-NOTES-1.43 +++ b/RELEASE-NOTES-1.43 @@ -21,7 +21,7 @@ https://www.mediawiki.org/wiki/Manual:Upgrading ==== Changed configuration ==== -* (T12345) ... +* (T378175) The REST API is now enabled when the Wikibase repo extension is loaded ==== Removed configuration ==== @@ -55,7 +55,7 @@ https://www.mediawiki.org/wiki/Manual:Upgrading === REST API changes in 1.43 === -* (T12345) ... +* (T378455) Wikibase REST API v1.0 has been released === Languages updated in 1.43 === diff --git a/extension-repo.json b/extension-repo.json index 5b14bfaff64..c96712478a2 100644 --- a/extension-repo.json +++ b/extension-repo.json @@ -332,6 +332,308 @@ ] } }, + "RestRoutes": [ + { + "path": "/wikibase/v1/entities/items/{item_id}", + "method": "GET", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\GetItemRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items", + "method": "POST", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\CreateItemRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items/{item_id}", + "method": "PATCH", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\PatchItemRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/properties/{property_id}", + "method": "GET", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\GetPropertyRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/properties/{property_id}", + "method": "PATCH", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\PatchPropertyRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items/{item_id}/statements", + "method": "POST", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\AddItemStatementRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/properties/{property_id}/statements", + "method": "POST", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\AddPropertyStatementRouteHandler::factory" + }, + { + "path": "/wikibase/v1/statements/{statement_id}", + "method": "GET", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\GetStatementRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items/{item_id}/statements/{statement_id}", + "method": "GET", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\GetItemStatementRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/properties/{property_id}/statements/{statement_id}", + "method": "GET", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\GetPropertyStatementRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items/{item_id}/statements", + "method": "GET", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\GetItemStatementsRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/properties/{property_id}/statements", + "method": "GET", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\GetPropertyStatementsRouteHandler::factory" + }, + { + "path": "/wikibase/v1/statements/{statement_id}", + "method": "PUT", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\ReplaceStatementRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items/{item_id}/statements/{statement_id}", + "method": "PUT", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\ReplaceItemStatementRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/properties/{property_id}/statements/{statement_id}", + "method": "PUT", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\ReplacePropertyStatementRouteHandler::factory" + }, + { + "path": "/wikibase/v1/statements/{statement_id}", + "method": "DELETE", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\RemoveStatementRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items/{item_id}/statements/{statement_id}", + "method": "DELETE", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\RemoveItemStatementRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/properties/{property_id}/statements/{statement_id}", + "method": "DELETE", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\RemovePropertyStatementRouteHandler::factory" + }, + { + "path": "/wikibase/v1/statements/{statement_id}", + "method": "PATCH", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\PatchStatementRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items/{item_id}/statements/{statement_id}", + "method": "PATCH", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\PatchItemStatementRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/properties/{property_id}/statements/{statement_id}", + "method": "PATCH", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\PatchPropertyStatementRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items/{item_id}/labels", + "method": "GET", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\GetItemLabelsRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/properties/{property_id}/labels", + "method": "GET", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\GetPropertyLabelsRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items/{item_id}/labels/{language_code}", + "method": "GET", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\GetItemLabelRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items/{item_id}/labels_with_language_fallback/{language_code}", + "method": "GET", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\GetItemLabelWithFallbackRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/properties/{property_id}/labels/{language_code}", + "method": "GET", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\GetPropertyLabelRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/properties/{property_id}/labels_with_language_fallback/{language_code}", + "method": "GET", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\GetPropertyLabelWithFallbackRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items/{item_id}/labels/{language_code}", + "method": "PUT", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\SetItemLabelRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/properties/{property_id}/labels/{language_code}", + "method": "PUT", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\SetPropertyLabelRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items/{item_id}/labels", + "method": "PATCH", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\PatchItemLabelsRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/properties/{property_id}/labels", + "method": "PATCH", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\PatchPropertyLabelsRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items/{item_id}/labels/{language_code}", + "method": "DELETE", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\RemoveItemLabelRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/properties/{property_id}/labels/{language_code}", + "method": "DELETE", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\RemovePropertyLabelRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items/{item_id}/descriptions", + "method": "GET", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\GetItemDescriptionsRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items/{item_id}/descriptions", + "method": "PATCH", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\PatchItemDescriptionsRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/properties/{property_id}/descriptions", + "method": "PATCH", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\PatchPropertyDescriptionsRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items/{item_id}/descriptions/{language_code}", + "method": "GET", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\GetItemDescriptionRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items/{item_id}/descriptions_with_language_fallback/{language_code}", + "method": "GET", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\GetItemDescriptionWithFallbackRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/properties/{property_id}/descriptions/{language_code}", + "method": "GET", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\GetPropertyDescriptionRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/properties/{property_id}/descriptions_with_language_fallback/{language_code}", + "method": "GET", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\GetPropertyDescriptionWithFallbackRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items/{item_id}/descriptions/{language_code}", + "method": "PUT", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\SetItemDescriptionRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/properties/{property_id}/descriptions/{language_code}", + "method": "PUT", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\SetPropertyDescriptionRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items/{item_id}/descriptions/{language_code}", + "method": "DELETE", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\RemoveItemDescriptionRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/properties/{property_id}/descriptions/{language_code}", + "method": "DELETE", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\RemovePropertyDescriptionRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items/{item_id}/aliases", + "method": "GET", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\GetItemAliasesRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/properties/{property_id}/descriptions", + "method": "GET", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\GetPropertyDescriptionsRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/properties/{property_id}/aliases", + "method": "GET", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\GetPropertyAliasesRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items/{item_id}/aliases", + "method": "PATCH", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\PatchItemAliasesRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/properties/{property_id}/aliases", + "method": "PATCH", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\PatchPropertyAliasesRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items/{item_id}/aliases/{language_code}", + "method": "GET", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\GetItemAliasesInLanguageRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/properties/{property_id}/aliases/{language_code}", + "method": "GET", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\GetPropertyAliasesInLanguageRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items/{item_id}/aliases/{language_code}", + "method": "POST", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\AddItemAliasesInLanguageRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/properties/{property_id}/aliases/{language_code}", + "method": "POST", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\AddPropertyAliasesInLanguageRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items/{item_id}/sitelinks", + "method": "GET", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\GetSitelinksRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items/{item_id}/sitelinks", + "method": "PATCH", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\PatchSitelinksRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items/{item_id}/sitelinks/{site_id}", + "method": "GET", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\GetSitelinkRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items/{item_id}/sitelinks/{site_id}", + "method": "DELETE", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\RemoveSitelinkRouteHandler::factory" + }, + { + "path": "/wikibase/v1/entities/items/{item_id}/sitelinks/{site_id}", + "method": "PUT", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\SetSitelinkRouteHandler::factory" + }, + { + "path": "/wikibase/v1/openapi.json", + "method": "GET", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\GetOpenApiDocRouteHandler::factory" + }, + { + "path": "/wikibase/v1/property-data-types", + "method": "GET", + "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\GetPropertyDataTypesHandler::factory" + } + ], "SpecialPages": { "NewItem": { "class": "Wikibase\\Repo\\Specials\\SpecialNewItem", diff --git a/repo/rest-api/CHANGELOG.md b/repo/rest-api/CHANGELOG.md index d8cc1f2c885..a9d4564d6b4 100644 --- a/repo/rest-api/CHANGELOG.md +++ b/repo/rest-api/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG {#wb_rest_api_changelog} +## Version 1.0 + +* Wikibase REST API v1 released + ## Version 0.5 * Added label/description endpoints with language fallback ([T371605](https://phabricator.wikimedia.org/T371605)) diff --git a/repo/rest-api/README.md b/repo/rest-api/README.md index a11cef14df7..27dd4a63bea 100644 --- a/repo/rest-api/README.md +++ b/repo/rest-api/README.md @@ -4,7 +4,9 @@ ### Enable the REST API -To enable the production-ready routes, add the following line to your `LocalSettings.php` file: +**As of REL1_44, the Wikibase REST API is enabled when the Wikibase repo extension is loaded** + +To enable the production-ready routes, in versions prior to REL1_44, add the following line to your `LocalSettings.php` file: ```php $wgRestAPIAdditionalRouteFiles[] = 'extensions/Wikibase/repo/rest-api/routes.json'; diff --git a/repo/rest-api/docs/adr/0007_work_in_progress_endpoints.md b/repo/rest-api/docs/adr/0007_work_in_progress_endpoints.md index 50f83ecac5d..fdea48d8d93 100644 --- a/repo/rest-api/docs/adr/0007_work_in_progress_endpoints.md +++ b/repo/rest-api/docs/adr/0007_work_in_progress_endpoints.md @@ -1,6 +1,7 @@ # 7) Wikibase REST API work-in-progress endpoints {#rest_adr_0007} Date: 2023-02-01 +Updated: 2024-11-01 ## Status @@ -35,6 +36,10 @@ How to manage new features or changes to existing endpoints are outside the scop - Wikibase admins that create their own route file risk broken routes if our factories change. - We will be able to add new routes to the OpenAPI definition before they are ready, while still indicating the status of each route. +## November 2024 Changes + +* With the REST API v1 release, all production ready endpoints are now defined in the `extension-repo.json` file and enabled when the Wikibase repo extension is loaded. Therefore, once the v0 endpoints are deprecated, there will be no need for the `routes.json` file. In development endpoints will still be defined in the `route.dev.json` file. + [doc.wikimedia.org]: https://doc.wikimedia.org [`extension-repo.json`]: https://gerrit.wikimedia.org/g/mediawiki/extensions/Wikibase/+/758065e4967fcb9575a06302a80a84ccb762d373/extension-repo.json [OpenAPI Definition]: https://swagger.io/specification/ diff --git a/repo/rest-api/docs/loaders/openapi-loader.js b/repo/rest-api/docs/loaders/openapi-loader.js index 97a84ab23a4..cd20b81d829 100644 --- a/repo/rest-api/docs/loaders/openapi-loader.js +++ b/repo/rest-api/docs/loaders/openapi-loader.js @@ -20,7 +20,7 @@ module.exports = function ( _ ) { done( null, JSON.stringify( { ...spec, - servers: [ { url: baseUrl + '/wikibase/v0'} ] + servers: [ { url: baseUrl + '/wikibase/v1' } ] } ) ) } ) .catch( ( { message } ) => done( message ) ); diff --git a/repo/rest-api/routes.dev.json b/repo/rest-api/routes.dev.json index 275a84392d0..803bf45d959 100644 --- a/repo/rest-api/routes.dev.json +++ b/repo/rest-api/routes.dev.json @@ -1,6 +1,6 @@ [ { - "path": "/wikibase/v0/entities/properties", + "path": "/wikibase/v1/entities/properties", "method": "POST", "factory": "Wikibase\\Repo\\RestApi\\RouteHandlers\\CreatePropertyRouteHandler::factory" } diff --git a/repo/rest-api/specs/openapi.json b/repo/rest-api/specs/openapi.json index 164dc279e28..bc33420baeb 100644 --- a/repo/rest-api/specs/openapi.json +++ b/repo/rest-api/specs/openapi.json @@ -92,6 +92,6 @@ } ], "servers": [ - { "url": "https://wikibase.example/w/rest.php/wikibase/v0" } + { "url": "https://wikibase.example/w/rest.php/wikibase/v1" } ] } diff --git a/repo/rest-api/src/RouteHandlers/GetItemDescriptionRouteHandler.php b/repo/rest-api/src/RouteHandlers/GetItemDescriptionRouteHandler.php index 3d5a63c1eaa..4349e09fd4e 100644 --- a/repo/rest-api/src/RouteHandlers/GetItemDescriptionRouteHandler.php +++ b/repo/rest-api/src/RouteHandlers/GetItemDescriptionRouteHandler.php @@ -27,7 +27,7 @@ class GetItemDescriptionRouteHandler extends SimpleHandler { private const ITEM_ID_PATH_PARAM = 'item_id'; private const LANGUAGE_CODE_PATH_PARAM = 'language_code'; - public const ROUTE = '/wikibase/v0/entities/items/{item_id}/descriptions/{language_code}'; + public const ROUTE = '/wikibase/v1/entities/items/{item_id}/descriptions/{language_code}'; private GetItemDescription $useCase; private MiddlewareHandler $middlewareHandler; diff --git a/repo/rest-api/src/RouteHandlers/GetItemLabelRouteHandler.php b/repo/rest-api/src/RouteHandlers/GetItemLabelRouteHandler.php index 2eca00f4a52..62f9e9177cc 100644 --- a/repo/rest-api/src/RouteHandlers/GetItemLabelRouteHandler.php +++ b/repo/rest-api/src/RouteHandlers/GetItemLabelRouteHandler.php @@ -26,7 +26,7 @@ class GetItemLabelRouteHandler extends SimpleHandler { private const ITEM_ID_PATH_PARAM = 'item_id'; private const LANGUAGE_CODE_PATH_PARAM = 'language_code'; - public const ROUTE = '/wikibase/v0/entities/items/{item_id}/labels/{language_code}'; + public const ROUTE = '/wikibase/v1/entities/items/{item_id}/labels/{language_code}'; private GetItemLabel $useCase; private MiddlewareHandler $middlewareHandler; diff --git a/repo/rest-api/src/RouteHandlers/GetItemRouteHandler.php b/repo/rest-api/src/RouteHandlers/GetItemRouteHandler.php index 6b645df5e6e..46db2bb3516 100644 --- a/repo/rest-api/src/RouteHandlers/GetItemRouteHandler.php +++ b/repo/rest-api/src/RouteHandlers/GetItemRouteHandler.php @@ -33,7 +33,7 @@ */ class GetItemRouteHandler extends SimpleHandler { - public const ROUTE = '/wikibase/v0/entities/items/{item_id}'; + public const ROUTE = '/wikibase/v1/entities/items/{item_id}'; public const ITEM_ID_PATH_PARAM = 'item_id'; private const FIELDS_QUERY_PARAM = '_fields'; diff --git a/repo/rest-api/src/RouteHandlers/GetItemStatementRouteHandler.php b/repo/rest-api/src/RouteHandlers/GetItemStatementRouteHandler.php index 00eb5fac2f2..e35e8a0b819 100644 --- a/repo/rest-api/src/RouteHandlers/GetItemStatementRouteHandler.php +++ b/repo/rest-api/src/RouteHandlers/GetItemStatementRouteHandler.php @@ -28,7 +28,7 @@ class GetItemStatementRouteHandler extends SimpleHandler { public const ITEM_ID_PATH_PARAM = 'item_id'; public const STATEMENT_ID_PATH_PARAM = 'statement_id'; - public const ROUTE = '/wikibase/v0/entities/items/{item_id}/statements/{statement_id}'; + public const ROUTE = '/wikibase/v1/entities/items/{item_id}/statements/{statement_id}'; private GetItemStatement $getStatement; private StatementSerializer $statementSerializer; diff --git a/repo/rest-api/src/RouteHandlers/GetPropertyDescriptionRouteHandler.php b/repo/rest-api/src/RouteHandlers/GetPropertyDescriptionRouteHandler.php index 6fedda3e792..95e27a7c612 100644 --- a/repo/rest-api/src/RouteHandlers/GetPropertyDescriptionRouteHandler.php +++ b/repo/rest-api/src/RouteHandlers/GetPropertyDescriptionRouteHandler.php @@ -26,7 +26,7 @@ class GetPropertyDescriptionRouteHandler extends SimpleHandler { private const PROPERTY_ID_PATH_PARAM = 'property_id'; private const LANGUAGE_CODE_PATH_PARAM = 'language_code'; - public const ROUTE = '/wikibase/v0/entities/properties/{property_id}/descriptions/{language_code}'; + public const ROUTE = '/wikibase/v1/entities/properties/{property_id}/descriptions/{language_code}'; private GetPropertyDescription $useCase; private MiddlewareHandler $middlewareHandler; diff --git a/repo/rest-api/src/RouteHandlers/GetPropertyLabelRouteHandler.php b/repo/rest-api/src/RouteHandlers/GetPropertyLabelRouteHandler.php index 3ae25036f10..35ae57f7449 100644 --- a/repo/rest-api/src/RouteHandlers/GetPropertyLabelRouteHandler.php +++ b/repo/rest-api/src/RouteHandlers/GetPropertyLabelRouteHandler.php @@ -26,7 +26,7 @@ class GetPropertyLabelRouteHandler extends SimpleHandler { private const PROPERTY_ID_PATH_PARAM = 'property_id'; private const LANGUAGE_CODE_PATH_PARAM = 'language_code'; - public const ROUTE = '/wikibase/v0/entities/properties/{property_id}/labels/{language_code}'; + public const ROUTE = '/wikibase/v1/entities/properties/{property_id}/labels/{language_code}'; private GetPropertyLabel $useCase; private MiddlewareHandler $middlewareHandler; diff --git a/repo/rest-api/src/RouteHandlers/GetPropertyRouteHandler.php b/repo/rest-api/src/RouteHandlers/GetPropertyRouteHandler.php index 9df7e30301d..789df839071 100644 --- a/repo/rest-api/src/RouteHandlers/GetPropertyRouteHandler.php +++ b/repo/rest-api/src/RouteHandlers/GetPropertyRouteHandler.php @@ -30,7 +30,7 @@ */ class GetPropertyRouteHandler extends SimpleHandler { - public const ROUTE = '/wikibase/v0/entities/properties/{property_id}'; + public const ROUTE = '/wikibase/v1/entities/properties/{property_id}'; public const PROPERTY_ID_PATH_PARAM = 'property_id'; private const FIELDS_QUERY_PARAM = '_fields'; diff --git a/repo/rest-api/src/RouteHandlers/GetPropertyStatementRouteHandler.php b/repo/rest-api/src/RouteHandlers/GetPropertyStatementRouteHandler.php index e36892162d1..e151be72391 100644 --- a/repo/rest-api/src/RouteHandlers/GetPropertyStatementRouteHandler.php +++ b/repo/rest-api/src/RouteHandlers/GetPropertyStatementRouteHandler.php @@ -27,7 +27,7 @@ class GetPropertyStatementRouteHandler extends SimpleHandler { public const PROPERTY_ID_PATH_PARAM = 'property_id'; public const STATEMENT_ID_PATH_PARAM = 'statement_id'; - public const ROUTE = '/wikibase/v0/entities/properties/{property_id}/statements/{statement_id}'; + public const ROUTE = '/wikibase/v1/entities/properties/{property_id}/statements/{statement_id}'; private GetPropertyStatement $getStatement; private StatementSerializer $statementSerializer; diff --git a/repo/rest-api/src/RouteHandlers/openapi.json b/repo/rest-api/src/RouteHandlers/openapi.json index 9e1410fe2d8..e52a303db63 100644 --- a/repo/rest-api/src/RouteHandlers/openapi.json +++ b/repo/rest-api/src/RouteHandlers/openapi.json @@ -7563,7 +7563,7 @@ ], "servers": [ { - "url": "https://wikibase.example/w/rest.php/wikibase/v0" + "url": "https://wikibase.example/w/rest.php/wikibase/v1" } ] } diff --git a/repo/rest-api/tests/mocha/api-testing/GetItemAliasesInLanguageTest.js b/repo/rest-api/tests/mocha/api-testing/GetItemAliasesInLanguageTest.js index 54f6c049079..b3e3fa16495 100644 --- a/repo/rest-api/tests/mocha/api-testing/GetItemAliasesInLanguageTest.js +++ b/repo/rest-api/tests/mocha/api-testing/GetItemAliasesInLanguageTest.js @@ -46,7 +46,7 @@ describe( newGetItemAliasesInLanguageRequestBuilder().getRouteDescription(), () expect( response ).to.have.status( 308 ); assert.isTrue( new URL( response.headers.location ).pathname - .endsWith( `rest.php/wikibase/v0/entities/items/${redirectTarget}/aliases/en` ) + .endsWith( `rest.php/wikibase/v1/entities/items/${redirectTarget}/aliases/en` ) ); } ); diff --git a/repo/rest-api/tests/mocha/api-testing/GetItemAliasesTest.js b/repo/rest-api/tests/mocha/api-testing/GetItemAliasesTest.js index 5ac481aae17..4dd0817f449 100644 --- a/repo/rest-api/tests/mocha/api-testing/GetItemAliasesTest.js +++ b/repo/rest-api/tests/mocha/api-testing/GetItemAliasesTest.js @@ -70,7 +70,7 @@ describe( newGetItemAliasesRequestBuilder().getRouteDescription(), () => { expect( response ).to.have.status( 308 ); assert.isTrue( new URL( response.headers.location ).pathname - .endsWith( `rest.php/wikibase/v0/entities/items/${redirectTarget}/aliases` ) + .endsWith( `rest.php/wikibase/v1/entities/items/${redirectTarget}/aliases` ) ); } ); } ); diff --git a/repo/rest-api/tests/mocha/api-testing/GetItemDescriptionTest.js b/repo/rest-api/tests/mocha/api-testing/GetItemDescriptionTest.js index 0b37d2391a0..38866e8395b 100644 --- a/repo/rest-api/tests/mocha/api-testing/GetItemDescriptionTest.js +++ b/repo/rest-api/tests/mocha/api-testing/GetItemDescriptionTest.js @@ -92,7 +92,7 @@ describe( newGetItemDescriptionRequestBuilder().getRouteDescription(), () => { expect( response ).to.have.status( 308 ); assert.isTrue( new URL( response.headers.location ).pathname - .endsWith( `rest.php/wikibase/v0/entities/items/${redirectTarget}/descriptions/en` ) + .endsWith( `rest.php/wikibase/v1/entities/items/${redirectTarget}/descriptions/en` ) ); } ); } ); diff --git a/repo/rest-api/tests/mocha/api-testing/GetItemDescriptionsTest.js b/repo/rest-api/tests/mocha/api-testing/GetItemDescriptionsTest.js index 1dfdabaa0af..3097e6507c9 100644 --- a/repo/rest-api/tests/mocha/api-testing/GetItemDescriptionsTest.js +++ b/repo/rest-api/tests/mocha/api-testing/GetItemDescriptionsTest.js @@ -68,7 +68,7 @@ describe( newGetItemDescriptionsRequestBuilder().getRouteDescription(), () => { expect( response ).to.have.status( 308 ); assert.isTrue( new URL( response.headers.location ).pathname - .endsWith( `rest.php/wikibase/v0/entities/items/${redirectTarget}/descriptions` ) + .endsWith( `rest.php/wikibase/v1/entities/items/${redirectTarget}/descriptions` ) ); } ); } ); diff --git a/repo/rest-api/tests/mocha/api-testing/GetItemLabelTest.js b/repo/rest-api/tests/mocha/api-testing/GetItemLabelTest.js index f853bf1467e..0cdd7ff55c6 100644 --- a/repo/rest-api/tests/mocha/api-testing/GetItemLabelTest.js +++ b/repo/rest-api/tests/mocha/api-testing/GetItemLabelTest.js @@ -63,7 +63,7 @@ describe( newGetItemLabelRequestBuilder().getRouteDescription(), () => { expect( response ).to.have.status( 308 ); assert.isTrue( new URL( response.headers.location ).pathname - .endsWith( `rest.php/wikibase/v0/entities/items/${redirectTarget}/labels/en` ) + .endsWith( `rest.php/wikibase/v1/entities/items/${redirectTarget}/labels/en` ) ); } ); diff --git a/repo/rest-api/tests/mocha/api-testing/GetItemLabelWithFallbackTest.js b/repo/rest-api/tests/mocha/api-testing/GetItemLabelWithFallbackTest.js index 1de0c984b02..73b1a4c6b51 100644 --- a/repo/rest-api/tests/mocha/api-testing/GetItemLabelWithFallbackTest.js +++ b/repo/rest-api/tests/mocha/api-testing/GetItemLabelWithFallbackTest.js @@ -45,7 +45,7 @@ describe( newGetItemLabelWithFallbackRequestBuilder().getRouteDescription(), () expect( response ).to.have.status( 307 ); assert.isTrue( new URL( response.headers.location ).pathname - .endsWith( `rest.php/wikibase/v0/entities/items/${itemId}/labels/ar` ) + .endsWith( `rest.php/wikibase/v1/entities/items/${itemId}/labels/ar` ) ); } ); @@ -55,7 +55,7 @@ describe( newGetItemLabelWithFallbackRequestBuilder().getRouteDescription(), () expect( response ).to.have.status( 307 ); assert.isTrue( new URL( response.headers.location ).pathname.endsWith( - `rest.php/wikibase/v0/entities/items/${itemId}/labels/mul` + `rest.php/wikibase/v1/entities/items/${itemId}/labels/mul` ) ); } ); @@ -70,7 +70,7 @@ describe( newGetItemLabelWithFallbackRequestBuilder().getRouteDescription(), () expect( response ).to.have.status( 308 ); assert.isTrue( new URL( response.headers.location ).pathname - .endsWith( `rest.php/wikibase/v0/entities/items/${redirectTarget}/labels_with_language_fallback/en` ) + .endsWith( `rest.php/wikibase/v1/entities/items/${redirectTarget}/labels_with_language_fallback/en` ) ); } ); diff --git a/repo/rest-api/tests/mocha/api-testing/GetItemLabelsTest.js b/repo/rest-api/tests/mocha/api-testing/GetItemLabelsTest.js index 82108e18031..a39c13f5ae2 100644 --- a/repo/rest-api/tests/mocha/api-testing/GetItemLabelsTest.js +++ b/repo/rest-api/tests/mocha/api-testing/GetItemLabelsTest.js @@ -65,7 +65,7 @@ describe( newGetItemLabelsRequestBuilder().getRouteDescription(), () => { expect( response ).to.have.status( 308 ); assert.isTrue( new URL( response.headers.location ).pathname - .endsWith( `rest.php/wikibase/v0/entities/items/${redirectTarget}/labels` ) + .endsWith( `rest.php/wikibase/v1/entities/items/${redirectTarget}/labels` ) ); } ); } ); diff --git a/repo/rest-api/tests/mocha/api-testing/GetItemStatementsTest.js b/repo/rest-api/tests/mocha/api-testing/GetItemStatementsTest.js index 848aafb44b4..bd660a32983 100644 --- a/repo/rest-api/tests/mocha/api-testing/GetItemStatementsTest.js +++ b/repo/rest-api/tests/mocha/api-testing/GetItemStatementsTest.js @@ -127,7 +127,7 @@ describe( newGetItemStatementsRequestBuilder().getRouteDescription(), () => { expect( response ).to.have.status( 308 ); assert.isTrue( new URL( response.headers.location ).pathname - .endsWith( `rest.php/wikibase/v0/entities/items/${redirectTarget}/statements` ) + .endsWith( `rest.php/wikibase/v1/entities/items/${redirectTarget}/statements` ) ); } ); diff --git a/repo/rest-api/tests/mocha/api-testing/GetItemTest.js b/repo/rest-api/tests/mocha/api-testing/GetItemTest.js index 20e94249d2d..23cc4fa8ba0 100644 --- a/repo/rest-api/tests/mocha/api-testing/GetItemTest.js +++ b/repo/rest-api/tests/mocha/api-testing/GetItemTest.js @@ -159,7 +159,7 @@ describe( newGetItemRequestBuilder().getRouteDescription(), () => { expect( response ).to.have.status( 308 ); const redirectLocation = new URL( response.headers.location ); - assert.isTrue( redirectLocation.pathname.endsWith( `rest.php/wikibase/v0/entities/items/${testItemId}` ) ); + assert.isTrue( redirectLocation.pathname.endsWith( `rest.php/wikibase/v1/entities/items/${testItemId}` ) ); assert.empty( redirectLocation.search ); } ); diff --git a/repo/rest-api/tests/mocha/api-testing/GetPropertyDescriptionWithFallbackTest.js b/repo/rest-api/tests/mocha/api-testing/GetPropertyDescriptionWithFallbackTest.js index 63033be4e87..abbf86e5c5e 100644 --- a/repo/rest-api/tests/mocha/api-testing/GetPropertyDescriptionWithFallbackTest.js +++ b/repo/rest-api/tests/mocha/api-testing/GetPropertyDescriptionWithFallbackTest.js @@ -42,7 +42,7 @@ describe( newGetPropertyDescriptionWithFallbackRequestBuilder().getRouteDescript assert.isTrue( new URL( response.headers.location ).pathname .endsWith( - `rest.php/wikibase/v0/entities/properties/${propertyId}/descriptions/${fallbackLanguageWithDescription}` + `rest.php/wikibase/v1/entities/properties/${propertyId}/descriptions/${fallbackLanguageWithDescription}` ) ); } ); diff --git a/repo/rest-api/tests/mocha/api-testing/GetPropertyLabelWithFallbackTest.js b/repo/rest-api/tests/mocha/api-testing/GetPropertyLabelWithFallbackTest.js index fa2139756f9..5db66461b1c 100644 --- a/repo/rest-api/tests/mocha/api-testing/GetPropertyLabelWithFallbackTest.js +++ b/repo/rest-api/tests/mocha/api-testing/GetPropertyLabelWithFallbackTest.js @@ -51,7 +51,7 @@ describe( newGetPropertyLabelWithFallbackRequestBuilder().getRouteDescription(), expect( response ).to.have.status( 307 ); assert.isTrue( new URL( response.headers.location ).pathname.endsWith( - `rest.php/wikibase/v0/entities/properties/${propertyId}/labels/de` + `rest.php/wikibase/v1/entities/properties/${propertyId}/labels/de` ) ); } ); @@ -63,7 +63,7 @@ describe( newGetPropertyLabelWithFallbackRequestBuilder().getRouteDescription(), expect( response ).to.have.status( 307 ); assert.isTrue( new URL( response.headers.location ).pathname.endsWith( - `rest.php/wikibase/v0/entities/properties/${propertyId}/labels/mul` + `rest.php/wikibase/v1/entities/properties/${propertyId}/labels/mul` ) ); } ); diff --git a/repo/rest-api/tests/mocha/api-testing/GetSitelinkTest.js b/repo/rest-api/tests/mocha/api-testing/GetSitelinkTest.js index 51316ae380c..c10f4c7e7e1 100644 --- a/repo/rest-api/tests/mocha/api-testing/GetSitelinkTest.js +++ b/repo/rest-api/tests/mocha/api-testing/GetSitelinkTest.js @@ -101,7 +101,7 @@ describe( newGetSitelinkRequestBuilder().getRouteDescription(), () => { expect( response ).to.have.status( 308 ); assert.isTrue( new URL( response.headers.location ).pathname - .endsWith( `rest.php/wikibase/v0/entities/items/${redirectTarget}/sitelinks/${siteId}` ) + .endsWith( `rest.php/wikibase/v1/entities/items/${redirectTarget}/sitelinks/${siteId}` ) ); } ); diff --git a/repo/rest-api/tests/mocha/api-testing/GetSitelinksTest.js b/repo/rest-api/tests/mocha/api-testing/GetSitelinksTest.js index c007032e771..096b0d10003 100644 --- a/repo/rest-api/tests/mocha/api-testing/GetSitelinksTest.js +++ b/repo/rest-api/tests/mocha/api-testing/GetSitelinksTest.js @@ -85,7 +85,7 @@ describe( newGetSitelinksRequestBuilder().getRouteDescription(), () => { expect( response ).to.have.status( 308 ); assert.isTrue( new URL( response.headers.location ).pathname - .endsWith( `rest.php/wikibase/v0/entities/items/${redirectTarget}/sitelinks` ) + .endsWith( `rest.php/wikibase/v1/entities/items/${redirectTarget}/sitelinks` ) ); } ); diff --git a/repo/rest-api/tests/mocha/helpers/RequestBuilder.js b/repo/rest-api/tests/mocha/helpers/RequestBuilder.js index 7cf8fad75bb..cc655b9e03f 100644 --- a/repo/rest-api/tests/mocha/helpers/RequestBuilder.js +++ b/repo/rest-api/tests/mocha/helpers/RequestBuilder.js @@ -6,7 +6,7 @@ const SwaggerParser = require( '@apidevtools/swagger-parser' ); const { default: OpenAPIRequestCoercer } = require( 'openapi-request-coercer' ); const { default: OpenAPIRequestValidator } = require( 'openapi-request-validator' ); -const basePath = 'rest.php/wikibase/v0'; +const basePath = 'rest.php/wikibase/v1'; const builtSpec = JSON.parse( readFileSync( `${__dirname}/../../../src/RouteHandlers/openapi.json` ) ); // "static" because it can be shared across requests, and we don't want to dereference it every time diff --git a/repo/rest-api/tests/mocha/openapi-validation/hooks.js b/repo/rest-api/tests/mocha/openapi-validation/hooks.js index daa2c82e1bc..abd7e7f7605 100644 --- a/repo/rest-api/tests/mocha/openapi-validation/hooks.js +++ b/repo/rest-api/tests/mocha/openapi-validation/hooks.js @@ -14,7 +14,7 @@ exports.mochaHooks = { beforeAll: [ async function () { const spec = await SwaggerParser.dereference( './specs/openapi.json' ); - spec.servers = [ { url: new REST().req.app + 'rest.php/wikibase/v0' } ]; + spec.servers = [ { url: new REST().req.app + 'rest.php/wikibase/v1' } ]; chai.use( chaiResponseValidator( spec ) ); } ] diff --git a/repo/rest-api/tests/phpunit/RouteHandlers/RouteHandlersTest.php b/repo/rest-api/tests/phpunit/RouteHandlers/RouteHandlersTest.php index 3037f45e6fd..e66d7427272 100644 --- a/repo/rest-api/tests/phpunit/RouteHandlers/RouteHandlersTest.php +++ b/repo/rest-api/tests/phpunit/RouteHandlers/RouteHandlersTest.php @@ -163,15 +163,15 @@ class RouteHandlersTest extends MediaWikiIntegrationTestCase { private static array $routesData = []; private static array $prodRoutesData = []; private const EXCLUDED_ROUTES = [ - '/wikibase/v0/openapi.json', - '/wikibase/v0/property-data-types', + '/wikibase/v1/openapi.json', + '/wikibase/v1/property-data-types', ]; public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); $notExcluded = fn( array $route ) => !in_array( $route['path'], self::EXCLUDED_ROUTES ); self::$prodRoutesData = array_filter( - json_decode( file_get_contents( __DIR__ . '/../../../routes.json' ), true ), + json_decode( file_get_contents( __DIR__ . '/../../../../../extension-repo.json' ), true )[ 'RestRoutes' ], $notExcluded ); self::$routesData = array_merge( diff --git a/repo/rest-api/tests/phpunit/RouteHandlers/RoutesTest.php b/repo/rest-api/tests/phpunit/RouteHandlers/RoutesTest.php index 83dcf46e854..e45ae57fd94 100644 --- a/repo/rest-api/tests/phpunit/RouteHandlers/RoutesTest.php +++ b/repo/rest-api/tests/phpunit/RouteHandlers/RoutesTest.php @@ -17,7 +17,7 @@ class RoutesTest extends TestCase { public function testRoutesMatch(): void { $objectFactory = MediaWikiServices::getInstance()->getObjectFactory(); $routes = array_merge( - json_decode( file_get_contents( __DIR__ . '/../../../routes.json' ), true ), + json_decode( file_get_contents( __DIR__ . '/../../../../../extension-repo.json' ), true )[ 'RestRoutes' ], json_decode( file_get_contents( __DIR__ . '/../../../routes.dev.json' ), true ), );