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

Commit

Permalink
Add openAPI (#47)
Browse files Browse the repository at this point in the history
* add: openAPI doc

* fix: magefile

* add: annotation

* add: annotation

* rm

* generate spec yaml by swaggo

* run mod tidy

* fix: review

* update to latest ssi sdk; install swag if not present

Co-authored-by: Gabe Cohen <[email protected]>
  • Loading branch information
atsushii and Gabe Cohen authored Jul 6, 2022
1 parent af71401 commit bf83a59
Show file tree
Hide file tree
Showing 13 changed files with 952 additions and 647 deletions.
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"]
20 changes: 15 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,15 @@ func init() {
logrus.SetOutput(os.Stdout)
}

// @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
Loading

0 comments on commit bf83a59

Please sign in to comment.