Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Add openAPI #47

Merged
merged 14 commits into from
Jul 6, 2022
14 changes: 14 additions & 0 deletions build/Dockerfile-swagger
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM golang:1.17-alpine AS build

WORKDIR /app

ENV SWAGGER_VERSION=v0.29.0
ENV REPO="github.com/go-swagger/go-swagger/cmd/swagger"

COPY go.mod ./
COPY go.sum ./
RUN go mod download

RUN go get -u "${REPO}@${SWAGGER_VERSION}"

ENTRYPOINT ["swagger"]
11 changes: 10 additions & 1 deletion build/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,13 @@ services:
context: ../
dockerfile: build/Dockerfile
ports:
- "8080:3000"
- "8080:3000"
swagger-ui:
build:
context: ../
dockerfile: build/Dockerfile-swagger
ports:
- "8002:8080"
volumes:
- ../docs/swagger.yaml:/app/swagger.yaml
command: ["serve", "/app/swagger.yaml", "--no-open", "--port", "8080"]
24 changes: 19 additions & 5 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ package main
import (
"context"
"expvar"
"github.com/ardanlabs/conf"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/tbd54566975/ssi-service/config"
"github.com/tbd54566975/ssi-service/pkg/server"
"net/http"
"os"
"os/signal"
"syscall"
"time"

"github.com/ardanlabs/conf"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/tbd54566975/ssi-service/config"
"github.com/tbd54566975/ssi-service/pkg/server"
)

const (
Expand All @@ -28,6 +29,19 @@ func init() {
logrus.SetOutput(os.Stdout)
}

// @title Swagger Example API
// @version 1.0
// @description This is a sample server celler server.
// @termsOfService http://swagger.io/terms/

// @contact.name API Support
// @contact.url http://www.swagger.io/support
// @contact.email [email protected]

// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html

// @host localhost:8080
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// @title Swagger Example API
// @version 1.0
// @description This is a sample server celler server.
// @termsOfService http://swagger.io/terms/
// @contact.name API Support
// @contact.url http://www.swagger.io/support
// @contact.email [email protected]
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @host localhost:8080
// @title SSI Service API
// @version 0.1
// @description https://github.com/TBD54566975/ssi-service
// @contact.name TBD
// @contact.url https://github.com/TBD54566975/ssi-service/issues
// @contact.email [email protected]
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @host localhost:8080

func main() {
logrus.Info("Starting up...")

Expand Down
2 changes: 2 additions & 0 deletions docs/.swaggo
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// TODO: read cryptosuite.LDKeyType from sdk properly
skip github.com/TBD54566975/ssi-sdk/did.VerificationMethod
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be solved before merge, what error did you run into?

Copy link
Contributor Author

@atsushii atsushii Jul 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@decentralgabe
ParseComment error in file {path to did.go} :cannot find type definition: cryptosuite.LDKeyType
the above error occurred when I ran swag init cmd.

Seems cannot read LDKeyType which define inside ssi-sdk

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably need to fix the type definition in ssi-sdk..
What do you think?

@decentralgabe

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me take a look. do you mind if I push to the branch if I find a solution?

Loading