Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to remove the "format" field for Numeric properties? #345

Open
jBernavaPrah opened this issue Sep 30, 2024 · 1 comment
Open

How to remove the "format" field for Numeric properties? #345

jBernavaPrah opened this issue Sep 30, 2024 · 1 comment

Comments

@jBernavaPrah
Copy link

Hi,

firstly thanks for this crate! Very useful!

As mentioned in the title, how can I programmatically remove the "format" from the json schema?

I'm using the v1.

use schemars::{ schema_for, JsonSchema};


#[derive(JsonSchema)]
struct MyTest {
    value: i32,
}

fn main() {
    let schema = schema_for!(MyTest);
    
   println!("{}", serde_json::to_string_pretty(&schema).unwrap());
    
    // output:
    // {
    //   "$schema": "https://json-schema.org/draft/2020-12/schema",
    //   "title": "MyTest",
    //   "type": "object",
    //   "properties": {
    //     "value": {
    //       "type": "integer",
    //       "format": "int32" <-- this one!
    //     }
    //   },
    //   "required": [
    //     "value"
    //   ]
    // }
    
}

@shmy
Copy link

shmy commented Jan 28, 2025

Some issues

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

No branches or pull requests

2 participants