Wrapping custom struct with Vec<HashMap> inside into Poem OpenAPI #694
Unanswered
AlexMikhalev
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a struct to return query results to the user:
which I am returning to the user using
with
I tried returning OK(Json(docs)), but in both cases, Poem response had extra slash in front of quotes like:
Which is understandable since it's JSON encoded twice.
But I cant figure out how to output custom struct without manually encoding JSON.
I tried using generic or NewType:
IndexDocument is not
Type
and so we can't implementNewType
forApiIndexedDocument
That is because
IndexedDocument
is notSend
andSync
.We tried
Arc<Mutex<IndexedDocument>>
but that didn't work either becauseMutex
is notType
either and we cannot implement that because of orphan rulesTherefore we manually serialize it with to_string()
Tried:
with Object, NewType etc.
Any suggestions? To reiterate the issue to return Vec of Structs from poem open API. Full code
Beta Was this translation helpful? Give feedback.
All reactions