Skip to content

Conversation

@stella3d
Copy link
Member

No description provided.

@stella3d stella3d requested a review from Copilot May 22, 2025 07:29
@stella3d stella3d self-assigned this May 22, 2025
Copy link

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 schema metadata by replacing verbose titles with concise generic-style ones and introducing descriptions for clarity.

  • Refactors fixed_capacity_schema_ref to use ArrayVec<…> as title and adds a description field.
  • Refactors PoemSmallVec schema to use Vec<…> 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 description field but omits a check for the new title (ArrayVec<…>). Add an assertion for box_meta.title to 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()));
Copy link

Copilot AI May 22, 2025

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

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

@stella3d stella3d merged commit ed5b25a into main May 22, 2025
1 check failed
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