Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Building a Kotlin Multiplatform Library in 10 Minutes.

Why Not?

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

!! WARNING !!

Viewer Discretion Advised - Live Code Generation Ahead

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Zachary Powell

Android Developer Since 2009

Sr Android Developer Advocate

Manager, DevRel at Vonage

@DevWithZachary

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Communication and Network APIs

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Libraries Libraries Libraries

  • Framework SDK's
  • Testing
  • Dependency Injector
  • Networking
  • Plus many many more.....
Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Application Programming Interfaces (APIs)

  • Third Party APIs
  • Internal APIs
Zachary Powell - DevRel Manager At Vonage - @devwithzachary
width
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Consuming APIs manually sucks!

  • Lacking Libraries
  • Missing Documentation
  • Time consuming
  • Ambiguity
Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Lets fix that with...

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Generating Libraries!

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?
Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?
Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?
Zachary Powell - DevRel Manager At Vonage - @devwithzachary
width
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Have you heard of OpenAPI?

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
width
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Do you use OpenAPI?

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
width
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

What is OpenAPI?

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

What is OpenAPI?

"The OpenAPI Specification (OAS) defines a standard, language-agnostic interface to HTTP APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection." - https://swagger.io/specification/

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
width
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

What is OpenAPI?

OpenAPI Documents

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

OpenAPI Documents

Define Objects that Break Down your API Definition

  • Meta Data
  • Server Infomation
  • End points
  • Parameters....
Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

JSON

{
  "title": "Sample Pet Store App",
  "summary": "A pet store manager.",
  "termsOfService": "https://example.com/terms/",
  "contact": {
    "name": "API Support",
    "url": "https://www.example.com/support",
    "email": "support@example.com"
  },
  "license": {
    "name": "Apache 2.0",
    "url": "https://www.apache.org/licenses/LICENSE-2.0.html"
  },
  "version": "1.0.1"
}
Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

YAML

title: Sample Pet Store App
summary: A pet store manager.
termsOfService: https://example.com/terms/
contact:
  name: API Support
  url: https://www.example.com/support
  email: support@example.com
license:
  name: Apache 2.0
  url: https://www.apache.org/licenses/LICENSE-2.0.html
version: 1.0.1
Zachary Powell - DevRel Manager At Vonage - @devwithzachary
width
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

But Why?

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

But Why?

Define an API Contract between those building the API and those using it.

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
width
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

But Why?

The Tooling!

  • Documentation
  • Mocking
  • Security
  • Testing
  • Code Generation
  • openapi.tools
Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Vonage SMS API

https://developer.vonage.com/en/api/sms

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?
"paths": {
      "/{format}": {
         "post": {
            "operationId": "send-an-sms",
            "summary": "Send an SMS",
            "description": "Send an outbound SMS from your Vonage account",
            "parameters": [
               {
                  "name": "format",
                  "description": "The format of the response",
                  "in": "path",
                  "required": true,
                  "schema": {
                     "example": "json",
                     "type": "string",
                     "enum": [
                        "json",
                        "xml"
                     ],
                     "default": "json"
                  }
               }
            ], ...
Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

OpenAPI Generator

https://openapi-generator.tech/

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Servers

ada-server, aspnet-fastendpoints, aspnetcore, cpp-pistache-server, cpp-qt-qhttpengine-server, cpp-restbed-server, cpp-restbed-server-deprecated, csharp-functions, erlang-server,erlang-server-deprecated, fsharp-functions, fsharp-giraffe-server, go-echo-server, go-gin-server, go-server, graphql-nodejs-express-server, haskell, haskell-yesod, java-camel, java-helidon-server, java-inflector, java-micronaut-server, java-microprofile, java-msf4j, java-pkmst, java-play-framework, java-undertow-server, java-vertx, java-vertx-web, java-wiremock, jaxrs-cxf, jaxrs-cxf-cdi, jaxrs-cxf-extended, jaxrs-jersey, jaxrs-resteasy, jaxrs-resteasy-eap, jaxrs-spec, julia-server, kotlin-server, kotlin-spring, kotlin-vertx, kotlin-wiremock, nodejs-express-server, php-flight, php-laravel, php-lumen, php-mezzio-ph, php-slim4, php-symfony, python-aiohttp, python-blueplanet, python-fastapi, python-flask, ruby-on-rails, ruby-sinatra, rust-axum, rust-server, scala-akka-http-server, scala-cask, scala-finch, scala-http4s-server, scala-lagom-server, scala-play-server, scalatra, spring

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Clients

ada, android, apex, bash, c, clojure, cpp-qt-client, cpp-restsdk, cpp-tiny, cpp-tizen, cpp-ue4, crystal, csharp, dart, dart-dio, eiffel, elixir, elm, erlang-client, erlang-proper, go, groovy, haskell-http-client, java, javascript, jaxrs-cxf-client, jetbrains-http-client, jmeter, julia-client, k6, kotlin, lua, n4js, nim, objc, ocaml, perl, php, powershell, python, r, ruby, rust, scala, scalaz, swift-combine, swift5, typescript, xojo-client, zapier

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Clients

ada, android, apex, bash, c, clojure, cpp-qt-client, cpp-restsdk, cpp-tiny, cpp-tizen, cpp-ue4, crystal, csharp, dart, dart-dio, eiffel, elixir, elm, erlang-client, erlang-proper, go, groovy, haskell-http-client, java, javascript, jaxrs-cxf-client, jetbrains-http-client, jmeter, julia-client, k6, kotlin, lua, n4js, nim, objc, ocaml, perl, php, powershell, python, r, ruby, rust, scala, scalaz, swift-combine, swift5, typescript, xojo-client, zapier

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Generate the code

java -jar ../openapi-generator-cli.jar generate
-i ../sms.json
-g kotlin
--additional-properties=library=multiplatform,dateLibrary=kotlinx-datetime

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Generate the code

java -jar ../openapi-generator-cli.jar generate
-i ../sms.json
-g kotlin
--additional-properties=library=multiplatform,dateLibrary=kotlinx-datetime

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Generate the code

java -jar ../openapi-generator-cli.jar generate
-i ../sms.json
-g kotlin
--additional-properties=library=multiplatform,dateLibrary=kotlinx-datetime

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Generate the code

java -jar ../openapi-generator-cli.jar generate
-i ../sms.json
-g kotlin
--additional-properties=library=multiplatform,dateLibrary=kotlinx-datetime

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Generate the code

java -jar ../openapi-generator-cli.jar generate
-i ../sms.json
-g kotlin
--additional-properties=library=multiplatform,dateLibrary=kotlinx-datetime

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Generate the code!

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Photo Break!

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
width
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Why Not?

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Why Not?

Incomplete/Complex OpenAPI specs may not generate as expected

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Why Not?

Purely one to one mapping

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Why Not?

No additional business logic or helper functions

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Why Not?

BUT its a great starting point!

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Hand made SDKs here to stay!

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Checkout the new Kotlin Server SDK

Coupon Code, €10 free credit: 25DEVW10

https://github.com/Vonage/vonage-kotlin-sdk

Zachary Powell - DevRel Manager At Vonage - @devwithzachary
Building a Kotlin Multiplatform Library in 10 Minutes. Why Not?

Thank you!

links.zpweb.site

github.com/devwithzachary/presentations

Zachary Powell - DevRel Manager At Vonage - @devwithzachary