Use authored request examples in Python samples - #33
Conversation
|
👋 Hello @glenn-jocher, thank you for submitting a
For more guidance, please refer to our Contributing Guide. Don't hesitate to leave a comment if you have any questions. Thank you for contributing to Ultralytics! 🚀 |
UltralyticsAssistant
left a comment
There was a problem hiding this comment.
🔍 PR Review
Made with ❤️ by Ultralytics Actions
Reviewed the Python sample integration and tuple-schema matching changes. The authored-example reuse and tuple matching paths are otherwise coherent, but not is only enforced during matching and not during direct example construction, so newly supported schemas can still produce invalid request samples.
💬 Posted 1 inline comment
- 💡 MEDIUM
lib/openapi.ts:1269The newnotsupport only affects paths that already callschemaMatches; the directschemaExamplebranches still return candidates without validating the enclosing schema. For example,{ type: "object", properties: { secret: { type: "string" } }, not: { required: ["secret"] } }generatessecret, and a tuple prefix item withnot: { const: "example" }can generate the forbidden value"example". These invalid values flow intorequestBodyExampleand the Python samples. Validate const…
UltralyticsAssistant
left a comment
There was a problem hiding this comment.
🔍 PR Review 2
Made with ❤️ by Ultralytics Actions
Since review 1, the broader not handling has been removed as discussed. The current diff cleanly reuses requestBodyExample for Python samples and adds consistent prefixItems matching and example generation, with focused coverage for authored union bodies and tuple arrays. I found no remaining concrete defects. LGTM.
|
🎉 PR #33 has been merged—thank you, @glenn-jocher!
This update puts that principle into practice by preserving authored request-body examples, including union-schema examples, and adding |
Summary
prefixItemsValidation
bun run test(19 tests, 358 assertions)bun run typecheckbun run lintbun run knipbun run buildbboxandkeypointsvalues🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
Python SDK samples now reuse authored request-body examples, including examples from union schemas, while supporting JSON Schema
prefixItemsfor fixed-length tuple arrays.📊 Key Changes
pythonCodeSampleto userequestBodyExamplewhen no explicit media example is provided.anyOfinstead of generating fallback values.prefixItemssupport toJsonSchema, including tuple-aware example generation and schema matching.🎯 Purpose & Impact
bboxandkeypointsvalues.prefixItemsentry and validate remaining elements againstitems.