You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I have a question regarding the response body. My API endpoint, which I created with actix-web, returns either struct a or struct b. Is there a way to model this with utoipa? I would need something like OneOf. Unfortunately I have not found an example in the docs. The code block is about lines 5 and 6.
#[utoipa::path( get, path = "/api/v1/app/{id}", responses((status = 200, description = "struct a", body = StructA),(status = 200, description = "struct b", body = StructB),(status = 400, description = "No valid ID", body = String, example = json!(["no valid id"])),(status = 500, description = "Internal Server Error"),(status = NOT_FOUND, description= "ID was not found", example = json!(["no id found"]))), params(("id" = String, description = "id")))]
Is there a way I can tell swagger to return either struct a or struct b?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, I have a question regarding the response body. My API endpoint, which I created with actix-web, returns either struct a or struct b. Is there a way to model this with utoipa? I would need something like OneOf. Unfortunately I have not found an example in the docs. The code block is about lines 5 and 6.
Is there a way I can tell swagger to return either struct a or struct b?
Beta Was this translation helpful? Give feedback.
All reactions