Skip to content

Commit

Permalink
Correct with_schema to schema_with in docs (juhaku#586)
Browse files Browse the repository at this point in the history
Also consistently use "schema with" in code, renaming
`Property::WithSchema` to `Property::SchemaWith`.
  • Loading branch information
jayvdb authored Apr 17, 2023
1 parent d007625 commit b59ee09
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions utoipa-gen/src/component/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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(),
}
Expand Down
10 changes: 5 additions & 5 deletions utoipa-gen/src/component/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions utoipa-gen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<RefOr<Schema>>`. It does
/// not accept arguments and must return anything that can be converted into `RefOr<Schema>`.
/// * `additional_properties = ...` Can be used to define free form types for maps such as
Expand Down Expand Up @@ -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<RefOr<Schema>>`. It does
/// not accept arguments and must return anything that can be converted into `RefOr<Schema>`.
///
Expand Down
6 changes: 3 additions & 3 deletions utoipa-gen/tests/schema_derive_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down

0 comments on commit b59ee09

Please sign in to comment.