From b59ee09584b3fd986001db6e79f93902a18cc2e1 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Mon, 17 Apr 2023 16:15:35 +0800 Subject: [PATCH] Correct `with_schema` to `schema_with` in docs (#586) Also consistently use "schema with" in code, renaming `Property::WithSchema` to `Property::SchemaWith`. --- utoipa-gen/src/component/features.rs | 10 +++++----- utoipa-gen/src/component/schema.rs | 10 +++++----- utoipa-gen/src/lib.rs | 4 ++-- utoipa-gen/tests/schema_derive_test.rs | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/utoipa-gen/src/component/features.rs b/utoipa-gen/src/component/features.rs index 03ec5f5b..ec7f1cbb 100644 --- a/utoipa-gen/src/component/features.rs +++ b/utoipa-gen/src/component/features.rs @@ -209,7 +209,7 @@ impl ToTokens for Feature { Feature::MinProperties(min_properties) => { quote! { .max_properties(Some(#min_properties)) } } - Feature::SchemaWith(with_schema) => with_schema.to_token_stream(), + Feature::SchemaWith(schema_with) => schema_with.to_token_stream(), Feature::Description(description) => quote! { .description(Some(#description)) }, Feature::Deprecated(deprecated) => quote! { .deprecated(Some(#deprecated)) }, Feature::AdditionalProperties(additional_properties) => { @@ -284,7 +284,7 @@ impl Display for Feature { Feature::MinItems(min_items) => min_items.fmt(f), Feature::MaxProperties(max_properties) => max_properties.fmt(f), Feature::MinProperties(min_properties) => min_properties.fmt(f), - Feature::SchemaWith(with_schema) => with_schema.fmt(f), + Feature::SchemaWith(schema_with) => schema_with.fmt(f), Feature::Description(description) => description.fmt(f), Feature::Deprecated(deprecated) => deprecated.fmt(f), Feature::As(as_feature) => as_feature.fmt(f), @@ -326,12 +326,12 @@ impl Validatable for Feature { Feature::MinItems(min_items) => min_items.is_validatable(), Feature::MaxProperties(max_properties) => max_properties.is_validatable(), Feature::MinProperties(min_properties) => min_properties.is_validatable(), - Feature::SchemaWith(with_schema) => with_schema.is_validatable(), + Feature::SchemaWith(schema_with) => schema_with.is_validatable(), Feature::Description(description) => description.is_validatable(), Feature::Deprecated(deprecated) => deprecated.is_validatable(), Feature::As(as_feature) => as_feature.is_validatable(), - Feature::AdditionalProperties(additional_properites) => { - additional_properites.is_validatable() + Feature::AdditionalProperties(additional_properties) => { + additional_properties.is_validatable() } Feature::Required(required) => required.is_validatable(), } diff --git a/utoipa-gen/src/component/schema.rs b/utoipa-gen/src/component/schema.rs index ab0517c6..81ef5cf6 100644 --- a/utoipa-gen/src/component/schema.rs +++ b/utoipa-gen/src/component/schema.rs @@ -347,14 +347,14 @@ impl NamedStructSchema<'_> { .as_ref() .map(|value_type| value_type.as_type_tree()); let comments = CommentAttributes::from_attributes(&field.attrs); - let with_schema = pop_feature!(field_features => Feature::SchemaWith(_)); + let schema_with = pop_feature!(field_features => Feature::SchemaWith(_)); let required = pop_feature_as_inner!(field_features => Feature::Required(_v)); let type_tree = override_type_tree.as_ref().unwrap_or(type_tree); let is_option = type_tree.is_option(); yield_(NamedStructFieldOptions { - property: if let Some(with_schema) = with_schema { - Property::WithSchema(with_schema) + property: if let Some(schema_with) = schema_with { + Property::SchemaWith(schema_with) } else { Property::Schema(ComponentSchema::new(super::ComponentSchemaProps { type_tree, @@ -1449,14 +1449,14 @@ struct TypeTuple<'a, T>(T, &'a Ident); #[cfg_attr(feature = "debug", derive(Debug))] enum Property { Schema(ComponentSchema), - WithSchema(Feature), + SchemaWith(Feature), } impl ToTokens for Property { fn to_tokens(&self, tokens: &mut TokenStream) { match self { Self::Schema(schema) => schema.to_tokens(tokens), - Self::WithSchema(with_schema) => with_schema.to_tokens(tokens), + Self::SchemaWith(schema_with) => schema_with.to_tokens(tokens), } } } diff --git a/utoipa-gen/src/lib.rs b/utoipa-gen/src/lib.rs index 7ed7a7ab..64f47c47 100644 --- a/utoipa-gen/src/lib.rs +++ b/utoipa-gen/src/lib.rs @@ -173,7 +173,7 @@ use self::{ /// be non-negative integer. /// * `min_items = ...` Can be used to define minimum items allowed for `array` fields. Value must /// be non-negative integer. -/// * `with_schema = ...` Use _`schema`_ created by provided function reference instead of the +/// * `schema_with = ...` Use _`schema`_ created by provided function reference instead of the /// default derived _`schema`_. The function must match to `fn() -> Into>`. It does /// not accept arguments and must return anything that can be converted into `RefOr`. /// * `additional_properties = ...` Can be used to define free form types for maps such as @@ -1700,7 +1700,7 @@ pub fn openapi(input: TokenStream) -> TokenStream { /// * `min_items = ...` Can be used to define minimum items allowed for `array` fields. Value must /// be non-negative integer. /// -/// * `with_schema = ...` Use _`schema`_ created by provided function reference instead of the +/// * `schema_with = ...` Use _`schema`_ created by provided function reference instead of the /// default derived _`schema`_. The function must match to `fn() -> Into>`. It does /// not accept arguments and must return anything that can be converted into `RefOr`. /// diff --git a/utoipa-gen/tests/schema_derive_test.rs b/utoipa-gen/tests/schema_derive_test.rs index 31d26fac..058e7ffd 100644 --- a/utoipa-gen/tests/schema_derive_test.rs +++ b/utoipa-gen/tests/schema_derive_test.rs @@ -1019,9 +1019,9 @@ fn derive_complex_enum_with_schema_properties() { let value: Value = api_doc! { /// This is the description #[derive(Serialize)] - #[schema(example = json!(EnumWithProperites::Variant2{name: String::from("foobar")}), - default = json!(EnumWithProperites::Variant{id: String::from("1")}))] - enum EnumWithProperites { + #[schema(example = json!(EnumWithProperties::Variant2{name: String::from("foobar")}), + default = json!(EnumWithProperties::Variant{id: String::from("1")}))] + enum EnumWithProperties { Variant { id: String },