Escape angle brackets in OpenAPI and AsyncAPI descriptions - #447
Merged
Conversation
Descriptions containing angle brackets (e.g. <fieldname>,<asc/desc>) were written raw into generated markdown and parsed by MDX as JSX tags, breaking the EventCatalog build. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 64eaeb7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
What This PR Does
Fixes a customer-reported bug where an OpenAPI parameter description containing angle brackets (e.g.
<veldnaam>,<asc/desc>) is written raw into the generated.mdxfile. MDX parses the angle brackets as a JSX tag and the EventCatalog build fails with:The AsyncAPI generator has the same class of bug in service and channel descriptions (with no escaping at all, including curly braces), so this PR fixes both packages.
Changes Overview
Key Changes
escapeSpecialCharactersThatBreakMarkdownnow also escapes<(as\<) alongside the existing{/}escaping, and protects inline code spans in addition to fenced code blocks. The escaping is now applied to parameter descriptions and response schema descriptions, which were previously interpolated raw.src/utils/markdown.ts) and applies it to service (info.description) and channel descriptions, which previously had no escaping at all.<fieldname>,<asc/desc>, curly braces, and inline code — all failing before the fix, passing after.@eventcatalog/generator-openapiand@eventcatalog/generator-asyncapi.How It Works
The escape utility replaces fenced code blocks and inline code spans with placeholders, escapes
{,}, and<in the remaining text (MDX parses{}as JSX expressions and<as the start of a JSX tag), then restores the code blocks untouched.\<renders as a literal<in MDX, so descriptions display exactly as authored.Verified end-to-end: regenerated a catalog from the customer's spec and from the AsyncAPI fixture, and compiled every generated
.mdxfile with@mdx-js/mdx— all compile cleanly, where the customer's file previously failed.Breaking Changes
None.
Additional Notes
"200": description: ...) are never rendered into markdown — what renders under### Responsesis the response schema's owndescription, which is what this PR escapes and tests.generator-aws-glue(src/utils/messages.ts) interpolatesschema.descriptionraw too — same class of bug, lower likelihood of angle brackets in practice. Left for a follow-up.https://claude.ai/code/session_01EdKN8y3UTR6LeBWME4SsEz