Closed sam0r040 closed 1 month ago
Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.
Hi @sam0r040!
The issue comes with the library we use for parsing YAML, which is js-yaml. There are several issues opened on their repository talking about this. For example: https://github.com/nodeca/js-yaml/issues/161
The summary is that, whenever that parser finds a field that is not an explicit string (without quotes), it fallbacks to some schemas. The default one is called "Core" , and is supposed to be based on YAML spec, so whenever it finds a value with the format of date
, it transforms it into a datetime. Means, it transforms from 2015-07-20
to 2015-07-20T00:00:00.000Z
.
As the first and quick solution, I encourage all those values to be enclosed with quotes. However, I tested their recommendation of using other fallback schemas, in particular the JSON Schema one and the parser is able to parse properly without those errors.
loadedObj = yaml.load(asyncapi, { schema: yaml.JSON_SCHEMA });
All tests are passing, but not 100% sure if adding that could break other documents, so not sure if this possible fix would become a breaking change 🤔
cc @jonaslagoni @magicmatatjahu
This bug gets fixed for both studio
and studio-next
by changes in packages:
@stoplight/spectral-core
https://github.com/stoplightio/spectral/blob/develop/packages/core/package.json#L46
- "ajv": "^8.6.0",
+ "ajv": "^8.17.1",
https://github.com/stoplightio/spectral/commit/4b4b46e33b07225cba206c91555c7e97305ab94b
(changes in other packages are required to build spectral
)
@asyncapi/parser
https://github.com/asyncapi/parser-js/blob/master/packages/parser/package.json#L57
- "ajv": "^8.11.0",
+ "ajv": "^8.17.1",
https://github.com/asyncapi/parser-js/commit/4a9fd5c4fca979ef680df1a634fc2f24026837fe
Compiled directories used:
./packages/parser/cjs
for studio
../packages/parser/esm
for studio-next
.All tests both in @stoplight/spectral-core
and @asyncapi/parser
pass with these changes.
Should I create PRs or might there be some hidden caveats?
It is assumed that an update of a minor version is unlikely to break anything, so the change to @stoplight/spectral-core
is submitted as the PR https://github.com/stoplightio/spectral/pull/2658 to https://github.com/stoplightio/spectral.
https://github.com/stoplightio/spectral/pull/2658 is merged. I hope this will help with @sam0r040's issue.
The second step in fixing this bug is merging of PR https://github.com/asyncapi/parser-js/pull/1042
The third and final step in fixing this bug is the merging of PR https://github.com/asyncapi/studio/pull/1124.
Validation of type date
was fixed in both studio
and studio-next
.
Describe the bug.
AsyncAPI studio shows an error for data type date when YAML is used while data type datetime works fine.
Interestingly enough, if the date string is wrapped in double quotes, the validation error goes away.
Expected behavior
Validation passes for the provided yaml.
Screenshots
How to Reproduce
44:23 "date" property must match format "date"
🥦 Browser
None
👀 Have you checked for similar open issues?
🏢 Have you read the Contributing Guidelines?
Are you willing to work on this issue ?
No, someone else can work on it