Skip to content

Commit

Permalink
Enable required usage with schema_with attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislearn committed Nov 27, 2023
1 parent 1f79496 commit a5ceada
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions crates/oapi-macros/src/schema/struct_schemas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,15 @@ impl ToTokens for NamedStructSchema<'_> {
.property(#name, #property)
});

if let Property::Schema(_) = property {
if (!is_option && crate::is_required(field_rule.as_ref(), container_rules.as_ref()))
|| required
.as_ref()
.map(crate::feature::Required::is_true)
.unwrap_or(false)
{
object_tokens.extend(quote! {
.required(#name)
})
}
if (!is_option && crate::is_required(field_rule.as_ref(), container_rules.as_ref()))
|| required
.as_ref()
.map(crate::feature::Required::is_true)
.unwrap_or(false)
{
object_tokens.extend(quote! {
.required(#name)
})
}

object_tokens
Expand Down

0 comments on commit a5ceada

Please sign in to comment.