@@ -42,6 +42,10 @@ TAGS ?=
4242
4343TMPDIR := $(shell mktemp -d 2>/dev/null || mktemp -d -t 'gitea-temp')
4444
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+
4549TEST_MYSQL_HOST ?= mysql:3306
4650TEST_MYSQL_DBNAME ?= testgitea
4751TEST_MYSQL_USERNAME ?= root
@@ -94,11 +98,12 @@ generate-swagger:
9498 @hash swagger > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
9599 $(GO ) get -u github.com/go-swagger/go-swagger/cmd/swagger; \
96100 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)'
98103
99104.PHONY : swagger-check
100105swagger-check : generate-swagger
101- @diff=$$(git diff public/swagger.v1.json ) ; \
106+ @diff=$$(git diff ' $( SWAGGER_SPEC ) ' ) ; \
102107 if [ -n " $$ diff" ]; then \
103108 echo " Please run 'make generate-swagger' and commit the result:" ; \
104109 echo " $$ {diff}" ; \
@@ -110,7 +115,9 @@ swagger-validate:
110115 @hash swagger > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
111116 $(GO ) get -u github.com/go-swagger/go-swagger/cmd/swagger; \
112117 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)'
114121
115122.PHONY : errcheck
116123errcheck :
0 commit comments