Skip to content

Commit 9efed20

Browse files
committed
fix(openapi): align admin certificate response schema
Signed-off-by: Vitor Mattos <[email protected]>
1 parent ecbab78 commit 9efed20

6 files changed

Lines changed: 59 additions & 16 deletions

File tree

lib/Controller/AdminController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,17 +225,17 @@ private function generateCertificate(
225225
/**
226226
* Load certificate data
227227
*
228-
* Return all data of the root certificate from the current engine.
228+
* Return all data of root certificate and a field called `generated` with a boolean value.
229229
*
230-
* @return DataResponse<Http::STATUS_OK, LibresignEngineHandler, array{}>
230+
* @return DataResponse<Http::STATUS_OK, LibresignCetificateDataGenerated, array{}>
231231
*
232232
* 200: OK
233233
*/
234234
#[NoCSRFRequired]
235235
#[ApiRoute(verb: 'GET', url: '/api/{apiVersion}/admin/certificate', requirements: ['apiVersion' => '(v1)'])]
236236
public function loadCertificate(): DataResponse {
237237
$engine = $this->certificateEngineFactory->getEngine();
238-
/** @var LibresignEngineHandler */
238+
/** @var LibresignCetificateDataGenerated */
239239
$certificate = $engine->toArray();
240240

241241
return new DataResponse($certificate);

lib/ResponseDefinitions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@
269269
* }
270270
* @psalm-type LibresignRootCertificateName = array{
271271
* id: string,
272-
* value: string,
272+
* value: string|list<string>|null,
273273
* }
274274
* @psalm-type LibresignRootCertificate = array{
275275
* commonName: string,

openapi-administration.json

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,24 @@
194194
}
195195
}
196196
},
197+
"CetificateDataGenerated": {
198+
"allOf": [
199+
{
200+
"$ref": "#/components/schemas/EngineHandler"
201+
},
202+
{
203+
"type": "object",
204+
"required": [
205+
"generated"
206+
],
207+
"properties": {
208+
"generated": {
209+
"type": "boolean"
210+
}
211+
}
212+
}
213+
]
214+
},
197215
"ConfigureCheck": {
198216
"type": "object",
199217
"required": [
@@ -713,7 +731,18 @@
713731
"type": "string"
714732
},
715733
"value": {
716-
"type": "string"
734+
"nullable": true,
735+
"oneOf": [
736+
{
737+
"type": "string"
738+
},
739+
{
740+
"type": "array",
741+
"items": {
742+
"type": "string"
743+
}
744+
}
745+
]
717746
}
718747
}
719748
},
@@ -1444,7 +1473,7 @@
14441473
"get": {
14451474
"operationId": "admin-load-certificate",
14461475
"summary": "Load certificate data",
1447-
"description": "Return all data of the root certificate from the current engine.\nThis endpoint requires admin access",
1476+
"description": "Return all data of root certificate and a field called `generated` with a boolean value.\nThis endpoint requires admin access",
14481477
"tags": [
14491478
"admin"
14501479
],
@@ -1502,7 +1531,7 @@
15021531
"$ref": "#/components/schemas/OCSMeta"
15031532
},
15041533
"data": {
1505-
"$ref": "#/components/schemas/EngineHandler"
1534+
"$ref": "#/components/schemas/CetificateDataGenerated"
15061535
}
15071536
}
15081537
}

openapi-full.json

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2327,7 +2327,18 @@
23272327
"type": "string"
23282328
},
23292329
"value": {
2330-
"type": "string"
2330+
"nullable": true,
2331+
"oneOf": [
2332+
{
2333+
"type": "string"
2334+
},
2335+
{
2336+
"type": "array",
2337+
"items": {
2338+
"type": "string"
2339+
}
2340+
}
2341+
]
23312342
}
23322343
}
23332344
},
@@ -11638,7 +11649,7 @@
1163811649
"get": {
1163911650
"operationId": "admin-load-certificate",
1164011651
"summary": "Load certificate data",
11641-
"description": "Return all data of the root certificate from the current engine.\nThis endpoint requires admin access",
11652+
"description": "Return all data of root certificate and a field called `generated` with a boolean value.\nThis endpoint requires admin access",
1164211653
"tags": [
1164311654
"admin"
1164411655
],
@@ -11696,7 +11707,7 @@
1169611707
"$ref": "#/components/schemas/OCSMeta"
1169711708
},
1169811709
"data": {
11699-
"$ref": "#/components/schemas/EngineHandler"
11710+
"$ref": "#/components/schemas/CetificateDataGenerated"
1170011711
}
1170111712
}
1170211713
}

src/types/openapi/openapi-administration.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export type paths = {
7474
};
7575
/**
7676
* Load certificate data
77-
* @description Return all data of the root certificate from the current engine.
77+
* @description Return all data of root certificate and a field called `generated` with a boolean value.
7878
* This endpoint requires admin access
7979
*/
8080
get: operations["admin-load-certificate"];
@@ -569,6 +569,9 @@ export type components = {
569569
status: "success";
570570
CPS: string;
571571
};
572+
CetificateDataGenerated: components["schemas"]["EngineHandler"] & {
573+
generated: boolean;
574+
};
572575
ConfigureCheck: {
573576
message: string;
574577
resource: string;
@@ -705,7 +708,7 @@ export type components = {
705708
};
706709
RootCertificateName: {
707710
id: string;
708-
value: string;
711+
value: (string | string[]) | null;
709712
};
710713
SignatureMethod: {
711714
enabled: boolean;
@@ -993,7 +996,7 @@ export interface operations {
993996
"application/json": {
994997
ocs: {
995998
meta: components["schemas"]["OCSMeta"];
996-
data: components["schemas"]["EngineHandler"];
999+
data: components["schemas"]["CetificateDataGenerated"];
9971000
};
9981001
};
9991002
};

src/types/openapi/openapi-full.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,7 @@ export type paths = {
11631163
};
11641164
/**
11651165
* Load certificate data
1166-
* @description Return all data of the root certificate from the current engine.
1166+
* @description Return all data of root certificate and a field called `generated` with a boolean value.
11671167
* This endpoint requires admin access
11681168
*/
11691169
get: operations["admin-load-certificate"];
@@ -2249,7 +2249,7 @@ export type components = {
22492249
};
22502250
RootCertificateName: {
22512251
id: string;
2252-
value: string;
2252+
value: (string | string[]) | null;
22532253
};
22542254
Settings: {
22552255
canSign: boolean;
@@ -6147,7 +6147,7 @@ export interface operations {
61476147
"application/json": {
61486148
ocs: {
61496149
meta: components["schemas"]["OCSMeta"];
6150-
data: components["schemas"]["EngineHandler"];
6150+
data: components["schemas"]["CetificateDataGenerated"];
61516151
};
61526152
};
61536153
};

0 commit comments

Comments
 (0)