Skip to content

feat: Add schemars1 feature implementing JsonSchema#32

Open
bidord wants to merge 2 commits into
Kestrer:mainfrom
bidord:feat/schemars1
Open

feat: Add schemars1 feature implementing JsonSchema#32
bidord wants to merge 2 commits into
Kestrer:mainfrom
bidord:feat/schemars1

Conversation

@bidord

@bidord bidord commented Jul 7, 2026

Copy link
Copy Markdown

Summary

Adds an optional schemars1 feature that implements JsonSchema for every bounded integer (both the bounded_integer!-generated types and the const-generic family). The generated schema is the underlying primitive's schema with custom minimum and maximum fields.

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 on alloc. schemars itself unconditionally requires alloc, even with all features off.

Changes

  • Cargo.toml: new optional feature schemars1.
  • src/lib.rs: added __private re-exports needed by the macro.
  • src/unsafe_api.rs: JsonSchema impl generated for every bounded integer.
  • Tests: src/macro.rs checks the schema of bounded_integer!-generated types, src/types.rs checks the schema of const-generic types.
  • .github/workflows/ci.yml: schemars1 feature 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 *.stderr for 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.

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