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
Everything in the docstring to be visible in the resulting openapi document, similar to how it is shown in cargo doc.
This unfortunately makes it hard to use doctests or include a string literal used in another test in the generated docs to ensure they're kept up-to-date. Which in my opinion would be a big benefit of putting the api specification in the rust code in the first place.
Note that so far I was not able to get code_sample(lang = "rust", source = "examples::JSON_WITNESS") to show up in the generated swagger UI either, which was my first attempt at adding additional information that is also checked with cargo test.
Actual Behavior
Code
openapi
cargo doc
rust_analyzer
/// Something
Yes
Yes
Yes
#[doc = "Test 123"]
No Yes
Yes
Yes
#[doc = include_str!("../../README.md")]
No
Yes
No
Doctests
As written, not hiding lines starting with #
Yes
Yes
In cargo doc
I've had to use a separate struct because the openapi type wasn't added to cargo doc due to being private.
In the swagger UI
Steps to Reproduce the Problem
Use the OpenApi macro, add a method to it and add the following docstring:
/// Retrieve previously stored key material
///
/// This also returns the access control list
///
/// ### Example value (before encryption and base64 encoding)
#[doc = include_str!("../../README.md")]
#[doc = "Test 123"]
///
/// ### Attempt 2
/// ```
/// println!("Hello");
/// # todo!();
/// println!("World")
/// ```
#[oai(
path = "/session/:session_id/keys/:id",
method = "get",
tag = Tags::KeyManagement
)]
async fn get_key(
// ...
Run cargo doc to see the results it generates
Run a binary with this API and the swagger UI enabled
Have a look at the description in the swagger UI (see screenshots)
Specifications
Version: 4.0.0
Platform: Linux
Subsystem: poem-openapi
The text was updated successfully, but these errors were encountered:
DragonDev1906
changed the title
<Title>
Doctests and #[doc = "string"] not visible in swagger UI
Feb 6, 2024
DragonDev1906
changed the title
Doctests and #[doc = "string"] not visible in swagger UI
Doctests not displayed correctly and #[doc = "string"] not visible in swagger UI
Feb 6, 2024
Expected Behavior
Everything in the docstring to be visible in the resulting openapi document, similar to how it is shown in
cargo doc
.This unfortunately makes it hard to use doctests or include a string literal used in another test in the generated docs to ensure they're kept up-to-date. Which in my opinion would be a big benefit of putting the api specification in the rust code in the first place.
Note that so far I was not able to get
code_sample(lang = "rust", source = "examples::JSON_WITNESS")
to show up in the generated swagger UI either, which was my first attempt at adding additional information that is also checked withcargo test
.Actual Behavior
/// Something
#[doc = "Test 123"]
NoYes#[doc = include_str!("../../README.md")]
#
In
cargo doc
I've had to use a separate struct because the openapi type wasn't added to cargo doc due to being private.
In the swagger UI
Steps to Reproduce the Problem
OpenApi
macro, add a method to it and add the following docstring:cargo doc
to see the results it generatesSpecifications
The text was updated successfully, but these errors were encountered: