Skip to content

Commit

Permalink
add VDR v2 spec, generated code and empty wrapper (#2630)
Browse files Browse the repository at this point in the history
  • Loading branch information
woutslakhorst authored Dec 5, 2023
1 parent 30d3f21 commit a33a934
Show file tree
Hide file tree
Showing 7 changed files with 2,461 additions and 1 deletion.
13 changes: 13 additions & 0 deletions codegen/configs/vdr_v2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package: v2
generate:
echo-server: true
client: true
models: true
strict-server: true
output-options:
skip-prune: true
exclude-schemas:
- DIDDocument
- DIDDocumentMetadata
- Service
- VerificationMethod
280 changes: 280 additions & 0 deletions docs/_static/vdr/v2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,280 @@
openapi: "3.0.0"
info:
title: Nuts Verifiable Data Registry API spec
description: API specification for the Verifiable Data Registry
version: 2.0.0
license:
name: GPLv3
servers:
- url: http://localhost:1323
paths:
/internal/vdr/v2/did:
post:
summary: Creates a new Web DID
description: |
A new web DID and DID Document are created.
A single key pair is generated and added to the DID document. The key pair is used for all verificationMethods.
No services are added. If no ID is given, a random UUID is generated.
error returns:
* 400 - Returned in case of malformed DID in the request body
* 500 - An error occurred while processing the request
operationId: "createDID"
tags:
- DID
requestBody:
description: Options for the DID creation.
required: false
content:
application/json:
schema:
$ref: '#/components/schemas/CreateDIDOptions'
responses:
"200":
description: "New DID has been created successfully. Returns the DID document."
content:
application/json:
schema:
$ref: '#/components/schemas/DIDDocument'
default:
$ref: '../common/error_response.yaml'
/internal/vdr/v2/did/{did}:
parameters:
- name: did
in: path
description: URL encoded DID.
required: true
example: did:web:example.com:iam:013c6fda-73e8-45ee-9220-48652dba854b
schema:
type: string
get:
summary: "Resolves a DID document"
description: |
Resolves a DID document.
error returns:
* 400 - Returned in case of malformed DID
* 404 - Corresponding DID document could not be found
* 500 - An error occurred while processing the request
operationId: "resolveDID"
tags:
- DID
responses:
"200":
description: DID document has been found and returned.
content:
application/json:
schema:
$ref: '#/components/schemas/DIDResolutionResult'
default:
$ref: '../common/error_response.yaml'
delete:
summary: Deletes a locally managed Document.
description: |
error returns:
* 400 - the DID param was malformed
* 404 - Corresponding DID document could not be found
* 500 - An error occurred while processing the request
operationId: "deleteDID"
tags:
- DID
responses:
"204":
description: DID document has been deactivated.
default:
$ref: '../common/error_response.yaml'
/internal/vdr/v2/did/{did}/service:
parameters:
- name: did
in: path
description: URL encoded DID.
required: true
example: did:web:example.com:iam:013c6fda-73e8-45ee-9220-48652dba854b
schema:
type: string
post:
summary: Adds a service to the DID document.
description: |
It adds the given service to the DID Document. The ID will be generated when not given.
error returns:
* 400 - Returned in case of malformed DID or service
* 404 - Corresponding DID document could not be found
* 500 - An error occurred while processing the request
parameters:
- name: service
in: body
description: Service to be added to the DID document.
required: true
schema:
$ref: '#/components/schemas/Service'
operationId: addService
tags:
- DID
responses:
"200":
description: "New service has been added successfully. Returns the service."
content:
application/json:
schema:
$ref: '#/components/schemas/VerificationMethod'
default:
$ref: '../common/error_response.yaml'
/internal/vdr/v2/did/{did}/service/{id}:
parameters:
- name: did
in: path
description: URL encoded DID.
required: true
example: did:web:example.com:iam:013c6fda-73e8-45ee-9220-48652dba854b
schema:
type: string
- name: id
in: path
description: URL encoded id identifying the service.
required: true
example: "did:web:example.com:iam:013c6fda-73e8-45ee-9220-48652dba854b#3106f751-59e3-440f-b57b-39a96a2da6c6"
schema:
type: string
delete:
summary: Delete a specific service
description: |
Removes the service from the DID Document.
No cascading will happen for references to the service.
error returns:
* 404 - Corresponding DID document or verification method could not be found
* 500 - An error occurred while processing the request
tags:
- DID
operationId: deleteService
responses:
"204":
description: The service was successfully deleted
default:
$ref: '../common/error_response.yaml'
put:
summary: Updates a service in the DID document.
description: |
It updates the given service in the DID Document.
error returns:
* 400 - Returned in case of malformed DID or service
* 404 - Corresponding DID document could not be found
* 500 - An error occurred while processing the request
tags:
- DID
operationId: updateService
parameters:
- name: service
in: body
description: Service to be added to the DID document.
required: true
schema:
$ref: '#/components/schemas/Service'
responses:
"200":
description: "Service has been updated successfully. Returns the service."
content:
application/json:
schema:
$ref: '#/components/schemas/Service'
default:
$ref: '../common/error_response.yaml'
/internal/vdr/v2/did/{did}/verificationmethod:
parameters:
- name: did
in: path
description: URL encoded DID.
required: true
example: did:web:example.com:iam:013c6fda-73e8-45ee-9220-48652dba854b
schema:
type: string
post:
summary: Creates and adds a new verificationMethod to the DID document.
description: |
It creates a new private public keypair. The public key is wrapped in verificationMethod. This method is added to the DID Document.
The key pair is used for all verificationMethods.
error returns:
* 404 - Corresponding DID document could not be found
* 500 - An error occurred while processing the request
operationId: addVerificationMethod
tags:
- DID
responses:
"200":
description: "New verification method has been created and added successfully. Returns the verification method."
content:
application/json:
schema:
$ref: '#/components/schemas/VerificationMethod'
default:
$ref: '../common/error_response.yaml'
/internal/vdr/v2/did/{did}/verificationmethod/{id}:
parameters:
- name: did
in: path
description: URL encoded DID.
required: true
example: did:web:example.com:iam:013c6fda-73e8-45ee-9220-48652dba854b
schema:
type: string
- name: id
in: path
description: URL encoded ID identifying the verification method.
required: true
example: "did:web:example.com:iam:013c6fda-73e8-45ee-9220-48652dba854b#3106f751-59e3-440f-b57b-39a96a2da6c6"
schema:
type: string
delete:
summary: Delete a specific verification method
description: |
Removes the verification method from the DID Document.
error returns:
* 404 - Corresponding DID document or verification method could not be found
* 500 - An error occurred while processing the request
tags:
- DID
operationId: deleteVerificationMethod
responses:
"204":
description: Verification Method was successfully deleted
default:
$ref: '../common/error_response.yaml'
components:
schemas:
CreateDIDOptions:
type: object
properties:
id:
type: string
description: The ID of the DID document. If not given, a random UUID is generated.
example: "did:web:example.com:iam:013c6fda-73e8-45ee-9220-48652dba854b"
DIDDocument:
$ref: '../common/ssi_types.yaml#/components/schemas/DIDDocument'
DIDDocumentMetadata:
$ref: '../common/ssi_types.yaml#/components/schemas/DIDDocumentMetadata'
VerificationMethod:
$ref: '../common/ssi_types.yaml#/components/schemas/VerificationMethod'
Service:
$ref: '../common/ssi_types.yaml#/components/schemas/Service'
DIDResolutionResult:
required:
- document
- documentMetadata
properties:
document:
$ref: '#/components/schemas/DIDDocument'
documentMetadata:
$ref: '#/components/schemas/DIDDocumentMetadata'
securitySchemes:
jwtBearerAuth:
type: http
scheme: bearer

security:
- {}
- jwtBearerAuth: []
1 change: 1 addition & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ gen-api:
oapi-codegen --config codegen/configs/common_ssi_types.yaml docs/_static/common/ssi_types.yaml | gofmt > api/ssi_types.go
oapi-codegen --config codegen/configs/crypto_v1.yaml -package v1 docs/_static/crypto/v1.yaml | gofmt > crypto/api/v1/generated.go
oapi-codegen --config codegen/configs/vdr_v1.yaml docs/_static/vdr/v1.yaml | gofmt > vdr/api/v1/generated.go
oapi-codegen --config codegen/configs/vdr_v2.yaml docs/_static/vdr/v2.yaml | gofmt > vdr/api/v2/generated.go
oapi-codegen --config codegen/configs/network_v1.yaml docs/_static/network/v1.yaml | gofmt > network/api/v1/generated.go
oapi-codegen --config codegen/configs/vcr_v2.yaml docs/_static/vcr/vcr_v2.yaml | gofmt > vcr/api/vcr/v2/generated.go
oapi-codegen --config codegen/configs/vcr_openid4vci_v0.yaml docs/_static/vcr/openid4vci_v0.yaml | gofmt > vcr/api/openid4vci/v0/generated.go
Expand Down
4 changes: 3 additions & 1 deletion vdr/api/v1/types.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
/*
* Nuts node
* Copyright (C) 2021 Nuts community
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Expand Down
Loading

0 comments on commit a33a934

Please sign in to comment.