← 返回首页
Extensions · ByteBardOrg/AsyncAPI.NET Wiki · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

Extensions

Alex Wichmann edited this page Jun 11, 2025 · 2 revisions
document.Extensions = new Dictionary<string, IAsyncApiExtension> { ["boolean"] = new AsyncApiAny(false), ["string"] = new AsyncApiAny("test"), ["decimal"] = new AsyncApiAny(2.2), ["int"] = new AsyncApiAny(1), ["array"] = new AsyncApiAny(new List<string>()), ["object"] = new AsyncApiAny(new { test = 123 }), };

Extension parsers

Extension parsers enable you to transform extensions, in any way you want. See example below.

asyncapi: 2.3.0 info: title: test version: 1.0.0 contact: name: API Support url: https://www.example.com/support email: support@example.com channels: workspace: x-someValue: onetwothreefour
Func<AsyncApiAny, IAsyncApiExtension> valueExtensionParser = (any) => { if (any.TryGetValue<string>(out var value)) { if (value == "onetwothreefour") { return new AsyncApiAny(1234); } } return new AsyncApiAny("No value provided"); }; var settings = new AsyncApiReaderSettings { ExtensionParsers = new Dictionary<string, Func<AsyncApiAny, IAsyncApiExtension>> { { "x-someValue", valueExtensionParser }, }, }; var reader = new AsyncApiStringReader(settings); var doc = reader.Read(yaml, out var diagnostic); Assert.AreEqual(AsyncApiAny.FromExtensionOrDefault<int>(doc.Channels["workspace"].Extensions["x-someValue"]), 1234); // True

Toggle table of contents Pages 8

Clone this wiki locally

Footer

© 2026 GitHub, Inc.