An open API service indexing awesome lists of open source software.

https://github.com/jakobkmar/kotlin-openapi-generator

A clean OpenAPI client generator for Kotlin multiplatform
https://github.com/jakobkmar/kotlin-openapi-generator

Last synced: 2 months ago
JSON representation

A clean OpenAPI client generator for Kotlin multiplatform

Awesome Lists containing this project

README

        

## kotlin-openapi-generator

A not yet feature complete client generator.

Features:

- generates 100% Kotlin multiplatform code
- does not generate any useless classes, tries to be as clean as possible
- supports OpenAPI object inheritance (`allOf`)

### Dependency

This is a personal project for my own use cases, however if you think it is useful for you too, you can use it as a
library or via the Gradle plugin:

**Gradle plugin:**

```kotlin
plugins {
id("net.axay.openapigenerator") version "$version"
}
```

or as a **Library:**

````kotlin
dependencies {
implementation("net.axay:openapigenerator:$version")
}
````

Both are available on `mavenCentral()`, and the Gradle plugin is also available on the `gradlePluginPortal()`.

### Usage

**Gradle plugin**

Example for how to register a generation task:

````kotlin
tasks {
register("generateFromYourSpec") {
specUrl.set("https://urltoyourspec.json") // you can also use 'specFile'
outputDirectory.set(file("src/commonMain/kotlin/"))
packageName.set("your.package.name")
// optionally: deleteOldOutput.set(true)
// this requires extra care, because it recursively deletes the output directory
}
}
````

All properties for the `OpenApiGenerateTask` can be
[found here](https://github.com/jakobkmar/kotlin-openapi-generator/blob/main/openapigenerator-gradle-plugin/src/main/kotlin/net/axay/openapigenerator/OpenApiGenerateTask.kt).

###

**Library**

Have a look at
[how the Gradle plugin uses the library](https://github.com/jakobkmar/kotlin-openapi-generator/blob/main/openapigenerator-gradle-plugin/src/main/kotlin/net/axay/openapigenerator/OpenApiGenerateTask.kt#L60).

___

If you modify this project, please respect the AGPL-3.0 License.