Skip to content

Commit

Permalink
schema: support empty QueryMsg in QueryResponses
Browse files Browse the repository at this point in the history
  • Loading branch information
uint committed Sep 5, 2022
1 parent e517a8e commit 0f3609c
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions packages/schema/src/query_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,24 @@ fn check_api_integrity<T: QueryResponses + ?Sized>(

// something more readable below?

let schema_queries: BTreeSet<_> = schema
.schema
.subschemas
.ok_or(IntegrityError::InvalidQueryMsgSchema)?
.one_of
.ok_or(IntegrityError::InvalidQueryMsgSchema)?
.into_iter()
.map(|s| {
s.into_object()
.object
.ok_or(IntegrityError::InvalidQueryMsgSchema)?
.required
.into_iter()
.next()
.ok_or(IntegrityError::InvalidQueryMsgSchema)
})
.collect::<Result<_, _>>()?;
let schema_queries: BTreeSet<_> = match schema.schema.subschemas {
Some(subschemas) => subschemas
.one_of
.ok_or(IntegrityError::InvalidQueryMsgSchema)?
.into_iter()
.map(|s| {
s.into_object()
.object
.ok_or(IntegrityError::InvalidQueryMsgSchema)?
.required
.into_iter()
.next()
.ok_or(IntegrityError::InvalidQueryMsgSchema)
})
.collect::<Result<_, _>>()?,
None => BTreeSet::new(),
};

if schema_queries != generated_queries {
return Err(IntegrityError::InconsistentQueries {
query_msg: schema_queries,
Expand Down

0 comments on commit 0f3609c

Please sign in to comment.