ProbablyClem / utoipauto

Rust Macros to automate the addition of Paths/Schemas to Utoipa crate, simulating Reflection during the compilation phase
Apache License 2.0
108 stars 10 forks source link

Allow macro inputs from workspace crates inside nested folders #8

Closed domenicquirl closed 7 months ago

domenicquirl commented 7 months ago

Fixes #7 with the first approach described in https://github.com/ProbablyClem/utoipauto/issues/7#issuecomment-1888588610.

This actually turned out to simplify the path conversion, as before allowing a single level of nesting was special-cased by replacing the first path segment with crate. The new algorithm no longer requires this, as it just replaces everything up to /src.

I've had to adjust the tests for the extract_module_name_from_path to match the new behaviour, but I have verified that the top-level tests still compile unchanged. I've also patched in my branch into my project and can confirm that it resolves my issue in #7 and that the macro outputs the same paths as I had manually specified.

In addition to the fix, I've taken the liberty to touch up some of the other macro functions with the same small clean-ups that I made to extract_module_name_from_path in a separate commit. Feel free to tell me off on that, I can rebase with only the first commit if you prefer.

ProbablyClem commented 7 months ago

Thanks for your contribution, I will make a new release

domenicquirl commented 7 months ago

Lovely, tysm!