Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix api schema mixup in revocation routes #2909

Merged
merged 2 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions aries_cloudagent/revocation/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def validate_fields(self, data, **kwargs):
)


class PublishRevocationsSchemaAnoncreds(OpenAPISchema):
class PublishRevocationsSchema(OpenAPISchema):
"""Request and result schema for revocation publication API call."""

rrid2crid = fields.Dict(
Expand All @@ -293,7 +293,7 @@ class TxnOrPublishRevocationsResultSchema(OpenAPISchema):
"""Result schema for credential definition send request."""

sent = fields.Nested(
PublishRevocationsSchemaAnoncreds(),
PublishRevocationsSchema(),
required=False,
metadata={"definition": "Content sent"},
)
Expand Down Expand Up @@ -330,7 +330,7 @@ class ClearPendingRevocationsRequestSchema(OpenAPISchema):
)


class CredRevRecordResultSchemaAnoncreds(OpenAPISchema):
class CredRevRecordResultSchema(OpenAPISchema):
"""Result schema for credential revocation record request."""

result = fields.Nested(IssuerCredRevRecordSchema())
Expand Down Expand Up @@ -613,7 +613,7 @@ async def revoke(request: web.BaseRequest):


@docs(tags=["revocation"], summary="Publish pending revocations to ledger")
@request_schema(PublishRevocationsSchemaAnoncreds())
@request_schema(PublishRevocationsSchema())
@querystring_schema(CreateRevRegTxnForEndorserOptionSchema())
@querystring_schema(RevRegConnIdMatchInfoSchema())
@response_schema(TxnOrPublishRevocationsResultSchema(), 200, description="")
Expand Down Expand Up @@ -686,7 +686,7 @@ async def publish_revocations(request: web.BaseRequest):

@docs(tags=["revocation"], summary="Clear pending revocations")
@request_schema(ClearPendingRevocationsRequestSchema())
@response_schema(PublishRevocationsSchemaAnoncreds(), 200, description="")
@response_schema(PublishRevocationsSchema(), 200, description="")
async def clear_pending_revocations(request: web.BaseRequest):
"""Request handler for clearing pending revocations.

Expand Down Expand Up @@ -1070,7 +1070,7 @@ async def update_rev_reg_revoked_state(request: web.BaseRequest):
summary="Get credential revocation status",
)
@querystring_schema(CredRevRecordQueryStringSchema())
@response_schema(CredRevRecordResultSchemaAnoncreds(), 200, description="")
@response_schema(CredRevRecordResultSchema(), 200, description="")
async def get_cred_rev_record(request: web.BaseRequest):
"""Request handler to get credential revocation record.

Expand Down
56 changes: 6 additions & 50 deletions aries_cloudagent/revocation_anoncreds/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@
WHOLE_NUM_VALIDATE,
UUIDFour,
)
from ..protocols.endorse_transaction.v1_0.models.transaction_record import (
TransactionRecordSchema,
)
from ..revocation.error import RevocationError
from ..revocation.models.issuer_rev_reg_record import (
IssuerRevRegRecord,
Expand Down Expand Up @@ -80,23 +77,6 @@ class RevRegResultSchemaAnoncreds(OpenAPISchema):
result = fields.Nested(IssuerRevRegRecordSchema())


class TxnOrRevRegResultSchema(OpenAPISchema):
"""Result schema for credential definition send request."""

sent = fields.Nested(
RevRegResultSchemaAnoncreds(),
required=False,
metadata={"definition": "Content sent"},
)
txn = fields.Nested(
TransactionRecordSchema(),
required=False,
metadata={
"description": "Revocation registry definition transaction to endorse"
},
)


class CredRevRecordQueryStringSchema(OpenAPISchema):
"""Parameters and validators for credential revocation record request."""

Expand Down Expand Up @@ -173,31 +153,7 @@ def validate_fields(self, data, **kwargs):
)


class ClearPendingRevocationsRequestSchema(OpenAPISchema):
"""Request schema for clear pending revocations API call."""

purge = fields.Dict(
required=False,
keys=fields.Str(metadata={"example": INDY_REV_REG_ID_EXAMPLE}),
values=fields.List(
fields.Str(
validate=INDY_CRED_REV_ID_VALIDATE,
metadata={
"description": "Credential revocation identifier",
"example": INDY_CRED_REV_ID_EXAMPLE,
},
)
),
metadata={
"description": (
"Credential revocation ids by revocation registry id: omit for all,"
" specify null or empty list for all pending per revocation registry"
)
},
)


class CredRevRecordResultSchema(OpenAPISchema):
class CredRevRecordResultSchemaAnoncreds(OpenAPISchema):
"""Result schema for credential revocation record request."""

result = fields.Nested(IssuerCredRevRecordSchemaAnoncreds())
Expand Down Expand Up @@ -386,7 +342,7 @@ class PublishRevocationsOptions(OpenAPISchema):
)


class PublishRevocationsSchema(OpenAPISchema):
class PublishRevocationsSchemaAnoncreds(OpenAPISchema):
"""Request and result schema for revocation publication API call."""

rrid2crid = fields.Dict(
Expand All @@ -406,7 +362,7 @@ class PublishRevocationsSchema(OpenAPISchema):
options = fields.Nested(PublishRevocationsOptions())


class PublishRevocationsResultSchema(OpenAPISchema):
class PublishRevocationsResultSchemaAnoncreds(OpenAPISchema):
"""Result schema for credential definition send request."""

rrid2crid = fields.Dict(
Expand Down Expand Up @@ -554,8 +510,8 @@ async def revoke(request: web.BaseRequest):


@docs(tags=[TAG_TITLE], summary="Publish pending revocations to ledger")
@request_schema(PublishRevocationsSchema())
@response_schema(PublishRevocationsResultSchema(), 200, description="")
@request_schema(PublishRevocationsSchemaAnoncreds())
@response_schema(PublishRevocationsResultSchemaAnoncreds(), 200, description="")
async def publish_revocations(request: web.BaseRequest):
"""Request handler for publishing pending revocations to the ledger.

Expand Down Expand Up @@ -988,7 +944,7 @@ async def update_rev_reg_revoked_state(request: web.BaseRequest):
summary="Get credential revocation status",
)
@querystring_schema(CredRevRecordQueryStringSchema())
@response_schema(CredRevRecordResultSchema(), 200, description="")
@response_schema(CredRevRecordResultSchemaAnoncreds(), 200, description="")
async def get_cred_rev_record(request: web.BaseRequest):
"""Request handler to get credential revocation record.

Expand Down