core icon indicating copy to clipboard operation
core copied to clipboard

Introduce ScalarUI

Open valentimarco opened this issue 1 year ago • 3 comments

Description
I really like this new interactive API documentation call ScalarUI and would be great to add it

Example
At the moment I implemented using Twig Replacement

valentimarco avatar Aug 24 '24 17:08 valentimarco

Would you be able to document this? Thanks!

soyuka avatar Aug 29 '24 20:08 soyuka

What should i do document? i can describe what i did to make that possible:

  1. Create a twig file under /templates/bundles/ApiPlatformBundle/SwaggerUi/index.html.twig
  2. Copy the html below:
  {# templates/bundles/ApiPlatformBundle/SwaggerUi/index.html.twig #}
  {% set openApiJson = swagger_data["spec"] %}
  <!doctype html>
  <html>
  <head>
      <title>Scalar API Reference</title>
      <meta charset="utf-8"/>
      <meta
              name="viewport"
              content="width=device-width, initial-scale=1"/>
  </head>
  <body>
  <script
          id="api-reference"
          type="application/json">{{ openApiJson| json_encode | raw }}</script>
  <script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script> 
  </body>
  </html>
  1. Under api_platform.yaml, define the following properties: tittle, description and version.

I tested using a Jwt token in a custom header as authentication

valentimarco avatar Aug 29 '24 23:08 valentimarco

this is awesome you could probably add it to https://github.com/api-platform/docs/blob/3.3/core/openapi.md ?

soyuka avatar Aug 30 '24 08:08 soyuka

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 29 '24 17:10 stale[bot]