From 06f1d366998e23be6dd8767635230bb4f1d38d01 Mon Sep 17 00:00:00 2001 From: cl0ete Date: Wed, 14 Aug 2024 23:02:38 +0200 Subject: [PATCH] Update `TxnOrPublishRevocationsResultSchema` (#3164) * fix response for publish revocations Signed-off-by: cl0ete * add logging Signed-off-by: cl0ete * update model to make txn a list of TransactionRecordSchema Signed-off-by: cl0ete * update return value to match response model Signed-off-by: cl0ete * remove logging Signed-off-by: cl0ete * ran script generate-open-api-spec Signed-off-by: cl0ete * remove white space Signed-off-by: cl0ete * TxnOrPublishRevocations... extends PublishRevocationsSchema Signed-off-by: cl0ete * remove sent i.e. revert back Signed-off-by: cl0ete * ran script generate-open-api-spec Signed-off-by: cl0ete --------- Signed-off-by: cl0ete --- aries_cloudagent/revocation/routes.py | 34 +++++++++++---------------- open-api/openapi.json | 27 +++++++++++++++------ open-api/swagger.json | 27 +++++++++++++++------ 3 files changed, 54 insertions(+), 34 deletions(-) diff --git a/aries_cloudagent/revocation/routes.py b/aries_cloudagent/revocation/routes.py index 83505db7d4..7b6b890d56 100644 --- a/aries_cloudagent/revocation/routes.py +++ b/aries_cloudagent/revocation/routes.py @@ -290,20 +290,17 @@ class PublishRevocationsSchema(OpenAPISchema): ) -class TxnOrPublishRevocationsResultSchema(OpenAPISchema): +class TxnOrPublishRevocationsResultSchema(PublishRevocationsSchema): """Result schema for credential definition send request.""" - sent = fields.Nested( - PublishRevocationsSchema(), - required=False, - metadata={"definition": "Content sent"}, - ) - txn = fields.Nested( - TransactionRecordSchema(), - required=False, - metadata={ - "description": "Revocation registry revocations transaction to endorse" - }, + txn = fields.List( + fields.Nested( + TransactionRecordSchema(), + required=False, + metadata={ + "description": "Revocation registry revocations transaction to endorse" + }, + ) ) @@ -661,13 +658,10 @@ async def publish_revocations(request: web.BaseRequest): raise web.HTTPBadRequest(reason=err.roll_up) from err if create_transaction_for_endorser: - return web.json_response( - ( - await _process_publish_response_for_endorsement( - profile, rev_reg_responses, outbound_handler, endorser_conn_id - ) - ) + list_of_txns = await _process_publish_response_for_endorsement( + profile, rev_reg_responses, outbound_handler, endorser_conn_id ) + return web.json_response({"txn": list_of_txns}) return web.json_response({"rrid2crid": result}) @@ -702,7 +696,7 @@ async def _process_publish_response_for_endorsement( await outbound_handler(transaction_request, connection_id=endorser_conn_id) - txn_responses.append({"txn": transaction.serialize()}) + txn_responses.append(transaction.serialize()) return txn_responses @@ -1926,4 +1920,4 @@ def post_process_routes(app: web.Application): methods["get"]["responses"]["200"]["schema"] = { "type": "string", "format": "binary", - } \ No newline at end of file + } diff --git a/open-api/openapi.json b/open-api/openapi.json index c68e24bbd7..06928e55a6 100644 --- a/open-api/openapi.json +++ b/open-api/openapi.json @@ -13703,15 +13703,28 @@ }, "TxnOrPublishRevocationsResult" : { "properties" : { - "sent" : { - "$ref" : "#/components/schemas/PublishRevocations" + "rrid2crid" : { + "additionalProperties" : { + "items" : { + "description" : "Credential revocation identifier", + "example" : "12345", + "pattern" : "^[1-9][0-9]*$", + "type" : "string" + }, + "type" : "array" + }, + "description" : "Credential revocation ids by revocation registry id", + "type" : "object" }, "txn" : { - "allOf" : [ { - "$ref" : "#/components/schemas/TransactionRecord" - } ], - "description" : "Revocation registry revocations transaction to endorse", - "type" : "object" + "items" : { + "allOf" : [ { + "$ref" : "#/components/schemas/TransactionRecord" + } ], + "description" : "Revocation registry revocations transaction to endorse", + "type" : "object" + }, + "type" : "array" } }, "type" : "object" diff --git a/open-api/swagger.json b/open-api/swagger.json index 63fe57fb0c..94e015c136 100644 --- a/open-api/swagger.json +++ b/open-api/swagger.json @@ -12148,11 +12148,28 @@ "TxnOrPublishRevocationsResult" : { "type" : "object", "properties" : { - "sent" : { - "$ref" : "#/definitions/PublishRevocations" + "rrid2crid" : { + "type" : "object", + "description" : "Credential revocation ids by revocation registry id", + "additionalProperties" : { + "type" : "array", + "items" : { + "type" : "string", + "example" : "12345", + "description" : "Credential revocation identifier", + "pattern" : "^[1-9][0-9]*$" + } + } }, "txn" : { - "$ref" : "#/definitions/TxnOrPublishRevocationsResult_txn" + "type" : "array", + "items" : { + "type" : "object", + "description" : "Revocation registry revocations transaction to endorse", + "allOf" : [ { + "$ref" : "#/definitions/TransactionRecord" + } ] + } } } }, @@ -14803,10 +14820,6 @@ "type" : "object", "description" : "Credential definition transaction to endorse" }, - "TxnOrPublishRevocationsResult_txn" : { - "type" : "object", - "description" : "Revocation registry revocations transaction to endorse" - }, "TxnOrRegisterLedgerNymResponse_txn" : { "type" : "object", "description" : "DID transaction to endorse"