asyncapi / bundler

Combine multiple AsyncAPI specification files into one.
Apache License 2.0
29 stars 15 forks source link

fix: add check that `$ref` value is a `string` (#92) #94

Closed aeworxet closed 2 years ago

aeworxet commented 2 years ago

This PR adds to function isExternalReference() additional check if $ref's value passed to it has the type of string (adds type guard for JS version, to which TS code will be transpiled when NPM package is released).

Except general usefulness, it is also a possible indirect fix of an issue reported by user in https://asyncapi.slack.com/archives/CQVJXFNQL/p1666700935030749 (excerpt from the conversation is mirrored in repository's issue https://github.com/asyncapi/bundler/issues/92).

Souvikns commented 2 years ago

You should add some simple test with AsyncAPI document with defined some messages with $ref and without it in .channels.X.publish/subcribe.message and only check if main function throws or not error, ok? :)

I checked this, and bundler just ignores it and resolves it normally, that is fetches the references and replaces them with the original values. Only $refs under $.channels.*.*.message will be fetched and resolved under #components/messages

magicmatatjahu commented 2 years ago

@Souvikns or @derberg Could you make review? I cannot accept 😅

aeworxet commented 2 years ago

Changed tests to logic, that if async function resolved Promise, then it did not throw. All other variants were not acceptable for different reasons. One was even crashing Jest itself.

aeworxet commented 2 years ago

@derberg Updated PR's description to point to related Slack discussion.

aeworxet commented 2 years ago

/rtm

asyncapi-bot commented 2 years ago

:tada: This PR is included in version 0.3.7 :tada:

The release is available on:

Your semantic-release bot :package::rocket: