diff --git a/schemars/src/json_schema_impls/array.rs b/schemars/src/json_schema_impls/array.rs index 3ccdd1c..558ddbd 100644 --- a/schemars/src/json_schema_impls/array.rs +++ b/schemars/src/json_schema_impls/array.rs @@ -7,7 +7,7 @@ impl JsonSchema for [T; 0] { no_ref_schema!(); fn schema_name() -> String { - "Empty_Array".to_owned() + "EmptyArray".to_owned() } fn json_schema(_: &mut SchemaGenerator) -> Schema { @@ -30,7 +30,7 @@ macro_rules! array_impls { no_ref_schema!(); fn schema_name() -> String { - format!("Array_Size_{}_Of_{}", $len, T::schema_name()) + format!("Array_size_{}_of_{}", $len, T::schema_name()) } fn json_schema(gen: &mut SchemaGenerator) -> Schema { diff --git a/schemars/src/json_schema_impls/core.rs b/schemars/src/json_schema_impls/core.rs index 23344fd..9ae9313 100644 --- a/schemars/src/json_schema_impls/core.rs +++ b/schemars/src/json_schema_impls/core.rs @@ -76,7 +76,7 @@ fn with_null_type(mut obj: SchemaObject) -> SchemaObject { impl JsonSchema for Result { fn schema_name() -> String { - format!("Result_Of_{}_Or_{}", T::schema_name(), E::schema_name()) + format!("Result_of_{}_or_{}", T::schema_name(), E::schema_name()) } fn json_schema(gen: &mut SchemaGenerator) -> Schema { @@ -102,7 +102,7 @@ impl JsonSchema for Result { impl JsonSchema for Range { fn schema_name() -> String { - format!("Range_Of_{}", T::schema_name()) + format!("Range_of_{}", T::schema_name()) } fn json_schema(gen: &mut SchemaGenerator) -> Schema { diff --git a/schemars/src/json_schema_impls/ffi.rs b/schemars/src/json_schema_impls/ffi.rs index 027ded2..8da586a 100644 --- a/schemars/src/json_schema_impls/ffi.rs +++ b/schemars/src/json_schema_impls/ffi.rs @@ -5,7 +5,7 @@ use std::ffi::{CStr, CString, OsStr, OsString}; impl JsonSchema for OsString { fn schema_name() -> String { - "OS_String".to_owned() + "OsString".to_owned() } fn json_schema(gen: &mut SchemaGenerator) -> Schema { diff --git a/schemars/src/json_schema_impls/maps.rs b/schemars/src/json_schema_impls/maps.rs index e5a592e..0fc3214 100644 --- a/schemars/src/json_schema_impls/maps.rs +++ b/schemars/src/json_schema_impls/maps.rs @@ -12,7 +12,7 @@ macro_rules! map_impl { no_ref_schema!(); fn schema_name() -> String { - format!("Map_Of_{}", V::schema_name()) + format!("Map_of_{}", V::schema_name()) } fn json_schema(gen: &mut SchemaGenerator) -> Schema { diff --git a/schemars/src/json_schema_impls/sequences.rs b/schemars/src/json_schema_impls/sequences.rs index ffb1f0d..ab146fe 100644 --- a/schemars/src/json_schema_impls/sequences.rs +++ b/schemars/src/json_schema_impls/sequences.rs @@ -11,7 +11,7 @@ macro_rules! seq_impl { no_ref_schema!(); fn schema_name() -> String { - format!("Array_Of_{}", T::schema_name()) + format!("Array_of_{}", T::schema_name()) } fn json_schema(gen: &mut SchemaGenerator) -> Schema { diff --git a/schemars/src/json_schema_impls/serdejson.rs b/schemars/src/json_schema_impls/serdejson.rs index 9f1f1b7..f911b8e 100644 --- a/schemars/src/json_schema_impls/serdejson.rs +++ b/schemars/src/json_schema_impls/serdejson.rs @@ -8,7 +8,7 @@ impl JsonSchema for Value { no_ref_schema!(); fn schema_name() -> String { - "Any_Value".to_owned() + "AnyValue".to_owned() } fn json_schema(gen: &mut SchemaGenerator) -> Schema { diff --git a/schemars/src/json_schema_impls/tuple.rs b/schemars/src/json_schema_impls/tuple.rs index 936fb66..d9e8971 100644 --- a/schemars/src/json_schema_impls/tuple.rs +++ b/schemars/src/json_schema_impls/tuple.rs @@ -9,7 +9,7 @@ macro_rules! tuple_impls { no_ref_schema!(); fn schema_name() -> String { - ["Tuple_Of".to_owned()$(, $name::schema_name())+].join("_And_") + ["Tuple_of".to_owned()$(, $name::schema_name())+].join("_and_") } fn json_schema(gen: &mut SchemaGenerator) -> Schema { diff --git a/schemars/tests/expected/os_strings.json b/schemars/tests/expected/os_strings.json index 0611998..7c9d062 100644 --- a/schemars/tests/expected/os_strings.json +++ b/schemars/tests/expected/os_strings.json @@ -8,14 +8,14 @@ ], "properties": { "borrowed": { - "$ref": "#/definitions/OS_String" + "$ref": "#/definitions/OsString" }, "owned": { - "$ref": "#/definitions/OS_String" + "$ref": "#/definitions/OsString" } }, "definitions": { - "OS_String": { + "OsString": { "oneOf": [ { "type": "object", diff --git a/schemars/tests/expected/range.json b/schemars/tests/expected/range.json index 759cf91..f8abf39 100644 --- a/schemars/tests/expected/range.json +++ b/schemars/tests/expected/range.json @@ -8,14 +8,14 @@ ], "properties": { "inclusive": { - "$ref": "#/definitions/Range_Of_double" + "$ref": "#/definitions/Range_of_double" }, "range": { - "$ref": "#/definitions/Range_Of_uint" + "$ref": "#/definitions/Range_of_uint" } }, "definitions": { - "Range_Of_double": { + "Range_of_double": { "type": "object", "required": [ "end", @@ -32,7 +32,7 @@ } } }, - "Range_Of_uint": { + "Range_of_uint": { "type": "object", "required": [ "end", diff --git a/schemars/tests/expected/result.json b/schemars/tests/expected/result.json index 0c3434b..44f7bb0 100644 --- a/schemars/tests/expected/result.json +++ b/schemars/tests/expected/result.json @@ -8,10 +8,10 @@ ], "properties": { "result1": { - "$ref": "#/definitions/Result_Of_MyStruct_Or_Array_Of_String" + "$ref": "#/definitions/Result_of_MyStruct_or_Array_of_String" }, "result2": { - "$ref": "#/definitions/Result_Of_Boolean_Or_Null" + "$ref": "#/definitions/Result_of_Boolean_or_Null" } }, "definitions": { @@ -27,7 +27,7 @@ } } }, - "Result_Of_Boolean_Or_Null": { + "Result_of_Boolean_or_Null": { "oneOf": [ { "type": "object", @@ -53,7 +53,7 @@ } ] }, - "Result_Of_MyStruct_Or_Array_Of_String": { + "Result_of_MyStruct_or_Array_of_String": { "oneOf": [ { "type": "object", diff --git a/schemars/tests/expected/schema-name-custom.json b/schemars/tests/expected/schema-name-custom.json index 4a3668b..04da1f7 100644 --- a/schemars/tests/expected/schema-name-custom.json +++ b/schemars/tests/expected/schema-name-custom.json @@ -1,6 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "title": "a-new-name-Array_Of_String-int32-int32", + "title": "a-new-name-Array_of_String-int32-int32", "type": "object", "required": [ "inner", diff --git a/schemars/tests/expected/schema-name-default.json b/schemars/tests/expected/schema-name-default.json index 46c49f4..4991c91 100644 --- a/schemars/tests/expected/schema-name-default.json +++ b/schemars/tests/expected/schema-name-default.json @@ -1,6 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "title": "MyStruct_For_int32_And_Null_And_Boolean_And_Array_Of_String", + "title": "MyStruct_for_int32_and_Null_and_Boolean_and_Array_of_String", "type": "object", "required": [ "inner", diff --git a/schemars/tests/expected/schema.json b/schemars/tests/expected/schema.json index ef9dd24..1fabd53 100644 --- a/schemars/tests/expected/schema.json +++ b/schemars/tests/expected/schema.json @@ -136,7 +136,7 @@ "items": { "anyOf": [ { - "$ref": "#/definitions/SingleOrVec_For_Schema" + "$ref": "#/definitions/SingleOrVec_for_Schema" }, { "type": "null" @@ -281,7 +281,7 @@ "type": { "anyOf": [ { - "$ref": "#/definitions/SingleOrVec_For_InstanceType" + "$ref": "#/definitions/SingleOrVec_for_InstanceType" }, { "type": "null" @@ -445,7 +445,7 @@ "items": { "anyOf": [ { - "$ref": "#/definitions/SingleOrVec_For_Schema" + "$ref": "#/definitions/SingleOrVec_for_Schema" }, { "type": "null" @@ -590,7 +590,7 @@ "type": { "anyOf": [ { - "$ref": "#/definitions/SingleOrVec_For_InstanceType" + "$ref": "#/definitions/SingleOrVec_for_InstanceType" }, { "type": "null" @@ -609,7 +609,7 @@ }, "additionalProperties": true }, - "SingleOrVec_For_InstanceType": { + "SingleOrVec_for_InstanceType": { "anyOf": [ { "$ref": "#/definitions/InstanceType" @@ -622,7 +622,7 @@ } ] }, - "SingleOrVec_For_Schema": { + "SingleOrVec_for_Schema": { "anyOf": [ { "$ref": "#/definitions/Schema" diff --git a/schemars_derive/src/lib.rs b/schemars_derive/src/lib.rs index 7aaee6e..51cbde3 100644 --- a/schemars_derive/src/lib.rs +++ b/schemars_derive/src/lib.rs @@ -47,8 +47,8 @@ pub fn derive_json_schema(input: proc_macro::TokenStream) -> proc_macro::TokenSt } } else if type_name == schema_base_name { let mut schema_name_fmt = schema_base_name; - schema_name_fmt.push_str("_For_{}"); - schema_name_fmt.push_str(&"_And_{}".repeat(type_params.len() - 1)); + schema_name_fmt.push_str("_for_{}"); + schema_name_fmt.push_str(&"_and_{}".repeat(type_params.len() - 1)); quote! { format!(#schema_name_fmt #(,#type_params::schema_name())*) }