Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3
Validation Rules
Alex Wichmann edited this page Jun 11, 2025
·
1 revision
Validation Rules can be added, to validate parts of the specification during reading, any errors/warnings will be pushed to the Diagnostics output of the reader.
as an example we could have the following validation rule for a License
varsettings=newAsyncApiReaderSettings();settings.RuleSet.Add(newValidationRule<AsyncApiLicense>((context,item)=>{context.Enter("name");if(item!=null&&item.Name!="MIT"){context.CreateError("license","License MUST be MIT");}context.Exit();}));Given the following AsyncApi specification
asyncapi: 2.6.0info:
title: testversion: 1.0.0license:
name: apachecontact: name: API Supporturl: https://www.example.com/supportemail: support@example.comDiagnostics will contain the following error message.