Skip to content

Fix JSON Schema comment injection in generated code#2870

Open
schani wants to merge 19 commits into
masterfrom
fix-comment-injection
Open

Fix JSON Schema comment injection in generated code#2870
schani wants to merge 19 commits into
masterfrom
fix-comment-injection

Conversation

@schani

@schani schani commented Jun 26, 2026

Copy link
Copy Markdown
Member

Summary

  • Add JSON Schema fixtures that reproduce comment injection through schema descriptions.
  • Add a parser-only tree-sitter regression fixture that loops over covered generated languages.
  • Normalize description line endings before comment emission.
  • Centralize comment delimiter escaping in emitCommentLines/emitComments so renderers do not need to escape manually.
  • Escape C-style (*/), Elm/Haskell (-}), and triple-quoted (""") documentation comments.
  • Add focused comment-injection fixtures to PR CI.

CI coverage

The PR workflow now includes a dedicated row for:

  • comment-injection-treesitter
  • comment-injection-typescript
  • comment-injection-typescript-zod
  • comment-injection-typescript-effect-schema

Existing schema fixture rows also pick up the new schema samples for languages that already run schema-* in CI.

Not yet in CI: Objective-C comment-injection fixture, because Objective-C is currently disabled/commented out in the workflow. PHP is covered by the tree-sitter parser fixture, not a runtime fixture.

Validation run locally

  • npm run build
  • npx tsc -p test/tsconfig.json --noEmit
  • CPUs=1 QUICKTEST=true FIXTURE=comment-injection-treesitter npm test -- test/inputs/schema/comment-injection.schema
  • CPUs=1 QUICKTEST=true FIXTURE=schema-typescript npm test -- test/inputs/schema/comment-injection.schema
  • CPUs=1 QUICKTEST=true FIXTURE=comment-injection-typescript npm test
  • CPUs=1 QUICKTEST=true FIXTURE=comment-injection-typescript-zod npm test
  • CPUs=1 QUICKTEST=true FIXTURE=comment-injection-typescript-effect-schema npm test
  • CPUs=1 QUICKTEST=true FIXTURE=comment-injection-treesitter,comment-injection-typescript,comment-injection-typescript-zod,comment-injection-typescript-effect-schema npm test

Open in Devin Review

@schani schani changed the title Fix JSON Schema comment injection in generated docs Fix JSON Schema comment injection in generated code Jun 26, 2026

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

Open in Devin Review

Comment thread packages/quicktype-core/src/ConvenienceRenderer.ts
Comment thread packages/quicktype-core/src/ConvenienceRenderer.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant