@@ -8,7 +8,7 @@ class OpenApiJsonUnwrappedsSpec extends AbstractOpenApiTypeElementSpec {
8
8
9
9
void " test JsonUnwrapped annotation" () {
10
10
11
- given :" An API definition"
11
+ given : " An API definition"
12
12
when :
13
13
buildBeanDefinition(' test.MyBean' , '''
14
14
package test;
@@ -91,16 +91,16 @@ class Test {
91
91
@jakarta.inject.Singleton
92
92
class MyBean {}
93
93
''' )
94
- then :" the state is correct"
94
+ then : " the state is correct"
95
95
Utils . testReference != null
96
96
97
- when :" The OpenAPI is retrieved"
97
+ when : " The OpenAPI is retrieved"
98
98
OpenAPI openAPI = Utils . testReference
99
99
Schema schema = openAPI. components. schemas[' Test' ]
100
100
Schema dummySchema = openAPI. components. schemas[' Dummy' ]
101
101
Schema petSchema = openAPI. components. schemas[' Pet' ]
102
102
103
- then :" the components are valid"
103
+ then : " the components are valid"
104
104
schema. type == ' object'
105
105
schema. properties. size() == 13
106
106
schema. properties[' plain' ]. $ref == ' #/components/schemas/Dummy'
@@ -176,4 +176,50 @@ class MyBean {}
176
176
exampleSchema. properties. nameInJson. type == ' string'
177
177
exampleSchema. properties. nameInJson. description == ' example field'
178
178
}
179
+
180
+ void " test issue with JsonUnwrapped and wildcard response type" () {
181
+
182
+ given : " An API definition"
183
+ when :
184
+ buildBeanDefinition(' test.MyBean' , '''
185
+ package test;
186
+
187
+ import com.fasterxml.jackson.annotation.JsonUnwrapped;
188
+ import io.micronaut.http.annotation.Controller;
189
+ import io.micronaut.http.annotation.Post;
190
+ import io.reactivex.Single;
191
+
192
+ @Controller("/test")
193
+ interface TestOperations {
194
+
195
+ @Post
196
+ Single<Test<?>> save(String name, int age);
197
+ }
198
+
199
+ class Base {
200
+
201
+ public String name;
202
+ }
203
+
204
+ class Test<T extends Base> {
205
+ @JsonUnwrapped
206
+ public T wrapped;
207
+ }
208
+
209
+ @jakarta.inject.Singleton
210
+ class MyBean {}
211
+ ''' )
212
+ then : " the state is correct"
213
+ Utils . testReference != null
214
+
215
+ when : " The OpenAPI is retrieved"
216
+ def openApi = Utils . testReference
217
+ Schema schema = openApi.components.schemas.Test_Base_
218
+
219
+ then : " the components are valid"
220
+ schema. type == ' object'
221
+ schema. properties
222
+ schema. properties. size() == 1
223
+ schema. properties. name
224
+ }
179
225
}
0 commit comments