Skip to content

Commit 4eff444

Browse files
committed
build: add spec-patch target to restore OpenAPI fields lost on swag regen
swag init strips the global security declaration, per-operation security overrides on /healthz and /readyz, and additionalProperties on the free-form WorkflowDetailResponse.definition field. Add a spec-patch Make target that re-applies these patches via jq/yq, and wire it to run automatically after every `make spec` invocation. Addresses CodeRabbit's suggestion from PR #129 review. https://claude.ai/code/session_011ueT4NU9ZysZWE19Zi4Ukn
1 parent 47addb4 commit 4eff444

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

packages/engine/Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LDFLAGS := -X github.com/dvflw/mantle/internal/version.Version=$(VERSION) \
55
-X github.com/dvflw/mantle/internal/version.Commit=$(COMMIT) \
66
-X github.com/dvflw/mantle/internal/version.Date=$(DATE)
77

8-
.PHONY: build test lint clean migrate run dev spec
8+
.PHONY: build test lint clean migrate run dev spec spec-patch
99

1010
build:
1111
go build -ldflags "$(LDFLAGS)" -o mantle ./cmd/mantle
@@ -35,3 +35,15 @@ spec: ## Regenerate OpenAPI spec (requires: go install github.com/swaggo/swag/cm
3535
--output internal/server/docs \
3636
--outputTypes json,yaml \
3737
--parseInternal
38+
$(MAKE) spec-patch
39+
40+
spec-patch: ## Re-apply manual OpenAPI patches lost on swag regeneration
41+
@# swag init does not emit global security declarations, per-operation security
42+
@# overrides, or additionalProperties on free-form objects. Patch them back after
43+
@# every regeneration run. Requires jq and yq (pip install yq).
44+
jq '.security=[{"ApiKeyAuth":[]},{"OIDCAuth":[]}]|.paths["/healthz"].get.security=[]|.paths["/readyz"].get.security=[]|.definitions["server.WorkflowDetailResponse"].properties.definition.additionalProperties=true' \
45+
internal/server/docs/swagger.json > internal/server/docs/swagger.json.tmp && \
46+
mv internal/server/docs/swagger.json.tmp internal/server/docs/swagger.json
47+
yq -y '.security=[{"ApiKeyAuth":[]},{"OIDCAuth":[]}]|.paths["/healthz"].get.security=[]|.paths["/readyz"].get.security=[]|.definitions["server.WorkflowDetailResponse"].properties.definition.additionalProperties=true' \
48+
internal/server/docs/swagger.yaml > internal/server/docs/swagger.yaml.tmp && \
49+
mv internal/server/docs/swagger.yaml.tmp internal/server/docs/swagger.yaml

0 commit comments

Comments
 (0)