Skip to content

Commit

Permalink
fix: opan-api generator script
Browse files Browse the repository at this point in the history
And some minor cleanup to make the generated openapi more usable

Signed-off-by: Daniel Bluhm <dbluhm@pm.me>
  • Loading branch information
dbluhm committed Dec 8, 2023
1 parent b055b78 commit d8a6f3f
Show file tree
Hide file tree
Showing 6 changed files with 1,963 additions and 594 deletions.
22 changes: 16 additions & 6 deletions aries_cloudagent/indy/models/cred.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import Mapping

from marshmallow import EXCLUDE, fields
from marshmallow import EXCLUDE, ValidationError, fields

from ...messaging.models.base import BaseModel, BaseModelSchema
from ...messaging.valid import (
Expand Down Expand Up @@ -52,6 +52,20 @@ class Meta:
)


class DictWithIndyAttrValueSchema(fields.Dict):
"""Dict with indy attribute value schema."""

def _deserialize(self, value, attr, data, **kwargs):
"""Deserialize dict with indy attribute value."""
if not isinstance(value, dict):
raise ValidationError("Value must be a dict.")

return {
k: IndyAttrValueSchema().load(v) if isinstance(v, dict) else v
for k, v in value.items()
}


class IndyCredential(BaseModel):
"""Indy credential."""

Expand Down Expand Up @@ -115,11 +129,7 @@ class Meta:
"example": INDY_REV_REG_ID_EXAMPLE,
},
)
values = fields.Dict(
keys=fields.Str(metadata={"description": "Attribute name"}),
values=fields.Nested(
IndyAttrValueSchema(), metadata={"description": "Attribute value"}
),
values = DictWithIndyAttrValueSchema(
required=True,
metadata={"description": "Credential attributes"},
)
Expand Down
45 changes: 5 additions & 40 deletions aries_cloudagent/resolver/routes.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,4 @@
"""Resolve did document admin routes.
"/resolver/resolve/{did}": {
"get": {
"responses": {
"200": {
"schema": {
"$ref": "#/definitions/DIDDoc"
},
"description": null
}
},
"parameters": [
{
"in": "path",
"name": "did",
"required": true,
"type": "string",
"pattern": "did:([a-z]+):((?:[a-zA-Z0-9._-]*:)*[a-zA-Z0-9._-]+)",
"description": "decentralize identifier(DID)",
"example": "did:ted:WgWxqztrNooG92RXvxSTWv"
}
],
"tags": [ "resolver" ],
"summary": "Retrieve doc for requested did",
"produces": [ "application/json" ]
}
}
"""
"""Resolve did document admin routes."""

from aiohttp import web
from aiohttp_apispec import docs, match_info_schema, response_schema
Expand Down Expand Up @@ -131,6 +93,9 @@ def post_process_routes(app: web.Application):
{
"name": "resolver",
"description": "did resolver interface.",
"externalDocs": {"description": "Specification"}, # , "url": SPEC_URI},
"externalDocs": {
"description": "DID Resolution Specification",
"url": "https://www.w3.org/TR/did-core/#resolution",
},
}
)
6 changes: 3 additions & 3 deletions aries_cloudagent/vc/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ def post_process_routes(app: web.Application):
app._state["swagger_dict"]["tags"] = []
app._state["swagger_dict"]["tags"].append(
{
"name": "jsonld",
"description": "Sign and verify json-ld data",
"name": "ldp-vc",
"description": "Issue and verify LDP VCs and VPs",
"externalDocs": {
"description": "Specification",
"url": "https://tools.ietf.org/html/rfc7515",
"url": "https://www.w3.org/TR/vc-data-model/",
},
}
)
Loading

0 comments on commit d8a6f3f

Please sign in to comment.