fix NPE in simplifyOneOfAnyOf (#15142)

This commit is contained in:
William Cheng
2023-04-07 09:34:20 +08:00
committed by GitHub
parent bd7bc9aa79
commit bda2e4a167
3 changed files with 15 additions and 2 deletions

View File

@@ -728,7 +728,7 @@ public class OpenAPINormalizer {
// if only one element left, simplify to just the element (schema)
if (schema.getAnyOf().size() == 1) {
if (schema.getNullable()) { // retain nullable setting
if (Boolean.TRUE.equals(schema.getNullable())) { // retain nullable setting
((Schema) schema.getAnyOf().get(0)).setNullable(true);
}
return (Schema) schema.getAnyOf().get(0);

View File

@@ -36,4 +36,11 @@ components:
enum:
- A
- B
SingleAnyOfTest:
description: to test anyOf (enum string only)
anyOf:
- type: string
enum:
- A
- B

View File

@@ -42,4 +42,10 @@ components:
- type: integer
- type: string
- $ref: null
SingleAnyOfTest:
description: to test anyOf (enum string only)
anyOf:
- type: string
enum:
- A
- B