-
-
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.
GH-237 Cover OpenApiPlugin setup with basic test
- Loading branch information
Showing
4 changed files
with
54 additions
and
2 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
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 |
---|---|---|
@@ -1,5 +1,11 @@ | ||
description = "Javalin OpenAPI Plugin | Serve raw OpenApi documentation under dedicated endpoint" | ||
|
||
plugins { | ||
kotlin("kapt") | ||
} | ||
|
||
dependencies { | ||
api(project(":openapi-specification")) | ||
|
||
kaptTest(project(":openapi-annotation-processor")) | ||
} |
46 changes: 46 additions & 0 deletions
46
javalin-plugins/javalin-openapi-plugin/src/test/kotlin/OpenApiPluginTest.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,46 @@ | ||
import io.javalin.Javalin | ||
import io.javalin.openapi.OpenApi | ||
import io.javalin.openapi.plugin.OpenApiPlugin | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.assertDoesNotThrow | ||
|
||
class OpenApiPluginTest { | ||
|
||
@OpenApi( | ||
path = "/test", | ||
) | ||
private object OpenApiTest | ||
|
||
@Test | ||
fun `should support schema modifications in definition configuration`() { | ||
assertDoesNotThrow { | ||
Javalin.create { config -> | ||
config.registerPlugin( | ||
OpenApiPlugin { openApiConfig -> | ||
openApiConfig.withDefinitionConfiguration { _, def -> | ||
def.withInfo { | ||
it.title = "My API" | ||
} | ||
} | ||
} | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun `should support empty definition configuration`() { | ||
assertDoesNotThrow { | ||
Javalin.create { config -> | ||
config.registerPlugin( | ||
OpenApiPlugin { | ||
it.withDefinitionConfiguration { _, _ -> | ||
/* do nothing */ | ||
} | ||
} | ||
) | ||
} | ||
} | ||
} | ||
|
||
} |
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