Skip to content

Commit

Permalink
Fix #540 PathItem.from_routes/1 dialyzer warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
zorbash committed May 30, 2023
1 parent a65a7b2 commit 055c8e0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
14 changes: 13 additions & 1 deletion examples/phoenix_app/lib/phoenix_app_web/api_spec.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
defmodule PhoenixAppWeb.ApiSpec do
alias OpenApiSpex.{Components, Info, OpenApi, OAuthFlow, OAuthFlows, Paths, SecurityScheme}
alias OpenApiSpex.{
Components,
Info,
OpenApi,
OAuthFlow,
OAuthFlows,
Paths,
SecurityScheme,
Schema,
MediaType,
Response
}

@behaviour OpenApi

@impl OpenApi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ defmodule PhoenixAppWeb.UserController do
summary: "List users",
description: "List all users",
responses: [
ok: {"User List Response", "application/json", Schemas.UsersResponse}
unprocessable_entity: %Reference{"$ref": "#/components/responses/unprocessable_entity"},
ok: {"User List Response", "application/json", Schemas.UsersResponse},
unprocessable_entity: %Reference{"$ref": "#/components/responses/unprocessable_entity"}
]

def index(conn, _params) do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ defmodule PhoenixAppWeb.UserControllerWithStructSpecs do
description: "List all useres",
operationId: "UserController.index",
responses: %{
200 => response("User List Response", "application/json", Schemas.UsersResponse)
422 => %Reference{"$ref": "#/components/responses/unprocessable_entity"},
200 => response("User List Response", "application/json", Schemas.UsersResponse),
422 => %Reference{"$ref": "#/components/responses/unprocessable_entity"}
}
}
end
Expand Down
4 changes: 2 additions & 2 deletions lib/open_api_spex/path_item.ex
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ defmodule OpenApiSpex.PathItem do
Eg from the generated `__routes__` function in a Phoenix.Router module.
"""
@type route ::
%{path: String.t(), verb: atom, plug: atom, opts: any}
| %{path: String.t(), verb: atom, plug: atom, plug_opts: any}
%{optional(:path) => String.t(), verb: atom, plug: atom, opts: any}
| %{optional(:path) => String.t(), verb: atom, plug: atom, plug_opts: any}

@doc """
Builds a PathItem struct from a list of routes that share a path.
Expand Down

0 comments on commit 055c8e0

Please sign in to comment.