OpenAPI codegen with swagger.json , openapi.json or openapi.yaml

System Information
  • 3.6.8:
  • Windows10:
  • SQLite:
  • 14.17.5:
  • 6.14.14:
  • 1.22.10:

I am used to download a definition file on the swagger page of an api and generate client code for it.
However with strapi I cant find a swagger-file download link on http://localhost:1337/documentation/v1.0.0

Trying to download
http://localhost:1337/documentation/v1.0.0/swagger.json
or http://localhost:1337/documentation/v1.0.0/openapi.json
or http://localhost:1337/documentation/v1.0.0/openapi.yaml
just returns a 404.

Does anyone know how to get a definition file to use it with codegens?

Hint: Downloading OpenAPI Definitions From SwaggerHub | SwaggerHub Documentation

Thanks!

1 Like

Ciao!
I am here because I am looking for the same thing. I want to generate client code, in order to do that I need access to openapi.json/yaml or similar.

I didn’t find what I am looking for but the workaround is to inspect the documentation HTTP response:

  <body>
    <div id="swagger-ui"></div>
    <script class="custom-swagger-ui">
      window.onload = function() {
        const ui = SwaggerUIBundle({
          url: "https://petstore.swagger.io/v2/swagger.json",
          spec: {"openapi":"3.0.0","info":{"vers ......
          dom_id: '#swagger-ui',
          docExpansion: "none",
          deepLinking: true,
          presets: [
            SwaggerUIBundle.presets.apis,
            SwaggerUIStandalonePreset,
          ],
          plugins: [
            SwaggerUIBundle.plugins.DownloadUrl,
          ],
          layout: "StandaloneLayout",
        });

        window.ui = ui;
      }

spec contains the information I am looking for. It will be nice to have access to this file in another way but I didn’t figure it out yet

Same here. It would be great if Strapi documentation plugin would spit out some sort of schema file that could be consumed by openapi generator. In my case, I had to switch from REST to GraphQL just to be able to generate the frontend query types and hooks for consuming the api.

In most codegens you can paste the relative path of the file as an input path.
In my case I have a next app with a codegen and a strapi app.
My path input path for the codegen is:
…/strapi-app/src/extensions/documentation/documentation/1.0.0/full_documentation.json

1 Like