Skip to content

feat: support OpenAPI metadata comment blocks#9

Merged
miclle merged 3 commits into
mainfrom
feat/openapi-comment-extensions
May 9, 2026
Merged

feat: support OpenAPI metadata comment blocks#9
miclle merged 3 commits into
mainfrom
feat/openapi-comment-extensions

Conversation

@miclle
Copy link
Copy Markdown
Member

@miclle miclle commented May 8, 2026

Summary

  • add handler doc comment openapi: blocks for operation metadata
  • support x-* extensions plus simple operation fields such as summary, description, operationId, tags, and deprecated
  • keep regular handler comments as summary/description when the block omits them
  • cover both direct route generation and route manifest generation
  • update English and Chinese README metadata docs

Validation

  • go test ./...

@miclle miclle marked this pull request as ready for review May 8, 2026 16:51
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for defining OpenAPI operation metadata directly within Go handler comments using an "openapi:" YAML block. This allows developers to specify fields such as summary, tags, deprecated, and custom extensions (e.g., x-public) directly in the source code. The implementation includes logic to extract and parse these blocks from doc comments, updates to the internal operation documentation structures, and corresponding tests. Review feedback identifies a bug in the comment parsing logic that strips leading whitespace and destroys YAML indentation. Additionally, it is recommended to use a struct for composite return values to improve code quality and to provide better error reporting when YAML unmarshaling fails within a comment block.

Comment thread comments.go Outdated
Comment thread comments.go Outdated
@miclle
Copy link
Copy Markdown
Member Author

miclle commented May 9, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the ability to define OpenAPI operation-level metadata and extensions directly in Go handler comments using a YAML-formatted openapi: block. The implementation includes a parser for these blocks, updates to the generator to apply the metadata, and corresponding documentation and tests. A review comment suggests that source-level warnings should be moved to a location re-evaluated during each generation cycle to ensure they are not lost when the specification is regenerated.

Comment thread comments.go Outdated
@miclle
Copy link
Copy Markdown
Member Author

miclle commented May 9, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for openapi: metadata blocks within Go handler comments, allowing developers to define operation-level fields such as summary, description, operationId, tags, deprecated, and custom OpenAPI extensions (e.g., x-public). The implementation includes a YAML parser for these blocks, logic to strip them from the final human-readable description, and a warning system for invalid metadata. Documentation and tests have been updated to reflect these changes. I have no feedback to provide.

@miclle miclle merged commit f74bef2 into main May 9, 2026
1 check passed
@miclle miclle deleted the feat/openapi-comment-extensions branch May 9, 2026 02:05
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