Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

JSON validator becomes confused when two unrelated classes have same discriminatorValue. #424

Open
diggernet opened this issue Feb 29, 2020 · 0 comments

Comments

@diggernet
Copy link

Version: 3.0.7
Scenario: Define two unrelated types with discriminators, and subtypes of them which happen to have the same discriminatorValue.
Error:
[ERROR] Failed to execute goal org.raml.jaxrs:raml-to-jaxrs-maven-plugin:3.0.7:generate (default) on project schema-test: Error generating Java classes from: null: [Error validating JSON. Error: - Missing required field "animalType"
[ERROR] - Missing required field "age"
[ERROR] - Missing required field "spots" -- C:/path/to/test.raml [line=38, col=14]]

Note that line 38 is the reference for vehicle.json. It is looking for Animal and Cat fields in the Vehicle->Jaguar JSON.

Commenting out the example declarations allows a successful build, with apparently-correct code generated. Only the validation step appears broken.

test.raml:
`
#%RAML 1.0 Library

types:
Response:
type: object
properties:
myPet:
type: Animal
myCar:
type: Vehicle

Animal:
type: object
discriminator: animalType
properties:
animalType: string
age: integer

Cat:
type: Animal
discriminatorValue: JAGUAR
properties:
spots: boolean
example: !include examples/animal.json

Vehicle:
type: object
discriminator: vehicleType
properties:
vehicleType: string
color: string

Jaguar:
type: Vehicle
discriminatorValue: JAGUAR
properties:
model: string
example: !include examples/vehicle.json
`

animal.json:
{ "animalType": "JAGUAR", "age": 3, "spots": false }

vehicle.json
{ "vehicleType": "JAGUAR", "color": "red", "model": "XK120" }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant