From 94250fa037a80929cc76450973a58fc27a326f20 Mon Sep 17 00:00:00 2001 From: Graham Esau Date: Thu, 8 Aug 2019 22:00:15 +0100 Subject: [PATCH] Rename SchemaRef to Ref --- schemars/Cargo.toml | 4 ++-- schemars/src/gen.rs | 2 +- schemars/src/schema.rs | 8 ++++---- schemars/tests/expected/schema-openapi3.json | 8 ++++---- schemars/tests/expected/schema.json | 6 +++--- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/schemars/Cargo.toml b/schemars/Cargo.toml index 67eec45..1c39db8 100644 --- a/schemars/Cargo.toml +++ b/schemars/Cargo.toml @@ -2,16 +2,16 @@ name = "schemars" description = "Generate JSON Schemas from Rust code" repository = "https://github.com/GREsau/schemars" -version = "0.1.0" +version = "0.1.1" authors = ["Graham Esau "] edition = "2018" license = "MIT" keywords = ["rust", "json-schema", "serde"] [dependencies] +schemars_derive = { version = "0.1.0", path = "../schemars_derive" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -schemars_derive = { version = "0.1.0", path = "../schemars_derive" } [dev-dependencies] pretty_assertions = "0.6.1" diff --git a/schemars/src/gen.rs b/schemars/src/gen.rs index 8523908..b93b155 100644 --- a/schemars/src/gen.rs +++ b/schemars/src/gen.rs @@ -95,7 +95,7 @@ impl SchemaGenerator { self.insert_new_subschema_for::(name.clone())?; } let reference = format!("{}{}", self.settings().definitions_path, name); - Ok(SchemaRef { reference }.into()) + Ok(Ref { reference }.into()) } fn insert_new_subschema_for(&mut self, name: String) -> Result<()> { diff --git a/schemars/src/schema.rs b/schemars/src/schema.rs index 3afe4c8..463c87b 100644 --- a/schemars/src/schema.rs +++ b/schemars/src/schema.rs @@ -7,7 +7,7 @@ use serde_json::Value; #[serde(untagged)] pub enum Schema { Bool(bool), - Ref(SchemaRef), + Ref(Ref), Object(SchemaObject), } @@ -23,8 +23,8 @@ impl From for Schema { } } -impl From for Schema { - fn from(r: SchemaRef) -> Self { +impl From for Schema { + fn from(r: Ref) -> Self { Schema::Ref(r) } } @@ -87,7 +87,7 @@ impl Schema { } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, MakeSchema)] -pub struct SchemaRef { +pub struct Ref { #[serde(rename = "$ref")] pub reference: String, } diff --git a/schemars/tests/expected/schema-openapi3.json b/schemars/tests/expected/schema-openapi3.json index fbba72d..fa32d86 100644 --- a/schemars/tests/expected/schema-openapi3.json +++ b/schemars/tests/expected/schema-openapi3.json @@ -6,7 +6,7 @@ "type": "boolean" }, { - "$ref": "#/components/schemas/SchemaRef" + "$ref": "#/components/schemas/Ref" }, { "$ref": "#/components/schemas/SchemaObject" @@ -30,7 +30,7 @@ "type": "boolean" }, { - "$ref": "#/components/schemas/SchemaRef" + "$ref": "#/components/schemas/Ref" }, { "$ref": "#/components/schemas/SchemaObject" @@ -97,7 +97,7 @@ "type": "boolean" }, { - "$ref": "#/components/schemas/SchemaRef" + "$ref": "#/components/schemas/Ref" }, { "$ref": "#/components/schemas/SchemaObject" @@ -145,7 +145,7 @@ }, "additionalProperties": true }, - "SchemaRef": { + "Ref": { "type": "object", "properties": { "$ref": { diff --git a/schemars/tests/expected/schema.json b/schemars/tests/expected/schema.json index f4bea94..f50e5de 100644 --- a/schemars/tests/expected/schema.json +++ b/schemars/tests/expected/schema.json @@ -6,7 +6,7 @@ "type": "boolean" }, { - "$ref": "#/definitions/SchemaRef" + "$ref": "#/definitions/Ref" }, { "$ref": "#/definitions/SchemaObject" @@ -30,7 +30,7 @@ "type": "boolean" }, { - "$ref": "#/definitions/SchemaRef" + "$ref": "#/definitions/Ref" }, { "$ref": "#/definitions/SchemaObject" @@ -181,7 +181,7 @@ }, "additionalProperties": true }, - "SchemaRef": { + "Ref": { "type": "object", "properties": { "$ref": {