OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.75k stars 6.56k forks source link

[BUG][rust-axum] Doc tests fail due to invalid should_panic attribute #19538

Open faro-dr opened 1 month ago

faro-dr commented 1 month ago

Bug Report Checklist

Description

Doc tests of code generated with rust-axum generator fail since Rust 1.80.0 because of a bug in modules/openapi-generator/src/main/resources/rust-axum/types.mustache

openapi-generator version

7.8.0

Not a regression I think but the Rust toolchain has become more restrictive (it didn't fail with Rust 1.77.1)

OpenAPI declaration file content or url

Not applicable

Generation Details
$openapi_cli generate \
        -i "${api_spec}" \
        -o "${out_dir}" \
        -g rust-axum \
        --additional-properties=packageName="$package_name" \
        --name-mappings type=type_property \
        --openapi-normalizer FILTER="operationId:${route_filter}"
Steps to reproduce

Generate rust-axum, execute cargo test

Related issues/PRs

Didn't find anytghin

Suggest a fix
--- a/openapi-generator/templates/rust-axum/types.mustache
+++ b/openapi-generator/templates/rust-axum/types.mustache
@@ -175,7 +175,7 @@ impl<T> Nullable<T> {
     /// assert_eq!(x.expect("the world is ending"), "value");
     /// ```
     ///
-    /// ```{.should_panic}
+    /// ```should_panic
     /// # use {{{externCrateName}}}::types::Nullable;
     ///
     /// let x: Nullable<&str> = Nullable::Null;
@@ -210,7 +210,7 @@ impl<T> Nullable<T> {
     /// assert_eq!(x.unwrap(), "air");
     /// ```
     ///
-    /// ```{.should_panic}
+    /// ```should_panic
     /// # use {{{externCrateName}}}::types::Nullable;
     ///
     /// let x: Nullable<&str> = Nullable::Null;

I'll create a pull request

faro-dr commented 1 month ago

Pull request: https://github.com/OpenAPITools/openapi-generator/pull/19539/commits