StackOverflowError in RAML validator
stmeissner opened this issue · 2 comments
stmeissner commented
Given following type definitions:
#%RAML 1.0 DataType
(package): Error
type: object
displayName: ErrorResponse
description: |
Base representation of an error response containing common fields to all errors.
example: !include ../../examples/Error/ErrorResponse.json
properties:
statusCode:
type: integer
description: |
HTTP status code corresponding to the error.
message:
type: string
description: |
First error message in the `errors` array.
errors?:
type: array
items: ErrorObject
description: |
Errors returned for a request.
A single error response can contain multiple errors if the errors are related to the same HTTP status code such as `400`.
and
#%RAML 1.0 DataType
(package): Error
type: object
displayName: ErrorObject
discriminator: code
properties:
code:
type: string
description: |
Error identifier.
message:
type: string
description: |
Plain text description of the cause of the error.
//:
type: any
description: |
Error-specific additional fields.
validating following example file ../../examples/Error/ErrorResponse.json
fails with a java.lang.StackOverflowError
:
{
"statusCode": 400,
"message": "First error message",
"errors": [
{ "code": "SomeErrorCode", "message": "First error message" },
{ "code": "SomeErrorCode", "message": "Second error message" },
{ "code": "SomeErrorCode", "message": "Third error message" }
]
}
Expected behavior
Validation is successful and no error is reported.
melindafekete commented
The RAML validator was checking that the code
inside the example is actually a type that we have defined. Since SomeErrorCode
does not exist as a discriminatorValue for an ErrorObject, it causes the validation to fail. We can consider introducing a meaningful error message for this, but probably not a super high priority.
thanks Jens for the investigation! 🤗
jenschude commented
Fixed the overflow error in rest-modelling-framework