Skip to content

Commit 10d2d2b

Browse files
ff137swcurran
andauthored
🎨 Fix swagger tag names for AnonCreds endpoints (openwallet-foundation#3661)
* 🎨 Use revocation_anoncreds tag title Signed-off-by: ff137 <ff137@proton.me> * 🎨 Deduplicate tag titles Signed-off-by: ff137 <ff137@proton.me> * 🎨 Deduplicate tag titles Signed-off-by: ff137 <ff137@proton.me> * 🎨 Avoid circular import, due to knot between anoncreds/routes and revocation_anoncreds/routes Signed-off-by: ff137 <ff137@proton.me> * 🎨 Fix new lines in description summary Signed-off-by: ff137 <ff137@proton.me> * 📝 Update openapi spec Signed-off-by: ff137 <ff137@proton.me> * 🎨 Reword update description Signed-off-by: ff137 <ff137@proton.me> --------- Signed-off-by: ff137 <ff137@proton.me> Co-authored-by: Stephen Curran <swcurran@gmail.com>
1 parent 50e19c2 commit 10d2d2b

File tree

6 files changed

+81
-58
lines changed

6 files changed

+81
-58
lines changed

acapy_agent/anoncreds/routes.py

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848

4949
LOGGER = logging.getLogger(__name__)
5050

51+
CRED_DEF_TAG_TITLE = "AnonCreds - Credential Definitions"
52+
SCHEMAS_TAG_TITLE = "AnonCreds - Schemas"
53+
REVOCATION_TAG_TITLE = "AnonCreds - Revocation"
54+
5155
SPEC_URI = "https://hyperledger.github.io/anoncreds-spec"
5256

5357
endorser_connection_id_description = (
@@ -153,7 +157,10 @@ class SchemaPostRequestSchema(OpenAPISchema):
153157
options = fields.Nested(SchemaPostOptionSchema())
154158

155159

156-
@docs(tags=["anoncreds - schemas"], summary="Create a schema on the connected datastore")
160+
@docs(
161+
tags=[SCHEMAS_TAG_TITLE],
162+
summary="Create a schema on the connected datastore",
163+
)
157164
@request_schema(SchemaPostRequestSchema())
158165
@response_schema(SchemaResultSchema(), 200, description="")
159166
@tenant_authentication
@@ -225,7 +232,10 @@ async def schemas_post(request: web.BaseRequest):
225232
raise web.HTTPBadRequest(reason=e.roll_up) from e
226233

227234

228-
@docs(tags=["anoncreds - schemas"], summary="Retrieve an individual schemas details")
235+
@docs(
236+
tags=[SCHEMAS_TAG_TITLE],
237+
summary="Retrieve an individual schemas details",
238+
)
229239
@match_info_schema(SchemaIdMatchInfo())
230240
@response_schema(GetSchemaResultSchema(), 200, description="")
231241
@tenant_authentication
@@ -255,7 +265,10 @@ async def schema_get(request: web.BaseRequest):
255265
raise web.HTTPBadRequest(reason=e.roll_up) from e
256266

257267

258-
@docs(tags=["anoncreds - schemas"], summary="Retrieve all schema ids")
268+
@docs(
269+
tags=[SCHEMAS_TAG_TITLE],
270+
summary="Retrieve all schema ids",
271+
)
259272
@querystring_schema(SchemasQueryStringSchema())
260273
@response_schema(GetSchemasResponseSchema(), 200, description="")
261274
@tenant_authentication
@@ -397,7 +410,7 @@ class CredDefsQueryStringSchema(OpenAPISchema):
397410

398411

399412
@docs(
400-
tags=["anoncreds - credential definitions"],
413+
tags=[CRED_DEF_TAG_TITLE],
401414
summary="Create a credential definition on the connected datastore",
402415
)
403416
@request_schema(CredDefPostRequestSchema())
@@ -449,7 +462,7 @@ async def cred_def_post(request: web.BaseRequest):
449462

450463

451464
@docs(
452-
tags=["anoncreds - credential definitions"],
465+
tags=[CRED_DEF_TAG_TITLE],
453466
summary="Retrieve an individual credential definition details",
454467
)
455468
@match_info_schema(CredIdMatchInfo())
@@ -497,7 +510,7 @@ class GetCredDefsResponseSchema(OpenAPISchema):
497510

498511

499512
@docs(
500-
tags=["anoncreds - credential definitions"],
513+
tags=[CRED_DEF_TAG_TITLE],
501514
summary="Retrieve all credential definition ids",
502515
)
503516
@querystring_schema(CredDefsQueryStringSchema())
@@ -592,7 +605,7 @@ class RevRegCreateRequestSchemaAnonCreds(OpenAPISchema):
592605

593606

594607
@docs(
595-
tags=["anoncreds - revocation"],
608+
tags=[REVOCATION_TAG_TITLE],
596609
summary="Create and publish a registration revocation on the connected datastore",
597610
)
598611
@request_schema(RevRegCreateRequestSchemaAnonCreds())
@@ -677,7 +690,7 @@ class RevListCreateRequestSchema(OpenAPISchema):
677690

678691

679692
@docs(
680-
tags=["anoncreds - revocation"],
693+
tags=[REVOCATION_TAG_TITLE],
681694
summary="Create and publish a revocation status list on the connected datastore",
682695
)
683696
@request_schema(RevListCreateRequestSchema())
@@ -713,7 +726,7 @@ async def rev_list_post(request: web.BaseRequest):
713726

714727

715728
@docs(
716-
tags=["anoncreds - revocation"],
729+
tags=[REVOCATION_TAG_TITLE],
717730
summary="Upload local tails file to server",
718731
)
719732
@match_info_schema(AnonCredsRevRegIdMatchInfoSchema())
@@ -749,7 +762,7 @@ async def upload_tails_file(request: web.BaseRequest):
749762

750763

751764
@docs(
752-
tags=["anoncreds - revocation"],
765+
tags=[REVOCATION_TAG_TITLE],
753766
summary="Update the active registry",
754767
)
755768
@match_info_schema(AnonCredsRevRegIdMatchInfoSchema())
@@ -820,14 +833,14 @@ def post_process_routes(app: web.Application):
820833
app._state["swagger_dict"]["tags"] = []
821834
app._state["swagger_dict"]["tags"].append(
822835
{
823-
"name": "AnonCreds - Schemas",
836+
"name": SCHEMAS_TAG_TITLE,
824837
"description": "AnonCreds schema management",
825838
"externalDocs": {"description": "Specification", "url": SPEC_URI},
826839
}
827840
)
828841
app._state["swagger_dict"]["tags"].append(
829842
{
830-
"name": "AnonCreds - Credential Definitions",
843+
"name": CRED_DEF_TAG_TITLE,
831844
"description": "AnonCreds credential definition management",
832845
"externalDocs": {"description": "Specification", "url": SPEC_URI},
833846
}

acapy_agent/revocation_anoncreds/routes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ class PublishRevocationsOptions(OpenAPISchema):
313313

314314
endorser_connection_id = fields.Str(
315315
metadata={
316-
"description": endorser_connection_id_description, # noqa: F821
316+
"description": endorser_connection_id_description,
317317
"required": False,
318318
"example": UUIDFour.EXAMPLE,
319319
}

acapy_agent/wallet/keys/routes.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from ...admin.request_context import AdminRequestContext
1111
from ...messaging.models.openapi import OpenAPISchema
1212
from ...wallet.error import WalletDuplicateError, WalletNotFoundError
13+
from ..routes import WALLET_TAG_TITLE
1314
from .manager import DEFAULT_ALG, MultikeyManager, MultikeyManagerError
1415

1516
LOGGER = logging.getLogger(__name__)
@@ -124,7 +125,7 @@ class FetchKeyResponseSchema(OpenAPISchema):
124125
)
125126

126127

127-
@docs(tags=["wallet"], summary="Fetch key info.")
128+
@docs(tags=[WALLET_TAG_TITLE], summary="Fetch key info.")
128129
@response_schema(FetchKeyResponseSchema, 200, description="")
129130
@tenant_authentication
130131
async def fetch_key(request: web.BaseRequest):
@@ -149,7 +150,7 @@ async def fetch_key(request: web.BaseRequest):
149150
return web.json_response({"message": str(err)}, status=400)
150151

151152

152-
@docs(tags=["wallet"], summary="Create a key pair")
153+
@docs(tags=[WALLET_TAG_TITLE], summary="Create a key pair")
153154
@request_schema(CreateKeyRequestSchema())
154155
@response_schema(CreateKeyResponseSchema, 200, description="")
155156
@tenant_authentication
@@ -184,7 +185,7 @@ async def create_key(request: web.BaseRequest):
184185
return web.json_response({"message": str(err)}, status=400)
185186

186187

187-
@docs(tags=["wallet"], summary="Update a key pair's kid")
188+
@docs(tags=[WALLET_TAG_TITLE], summary="Update a key pair's kid")
188189
@request_schema(UpdateKeyRequestSchema())
189190
@response_schema(UpdateKeyResponseSchema, 200, description="")
190191
@tenant_authentication

acapy_agent/wallet/routes.py

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@
8888

8989
LOGGER = logging.getLogger(__name__)
9090

91+
WALLET_TAG_TITLE = "wallet"
92+
UPGRADE_TAG_TITLE = "AnonCreds - Wallet Upgrade"
93+
9194

9295
class WalletModuleResponseSchema(OpenAPISchema):
9396
"""Response schema for Wallet Module."""
@@ -447,7 +450,7 @@ def format_did_info(info: DIDInfo):
447450
}
448451

449452

450-
@docs(tags=["wallet"], summary="List wallet DIDs")
453+
@docs(tags=[WALLET_TAG_TITLE], summary="List wallet DIDs")
451454
@querystring_schema(DIDListQueryStringSchema())
452455
@response_schema(DIDListSchema, 200, description="")
453456
@tenant_authentication
@@ -553,7 +556,7 @@ async def wallet_did_list(request: web.BaseRequest):
553556
return web.json_response({"results": results})
554557

555558

556-
@docs(tags=["wallet"], summary="Create a local DID")
559+
@docs(tags=[WALLET_TAG_TITLE], summary="Create a local DID")
557560
@request_schema(DIDCreateSchema())
558561
@response_schema(DIDResultSchema, 200, description="")
559562
@tenant_authentication
@@ -680,7 +683,7 @@ async def wallet_create_did(request: web.BaseRequest):
680683
return web.json_response({"result": format_did_info(info)})
681684

682685

683-
@docs(tags=["wallet"], summary="Fetch the current public DID")
686+
@docs(tags=[WALLET_TAG_TITLE], summary="Fetch the current public DID")
684687
@response_schema(DIDResultSchema, 200, description="")
685688
@tenant_authentication
686689
async def wallet_get_public_did(request: web.BaseRequest):
@@ -707,7 +710,7 @@ async def wallet_get_public_did(request: web.BaseRequest):
707710
return web.json_response({"result": format_did_info(info)})
708711

709712

710-
@docs(tags=["wallet"], summary="Assign the current public DID")
713+
@docs(tags=[WALLET_TAG_TITLE], summary="Assign the current public DID")
711714
@querystring_schema(DIDQueryStringSchema())
712715
@querystring_schema(CreateAttribTxnForEndorserOptionSchema())
713716
@querystring_schema(AttribConnIdMatchInfoSchema())
@@ -952,7 +955,10 @@ async def promote_wallet_public_did(
952955
return info, attrib_def
953956

954957

955-
@docs(tags=["wallet"], summary="Update endpoint in wallet and on ledger if posted to it")
958+
@docs(
959+
tags=[WALLET_TAG_TITLE],
960+
summary="Update endpoint in wallet and on ledger if posted to it",
961+
)
956962
@request_schema(DIDEndpointWithTypeSchema)
957963
@querystring_schema(CreateAttribTxnForEndorserOptionSchema())
958964
@querystring_schema(AttribConnIdMatchInfoSchema())
@@ -1083,7 +1089,7 @@ async def wallet_set_did_endpoint(request: web.BaseRequest):
10831089
return web.json_response({"txn": transaction.serialize()})
10841090

10851091

1086-
@docs(tags=["wallet"], summary="Create a jws using did keys with a given payload")
1092+
@docs(tags=[WALLET_TAG_TITLE], summary="Create a jws using did keys with a given payload")
10871093
@request_schema(JWSCreateSchema)
10881094
@response_schema(WalletModuleResponseSchema(), description="")
10891095
@tenant_authentication
@@ -1121,7 +1127,10 @@ async def wallet_jwt_sign(request: web.BaseRequest):
11211127
return web.json_response(jws)
11221128

11231129

1124-
@docs(tags=["wallet"], summary="Create an sd-jws using did keys with a given payload")
1130+
@docs(
1131+
tags=[WALLET_TAG_TITLE],
1132+
summary="Create an sd-jws using did keys with a given payload",
1133+
)
11251134
@request_schema(SDJWSCreateSchema)
11261135
@response_schema(WalletModuleResponseSchema(), description="")
11271136
@tenant_authentication
@@ -1163,7 +1172,7 @@ async def wallet_sd_jwt_sign(request: web.BaseRequest):
11631172
return web.json_response(sd_jws)
11641173

11651174

1166-
@docs(tags=["wallet"], summary="Verify a jws using did keys with a given JWS")
1175+
@docs(tags=[WALLET_TAG_TITLE], summary="Verify a jws using did keys with a given JWS")
11671176
@request_schema(JWSVerifySchema())
11681177
@response_schema(JWSVerifyResponseSchema(), 200, description="")
11691178
@tenant_authentication
@@ -1204,7 +1213,7 @@ async def wallet_jwt_verify(request: web.BaseRequest):
12041213

12051214

12061215
@docs(
1207-
tags=["wallet"],
1216+
tags=[WALLET_TAG_TITLE],
12081217
summary="Verify an sd-jws using did keys with a given SD-JWS with "
12091218
"optional key binding",
12101219
)
@@ -1239,7 +1248,7 @@ async def wallet_sd_jwt_verify(request: web.BaseRequest):
12391248
return web.json_response(result.serialize())
12401249

12411250

1242-
@docs(tags=["wallet"], summary="Query DID endpoint in wallet")
1251+
@docs(tags=[WALLET_TAG_TITLE], summary="Query DID endpoint in wallet")
12431252
@querystring_schema(DIDQueryStringSchema())
12441253
@response_schema(DIDEndpointSchema, 200, description="")
12451254
@tenant_authentication
@@ -1273,7 +1282,9 @@ async def wallet_get_did_endpoint(request: web.BaseRequest):
12731282
return web.json_response({"did": did, "endpoint": endpoint})
12741283

12751284

1276-
@docs(tags=["wallet"], summary="Rotate keypair for a DID not posted to the ledger")
1285+
@docs(
1286+
tags=[WALLET_TAG_TITLE], summary="Rotate keypair for a DID not posted to the ledger"
1287+
)
12771288
@querystring_schema(DIDQueryStringSchema())
12781289
@response_schema(WalletModuleResponseSchema(), description="")
12791290
@tenant_authentication
@@ -1329,11 +1340,9 @@ class UpgradeResultSchema(OpenAPISchema):
13291340

13301341

13311342
@docs(
1332-
tags=["anoncreds - wallet upgrade"],
1333-
summary="""
1334-
Upgrade the wallet from askar to anoncreds - Be very careful with this! You
1335-
cannot go back! See migration guide for more information.
1336-
""",
1343+
tags=[UPGRADE_TAG_TITLE],
1344+
summary="Upgrade the wallet from askar to askar-anoncreds. Be very careful with this!"
1345+
" You cannot go back! See migration guide for more information.",
13371346
)
13381347
@querystring_schema(UpgradeVerificationSchema())
13391348
@response_schema(UpgradeResultSchema(), description="")
@@ -1484,7 +1493,7 @@ def post_process_routes(app: web.Application):
14841493
app._state["swagger_dict"]["tags"] = []
14851494
app._state["swagger_dict"]["tags"].append(
14861495
{
1487-
"name": "wallet",
1496+
"name": WALLET_TAG_TITLE,
14881497
"description": "DID and tag policy management",
14891498
"externalDocs": {
14901499
"description": "Design",
@@ -1497,7 +1506,7 @@ def post_process_routes(app: web.Application):
14971506
)
14981507
app._state["swagger_dict"]["tags"].append(
14991508
{
1500-
"name": "AnonCreds - Wallet Upgrade",
1509+
"name": UPGRADE_TAG_TITLE,
15011510
"description": "AnonCreds wallet upgrade",
15021511
"externalDocs": {
15031512
"description": "Specification",

0 commit comments

Comments
 (0)