Skip to content

Commit 4fd67ae

Browse files
committed
Fix/Enh. OpenAPI
1 parent 922fff9 commit 4fd67ae

26 files changed

Lines changed: 282 additions & 322 deletions

src/lib/Server/Controller/Bookmark/BookmarkCreateController.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,22 @@
2323
uriTemplate: '/bookmark/{locationId}',
2424
extraProperties: [OpenApiFactory::OVERRIDE_OPENAPI_RESPONSES => false],
2525
openapi: new Model\Operation(
26+
operationId: 'ibexa.rest.create_bookmark',
2627
summary: 'Create bookmark',
2728
description: 'Add given Location to bookmarks of the current user.',
2829
tags: [
2930
'Bookmark',
3031
],
3132
parameters: [
33+
new Model\Parameter(
34+
name: 'X-CSRF-Token',
35+
in: 'header',
36+
required: true,
37+
description: 'The CSRF Token needed on all unsafe HTTP methods with session.',
38+
schema: [
39+
'type' => 'string',
40+
],
41+
),
3242
new Model\Parameter(
3343
name: 'locationId',
3444
in: 'path',
@@ -38,6 +48,10 @@
3848
],
3949
),
4050
],
51+
requestBody: new Model\RequestBody(
52+
description: 'No payload required',
53+
content: new \ArrayObject(),
54+
),
4155
responses: [
4256
Response::HTTP_CREATED => [
4357
'description' => 'Created.',
@@ -52,9 +66,6 @@
5266
'description' => 'Error - Location is already bookmarked.',
5367
],
5468
],
55-
requestBody: new Model\RequestBody(
56-
content: new \ArrayObject(),
57-
),
5869
),
5970
)]
6071
class BookmarkCreateController extends RestController

src/lib/Server/Controller/Bookmark/BookmarkDeleteController.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,22 @@
2222
#[Delete(
2323
uriTemplate: '/bookmark/{locationId}',
2424
openapi: new Model\Operation(
25+
operationId: 'ibexa.rest.delete_bookmark',
2526
summary: 'Delete bookmark',
2627
description: 'Deletes the given Location from bookmarks of the current user.',
2728
tags: [
2829
'Bookmark',
2930
],
3031
parameters: [
32+
new Model\Parameter(
33+
name: 'X-CSRF-Token',
34+
in: 'header',
35+
required: true,
36+
description: 'The CSRF Token needed on all unsafe HTTP methods with session.',
37+
schema: [
38+
'type' => 'string',
39+
],
40+
),
3141
new Model\Parameter(
3242
name: 'locationId',
3343
in: 'path',

src/lib/Server/Controller/Bookmark/BookmarkIsBookmarkedController.php

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace Ibexa\Rest\Server\Controller\Bookmark;
1010

1111
use ApiPlatform\OpenApi\Model;
12+
use Ibexa\Bundle\Rest\ApiPlatform\Get;
1213
use Ibexa\Bundle\Rest\ApiPlatform\Head;
1314
use Ibexa\Contracts\Core\Repository\BookmarkService;
1415
use Ibexa\Contracts\Core\Repository\LocationService;
@@ -20,6 +21,7 @@
2021
#[Head(
2122
uriTemplate: '/bookmark/{locationId}',
2223
openapi: new Model\Operation(
24+
operationId: 'ibexa.rest.is_bookmarked.head',
2325
summary: 'Check if Location is bookmarked',
2426
description: 'Checks if the given Location is bookmarked by the current user.',
2527
tags: [
@@ -31,19 +33,51 @@
3133
in: 'path',
3234
required: true,
3335
schema: [
34-
'type' => 'string',
36+
'type' => 'integer',
3537
],
3638
),
3739
],
3840
responses: [
3941
Response::HTTP_OK => [
40-
'description' => 'OK - bookmarked.',
42+
'description' => 'OK - the given Location is bookmarked.',
4143
],
4244
Response::HTTP_UNAUTHORIZED => [
4345
'description' => 'Error - the user is not authorized for the given Location.',
4446
],
4547
Response::HTTP_NOT_FOUND => [
46-
'description' => 'Error - the given Location does not exist / is not bookmarked.',
48+
'description' => 'Error - the given Location is not bookmarked or does not exist.',
49+
],
50+
],
51+
),
52+
)]
53+
#[Get(
54+
uriTemplate: '/bookmark/{locationId}',
55+
openapi: new Model\Operation(
56+
operationId: 'ibexa.rest.is_bookmarked.get',
57+
summary: 'Check if Location is bookmarked',
58+
description: 'Checks if the given Location is bookmarked by the current user.',
59+
tags: [
60+
'Bookmark',
61+
],
62+
parameters: [
63+
new Model\Parameter(
64+
name: 'locationId',
65+
in: 'path',
66+
required: true,
67+
schema: [
68+
'type' => 'integer',
69+
],
70+
),
71+
],
72+
responses: [
73+
Response::HTTP_OK => [
74+
'description' => 'OK - the given Location is bookmarked.',
75+
],
76+
Response::HTTP_UNAUTHORIZED => [
77+
'description' => 'Error - the user is not authorized for the given Location.',
78+
],
79+
Response::HTTP_NOT_FOUND => [
80+
'description' => 'Error - the given Location is not bookmarked or does not exist.',
4781
],
4882
],
4983
),

