22
33package io.javalin.openapi.processor
44
5- import io.javalin.openapi.OpenApi
6- import io.javalin.openapi.OpenApiContent
7- import io.javalin.openapi.OpenApiResponse
5+ import io.javalin.openapi.*
86import io.javalin.openapi.processor.specification.OpenApiAnnotationProcessorSpecification
97import net.javacrumbs.jsonunit.assertj.JsonAssertions.json
108import net.javacrumbs.jsonunit.assertj.assertThatJson
@@ -61,7 +59,14 @@ internal class TypeMappersTest : OpenApiAnnotationProcessorSpecification() {
6159 @OpenApi(
6260 path = " simple-types" ,
6361 versions = [" should_map_all_simple_types" ],
64- responses = [OpenApiResponse (status = " 200" , content = [OpenApiContent (from = SimpleTypesList ::class )])]
62+ responses = [
63+ OpenApiResponse (
64+ status = " 200" ,
65+ content = [
66+ OpenApiContent (from = SimpleTypesList ::class ),
67+ ],
68+ ),
69+ ]
6570 )
6671 @Test
6772 fun should_map_all_simple_types () = withOpenApi(" should_map_all_simple_types" ) {
@@ -70,7 +75,9 @@ internal class TypeMappersTest : OpenApiAnnotationProcessorSpecification() {
7075 assertThatJson(it)
7176 .inPath(" $.components.schemas.SimpleTypesList.properties" )
7277 .isObject
73- .isEqualTo(json("""
78+ .isEqualTo(json(
79+ // language=json
80+ """
7481 {
7582 "customType": {
7683 "type": "string"
@@ -193,15 +200,56 @@ internal class TypeMappersTest : OpenApiAnnotationProcessorSpecification() {
193200 }
194201 }
195202 }
196- }"""
203+ }
204+ """
205+ ))
206+ }
207+
208+ @OpenApi(
209+ path = " dictionary-structure" ,
210+ versions = [" should_output_dictionary_structure" ],
211+ responses = [
212+ OpenApiResponse (
213+ status = " 200" ,
214+ content = [
215+ OpenApiContent (
216+ mimeType = " application/map-string-string" ,
217+ additionalProperties = OpenApiAdditionalContent (
218+ from = String ::class ,
219+ exampleObjects = [OpenApiExampleProperty (name = " monke" , value = " banana" )]
220+ )
221+ ),
222+ ],
223+ ),
224+ ]
225+ )
226+ @Test
227+ fun should_output_dictionary_structure () = withOpenApi(" should_output_dictionary_structure" ) {
228+ println (it)
229+
230+ assertThatJson(it)
231+ .inPath(" $.paths['/dictionary-structure'].get.responses.200.content['application/map-string-string'].schema" )
232+ .isObject
233+ .isEqualTo(json(
234+ // language=json
235+ """
236+ {
237+ "type": "object",
238+ "additionalProperties": {
239+ "type": "string"
240+ },
241+ "example": {
242+ "monke": "banana"
243+ }
244+ }
245+ """ ,
197246 ))
198247 }
199248
200249 private class Loop (
201250 val self : Loop ? ,
202251 )
203252
204-
205253 @OpenApi(
206254 path = " recursive" ,
207255 versions = [" should_map_recursive_type" ],
0 commit comments