OpenAPITools / OpenAPITools/openapi-generator
[REQ] proposal: rust/reqwest changes
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
@frol / @farcaller / @richardwhiuk / @paladinzh
In order to make the rust/reqwest api/models more flexible for use with an arbitrary/external client
I would propose the following changes...
- Add extensions to alter generation :
new extension attributes: vendorExtensions.*
x-add-dependencies Cargo dependency additions
x-add-dependencies-dev Cargo dependency-dev additions
x-add-use Use statements for all files (could be added to partial header
x-add-derive-enum Added before all enum definitions
x-add-derive-struct Added before all struct definitions
It would be used with something like this:
generatorName: rust
outputDir: xxxxx
library: reqwest
inputSpec: xxxxx/yyy.yaml
additionalProperties:
supportAsync: true
packageName: my_xxxx
vendorExtensions.x-group-parameters: true
vendorExtensions.x-add-dependencies: >
strum = "*"
strum_macros = "*"
builder_macro = "*"
derive-getters = "*"
derive_builder = "*"
getset = "*"
rand = "*"
vendorExtensions.x-add-dependencies-dev: >
# added dev dependencies
vendorExtensions.x-add-use: >
#[allow(unused_imports)]
pub use serde::{
Serialize, Deserialize,
ser::{SerializeStruct},
de::{Visitor, MapAccess},
};
#[allow(unused_imports)]
pub use derive_builder::{Builder};
#[allow(unused_imports)]
pub use getset::{CopyGetters, Getters, MutGetters, Setters};
#[allow(unused_imports)]
pub use strum_macros::{ Display, EnumMessage, EnumIter, EnumString, AsRefStr, AsStaticStr, };
vendorExtensions.x-add-derive-enum: >
#[derive(Display, AsRefStr, AsStaticStr, EnumString, EnumMessage, EnumIter)]
vendorExtensions.x-add-derive-struct: >
#[derive(Builder, Getters, Setters, MutGetters, CopyGetters)]
#[builder(try_setter, setter(into))]
vendorExtensions.x-other: false
-
Split the API methods into:
- {{{operationId}}}_setparameters(builder, ...)
-- Set all parameters - {{{operationId}}}(config, ...)
- create builder
- call {{{operationId}}}_setparameters(builder, ...)
- execute
This change would make the integration into an external library with existing client generator easier.
- {{{operationId}}}_setparameters(builder, ...)
-
Generate #[tests] based on examples in spec file
-
Create a trait definition that all API methods implement
To make it easier to have a map of traits and call them generically
I have implemented some of this already in my branch...
Comments thoughts ?
Thanks
JR
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the rust/reqwest generator and the proposer’s branch, jrz_v500_add_extensions. The proposal covers vendor-extension support, API method splitting, generated tests, and traits; done would require agreeing on scope and implementing and validating the selected changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100