-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(api): add swagger specification generation (#891)
- Loading branch information
Showing
35 changed files
with
1,000 additions
and
142 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 |
---|---|---|
|
@@ -3,9 +3,12 @@ FROM golang:1.18 as builder | |
COPY go.mod go.sum /go/src/github.com/moira-alert/moira/ | ||
WORKDIR /go/src/github.com/moira-alert/moira | ||
RUN go mod download | ||
RUN go install github.com/swaggo/swag/cmd/[email protected] | ||
|
||
COPY . /go/src/github.com/moira-alert/moira/ | ||
|
||
RUN /go/bin/swag init -g api/handler/handler.go | ||
|
||
ARG GO_VERSION="GoVersion" | ||
ARG GIT_COMMIT="git_Commit" | ||
ARG MoiraVersion="MoiraVersion" | ||
|
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 |
---|---|---|
|
@@ -39,6 +39,20 @@ lint: | |
mock: | ||
. ./generate_mocks.sh | ||
|
||
.PHONY: install-swag | ||
install-swag: | ||
go install github.com/swaggo/swag/cmd/[email protected] | ||
|
||
.PHONY: spec | ||
spec: | ||
echo "Generating Swagger documentation" | ||
swag init -g api/handler/handler.go | ||
swag fmt | ||
|
||
.PHONY: validate-spec | ||
validate-spec: | ||
openapi-generator-cli validate -i docs/swagger.yaml | ||
|
||
.PHONY: test | ||
test: | ||
echo 'mode: atomic' > coverage.txt && go list ./... | xargs -n1 -I{} sh -c 'go test -race -v -bench=. -covermode=atomic -coverprofile=coverage.tmp {} && tail -n +2 coverage.tmp >> coverage.txt' && rm coverage.tmp | ||
|
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 |
---|---|---|
|
@@ -17,10 +17,10 @@ func (*ContactList) Render(w http.ResponseWriter, r *http.Request) error { | |
} | ||
|
||
type Contact struct { | ||
Type string `json:"type"` | ||
Value string `json:"value"` | ||
ID string `json:"id,omitempty"` | ||
User string `json:"user,omitempty"` | ||
Type string `json:"type" example:"mail"` | ||
Value string `json:"value" example:"[email protected]"` | ||
ID string `json:"id,omitempty" example:"1dd38765-c5be-418d-81fa-7a5f879c2315"` | ||
User string `json:"user,omitempty" example:""` | ||
TeamID string `json:"team_id,omitempty"` | ||
} | ||
|
||
|
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
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
Oops, something went wrong.