Skip to content

Commit

Permalink
fix: Add static checks to resolver before requests are sent to the le…
Browse files Browse the repository at this point in the history
…dger [DEV-2204] (#111)

- Added static validation for `versionId` and `resourceId`.
- Already added static validation for DID (length DID, namespace DID,
etc.).
- Added correctly HTTP status code for `methodNotSupport` error.
- Fix problem with `updated` field in `DIDDocMetadata` type.
- Update swagger OpenAPI.
  • Loading branch information
Andrew Nikitin committed Mar 15, 2023
2 parents 712480c + c96afcc commit 430e1fb
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 31 deletions.
42 changes: 42 additions & 0 deletions docs/docs.go

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

42 changes: 42 additions & 0 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@
"schema": {
"$ref": "#/definitions/types.IdentityError"
}
},
"501": {
"description": "Not Implemented",
"schema": {
"$ref": "#/definitions/types.IdentityError"
}
}
}
}
Expand Down Expand Up @@ -166,6 +172,12 @@
"schema": {
"$ref": "#/definitions/types.IdentityError"
}
},
"501": {
"description": "Not Implemented",
"schema": {
"$ref": "#/definitions/types.IdentityError"
}
}
}
}
Expand Down Expand Up @@ -232,6 +244,12 @@
"schema": {
"$ref": "#/definitions/types.IdentityError"
}
},
"501": {
"description": "Not Implemented",
"schema": {
"$ref": "#/definitions/types.IdentityError"
}
}
}
}
Expand Down Expand Up @@ -299,6 +317,12 @@
"schema": {
"$ref": "#/definitions/types.IdentityError"
}
},
"501": {
"description": "Not Implemented",
"schema": {
"$ref": "#/definitions/types.IdentityError"
}
}
}
}
Expand Down Expand Up @@ -366,6 +390,12 @@
"schema": {
"$ref": "#/definitions/types.IdentityError"
}
},
"501": {
"description": "Not Implemented",
"schema": {
"$ref": "#/definitions/types.IdentityError"
}
}
}
}
Expand Down Expand Up @@ -433,6 +463,12 @@
"schema": {
"$ref": "#/definitions/types.IdentityError"
}
},
"501": {
"description": "Not Implemented",
"schema": {
"$ref": "#/definitions/types.IdentityError"
}
}
}
}
Expand Down Expand Up @@ -505,6 +541,12 @@
"schema": {
"$ref": "#/definitions/types.IdentityError"
}
},
"501": {
"description": "Not Implemented",
"schema": {
"$ref": "#/definitions/types.IdentityError"
}
}
}
}
Expand Down
28 changes: 28 additions & 0 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ paths:
description: Internal Server Error
schema:
$ref: '#/definitions/types.IdentityError'
"501":
description: Not Implemented
schema:
$ref: '#/definitions/types.IdentityError'
summary: Resolve DID Document on did:cheqd
tags:
- DID Resolution
Expand Down Expand Up @@ -354,6 +358,10 @@ paths:
description: Internal Server Error
schema:
$ref: '#/definitions/types.IdentityError'
"501":
description: Not Implemented
schema:
$ref: '#/definitions/types.IdentityError'
summary: Fetch metadata for all Resources
tags:
- Resource Resolution
Expand Down Expand Up @@ -398,6 +406,10 @@ paths:
description: Internal Server Error
schema:
$ref: '#/definitions/types.IdentityError'
"501":
description: Not Implemented
schema:
$ref: '#/definitions/types.IdentityError'
summary: Fetch specific Resource
tags:
- Resource Resolution
Expand Down Expand Up @@ -444,6 +456,10 @@ paths:
description: Internal Server Error
schema:
$ref: '#/definitions/types.IdentityError'
"501":
description: Not Implemented
schema:
$ref: '#/definitions/types.IdentityError'
summary: Fetch Resource-specific metadata
tags:
- Resource Resolution
Expand Down Expand Up @@ -491,6 +507,10 @@ paths:
description: Internal Server Error
schema:
$ref: '#/definitions/types.IdentityError'
"501":
description: Not Implemented
schema:
$ref: '#/definitions/types.IdentityError'
summary: Resolve DID Document Version on did:cheqd
tags:
- DID Resolution
Expand Down Expand Up @@ -538,6 +558,10 @@ paths:
description: Internal Server Error
schema:
$ref: '#/definitions/types.IdentityError'
"501":
description: Not Implemented
schema:
$ref: '#/definitions/types.IdentityError'
summary: Resolve DID Document Version Metadata on did:cheqd
tags:
- DID Resolution
Expand Down Expand Up @@ -585,6 +609,10 @@ paths:
description: Internal Server Error
schema:
$ref: '#/definitions/types.IdentityError'
"501":
description: Not Implemented
schema:
$ref: '#/definitions/types.IdentityError'
summary: Resolve DID Document Versions on did:cheqd
tags:
- DID Resolution
Expand Down
4 changes: 4 additions & 0 deletions services/ledger_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func NewLedgerService() LedgerService {
// @Failure 400 {object} types.IdentityError
// @Failure 404 {object} types.IdentityError
// @Failure 406 {object} types.IdentityError
// @Failure 501 {object} types.IdentityError
// @Failure 500 {object} types.IdentityError
// @Router /{did} [get]
func (ls LedgerService) QueryDIDDoc(did string, version string) (*didTypes.DidDocWithMetadata, *types.IdentityError) {
Expand Down Expand Up @@ -103,6 +104,7 @@ func (ls LedgerService) QueryDIDDoc(did string, version string) (*didTypes.DidDo
// @Failure 400 {object} types.IdentityError
// @Failure 404 {object} types.IdentityError
// @Failure 406 {object} types.IdentityError
// @Failure 501 {object} types.IdentityError
// @Failure 500 {object} types.IdentityError
// @Router /{did}/versions [get]
func (ls LedgerService) QueryAllDidDocVersionsMetadata(did string) ([]*didTypes.Metadata, *types.IdentityError) {
Expand Down Expand Up @@ -143,6 +145,7 @@ func (ls LedgerService) QueryAllDidDocVersionsMetadata(did string) ([]*didTypes.
// @Failure 400 {object} types.IdentityError
// @Failure 404 {object} types.IdentityError
// @Failure 406 {object} types.IdentityError
// @Failure 501 {object} types.IdentityError
// @Failure 500 {object} types.IdentityError
// @Router /{did}/resources/{resourceId} [get]
func (ls LedgerService) QueryResource(did string, resourceId string) (*resourceTypes.ResourceWithMetadata, *types.IdentityError) {
Expand Down Expand Up @@ -184,6 +187,7 @@ func (ls LedgerService) QueryResource(did string, resourceId string) (*resourceT
// @Failure 400 {object} types.IdentityError
// @Failure 404 {object} types.IdentityError
// @Failure 406 {object} types.IdentityError
// @Failure 501 {object} types.IdentityError
// @Failure 500 {object} types.IdentityError
// @Router /{did}/metadata [get]
func (ls LedgerService) QueryCollectionResources(did string) ([]*resourceTypes.Metadata, *types.IdentityError) {
Expand Down
Loading

0 comments on commit 430e1fb

Please sign in to comment.