Skip to content

feat: support api metadata when register path#49

Merged
ren0503 merged 1 commit into
masterfrom
feat/ren/48-support-register-metadata
Nov 14, 2025
Merged

feat: support api metadata when register path#49
ren0503 merged 1 commit into
masterfrom
feat/ren/48-support-register-metadata

Conversation

@ren0503

@ren0503 ren0503 commented Nov 14, 2025

Copy link
Copy Markdown
Contributor

No description provided.

@ren0503 ren0503 added this to the Swagger Release v2.3.0 milestone Nov 14, 2025
@coderabbitai

coderabbitai Bot commented Nov 14, 2025

Copy link
Copy Markdown

Summary by CodeRabbit

  • New Features

    • Added new APIs to support descriptions and summaries for REST endpoints, enabling enhanced OpenAPI documentation with richer endpoint metadata.
  • Chores

    • Updated Go language version from 1.23 to 1.24 with toolchain 1.24.1. Upgraded multiple dependencies including core libraries for improved stability, performance, and compatibility.

Walkthrough

This PR upgrades Go from 1.23.0 to 1.24.0, updates dependencies, and extends OpenAPI metadata support. It renames existing OpenAPI metadata keys with an "openapi_" prefix and adds new ApiDescription and ApiSummary functions for Swagger operation documentation.

Changes

Cohort / File(s) Summary
Dependency upgrades
go.mod
Go version bumped 1.23.0 → 1.24.0 (toolchain: go1.24.1). Direct dependencies updated: kin-openapi v0.132.0 → v0.133.0, testify v1.10.0 → v1.11.1, tinhtinh/v2 v2.3.1 → v2.3.4. Indirect updates: jsonpointer, easyjson, and new woodsbury/decimal128 added.
OpenAPI metadata API
metadata.go
Constants renamed with "openapi_" prefix: TAG, SECURITY, CONSUMER, FILE. New public constants and functions added: DESCRIPTION/ApiDescription() and SUMMARY/ApiSummary() for operation descriptions and summaries.
Metadata parsing
parse.go
Swagger path parser now extracts DESCRIPTION and SUMMARY metadata keys from routes and assigns them to operation.Description and operation.Summary fields.
Test updates
unit_test.go
Test route updated to apply new ApiDescription() and ApiSummary() metadata helpers to Get route definition.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify that renaming metadata constants (TAG → "openapi_tag", etc.) does not break existing route definitions or downstream metadata consumers
  • Confirm the metadata key names align with OpenAPI specification expectations
  • Review parse.go logic to ensure DESCRIPTION and SUMMARY are correctly extracted and applied to the operation object

Poem

🐰 New tags with openapi_ prefix gleam,
Description and Summary join the team!
Swagger docs dance with metadata bright,
Go 1.24 sets the upgrade right! 🚀

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to assess relevance to the changeset. Add a description explaining the purpose of this metadata support feature and why these changes are needed.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding support for API metadata (description and summary) during path registration.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/ren/48-support-register-metadata

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ae163d3 and 2c07c06.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (4)
  • go.mod (1 hunks)
  • metadata.go (1 hunks)
  • parse.go (1 hunks)
  • unit_test.go (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
parse.go (1)
metadata.go (2)
  • DESCRIPTION (11-11)
  • SUMMARY (17-17)
unit_test.go (1)
metadata.go (2)
  • ApiDescription (13-15)
  • ApiSummary (19-21)
🔇 Additional comments (10)
parse.go (2)

132-139: LGTM! Consistent implementation.

The API Description extraction follows the established pattern for metadata handling and correctly assigns the description to the OpenAPI operation.


141-148: LGTM! Consistent implementation.

The API Summary extraction follows the established pattern and correctly assigns the summary to the OpenAPI operation.

unit_test.go (1)

107-109: LGTM! Proper test coverage.

The test correctly demonstrates usage of the new ApiDescription and ApiSummary metadata functions, ensuring the functionality added in parse.go is properly validated.

go.mod (3)

15-18: Indirect dependency updates look reasonable.

The indirect dependency updates include minor version bumps and the addition of decimal128. These changes are typical when upgrading direct dependencies.

Also applies to: 25-25


3-5: Go 1.24.0 is a stable release with valid configuration.

Go 1.24 was released in February 2025 and maintains the Go 1 promise of compatibility, with almost all Go programs expected to continue compiling and running as before. As of November 5, 2025, the Go 1.24 line includes Go 1.24.10, confirming multiple stable patch releases have been issued.

The go.mod configuration is correct. The go directive specifies the minimum required Go version, while the toolchain directive specifies the exact Go toolchain to use when working in the module. The toolchain line takes precedence over the go line when the go command is deciding which toolchain to use. Having go 1.24.0 with toolchain go1.24.1 is an intentional and valid configuration for ensuring build consistency.


8-10: All dependency versions verified and validated.

All three updated dependencies exist and are secure:

  • kin-openapi v0.133.0 ✓ includes fixes for CVE-2025-30153
  • testify v1.11.1 ✓ no known vulnerabilities
  • tinhtinh/v2 v2.3.4 ✓ no known vulnerabilities
metadata.go (4)

5-9: Constant rename enhances clarity.

The rename from "tag" to "openapi_tag" improves clarity and aligns with OpenAPI naming conventions. If consumers use the ApiTag function rather than the constant directly, this change is backward compatible.


11-15: LGTM! Well-designed API addition.

The ApiDescription function follows the established pattern and appropriately takes a single string parameter for the OpenAPI description field.


17-21: LGTM! Well-designed API addition.

The ApiSummary function follows the established pattern and appropriately takes a single string parameter for the OpenAPI summary field.


23-45: Consistent naming convention applied.

The remaining constant renames (SECURITY, CONSUMER, FILE) maintain consistency with the "openapi_" prefix. This improves clarity and prevents potential naming conflicts. The function signatures remain unchanged, minimizing user impact.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ren0503 ren0503 linked an issue Nov 14, 2025 that may be closed by this pull request
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@ren0503 ren0503 merged commit b465060 into master Nov 14, 2025
4 checks passed
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.

Add Api Metadata When Register Path

2 participants