From 938a604285fe8403ba77d989b19289f771231fa6 Mon Sep 17 00:00:00 2001 From: Ryan Brink <5607577+rgbrizzlehizzle@users.noreply.github.com> Date: Tue, 4 May 2021 14:37:16 -0400 Subject: [PATCH] updated playground (#46) --- .../leafygreens/kompendium/playground/Main.kt | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/kompendium-playground/src/main/kotlin/org/leafygreens/kompendium/playground/Main.kt b/kompendium-playground/src/main/kotlin/org/leafygreens/kompendium/playground/Main.kt index 9a978cc25..4ba2e0585 100644 --- a/kompendium-playground/src/main/kotlin/org/leafygreens/kompendium/playground/Main.kt +++ b/kompendium-playground/src/main/kotlin/org/leafygreens/kompendium/playground/Main.kt @@ -43,6 +43,7 @@ import org.leafygreens.kompendium.models.oas.OpenApiSpecServer import org.leafygreens.kompendium.playground.KompendiumTOC.testAuthenticatedSingleGetInfo import org.leafygreens.kompendium.playground.KompendiumTOC.testGetWithExamples import org.leafygreens.kompendium.playground.KompendiumTOC.testIdGetInfo +import org.leafygreens.kompendium.playground.KompendiumTOC.testPostWithExamples import org.leafygreens.kompendium.playground.KompendiumTOC.testSingleDeleteInfo import org.leafygreens.kompendium.playground.KompendiumTOC.testSingleGetInfo import org.leafygreens.kompendium.playground.KompendiumTOC.testSingleGetInfoWithThrowable @@ -116,7 +117,8 @@ fun Application.configModule() { notarizedException( info = ResponseInfo( KompendiumHttpCodes.BAD_REQUEST, - "Bad Things Happened" + "Bad Things Happened", + examples = mapOf("example" to ExceptionResponse("hey bad things happened sorry")) ) ) { call.respond(HttpStatusCode.BadRequest, ExceptionResponse("Why you do dis?")) @@ -136,6 +138,9 @@ fun Application.mainModule() { notarizedGet(testGetWithExamples) { call.respond(HttpStatusCode.OK) } + notarizedPost(testPostWithExamples) { + call.respond(HttpStatusCode.Created, ExampleResponse("hey")) + } } route("/test") { route("/{id}") { @@ -207,7 +212,29 @@ object KompendiumTOC { description = "nice", examples = mapOf("test" to ExampleResponse(c = "spud")) ), + canThrow = setOf(Exception::class) ) + @Suppress("MagicNumber") + val testPostWithExamples = PostInfo( + summary = "Full Example", + description = "Throws just about all Kompendium has to offer into one endpoint", + requestInfo = RequestInfo( + description = "Necessary deetz", + examples = mapOf( + "Send This" to ExampleRequest(ExampleNested("potato"), 13.37, listOf(12341)) + ) + ), + responseInfo = ResponseInfo( + status = KompendiumHttpCodes.CREATED, + description = "Congratz you hit da endpoint", + examples = mapOf( + "Expect This" to ExampleResponse(c = "Hi"), + "Or This" to ExampleResponse(c = "Hey") + ) + ), + canThrow = setOf(Exception::class) + ) + val testIdGetInfo = GetInfo( summary = "Get Test", description = "Test for the getting",