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: Dereference resource data based on mediatype [DEV-4778] #350

Merged
merged 6 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from 4 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
16 changes: 15 additions & 1 deletion docs/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,20 @@
}
}
},
"types.ResolutionResourceMetadata": {
"type": "object",
"properties": {
"linkedResourceMetadata": {
"type": "array",
"items": {
"$ref": "#/definitions/types.DereferencedResource"
}
},
"metadata": {
"$ref": "#/definitions/types.DereferencedResource"
}
}
},
"types.ResourceDereferencing": {
"type": "object",
"properties": {
Expand All @@ -939,7 +953,7 @@
"example": "https://w3id.org/did-resolution/v1"
},
"contentMetadata": {
"$ref": "#/definitions/types.DereferencedResource"
"$ref": "#/definitions/types.ResolutionResourceMetadata"
},
"contentStream": {},
"dereferencingMetadata": {
Expand Down
11 changes: 10 additions & 1 deletion docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,22 @@ definitions:
example: "2021-09-01T12:00:00Z"
type: string
type: object
types.ResolutionResourceMetadata:
properties:
linkedResourceMetadata:
items:
$ref: '#/definitions/types.DereferencedResource'
type: array
metadata:
$ref: '#/definitions/types.DereferencedResource'
type: object
types.ResourceDereferencing:
properties:
'@context':
example: https://w3id.org/did-resolution/v1
type: string
contentMetadata:
$ref: '#/definitions/types.DereferencedResource'
$ref: '#/definitions/types.ResolutionResourceMetadata'
contentStream: {}
dereferencingMetadata:
$ref: '#/definitions/types.DereferencingMetadata'
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/resource_dereference_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (rds ResourceService) DereferenceResourceDataWithMetadata(did string, resou
var result types.ContentStreamI
result = types.NewDereferencedResourceData(resource.Resource.Data)
metadata := types.NewDereferencedResource(did, resource.Metadata)
if dereferenceMetadata.ContentType == types.JSON || dereferenceMetadata.ContentType == types.TEXT {
if metadata.MediaType == string(types.JSON) || metadata.MediaType == string(types.TEXT) {
if res, err := types.NewResourceData(resource.Resource.Data); err == nil {
result = res
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"method": "cheqd"
}
},
"contentStream": "eyAKICAgICJjb250ZW50IjogInRlc3QgZGF0YSIKfQ==",
"contentStream": {
"content": "test data"
},
"contentMetadata": {
"resourceURI": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0/resources/9ba3922e-d5f5-4f53-b265-fc0d4e988c77",
"resourceCollectionId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0",
Expand Down
Loading