Comments (1)
Agreed. I have just begun playing with Saunter and ran into the same challenge.
Ideally I would like to easily include a "Swashbuckle" style endpoint with an HTML UI.
However, in the mean-time I can settle for generating a static html file I can commit with the application source.
En-route to this I am writing test code that uses Saunter to scan a specific assembly for relevant message formats and plug them into a "Skeleton" AsyncApiDocument. Then the json\yaml must be serialized in order to feed the standard generator with html template.
I had to lift exactly the same code as above into my own project to get this close to working.
Additionally, the serialization needs to ensure proper lower-casing of the serialized asyncapi.json document AND ensure that the asyncapi attribute is tagged with a proper version value.
Relevant code snippets here:
private static void ConvertToHtml(AsyncApiDocument doc)
{
string json = AsyncApiDocToString(doc);
File.WriteAllText("asyncapi.json", json);
using (Process compiler = new Process())
{
compiler.StartInfo.FileName = "ag";
compiler.StartInfo.Arguments = $" asyncapi.json @asyncapi/html-template -o output --force-write --param singleFile=true";
compiler.StartInfo.UseShellExecute = true;
compiler.StartInfo.RedirectStandardOutput = false;
compiler.Start();
compiler.WaitForExit();
}
}
private static string AsyncApiDocToString(AsyncApiDocument doc)
{
string docString = JsonSerializer.Serialize(
doc,
new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
WriteIndented = true,
IgnoreNullValues = true,
Converters =
{
new DictionaryKeyToStringConverter(),
new InterfaceImplementationConverter(),
},
}
);
return docString.Replace("\"asyncApi\": 0,", "\"asyncapi\": \"2.0.0\",");
}
Please consider this an "up-vote" for the suggested solution and related issues.
from saunter.
Related Issues (20)
- [FEATURE] update logo and project URLs
- [FEATURE] Support AOT Trimmed applications HOT 3
- [FEATURE] Migrate to DTO from AsyncApi.Net HOT 7
- Operation types in the side panel index are not correct HOT 1
- Rename & change namespace of project
- Allows greater flexibility in serializer to be used HOT 1
- Allows greater flexibility in bindings to be used HOT 1
- Add in the ability to generate ASYNCAPI Yaml HOT 2
- Publish a global dotnet tool HOT 2
- Produce AsyncAPI documents at build time HOT 2
- Only generate schema on initial request HOT 2
- Produce a standalone Attribute Package
- Implement more dotnet best practises HOT 2
- Add an editorconfig to the project
- Dotnet cli tool can scaffold files
- [📑 Docs]: We need a roadmap!! HOT 3
- [FEATURE] Generate classes based on AsyncAPI document HOT 4
- [FEATURE] Check fmt + test on CI
- [FEATURE] Migrate to target arch HOT 2
- [FEATURE] Allow usages of the annotation attributes on interfaces (not only classes)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from saunter.