From 1e2f428cb78f55c8a970827e93eeacee23a76cb9 Mon Sep 17 00:00:00 2001 From: Cody Mikol Date: Tue, 31 May 2022 20:06:01 -0400 Subject: [PATCH] fix(kotlin): properly generate ByteArray property this removes an incorrect wrapper around bytearray properties. Fixes N/A --- .../org/springdoc/api/app6/HelloController.kt | 34 +++++++++++++ .../springdoc/api/app6/SpringDocApp6Test.kt | 31 +++++++++++ .../src/test/resources/results/app6.json | 51 +++++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 springdoc-openapi-kotlin/src/test/kotlin/test/org/springdoc/api/app6/HelloController.kt create mode 100644 springdoc-openapi-kotlin/src/test/kotlin/test/org/springdoc/api/app6/SpringDocApp6Test.kt create mode 100644 springdoc-openapi-kotlin/src/test/resources/results/app6.json diff --git a/springdoc-openapi-kotlin/src/test/kotlin/test/org/springdoc/api/app6/HelloController.kt b/springdoc-openapi-kotlin/src/test/kotlin/test/org/springdoc/api/app6/HelloController.kt new file mode 100644 index 000000000..606dfbfb8 --- /dev/null +++ b/springdoc-openapi-kotlin/src/test/kotlin/test/org/springdoc/api/app6/HelloController.kt @@ -0,0 +1,34 @@ +/* + * + * * Copyright 2019-2022 the original author or authors. + * * + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * + * * https://www.apache.org/licenses/LICENSE-2.0 + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package test.org.springdoc.api.app6 + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +data class Foo(val data: ByteArray) + +@RestController +@RequestMapping("/test") +class ByteArrayTestController { + + @GetMapping("/") + fun foo(): Foo = Foo(byteArrayOf(0)) + +} diff --git a/springdoc-openapi-kotlin/src/test/kotlin/test/org/springdoc/api/app6/SpringDocApp6Test.kt b/springdoc-openapi-kotlin/src/test/kotlin/test/org/springdoc/api/app6/SpringDocApp6Test.kt new file mode 100644 index 000000000..3b1b09262 --- /dev/null +++ b/springdoc-openapi-kotlin/src/test/kotlin/test/org/springdoc/api/app6/SpringDocApp6Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 the original author or authors. + * * + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * + * * https://www.apache.org/licenses/LICENSE-2.0 + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package test.org.springdoc.api.app5 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.AbstractKotlinSpringDocTest + +class SpringDocApp6Test : AbstractKotlinSpringDocTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.app6"]) + open class DemoApplication + +} \ No newline at end of file diff --git a/springdoc-openapi-kotlin/src/test/resources/results/app6.json b/springdoc-openapi-kotlin/src/test/resources/results/app6.json new file mode 100644 index 000000000..cc23209d5 --- /dev/null +++ b/springdoc-openapi-kotlin/src/test/resources/results/app6.json @@ -0,0 +1,51 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/test/": { + "get": { + "tags": [ + "byte-array-test-controller" + ], + "operationId": "foo", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Foo" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Foo": { + "required": [ + "data" + ], + "type": "object", + "properties": { + "data": { + "type": "string", + "format": "byte" + } + } + } + } + } +} \ No newline at end of file