Skip to content

Commit

Permalink
Merge pull request #3 from uzimaru0000/feat/any-of-schema
Browse files Browse the repository at this point in the history
Add support for anyOf schema in flat_schema function
  • Loading branch information
uzimaru0000 authored Dec 29, 2023
2 parents 3dfdc2e + fca523b commit 93959a5
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,20 @@ pub fn flat_schema(

Ok((select, is_required))
}
openapiv3::SchemaKind::AnyOf { any_of } => {
// NOTE: treat oneOf and anyOf the same in input
let any_of = any_of
.iter()
.map(|x| {
let x = x.item(api)?;
let (x, _) = flat_schema(x, api, is_required)?;
Ok(x)
})
.collect::<Result<Vec<_>>>()?;
let select = Select::new("Select any of schema", any_of).prompt()?;

Ok((select, is_required))
}
openapiv3::SchemaKind::AllOf { all_of } => {
let all_of = items(all_of, api)
.map(|x| {
Expand All @@ -241,8 +255,7 @@ pub fn flat_schema(

Ok((SchemaType::Object(obj), is_required))
}
openapiv3::SchemaKind::AnyOf { .. } => todo!("AnyOf"),
openapiv3::SchemaKind::Not { .. } => todo!("Not"),
openapiv3::SchemaKind::Not { .. } => todo!("Not is not supported"),
openapiv3::SchemaKind::Any(_) => todo!("Any"),
}
}
Expand Down

0 comments on commit 93959a5

Please sign in to comment.