Skip to main content

Documentation for the kotlin Generator

METADATA

PropertyValueNotes
generator namekotlinpass this to the generate command after -g
generator stabilitySTABLE
generator typeCLIENT
generator languageKotlin
generator default templating enginemustache
helpTxtGenerates a Kotlin client.

CONFIG OPTIONS

These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to configuration docs for more details.

OptionDescriptionValuesDefault
additionalModelTypeAnnotationsAdditional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)null
apiSuffixsuffix for api classesApi
artifactIdGenerated artifact id (name of jar).kotlin-client
artifactVersionGenerated artifact's package version.1.0.0
collectionTypeOption. Collection type to use
array
kotlin.Array
list
kotlin.collections.List
list
dateLibraryOption. Date library to use
threetenbp-localdatetime
Threetenbp - Backport of JSR310 (jvm only, for legacy app only)
kotlinx-datetime
kotlinx-datetime (preferred for multiplatform)
string
String
java8-localdatetime
Java 8 native JSR310 (jvm only, for legacy app only)
java8
Java 8 native JSR310 (jvm only, preferred for jdk 1.8+)
threetenbp
Threetenbp - Backport of JSR310 (jvm only, preferred for jdk < 1.8)
java8
enumPropertyNamingNaming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'original
generateRoomModelsGenerate Android Room database models in addition to API models (JVM Volley library only)false
groupIdGenerated artifact package's organization (i.e. maven groupId).org.openapitools
ideaAdd IntellJ Idea plugin and mark Kotlin main and test folders as source folders.false
libraryLibrary template (sub-template) to use
jvm-ktor
Platform: Java Virtual Machine. HTTP client: Ktor 1.6.7. JSON processing: Gson, Jackson (default).
jvm-okhttp4
[DEFAULT] Platform: Java Virtual Machine. HTTP client: OkHttp 4.2.0 (Android 5.0+ and Java 8+). JSON processing: Moshi 1.8.0.
jvm-spring-webclient
Platform: Java Virtual Machine. HTTP: Spring 5 (or 6 with useSpringBoot3 enabled) WebClient. JSON processing: Jackson.
jvm-spring-restclient
Platform: Java Virtual Machine. HTTP: Spring 6 RestClient. JSON processing: Jackson.
jvm-retrofit2
Platform: Java Virtual Machine. HTTP client: Retrofit 2.6.2.
multiplatform
Platform: Kotlin multiplatform. HTTP client: Ktor 1.6.7. JSON processing: Kotlinx Serialization: 1.2.1.
jvm-volley
Platform: JVM for Android. HTTP client: Volley 1.2.1. JSON processing: gson 2.8.9
jvm-vertx
Platform: Java Virtual Machine. HTTP client: Vert.x Web Client. JSON processing: Moshi, Gson or Jackson.
jvm-okhttp4
modelMutableCreate mutable modelsfalse
moshiCodeGenWhether to enable codegen with the Moshi library. Refer to the official Moshi doc for more info.false
nullableReturnTypeNullable return typefalse
omitGradlePluginVersionsWhether to declare Gradle plugin versions in build files.false
omitGradleWrapperWhether to omit Gradle wrapper for creating a sub project.false
packageNameGenerated artifact package name.org.openapitools.client
parcelizeModelstoggle "@Parcelize" for generated modelsnull
requestDateConverterJVM-Option. Defines in how to handle date-time objects that are used for a request (as query or parameter)
toJson
[DEFAULT] Date formatter option using a json converter.
toString
Use the 'toString'-method of the date-time object to retrieve the related string representation.
toJson
serializableModelboolean - toggle "implements Serializable" for generated modelsnull
serializationLibraryWhat serialization library to use: 'moshi' (default), or 'gson' or 'jackson' or 'kotlinx_serialization'moshi
sortModelPropertiesByRequiredFlagSort model properties to place required parameters before optional parameters.null
sortParamsByRequiredFlagSort method arguments to place required parameters before optional parameters.null
sourceFoldersource folder for generated codesrc/main/kotlin
supportAndroidApiLevel25AndBelow[WARNING] This flag will generate code that has a known security vulnerability. It uses kotlin.io.createTempFile instead of java.nio.file.Files.createTempFile in order to support Android API level 25 and bellow. For more info, please check the following links https://github.com/OpenAPITools/openapi-generator/security/advisories/GHSA-23x4-m842-fmwf, https://github.com/OpenAPITools/openapi-generator/pull/9284false
useCoroutinesWhether to use the Coroutines adapter with the retrofit2 library.false
useRxJava3Whether to use the RxJava3 adapter with the retrofit2 library.false
useSettingsGradleWhether the project uses settings.gradle.false
useSpringBoot3Whether to use the Spring Boot 3 with the jvm-spring-webclient library.false

IMPORT MAPPING

Type/AliasImports
BigDecimaljava.math.BigDecimal
Datejava.time.LocalDate
DateTimejava.time.OffsetDateTime
Filejava.io.File
LocalDatejava.time.LocalDate
LocalDateTimejava.time.LocalDateTime
LocalTimejava.time.LocalTime
Timestampjava.sql.Timestamp
URIjava.net.URI
UUIDjava.util.UUID

