Skip to content

Conversation

@rgraff
Copy link

@rgraff rgraff commented Aug 31, 2025

Added details about prefix and security scheme customization in OpenAPI spec.

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • I accept the AI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

Added details about prefix and security scheme customization in OpenAPI spec.

If `:open_api_servers` is not specified, a default server is automatically derived from your app's Phoenix endpoint, as retrieved from inbound connections on the `open_api` HTTP route.

The `:prefix` is usually automatically inferred, but when generating files or using swaggerui you'll need to set it manually.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should actually just fix that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you look into modifying the opts in the router? Something like this:

    opts =
      Keyword.put_new_lazy(opts, :prefix, fn ->
        conn.request_path
        |> Path.split()
        |> Enum.reverse()
        |> Enum.drop(Enum.count(conn.path_info))
        |> Enum.reverse()
        |> case do
          [] -> "/"
          paths -> Path.join(paths)
        end
      end)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants