mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2026-03-18 07:29:10 +00:00
Rust reqwest improve (#1890)
* Resolves #525 for Rust client generator with reqwest library. * Use Reqwest "query" method to generate query URL. * urlencode URL string parameters. * Generate rust-reqwest client, and verify it compiles and work as intended. * Map file params (to "&std::path::Path") and support multipart operations (with file params) in Reqwest library. * Cleanup: template compression to remove unecessary blank lines in generated code.
This commit is contained in:
committed by
William Cheng
parent
16f52cf2ad
commit
888068d122
@@ -119,8 +119,11 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
typeMapping.put("date", "string");
|
||||
typeMapping.put("DateTime", "String");
|
||||
typeMapping.put("password", "String");
|
||||
// TODO(farcaller): map file
|
||||
typeMapping.put("file", "::models::File");
|
||||
// TODO(bcourtine): review file mapping.
|
||||
// I tried to map as "std::io::File", but Reqwest multipart file requires a "AsRef<Path>" param.
|
||||
// Getting a file from a Path is simple, but the opposite is difficult. So I map as "std::path::Path".
|
||||
// Reference is required here because Path does not implement the "Sized" trait.
|
||||
typeMapping.put("file", "&std::path::Path");
|
||||
typeMapping.put("binary", "::models::File");
|
||||
typeMapping.put("ByteArray", "String");
|
||||
typeMapping.put("object", "Value");
|
||||
@@ -379,7 +382,6 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
|
||||
@SuppressWarnings("unchecked")
|
||||
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
||||
Set<String> headerKeys = new HashSet<>();
|
||||
for (CodegenOperation operation : operations) {
|
||||
// http method verb conversion, depending on client library (e.g. Hyper: PUT => Put, Reqwest: PUT => put)
|
||||
if (HYPER_LIBRARY.equals(getLibrary())) {
|
||||
@@ -439,9 +441,6 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}*/
|
||||
}
|
||||
|
||||
additionalProperties.put("headerKeys", headerKeys);
|
||||
additionalProperties.putIfAbsent("authHeaderKey", "api-key");
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user