feat: Add schemars1 feature implementing JsonSchema#32
Open
bidord wants to merge 2 commits into
Open
Conversation
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.
Summary
Adds an optional
schemars1feature that implementsJsonSchemafor every bounded integer (both thebounded_integer!-generated types and the const-generic family). The generated schema is the underlying primitive's schema with customminimumandmaximumfields.schemars generates JSON Schema documents from Rust types, kept in sync with their
serde(de)serialization. It's widely used for request/response validation, config documentation, and OpenAPI tooling. It's the de-facto standard for JSON Schema in Rust, with over 300M downloads on crates.io.The feature is
no_std-friendly but depends onalloc. schemars itself unconditionally requiresalloc, even with all features off.Changes
Cargo.toml: new optional featureschemars1.src/lib.rs: added__privatere-exports needed by the macro.src/unsafe_api.rs:JsonSchemaimpl generated for every bounded integer.src/macro.rschecks the schema ofbounded_integer!-generated types,src/types.rschecks the schema of const-generic types..github/workflows/ci.yml:schemars1feature added to clippy and test on stable toolchain.README.md: feature list updated to match the crate docs.NB: I also included an unrelated "Fix CI" commit to this PR that updates trybuild's
*.stderrfor latest toolchain. I wanted to see a green check. I can remove it if you want me to.AI usage disclosure: Claude Code assisted with adding some code comments, updating readme, updating documentation, drafting this PR.