Make prepositions/conjunctions in generated schema names lowercase
This commit is contained in:
parent
09d76c93e4
commit
60bfc6ee49
14 changed files with 30 additions and 30 deletions
|
@ -7,7 +7,7 @@ impl<T> JsonSchema for [T; 0] {
|
||||||
no_ref_schema!();
|
no_ref_schema!();
|
||||||
|
|
||||||
fn schema_name() -> String {
|
fn schema_name() -> String {
|
||||||
"Empty_Array".to_owned()
|
"EmptyArray".to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn json_schema(_: &mut SchemaGenerator) -> Schema {
|
fn json_schema(_: &mut SchemaGenerator) -> Schema {
|
||||||
|
@ -30,7 +30,7 @@ macro_rules! array_impls {
|
||||||
no_ref_schema!();
|
no_ref_schema!();
|
||||||
|
|
||||||
fn schema_name() -> String {
|
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 {
|
fn json_schema(gen: &mut SchemaGenerator) -> Schema {
|
||||||
|
|
|
@ -76,7 +76,7 @@ fn with_null_type(mut obj: SchemaObject) -> SchemaObject {
|
||||||
|
|
||||||
impl<T: JsonSchema, E: JsonSchema> JsonSchema for Result<T, E> {
|
impl<T: JsonSchema, E: JsonSchema> JsonSchema for Result<T, E> {
|
||||||
fn schema_name() -> String {
|
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 {
|
fn json_schema(gen: &mut SchemaGenerator) -> Schema {
|
||||||
|
@ -102,7 +102,7 @@ impl<T: JsonSchema, E: JsonSchema> JsonSchema for Result<T, E> {
|
||||||
|
|
||||||
impl<T: JsonSchema> JsonSchema for Range<T> {
|
impl<T: JsonSchema> JsonSchema for Range<T> {
|
||||||
fn schema_name() -> String {
|
fn schema_name() -> String {
|
||||||
format!("Range_Of_{}", T::schema_name())
|
format!("Range_of_{}", T::schema_name())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn json_schema(gen: &mut SchemaGenerator) -> Schema {
|
fn json_schema(gen: &mut SchemaGenerator) -> Schema {
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::ffi::{CStr, CString, OsStr, OsString};
|
||||||
|
|
||||||
impl JsonSchema for OsString {
|
impl JsonSchema for OsString {
|
||||||
fn schema_name() -> String {
|
fn schema_name() -> String {
|
||||||
"OS_String".to_owned()
|
"OsString".to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn json_schema(gen: &mut SchemaGenerator) -> Schema {
|
fn json_schema(gen: &mut SchemaGenerator) -> Schema {
|
||||||
|
|
|
@ -12,7 +12,7 @@ macro_rules! map_impl {
|
||||||
no_ref_schema!();
|
no_ref_schema!();
|
||||||
|
|
||||||
fn schema_name() -> String {
|
fn schema_name() -> String {
|
||||||
format!("Map_Of_{}", V::schema_name())
|
format!("Map_of_{}", V::schema_name())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn json_schema(gen: &mut SchemaGenerator) -> Schema {
|
fn json_schema(gen: &mut SchemaGenerator) -> Schema {
|
||||||
|
|
|
@ -11,7 +11,7 @@ macro_rules! seq_impl {
|
||||||
no_ref_schema!();
|
no_ref_schema!();
|
||||||
|
|
||||||
fn schema_name() -> String {
|
fn schema_name() -> String {
|
||||||
format!("Array_Of_{}", T::schema_name())
|
format!("Array_of_{}", T::schema_name())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn json_schema(gen: &mut SchemaGenerator) -> Schema {
|
fn json_schema(gen: &mut SchemaGenerator) -> Schema {
|
||||||
|
|
|
@ -8,7 +8,7 @@ impl JsonSchema for Value {
|
||||||
no_ref_schema!();
|
no_ref_schema!();
|
||||||
|
|
||||||
fn schema_name() -> String {
|
fn schema_name() -> String {
|
||||||
"Any_Value".to_owned()
|
"AnyValue".to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn json_schema(gen: &mut SchemaGenerator) -> Schema {
|
fn json_schema(gen: &mut SchemaGenerator) -> Schema {
|
||||||
|
|
|
@ -9,7 +9,7 @@ macro_rules! tuple_impls {
|
||||||
no_ref_schema!();
|
no_ref_schema!();
|
||||||
|
|
||||||
fn schema_name() -> String {
|
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 {
|
fn json_schema(gen: &mut SchemaGenerator) -> Schema {
|
||||||
|
|
|
@ -8,14 +8,14 @@
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"borrowed": {
|
"borrowed": {
|
||||||
"$ref": "#/definitions/OS_String"
|
"$ref": "#/definitions/OsString"
|
||||||
},
|
},
|
||||||
"owned": {
|
"owned": {
|
||||||
"$ref": "#/definitions/OS_String"
|
"$ref": "#/definitions/OsString"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"OS_String": {
|
"OsString": {
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
|
|
@ -8,14 +8,14 @@
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"inclusive": {
|
"inclusive": {
|
||||||
"$ref": "#/definitions/Range_Of_double"
|
"$ref": "#/definitions/Range_of_double"
|
||||||
},
|
},
|
||||||
"range": {
|
"range": {
|
||||||
"$ref": "#/definitions/Range_Of_uint"
|
"$ref": "#/definitions/Range_of_uint"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"Range_Of_double": {
|
"Range_of_double": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"end",
|
"end",
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Range_Of_uint": {
|
"Range_of_uint": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"end",
|
"end",
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"result1": {
|
"result1": {
|
||||||
"$ref": "#/definitions/Result_Of_MyStruct_Or_Array_Of_String"
|
"$ref": "#/definitions/Result_of_MyStruct_or_Array_of_String"
|
||||||
},
|
},
|
||||||
"result2": {
|
"result2": {
|
||||||
"$ref": "#/definitions/Result_Of_Boolean_Or_Null"
|
"$ref": "#/definitions/Result_of_Boolean_or_Null"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"definitions": {
|
"definitions": {
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Result_Of_Boolean_Or_Null": {
|
"Result_of_Boolean_or_Null": {
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"Result_Of_MyStruct_Or_Array_Of_String": {
|
"Result_of_MyStruct_or_Array_of_String": {
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
"$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",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"inner",
|
"inner",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
"$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",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"inner",
|
"inner",
|
||||||
|
|
|
@ -136,7 +136,7 @@
|
||||||
"items": {
|
"items": {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/SingleOrVec_For_Schema"
|
"$ref": "#/definitions/SingleOrVec_for_Schema"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "null"
|
"type": "null"
|
||||||
|
@ -281,7 +281,7 @@
|
||||||
"type": {
|
"type": {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/SingleOrVec_For_InstanceType"
|
"$ref": "#/definitions/SingleOrVec_for_InstanceType"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "null"
|
"type": "null"
|
||||||
|
@ -445,7 +445,7 @@
|
||||||
"items": {
|
"items": {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/SingleOrVec_For_Schema"
|
"$ref": "#/definitions/SingleOrVec_for_Schema"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "null"
|
"type": "null"
|
||||||
|
@ -590,7 +590,7 @@
|
||||||
"type": {
|
"type": {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/SingleOrVec_For_InstanceType"
|
"$ref": "#/definitions/SingleOrVec_for_InstanceType"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "null"
|
"type": "null"
|
||||||
|
@ -609,7 +609,7 @@
|
||||||
},
|
},
|
||||||
"additionalProperties": true
|
"additionalProperties": true
|
||||||
},
|
},
|
||||||
"SingleOrVec_For_InstanceType": {
|
"SingleOrVec_for_InstanceType": {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/InstanceType"
|
"$ref": "#/definitions/InstanceType"
|
||||||
|
@ -622,7 +622,7 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"SingleOrVec_For_Schema": {
|
"SingleOrVec_for_Schema": {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/Schema"
|
"$ref": "#/definitions/Schema"
|
||||||
|
|
|
@ -47,8 +47,8 @@ pub fn derive_json_schema(input: proc_macro::TokenStream) -> proc_macro::TokenSt
|
||||||
}
|
}
|
||||||
} else if type_name == schema_base_name {
|
} else if type_name == schema_base_name {
|
||||||
let mut schema_name_fmt = schema_base_name;
|
let mut schema_name_fmt = schema_base_name;
|
||||||
schema_name_fmt.push_str("_For_{}");
|
schema_name_fmt.push_str("_for_{}");
|
||||||
schema_name_fmt.push_str(&"_And_{}".repeat(type_params.len() - 1));
|
schema_name_fmt.push_str(&"_and_{}".repeat(type_params.len() - 1));
|
||||||
quote! {
|
quote! {
|
||||||
format!(#schema_name_fmt #(,#type_params::schema_name())*)
|
format!(#schema_name_fmt #(,#type_params::schema_name())*)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue