You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
openapi: 3.0.3info:
title: Sample APIdescription: Sample API for inheritanceversion: 0.0.1paths: {}components:
schemas:
Policy:
type: objectproperties:
policyNumber:
description: The insurance policy numbertype: stringexample: IXP12345678startAt:
type: stringformat: date-timepattern: '^[0-9]{4}-[0-9]{2}-[0-9]{2}T[012][0-9]:[0-5][0-9]:[0-5][0-9]Z$'description: The date-time from which this policy becomes activeendAt:
type: stringformat: date-timepattern: '^[0-9]{4}-[0-9]{2}-[0-9]{2}T[012][0-9]:[0-5][0-9]:[0-5][0-9]Z$'description: The date-time from which this policy ceasespolicyType:
type: stringdescription: The type of insurance policy (base set)enum: [CAR, HOME, HEALTH]CarPolicy:
allOf:
- $ref: "#/components/schemas/Policy"
- type: objectproperties:
make:
description: The make of caretype: stringexample: Nissanrange:
description: car model rangetype: stringexample: hatchbackmodel:
description: car modeltype: stringexample: micraregistrationNumber:
description: the registration number of the vehicle type: stringexample: 00G1011value:
type: numberformat: doubledescription: The value of the vehicleexample: 2000.0policyType:
type: stringdescription: specialized policy typeenum: [CAR, CAR-COMPREHENSIVE]
Describe the bug you're encountering
allOf + enum is resulting in a enum array merge when it should actually be an intersection as any instance must validate against all subschemas.
In the example above, the expected result in the composed model would be to have the policyType with enum: [CAR] as CAR is the only enum value existing in both schemas. However a merge of the two enum arrays occurs resulting in enum: [CAR, HOME, HEALTH, CAR, CAR-COMPREHENSIVE] (even duplicates).
To reproduce...
Steps to reproduce the behavior:
Paste the YAML into swagger editor
Expected behavior
allOf + enum is resulting in a enum array merge when it should actually be an intersection as any instance must validate against all subschemas.
Screenshots
Additional context or thoughts
Enums will have to be fixed directly in all-off plugin, before the deepmerge is executed. See this PR for related discussion
The text was updated successfully, but these errors were encountered:
frankkilcommins
changed the title
allOf + enum is resulting in a enum array merge when it should actually be an intersection
allOf + enum is resulting in a enum array merge when it should be an intersection
Feb 23, 2022
Q&A (please complete the following information)
Content & configuration
Paste the
yaml
below into https://editor.swagger.io/Swagger/OpenAPI definition:
Describe the bug you're encountering
allOf + enum
is resulting in a enum array merge when it should actually be an intersection as any instance must validate against all subschemas.In the example above, the expected result in the composed model would be to have the policyType with
enum: [CAR]
as CAR is the only enum value existing in both schemas. However a merge of the two enum arrays occurs resulting inenum: [CAR, HOME, HEALTH, CAR, CAR-COMPREHENSIVE]
(even duplicates).To reproduce...
Steps to reproduce the behavior:
Paste the YAML into swagger editor
Expected behavior
allOf + enum
is resulting in a enum array merge when it should actually be an intersection as any instance must validate against all subschemas.Screenshots
Additional context or thoughts
Enums will have to be fixed directly in all-off plugin, before the deepmerge is executed. See this PR for related discussion
The text was updated successfully, but these errors were encountered: