-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
182 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--add-opens=java.base/java.lang=ALL-UNNAMED | ||
--add-opens=java.base/java.io=ALL-UNNAMED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# javalin-maven-kotlin | ||
|
||
This is a simple example of a Javalin application using Maven and Kotlin. | ||
In order to generate OpenAPI specification with Maven, run the following command: | ||
|
||
```shell | ||
$ mvn clean compile | ||
``` | ||
|
||
Once the command is executed, the OpenAPI annotation processor will generate output files in the `target/classes/openapi-plugin` directory. | ||
These files will be picked up by the OpenAPI plugin and hosted at `http://localhost:8080/openapi`. | ||
You can also access the Swagger UI at `http://localhost:8080/swagger-ui`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>io.javalin.community.openapi.examples</groupId> | ||
<artifactId>javalin-apptest</artifactId> | ||
<version>1.0.0</version> | ||
|
||
<properties> | ||
<javalin.version>6.3.0</javalin.version> | ||
<javalin.openapi.version>6.3.0</javalin.openapi.version> | ||
<kotlin.version>2.1.0</kotlin.version> | ||
</properties> | ||
|
||
<repositories> | ||
<repository> | ||
<id>reposilite-repository</id> | ||
<url>https://maven.reposilite.com/snapshots</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<artifactId>kotlin-stdlib</artifactId> | ||
<version>${kotlin.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.javalin</groupId> | ||
<artifactId>javalin</artifactId> | ||
<version>${javalin.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.javalin.community.openapi</groupId> | ||
<artifactId>javalin-openapi-plugin</artifactId> | ||
<version>${javalin.openapi.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.javalin.community.openapi</groupId> | ||
<artifactId>javalin-swagger-plugin</artifactId> | ||
<version>${javalin.openapi.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.javalin.community.openapi</groupId> | ||
<artifactId>javalin-redoc-plugin</artifactId> | ||
<version>${javalin.openapi.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.webjars.npm</groupId> | ||
<artifactId>redoc</artifactId> | ||
<version>2.0.0-rc.56</version> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>*</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.tinylog</groupId> | ||
<artifactId>tinylog-api</artifactId> | ||
<version>2.4.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.tinylog</groupId> | ||
<artifactId>tinylog-impl</artifactId> | ||
<version>2.4.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.tinylog</groupId> | ||
<artifactId>slf4j-tinylog</artifactId> | ||
<version>2.4.1</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<artifactId>kotlin-maven-plugin</artifactId> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<version>2.1.0</version> | ||
|
||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<artifactId>kotlin-maven-plugin</artifactId> | ||
<version>${kotlin.version}</version> | ||
<executions> | ||
<execution> | ||
<id>kapt</id> | ||
<goals> | ||
<goal>kapt</goal> | ||
</goals> | ||
<configuration> | ||
<sourceDirs> | ||
<sourceDir>src/main/kotlin</sourceDir> | ||
</sourceDirs> | ||
<annotationProcessorPaths> | ||
<annotationProcessorPath> | ||
<groupId>io.javalin.community.openapi</groupId> | ||
<artifactId>openapi-annotation-processor</artifactId> | ||
<version>${javalin.openapi.version}</version> | ||
</annotationProcessorPath> | ||
</annotationProcessorPaths> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>compile</id> | ||
<phase>compile</phase> | ||
<goals> | ||
<goal>compile</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
31 changes: 31 additions & 0 deletions
31
examples/javalin-maven-kotlin/src/main/kotlin/io/javalin/openapi/plugin/test/KotlinTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.javalin.openapi.plugin.test | ||
|
||
import io.javalin.Javalin | ||
import io.javalin.openapi.HttpMethod | ||
import io.javalin.openapi.OpenApi | ||
import io.javalin.openapi.plugin.OpenApiPlugin | ||
import io.javalin.openapi.plugin.swagger.SwaggerPlugin | ||
|
||
@OpenApi( | ||
description = "Test description", | ||
summary = "Test summary", | ||
tags = ["test-tag"], | ||
methods = [HttpMethod.GET], | ||
path = "/" | ||
) | ||
fun main() { | ||
Javalin.createAndStart { config -> | ||
config.registerPlugin( | ||
OpenApiPlugin { | ||
it.documentationPath = "/openapi" | ||
} | ||
) | ||
|
||
config.registerPlugin( | ||
SwaggerPlugin { | ||
it.uiPath = "/swagger" | ||
it.documentationPath = "/openapi" | ||
} | ||
) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
examples/javalin-maven-kotlin/src/main/resources/logback.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<configuration> | ||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<root level="info"> | ||
<appender-ref ref="STDOUT"/> | ||
</root> | ||
</configuration> |