-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allowing utoipa/utoipa-swagger-ui successfully build on Windows and made path proc macro attribute more permissive #830
Conversation
Allowed arbitrary expressions to be used in the description field. Now my
However, the change affected only the description of request body. Other fields deserve fair treatment as well. |
Updated #[utoipa::path(
post,
request_body(
content = ElasticModulesForUnidirectionalCompositeArgsMessage,
description = format!(
"Python struct format string: {:?}. See <https://docs.python.org/3/library/struct.html#format-strings>.\n\n\
See schema for the order of the fields (but not their sizes).",
ElasticModulesForUnidirectionalCompositeArgsMessage::py_struct_format_string()
),
content_type = ElasticModulesForUnidirectionalCompositeArgsMessage::content_type(),
example = ElasticModulesForUnidirectionalCompositeArgsMessage::example_as_serde_big_array,
),
responses (
(
status = 200,
description = "Computes elastic_modules_for_unidirectional_composite. \
Returns the binary representation of [E1, E2, E3, nu12, nu13, nu23, G12, G13, G23] with the requested endianness.\n\n\
Python struct format string: \"ddddddddd\". See <https://docs.python.org/3/library/struct.html#format-strings>.",
body = ElasticModulesForUnidirectionalCompositeResponseMessage,
content_type = "application/x.elastic-modules-for-unidirectional-composite-response-message"
),
)
)]
#[post("/compute/elastic_modules_for_unidirectional_composite")]
async fn elastic_modules_for_unidirectional_composite(
args: ElasticModulesForUnidirectionalCompositeArgsMessage,
) -> impl Responder {
//...
} |
…_type of reponse(s) of this type
Updated path:
|
…sponse description be of this type
|
utoipa/utoipa-swagger-ui
successfully build on Windows and allowed any AnyValue
for example
fieldThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, this is is a good relaxing of the restrictions of the path
macro.
I'm using
utoipa
for documentation of a custom binary protocol which is used for communication between a server and client applications.P.S.
Custom content type had to be used because swagger UI does not display examples for content type
application/octet-stream
.Allowing
utoipa/utoipa-swagger-ui
successfully build on WindowsOn Windows,
\
is a part of path and using it in Rust string makes the following character act as an escape character. For correct behavior on Windows, raw string literal syntax must be used instead.Allowing any AnyValue for example field
While documenting the web server, I realized that I can use only
json!
macro anexample
(and I doubt that this restriction was necessary because the only requirement for the type is that it has to implementserde::se::Serialize
). Even though I can usejson!
macro with a copy-pastedu8
array, it is not ideal.Currently, my
utoipa::path
attribute looks like this:and I'm planning to tinker with
utoipa
more to have less boilerplate.