Skip to content
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

#[derive(utoipa::ToSchema)] detection fails #23

Closed
bengsparks opened this issue Apr 16, 2024 · 6 comments
Closed

#[derive(utoipa::ToSchema)] detection fails #23

bengsparks opened this issue Apr 16, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@bengsparks
Copy link

bengsparks commented Apr 16, 2024

It seems the detection of utoipa::ToSchema is buggy.
I have uploaded an MRE here that I invite you to try out at your convenience.

Generating and comparing both openapi.working.yaml and openapi.broken.yaml indicate that the latter is missing the schema for the Person struct, whereas the former includes it.

$ diff src/broken.rs src/working.rs -U1000

--- src/broken.rs       2024-04-16 14:53:32
+++ src/working.rs      2024-04-16 14:53:35
@@ -1,19 +1,19 @@
-use utoipa::OpenApi;
+use utoipa::{OpenApi, ToSchema};
 use utoipauto;
 
-#[derive(utoipa::ToSchema)]
+#[derive(ToSchema)]
 pub struct Person {
     /// Id of person
     id: i64,
     /// Name of person
     name: String,
 }
 
 pub fn gen_my_openapi() -> String {
-    #[utoipauto::utoipauto(paths = "./src/broken.rs")]
+    #[utoipauto::utoipauto(paths = "./src/working.rs")]
     #[derive(OpenApi)]
     #[openapi()]
     struct ApiDoc;
 
     ApiDoc::openapi().to_pretty_json().unwrap()
 }

It seems the discovery mechanism of utoipauto fails to account for the fully qualified reference to utoipa::ToSchema, and only matches on ToSchema.
I suspect the issue lies somewhere here?
I also assume the same bug affects discovery of utoipa::ToResponse

@squadgazzz
Copy link

@ProbablyClem
Copy link
Owner

Should be fixed in the new 0.1.11 release
Does it work ?

@ProbablyClem ProbablyClem added the bug Something isn't working label May 17, 2024
@leelhn2345
Copy link

Should be fixed in the new 0.1.11 release Does it work ?

Hi, are you asking if the new 0.1.11 release works?
According to crates.io, the latest version of this crate is still 0.1.10

@DenuxPlays
Copy link
Collaborator

Should be fixed in the new 0.1.11 release Does it work ?

Hi, are you asking if the new 0.1.11 release works? According to crates.io, the latest version of this crate is still 0.1.10

v0.1.11 is now availble on crates.io
Does it work?

@bengsparks
Copy link
Author

Rebuilding my MRE repo with v0.1.11 looks good on my end; thanks very much

@DenuxPlays
Copy link
Collaborator

@ProbablyClem I think this can be closed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants