-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
54 lines (44 loc) · 1.97 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#Copyright 2021, Staffbase GmbH and contributors.
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#
#You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.
.PHONY: download generate build help
SWAGGER_SPEC=swagger.json
SWAGGER_URL=https://api-docs.bitrise.io/docs/swagger.json
help: ## Show this help.
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
all: download generate build ## Validate the swagger spec, generate the code and build it.
build: ## Build the API Go client.
go build ./go/...
download: ## Download bitrise swagger specification
wget -q -O $(SWAGGER_SPEC) $(SWAGGER_URL)
clean:
rm -rf go/*
generate: clean ## Generate the API Go client and the JSON document for the UI.
go run github.com/go-swagger/go-swagger/cmd/[email protected] generate client \
--name bitrise-api \
--spec $(SWAGGER_SPEC) \
--target go \
--default-scheme=https \
--with-flatten=minimal \
--skip-tag-packages
validate: ## Check that the swagger spec is valid.
go run github.com/go-swagger/go-swagger/cmd/[email protected] validate $(SWAGGER_SPEC)
test: ## Generate with openapitools/openapi-generator-cli
docker run --rm -v $(shell pwd):/local openapitools/openapi-generator-cli generate \
-i /local/swagger.json \
-g go \
-o /local/go2 \
--git-user-id=staffbase \
--git-repo-id=bitrise-api
test2:
go run github.com/deepmap/oapi-codegen/cmd/oapi-codegen@latest -package=examplepkg -generate=types,client,spec -o=go3/example-client.go ./openapi.yaml