How to include port number into the local routes for "open_api_spex" library?

defmodule MyAppWeb.MyApi.ApiSpec do
  alias OpenApiSpex.{Components, Info, OpenApi, Paths, Server}
  @behaviour OpenApi

  @impl OpenApi
  def spec do
    %OpenApiSpex.OpenApi{
      servers: [
        OpenApiSpex.Server.from_endpoint(MyAppWeb.Endpoint)
      ],
      info: %Info{
        title: "API",
        version: "1.0"
      },
      paths: Paths.from_router(MyAppWeb.Router),
      components: %Components{
        securitySchemes: %{
          "bearer_auth" => %OpenApiSpex.SecurityScheme{
            type: "apiKey",
            name: "Authorization",
            in: "header",
            # TODO
            # scheme: "Bearer",
            # description: "API Key",
    }}}}
    |> OpenApiSpex.resolve_schema_modules()
  end

On localhost, at “swagger_ui” all the routes get generated with the port 80 - without a port, that is. But my web app runs on the other port. How will I make it include the port number explicitly?

1 Like