Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR improves schema metadata by replacing verbose titles with concise generic-style ones and introducing descriptions for clarity.
- Refactors
fixed_capacity_schema_refto useArrayVec<…>as title and adds a description field. - Refactors
PoemSmallVecschema to useVec<…>as title and adds a description field. - Updates tests to check the new description fields and adjust title expectations.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/util.rs | Changed schema.title, added schema.description via Box::leak |
| src/smallvec.rs | Changed schema.title, added schema.description via Box::leak |
| src/lib.rs | Updated tests to assert on description and adjusted title assertions |
Comments suppressed due to low confidence (1)
src/lib.rs:35
- The updated test only asserts the
descriptionfield but omits a check for the newtitle(ArrayVec<…>). Add an assertion forbox_meta.titleto fully validate both metadata fields.
assert_eq!(box_meta.description, Some(format!("1 to {max} items of type {}", <T as Type>::RawElementValueType::name()).as_str()));
|
|
||
| let desc = format!("1 to {SIZE} items of type {}", T::name()); | ||
| // this should only get called to build the openapi schema, and not be a repeated cost | ||
| schema.description = Some(Box::leak(desc.into_boxed_str())); |
There was a problem hiding this comment.
Leaking a new Box on every call can lead to unbounded memory growth; consider caching the leaked &str (e.g., using OnceCell or lazy_static) so the description is allocated only once per schema.
Member
Author
There was a problem hiding this comment.
i think poem only calls this once to build the openapi schema ? wouldn't this method already be pretty expensive to call over and over
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.
No description provided.