Merge pull request #535 from AffanShaikhsurab/patch-5

Add detailed instructions for running API Dash-generated code in Kotlin using okhttp3
This commit is contained in:
Ashita Prasad
2025-01-22 20:37:19 +05:30
committed by GitHub

View File

@ -533,7 +533,50 @@ TODO
## Kotlin (okhttp3)
TODO
Here are the detailed instructions for running the generated API Dash code in Kotlin (using okhttp3) for macOS, Windows, and Linux:
### 1. Install Kotlin
To run Kotlin code, you need to install Kotlin by following the below instructions:
- Go to [Kotlin Installation Guide](https://kotlinlang.org/docs/getting-started.html#install-kotlin) for detailed steps.
- Kotlin is also included in IntelliJ IDEA and Android Studio. You can also download and install one of these IDEs to start using Kotlin.
### 2. Add `okhttp` library
To use `okhttp3` in your Kotlin project, you need to include it as a dependency. If you're using **Gradle**, follow these steps:
- Open the `build.gradle` file in your project.
- Add the following dependency in the `dependencies` section:
```gradle
implementation("com.squareup.okhttp3:okhttp:4.12.0")
```
- Sync your project to apply the dependency.
### 3. Execute the generated code
After setting up Kotlin and `okhttp3`, follow these steps to run the generated code:
#### Using IDE
1. Open the installed IDE like Android Studio.
2. Create a new Kotlin file.
3. Copy the generated code from API Dash and paste it in the Kotlin file.
4. Run the Kotlin file by clicking the `Run` button in the IDE or by using the command line.
#### Using command line
1. Create a new Kotlin file.
2. Copy the generated code from API Dash and paste it in the Kotlin file (`api_test.kt`).
3. Navigate to the project directory using the terminal or command prompt.
4. Compile and run the Kotlin file by executing:
```bash
kotlinc api_test.kt -include-runtime -d api_test.jar
java -jar api_test.jar
```
## PHP (curl)