# How to Run Generated Code for a Programming Language Choose your programming language/library from the list provided below to learn more how you can execute them: - [cURL](#curl) - [C (libcurl)](#c-libcurl) - [C# (HttpClient)](#c-httpclient) - [C# (RestSharp)](#c-restsharp) - [Dart (http)](#dart-http) - [Dart (dio)](#dart-dio) - [Go (net/http)](#go-nethttp) - [JavaScript (axios)](#javascript-axios) - [JavaScript (fetch)](#javascript-fetch) - [node.js (JavaScript, axios)](#nodejs-javascript-axios) - [node.js (JavaScript, fetch)](#nodejs-javascript-fetch) - [Java (asynchttpclient)](#java-asynchttpclient) - [Java (HttpClient)](#java-httpclient) - [Java (okhttp3)](#java-okhttp3) - [Java (Unirest)](#java-unirest) - [Julia (HTTP)](#julia-http) - [Kotlin (okhttp3)](#kotlin-okhttp3) - [PHP (curl)](#php-curl) - [PHP (guzzle)](#php-guzzle) - [PHP (HTTPlug)](#php-httplug) - [Python (requests)](#python-requests) - [Python (http.client)](#python-httpclient) - [Ruby (faraday)](#ruby-faraday) - [Ruby (net/http)](#ruby-nethttp) - [Rust (hyper)](#rust-hyper) - [Rust (reqwest)](#rust-reqwest) - [Rust (ureq)](#rust-ureq) - [Rust (Actix Client)](#rust-actix-client) - [Swift](#swift) **Please raise a GitHub issue in case any instruction is not clear or if it is not working.** ## cURL TODO ## C (libcurl) TODO ## C# (HttpClient) Here are the detailed instructions for running the generated API Dash code in C# (using `HttpClient`) for macOS, Windows, and Linux: ### 1. Setting Up the C# Development Environment #### macOS and Windows: 1. **Install .NET SDK:** - Visit the [official .NET download page](https://dotnet.microsoft.com/download). - Download and install the latest .NET SDK for macOS. 2. **Verify Installation:** - Open the terminal and run the following command to verify the installation: ```bash dotnet --version ``` #### Linux: 1. **Install .NET SDK:** - Run the following commands based on your distribution: - For Ubuntu/Debian-based systems: ```bash sudo apt update sudo apt install dotnet-sdk-7.0 ``` - For Fedora/CentOS-based systems: ```bash sudo dnf install dotnet-sdk-7.0 ``` 2. **Verify Installation:** - Open the terminal and run the following command to verify the installation: ```bash dotnet --version ``` ### 2. Preparing a Project #### In Visual Studio: 1. **Create a New Project:** - Open Visual Studio and select **Create a new project**. - Choose the **Console Application (.NET Core)** template and create the project. 2. **Check `System.Net.Http` Namespace:** - `HttpClient` is included by default. No additional installation is required. #### Using the CLI: 1. **Create a Project:** ```bash dotnet new console -n HttpClientExample cd HttpClientExample ``` 2. **Install the Package (if necessary):** ```bash dotnet add package System.Net.Http ``` ### 3. Execute the generated code: Once you have .NET(C#) and `HttpClient` installed, follow these steps to execute the generated code: 1. **Open a IDE/text editor** ✍️ (Visual Studio, VS Code or any other text editor). 2. **Copy the generated code** 📋 from API Dash. 3. **Paste the code** into your project. ex) prgoram.cs #### In Visual Studio: 1. Click the **Start Debugging (F5)** button from the top menu to run the project. 2. The output window will display the API response. #### Using the CLI: 1. Open the terminal at the project root directory and run the following command: ```bash dotnet run ``` ## C# (RestSharp) Here are the detailed instructions for running the generated API Dash code in C# (using RestSharp) for macOS, Windows, and Linux: ### 1. Setting Up the C# Development Environment #### macOS and Windows 1. **Install .NET SDK** - Visit the [official .NET download page](https://dotnet.microsoft.com/download). - Download and install the latest .NET SDK for macOS. 2. **Verify Installation** - Open the terminal and run the following command to verify the installation: ```bash dotnet --version ``` #### Linux 1. **Install .NET SDK** - Run the following commands based on your distribution: - For Ubuntu/Debian-based systems: ```bash sudo apt update sudo apt install dotnet-sdk-7.0 ``` - For Fedora/CentOS-based systems: ```bash sudo dnf install dotnet-sdk-7.0 ``` 2. **Verify Installation** - Open the terminal and run the following command to verify the installation: ```bash dotnet --version ``` ### 2. Preparing a Project #### In Visual Studio 1. **Create a New Project** - Open Visual Studio and select **Create a new project**. - Choose the **Console Application (.NET Core)** template and create the project. 2. **Install `RestSharp`** - Go to Tools > NuGet Package Manager > Manage NuGet Packages for Solution. - Under the Browse tab, search for `RestSharp` and install it. #### Using the CLI 1. **Create a Project** ```bash dotnet new console -n RestSharpExample cd RestSharpExample ``` 2. **Install the Package** ```bash dotnet add package RestSharp ``` ### 3. Execute the generated code Once you have .NET(C#) and `RestSharp` installed, follow these steps to execute the generated code: 1. Open a IDE/text editor (Visual Studio, VS Code or any other text editor). 2. Copy the generated code from API Dash. 3. Paste the code into your project like program.cs #### In Visual Studio 1. Click the **Start Debugging (F5)** button from the top menu to run the project. 2. The output window will display the API response. #### Using the CLI 1. Open the terminal at the project root directory and run the following command: ```bash dotnet run ``` ## Dart (http) Here are the detailed instructions for running the generated API Dash code in **Dart (using `http`)** for macOS, Windows, and Linux: ### **1. Install Dart** - Visit the official **[Dart Installation Guide](https://dart.dev/get-dart)** for step-by-step installation instructions for macOS, Windows, and Linux. ### **2. Add the `http` Package** - Add the `http` package as a dependency under the `dependencies` section of the `pubspec.yaml` file: ```yaml dependencies: http: ^1.2.2 ``` - Run the following command to fetch the dependency: ```bash dart pub get ``` ### **3. Run the Generated Code** #### **Using a Text Editor or IDE (e.g., Visual Studio Code):** 1. Open a text editor or an IDE like Visual Studio Code. 2. Create a new Dart file, such as `api_test.dart`. 3. Copy the generated code from API Dash and paste it into this file. 4. Save the file. 5. Run the Dart file using the terminal or the IDE's built-in tools. #### **Using the Command Line:** 1. Save the generated code to a Dart file, e.g., `api_test.dart`. 2. Open a terminal and navigate to the directory containing the file. 3. Run the Dart file with the following command: ```bash dart run api_test.dart ``` ## Dart (dio) Here are the detailed instructions for running the generated API Dash code in **Dart (using `dio`)** for macOS, Windows, and Linux: ### **1. Install Dart** - Visit the official **[Dart Installation Guide](https://dart.dev/get-dart)** for step-by-step installation instructions for macOS, Windows, and Linux. ### **2. Add the `dio` Package** - Add the `dio` package as a dependency under the `dependencies` section of the `pubspec.yaml` file: ```yaml dependencies: dio: ^5.7.0 ``` - Run the following command to fetch the dependency: ```bash dart pub get ``` ### **3. Run the Generated Code** #### **Using a Text Editor or IDE (e.g., Visual Studio Code):** 1. Open a text editor or an IDE like Visual Studio Code. 2. Create a new Dart file, such as `api_test.dart`. 3. Copy the generated code from API Dash and paste it into this file. 4. Save the file. 5. Run the Dart file using the terminal or the IDE's built-in tools. #### **Using the Command Line:** 1. Save the generated code to a Dart file, e.g., `api_test.dart`. 2. Open a terminal and navigate to the directory containing the file. 3. Run the Dart file with the following command: ```bash dart run api_test.dart ``` ## Go (net/http) ### 1. Install Go compiler - Windows and MacOS: check out the [official source](https://go.dev/doc/install) - Linux: Install from your distro's package manager. Verify if go is installed: ```bash go version ``` ### 2. Create a project ```bash go mod init example.com/api ``` ### 3. Run the generated code - Paste the generated code into `main.go`. - Build and run by `go run main.go`. ## JavaScript (axios) The generated api code can be run in browser by using the code in an html file as demonstrated below: ### 1. Create the html file with generated code Create a new file `index.html` ```html