C4-Builder
C4-Builder copied to clipboard
Script tag execution and openapi rendering
closes #61
Supports script
tag execution in MD file
Supports Swagger UI for openapi specs loading using html and script tag in MD file as below
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta
name="description"
content="SwaggerIU"
/>
<title>SwaggerUI</title>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/swagger-ui.css" />
</head>
<body>
<div id="swagger-ui"></div>
<script>
window.onload = () => {
window.ui = SwaggerUIBundle({
url: 'https://petstore3.swagger.io/api/v3/openapi.json',
dom_id: '#swagger-ui',
});
};
</script>
</body>
</html>
@adrianvlupu Please help review the changes and let me know if we need any adjustments as this is my time engaging in this project.
If all good please help merge these changes when you get a chance. Hope it will help incorporate API specs along with awesome plantuml C4design artifacts.
@vellala2000 Have some questions around this one (I haven't tested it so)
- Does it work with local openapi.json files? (having a documentation failing because the web api isn't running seems wrong)
- The Swagger UI present a readonly presentation or are you able to make API calls from it? (Normally I have Swagger activated on my Web API:s in dev/test stage)
- What happens if you generate a PDF? If it breaks or looks totally weird should it be special case handling for that.
And also a small comment: The option naming should be something like includeSwagger instead of executeScript because it only includes the JS link or not.
@MickeJohannesson
-
Yes its working with local and remote JSON file
-
Try it out feature available and working in swagger UI
-
PDF is generating okay with just one liner showing folder name and path with the example code(see below). it depends on what user decided to do with
<html>
and -
The flag name is actually borrowed from docsify, it enables
@vellala2000 I think this is a good addon, even though I would like an automatic generated md file with all content instead of the SwaggerUI generation (Need to have the PDF in some cases). Like you add the json-file in the /src directory and in the /docs there would be a generated MD file.
Regarding the naming, sorry but I missed the option in the docsify option. Naming makes more sense then :)
Still will test it out to see how it works, but I haven't got the time at the moment
Yeah I understand where you are coming from.
I looked into widdershins which converts specs into MD file and it looks decent enough for old school :).
to be fair its not easy to make specs readable in documentation.
I am looking forward to use this functionality soon. no pressure :)
this actually completes all types of design documents I am trying to showcase.
I am able to do openapi rendering by using existing custom docsify template option.