Skip to content

Commit bb755d6

Browse files
authored
Merge pull request #7662 from LibreSign/feat/sdk-generator-contract-hardening
feat: harden OpenAPI contracts for SDK generators
2 parents e035257 + c7476e0 commit bb755d6

8 files changed

Lines changed: 256 additions & 20 deletions

File tree

lib/Controller/AdminController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public function configureCheck(): DataResponse {
269269
*
270270
* This will disable hate limit to current session.
271271
*
272-
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
272+
* @return DataResponse<Http::STATUS_OK, array{}, array{}>
273273
*
274274
* 200: OK
275275
*/

lib/ResponseDefinitions.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,29 @@
132132
* }
133133
* @psalm-type LibresignIdentifyAccountsResponse = list<LibresignIdentifyAccount>
134134
* @psalm-type LibresignNotify = array{
135-
* date: string,
135+
* date: non-negative-int,
136136
* method: "activity"|"notify"|"mail",
137+
* description?: string,
137138
* }
138139
* @psalm-type LibresignRequestedBy = array{
139140
* userId: string,
140141
* displayName: ?string,
141142
* }
143+
* @psalm-type LibresignDynamicMetadataScalar = string|int|float|bool|null
144+
* @psalm-type LibresignDynamicMetadataRecord = array<string, LibresignDynamicMetadataScalar>
145+
* @psalm-type LibresignDynamicMetadataValue = LibresignDynamicMetadataScalar|list<LibresignDynamicMetadataScalar>|LibresignDynamicMetadataRecord|list<LibresignDynamicMetadataRecord>
146+
* @psalm-type LibresignSignerCertificateInfo = array{
147+
* serialNumber?: string,
148+
* serialNumberHex?: string,
149+
* hash?: string,
150+
* subject?: LibresignDynamicMetadataValue,
151+
* }
152+
* @psalm-type LibresignSignerMetadata = array{
153+
* remote-address?: string,
154+
* user-agent?: string,
155+
* notify?: LibresignNotify[],
156+
* certificate_info?: LibresignSignerCertificateInfo,
157+
* }
142158
* @psalm-type LibresignSignerSummary = array{
143159
* signRequestId: int,
144160
* displayName: string,
@@ -167,7 +183,7 @@
167183
* visibleElements: LibresignVisibleElement[],
168184
* signatureMethods?: LibresignSignatureMethods,
169185
* uid?: string,
170-
* metadata?: mixed,
186+
* metadata?: LibresignSignerMetadata,
171187
* }
172188
*
173189
* Shared feedback and action contracts
@@ -363,7 +379,7 @@
363379
* pdfVersion?: string,
364380
* status_changed_at?: string,
365381
* }
366-
* @psalm-type LibresignFileRuntimeMetadata = LibresignValidateMetadata|array<string, mixed>
382+
* @psalm-type LibresignFileRuntimeMetadata = LibresignValidateMetadata|array<string, LibresignDynamicMetadataValue>
367383
* @psalm-type LibresignValidationPageResolution = array{
368384
* w: float,
369385
* h: float,

openapi-administration.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,9 @@
14621462
"meta": {
14631463
"$ref": "#/components/schemas/OCSMeta"
14641464
},
1465-
"data": {}
1465+
"data": {
1466+
"type": "object"
1467+
}
14661468
}
14671469
}
14681470
}

openapi-full.json

Lines changed: 95 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,53 @@
949949
}
950950
}
951951
},
952+
"DynamicMetadataRecord": {
953+
"type": "object",
954+
"additionalProperties": {
955+
"$ref": "#/components/schemas/DynamicMetadataScalar"
956+
}
957+
},
958+
"DynamicMetadataScalar": {
959+
"nullable": true,
960+
"anyOf": [
961+
{
962+
"type": "string"
963+
},
964+
{
965+
"type": "integer",
966+
"format": "int64"
967+
},
968+
{
969+
"type": "number",
970+
"format": "double"
971+
},
972+
{
973+
"type": "boolean"
974+
}
975+
]
976+
},
977+
"DynamicMetadataValue": {
978+
"anyOf": [
979+
{
980+
"$ref": "#/components/schemas/DynamicMetadataScalar"
981+
},
982+
{
983+
"type": "array",
984+
"items": {
985+
"$ref": "#/components/schemas/DynamicMetadataScalar"
986+
}
987+
},
988+
{
989+
"$ref": "#/components/schemas/DynamicMetadataRecord"
990+
},
991+
{
992+
"type": "array",
993+
"items": {
994+
"$ref": "#/components/schemas/DynamicMetadataRecord"
995+
}
996+
}
997+
]
998+
},
952999
"EngineHandler": {
9531000
"type": "object",
9541001
"required": [
@@ -1303,7 +1350,7 @@
13031350
{
13041351
"type": "object",
13051352
"additionalProperties": {
1306-
"type": "object"
1353+
"$ref": "#/components/schemas/DynamicMetadataValue"
13071354
}
13081355
}
13091356
]
@@ -1793,7 +1840,9 @@
17931840
],
17941841
"properties": {
17951842
"date": {
1796-
"type": "string"
1843+
"type": "integer",
1844+
"format": "int64",
1845+
"minimum": 0
17971846
},
17981847
"method": {
17991848
"type": "string",
@@ -1802,6 +1851,9 @@
18021851
"notify",
18031852
"mail"
18041853
]
1854+
},
1855+
"description": {
1856+
"type": "string"
18051857
}
18061858
}
18071859
},
@@ -2353,6 +2405,23 @@
23532405
}
23542406
}
23552407
},
2408+
"SignerCertificateInfo": {
2409+
"type": "object",
2410+
"properties": {
2411+
"serialNumber": {
2412+
"type": "string"
2413+
},
2414+
"serialNumberHex": {
2415+
"type": "string"
2416+
},
2417+
"hash": {
2418+
"type": "string"
2419+
},
2420+
"subject": {
2421+
"$ref": "#/components/schemas/DynamicMetadataValue"
2422+
}
2423+
}
2424+
},
23562425
"SignerDetail": {
23572426
"allOf": [
23582427
{
@@ -2443,12 +2512,32 @@
24432512
"type": "string"
24442513
},
24452514
"metadata": {
2446-
"type": "object"
2515+
"$ref": "#/components/schemas/SignerMetadata"
24472516
}
24482517
}
24492518
}
24502519
]
24512520
},
2521+
"SignerMetadata": {
2522+
"type": "object",
2523+
"properties": {
2524+
"remote-address": {
2525+
"type": "string"
2526+
},
2527+
"user-agent": {
2528+
"type": "string"
2529+
},
2530+
"notify": {
2531+
"type": "array",
2532+
"items": {
2533+
"$ref": "#/components/schemas/Notify"
2534+
}
2535+
},
2536+
"certificate_info": {
2537+
"$ref": "#/components/schemas/SignerCertificateInfo"
2538+
}
2539+
}
2540+
},
24522541
"SignerSummary": {
24532542
"type": "object",
24542543
"required": [
@@ -10732,7 +10821,9 @@
1073210821
"meta": {
1073310822
"$ref": "#/components/schemas/OCSMeta"
1073410823
},
10735-
"data": {}
10824+
"data": {
10825+
"type": "object"
10826+
}
1073610827
}
1073710828
}
1073810829
}

openapi.json

Lines changed: 92 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,53 @@
622622
}
623623
]
624624
},
625+
"DynamicMetadataRecord": {
626+
"type": "object",
627+
"additionalProperties": {
628+
"$ref": "#/components/schemas/DynamicMetadataScalar"
629+
}
630+
},
631+
"DynamicMetadataScalar": {
632+
"nullable": true,
633+
"anyOf": [
634+
{
635+
"type": "string"
636+
},
637+
{
638+
"type": "integer",
639+
"format": "int64"
640+
},
641+
{
642+
"type": "number",
643+
"format": "double"
644+
},
645+
{
646+
"type": "boolean"
647+
}
648+
]
649+
},
650+
"DynamicMetadataValue": {
651+
"anyOf": [
652+
{
653+
"$ref": "#/components/schemas/DynamicMetadataScalar"
654+
},
655+
{
656+
"type": "array",
657+
"items": {
658+
"$ref": "#/components/schemas/DynamicMetadataScalar"
659+
}
660+
},
661+
{
662+
"$ref": "#/components/schemas/DynamicMetadataRecord"
663+
},
664+
{
665+
"type": "array",
666+
"items": {
667+
"$ref": "#/components/schemas/DynamicMetadataRecord"
668+
}
669+
}
670+
]
671+
},
625672
"ErrorItem": {
626673
"type": "object",
627674
"required": [
@@ -904,7 +951,7 @@
904951
{
905952
"type": "object",
906953
"additionalProperties": {
907-
"type": "object"
954+
"$ref": "#/components/schemas/DynamicMetadataValue"
908955
}
909956
}
910957
]
@@ -1332,7 +1379,9 @@
13321379
],
13331380
"properties": {
13341381
"date": {
1335-
"type": "string"
1382+
"type": "integer",
1383+
"format": "int64",
1384+
"minimum": 0
13361385
},
13371386
"method": {
13381387
"type": "string",
@@ -1341,6 +1390,9 @@
13411390
"notify",
13421391
"mail"
13431392
]
1393+
},
1394+
"description": {
1395+
"type": "string"
13441396
}
13451397
}
13461398
},
@@ -1755,6 +1807,23 @@
17551807
}
17561808
}
17571809
},
1810+
"SignerCertificateInfo": {
1811+
"type": "object",
1812+
"properties": {
1813+
"serialNumber": {
1814+
"type": "string"
1815+
},
1816+
"serialNumberHex": {
1817+
"type": "string"
1818+
},
1819+
"hash": {
1820+
"type": "string"
1821+
},
1822+
"subject": {
1823+
"$ref": "#/components/schemas/DynamicMetadataValue"
1824+
}
1825+
}
1826+
},
17581827
"SignerDetail": {
17591828
"allOf": [
17601829
{
@@ -1845,12 +1914,32 @@
18451914
"type": "string"
18461915
},
18471916
"metadata": {
1848-
"type": "object"
1917+
"$ref": "#/components/schemas/SignerMetadata"
18491918
}
18501919
}
18511920
}
18521921
]
18531922
},
1923+
"SignerMetadata": {
1924+
"type": "object",
1925+
"properties": {
1926+
"remote-address": {
1927+
"type": "string"
1928+
},
1929+
"user-agent": {
1930+
"type": "string"
1931+
},
1932+
"notify": {
1933+
"type": "array",
1934+
"items": {
1935+
"$ref": "#/components/schemas/Notify"
1936+
}
1937+
},
1938+
"certificate_info": {
1939+
"$ref": "#/components/schemas/SignerCertificateInfo"
1940+
}
1941+
}
1942+
},
18541943
"SignerSummary": {
18551944
"type": "object",
18561945
"required": [

src/types/openapi/openapi-administration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ export interface operations {
979979
"application/json": {
980980
ocs: {
981981
meta: components["schemas"]["OCSMeta"];
982-
data: unknown;
982+
data: Record<string, never>;
983983
};
984984
};
985985
};

0 commit comments

Comments
 (0)