updated make to allow me to convert swagger into a api client with some tools

This commit is contained in:
James Tombleson 2024-07-17 22:02:38 -07:00
parent fa1e762f51
commit 3cf6afb39c
4 changed files with 3772 additions and 3 deletions

2
.gitignore vendored
View File

@ -3,6 +3,7 @@ dev.session.sql
__debug_bin
server
.vscode
openapi.json
# Binaries for programs and plugins
*.exe
@ -12,6 +13,7 @@ server
*.dylib
collector
newsbot.db
tmp/
# Test binary, built with `go test -c`
*.test

3756
api/api.gen.go Normal file

File diff suppressed because it is too large Load Diff

6
api/client.yaml Normal file
View File

@ -0,0 +1,6 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/deepmap/oapi-codegen/HEAD/configuration-schema.json
package: api
output: api.gen.go
generate:
models: true
client: true

View File

@ -19,8 +19,13 @@ migrate-dev-down: ## revert sql migrations to dev db
goose -dir "./internal/database/migrations" sqlite3 ./cmd/newsbot.db down
swag: ## Generates the swagger documentation with the swag tool
~/go/bin/swag f
~/go/bin/swag f -g cmd/server.go
~/go/bin/swag init -g cmd/server.go
go run tools/swaggertoopenapi/main.go
oapi-codegen -config api/client.yaml docs/openapi.json
mv api.gen.go api/
gensql: ## Generates SQL code with sqlc
sqlc generate
install-tools: ## Installs the required tools for this project
go install github.com/swaggo/swag/cmd/swag@v1.8.1
go install github.com/pressly/goose/v3/cmd/goose@latest
go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@v2.3.0