You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a developer and schema maintainer, I want to control which subschemas are inlined and which are placed in $defs.
I have a use-case where I want to define a struct that inlines a particular subschema but uses $defs for external schemas (creating a canonically bundled schema).
For example, I would like to be able to define something like the following (contrived) example:
mod tstoy {mod config {#[derive(Debug,Clone,PartialEq,Eq,Hash,Serialize,Deserialize,JsonSchema)]#[serde(rename_all = "camelCase")]pubenumScope{Machine,User,}#[derive(Debug,Clone,PartialEq,Eq,Hash,Serialize,Deserialize,JsonSchema)]pubstructUpdateSettings{pubautomatic:Option<bool>,pubfrequency:Option<int>,}#[derive(Debug,Clone,PartialEq,Eq,Hash,Serialize,Deserialize,JsonSchema)]pubstructInstance{// This property should only be a $ref, no $defs#[serde(rename = "_exist",default)]#[schemars(schema_with = "dsc_rdk::standard_properties::reference_exist")]pubexist:bool,pubscope:ConfigScope,// Even though this property normally would be a $ref to an entry in $defs,// I want to inline the subschema without having to implement JsonSchema for// the struct.#[schemars(inline)]pubupdate:Option<UpdateSettings>,}}}
And have it emit something like the following (hand-authored) schema:
{"type": "object","required": ["scope"]"properties": {"_exist": {"$ref": "https://schemas.example.com/v1/standard_properties/exist.json"},"scope": {"type": "string""enum": ["machine","user"]},"update": {"automatic": {"type": "boolean"}"frequency": {"type": "integer"}}},// I know that right now I'd have to insert this myself"$defs": {"https://schemas.example.com/v1/standard_properties/exist.json": {"type": "boolean, "default": true}}}
I can probably figure out how to write appropriate transformers for this for my own usage, but I would prefer to be able to control whether a particular item in my struct is inlined without having to add extra custom handling.
The text was updated successfully, but these errors were encountered:
I have a use-case where I want to define a struct that inlines a particular subschema but uses
$defs
for external schemas (creating a canonically bundled schema).For example, I would like to be able to define something like the following (contrived) example:
And have it emit something like the following (hand-authored) schema:
I can probably figure out how to write appropriate transformers for this for my own usage, but I would prefer to be able to control whether a particular item in my struct is inlined without having to add extra custom handling.
The text was updated successfully, but these errors were encountered: