asyncapi / asyncapi/parser-js

Payload property named message breaks with null value

Open
#863 10 comments 0 reactions 1 assignee Claimed by @AayushSaini101 View on GitHub
Dominant language
TypeScript
Stars
144
Forks
144
Avg merge
6m
Merged PRs (30d)
11

Description

**Payload property named message breaks with null value**

``` "payload": {
"type": "object",
"properties": {
"message": {
"type": ["string", "null"],
"maxLength": 50
}
},
"required": ["message"],
},
"examples": [{
"name": "return",
"payload": {
"message": null
}
}
]
}
```

It breaks rendering of the asyncapi spec, validation does not give valid errors and studio.asyncapi.com breaks

**Expected result**
It works and renders. Note that this works if the message property is renamed or given a non null example value.

**Actual result**

The following error is given
```
Error thrown during AsyncAPI document validation. Name: Error, message: jsonPath: Cannot read properties of null (reading 'schemaFormat'): _$_property === 'message' && _$_v.schemaFormat === void 0, stack: Error: jsonPath: Cannot read properties of null (reading 'schemaFormat'): _$_property === 'message' && _$_v.schemaFormat === void 0 at v._eval (https://studio.asyncapi.com/static/js/main.f7f7093d.js:2:4494941) at https://studio.asyncapi.com/static/js/main.f7f7093d.js:2:4491179 at https://studio.asyncapi.com/static/js/main.f7f7093d.js:2:4493697 at Array.forEach () at v._walk (https://studio.asyncapi.com/static/js/main.f7f7093d.js:2:4493676) at v._trace (https://studio.asyncapi.com/static/js/main.f7f7093d.js:2:4491130) at v._trace (https://studio.asyncapi.com/static/js/main.f7f7093d.js:2:4490522) at https://studio.asyncapi.com/static/js/main.f7f7093d.js:2:4490621 at https://studio.asyncapi.com/static/js/main.f7f7093d.js:2:4493697 at Array.forEach ()
```

**Steps to reproduce**

Paste the following gist into the asyncapi studio
https://gist.github.com/ly29/6b56cc8252ad48ac681f19ea468d540f

**Troubleshooting**
I have reduced the issue down to one specific property that breaks.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.