dankinsoid / VaporToOpenAPI

OpenAPI specification generator for Vapor based Swift projects.
MIT License
98 stars 8 forks source link

Support Stoplight Elements Visualisation #23

Closed Sherlouk closed 4 months ago

Sherlouk commented 4 months ago

https://stoplight.io/open-source/elements is a beautiful renderer for OpenAPI documentation.

The file which needs to be rendered is as simple as this:

<!doctype html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <title>TITLE</title>

  <script src="https://unpkg.com/@stoplight/elements/web-components.min.js"></script>
  <link rel="stylesheet" href="https://unpkg.com/@stoplight/elements/styles.min.css">
</head>

<body>
  <elements-api apiDescriptionUrl="PATH TO OPEN API" router="hash" />
</body>

</html>

Passing in the path to the OpenAPI documentation which this project already creates, it creates a beautiful and interactive page such as this: https://elements-demo.stoplight.io/#/

It's a much more modern version in comparison to SwaggerUI which this project currently recommends, and would be much more trivial to provide as a simple one line route rather than complex FileMiddleware and file structures.

dankinsoid commented 4 months ago

@Sherlouk thank you very much!