Skip to content

fix: Schema declaration in message & record unresolved $ref#1488

Merged
jfallows merged 8 commits intoaklivity:developfrom
ankitk-me:asyncapi-ref-error-handling
Jun 26, 2025
Merged

fix: Schema declaration in message & record unresolved $ref#1488
jfallows merged 8 commits intoaklivity:developfrom
ankitk-me:asyncapi-ref-error-handling

Conversation

@ankitk-me
Copy link
Contributor

Fixes #1466

@ankitk-me ankitk-me marked this pull request as ready for review June 19, 2025 14:43
@ankitk-me ankitk-me requested a review from jfallows June 19, 2025 14:43
Comment on lines +52 to +65
public Set<String> unresolved()
{
Stream.of(
channels.unresolved(),
operations.unresolved(),
messages.unresolved(),
securitySchemes.unresolved(),
schemas.unresolved(),
messageTraits.unresolved(),
serverVariables.unresolved(),
correlationIds.unresolved())
.forEach(unresolved::addAll);

return unresolved;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this method is called more than once then unresolved refs will be added multiple times.
Suggest moving the instantiation of unresolved into the unresolved() method.
Perhaps rename method to unresolvedRefs().

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, instead of instantiating and copying each list of individual unresolved refs into one larger collection, perhaps create unresolved collection up front (as you have done) and pass it into each sub resolver to use to collect unresolved refs, then this unresolved() method can just return unresolved without needing to copy.

Comment on lines +91 to +95
public Set<String> unresolved()
{
return resolver.unresolved();
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public Set<String> unresolved()
{
return resolver.unresolved();
}
public Set<String> unresolvedRefs()
{
return resolver.unresolvedRefs();
}

"${composite}/http/create.pet/client",
"${asyncapi}/http/create.pet/server"
})
public void shouldPublishEventUnresolvedRef() throws Exception
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public void shouldPublishEventUnresolvedRef() throws Exception
public void shouldLogEventUnresolvedRef() throws Exception

Comment on lines +67 to +73
public Set<String> unresolved()
{
return Stream.concat(
channels.unresolved().stream(),
messages.unresolved().stream())
.collect(Collectors.toSet());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See feedback in AsyncapiVIew about avoiding the copy for unresolved refs.

Comment on lines +66 to +72
public Set<String> unresolved()
{
return unresolved
.stream()
.map(r -> r.ref)
.collect(Collectors.toSet());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See feedback in AsyncapiVIew about avoiding the copy for unresolved refs.

if (value.containsKey("$ref"))
{
parser.next();
AsyncapiSchemaItem asyncapiSchemaItem = new AsyncapiSchemaItem();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
AsyncapiSchemaItem asyncapiSchemaItem = new AsyncapiSchemaItem();
AsyncapiSchemaItem schemaItem = new AsyncapiSchemaItem();

@jfallows jfallows merged commit a661051 into aklivity:develop Jun 26, 2025
40 of 41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validate $ref in AsyncAPI Schema

2 participants