Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: vnext schema refs #185

Open
wants to merge 4 commits into
base: vnext
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion test/LEGO.AsyncAPI.Tests/Models/AsyncApiReference_Should.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,10 @@ public void AsyncApiReference_WithExternalResourcesInterface_DeserializesCorrect
var message = doc.Channels["workspace"].Publish.Message.First();
message.Name.Should().Be("Test");
var payload = message.Payload.As<AsyncApiJsonSchemaPayload>();
payload.Properties.Count.Should().Be(3);
payload.Properties.Count.Should().Be(4);
payload.Properties["orderHistory"].Properties.Count.Should().Be(2);
payload.Properties["orderHistory"].Properties["historyStorageRecord"].Properties.First().Key.Should()
.Be("historyLog");
}

[Test]
Expand Down Expand Up @@ -426,6 +429,8 @@ public string Load(string reference)
userName:
description: User name.
type: string
orderHistory:
$ref: '#/components/OrderHistory'
Copy link
Collaborator

@VisualBean VisualBean Jul 1, 2024

Choose a reason for hiding this comment

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

these component refs are wrong.
its usually #/components/{componentType}/{refId}, which also means the components object is technically invalid in this test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @VisualBean I've updated with valid componentType object now I think. It's still not resolving though so I think the initial thought about internals not being resolved in externals is still valid.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ive debugged through it, and it seems to stem from the externalReferenceResolver.
Basically when the external reference is loaded, the subreferences are internal. So the ResolveReference method simply returns null.

if (reference.IsExternal)
{
   ...
   return externalAsyncApiContent;
}

return null;

So - hopefully my referenceresolution followup PR will fix it.

required:
- orderId
example:
Expand All @@ -434,6 +439,23 @@ public string Load(string reference)
orderDetails:
userId: Admin
userName: Admin
components:
OrderHistory:
type: object
properties:
historyId:
description: ID for order history storage
type: string
format: uuid
historyStorageRecord:
$ref: '#/components/HistoryStorageRecord'
HistoryStorageRecord:
type: object
properties:
historyLog:
type: array
items:
type: string
""";
}
}
Expand Down
Loading