Skip to content

Commit

Permalink
[openapi-normalizer] Fix nullable boolean check in oneOf schema (#15276)
Browse files Browse the repository at this point in the history
* fix nullable boolean check in oneof

* minor fix

* fix spec
  • Loading branch information
wing328 committed Apr 22, 2023
1 parent b5745e6 commit e51908f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ private Schema processSimplifyOneOf(Schema schema) {

// if only one element left, simplify to just the element (schema)
if (schema.getOneOf().size() == 1) {
if (schema.getNullable()) { // retain nullable setting
if (Boolean.TRUE.equals(schema.getNullable())) { // retain nullable setting
((Schema) schema.getOneOf().get(0)).setNullable(true);
}
return (Schema) schema.getOneOf().get(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,27 @@ components:
number:
anyOf:
- $ref: '#/components/schemas/Number'
ParentWithOneOfProperty:
type: object
properties:
number:
oneOf:
- $ref: '#/components/schemas/Number'
ParentWithPluralOneOfProperty:
type: object
properties:
number:
oneOf:
- $ref: '#/components/schemas/Number'
- $ref: '#/components/schemas/Number2'
Number:
enum:
- one
- two
- three
type: string
Number2:
enum:
- one
- two
type: string

0 comments on commit e51908f

Please sign in to comment.