Skip to content

Commit 5229f99

Browse files
authored
Merge pull request #695 from Udhay-Adithya/add-reqwest-docs
docs(codegen): add detailed instructions for reqwest
2 parents 8b12a72 + 9545318 commit 5229f99

File tree

1 file changed

+62
-1
lines changed

1 file changed

+62
-1
lines changed

doc/user_guide/instructions_to_run_generated_code.md

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,68 @@ TODO
945945

946946
## Rust (reqwest)
947947

948-
TODO
948+
### 1. Download and Install Rust:
949+
950+
#### **Windows**
951+
1. Download and install `rustup` from [Rustup Official Site](https://rustup.rs).
952+
2. Run the installer (`rustup-init.exe`) and follow the instructions.
953+
3. Restart your terminal (Command Prompt or PowerShell).
954+
4. Verify the installation:
955+
```sh
956+
rustc --version
957+
cargo --version
958+
```
959+
960+
#### **MacOS/Linux**
961+
1. Run the following in your terminal:
962+
```sh
963+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
964+
```
965+
then follow the on-screen instructions.
966+
967+
2. Restart the terminal and verify:
968+
```sh
969+
rustc --version
970+
cargo --version
971+
```
972+
973+
> Note: If you prefer not to use rustup for some reason, please see the Other [Rust Installation Methods](https://forge.rust-lang.org/infra/other-installation-methods.html) page for more options.
974+
975+
### 2. Set Up a New Rust Project
976+
1. Open a terminal and create a new Rust project:
977+
```sh
978+
cargo new reqwest-demo
979+
```
980+
2. Navigate into the project directory:
981+
```sh
982+
cd reqwest-demo
983+
```
984+
985+
or open this project directory in your preferred code editor.
986+
987+
### 3. Add Necessary Dependencies
988+
Run the following command to add dependencies:
989+
```sh
990+
cargo add reqwest --features blocking,json
991+
cargo add tokio --features full
992+
```
993+
- `"blocking"`: Enables synchronous requests.
994+
- `"json"`: Allows JSON parsing.
995+
- `"tokio"`: Needed for asynchronous execution.
996+
997+
Run the following command to fetch dependencies:
998+
```sh
999+
cargo build
1000+
```
1001+
1002+
### 4. Execute code
1003+
1. Copy the generated code from API Dash.
1004+
2. Paste the code into your project's `src/main.rs` directory
1005+
1006+
Run the generated code:
1007+
```sh
1008+
cargo run
1009+
```
9491010
9501011
## Rust (ureq)
9511012

0 commit comments

Comments
 (0)