open-api-spex / open_api_spex

Open API Specifications for Elixir Plug applications
Mozilla Public License 2.0
681 stars 177 forks source link

How to include a port number in the routes? #570

Open GildedHonour opened 8 months ago

GildedHonour commented 8 months ago
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?