fastify / fastify-swagger

Swagger documentation generator for Fastify
MIT License
889 stars 199 forks source link

Generate json without swagger-ui #759

Closed dennys closed 9 months ago

dennys commented 9 months ago

Prerequisites

Issue

I can use fastify-swagger with fastify-swagger-ui now, but I want to remove swagger-ui and generate json for RapicDoc. Based on the hint, I can use fastify.swagger() to generate a json without swagger-ui.

 fastify.get('/doc', opts, async (request, reply) => {
      reply.send(fastify.swagger())
    });

Then I can integrate it to RapiDoc

<!doctype html> <!-- Important: must specify -->
<html>
  <head>
    <meta charset="utf-8"> <!-- Important: rapi-doc uses utf8 characters -->
    <script type="module" src="rapidoc-min.js"></script>
  </head>
  <body>
    <rapi-doc spec-url = "http://localhost:3000/doc"> </rapi-doc>
  </body>
</html>

Is this a correct/good solution?

mcollina commented 9 months ago

Yes