-
-
Notifications
You must be signed in to change notification settings - Fork 294
Open
Description
Hi, is there a way to get #[serde(transparent)] behaviour of inlining the inner type along with custom schema name from `#[schemars(rename = "...")]?
Here's an example
use schemars::JsonSchema;
use serde::Serialize;
#[derive(Serialize, JsonSchema)]
pub struct Anonymous<T>(T);
#[derive(Serialize, JsonSchema)]
#[serde(transparent)]
#[schemars(rename = "Alias")]
pub struct AliasNewType(Anonymous<i32>);
#[derive(Serialize, JsonSchema)]
#[schemars(rename = "Wrapped{T}")]
pub struct Wrapper<T>(T);
fn main() {
println!(
"{:#}",
schemars::schema_for!(Wrapper<AliasNewType>).to_value()
);
}In the case above I'd expect that #[schemars(rename = "Alias")] would override serde's attributes (which is otherwise always the case as far as I know), and yet it doesn't here:
{
"$defs": {
"Anonymous": {
"format": "int32",
"type": "integer"
}
},
"$ref": "#/$defs/Anonymous",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "WrappedAnonymous"
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels