├── examples
├── README.md
├── javalin-maven-kotlin
│ ├── .mvn
│ │ └── jvm.config
│ ├── src
│ │ └── main
│ │ │ ├── resources
│ │ │ └── logback.xml
│ │ │ └── kotlin
│ │ │ └── io
│ │ │ └── javalin
│ │ │ └── openapi
│ │ │ └── plugin
│ │ │ └── test
│ │ │ └── KotlinTest.kt
│ ├── README.md
│ └── pom.xml
├── javalin-gradle-kotlin
│ ├── src
│ │ └── main
│ │ │ ├── resources
│ │ │ ├── tinylog.properties
│ │ │ └── logback.xml
│ │ │ ├── compile
│ │ │ └── openapi.groovy
│ │ │ └── kotlin
│ │ │ └── io
│ │ │ └── javalin
│ │ │ └── openapi
│ │ │ └── plugin
│ │ │ └── test
│ │ │ └── KotlinEntity.kt
│ └── build.gradle.kts
└── javalin-maven-java
│ ├── src
│ └── main
│ │ ├── kotlin
│ │ └── io
│ │ │ └── javalin
│ │ │ └── openapi
│ │ │ └── plugin
│ │ │ └── test
│ │ │ └── KotlinEntity.kt
│ │ └── resources
│ │ └── logback.xml
│ └── pom.xml
├── .github
├── FUNDING.yml
├── .dependabot.yml
├── workflows
│ ├── gradle.yml
│ └── publish-to-reposilite.yml
└── README.md
├── javalin-plugins
├── javalin-redoc-plugin
│ ├── src
│ │ ├── test
│ │ │ ├── resources
│ │ │ │ ├── openapi-plugin
│ │ │ │ │ ├── test.json
│ │ │ │ │ └── .index
│ │ │ │ └── logback.xml
│ │ │ └── kotlin
│ │ │ │ └── io
│ │ │ │ └── javalin
│ │ │ │ └── openapi
│ │ │ │ └── plugin
│ │ │ │ └── redoc
│ │ │ │ ├── RedocPluginTest.kt
│ │ │ │ └── specification
│ │ │ │ └── JavalinBehindProxy.kt
│ │ └── main
│ │ │ └── kotlin
│ │ │ └── io
│ │ │ └── javalin
│ │ │ └── openapi
│ │ │ └── plugin
│ │ │ └── redoc
│ │ │ ├── ReDocWebJarHandler.kt
│ │ │ ├── ReDocPlugin.kt
│ │ │ └── ReDocHandler.kt
│ └── build.gradle.kts
├── javalin-swagger-plugin
│ ├── src
│ │ ├── test
│ │ │ ├── resources
│ │ │ │ ├── openapi-plugin
│ │ │ │ │ ├── .index
│ │ │ │ │ └── test.json
│ │ │ │ └── logback.xml
│ │ │ └── kotlin
│ │ │ │ └── io
│ │ │ │ └── javalin
│ │ │ │ └── openapi
│ │ │ │ └── plugin
│ │ │ │ └── swagger
│ │ │ │ ├── specification
│ │ │ │ └── JavalinBehindProxy.kt
│ │ │ │ └── SwaggerPluginTest.kt
│ │ └── main
│ │ │ └── kotlin
│ │ │ └── io
│ │ │ └── javalin
│ │ │ └── openapi
│ │ │ └── plugin
│ │ │ └── swagger
│ │ │ ├── SwaggerWebJarHandler.kt
│ │ │ ├── SwaggerPlugin.kt
│ │ │ └── SwaggerHandler.kt
│ └── build.gradle.kts
└── javalin-openapi-plugin
│ ├── build.gradle.kts
│ └── src
│ ├── main
│ └── kotlin
│ │ └── io
│ │ └── javalin
│ │ └── openapi
│ │ └── plugin
│ │ ├── OpenApiHandler.kt
│ │ ├── OpenApiPlugin.kt
│ │ └── OpenApiConfiguration.kt
│ └── test
│ └── kotlin
│ └── OpenApiPluginTest.kt
├── .gitmodules
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── openapi-annotation-processor
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── META-INF
│ │ │ │ └── services
│ │ │ │ │ └── javax.annotation.processing.Processor
│ │ │ └── logback.xml
│ │ └── kotlin
│ │ │ └── io
│ │ │ └── javalin
│ │ │ └── openapi
│ │ │ └── processor
│ │ │ ├── generators
│ │ │ └── JsonSchemaGenerator.kt
│ │ │ ├── AnnotationProcessorTools.kt
│ │ │ ├── configuration
│ │ │ └── OpenApiPrecompileScriptingEngine.kt
│ │ │ └── OpenApiAnnotationProcessor.kt
│ └── test
│ │ ├── resources
│ │ ├── META-INF
│ │ │ └── services
│ │ │ │ └── javax.annotation.processing.Processor
│ │ └── logback-test.xml
│ │ ├── kotlin
│ │ └── io
│ │ │ └── javalin
│ │ │ └── openapi
│ │ │ └── processor
│ │ │ ├── specification
│ │ │ └── OpenApiAnnotationProcessorSpecification.kt
│ │ │ ├── CustomTypeMappingsTest.kt
│ │ │ ├── SchemeTest.kt
│ │ │ ├── CustomAnnotationsTest.kt
│ │ │ ├── ComponentAnnotationsTest.kt
│ │ │ ├── OpenApiAnnotationTest.kt
│ │ │ ├── UserCasesTest.kt
│ │ │ ├── CompositionTest.kt
│ │ │ └── TypeMappersTest.kt
│ │ └── compile
│ │ └── openapi.groovy
└── build.gradle.kts
├── settings.gradle.kts
├── openapi-specification
├── build.gradle.kts
└── src
│ └── main
│ └── kotlin
│ └── io
│ └── javalin
│ └── openapi
│ ├── experimental
│ ├── OpenApiAnnotationProcessorParameters.kt
│ ├── defaults
│ │ ├── CompositionEmbeddedTypeProcessor.kt
│ │ ├── ArrayEmbeddedTypeProcessor.kt
│ │ ├── DictionaryEmbeddedTypeProcessor.kt
│ │ └── DefaultSimpleTypeMappings.kt
│ ├── processor
│ │ ├── shared
│ │ │ ├── JsonExtensions.kt
│ │ │ ├── ModelExtensions.kt
│ │ │ └── AnnotationProcessorExtensions.kt
│ │ └── generators
│ │ │ ├── ExampleGenerator.kt
│ │ │ └── CompositionGenerator.kt
│ ├── OpenApiAnnotationProcessorConfiguration.kt
│ ├── AnnotationProcessorContext.kt
│ └── ClassDefinitionApi.kt
│ ├── Server.kt
│ ├── Info.kt
│ ├── Security.kt
│ ├── JsonSchemaAnnotations.kt
│ ├── data
│ └── OpenApiAnnotationsData.kt
│ └── OpenApiAnnotations.kt
├── gradle.properties
├── .run
└── Examples __ Gradle - JavalinTest.run.xml
├── gradlew.bat
├── .gitignore
├── gradlew
└── LICENSE
/examples/README.md:
--------------------------------------------------------------------------------
1 | # Examples
2 |
3 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: dzikoysk
2 |
--------------------------------------------------------------------------------
/javalin-plugins/javalin-redoc-plugin/src/test/resources/openapi-plugin/test.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/javalin-plugins/javalin-redoc-plugin/src/test/resources/openapi-plugin/.index:
--------------------------------------------------------------------------------
1 | test.json
--------------------------------------------------------------------------------
/javalin-plugins/javalin-swagger-plugin/src/test/resources/openapi-plugin/.index:
--------------------------------------------------------------------------------
1 | test.json
--------------------------------------------------------------------------------
/javalin-plugins/javalin-swagger-plugin/src/test/resources/openapi-plugin/test.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "wiki"]
2 | path = wiki
3 | url = https://github.com/javalin/javalin-openapi.wiki.git
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Petersoj/javalin-openapi/main/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/examples/javalin-maven-kotlin/.mvn/jvm.config:
--------------------------------------------------------------------------------
1 | --add-opens=java.base/java.lang=ALL-UNNAMED
2 | --add-opens=java.base/java.io=ALL-UNNAMED
--------------------------------------------------------------------------------
/.github/.dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: "gradle"
4 | directory: "/"
5 | schedule:
6 | interval: "daily"
7 |
--------------------------------------------------------------------------------
/openapi-annotation-processor/src/main/resources/META-INF/services/javax.annotation.processing.Processor:
--------------------------------------------------------------------------------
1 | io.javalin.openapi.processor.OpenApiAnnotationProcessor
--------------------------------------------------------------------------------
/openapi-annotation-processor/src/test/resources/META-INF/services/javax.annotation.processing.Processor:
--------------------------------------------------------------------------------
1 | io.javalin.openapi.processor.OpenApiAnnotationProcessor
--------------------------------------------------------------------------------
/examples/javalin-gradle-kotlin/src/main/resources/tinylog.properties:
--------------------------------------------------------------------------------
1 | writer = console
2 | writer.level = info
3 | writer.format = {date: HH:mm:ss.SSS} {level} | {message}
--------------------------------------------------------------------------------
/examples/javalin-maven-java/src/main/kotlin/io/javalin/openapi/plugin/test/KotlinEntity.kt:
--------------------------------------------------------------------------------
1 | package io.javalin.openapi.plugin.test
2 |
3 | data class KotlinEntity(
4 | val name: String,
5 | val value: Int
6 | )
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
--------------------------------------------------------------------------------
/javalin-plugins/javalin-openapi-plugin/build.gradle.kts:
--------------------------------------------------------------------------------
1 | description = "Javalin OpenAPI Plugin | Serve raw OpenApi documentation under dedicated endpoint"
2 |
3 | plugins {
4 | kotlin("kapt")
5 | }
6 |
7 | dependencies {
8 | api(project(":openapi-specification"))
9 |
10 | kaptTest(project(":openapi-annotation-processor"))
11 | }
12 |
--------------------------------------------------------------------------------
/javalin-plugins/javalin-swagger-plugin/build.gradle.kts:
--------------------------------------------------------------------------------
1 | description = "Javalin Swagger Plugin | Serve Swagger UI for OpenAPI specification"
2 |
3 | dependencies {
4 | api(project(":openapi-specification"))
5 | @Suppress("GradlePackageUpdate")
6 | api("org.webjars:swagger-ui:5.17.14") // also bump swagger-ui version in OpenApiConfiguration
7 | }
8 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | rootProject.name = "javalin-openapi"
2 |
3 | include(
4 | "openapi-specification",
5 | "openapi-annotation-processor",
6 | "javalin-plugins",
7 | "javalin-plugins:javalin-openapi-plugin",
8 | "javalin-plugins:javalin-swagger-plugin",
9 | "javalin-plugins:javalin-redoc-plugin",
10 | "examples",
11 | "examples:javalin-gradle-kotlin"
12 | )
--------------------------------------------------------------------------------
/openapi-specification/build.gradle.kts:
--------------------------------------------------------------------------------
1 | description = "Javalin OpenAPI Specification | Compile-time OpenAPI integration for Javalin 6.x"
2 |
3 | dependencies {
4 | val jacksonVersion = "2.18.1"
5 | api("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")
6 | api("com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonVersion")
7 | api("com.google.code.gson:gson:2.10.1")
8 | }
--------------------------------------------------------------------------------
/examples/javalin-gradle-kotlin/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/examples/javalin-maven-java/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/examples/javalin-maven-kotlin/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/openapi-annotation-processor/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/openapi-annotation-processor/src/test/resources/logback-test.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/javalin-plugins/javalin-redoc-plugin/src/test/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/javalin-plugins/javalin-swagger-plugin/src/test/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/javalin-plugins/javalin-redoc-plugin/build.gradle.kts:
--------------------------------------------------------------------------------
1 | description = "Javalin ReDoc Plugin | Serve ReDoc UI for OpenAPI specification"
2 |
3 | dependencies {
4 | api(project(":openapi-specification"))
5 |
6 | implementation("org.webjars.npm:redoc:2.1.4") { // also bump redoc-ui version in OpenApiConfiguration
7 | exclude(group = "org.webjars.npm")
8 | }
9 | implementation("org.webjars.npm:js-tokens:8.0.2")
10 | }
11 |
--------------------------------------------------------------------------------
/openapi-specification/src/main/kotlin/io/javalin/openapi/experimental/OpenApiAnnotationProcessorParameters.kt:
--------------------------------------------------------------------------------
1 | package io.javalin.openapi.experimental
2 |
3 | const val OPENAPI_INFO_TITLE = "openapi.info.title"
4 | const val OPENAPI_INFO_VERSION = "openapi.info.version"
5 |
6 | data class OpenApiAnnotationProcessorParameters(
7 | val info: Info
8 | ) {
9 |
10 | data class Info(
11 | val title: String,
12 | val version: String,
13 | )
14 |
15 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Gradle
2 | org.gradle.daemon=false
3 | org.gradle.parallel=false
4 | org.gradle.jvmargs=-Dfile.encoding=UTF-8
5 | org.gradle.logging.stacktrace=full
6 |
7 | # Kapt
8 | kapt.include.compile.classpath=false
9 | # kapt.incremental.apt=false
10 | # kapt.use.worker.api=false
11 |
12 | # Maven
13 | mavenUser=
14 | mavenPassword=
15 |
16 | # Sonatype
17 | sonatypeUser=
18 | sonatypePassword=
19 |
20 | # Sign
21 | signing.keyId=
22 | signing.password=
23 | signing.secretKeyRingFile=
24 |
--------------------------------------------------------------------------------
/examples/javalin-maven-kotlin/README.md:
--------------------------------------------------------------------------------
1 | # javalin-maven-kotlin
2 |
3 | This is a simple example of a Javalin application using Maven and Kotlin.
4 | In order to generate OpenAPI specification with Maven, run the following command:
5 |
6 | ```shell
7 | $ mvn clean compile
8 | ```
9 |
10 | Once the command is executed, the OpenAPI annotation processor will generate output files in the `target/classes/openapi-plugin` directory.
11 | These files will be picked up by the OpenAPI plugin and hosted at `http://localhost:8080/openapi`.
12 | You can also access the Swagger UI at `http://localhost:8080/swagger-ui`.
13 |
--------------------------------------------------------------------------------
/examples/javalin-gradle-kotlin/src/main/compile/openapi.groovy:
--------------------------------------------------------------------------------
1 | import io.javalin.openapi.experimental.ExperimentalCompileOpenApiConfiguration
2 | import io.javalin.openapi.experimental.OpenApiAnnotationProcessorConfiguration
3 | import io.javalin.openapi.experimental.OpenApiAnnotationProcessorConfigurer
4 |
5 | @ExperimentalCompileOpenApiConfiguration
6 | class OpenApiConfiguration implements OpenApiAnnotationProcessorConfigurer {
7 |
8 | @Override
9 | void configure(OpenApiAnnotationProcessorConfiguration openApiAnnotationProcessorConfiguration) {
10 | // openApiAnnotationProcessorConfiguration.debug = true
11 | }
12 |
13 | }
--------------------------------------------------------------------------------
/.github/workflows/gradle.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 | on:
3 | push:
4 | branches: [ main ]
5 | pull_request:
6 | branches: [ main ]
7 | jobs:
8 | build:
9 | name: "Build with JDK${{ matrix.jdk }}"
10 | runs-on: ubuntu-latest
11 | strategy:
12 | matrix:
13 | jdk: [ 17, 21 ]
14 | steps:
15 | - uses: actions/checkout@v2
16 | - name: Set up JDK
17 | uses: actions/setup-java@v1
18 | with:
19 | java-version: ${{ matrix.jdk }}
20 | - name: Grant execute permission for gradlew
21 | run: chmod +x gradlew
22 | - name: Build with Gradle
23 | run: ./gradlew build
24 | - name: Upload coverage to Codecov
25 | uses: codecov/codecov-action@v1
26 |
--------------------------------------------------------------------------------
/javalin-plugins/javalin-openapi-plugin/src/main/kotlin/io/javalin/openapi/plugin/OpenApiHandler.kt:
--------------------------------------------------------------------------------
1 | package io.javalin.openapi.plugin
2 |
3 | import io.javalin.http.ContentType
4 | import io.javalin.http.Context
5 | import io.javalin.http.Handler
6 | import io.javalin.http.Header
7 |
8 | internal class OpenApiHandler(private val documentation: Lazy