Repository navigation
Conversation
MarkdownText.render() round-trips parsed doc comments through commonmark's MarkdownRenderer, which backslash-escapes underscores in Text nodes. A bare URL is not autolinked by the parser, so https://en.wikipedia.org/wiki/ISO_8601 came out as ISO\_8601 and leaked into generated OpenAPI descriptions whenever the comment also contained a reference link (the only case that re-renders). Add a Text node renderer that writes bare http(s) URLs raw and delegates all other text to the core renderer's escaping. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
Problem
MarkdownText.render()round-trips parsed doc comments through commonmark'sMarkdownRenderer, which backslash-escapes_inTextnodes. The parser doesn't autolink bare URLs, sohttps://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representationswas emitted asISO\_8601#Combined\_date\_and\_time\_representations. This only happens when a comment also contains a[Reference]link (the only case whereprotoc-gen-openapire-renders), so the same URL showed up in two shapes in the generated OpenAPI and displayed backslashes in Redoc.Fix
Register a
Textnode renderer that writes barehttp(s)://URLs raw (trimming trailing sentence punctuation) and delegates everything else toCoreMarkdownNodeRenderer, so other text is still escaped.Testing
ReferenceLinkTestscase: URL with underscores, URL followed by a period, and non-URL escaped underscores in the same paragraph.protoc-gen-openapiagainst it and regenerated engine-partner-api: noISO\_8601remains in either generated spec; verified in served Redoc and Swagger UI.🤖 Generated with Claude Code