Added support for a trait based reqwest Rust client#19788
Added support for a trait based reqwest Rust client#19788wing328 merged 7 commits intoOpenAPITools:masterfrom
Conversation
|
not related to this change |
| {{/reqwestTrait}} | ||
|
|
||
| [features] | ||
| {{#mockall}} |
There was a problem hiding this comment.
what about putting [features] inside the mockall mustache tags?
There was a problem hiding this comment.
@wing328 I thought about that originally, but figured it would be easier to always add [features] so adding new features in the future would be easier.
ie.
[features]
{{#mockall}}
mockall = ["dep:mockall"]
{{/mockall}}
{{#foo}}
foo = ["dep:foo"]
{{/foo}}
{{#bar}}
bar = ["dep:bar"]
{{/bar}}But I do not have a strong opinion on this, we can change if there is a reason to 👍
There was a problem hiding this comment.
that's ok. i may file a PR later to update it
|
I went ahead and added support for the 2 things I need:
|
|
@TroyKomodo Thanks! |
|
can you please commit the updated samples and docs one more time? |
Adds support for single argument and bon building for the new reqwest-trait generator
Sure, I just pushed a commit rebuilding them. 👍 |
|
thanks for the PR let's give it a try to see if the community has any feedback/suggestion on this new generator |


This PR added a new
reqwest-traitgenerator that was requested in #11319.This implementation uses traits as the primary interface using APIs. This has 2 primary benefits
configuration::Configurationto all API calls as we now store that in the implementing struct.I also added 2 small QoL features in this sub-library:
mockalloption (defaults to OFF) that adds the mockall crate to make testing much easier.topLevelApiClientoption (defaults to OFF) that adds a top levelApitrait andApiClientstruct that serves a container. This makes managing APIs with many tags much easier as we only need to construct one client instead of many.PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)