feat(codegen): propagate JSON Schema deprecated:true as // Deprecated: doc comment#135
feat(codegen): propagate JSON Schema deprecated:true as // Deprecated: doc comment#135bokelley wants to merge 5 commits into
Conversation
…: doc comment For struct fields where the source JSON Schema property declares `deprecated: true`, generate.py now emits a preceding standalone `// Deprecated: <description>` line rather than a trailing inline comment. The preceding-line form is required by Go's documentation comment convention (go.dev/doc/comment) for the deprecation to be recognised by gopls and go doc. Also adds adcp/schemas/test_generate.py (Python unittest) with 5 test cases covering deprecated, non-deprecated, and mixed-struct scenarios, and adcp/generator_test.go which shells out to run those Python tests under `go test ./...` so CI coverage does not require a separate workflow step. No types_gen.go changes: no current schema in the 3.0 bundle has `deprecated: true`. The generated output will update automatically when the AdCP 3.1 schema bundle lands and `download.sh` + `generate.py` are re-run (adcontextprotocol/adcp#4904). Refs #134 https://claude.ai/code/session_01TXU3btrUh956CDjk3rm8sL
…recated: doc comment
Strip redundant leading "Deprecated: " prefix from description before
using it as the // Deprecated: message, preventing double-prefix output
("// Deprecated: Deprecated: ...") when schema authors set both
deprecated:true and start the description with "Deprecated: ".
Stripping is case-insensitive. Two new test cases cover the
already-prefixed and lowercase-prefix variants.
Refs #134
https://claude.ai/code/session_01TXU3btrUh956CDjk3rm8sL
…recated: doc comment Clarify generator_test.go doc comment: the adcp/ module has no CI step (pre-existing gap). Replace misleading "CI does not require a separate workflow step" with an accurate note and follow-up pointer. Refs #134 https://claude.ai/code/session_01TXU3btrUh956CDjk3rm8sL
|
Fold suggestion from triage of #151: two small fixes naturally belong in this diff before merge rather than in a separate follow-up PR. Item 1 — Item 2 — Both changes are mechanical (no logic impact on the deprecated-annotation feature) and each is ~1–3 lines. Details in #151. Triaged by Claude Code. Session: https://claude.ai/code/cse_01Y3MmzgEj2mxK4G7rN5NQyk Generated by Claude Code |
|
Fold candidate note from #180: that issue requests union-helper regression tests — broken Generated by Claude Code |
…gen-deprecated-comment-v2
…gn discovery pattern - Merge TestDeprecatedField from test_generate.py into generate_test.py so all schema generator tests live in one file with a consistent *_test.py naming convention - Remove test_generate.py (now superseded) - Update generator_test.go to use *_test.py discovery pattern, matching the CI "Test schema generator" step exactly — previously test_generate.py was invisible to CI and generate_test.py (from #183) was invisible to the Go test https://claude.ai/code/session_018Gmdum6TsUTwpA6SXHjLLv
|
The fold candidate from #180 is no longer needed — @bokelley landed the union helper tests directly in PR #183 ( However, the merge surfaced a test discovery gap: Fixed in the latest push:
All 13 tests (7 deprecated-comment + 6 union-helper) pass under both Also merged the latest Generated by Claude Code Generated by Claude Code |
|
Acknowledged. The test consolidation is clean: a single _Generated by Claude Code Generated by Claude Code |
Refs #134
Modifies
adcp/schemas/generate.pyso that JSON Schema properties withdeprecated: trueproduce a preceding standalone// Deprecated: <description>comment on the generated Go struct field. The preceding-line form is required by Go's documentation comment convention (go.dev/doc/comment §Deprecated) forgopls,go doc, and IDE hover to recognise the deprecation — a trailing inline comment (the existing approach fordescriptiontext) is not recognised.No changes to
types_gen.go: the current 3.0 bundle has nodeprecated: trueproperties. The generated output will update automatically when the AdCP 3.1 schema bundle lands (download.sh+generate.pyre-run, see adcontextprotocol/adcp#4904).What changed
adcp/schemas/generate.py(8 lines changed inschema_to_struct):prop.get('deprecated', False)is true, emit// Deprecated: <description>on a line preceding the field declaration, and suppress the duplicate trailing inline description comment."Deprecated: "prefix (case-insensitive) fromdescriptionbefore using it as the message, to prevent// Deprecated: Deprecated: ...if a schema author sets bothdeprecated: trueand starts the description with"Deprecated: "(the existingaxe_include_segmentpattern in the 3.0 bundle, lines 2004–2005 oftypes_gen.go, illustrates this authoring pattern)."No replacement specified.".adcp/schemas/test_generate.py(new, 156 lines): Python unittest forschema_to_struct. 7 test cases: basic deprecated field, fallback message, non-deprecated unchanged, no-description, mixed struct regression, double-prefix strip, case-insensitive strip.adcp/generator_test.go(new, 26 lines): Go test that shells out topython3 -m unittest discoverso the Python tests run whencd adcp && go test ./...is executed. Python is already a build-time dependency of this module (CI invokesgenerate.pyandlint.py).What was tested
python3 -m unittest discover -s adcp/schemas -p 'test_*.py' -v→ 7/7 passcd adcp && go test ./...→ all pass (includingTestGeneratorDeprecatedPropagation)go build ./...(root module) → cleango vet ./...(root module) → cleancd adcp/schemas && python3 lint.py→ no drift (no schema in 3.0 bundle hasdeprecated: true, sotypes_gen.gois unchanged)adcp/sub-module (adcp/go.mod) has no dedicated CI step in.github/workflows/ci.yml. All 6+ existing test files inadcp/(e.g.testcontroller_test.go,addtool_test.go,seller_test.go) run only viacd adcp && go test ./...locally. A follow-up CI step analogous to the existingTest context agent/Test bench modulesteps is needed:Pre-PR review
re.subdouble-prefix fix is correct; CI gap is pre-existing infrastructure debt for alladcp/tests, not a logic issue; nit (doc comment clarity) addresseddeprecated→ Go// Deprecated:preceding-line mapping is correct per go.dev/doc/comment; back-compat clean on 3.0 bundlesafe_comment()sanitization already covers the newdeprecated_msgpath; no new injection surfaceSession: https://claude.ai/code/session_01TXU3btrUh956CDjk3rm8sL
Generated by Claude Code