-
-
Notifications
You must be signed in to change notification settings - Fork 502
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kotlin enums are always marked as required if used in Java controllers.
Fixes #2622
- Loading branch information
1 parent
cf12547
commit 524c5fa
Showing
4 changed files
with
109 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
18 changes: 18 additions & 0 deletions
18
...napi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app12/EnumController.java
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,18 @@ | ||
package test.org.springdoc.api.app12; | ||
|
||
import jakarta.annotation.Nullable; | ||
import test.org.springdoc.api.app12.SpringDocApp12Test.MyEnum; | ||
|
||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* @author bnasslahsen | ||
*/ | ||
@RestController | ||
public class EnumController { | ||
@GetMapping("/test-enum-2") | ||
String testEnum2(@Nullable MyEnum e) { | ||
return ""; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...pi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app12/SpringDocApp12Test.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,35 @@ | ||
/* | ||
* | ||
* * Copyright 2019-2023 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.app12 | ||
|
||
import org.springframework.boot.autoconfigure.SpringBootApplication | ||
import org.springframework.context.annotation.ComponentScan | ||
import test.org.springdoc.api.AbstractKotlinSpringDocMVCTest | ||
|
||
class SpringDocApp12Test : AbstractKotlinSpringDocMVCTest() { | ||
|
||
@SpringBootApplication | ||
@ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.app12"]) | ||
class DemoApplication | ||
|
||
enum class MyEnum { | ||
A, B; | ||
} | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
...openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app12.json
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,50 @@ | ||
{ | ||
"openapi": "3.0.1", | ||
"info": { | ||
"title": "OpenAPI definition", | ||
"version": "v0" | ||
}, | ||
"servers": [ | ||
{ | ||
"url": "http://localhost", | ||
"description": "Generated server url" | ||
} | ||
], | ||
"paths": { | ||
"/test-enum-2": { | ||
"get": { | ||
"tags": [ | ||
"enum-controller" | ||
], | ||
"operationId": "testEnum2", | ||
"parameters": [ | ||
{ | ||
"name": "e", | ||
"in": "query", | ||
"required": false, | ||
"schema": { | ||
"type": "string", | ||
"enum": [ | ||
"A", | ||
"B" | ||
] | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"content": { | ||
"*/*": { | ||
"schema": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"components": {} | ||
} |