Consolidated ASP Classic MVC framework from best components
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

40 lignes
1.7KB

  1. <%
  2. ' One Swagger UI dropdown entry per public/api/*.openapi.json (scripts/gen.cmd api writes one per table)
  3. Dim specFso, specFolder, specFile, specUrls, specName
  4. Set specFso = Server.CreateObject("Scripting.FileSystemObject")
  5. specUrls = ""
  6. If specFso.FolderExists(Server.MapPath("/api")) Then
  7. Set specFolder = specFso.GetFolder(Server.MapPath("/api"))
  8. For Each specFile In specFolder.Files
  9. If LCase(Right(specFile.Name, 13)) = ".openapi.json" Then
  10. specName = Left(specFile.Name, Len(specFile.Name) - 13)
  11. If Len(specUrls) > 0 Then
  12. specUrls = specUrls & ","
  13. End If
  14. specUrls = specUrls & "{url:""/api/" & Server.HTMLEncode(specFile.Name) & """,name:""" & Server.HTMLEncode(specName) & """}"
  15. End If
  16. Next
  17. End If
  18. %>
  19. <% If Len(specUrls) = 0 Then %>
  20. <div class="alert alert-info">
  21. No API specs yet. Generate one for a table with <code>scripts\gen.cmd api /table:&lt;Table&gt; /pk:Id</code>
  22. (it writes <code>public/api/&lt;table&gt;.openapi.json</code>), then reload this page.
  23. </div>
  24. <% Else %>
  25. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui.css" />
  26. <div id="swagger-ui"></div>
  27. <script src="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui-bundle.js"></script>
  28. <script src="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui-standalone-preset.js"></script>
  29. <script>
  30. window.ui = SwaggerUIBundle({
  31. urls: [<%= specUrls %>],
  32. presets: [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset],
  33. layout: "StandaloneLayout", // the spec dropdown (urls) only works with the standalone layout
  34. dom_id: "#swagger-ui",
  35. deepLinking: true,
  36. tryItOutEnabled: true
  37. });
  38. </script>
  39. <% End If %>

Powered by TurnKey Linux.