-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Generate OpenAPI spec for the REST API
The OpenAPI spec is generated from the Sidetree model using swagger annotations. closes #57 Signed-off-by: Bob Stasyszyn <[email protected]>
- Loading branch information
1 parent
a14a3c6
commit 97a31da
Showing
12 changed files
with
175 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,5 @@ | |
# OS generated files | ||
.DS_Store | ||
|
||
coverage.txt | ||
coverage.txt | ||
.build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
// Package diddochandler DID document API. | ||
// | ||
// | ||
// Terms Of Service: | ||
// | ||
// Schemes: http, https | ||
// Host: 127.0.0.1:8080 | ||
// Version: 0.1.0 | ||
// License: SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Consumes: | ||
// - application/json | ||
// | ||
// Produces: | ||
// - application/json | ||
// | ||
// swagger:meta | ||
package diddochandler | ||
|
||
import ( | ||
"github.com/trustbloc/sidetree-core-go/pkg/restapi/model" | ||
) | ||
|
||
// swagger:route POST /document create-did-document request | ||
// Creates/updates a DID document. | ||
// Responses: | ||
// default: error | ||
// 200: response | ||
|
||
// Resolve swagger:route GET /document/{id} resolve-did-document resolveDocParams | ||
// Resolves a DID document by ID or validates the DID document if provided. | ||
// Responses: | ||
// default: error | ||
// 200: response | ||
|
||
// Contains the DID document. | ||
//swagger:response response | ||
//nolint:deadcode,unused | ||
type responseWrapper struct { | ||
// The body of the response. | ||
// | ||
// required: true | ||
// in: body | ||
Body model.Response | ||
} | ||
|
||
// Contains the request. | ||
//swagger:parameters request | ||
//nolint:deadcode,unused | ||
type requestWrapper struct { | ||
// The body of the request. | ||
// | ||
// required: true | ||
// in: body | ||
Body model.Request | ||
} | ||
|
||
// resolveDocumentParams model | ||
// This is used for getting specific DID document | ||
// | ||
//swagger:parameters resolveDocParams | ||
//nolint:deadcode,unused | ||
type resolveDocumentParams struct { | ||
// The ID of the DID document or the DID document to be validated. | ||
// | ||
// in: path | ||
// required: true | ||
ID string `json:"id"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
set -e | ||
|
||
CODEBASE="$(dirname "$PWD")" | ||
SPEC_LOC="${SPEC_LOC}" | ||
SPEC_META="${SPEC_META:-pkg/restapi/diddochandler/doc.go}" | ||
OUTPUT="$SPEC_LOC/openAPI.yml" | ||
IMAGE="${DOCKER_IMAGE:-quay.io/goswagger/swagger}" | ||
IMAGE_VERSION="${DOCKER_IMAGE_VERSION:-latest}" | ||
|
||
# generate and validate commands | ||
GENERATE_COMMAND="generate spec $SPEC_META -o $OUTPUT" | ||
VALIDATE_COMMAND="validate $OUTPUT" | ||
|
||
echo "Generating Open API spec" | ||
docker run --rm -e GOPATH=$HOME/go:/go -v $HOME:$HOME -w $(pwd) ${IMAGE}:${IMAGE_VERSION} $GENERATE_COMMAND | ||
|
||
echo "Validating generated spec" | ||
docker run --rm -e GOPATH=$HOME/go:/go -v $HOME:$HOME -w $(pwd) ${IMAGE}:${IMAGE_VERSION} $VALIDATE_COMMAND |