-
Notifications
You must be signed in to change notification settings - Fork 68
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
feat(aide): add axum_typed_multipart integration #111
Conversation
Looks great, thank you ! The issue with implementing interop between libraries is that inevitably the up to date version will clash with the implemented version. We had massive issues when a major version changed for axum and sqlx. Would that be ok for you ? |
Sure, shouldn't be a problem. |
* rename `ApiFieldData` to `FieldData` * pass down `FromRequest` trait impl to `TypedMultipart` * fix missing async_trait * reorder structs and trait impls
Looks good to me ! You may want to create your own proc macro based on the axum one if you wish to truly document all the different aspects. However just having the general type for most cases is good enough, i would accept it as-is and allow for future expansion as the need arises in your usecase. It's up to you. |
Yes, I have been considering using a macro to document the encoding, but I am very inexperienced in authoring macros. Let me explore this a bit and follow up with a new PR. For the time being I think this is sufficient for 0.1.0. |
Not yet, i have a tight deadline at the moment. |
…#111) * feat(aide): add axum_typed_multipart integration * remove unused import & format toml * move aide-axum-typed-multipart to subcrate * add `FromRequest` impl & refactor * rename `ApiFieldData` to `FieldData` * pass down `FromRequest` trait impl to `TypedMultipart` * fix missing async_trait * reorder structs and trait impls * docs: summary and example * docs: `TypedMultipart` and `FieldData` wrappers * docs: add `aide-axum-typed-multipart` to README.md * docs: beautified README.md * add cliff * chore(aide-axum-typed-multipart): update changelog * remove changelog
Oops I broke the tests, I forgot that Rust runs code blocks in docstrings. Will fix in a new PR. |
i fixed it, no worries. published |
Is there a way to validate the file extension like you did for file limit. For instance, if I want to take only png or pdf files, how do I do it ? |
I think checking the file extension is perfectly fine. You could also check the |
Ooh got it, Thankss! |
Currently, aide generates a very generic schema from the multipart extractor:
This is impossible to fix with vanilla axum, as it only provides a plain
Multipart
extractor which imperatively reads the fields without providing types beyond that.This PR adds integration for https://github.com/murar8/axum_typed_multipart, which provides a fully typed multipart extractor.
Example
generates
and the schemas
Still not great
The image input, represented in Rust as
axum::body::Bytes
serialises toArray_of_uint8
JsonSchema as implemented in schemars with the bytes feature enabled, but OpenAPI offers more advanced options to specify this.The current state of this PR does not yet cover Encoding Objects, which allow something like this:
Tasks
I can see multiple directions to design such an API, but I would prefer to discuss this before I implement something in a bad direction, which is why I created this draft PR.
Feedback is much appreciated.