这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@danielgtaylor
Copy link
Owner

This PR fixes an issue where switching from full paths to huma.Group while using convenience functions breaks the resulting OpenAPI backward compatibility. Since these two things (convenience functions and groups) operate at different layers, the operation's metadata is used to communicate when auto-generated operation ID and summaries have been used, enabling groups to regenerate those values if they have not been modified.

Fixes #754.

Copilot AI review requested due to automatic review settings March 18, 2025 16:41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves the interoperability between convenience functions and groups by ensuring that auto‐generated operation IDs and summaries are properly re‑generated when using groups. Key changes include:

  • Adding tests in group_test.go to verify consistency between convenience and group behavior.
  • Updating group.go to copy operation metadata and re‑generate IDs and summaries based on convenience hints.
  • Modifying huma.go’s convenience function to annotate operations with metadata for later regeneration by groups.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
group_test.go Adds tests to validate interop between convenience functions and groups.
group.go Updates ModifyOperation to copy metadata and conditionally regenerate operation details.
huma.go Adjusts the convenience function to generate and annotate operation metadata.
Comments suppressed due to low confidence (2)

huma.go:2042

  • [nitpick] Consider defining constants for metadata keys like '_convenience_id', '_convenience_id_out', '_convenience_summary', and '_convenience_summary_out' to improve maintainability and reduce the risk of typos.
operation.Metadata["_convenience_id"] = opID

group.go:146

  • [nitpick] For consistency with the convenience function, consider using defined constants for the metadata keys in this regeneration logic.
if op.Metadata["_convenience_id"] == op.OperationID {

@codecov
Copy link

codecov bot commented Mar 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.10%. Comparing base (ad6a04a) to head (b899b51).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #770      +/-   ##
==========================================
+ Coverage   93.06%   93.10%   +0.04%     
==========================================
  Files          23       23              
  Lines        5261     5296      +35     
==========================================
+ Hits         4896     4931      +35     
  Misses        313      313              
  Partials       52       52              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@danielgtaylor danielgtaylor merged commit 4977a7a into main Mar 18, 2025
7 checks passed
@danielgtaylor danielgtaylor deleted the group-convenience branch March 18, 2025 16:46
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.

Switching to route groups changes OpenAPI operation ID (and breaks auto-generated clients)

2 participants