GREsau / schemars

Generate JSON Schema documents from Rust code
https://graham.cool/schemars/
MIT License
791 stars 220 forks source link

bug(schemars_derive/docs): newlines get stripped in example blocks #313

Closed DonIsaac closed 1 month ago

DonIsaac commented 1 month ago
use schemars::JsonSchema;
use serde::Deserialize;

/// # Some Config
/// 
/// This config does some stuff.
///
/// # Example
///
/// ```jsonc
/// {
///   // use this config setting in a certain way
///   "foo": ["bar", "baz"],
/// }
/// ```
#[derive(Debug, Deserialize, Default, JSONSchema)]
pub struct Config {
    foo: Vec<String>
}

When rendered to a JSON schema, the code block in the schema's description field will be stripped, causing invalid JSONC to be rendered. It looks like other markdown in description has its whitespace preserved.

GREsau commented 1 month ago

Duplicate of #38 / #120 / #129

Fortunately, this is now fixed in schemars v1.0.0-alpha.3