feat(codegen): propagate JSON Schema deprecated:true as // Deprecated: doc comment#135
Draft
bokelley wants to merge 3 commits into
Draft
feat(codegen): propagate JSON Schema deprecated:true as // Deprecated: doc comment#135bokelley wants to merge 3 commits into
bokelley wants to merge 3 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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