-
Notifications
You must be signed in to change notification settings - Fork 10
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
Detecting ToSchema
fails when behind a cfg_attr
flag
#13
Comments
Oh, thinking about this more, since the detection is done via the macro I'm guessing it might run before the |
From this https://stackoverflow.com/a/42551386, it seems that #[cfg_attr(feature = "openapi", derive(ToSchema))] is the same as derive(ToSchema) if the openapi flag is enabled. There is probably a solution to this but I don't know how to fix it yet... |
Also: |
I was about to submit an issue for this… guess I'm stuck like you 😕 Has anyone found a solution/workaround? |
It doesn't look good… I found rust-lang/rust-analyzer#13360 which mentions no solution… |
I think this is doable.
|
This could work to remove a struct from the spec, but this wouldn't remove the compile time cost of the macro I believe... |
No the macro would take the same amount of time and resources regardless if a feature is active or not. But AFAIK we cannot get whether a feature is activated or not from a macro. |
Hi! 👋
I'm playing around with this crate and ran into an issue where schemas (and I'm guessing paths) aren't detected when behind a
cfg_attr
flag. E.g:Works:
Doesn't work:
Essentially, my use case is to only generate the OpenAPI spec when writing it to a file in my CI step, and I don't want to have to compile all my
utoipa
macros when running the webserver normally.Thanks for the library, it's really nice!
The text was updated successfully, but these errors were encountered: