chg: remove the /api/v1 prefix for api endpoints

pull/80/head
Luciano Righetti 2022-01-19 16:22:44 +01:00
parent 01b4bc9bac
commit 25b7d167f1
42 changed files with 96 additions and 109 deletions

View File

@ -92,27 +92,14 @@ $routes->prefix('Open', function (RouteBuilder $routes) {
$routes->fallbacks(DashedRoute::class);
});
// API routes
$routes->scope('/api', function (RouteBuilder $routes) {
// $routes->applyMiddleware('ratelimit', 'auth.api');
$routes->scope('/v1', function (RouteBuilder $routes) {
// $routes->applyMiddleware('v1compat');
$routes->setExtensions(['json']);
// Generic API route
$routes->connect('/{controller}/{action}/*');
// Tags plugin routes
$routes->plugin(
'tags',
['path' => '/tags'],
function ($routes) {
$routes->setRouteClass(DashedRoute::class);
$routes->connect(
'/{action}/*',
['controller' => 'Tags']
);
}
);
});
});
/*
* If you need a different set of middleware or none at all,
* open new scope and define routes there.
*
* ```
* $routes->scope('/api', function (RouteBuilder $builder) {
* // No $builder->applyMiddleware() here.
* // Connect API actions here.
* });
* ```
*/

View File

