@@ -19,7 +19,7 @@ LDFLAGS=-ldflags="-s -w"
1919# Directories
2020FRONTEND_DIR =frontend
2121
22- .PHONY : all build build-linux build-windows build-windows-arm64 clean deps frontend help hooks lint dev-build release openapi openapi-check openapi-v2-check coding-agent-image dev-tools install-golangci-lint install-govulncheck install-deadcode ci-tools-check ci-go ci-frontend ci
22+ .PHONY : all build build-linux build-windows build-windows-arm64 clean deps frontend help hooks lint dev-build release openapi openapi-v2 openapi- check openapi-v2-check openapi-v2-client-smoke coding-agent-image dev-tools install-golangci-lint install-govulncheck install-deadcode ci-tools-check ci-go ci-frontend ci
2323
2424# Tooling. swag is a tool dependency tracked in go.mod (see `tool` directive),
2525# so the version is pinned and CI / dev installs always agree. `go tool swag`
@@ -29,6 +29,8 @@ OPENAPI_DIR = api
2929GOLANGCI_LINT_VERSION := 2.13.1
3030GOVULNCHECK_VERSION := 1.3.0
3131DEADCODE_VERSION := 0.45.0
32+ OAPI_CODEGEN_VERSION := 2.5.0
33+ OAPI_RUNTIME_VERSION := 1.1.1
3234NODE_VERSION := 24.18.0
3335NPM_VERSION := 11.16.0
3436
@@ -125,26 +127,30 @@ ci: ci-go ci-frontend
125127
126128# Regenerate the OpenAPI v1 spec from handler annotations.
127129# Pipeline: swag emits Swagger 2.0 (JSON) -> openapi-convert produces
128- # OpenAPI 3.0 yaml/json -> intermediate Swagger 2.0 file is removed.
129- # Only api/openapi.{yaml, json} is committed.
130+ # OpenAPI 3.0 JSON -> intermediate Swagger 2.0 file is removed.
131+ # Only api/openapi.json is committed.
130132openapi :
131133 @echo " Regenerating OpenAPI spec..."
132134 @$(SWAG ) init -g internal/restapi/v1/doc.go -d ./,internal/restapi --parseInternal -o $(OPENAPI_DIR ) --outputTypes json -q
133135 @go run ./scripts/openapi-convert -in $(OPENAPI_DIR ) /swagger.json \
134- -out-yaml $(OPENAPI_DIR ) /openapi.yaml \
135136 -out-json $(OPENAPI_DIR ) /openapi.json
136137 @rm -f $(OPENAPI_DIR ) /swagger.json
137- @echo " Spec written to $( OPENAPI_DIR) /openapi.{yaml,json}"
138+ @echo " Spec written to $( OPENAPI_DIR) /openapi.json"
139+
140+ # Regenerate the public v2 schemas and shared responses from canonical route
141+ # request, response, media-type, envelope, and success-status metadata.
142+ openapi-v2 :
143+ @go run ./scripts/openapi-v2-generate -spec $(OPENAPI_DIR ) /openapi-v2.json
138144
139145# Verify that handler annotations parse cleanly under swag and the generated
140146# spec is valid OpenAPI 3.0. Does NOT compare against the committed
141- # api/openapi.{ json,yaml} — that byte-equality check was a continuous source
147+ # api/openapi.json — that byte-equality check was a continuous source
142148# of host-environment-dependent CI noise (swag's output differed between CI
143149# and local in ways we couldn't isolate over multiple cycles).
144150#
145151# The canonical contract test is core-tests/TestAPIOpenAPIContract, which runs
146152# the actual server and validates response shapes against the spec. The
147- # committed api/openapi.{ json,yaml} is best-effort up-to-date; run
153+ # committed api/openapi.json is best-effort up-to-date; run
148154# `make openapi` locally to refresh it (e.g., before a release).
149155#
150156# This target writes to a tempdir so it doesn't touch the committed spec.
@@ -157,13 +163,24 @@ openapi-check:
157163 @tmpdir=$$(mktemp -d ) && trap " rm -rf $$ tmpdir" EXIT && \
158164 $(SWAG ) init -g internal/restapi/v1/doc.go -d ./,internal/restapi --parseInternal -o $$ tmpdir --outputTypes json -q && \
159165 go run ./scripts/openapi-convert -in $$ tmpdir/swagger.json \
160- -out-yaml $$ tmpdir/openapi.yaml \
161166 -out-json $$ tmpdir/openapi.json && \
162167 echo " OpenAPI spec generates cleanly and validates as OpenAPI 3.0."
163168 @$(MAKE ) --no-print-directory openapi-v2-check
164169
165170openapi-v2-check :
171+ @go run ./scripts/openapi-v2-metadata -check
172+ @go run ./scripts/openapi-v2-generate -spec api/openapi-v2.json -check
166173 @go run ./scripts/openapi-v2-check -spec api/openapi-v2.json
174+ @$(MAKE ) --no-print-directory openapi-v2-client-smoke
175+ @node scripts/check-frontend-v2-fields.mjs
176+
177+ openapi-v2-client-smoke :
178+ @tmpdir=$$(mktemp -d /tmp/windshift-v2-client.XXXXXX ) && trap ' rm -rf "$$tmpdir"' EXIT && \
179+ go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@v$(OAPI_CODEGEN_VERSION ) \
180+ -generate types,client -package v2client -o " $$ tmpdir/client.gen.go" api/openapi-v2.json && \
181+ cd " $$ tmpdir" && go mod init windshift-v2-client-smoke > /dev/null && \
182+ go get github.com/oapi-codegen/runtime@v$(OAPI_RUNTIME_VERSION ) > /dev/null && \
183+ go test ./...
167184
168185# Run static analysis
169186lint :
@@ -219,7 +236,9 @@ help:
219236 @echo " make clean - Clean build artifacts"
220237 @echo " make dev-tools - Install pinned Go tools used by CI"
221238 @echo " make hooks - Install git pre-commit hook"
222- @echo " make openapi - Regenerate api/openapi.{yaml,json} from handler annotations"
239+ @echo " make openapi - Regenerate api/openapi.json from handler annotations"
240+ @echo " make openapi-v2 - Regenerate typed v2 schemas from canonical route metadata"
241+ @echo " make openapi-v2-client-smoke - Generate and compile a pinned Go v2 client"
223242 @echo " make openapi-check - Validate v1 generation and v2 route/spec parity (used by hooks/CI)"
224243 @echo " make coding-agent-image - Build the thin ws-carrier image (WS_IMAGE for windshift-agent)"
225244 @echo " make help - Show this help message"
0 commit comments