Skip to content

Commit

Permalink
fix(webhooks): Fix openapi reponse definition
Browse files Browse the repository at this point in the history
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
  • Loading branch information
come-nc committed Jun 11, 2024
1 parent f09c781 commit d5b53be
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 39 deletions.
10 changes: 5 additions & 5 deletions apps/webhook_listeners/lib/Controller/WebhooksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
use Psr\Log\LoggerInterface;

/**
* @psalm-import-type WebhooksListenerInfo from ResponseDefinitions
* @psalm-import-type WebhookListenersWebhookInfo from ResponseDefinitions
*/
#[OpenAPI(scope: OpenAPI::SCOPE_ADMINISTRATION)]
class WebhooksController extends OCSController {
Expand All @@ -44,7 +44,7 @@ public function __construct(
/**
* List registered webhooks
*
* @return DataResponse<Http::STATUS_OK, WebhooksListenerInfo[], array{}>
* @return DataResponse<Http::STATUS_OK, WebhookListenersWebhookInfo[], array{}>
*
* 200: Webhook registrations returned
*/
Expand All @@ -61,7 +61,7 @@ public function index(): DataResponse {
*
* @param int $id id of the webhook
*
* @return DataResponse<Http::STATUS_OK, WebhooksListenerInfo, array{}>
* @return DataResponse<Http::STATUS_OK, WebhookListenersWebhookInfo, array{}>
*
* 200: Webhook registration returned
*/
Expand All @@ -82,7 +82,7 @@ public function show(int $id): DataResponse {
* @param "none"|"headers"|null $authMethod Authentication method to use
* @param ?array<string,mixed> $authData Array of data for authentication
*
* @return DataResponse<Http::STATUS_OK, WebhooksListenerInfo, array{}>
* @return DataResponse<Http::STATUS_OK, WebhookListenersWebhookInfo, array{}>
*
* 200: Webhook registration returned
*
Expand Down Expand Up @@ -141,7 +141,7 @@ public function create(
* @param "none"|"headers"|null $authMethod Authentication method to use
* @param ?array<string,mixed> $authData Array of data for authentication
*
* @return DataResponse<Http::STATUS_OK, WebhooksListenerInfo, array{}>
* @return DataResponse<Http::STATUS_OK, WebhookListenersWebhookInfo, array{}>
*
* 200: Webhook registration returned
*
Expand Down
2 changes: 1 addition & 1 deletion apps/webhook_listeners/lib/ResponseDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace OCA\WebhookListeners;

/**
* @psalm-type WebhooksListenerInfo = array{
* @psalm-type WebhookListenersWebhookInfo = array{
* id: string,
* userId: string,
* httpMethod: string,
Expand Down
66 changes: 33 additions & 33 deletions apps/webhook_listeners/openapi.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"openapi": "3.0.3",
"info": {
"title": "webhooks",
"title": "webhook_listeners",
"version": "0.0.1",
"description": "Nextcloud webhook support",
"license": {
Expand All @@ -20,7 +20,31 @@
}
},
"schemas": {
"ListenerInfo": {
"OCSMeta": {
"type": "object",
"required": [
"status",
"statuscode"
],
"properties": {
"status": {
"type": "string"
},
"statuscode": {
"type": "integer"
},
"message": {
"type": "string"
},
"totalitems": {
"type": "string"
},
"itemsperpage": {
"type": "string"
}
}
},
"WebhookInfo": {
"type": "object",
"required": [
"id",
Expand Down Expand Up @@ -67,35 +91,11 @@
}
}
}
},
"OCSMeta": {
"type": "object",
"required": [
"status",
"statuscode"
],
"properties": {
"status": {
"type": "string"
},
"statuscode": {
"type": "integer"
},
"message": {
"type": "string"
},
"totalitems": {
"type": "string"
},
"itemsperpage": {
"type": "string"
}
}
}
}
},
"paths": {
"/ocs/v2.php/apps/webhooks/api/v1/webhooks": {
"/ocs/v2.php/apps/webhook_listeners/api/v1/webhooks": {
"get": {
"operationId": "webhooks-index",
"summary": "List registered webhooks",
Expand Down Expand Up @@ -147,7 +147,7 @@
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ListenerInfo"
"$ref": "#/components/schemas/WebhookInfo"
}
}
}
Expand Down Expand Up @@ -275,7 +275,7 @@
"$ref": "#/components/schemas/OCSMeta"
},
"data": {
"$ref": "#/components/schemas/ListenerInfo"
"$ref": "#/components/schemas/WebhookInfo"
}
}
}
Expand Down Expand Up @@ -343,7 +343,7 @@
}
}
},
"/ocs/v2.php/apps/webhooks/api/v1/webhooks/{id}": {
"/ocs/v2.php/apps/webhook_listeners/api/v1/webhooks/{id}": {
"get": {
"operationId": "webhooks-show",
"summary": "Get details on a registered webhook",
Expand Down Expand Up @@ -403,7 +403,7 @@
"$ref": "#/components/schemas/OCSMeta"
},
"data": {
"$ref": "#/components/schemas/ListenerInfo"
"$ref": "#/components/schemas/WebhookInfo"
}
}
}
Expand Down Expand Up @@ -540,7 +540,7 @@
"$ref": "#/components/schemas/OCSMeta"
},
"data": {
"$ref": "#/components/schemas/ListenerInfo"
"$ref": "#/components/schemas/WebhookInfo"
}
}
}
Expand Down Expand Up @@ -736,4 +736,4 @@
}
},
"tags": []
}
}

0 comments on commit d5b53be

Please sign in to comment.