-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
[Rust] harden against name collisions while generate cleaner rust code, fix #20337 #20396
base: master
Are you sure you want to change the base?
Changes from all commits
6d06003
46f1379
b695b68
6bb4f1a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,58 +31,52 @@ pub enum GetStateError { | |
|
||
|
||
pub fn create_state(configuration: &configuration::Configuration, create_state_request: models::CreateStateRequest) -> Result<(), Error<CreateStateError>> { | ||
let local_var_configuration = configuration; | ||
// add a prefix to parameters to efficiently prevent name collisions | ||
let p_create_state_request = create_state_request; | ||
|
||
let local_var_client = &local_var_configuration.client; | ||
let uri_str = format!("{}/state", configuration.base_path); | ||
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); | ||
|
||
let local_var_uri_str = format!("{}/state", local_var_configuration.base_path); | ||
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); | ||
|
||
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { | ||
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); | ||
if let Some(ref user_agent) = configuration.user_agent { | ||
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); | ||
} | ||
local_var_req_builder = local_var_req_builder.json(&create_state_request); | ||
req_builder = req_builder.json(&p_create_state_request); | ||
|
||
let local_var_req = local_var_req_builder.build()?; | ||
let local_var_resp = local_var_client.execute(local_var_req)?; | ||
let req = req_builder.build()?; | ||
let resp = configuration.client.execute(req)?; | ||
|
||
let local_var_status = local_var_resp.status(); | ||
let status = resp.status(); | ||
|
||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() { | ||
if !status.is_client_error() && !status.is_server_error() { | ||
Ok(()) | ||
} else { | ||
let local_var_content = local_var_resp.text()?; | ||
let local_var_entity: Option<CreateStateError> = serde_json::from_str(&local_var_content).ok(); | ||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; | ||
Err(Error::ResponseError(local_var_error)) | ||
let content = resp.text()?; | ||
let entity: Option<CreateStateError> = serde_json::from_str(&content).ok(); | ||
Err(Error::ResponseError(ResponseContent { status, content, entity })) | ||
} | ||
} | ||
|
||
pub fn get_state(configuration: &configuration::Configuration, ) -> Result<models::GetState200Response, Error<GetStateError>> { | ||
let local_var_configuration = configuration; | ||
|
||
let local_var_client = &local_var_configuration.client; | ||
|
||
let local_var_uri_str = format!("{}/state", local_var_configuration.base_path); | ||
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); | ||
let uri_str = format!("{}/state", configuration.base_path); | ||
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); | ||
|
||
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { | ||
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); | ||
if let Some(ref user_agent) = configuration.user_agent { | ||
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); | ||
} | ||
|
||
let local_var_req = local_var_req_builder.build()?; | ||
let local_var_resp = local_var_client.execute(local_var_req)?; | ||
let req = req_builder.build()?; | ||
let resp = configuration.client.execute(req)?; | ||
|
||
let local_var_status = local_var_resp.status(); | ||
let status = resp.status(); | ||
|
||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() { | ||
let local_var_content = local_var_resp.text()?; | ||
serde_json::from_str(&local_var_content).map_err(Error::from) | ||
if !status.is_client_error() && !status.is_server_error() { | ||
let content = resp.text()?; | ||
serde_json::from_str(&content).map_err(Error::from) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about adding a fake endpoint with the parameter test spec: modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml an example of fake endpoint: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml#L585 |
||
} else { | ||
let local_var_content = local_var_resp.text()?; | ||
let local_var_entity: Option<GetStateError> = serde_json::from_str(&local_var_content).ok(); | ||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; | ||
Err(Error::ResponseError(local_var_error)) | ||
let content = resp.text()?; | ||
let entity: Option<GetStateError> = serde_json::from_str(&content).ok(); | ||
Err(Error::ResponseError(ResponseContent { status, content, entity })) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we rename
in_function_identifier
toinFunctionIdentifier
instead to conform to java variable naming convention?