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

Add caution on export rule #273

Merged
merged 2 commits into from
Sep 8, 2022
Merged

Add caution on export rule #273

merged 2 commits into from
Sep 8, 2022

Conversation

komi1230
Copy link
Contributor

@komi1230 komi1230 commented Sep 8, 2022

Hello,

Thank you for developing such an awesome project.
I'm developing an application with Rust and Axum and I've found this crate is very helpful for documenting API spec.

When I started to use utoipa, I was stuck in how to export handler function since I put the handler function in different file and exported this.
And finally I solved this with exporting a function named with __path_ suffix.

When developing a big project, many people can split modules and cut off handler function in different file.
So I think this message would be very helpful for those people.

Thank you checking !

@juhaku
Copy link
Owner

juhaku commented Sep 8, 2022

Yeah, indeed, the handler with path macro and essentially the __path_ prefixed struct implementing the path for the handler need to be visible to the OpenApi trait to register them. There is planned effort to improve this a bit for bigger projects wherein people tend to split the functionality to separate modules. By allowing users to define multiple OpenApi trait implementing structs and merge them in root level. This way developers only need to export the struct to the root and can leave the implementation private to the module.

There already are people doing so but currently there is no built in support for this. There is an existing discussion related to this might be worth linking here: #208

Copy link
Owner

@juhaku juhaku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is 👌 Just a minor edit to the text 🙂

README.md Outdated Show resolved Hide resolved
Co-authored-by: Juha Kukkonen <juha7kukkonen@gmail.com>
Copy link
Owner

@juhaku juhaku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome 👍

@komi1230
Copy link
Contributor Author

komi1230 commented Sep 8, 2022

Thank you for quick review !

@juhaku juhaku merged commit b5c3327 into juhaku:master Sep 8, 2022
@juhaku
Copy link
Owner

juhaku commented Sep 8, 2022

Thank you for quick review !

Anytime 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants