Skip to content

Commit 2bb1d45

Browse files
authored
Merge pull request #7664 from LibreSign/backport/7662/stable32
[stable32] feat: harden OpenAPI contracts for SDK generators
2 parents c4548e7 + 621eb95 commit 2bb1d45

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
@@ -948,6 +948,53 @@
948948
}
949949
}
950950
},
951+
"DynamicMetadataRecord": {
952+
"type": "object",
953+
"additionalProperties": {
954+
"$ref": "#/components/schemas/DynamicMetadataScalar"
955+
}
956+
},
957+
"DynamicMetadataScalar": {
958+
"nullable": true,
959+
"anyOf": [
960+
{
961+
"type": "string"
962+
},
963+
{
964+
"type": "integer",
965+
"format": "int64"
966+
},
967+
{
968+
"type": "number",
969+
"format": "double"
970+
},
971+
{
972+
"type": "boolean"
973+
}
974+
]
975+
},
976+
"DynamicMetadataValue": {
977+
"anyOf": [
978+
{
979+
"$ref": "#/components/schemas/DynamicMetadataScalar"
980+
},
981+
{
982+
"type": "array",
983+
"items": {
984+
"$ref": "#/components/schemas/DynamicMetadataScalar"
985+
}
986+
},
987+
{
988+
"$ref": "#/components/schemas/DynamicMetadataRecord"
989+
},
990+
{
991+
"type": "array",
992+
"items": {
993+
"$ref": "#/components/schemas/DynamicMetadataRecord"
994+
}
995+
}
996+
]
997+
},
951998
"EngineHandler": {
952999
"type": "object",
9531000
"required": [
@@ -1302,7 +1349,7 @@
13021349
{
13031350
"type": "object",
13041351
"additionalProperties": {
1305-
"type": "object"
1352+
"$ref": "#/components/schemas/DynamicMetadataValue"
13061353
}
13071354
}
13081355
]
@@ -1792,7 +1839,9 @@
17921839
],
17931840
"properties": {
17941841
"date": {
1795-
"type": "string"
1842+
"type": "integer",
1843+
"format": "int64",
1844+
"minimum": 0
17961845
},
17971846
"method": {
17981847
"type": "string",
@@ -1801,6 +1850,9 @@
18011850
"notify",
18021851
"mail"
18031852
]
1853+
},
1854+
"description": {
1855+
"type": "string"
18041856
}
18051857
}
18061858
},
@@ -2352,6 +2404,23 @@
23522404
}
23532405
}
23542406
},
2407+
"SignerCertificateInfo": {
2408+
"type": "object",
2409+
"properties": {
2410+
"serialNumber": {
2411+
"type": "string"
2412+
},
2413+
"serialNumberHex": {
2414+
"type": "string"
2415+
},
2416+
"hash": {
2417+
"type": "string"
2418+
},
2419+
"subject": {
2420+
"$ref": "#/components/schemas/DynamicMetadataValue"
2421+
}
2422+
}
2423+
},
23552424
"SignerDetail": {
23562425
"allOf": [
23572426
{
@@ -2442,12 +2511,32 @@
24422511
"type": "string"
24432512
},
24442513
"metadata": {
2445-
"type": "object"
2514+
"$ref": "#/components/schemas/SignerMetadata"
24462515
}
24472516
}
24482517
}
24492518
]
24502519
},
2520+
"SignerMetadata": {
2521+
"type": "object",
2522+
"properties": {
2523+
"remote-address": {
2524+
"type": "string"
2525+
},
2526+
"user-agent": {
2527+
"type": "string"
2528+
},
2529+
"notify": {
2530+
"type": "array",
2531+
"items": {
2532+
"$ref": "#/components/schemas/Notify"
2533+
}
2534+
},
2535+
"certificate_info": {
2536+
"$ref": "#/components/schemas/SignerCertificateInfo"
2537+
}
2538+
}
2539+
},
24512540
"SignerSummary": {
24522541
"type": "object",
24532542
"required": [
@@ -10731,7 +10820,9 @@
1073110820
"meta": {
1073210821
"$ref": "#/components/schemas/OCSMeta"
1073310822
},
10734-
"data": {}
10823+
"data": {
10824+
"type": "object"
10825+
}
1073510826
}
1073610827
}
1073710828
}

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)