Repository navigation
Conversation
For an action with no `operation` declaration, the fallback clause that
`OpenApiSpex.ControllerSpecs` generates warned and then returned the
result of `IO.warn/1`, which is `:ok`. `PathItem.from_routes/1` drops
only `nil` operations, so such an action appeared in the spec as
`%PathItem{get: :ok}`.
The fallback now returns `nil` after the warning, as
`operation :action, false` and `OpenApiSpex.Controller` already do for
"no operation". The injected `open_api_operation/1` specs in both
modules now say `OpenApiSpex.Operation.t() | nil`, which matches
`__api_operation__/2` and `Operation.from_plug/2`.
This was found when [running an eqWAlizer type check on our Elixir project][elixir-elp].
[elixir-elp]: WhatsApp/erlang-language-platform#303
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #712
For an action with no
operationdeclaration, the fallback clause thatOpenApiSpex.ControllerSpecsgenerates warned and then returned the result ofIO.warn/1, which is:ok.PathItem.from_routes/1drops onlyniloperations, so the action appeared in the spec as%PathItem{get: :ok}.Changes
ControllerSpecs: the fallbackopen_api_operation/1returnsnilafter the warning. This matchesoperation :action, falseandOpenApiSpex.Controller.ControllerSpecsandController: the injectedopen_api_operation/1specs are nowOpenApiSpex.Operation.t() | nil. This matches__api_operation__/2andOperation.from_plug/2.Tests
controller_specs_test.exs: the existing warning test also asserts that the result isnil.path_item_test.exs: new test,from_routes skips an action without an operation spec.Without the fix, both tests fail with
:okand%PathItem{get: :ok}. With the fix, the full suite passes (399 tests, Elixir 1.20.4 / OTP 29).This was found when running an eqWAlizer type check on our Elixir project.
Drafted with AI assistance.