@ -13,7 +13,7 @@ class AddAuthKeyApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/authKeys/add';
protected const ENDPOINT = '/authKeys/add';
protected $fixtures = [
'app.Organisations',

View File

@ -12,7 +12,7 @@ class DeleteAuthKeyApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/authKeys/delete';
protected const ENDPOINT = '/authKeys/delete';
protected $fixtures = [
'app.Organisations',

View File

@ -12,7 +12,7 @@ class IndexAuthKeysApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/authKeys/index';
protected const ENDPOINT = '/authKeys/index';
protected $fixtures = [
'app.Organisations',

View File

@ -13,7 +13,7 @@ class AddBroodApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/broods/add';
protected const ENDPOINT = '/broods/add';
protected $fixtures = [
'app.Organisations',

View File

@ -13,7 +13,7 @@ class DeleteBroodApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/broods/delete';
protected const ENDPOINT = '/broods/delete';
protected $fixtures = [
'app.Organisations',

View File

@ -14,7 +14,7 @@ class EditBroodApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/broods/edit';
protected const ENDPOINT = '/broods/edit';
protected $fixtures = [
'app.Organisations',

View File

@ -13,7 +13,7 @@ class IndexBroodsApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/users/index';
protected const ENDPOINT = '/users/index';
protected $fixtures = [
'app.Organisations',

View File

@ -16,7 +16,7 @@ class TestBroodConnectionApiTest extends TestCase
use ApiTestTrait;
use WireMockTestTrait;
protected const ENDPOINT = '/api/v1/broods/testConnection';
protected const ENDPOINT = '/broods/testConnection';
protected $fixtures = [
'app.Organisations',

View File

@ -13,7 +13,7 @@ class ViewBroodApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/broods/view';
protected const ENDPOINT = '/broods/view';
protected $fixtures = [
'app.Organisations',

View File

@ -14,7 +14,7 @@ class AddEncryptionKeyApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/encryptionKeys/add';
protected const ENDPOINT = '/encryptionKeys/add';
protected $fixtures = [
'app.Organisations',

View File

@ -13,7 +13,7 @@ class DeleteEncryptionKeyApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/encryptionKeys/delete';
protected const ENDPOINT = '/encryptionKeys/delete';
protected $fixtures = [
'app.Organisations',

View File

@ -13,7 +13,7 @@ class EditEncryptionKeyApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/encryptionKeys/edit';
protected const ENDPOINT = '/encryptionKeys/edit';
protected $fixtures = [
'app.Organisations',

View File

@ -13,7 +13,7 @@ class IndexEncryptionKeysApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/encryptionKeys/index';
protected const ENDPOINT = '/encryptionKeys/index';
protected $fixtures = [
'app.Organisations',

View File

@ -13,7 +13,7 @@ class ViewEncryptionKeyApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/encryptionKeys/view';
protected const ENDPOINT = '/encryptionKeys/view';
protected $fixtures = [
'app.Organisations',

View File

@ -12,7 +12,7 @@ class CreateInboxEntryApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/inbox/createEntry';
protected const ENDPOINT = '/inbox/createEntry';
protected $fixtures = [
'app.Inbox',

View File

@ -13,7 +13,7 @@ class IndexInboxApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/inbox/index';
protected const ENDPOINT = '/inbox/index';
protected $fixtures = [
'app.Inbox',

View File

@ -12,7 +12,7 @@ class AddIndividualApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/individuals/add';
protected const ENDPOINT = '/individuals/add';
protected $fixtures = [
'app.Organisations',

View File

@ -13,7 +13,7 @@ class DeleteIndividualApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/individuals/delete';
protected const ENDPOINT = '/individuals/delete';
protected $fixtures = [
'app.Organisations',

View File

@ -13,7 +13,7 @@ class EditIndividualApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/individuals/edit';
protected const ENDPOINT = '/individuals/edit';
protected $fixtures = [
'app.Organisations',

View File

@ -13,7 +13,7 @@ class IndexIndividualsApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/individuals/index';
protected const ENDPOINT = '/individuals/index';
protected $fixtures = [
'app.Organisations',

View File

@ -13,7 +13,7 @@ class ViewIndividualApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/individuals/view';
protected const ENDPOINT = '/individuals/view';
protected $fixtures = [
'app.Organisations',

View File

@ -12,7 +12,7 @@ class AddOrganisationApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/organisations/add';
protected const ENDPOINT = '/organisations/add';
protected $fixtures = [
'app.Organisations',

View File

@ -14,7 +14,7 @@ class DeleteOrganisationApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/organisations/delete';
protected const ENDPOINT = '/organisations/delete';
protected $fixtures = [
'app.Organisations',

View File

@ -13,7 +13,7 @@ class EditOrganisationApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/organisations/edit';
protected const ENDPOINT = '/organisations/edit';
protected $fixtures = [
'app.Organisations',

View File

@ -13,7 +13,7 @@ class IndexOrganisationApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/organisations/index';
protected const ENDPOINT = '/organisations/index';
protected $fixtures = [
'app.Organisations',

View File

@ -14,7 +14,7 @@ class TagOrganisationApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/organisations/tag';
protected const ENDPOINT = '/organisations/tag';
protected $fixtures = [
'app.TagsTags',

View File

@ -14,7 +14,7 @@ class UntagOrganisationApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/organisations/untag';
protected const ENDPOINT = '/organisations/untag';
protected $fixtures = [
'app.TagsTags',

View File

@ -13,7 +13,7 @@ class ViewOrganisationApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/organisations/view';
protected const ENDPOINT = '/organisations/view';
protected $fixtures = [
'app.TagsTags',

View File

@ -14,7 +14,7 @@ class AddSharingGroupApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/sharingGroups/add';
protected const ENDPOINT = '/sharingGroups/add';
protected $fixtures = [
'app.Organisations',

View File

@ -13,7 +13,7 @@ class DeleteSharingGroupApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/sharingGroups/delete';
protected const ENDPOINT = '/sharingGroups/delete';
protected $fixtures = [
'app.Organisations',

View File

@ -13,7 +13,7 @@ class EditSharingGroupApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/sharingGroups/edit';
protected const ENDPOINT = '/sharingGroups/edit';
protected $fixtures = [
'app.Organisations',

View File

@ -13,7 +13,7 @@ class IndexSharingGroupsApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/sharingGroups/index';
protected const ENDPOINT = '/sharingGroups/index';
protected $fixtures = [
'app.Organisations',

View File

@ -13,7 +13,7 @@ class ViewSharingGroupApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/sharingGroups/view';
protected const ENDPOINT = '/sharingGroups/view';
protected $fixtures = [
'app.Organisations',

View File

@ -12,7 +12,7 @@ class IndexTagsApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/tags/index';
protected const ENDPOINT = '/tags/index';
protected $fixtures = [
'app.TagsTags',

View File

@ -15,7 +15,7 @@ class AddUserApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/users/add';
protected const ENDPOINT = '/users/add';
protected $fixtures = [
'app.Organisations',

View File

@ -17,7 +17,7 @@ class ChangePasswordApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/users/edit';
protected const ENDPOINT = '/users/edit';
/** @var \Cake\Auth\FormAuthenticate */
protected $auth;

View File

@ -13,7 +13,7 @@ class DeleteUserApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/users/delete';
protected const ENDPOINT = '/users/delete';
protected $fixtures = [
'app.Organisations',

View File

@ -14,7 +14,7 @@ class EditUserApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/users/edit';
protected const ENDPOINT = '/users/edit';
protected $fixtures = [
'app.Organisations',

View File

@ -13,7 +13,7 @@ class IndexUsersApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/users/index';
protected const ENDPOINT = '/users/index';
protected $fixtures = [
'app.Organisations',

View File

@ -13,7 +13,7 @@ class ViewUserApiTest extends TestCase
{
use ApiTestTrait;
protected const ENDPOINT = '/api/v1/users/view';
protected const ENDPOINT = '/users/view';
protected $fixtures = [
'app.Organisations',

View File

@ -29,7 +29,7 @@ tags:
description: "Authkeys are used for API access. A user can have more than one authkey, so if you would like to use separate keys per tool that queries Cerebrate, add additional keys. Use the comment field to make identifying your keys easier."
paths:
/api/v1/individuals/index:
/individuals/index:
get:
summary: "Get individuals list"
operationId: getIndividuals
@ -47,7 +47,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/individuals/view/{individualId}:
/individuals/view/{individualId}:
get:
summary: "Get individual by ID"
operationId: getIndividualById
@ -65,7 +65,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/individuals/add:
/individuals/add:
post:
summary: "Add individual"
operationId: addIndividual
@ -83,7 +83,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/individuals/edit/{individualId}:
/individuals/edit/{individualId}:
put:
summary: "Edit individual"
operationId: editIndividual
@ -103,7 +103,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/individuals/delete/{individualId}:
/individuals/delete/{individualId}:
delete:
summary: "Delete individual by ID"
operationId: deleteIndividualById
@ -121,7 +121,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/users/index:
/users/index:
get:
summary: "Get users list"
operationId: getUsers
@ -139,7 +139,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/users/view:
/users/view:
get:
summary: "Get information about the current user"
operationId: viewUserMe
@ -155,7 +155,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/users/view/{userId}:
/users/view/{userId}:
get:
summary: "Get information of a user by ID"
operationId: viewUserById
@ -173,7 +173,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/users/add:
/users/add:
post:
summary: "Add user"
operationId: addUser
@ -191,7 +191,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/users/edit:
/users/edit:
put:
summary: "Edit current user"
operationId: editUser
@ -209,7 +209,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/users/edit/{userId}:
/users/edit/{userId}:
put:
summary: "Edit current user"
operationId: editUserById
@ -229,7 +229,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/users/delete/{userId}:
/users/delete/{userId}:
delete:
summary: "Delete user by ID"
operationId: deleteUserById
@ -247,7 +247,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/organisations/add:
/organisations/add:
post:
summary: "Add organisation"
operationId: addOrganisation
@ -265,7 +265,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/organisations/edit/{organisationId}:
/organisations/edit/{organisationId}:
put:
summary: "Edit organisation"
operationId: editOrganisation
@ -285,7 +285,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/organisations/index:
/organisations/index:
get:
summary: "Get organisations"
operationId: getOrganisations
@ -303,7 +303,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/organisations/view/{organisationId}:
/organisations/view/{organisationId}:
get:
summary: "View organisation by ID"
operationId: getOrganisationById
@ -321,7 +321,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/organisations/delete/{organisationId}:
/organisations/delete/{organisationId}:
delete:
summary: "Delete organisation by ID"
operationId: deleteOrganisationById
@ -339,7 +339,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/organisations/tag/{organisationId}:
/organisations/tag/{organisationId}:
post:
summary: "Tag organisation by ID"
operationId: tagOrganisationById
@ -359,7 +359,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/organisations/untag/{organisationId}:
/organisations/untag/{organisationId}:
post:
summary: "Remove organisation tag by ID"
operationId: untagOrganisationById
@ -379,7 +379,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/tags/index:
/tags/index:
get:
summary: "Get tags list"
operationId: getTags
@ -397,7 +397,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/inbox/index:
/inbox/index:
get:
summary: "Get inbox list"
operationId: getinbox
@ -415,7 +415,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/inbox/createEntry/User/Registration:
/inbox/createEntry/User/Registration:
post:
summary: "Create user registration inbox entry"
operationId: createInboxEntry
@ -433,7 +433,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/sharingGroups/index:
/sharingGroups/index:
get:
summary: "Get a sharing groups list"
operationId: getSharingGroups
@ -451,7 +451,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/sharingGroups/add:
/sharingGroups/add:
post:
summary: "Add sharing group"
operationId: addSharingGroup
@ -469,7 +469,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/sharingGroups/view/{sharingGroupId}:
/sharingGroups/view/{sharingGroupId}:
get:
summary: "Get sharing group by ID"
operationId: getSharingGroupById
@ -487,7 +487,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/sharingGroups/delete/{sharingGroupId}:
/sharingGroups/delete/{sharingGroupId}:
delete:
summary: "Delete sharing group by ID"
operationId: deleteSharingGroupById
@ -505,7 +505,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/sharingGroups/edit/{sharingGroupId}:
/sharingGroups/edit/{sharingGroupId}:
put:
summary: "Edit sharing group"
operationId: editSharingGroup
@ -525,7 +525,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/broods/index:
/broods/index:
get:
summary: "Get broods list"
operationId: getBroods
@ -543,7 +543,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/broods/view/{broodId}:
/broods/view/{broodId}:
get:
summary: "Get brood by ID"
operationId: getBroodById
@ -561,7 +561,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/broods/add:
/broods/add:
post:
summary: "Add brood"
operationId: addBrood
@ -579,7 +579,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/broods/edit/{broodId}:
/broods/edit/{broodId}:
put:
summary: "Edit brood"
operationId: editBrood
@ -599,7 +599,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/broods/delete/{broodId}:
/broods/delete/{broodId}:
delete:
summary: "Delete brood by ID"
operationId: deleteBroodById
@ -617,7 +617,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/broods/testConnection/{broodId}:
/broods/testConnection/{broodId}:
get:
summary: "Test brood connection by ID"
operationId: testBroodConnectionById
@ -636,7 +636,7 @@ paths:
$ref: "#/components/responses/ApiErrorResponse"
# EncryptionKeys
/api/v1/encryptionKeys/index:
/encryptionKeys/index:
get:
summary: "Get encryption keys list"
operationId: getEncryptionKeys
@ -654,7 +654,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/encryptionKeys/view/{encryptionKeyId}:
/encryptionKeys/view/{encryptionKeyId}:
get:
summary: "Get encryption key by ID"
operationId: getEncryptionKeyId
@ -672,7 +672,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/encryptionKeys/add:
/encryptionKeys/add:
post:
summary: "Add encryption key"
operationId: addEncryptionKey
@ -690,7 +690,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/encryptionKeys/edit/{encryptionKeyId}:
/encryptionKeys/edit/{encryptionKeyId}:
put:
summary: "Edit encryption key"
operationId: editEncryptionKey
@ -710,7 +710,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/encryptionKeys/delete/{encryptionKeyId}:
/encryptionKeys/delete/{encryptionKeyId}:
delete:
summary: "Delete encryption key by ID"
operationId: deleteEncryptionKeyById
@ -729,7 +729,7 @@ paths:
$ref: "#/components/responses/ApiErrorResponse"
# AuthKeys
/api/v1/authKeys/index:
/authKeys/index:
get:
summary: "Get auth keys list"
operationId: getAuthKeys
@ -747,7 +747,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/authKeys/add:
/authKeys/add:
post:
summary: "Add auth keys"
operationId: addAuthKey
@ -765,7 +765,7 @@ paths:
default:
$ref: "#/components/responses/ApiErrorResponse"
/api/v1/authKeys/delete/{authKeyId}:
/authKeys/delete/{authKeyId}:
delete:
summary: "Delete auth key by ID"
operationId: deleteAuthKeyById
@ -1374,7 +1374,7 @@ components:
type: string
url:
type: string
example: "/api/v1/users"
example: "/users"
code:
type: integer
example: 500
@ -1391,7 +1391,7 @@ components:
example: "Authentication failed. Please make sure you pass the API key of an API enabled user along in the Authorization header."
url:
type: string
example: "/api/v1/users"
example: "/users"
code:
type: integer
example: 403
@ -1408,7 +1408,7 @@ components:
example: "You do not have permission to use this functionality."
url:
type: string
example: "/api/v1/users/index"
example: "/users/index"
code:
type: integer
example: 405
@ -1425,7 +1425,7 @@ components:
example: "Invalid user"
url:
type: string
example: "/api/v1/users/users/view/1234"
example: "/users/users/view/1234"
code:
type: integer
example: 404