dukecon / dukecon_mobile

Native mobile clients for Dukecon.org conferences build with Kotlin Multiplatform
https://dukecon.github.io/dukecon_mobile
Apache License 2.0
5 stars 0 forks source link

Replace hand writen remote client with code generated from OpenApi definition #4

Closed michalharakal closed 4 years ago

michalharakal commented 4 years ago

Original android version of ducon client contains remote networking clinet generated by gradle plugin from OpenApi specification. See original implementation for details https://github.com/dukecon/dukecon_android/blob/master/dukecon-api/build.gradle

Since originally generated code is java and also has dependecy on java libraries (e.g. threeten for date time) was not posible to directly use it in a kotlin multiplatform project.

There are two ready to use solution which can be considered to apply as solution:

  1. official OpenApi code generator added support for kotlin client and meanwhile there is a initial version of ktor based code for generating code for multiplatform project
  2. A wonderfull MOKO project provided ready to use solution with https://github.com/icerockdev/moko-network

The goal of this task is, that remote modules consist only from gradle script and OpenApi definition for given backend and mappers to RemoteData Entities.

If finished and working, this will prove that ideas of modulaer and clean architecture are implemented properly in this project.

  1. M
michalharakal commented 4 years ago

4.3.1-Snapshot of open-api generator already contains initial implementaion of kotlin-multiplatform ktor based client. See original message on redditReddit post

  1. Download the Java JAR (https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.1.3-SNAPSHOT/openapi-generator-cli-4.1.3-20190927.041122-45.jar)
  2. Rename the JAR as "openapi-generator-cli.jar"
  3. Run the following command to generate a Kotlin API client for the Petstore API (https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml):

Mac/Linux: $ java -jar openapi-generator-cli.jar generate -g kotlin -i https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml --library multiplatform -o /var/tmp/kotlin/

Windows: $ java -jar openapi-generator-cli.jar generate -g kotlin -i https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml --library multiplatform -o C:\tmp\kotlin

Ref: Link to original pull request