Skip to content

Commit

Permalink
Add swagger definitions to the API (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
dramich authored Oct 3, 2023
1 parent 928ef3f commit bcc95f3
Show file tree
Hide file tree
Showing 11 changed files with 986 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ generate:
./scripts/graphql-gen.sh
cd ${API_DIR} && go generate

.PHONY:
swagger-gen:
swag fmt -g cmd/server.go
swag init -g cmd/server.go --pd --ot go,yaml

.PHONY: test
test:
go test ./... -cover
Expand Down
12 changes: 11 additions & 1 deletion cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"syscall"
"time"

_ "github.com/massdriver-cloud/mass/docs" // Init swagger docs
"github.com/massdriver-cloud/mass/pkg/server"
"github.com/spf13/cobra"
)
Expand All @@ -29,13 +30,22 @@ func NewCmdServer() *cobra.Command {
Args: cobra.NoArgs,
}

cmd.Flags().StringP("port", "p", "", "port for the server to listen on")
cmd.Flags().StringP("port", "p", "8080", "port for the server to listen on")
cmd.Flags().StringP("directory", "d", "", "directory for the massdriver bundle, will default to the directory the server is ran from")
cmd.Flags().String("log-level", "info", "Set the log level for the server. Options are [debug, info, warn, error]")

return cmd
}

// @title Massdriver API
// @description Massdriver Bundle Development Server API
// @contact.url https://github.com/massdriver-cloud/mass
// @contact.name Massdriver
// @license.name Apache 2.0
// @license.url https://github.com/massdriver-cloud/mass/blob/main/LICENSE
// @host 127.0.0.1:8080
// @externalDocs.description OpenAPI
// @externalDocs.url https://swagger.io/resources/open-api/
func runServer(cmd *cobra.Command) {
logLevel, err := cmd.Flags().GetString("log-level")
if err != nil {
Expand Down
Loading

0 comments on commit bcc95f3

Please sign in to comment.