|
- <%
- ' One Swagger UI dropdown entry per public/api/*.openapi.json (scripts/gen.cmd api writes one per table)
- Dim specFso, specFolder, specFile, specUrls, specName
- Set specFso = Server.CreateObject("Scripting.FileSystemObject")
- specUrls = ""
- If specFso.FolderExists(Server.MapPath("/api")) Then
- Set specFolder = specFso.GetFolder(Server.MapPath("/api"))
- For Each specFile In specFolder.Files
- If LCase(Right(specFile.Name, 13)) = ".openapi.json" Then
- specName = Left(specFile.Name, Len(specFile.Name) - 13)
- If Len(specUrls) > 0 Then
- specUrls = specUrls & ","
- End If
- specUrls = specUrls & "{url:""/api/" & Server.HTMLEncode(specFile.Name) & """,name:""" & Server.HTMLEncode(specName) & """}"
- End If
- Next
- End If
- %>
- <% If Len(specUrls) = 0 Then %>
- <div class="alert alert-info">
- No API specs yet. Generate one for a table with <code>scripts\gen.cmd api /table:<Table> /pk:Id</code>
- (it writes <code>public/api/<table>.openapi.json</code>), then reload this page.
- </div>
- <% Else %>
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui.css" />
- <div id="swagger-ui"></div>
- <script src="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui-bundle.js"></script>
- <script src="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui-standalone-preset.js"></script>
- <script>
- window.ui = SwaggerUIBundle({
- urls: [<%= specUrls %>],
- presets: [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset],
- layout: "StandaloneLayout", // the spec dropdown (urls) only works with the standalone layout
- dom_id: "#swagger-ui",
- deepLinking: true,
- tryItOutEnabled: true
- });
- </script>
- <% End If %>
|