Commit f5b9eae
authored
openapi: Fix mutual-recursion bug in scala 2.13 (issue 4911) (#4916)
Contains the fix for a few disparate things:
- fix runtime stackoverflow for mutually-recursive scheme definitions in
scala 2.13 ([issue](#4911))
- permit defining schema aliases for simple types (i.e
```yaml
ClientIdParameterStr:
type: string
```
becomes `type ClientIdParameterStr = String`)
- handle missing descriptions on responses (these are technically
required by the spec, but often absent IRL)
- handle non-200 streaming responses with descriptions
- handle optional streaming responses with empty alternatives defined
for other status codes
- produce io.circe.JsonObject for [free-form
object](https://swagger.io/docs/specification/v3_0/data-models/data-types/#free-form-object)
types, rather than empty case classes (note that old behaviour can be
achieved by adding an empty `properties` map to the definition; but that
an empty case class was never an appropriate model to generate for a
free form object). This is not always going to be the correct model --
arguably, for any non-json endpoint, it's probably not ideal -- but it's
the most generic model that's known to be available, and which can be
generally mapped to object schema definitions.
- handle inline enum definitions in paths
- default `*/*` to strict for convenience (this behaviour can be
overridden by the appropriate directives, but seems like it's _probably_
a saner default)
Includes the swagger from
https://nifi.apache.org/nifi-docs/swagger.yaml, which prompted these
fixes - since it's an OSS apache project, that seems legit - along with
a few modifications to it (mostly commenting out some security
declarations, although also removes some 'object' wrappers around what
would otherwise be primitive schema declarations, fudges the wrapper
around `BulletinBoardPatternParameter` a bit since doing otherwise would
require supporting objects in query params, and adds a `flows` field to
the `HTTPBearerJWT` decl. Doesn't address the fact that some query
params look like they should probably be arrays judging by the
description, nor does it try to make sense of the security declarations
since they don't match up with any openapi conventions I'm aware of).
This is a pretty chunky spec and adds a couple of mins to the openapi
test duration, but I think it's worth it to get the extra coverage...
Given the nature of the bug, we not only run the check to validate
expected scala output and that the code compiles, but also explicitly
check that the `controllerServiceReferencingComponentDTOTapirSchema`
schema doesn't throw a `StackOverflow` at runtime.1 parent a583cd0 commit f5b9eae
File tree
21 files changed
+33646
-75
lines changed- openapi-codegen
- core/src
- main/scala/sttp/tapir/codegen
- openapi/models
- test/scala/sttp/tapir/codegen
- models
- sbt-plugin/src/sbt-test/sbt-openapi-codegen
- nifi_test
- project
- src/main/scala
- oneOf-json-roundtrip_jsoniter
21 files changed
+33646
-75
lines changedLines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
| |||
196 | 197 | | |
197 | 198 | | |
198 | 199 | | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
199 | 207 | | |
200 | 208 | | |
201 | 209 | | |
| |||
Lines changed: 50 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
102 | 110 | | |
103 | 111 | | |
104 | 112 | | |
| |||
119 | 127 | | |
120 | 128 | | |
121 | 129 | | |
| 130 | + | |
| 131 | + | |
122 | 132 | | |
123 | 133 | | |
124 | 134 | | |
| |||
211 | 221 | | |
212 | 222 | | |
213 | 223 | | |
214 | | - | |
| 224 | + | |
215 | 225 | | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
216 | 229 | | |
217 | 230 | | |
218 | 231 | | |
| |||
253 | 266 | | |
254 | 267 | | |
255 | 268 | | |
256 | | - | |
| 269 | + | |
| 270 | + | |
257 | 271 | | |
258 | 272 | | |
259 | 273 | | |
| |||
280 | 294 | | |
281 | 295 | | |
282 | 296 | | |
| 297 | + | |
283 | 298 | | |
284 | 299 | | |
285 | 300 | | |
286 | 301 | | |
287 | | - | |
288 | | - | |
289 | | - | |
| 302 | + | |
| 303 | + | |
290 | 304 | | |
291 | 305 | | |
292 | 306 | | |
| |||
328 | 342 | | |
329 | 343 | | |
330 | 344 | | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
331 | 348 | | |
332 | 349 | | |
333 | 350 | | |
334 | 351 | | |
335 | 352 | | |
336 | 353 | | |
337 | | - | |
| 354 | + | |
338 | 355 | | |
339 | 356 | | |
340 | 357 | | |
341 | 358 | | |
342 | | - | |
| 359 | + | |
343 | 360 | | |
344 | 361 | | |
345 | 362 | | |
| |||
352 | 369 | | |
353 | 370 | | |
354 | 371 | | |
355 | | - | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
356 | 376 | | |
357 | 377 | | |
358 | 378 | | |
359 | 379 | | |
360 | | - | |
| 380 | + | |
361 | 381 | | |
362 | 382 | | |
363 | | - | |
364 | | - | |
| 383 | + | |
| 384 | + | |
365 | 385 | | |
366 | | - | |
367 | | - | |
368 | | - | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
369 | 392 | | |
370 | 393 | | |
371 | 394 | | |
| |||
382 | 405 | | |
383 | 406 | | |
384 | 407 | | |
385 | | - | |
| 408 | + | |
386 | 409 | | |
387 | 410 | | |
388 | 411 | | |
| |||
505 | 528 | | |
506 | 529 | | |
507 | 530 | | |
508 | | - | |
509 | | - | |
| 531 | + | |
510 | 532 | | |
511 | 533 | | |
512 | 534 | | |
| |||
651 | 673 | | |
652 | 674 | | |
653 | 675 | | |
654 | | - | |
655 | | - | |
| 676 | + | |
656 | 677 | | |
657 | 678 | | |
658 | 679 | | |
| |||
770 | 791 | | |
771 | 792 | | |
772 | 793 | | |
| 794 | + | |
773 | 795 | | |
774 | 796 | | |
775 | | - | |
776 | | - | |
777 | | - | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
778 | 801 | | |
779 | 802 | | |
780 | 803 | | |
| |||
834 | 857 | | |
835 | 858 | | |
836 | 859 | | |
| 860 | + | |
| 861 | + | |
837 | 862 | | |
838 | 863 | | |
839 | | - | |
| 864 | + | |
840 | 865 | | |
841 | 866 | | |
842 | | - | |
| 867 | + | |
843 | 868 | | |
844 | 869 | | |
845 | 870 | | |
846 | 871 | | |
847 | 872 | | |
848 | | - | |
| 873 | + | |
849 | 874 | | |
850 | 875 | | |
851 | 876 | | |
| |||
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
152 | 153 | | |
153 | 154 | | |
154 | 155 | | |
| 156 | + | |
155 | 157 | | |
156 | 158 | | |
157 | 159 | | |
| |||
276 | 278 | | |
277 | 279 | | |
278 | 280 | | |
279 | | - | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
280 | 288 | | |
281 | 289 | | |
282 | 290 | | |
| |||
333 | 341 | | |
334 | 342 | | |
335 | 343 | | |
| 344 | + | |
336 | 345 | | |
337 | 346 | | |
338 | 347 | | |
| |||
492 | 501 | | |
493 | 502 | | |
494 | 503 | | |
| 504 | + | |
495 | 505 | | |
496 | 506 | | |
497 | 507 | | |
| |||
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
360 | 361 | | |
361 | 362 | | |
362 | 363 | | |
363 | | - | |
364 | | - | |
| 364 | + | |
| 365 | + | |
365 | 366 | | |
366 | 367 | | |
367 | 368 | | |
| |||
0 commit comments