docs icon indicating copy to clipboard operation
docs copied to clipboard

Lightning API docs

Open mtuchi opened this issue 2 months ago • 3 comments

Continue from #673 Next steps

  • We need to add support for Open API Spec on lightning. use this library https://github.com/open-api-spex/open_api_spex
  • After adding that library create a demo spec eg project_controller_spec.ex to show the structure
  • generate openapi.yaml file and put it in a directory that can be fetch via http request, eg static/openapi.yaml
  • In docs repo use "docusaurus-plugin-openapi-docs": "^4.5.1", "docusaurus-theme-openapi-docs": "^4.5.1", to generate docs. In docusaurus.config.ts We can specify
 plugins: [
    [
      'docusaurus-plugin-openapi-docs',
      {
        id: 'api',
        docsPluginId: 'classic',
        config: {
          lightning: {
            specPath: 'static/openapi.yaml',
            outputDir: 'docs/api',
            sidebarOptions: {
              groupPathsBy: 'tag',
              categoryLinkSource: 'tag',
            },
          },
        },
      },
    ],
  ],
  • It's definitely easier to generating the docs on lightning, So i will have to figure out how to fetch the openapi.yaml form lightning repo. Probably should look on adaptor generate script

Resources

mtuchi avatar Oct 27 '25 07:10 mtuchi

Okay maybe we need to use swagdox because you get to specify the api on the function using similar syntaxt like hexdoc

defmodule MyApp.UserController do

  @doc """
  Returns a User.

  [Swagdox] API:
    @param id(query), integer, "User ID", required: true

    @response 200, User, "User found"
    @response 403, "User not authorized"
    @response 404, "User not found"

    @security ApiAuth, [read]
  """
  @spec show(any(), map()) :: nil
  def show(_conn, _params) do
    ...
  end
end

mtuchi avatar Oct 27 '25 12:10 mtuchi

Read https://elixirforum.com/t/generating-rest-api-docs-by-swagger/57862/15

mtuchi avatar Nov 05 '25 05:11 mtuchi

Just a heads up @martalovescoffee i don't think i will be able to work on this issue in this sprint

mtuchi avatar Nov 19 '25 09:11 mtuchi

for docs repo https://github.com/kevinswiber/postman2openapi?tab=readme-ov-file#javascript-library

mtuchi avatar Dec 04 '25 12:12 mtuchi

Okay i ran into couple of hiccups. Getting Open API spec from lightning using bureaucrat package was really hard I had to switch gear and improvise a bit to generate a Postman collection instead

mtuchi avatar Dec 05 '25 16:12 mtuchi