src/lib/Server/Controller/Bookmark/BookmarkListController.php

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,37 +23,28 @@
2323
uriTemplate: '/bookmark',
2424
extraProperties: [OpenApiFactory::OVERRIDE_OPENAPI_RESPONSES => false],
2525
openapi: new Model\Operation(
26+
operationId: 'ibexa.rest.load_bookmarks',
2627
summary: 'List of bookmarks',
2728
description: 'Lists bookmarked Locations for the current user.',
2829
tags: [
2930
'Bookmark',
3031
],
31-
parameters: [
32-
new Model\Parameter(
33-
name: 'Accept',
34-
in: 'header',
35-
required: true,
36-
description: 'If set, the list is returned in XML or JSON format.',
37-
schema: [
38-
'type' => 'string',
39-
],
40-
),
41-
],
4232
responses: [
4333
Response::HTTP_OK => [
34+
'description' => 'If set, the list is returned in XML or JSON format.',
4435
'content' => [
45-
'application/vnd.ibexa.api.BookmarkList+xml' => [
46-
'schema' => [
47-
'$ref' => '#/components/schemas/BookmarkList',
48-
],
49-
'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/bookmark/GET/BookmarkList.xml.example',
50-
],
5136
'application/vnd.ibexa.api.BookmarkList+json' => [
5237
'schema' => [
5338
'$ref' => '#/components/schemas/BookmarkListWrapper',
5439
],
5540
'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/bookmark/GET/BookmarkList.json.example',
5641
],
42+
'application/vnd.ibexa.api.BookmarkList+xml' => [
43+
'schema' => [
44+
'$ref' => '#/components/schemas/BookmarkList',
45+
],
46+
'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/bookmark/GET/BookmarkList.xml.example',
47+
],
5748
],
5849
],
5950
Response::HTTP_UNAUTHORIZED => [

src/lib/Server/Controller/Language/LanguageListController.php

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,28 @@
2121
uriTemplate: '/languages',
2222
extraProperties: [OpenApiFactory::OVERRIDE_OPENAPI_RESPONSES => false],
2323
openapi: new Model\Operation(
24+
operationId: 'ibexa.rest.languages.list',
2425
summary: 'Language list',
2526
description: 'Lists languages',
2627
tags: [
2728
'Language',
2829
],
29-
parameters: [
30-
new Model\Parameter(
31-
name: 'Accept',
32-
in: 'header',
33-
required: true,
34-
description: 'If set, the list is returned in XML or JSON format.',
35-
schema: [
36-
'type' => 'string',
37-
],
38-
),
39-
],
4030
responses: [
4131
Response::HTTP_OK => [
32+
'description' => 'If set, the list is returned in XML or JSON format.',
4233
'content' => [
43-
'application/vnd.ibexa.api.LanguageList+xml' => [
44-
'schema' => [
45-
'$ref' => '#/components/schemas/LanguageList',
46-
],
47-
'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/languages/GET/LanguageList.xml.example',
48-
],
4934
'application/vnd.ibexa.api.LanguageList+json' => [
5035
'schema' => [
5136
'$ref' => '#/components/schemas/LanguageListWrapper',
5237
],
5338
'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/languages/GET/LanguageList.json.example',
5439
],
40+
'application/vnd.ibexa.api.LanguageList+xml' => [
41+
'schema' => [
42+
'$ref' => '#/components/schemas/LanguageList',
43+
],
44+
'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/languages/GET/LanguageList.xml.example',
45+
],
5546
],
5647
],
5748
],

src/lib/Server/Controller/Language/LanguageLoadByIdController.php

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,12 @@
2020
uriTemplate: '/languages/{code}',
2121
extraProperties: [OpenApiFactory::OVERRIDE_OPENAPI_RESPONSES => false],
2222
openapi: new Model\Operation(
23+
operationId: 'ibexa.rest.languages.view',
2324
summary: 'Get language',
2425
tags: [
2526
'Language',
2627
],
2728
parameters: [
28-
new Model\Parameter(
29-
name: 'Accept',
30-
in: 'header',
31-
required: true,
32-
description: 'If set, the language is returned in XML or JSON format.',
33-
schema: [
34-
'type' => 'string',
35-
],
36-
),
3729
new Model\Parameter(
3830
name: 'code',
3931
in: 'path',
@@ -45,19 +37,20 @@
4537
],
4638
responses: [
4739
Response::HTTP_OK => [
40+
'description' => 'If set, the language is returned in XML or JSON format.',
4841
'content' => [
49-
'application/vnd.ibexa.api.Language+xml' => [
50-
'schema' => [
51-
'$ref' => '#/components/schemas/Language',
52-
],
53-
'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/languages/code/GET/Language.xml.example',
54-
],
5542
'application/vnd.ibexa.api.Language+json' => [
5643
'schema' => [
5744
'$ref' => '#/components/schemas/LanguageWrapper',
5845
],
5946
'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/languages/code/GET/Language.json.example',
6047
],
48+
'application/vnd.ibexa.api.Language+xml' => [
49+
'schema' => [
50+
'$ref' => '#/components/schemas/Language',
51+
],
52+
'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/languages/code/GET/Language.xml.example',
53+
],
6154
],
6255
],
6356
],

src/lib/Server/Controller/Root.php

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,28 @@
1818
#[Get(
1919
uriTemplate: '/',
2020
openapi: new Model\Operation(
21+
operationId: 'ibexa.rest.load_root_resource',
2122
summary: 'List of root resources',
2223
description: 'Lists the root resources of the Ibexa Platform installation.',
2324
tags: [
2425
'Root',
2526
],
26-
parameters: [
27-
new Model\Parameter(
28-
name: 'Accept',
29-
in: 'header',
30-
required: true,
31-
description: 'If set, the list is return in XML or JSON format.',
32-
schema: [
33-
'type' => 'string',
34-
],
35-
),
36-
],
3727
responses: [
3828
Response::HTTP_OK => [
29+
'description' => 'If set, the list is return in XML or JSON format.',
3930
'content' => [
40-
'application/vnd.ibexa.api.Root+xml' => [
41-
'schema' => [
42-
'$ref' => '#/components/schemas/Root',
43-
],
44-
'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/GET/Root.xml.example',
45-
],
4631
'application/vnd.ibexa.api.Root+json' => [
4732
'schema' => [
4833
'$ref' => '#/components/schemas/RootWrapper',
4934
],
5035
'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/GET/Root.json.example',
5136
],
37+
'application/vnd.ibexa.api.Root+xml' => [
38+
'schema' => [
39+
'$ref' => '#/components/schemas/Root',
40+
],
41+
'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/GET/Root.xml.example',
42+
],
5243
],
5344
],
5445
],

0 commit comments

Comments
 (0)