fix(api): add explicit @PathVariable name on transcription-block comment endpoints #473
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Spectral lint of the live
/v3/api-docsreports two ERROR-severity findings (only ERROR-severity findings out of 244 total — the rest are documentation warnings):What this means: the OpenAPI spec for these two endpoints is missing path parameters that the URL itself contains. The cause is almost always that the Spring controller method uses an implicit
@PathVariable UUID documentId(no name attribute) and SpringDoc fails to associate it with the path placeholder.The practical impact: when
npm run generate:apiregeneratesfrontend/src/lib/generated/api.ts, the typed call signatures for these two endpoints are missing the path parameter — meaning frontend code that should be type-checked at compile time silently accepts wrong types or no types at all.Approach
Find the affected handlers in:
backend/src/main/java/org/raddatz/familienarchiv/document/comment/CommentController.java(most likely location)backend/src/main/java/org/raddatz/familienarchiv/document/transcription/TranscriptionBlockController.javaLook for handlers matching the path patterns. Add the explicit
nameattribute:While there, also verify the
/repliesPOST handler. Spectral specifically called out missing{blockId}on the POST — a sibling parameter problem.Why does this happen?
Spring's
@PathVariabledoes infer the name from the parameter name when compiled with-parameters(Java 8+). SpringDoc typically picks this up. The bug surfaces when:-parametersto javac (verify inpom.xml'smaven-compiler-pluginconfig).If the root cause is missing
-parameters, the fix is to add it to the compiler plugin and the explicit-name strategy becomes optional (defense-in-depth).Critical files
backend/src/main/java/org/raddatz/familienarchiv/document/comment/CommentController.javabackend/src/main/java/org/raddatz/familienarchiv/document/transcription/TranscriptionBlockController.javabackend/pom.xml— verify/add<parameters>true</parameters>frontend/src/lib/generated/api.tsvianpm run generate:apiVerification
./mvnw spring-boot:run -Dspring-boot.run.profiles=dev.curl http://localhost:8080/v3/api-docs > /tmp/openapi.json.npx @stoplight/spectral-cli@6.13.1 spectral lint /tmp/openapi.json --ruleset spectral:oas --fail-severity error— exit 0.jq '.paths."/api/documents/{documentId}/transcription-blocks/{blockId}/comments".get.parameters' /tmp/openapi.jsonshows both path params with names.cd frontend && npm run generate:api. Inspect newapi.ts— these endpoints now have the path-param fields typed.npm run check— any code calling these endpoints will surface type errors if they were previously ignoring path params.Acceptance criteria
--fail-severity errorexits 0 against the live/v3/api-docs.documentIdandblockIdas path parameters in the spec.frontend/src/lib/generated/api.tsregenerated with the corrected signatures.npm run checkpasses (or surfaces real type bugs in callers, which then get fixed in the same PR).<parameters>true</parameters>confirmed/set in compiler plugin.Effort
XS — 15 minutes for the controller fix; 1 hour if it surfaces caller type errors.
Risk if not addressed
Generated TypeScript types are wrong → silent compile-time bugs in frontend code calling these endpoints. CI's planned OpenAPI lint gate (in the devops(ci) issue) will fail.
Tracked in audit doc as F-36 (Medium) — new dynamic finding from Spectral lint.