INSTANTIATION TYPES

Type/AliasInstantiated By
arraykotlin.collections.ArrayList
listkotlin.collections.ArrayList
mapkotlin.collections.HashMap

LANGUAGE PRIMITIVES

  • kotlin.Array
  • kotlin.Boolean
  • kotlin.Byte
  • kotlin.ByteArray
  • kotlin.Char
  • kotlin.Double
  • kotlin.Float
  • kotlin.Int
  • kotlin.Long
  • kotlin.Short
  • kotlin.String
  • kotlin.collections.List
  • kotlin.collections.Map
  • kotlin.collections.MutableList
  • kotlin.collections.MutableMap
  • kotlin.collections.MutableSet
  • kotlin.collections.Set

RESERVED WORDS

  • ApiResponse
  • abstract
  • actual
  • annotation
  • as
  • break
  • class
  • companion
  • const
  • constructor
  • continue
  • contract
  • crossinline
  • data
  • delegate
  • do
  • dynamic
  • else
  • enum
  • expect
  • external
  • false
  • field
  • final
  • finally
  • for
  • fun
  • if
  • import
  • in
  • infix
  • init
  • inline
  • inner
  • interface
  • internal
  • is
  • it
  • lateinit
  • noinline
  • null
  • object
  • open
  • operator
  • out
  • override
  • package
  • param
  • private
  • property
  • protected
  • public
  • receiver
  • reified
  • return
  • sealed
  • setparam
  • super
  • suspend
  • tailrec
  • this
  • throw
  • true
  • try
  • typealias
  • typeof
  • val
  • value
  • var
  • vararg
  • when
  • where
  • while

FEATURE SET

Client Modification Feature

NameSupportedDefined By
BasePathToolingExtension
AuthorizationsToolingExtension
UserAgentToolingExtension
MockServerToolingExtension

Data Type Feature

NameSupportedDefined By
CustomOAS2,OAS3
Int32OAS2,OAS3
Int64OAS2,OAS3
FloatOAS2,OAS3
DoubleOAS2,OAS3
DecimalToolingExtension
StringOAS2,OAS3
ByteOAS2,OAS3
BinaryOAS2,OAS3
BooleanOAS2,OAS3
DateOAS2,OAS3
DateTimeOAS2,OAS3
PasswordOAS2,OAS3
FileOAS2
Uuid
ArrayOAS2,OAS3
NullOAS3
AnyTypeOAS2,OAS3
ObjectOAS2,OAS3
MapsToolingExtension
CollectionFormatOAS2
CollectionFormatMultiOAS2
EnumOAS2,OAS3
ArrayOfEnumToolingExtension
ArrayOfModelToolingExtension
ArrayOfCollectionOfPrimitivesToolingExtension
ArrayOfCollectionOfModelToolingExtension
ArrayOfCollectionOfEnumToolingExtension
MapOfEnumToolingExtension
MapOfModelToolingExtension
MapOfCollectionOfPrimitivesToolingExtension
MapOfCollectionOfModelToolingExtension
MapOfCollectionOfEnumToolingExtension

Documentation Feature

NameSupportedDefined By
ReadmeToolingExtension
ModelToolingExtension
ApiToolingExtension

Global Feature

NameSupportedDefined By
HostOAS2,OAS3
BasePathOAS2,OAS3
InfoOAS2,OAS3
SchemesOAS2,OAS3
PartialSchemesOAS2,OAS3
ConsumesOAS2
ProducesOAS2
ExternalDocumentationOAS2,OAS3
ExamplesOAS2,OAS3
XMLStructureDefinitionsOAS2,OAS3
MultiServerOAS3
ParameterizedServerOAS3
ParameterStylingOAS3
CallbacksOAS3
LinkObjectsOAS3

Parameter Feature

NameSupportedDefined By
PathOAS2,OAS3
QueryOAS2,OAS3
HeaderOAS2,OAS3
BodyOAS2
FormUnencodedOAS2
FormMultipartOAS2
CookieOAS3

Schema Support Feature

NameSupportedDefined By
SimpleOAS2,OAS3
CompositeOAS2,OAS3
PolymorphismOAS2,OAS3
UnionOAS3
allOfOAS2,OAS3
anyOfOAS3
oneOfOAS3
notOAS3

Security Feature

NameSupportedDefined By
BasicAuthOAS2,OAS3
ApiKeyOAS2,OAS3
OpenIDConnectOAS3
BearerTokenOAS3
OAuth2_ImplicitOAS2,OAS3
OAuth2_PasswordOAS2,OAS3
OAuth2_ClientCredentialsOAS2,OAS3
OAuth2_AuthorizationCodeOAS2,OAS3
SignatureAuthOAS3
AWSV4SignatureToolingExtension

Wire Format Feature

NameSupportedDefined By
JSONOAS2,OAS3
XMLOAS2,OAS3
PROTOBUFToolingExtension
CustomOAS2,OAS3