Skip to content

Commit

Permalink
feat: Remove dereferenceSecondary Swagger Endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
DaevMithran committed Dec 5, 2022
1 parent ce35f07 commit 83e4728
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 247 deletions.
73 changes: 0 additions & 73 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,79 +286,6 @@ const docTemplate = `{
}
}
}
},
"/1.0/identifiers/{did}{fragmentId}": {
"get": {
"description": "Get DID Doc or its fragment",
"consumes": [
"application/did+ld+json",
"application/ld+json",
"application/did+json"
],
"produces": [
"application/did+ld+json",
"application/ld+json",
"application/did+json"
],
"tags": [
"Dereferencing"
],
"summary": "Resolve or dereferencing DID Doc",
"parameters": [
{
"type": "string",
"description": "DID Doc Id",
"name": "did",
"in": "path",
"required": true
},
{
"type": "string",
"description": "` + "`" + `#` + "`" + ` + DID Doc Verification Method or Service identifier",
"name": "fragmentId",
"in": "path",
"required": true
},
{
"type": "string",
"description": "Service id",
"name": "service",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/types.DidDereferencing"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/types.DidDereferencing"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/types.DidDereferencing"
}
},
"406": {
"description": "Not Acceptable",
"schema": {
"$ref": "#/definitions/types.DidDereferencing"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/types.DidDereferencing"
}
}
}
}
}
},
"definitions": {
Expand Down
73 changes: 0 additions & 73 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -277,79 +277,6 @@
}
}
}
},
"/1.0/identifiers/{did}{fragmentId}": {
"get": {
"description": "Get DID Doc or its fragment",
"consumes": [
"application/did+ld+json",
"application/ld+json",
"application/did+json"
],
"produces": [
"application/did+ld+json",
"application/ld+json",
"application/did+json"
],
"tags": [
"Dereferencing"
],
"summary": "Resolve or dereferencing DID Doc",
"parameters": [
{
"type": "string",
"description": "DID Doc Id",
"name": "did",
"in": "path",
"required": true
},
{
"type": "string",
"description": "`#` + DID Doc Verification Method or Service identifier",
"name": "fragmentId",
"in": "path",
"required": true
},
{
"type": "string",
"description": "Service id",
"name": "service",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/types.DidDereferencing"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/types.DidDereferencing"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/types.DidDereferencing"
}
},
"406": {
"description": "Not Acceptable",
"schema": {
"$ref": "#/definitions/types.DidDereferencing"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/types.DidDereferencing"
}
}
}
}
}
},
"definitions": {
Expand Down
50 changes: 0 additions & 50 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -371,54 +371,4 @@ paths:
summary: Collection resources
tags:
- Dereferencing
/1.0/identifiers/{did}{fragmentId}:
get:
consumes:
- application/did+ld+json
- application/ld+json
- application/did+json
description: Get DID Doc or its fragment
parameters:
- description: DID Doc Id
in: path
name: did
required: true
type: string
- description: '`#` + DID Doc Verification Method or Service identifier'
in: path
name: fragmentId
required: true
type: string
- description: Service id
in: query
name: service
type: string
produces:
- application/did+ld+json
- application/ld+json
- application/did+json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/types.DidDereferencing'
"400":
description: Bad Request
schema:
$ref: '#/definitions/types.DidDereferencing'
"404":
description: Not Found
schema:
$ref: '#/definitions/types.DidDereferencing'
"406":
description: Not Acceptable
schema:
$ref: '#/definitions/types.DidDereferencing'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/types.DidDereferencing'
summary: Resolve or dereferencing DID Doc
tags:
- Dereferencing
swagger: "2.0"
15 changes: 0 additions & 15 deletions services/diddoc_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,6 @@ func (dds DIDDocService) Resolve(did string, contentType types.ContentType) (*ty
return &result, nil
}

// ResolveDIDDocDereferencing godoc
// @Summary Resolve or dereferencing DID Doc
// @Description Get DID Doc or its fragment
// @Tags Dereferencing
// @Accept application/did+ld+json,application/ld+json,application/did+json
// @Produce application/did+ld+json,application/ld+json,application/did+json
// @Param did path string true "DID Doc Id" Did(did:cheqd:mainnet:zF7rhDBfUt9d1gJPjx7s1JXfUY7oVWkY)
// @Param fragmentId path string true "`#` + DID Doc Verification Method or Service identifier" FragmentId(#key1)
// @Param service query string false "Service id" ServiceId("service1")
// @Success 200 {object} types.DidDereferencing
// @Failure 400 {object} types.DidDereferencing
// @Failure 404 {object} types.DidDereferencing
// @Failure 406 {object} types.DidDereferencing
// @Failure 500 {object} types.DidDereferencing
// @Router /1.0/identifiers/{did}{fragmentId} [get]
func (dds DIDDocService) dereferenceSecondary(did string, fragmentId string, contentType types.ContentType) (*types.DidDereferencing, *types.IdentityError) {
didResolution, err := dds.Resolve(did, contentType)
if err != nil {
Expand Down
72 changes: 36 additions & 36 deletions tests/pytest/test_resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,42 +78,42 @@ def test_resolution_content_type(accept, expected_header, expected_body, has_con
assert not re.findall(r"context", r.text.replace("\n", "\\n").replace("\n", "\\n"))


secondary_dereferencing_content_type_test_set = [
(LDJSON, DIDLDJSON, True, 200,
r"(.*?)dereferencingMetadata(.*?)application/did\+ld\+json"
r"(.*?)contentStream(.*?)@context(.*?)contentMetadata"),
(DIDLDJSON, DIDLDJSON, True, 200,
"(.*?)dereferencingMetadata(.*?)application/did\+ld\+json"
"(.*?)contentStream(.*?)@context(.*?)contentMetadata"),
("*/*", DIDLDJSON, True, 200,
"(.*?)dereferencingMetadata(.*?)application/did\+ld\+json"
"(.*?)contentStream(.*?)@context(.*?)contentMetadata"),
(DIDJSON, DIDJSON, False, 200,
r"(.*?)dereferencingMetadata(.*?)application/did\+json"
r"(.*?)contentStream(.*?)contentMetadata"),
(HTML, JSON, False, 406,
"(.*?)dereferencingMetadata(.*?)\"error\": \"representationNotSupported\""
"(.*?)\"contentStream\": null,(.*?)\"contentMetadata\": \{\}"),
]


@pytest.mark.parametrize(
"accept, expected_header, has_context, expected_status_code, expected_body",
secondary_dereferencing_content_type_test_set
)
def test_dereferencing_content_type_fragment(accept, expected_header, expected_body, has_context, expected_status_code):
url = RESOLVER_URL + PATH + TESTNET_FRAGMENT.replace("#", "%23")
header = {"Accept": accept} if accept else {}

r = requests.get(url, headers=header)

assert r.headers["Content-Type"] == expected_header
assert r.status_code == expected_status_code
assert re.match(expected_body, r.text.replace("\n", "\\n"))
if has_context:
assert re.findall(r"context", r.text.replace("\n", "\\n"))
else:
assert not re.findall(r"context", r.text.replace("\n", "\\n"))
# secondary_dereferencing_content_type_test_set = [
# (LDJSON, DIDLDJSON, True, 200,
# r"(.*?)dereferencingMetadata(.*?)application/did\+ld\+json"
# r"(.*?)contentStream(.*?)@context(.*?)contentMetadata"),
# (DIDLDJSON, DIDLDJSON, True, 200,
# "(.*?)dereferencingMetadata(.*?)application/did\+ld\+json"
# "(.*?)contentStream(.*?)@context(.*?)contentMetadata"),
# ("*/*", DIDLDJSON, True, 200,
# "(.*?)dereferencingMetadata(.*?)application/did\+ld\+json"
# "(.*?)contentStream(.*?)@context(.*?)contentMetadata"),
# (DIDJSON, DIDJSON, False, 200,
# r"(.*?)dereferencingMetadata(.*?)application/did\+json"
# r"(.*?)contentStream(.*?)contentMetadata"),
# (HTML, JSON, False, 406,
# "(.*?)dereferencingMetadata(.*?)\"error\": \"representationNotSupported\""
# "(.*?)\"contentStream\": null,(.*?)\"contentMetadata\": \{\}"),
# ]


# @pytest.mark.parametrize(
# "accept, expected_header, has_context, expected_status_code, expected_body",
# secondary_dereferencing_content_type_test_set
# )
# def test_dereferencing_content_type_fragment(accept, expected_header, expected_body, has_context, expected_status_code):
# url = RESOLVER_URL + PATH + TESTNET_FRAGMENT.replace("#", "%23")
# header = {"Accept": accept} if accept else {}

# r = requests.get(url, headers=header)

# assert r.headers["Content-Type"] == expected_header
# assert r.status_code == expected_status_code
# assert re.match(expected_body, r.text.replace("\n", "\\n"))
# if has_context:
# assert re.findall(r"context", r.text.replace("\n", "\\n"))
# else:
# assert not re.findall(r"context", r.text.replace("\n", "\\n"))


primary_dereferencing_content_type_test_set = [
Expand Down

0 comments on commit 83e4728

Please sign in to comment.