diff --git a/acapy_agent/anoncreds/models/schema.py b/acapy_agent/anoncreds/models/schema.py index 6a3f56bc03..1a3e3152d2 100644 --- a/acapy_agent/anoncreds/models/schema.py +++ b/acapy_agent/anoncreds/models/schema.py @@ -64,6 +64,7 @@ class Meta: "example": ANONCREDS_DID_EXAMPLE, }, data_key="issuerId", + required=True, ) attr_names = fields.List( fields.Str( @@ -74,11 +75,15 @@ class Meta: ), metadata={"description": "Schema attribute names"}, data_key="attrNames", + required=True, ) name = fields.Str( - metadata={"description": "Schema name", "example": "Example schema"} + metadata={"description": "Schema name", "example": "Example schema"}, + required=True, + ) + version = fields.Str( + metadata={"description": "Schema version", "example": "1.0"}, required=True ) - version = fields.Str(metadata={"description": "Schema version", "example": "1.0"}) class GetSchemaResult(BaseModel): diff --git a/acapy_agent/anoncreds/routes.py b/acapy_agent/anoncreds/routes.py index 9a8fe04669..2f877c5cc6 100644 --- a/acapy_agent/anoncreds/routes.py +++ b/acapy_agent/anoncreds/routes.py @@ -524,6 +524,7 @@ class InnerRevRegDefSchema(OpenAPISchema): "example": ANONCREDS_DID_EXAMPLE, }, data_key="issuerId", + required=True, ) cred_def_id = fields.Str( metadata={ @@ -531,9 +532,11 @@ class InnerRevRegDefSchema(OpenAPISchema): "example": ANONCREDS_SCHEMA_ID_EXAMPLE, }, data_key="credDefId", + required=True, ) tag = fields.Str( - metadata={"description": "tag for revocation registry", "example": "default"} + metadata={"description": "tag for revocation registry", "example": "default"}, + required=True, ) max_cred_num = fields.Int( metadata={ @@ -541,6 +544,7 @@ class InnerRevRegDefSchema(OpenAPISchema): "example": 777, }, data_key="maxCredNum", + required=True, ) @@ -649,7 +653,8 @@ class RevListCreateRequestSchema(OpenAPISchema): metadata={ "description": "Revocation registry definition identifier", "example": ANONCREDS_REV_REG_ID_EXAMPLE, - } + }, + required=True, ) options = fields.Nested(RevListOptionsSchema) diff --git a/acapy_agent/anoncreds/tests/test_routes.py b/acapy_agent/anoncreds/tests/test_routes.py index 607b81f4ae..c59af1a662 100644 --- a/acapy_agent/anoncreds/tests/test_routes.py +++ b/acapy_agent/anoncreds/tests/test_routes.py @@ -97,6 +97,13 @@ async def test_schemas_post(self, mock_create_and_register_schema): }, {}, {"schema": {}}, + { + "schema": { + "attrNames": ["score"], + "name": "Example Schema", + "version": "0.0.1", + } + }, ] ) result = await test_module.schemas_post(self.request) @@ -105,9 +112,12 @@ async def test_schemas_post(self, mock_create_and_register_schema): assert mock_create_and_register_schema.call_count == 1 with self.assertRaises(web.HTTPBadRequest): + # Empty body + await test_module.schemas_post(self.request) + # Empty schema + await test_module.schemas_post(self.request) + # Missing issuerId await test_module.schemas_post(self.request) - - await test_module.schemas_post(self.request) async def test_get_schema(self): self.request.match_info = {"schema_id": "schema_id"}