1
0
Fork 0
mirror of https://gitlab.com/msrd0/gotham-restful.git synced 2025-02-22 20:52:27 +00:00

fix bug: required is now properly populated

This commit is contained in:
Dominic 2019-10-01 18:03:44 +02:00
parent 3427fb4c6f
commit a4185a5665
Signed by: msrd0
GPG key ID: DCC8C247452E98F9

View file

@ -40,17 +40,26 @@ macro_rules! rest_struct {
$(
{
let mut schema = <$field_ty>::to_schema();
if schema.nullable
{
schema.nullable = false;
schema.name = schema.name.map(|name|
if name.ends_with("OrNull") {
name[..(name.len()-6)].to_string()
} else { name });
}
else
{
required.push(stringify!($field_id).to_string());
}
if let Some(name) = schema.name.clone()
{
properties.insert(
stringify!($field_id).to_string(),
ReferenceOr::Reference { reference: format!("#/components/schemas/{}", name) }
);
if schema.nullable
{
required.push(stringify!($field_id).to_string());
schema.nullable = false;
}
dependencies.insert(name, schema);
}
else