internal docs in `api.json`?
y-haidar opened this issue · 7 comments
I was playing around with aide, and trying different things, then I noticed this issue. I tried aide = { version = "=0.13.0" ...
still the same. Though, this is not happening with the example that aide provided, my code is not that much different.
here is the full generated file: api.json
screen shot
0.13.0 is bugged IIRC, see changelog, please use 0.13, 1.13.1, or 0.13.2
@Wicpar but I was using version 0.13.2. Did cargo clean and got Compiling aide v0.13.2
I can still see this issue coming up.
I found it. The .into_response()
call stopped Json
from generating docs for OpenApi
struct. I was wrong about "internal docs" being extracted.
My code:
async fn serve_docs(Extension(api): Extension<Arc<OpenApi>>) -> impl IntoApiResponse {
Json(api)
}
Aide example:
async fn serve_docs(Extension(api): Extension<Arc<OpenApi>>) -> impl IntoApiResponse {
Json(api).into_response()
}
Honestly, don't you see that there is a problem here? Yes I may be stupid, but I meant, the example/documentation is way too fragile, and bad. How am I supposed to know that into_response()
would prevent the output from being generated?
Oh, i will investigate it, can you make a minimal example?
@Wicpar These is no problem, it was my mistake. Thank you and sorry for your time.
The code I was talking about is this:
aide/examples/example-axum/src/docs.rs
Lines 56 to 58 in 6a3ca01
Closing.
but I meant, the example/documentation is way too fragile, and bad. How am I supposed to know that into_response() would prevent the output from being generated?
impl IntoApiResponse
hides the actual response type, Json<OpenApi>
and Response
are two different types. Axum's Response
also implements IntoApiResponse
but does not add any information, whereas Json<OpenApi>
includes the schema of OpenApi
itself like in your example.
impl Into*Response
is used in the examples as it is used in Axum's examples as well, but I believe explicit types should be always preferred when possible (even without aide
).