Rename SchemaRef to Ref
This commit is contained in:
parent
87b56f2a77
commit
94250fa037
5 changed files with 14 additions and 14 deletions
|
@ -2,16 +2,16 @@
|
||||||
name = "schemars"
|
name = "schemars"
|
||||||
description = "Generate JSON Schemas from Rust code"
|
description = "Generate JSON Schemas from Rust code"
|
||||||
repository = "https://github.com/GREsau/schemars"
|
repository = "https://github.com/GREsau/schemars"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
authors = ["Graham Esau <gesau@hotmail.co.uk>"]
|
authors = ["Graham Esau <gesau@hotmail.co.uk>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
keywords = ["rust", "json-schema", "serde"]
|
keywords = ["rust", "json-schema", "serde"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
schemars_derive = { version = "0.1.0", path = "../schemars_derive" }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
schemars_derive = { version = "0.1.0", path = "../schemars_derive" }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
pretty_assertions = "0.6.1"
|
pretty_assertions = "0.6.1"
|
||||||
|
|
|
@ -95,7 +95,7 @@ impl SchemaGenerator {
|
||||||
self.insert_new_subschema_for::<T>(name.clone())?;
|
self.insert_new_subschema_for::<T>(name.clone())?;
|
||||||
}
|
}
|
||||||
let reference = format!("{}{}", self.settings().definitions_path, name);
|
let reference = format!("{}{}", self.settings().definitions_path, name);
|
||||||
Ok(SchemaRef { reference }.into())
|
Ok(Ref { reference }.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn insert_new_subschema_for<T: ?Sized + MakeSchema>(&mut self, name: String) -> Result<()> {
|
fn insert_new_subschema_for<T: ?Sized + MakeSchema>(&mut self, name: String) -> Result<()> {
|
||||||
|
|
|
@ -7,7 +7,7 @@ use serde_json::Value;
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum Schema {
|
pub enum Schema {
|
||||||
Bool(bool),
|
Bool(bool),
|
||||||
Ref(SchemaRef),
|
Ref(Ref),
|
||||||
Object(SchemaObject),
|
Object(SchemaObject),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,8 +23,8 @@ impl From<bool> for Schema {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<SchemaRef> for Schema {
|
impl From<Ref> for Schema {
|
||||||
fn from(r: SchemaRef) -> Self {
|
fn from(r: Ref) -> Self {
|
||||||
Schema::Ref(r)
|
Schema::Ref(r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ impl Schema {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, MakeSchema)]
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, MakeSchema)]
|
||||||
pub struct SchemaRef {
|
pub struct Ref {
|
||||||
#[serde(rename = "$ref")]
|
#[serde(rename = "$ref")]
|
||||||
pub reference: String,
|
pub reference: String,
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$ref": "#/components/schemas/SchemaRef"
|
"$ref": "#/components/schemas/Ref"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$ref": "#/components/schemas/SchemaObject"
|
"$ref": "#/components/schemas/SchemaObject"
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$ref": "#/components/schemas/SchemaRef"
|
"$ref": "#/components/schemas/Ref"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$ref": "#/components/schemas/SchemaObject"
|
"$ref": "#/components/schemas/SchemaObject"
|
||||||
|
@ -97,7 +97,7 @@
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$ref": "#/components/schemas/SchemaRef"
|
"$ref": "#/components/schemas/Ref"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$ref": "#/components/schemas/SchemaObject"
|
"$ref": "#/components/schemas/SchemaObject"
|
||||||
|
@ -145,7 +145,7 @@
|
||||||
},
|
},
|
||||||
"additionalProperties": true
|
"additionalProperties": true
|
||||||
},
|
},
|
||||||
"SchemaRef": {
|
"Ref": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"$ref": {
|
"$ref": {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/SchemaRef"
|
"$ref": "#/definitions/Ref"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/SchemaObject"
|
"$ref": "#/definitions/SchemaObject"
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/SchemaRef"
|
"$ref": "#/definitions/Ref"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/SchemaObject"
|
"$ref": "#/definitions/SchemaObject"
|
||||||
|
@ -181,7 +181,7 @@
|
||||||
},
|
},
|
||||||
"additionalProperties": true
|
"additionalProperties": true
|
||||||
},
|
},
|
||||||
"SchemaRef": {
|
"Ref": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"$ref": {
|
"$ref": {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue