Skip to content
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

updated rust codegen #788

Merged
merged 4 commits into from
Apr 9, 2025
Merged

updated rust codegen #788

merged 4 commits into from
Apr 9, 2025

Conversation

badnikhil
Copy link
Contributor

@badnikhil badnikhil commented Apr 7, 2025

PR Description

This PR fixes a compatibility issue with ureq 3.x caused by the removal of the into_string() method.] The code generated currently uses response.into_string(), which leads to compilation errors when using ureq 3.x and above.
Updated it to into_body().read_to_string()

Related Issues

Checklist

  • I have gone through the contributing guide
  • I have updated my branch and synced it with project main branch before making this PR
  • I am using the latest Flutter stable branch (run flutter upgrade and verify)
  • I have run the tests (flutter test) and all tests are passing

Added/updated tests?

We encourage you to add relevant test cases.

  • Yes
  • No, and this is why: please replace this line with details on why tests have not been included

OS on which you have developed and tested the feature?

  • Windows

@animator
Copy link
Member

animator commented Apr 7, 2025

@Udhay-Adithya Kindly review this PR

@Udhay-Adithya
Copy link
Contributor

@animator I’ve reviewed the PR and tested it locally. Everything works as expected.

However, I noticed that some methods in the current codegen are deprecated. For example:

.set(...) → is replaced with .header(...)

.send_json(...)

It’d be good to update these to follow the latest standards and avoid future issues.

@badnikhil
Copy link
Contributor Author

badnikhil commented Apr 7, 2025

@animator I’ve reviewed the PR and tested it locally. Everything works as expected.

However, I noticed that some methods in the current codegen are deprecated. For example:

.set(...) → is replaced with .header(...)

.send_json(...)

It’d be good to update these to follow the latest standards and avoid future issues.

this PR solves the errors mentioned in the issue but I'll check and update everything within rust codegen.

@Udhay-Adithya
Copy link
Contributor

this PR solves the errors mentioned in the issue but I'll check and update everything within rust codegen.

That would be great.

@badnikhil
Copy link
Contributor Author

badnikhil commented Apr 7, 2025

@animator I’ve reviewed the PR and tested it locally. Everything works as expected.

However, I noticed that some methods in the current codegen are deprecated. For example:

.set(...) → is replaced with .header(...)

.send_json(...)

It’d be good to update these to follow the latest standards and avoid future issues.

for json requests serde_json is needed.
send_json is not deprecated yet - you need to manually enable this feature.
Can you confirm the dependencies and the code above?
Also i have pushed a commit.
I will update tests after your confirmation and then the PR can be merged.

ureq = { version = "3.0.10", features = ["json"] }
serde_json = "1.0"

use serde_json::json;

fn main() ->Result<(), ureq::Error>  {
    let url = "https://api.apidash.dev/case/lower";

    let payload = json!({
       "text": "I LOVE Flutter"
    });

    let response = ureq::post(url)
        .send_json(payload)?;

    println!("Response Status: {}", response.status());

    println!("Response: {}",  response.into_body().read_to_string()?);

    Ok(())
}

@Udhay-Adithya
Copy link
Contributor

fn main() -> Result<(), ureq::Error> {
    let url = "https://api.apidash.dev";    use serde_json::json;
    let payload = json!({
  "name" : "udhay"
});

    let response = ureq::post(url)
        .send_json(payload)?;

    println!("Response Status: {}", response.status());
    println!("Response: {}", response.into_body().read_to_string()?);

    Ok(())
}

The changes you made are working fine. Just move the use statement use serde_json::json; to the top of the code block.
Also update the related tests.

@badnikhil
Copy link
Contributor Author

badnikhil commented Apr 8, 2025

@Udhay-Adithya confirm the latest commit and PR is ready to be merged.
also updated send_string(deprecated) to send.

@Udhay-Adithya
Copy link
Contributor

@animator Everything works as expected. This PR can be merged.

@animator
Copy link
Member

animator commented Apr 9, 2025

Thanks @badnikhil & @Udhay-Adithya

@animator animator merged commit b8cf1ee into foss42:main Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

codegen: Update ureq to support v3.x
3 participants