@@ -42,6 +42,10 @@ TAGS ?=
42
42
43
43
TMPDIR := $(shell mktemp -d 2>/dev/null || mktemp -d -t 'gitea-temp')
44
44
45
+ SWAGGER_SPEC := templates/swagger/v1_json.tmpl
46
+ SWAGGER_SPEC_S_TMPL := s|"basePath":\s*"/api/v1"|"basePath": "{{AppSubUrl}}/api/v1"|g
47
+ SWAGGER_SPEC_S_JSON := s|"basePath":\s*"{{AppSubUrl}}/api/v1"|"basePath": "/api/v1"|g
48
+
45
49
TEST_MYSQL_HOST ?= mysql:3306
46
50
TEST_MYSQL_DBNAME ?= testgitea
47
51
TEST_MYSQL_USERNAME ?= root
@@ -94,11 +98,12 @@ generate-swagger:
94
98
@hash swagger > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
95
99
$(GO ) get -u github.com/go-swagger/go-swagger/cmd/swagger; \
96
100
fi
97
- swagger generate spec -o ./public/swagger.v1.json
101
+ swagger generate spec -o ' ./$(SWAGGER_SPEC)'
102
+ $(SED_INPLACE ) ' $(SWAGGER_SPEC_S_TMPL)' ' ./$(SWAGGER_SPEC)'
98
103
99
104
.PHONY : swagger-check
100
105
swagger-check : generate-swagger
101
- @diff=$$(git diff public/swagger.v1.json ) ; \
106
+ @diff=$$(git diff ' $( SWAGGER_SPEC ) ' ) ; \
102
107
if [ -n " $$ diff" ]; then \
103
108
echo " Please run 'make generate-swagger' and commit the result:" ; \
104
109
echo " $$ {diff}" ; \
@@ -110,7 +115,9 @@ swagger-validate:
110
115
@hash swagger > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
111
116
$(GO ) get -u github.com/go-swagger/go-swagger/cmd/swagger; \
112
117
fi
113
- swagger validate ./public/swagger.v1.json
118
+ $(SED_INPLACE ) ' $(SWAGGER_SPEC_S_JSON)' ' ./$(SWAGGER_SPEC)'
119
+ swagger validate ' ./$(SWAGGER_SPEC)'
120
+ $(SED_INPLACE ) ' $(SWAGGER_SPEC_S_TMPL)' ' ./$(SWAGGER_SPEC)'
114
121
115
122
.PHONY : errcheck
116
123
errcheck :
0 commit comments