-
-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
I tried this:
I tried to build an AsyncAPI v3 document using the FluentBuilder API where an operation references a message.
Minimal reproducible example (reduced from the README):
[Fact]
public void Validate_FluentBuilder_Should_Valid()
{
var channelParameterSchema = new JsonSchemaBuilder().FromType<V2LicenseDefinition>();
var builder = ServiceProvider.GetRequiredService<IV3AsyncApiDocumentBuilder>();
var doc = builder
.WithTitle("Cloud Event API")
.WithVersion("1.0.0")
.WithServer("StreetLightsApi", server => server
.WithHost("https://streetlights.fake.com")
.WithProtocol(AsyncApiProtocol.Http, "2.0")
.WithBinding(new HttpServerBindingDefinition()))
.WithChannel("events", channel => channel
.WithServer("#/servers/StreetLightsApi")
.WithDescription("The endpoint used to publish and subscribe to cloud events")
.WithBinding(new HttpChannelBindingDefinition())
.WithMessage("lightMeasuredEvent", definitionBuilder => { }))
.WithOperation("observeCloudEvents", operation => operation
.WithAction(V3OperationAction.Send)
.WithChannel("#/channels/events")
.WithTitle("ObserveCloudEvents")
.WithDescription("Observes cloud events published by the StreetLightsApi")
.WithBinding(new HttpOperationBindingDefinition
{
Method = HttpMethod.POST,
Type = HttpBindingOperationType.Response
})
.WithMessage("#/components/messages/lightMeasuredEvent"))
.WithMessageComponent("lightMeasuredEvent", message => message
.WithName("LightMeasuredEvent")
.WithDescription("The event fired whenever the luminosity of a light has been measured")
.WithContentType("application/json"))
.Build();
}This happened:
Build() throws a FluentValidation.ValidationException:
Validation failed:
-- Operations.Values[0].Messages[0]:
The operation must reference a message defined by the channel it belongs to
I expected this:
No response
Is there a workaround?
No response
Anything else?
Root cause analysis:
V3OperationMessageValidatorenforces that operation messages must reference channel messages only- During validation,
DereferenceChannelMessage(...)is called with a reference like
#/components/messages/lightMeasuredEvent - This method explicitly rejects non-channel references and throws an
InvalidDataException, which causes the validator to fail
Platform(s)
Windows
Community Notes
- Please vote by adding a π reaction to the issue to help us prioritize.
- If you are interested to work on this issue, please leave a comment.name: Bug Report π
cdavernas
Metadata
Metadata
Assignees
Labels
No labels