Repository navigation
Sample a repeated character class instead of printing a pattern placeholder - #64
Merged
Merged
Conversation
UltralyticsAssistant
left a comment
Member
There was a problem hiding this comment.
🔍 PR Review
Made with ❤️ by Ultralytics Actions
Reviewed string-example generation and its new test. The ID/hash case works, but punctuation-only repeated classes still produce the placeholder.
💬 Posted 1 inline comment
- 📝 LOW
lib/openapi.ts:961For a valid repeated class that allows only punctuation, such as^[._-]{3}$, both candidate alphabets are empty, so this falls through to<pattern value>instead of sampling the class. Include punctuation candidates after the current alphanumeric candidates.
Member
|
🎉 PR #64 was merged—thank you, @glenn-jocher! String example generation can now produce valid candidates for repeated character-class patterns, including hexadecimal IDs, instead of falling back to |
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.
stringExampleprints<pattern value>when no candidate matches a string'spattern. The usual case is an ID or a hash: a pattern such as^[0-9a-fA-F]{24}$or^[a-f\d]{32}$that no word-like candidate can satisfy. Docs and request samples then show"<pattern value>", which is neither valid nor readable.This adds one candidate for a pattern that is a single character class repeated (
{n},{n,m}or+): it cycles through the characters the class allows, lowercase and digits first.^[0-9a-fA-F]{24}$"<pattern value>""0123456789abcdef01234567"^[a-f\d]{32}$"<pattern value>""0123456789abcdef0123456789abcdef"^[A-Z]{3}$"<pattern value>""ABC"^[a-z0-9_-]+$,^\d{4}-\d{2}$, plain stringsThe class is applied with
RegExpto each candidate character rather than parsed, so ranges, escapes such as\d, and negations behave as the pattern defines them. Like every other candidate, the result is kept only if the whole pattern and the length limits accept it. Patterns of any other shape keep their existing behavior.Testing
bun test: 21 pass, including a new assertion for^[0-9a-fA-F]{24}$.schemaExampleon this branch.bun run typecheckandbun run lintpass.🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
String example generation now creates a candidate for patterns consisting of one repeated character class, replacing an otherwise unusable placeholder when the candidate passes validation.
📊 Key Changes
{n},{n,m}, or+.^[0-9a-fA-F]{24}$produces0123456789abcdef01234567.🎯 Purpose & Impact
"<pattern value>"; patterns outside the supported shape retain their existing behavior.