summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorPiotr Orzechowski <piotr@orzechowski.tech>2018-07-28 02:19:01 +0200
committerLauris BH <lauris@nix.lv>2018-07-28 03:19:01 +0300
commita74426d631e3311cc3c460ae9917f76f0221f4de (patch)
tree1343766d999308825f42bc0b67c1845a5e9e9546 /Makefile
parent412583a3f28162c89e827fbb586319ac8eea9825 (diff)
downloadgitea-a74426d631e3311cc3c460ae9917f76f0221f4de.tar.gz
gitea-a74426d631e3311cc3c460ae9917f76f0221f4de.zip
Swagger.v1.json template (#3572)
* Turn swagger.v1.json into template * Rename ENABLE_SWAGGER_ENDPOINT option to ENABLE_SWAGGER
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile13
1 files changed, 10 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 256e872adc..4eb5873e42 100644
--- a/Makefile
+++ b/Makefile
@@ -42,6 +42,10 @@ TAGS ?=
TMPDIR := $(shell mktemp -d 2>/dev/null || mktemp -d -t 'gitea-temp')
+SWAGGER_SPEC := templates/swagger/v1_json.tmpl
+SWAGGER_SPEC_S_TMPL := s|"basePath":\s*"/api/v1"|"basePath": "{{AppSubUrl}}/api/v1"|g
+SWAGGER_SPEC_S_JSON := s|"basePath":\s*"{{AppSubUrl}}/api/v1"|"basePath": "/api/v1"|g
+
TEST_MYSQL_HOST ?= mysql:3306
TEST_MYSQL_DBNAME ?= testgitea
TEST_MYSQL_USERNAME ?= root
@@ -94,11 +98,12 @@ generate-swagger:
@hash swagger > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
$(GO) get -u github.com/go-swagger/go-swagger/cmd/swagger; \
fi
- swagger generate spec -o ./public/swagger.v1.json
+ swagger generate spec -o './$(SWAGGER_SPEC)'
+ $(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)'
.PHONY: swagger-check
swagger-check: generate-swagger
- @diff=$$(git diff public/swagger.v1.json); \
+ @diff=$$(git diff '$(SWAGGER_SPEC)'); \
if [ -n "$$diff" ]; then \
echo "Please run 'make generate-swagger' and commit the result:"; \
echo "$${diff}"; \
@@ -110,7 +115,9 @@ swagger-validate:
@hash swagger > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
$(GO) get -u github.com/go-swagger/go-swagger/cmd/swagger; \
fi
- swagger validate ./public/swagger.v1.json
+ $(SED_INPLACE) '$(SWAGGER_SPEC_S_JSON)' './$(SWAGGER_SPEC)'
+ swagger validate './$(SWAGGER_SPEC)'
+ $(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)'
.PHONY: errcheck
errcheck: