mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-01 09:51:39 -05:00
Separate generate swagger + fix sed os specific (#1791)
* Separate generate-swagger * Remove go generate rules * Add missing definition replacement + remove use of -i sed flag for compatibility with mac os default sed version. This is a little hacky a better solution could be use. * Use custom SED_INPLACE depending of platform detection * Use SED_INPLACE for swagger-ui also
This commit is contained in:
parent
01322af2e8
commit
2bcd9471c9
2 changed files with 22 additions and 7 deletions
23
Makefile
23
Makefile
|
@ -1,5 +1,18 @@
|
||||||
DIST := dist
|
DIST := dist
|
||||||
IMPORT := code.gitea.io/gitea
|
IMPORT := code.gitea.io/gitea
|
||||||
|
|
||||||
|
SED_INPLACE := sed -i
|
||||||
|
|
||||||
|
ifeq ($(OS), Windows_NT)
|
||||||
|
EXECUTABLE := gitea.exe
|
||||||
|
else
|
||||||
|
EXECUTABLE := gitea
|
||||||
|
UNAME_S := $(shell uname -s)
|
||||||
|
ifeq ($(UNAME_S),Darwin)
|
||||||
|
SED_INPLACE := sed -i ''
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
BINDATA := modules/{options,public,templates}/bindata.go
|
BINDATA := modules/{options,public,templates}/bindata.go
|
||||||
STYLESHEETS := $(wildcard public/less/index.less public/less/_*.less)
|
STYLESHEETS := $(wildcard public/less/index.less public/less/_*.less)
|
||||||
JAVASCRIPTS :=
|
JAVASCRIPTS :=
|
||||||
|
@ -59,10 +72,16 @@ generate:
|
||||||
@hash go-bindata > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
@hash go-bindata > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||||||
go get -u github.com/jteeuwen/go-bindata/...; \
|
go get -u github.com/jteeuwen/go-bindata/...; \
|
||||||
fi
|
fi
|
||||||
|
go generate $(PACKAGES)
|
||||||
|
|
||||||
|
.PHONY: generate-swagger
|
||||||
|
generate-swagger:
|
||||||
@hash swagger > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
@hash swagger > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||||||
go get -u github.com/go-swagger/go-swagger/cmd/swagger; \
|
go get -u github.com/go-swagger/go-swagger/cmd/swagger; \
|
||||||
fi
|
fi
|
||||||
go generate $(PACKAGES)
|
swagger generate spec -o ./public/swagger.v1.json
|
||||||
|
$(SED_INPLACE) "s;\".ref\": \"#/definitions/GPGKey\";\"type\": \"object\";g" ./public/swagger.v1.json
|
||||||
|
$(SED_INPLACE) "s;^ \".ref\": \"#/definitions/Repository\"; \"type\": \"object\";g" ./public/swagger.v1.json
|
||||||
|
|
||||||
.PHONY: errcheck
|
.PHONY: errcheck
|
||||||
errcheck:
|
errcheck:
|
||||||
|
@ -241,7 +260,7 @@ swagger-ui:
|
||||||
git clone --depth=10 -b v3.0.7 --single-branch https://github.com/swagger-api/swagger-ui.git /tmp/swagger-ui
|
git clone --depth=10 -b v3.0.7 --single-branch https://github.com/swagger-api/swagger-ui.git /tmp/swagger-ui
|
||||||
mv /tmp/swagger-ui/dist public/assets/swagger-ui
|
mv /tmp/swagger-ui/dist public/assets/swagger-ui
|
||||||
rm -Rf /tmp/swagger-ui
|
rm -Rf /tmp/swagger-ui
|
||||||
sed -i "s;http://petstore.swagger.io/v2/swagger.json;../../swagger.v1.json;g" public/assets/swagger-ui/index.html
|
$(SED_INPLACE) "s;http://petstore.swagger.io/v2/swagger.json;../../swagger.v1.json;g" public/assets/swagger-ui/index.html
|
||||||
|
|
||||||
.PHONY: assets
|
.PHONY: assets
|
||||||
assets: javascripts stylesheets
|
assets: javascripts stylesheets
|
||||||
|
|
|
@ -2,10 +2,6 @@
|
||||||
// Use of this source code is governed by a MIT-style
|
// Use of this source code is governed by a MIT-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:generate swagger generate spec -o ../../../public/swagger.v1.json
|
|
||||||
//go:generate sed -i "s;\".ref\": \"#/definitions/GPGKey\";\"type\": \"object\";g" ../../../public/swagger.v1.json
|
|
||||||
//go:generate sed -i "s;^ \".ref\": \"#/definitions/Repository\"; \"type\": \"object\";g" ../../../public/swagger.v1.json
|
|
||||||
|
|
||||||
// Package v1 Gitea API.
|
// Package v1 Gitea API.
|
||||||
//
|
//
|
||||||
// This provide API interface to communicate with this Gitea instance.
|
// This provide API interface to communicate with this Gitea instance.
|
||||||
|
|
Loading…
Reference in a new issue