Merged in jb/openapi (pull request #22)

add openapi infra

* add openapi infra

Includes generated stubs and all deps

* generatetolocation

* basesetupoffunctionsandclient

* round1controllertests

* passintegrationtests

* cleanupfromfullsuite

* storedjson

* fixjsonyaml

* fixtests


Approved-by: Michael McGuinness
This commit is contained in:
Jay Brown
2025-01-15 19:45:51 +00:00
committed by Michael McGuinness
parent 5ca36b0502
commit 174644b63c
443 changed files with 78766 additions and 2119 deletions
+15 -14
View File
@@ -17,9 +17,9 @@ includes:
docker:
dir: "{{.CONTEXT}}"
taskfile: docker.yml
proto:
openapi:
dir: "{{.CONTEXT}}"
taskfile: proto.yml
taskfile: openapi.yml
compose:
dir: "{{.CONTEXT}}"
taskfile: compose.yml
@@ -32,39 +32,40 @@ tasks:
cmds:
- touch .env
fullsuite:
deps:
- lint
- test:unit:coverage
- test:integration
cmds:
- task lint
- task test:unit:coverage
- task test:integration
generate:
deps:
- db:generate
- proto:generate
- openapi:generate
lint:
cmds:
- task code:lint
- task go:lint
- task db:lint
- task yaml:lint
- task json:lint
- task docker:lint
- task compose:lint
- task proto:lint
- task openapi:lint
lint:fix:
cmds:
- task code:lint:fix
- task proto:lint:fix
- task go:lint:fix
- task openapi:lint:fix
- task db:lint
- task yaml:lint
- task json:lint:fix
- task docker:lint
- task compose:lint
code:lint:
go:lint:
cmds:
- golangci-lint run
code:lint:fix:
go:lint:fix:
deps:
- go:lint
cmds:
- gofmt -w .
- golangci-lint run
yaml:lint:
cmds:
- yamllint . -s
+52
View File
@@ -0,0 +1,52 @@
---
# https://taskfile.dev
version: '3'
tasks:
lint:
cmds:
- echo "OpenAPI lint"
lint:fix:
cmds:
- echo "OpenAPI lint:fix"
generate:
deps:
- generate:server
- generate:client
generate:client:
cmds:
- |
for file in serviceAPIs/*.yml serviceAPIs/*.yaml; do
if [[ -f "$file" ]]; then
service=$(basename "$file")
service=${service%.*}
service_lower=${service,,}
outputloc=./pkg/$service
mkdir -p $outputloc
oapi-codegen \
-generate "models,client" \
-config .openapi.yml \
-package $service_lower \
-o $outputloc/api.gen.go \
$file
fi
done
generate:server:
cmds:
- |
for file in serviceAPIs/*.yml serviceAPIs/*.yaml; do
if [[ -f "$file" ]]; then
service=$(basename "$file")
service=${service%.*}
service_lower=${service,,}
outputloc=./api/$service
mkdir -p $outputloc
oapi-codegen \
-generate "models,embedded-spec,echo-server" \
-config .openapi.yml \
-package $service_lower \
-o $outputloc/api.gen.go \
$file
fi
done
-23
View File
@@ -1,23 +0,0 @@
---
# https://taskfile.dev
version: '3'
vars:
PROTO_DIR: serviceInterfaces
API_DIR: api
tasks:
lint:
cmds:
- protolint lint {{.PROTO_DIR}}
lint:fix:
cmds:
- protolint lint -fix {{.PROTO_DIR}}
generate:
cmds:
- |
protoc --proto_path={{.PROTO_DIR}} \
--go_out={{.API_DIR}}/serviceInterfaces --go-grpc_out={{.API_DIR}} \
--go_opt=paths=source_relative --experimental_allow_proto3_optional \
main.proto
+7 -3
View File
@@ -14,18 +14,22 @@ tasks:
vars:
INTERNAL: "./internal/..."
API: "./api/..."
PKG: "./pkg/..."
cmds:
- mkdir -p {{.OUT_DIR}}
- |
go test {{.INTERNAL}} {{.API}} \
-coverpkg={{.INTERNAL}},{{.API}} -coverprofile={{.COVERAGE_FILE}}
go test {{.INTERNAL}} {{.API}} {{.PKG}} \
-coverpkg={{.INTERNAL}},{{.API}},{{.PKG}} \
-coverprofile={{.COVERAGE_FILE}}
unit:coverage:
deps:
- unit
vars:
TMP_FILE: "{{.OUT_DIR}}/coverage.tmp"
FILTER_COVERAGE_FILE: "{{.OUT_DIR}}/filtered_coverage.out"
cmds:
- go tool cover -func={{.COVERAGE_FILE}} > {{.TMP_FILE}}
- grep -v ".gen.go" {{.COVERAGE_FILE}} > {{.FILTER_COVERAGE_FILE}}
- go tool cover -func={{.FILTER_COVERAGE_FILE}} > {{.TMP_FILE}}
- cat {{.TMP_FILE}}
- |
COVERAGE=$(grep total: {{.TMP_FILE}} \