Skip to content

Conversation

@xxdavid
Copy link
Contributor

@xxdavid xxdavid commented Jul 22, 2025

I think it might be useful to check whether all the keys given to OpenApiSpex.ControllerSpecs.operation/2 are valid (and there is not a typo in them), similarly to what struct construction does. What do you think?

def operation_spec(_module, _action, false = _spec), do: nil

def operation_spec(module, action, spec) do
allowed_keys = [
Copy link
Contributor

Choose a reason for hiding this comment

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

[suggestion] Assign the allowed keys to a module attribute and list them in the @doc.

@operation_permitted_keys [:a, :b, :c]
@doc """
Define an Operation for a controller action.

See `OpenApiSpex.ControllerSpecs` for usage and examples.

Permitted operation keys:

#{for k <- @operation_permitted_keys, do: "* #{k}\n"}
"""

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea! I've changed it like so (and also added a note about extension keys) and forced pushed.

@xxdavid xxdavid force-pushed the validate_operation_keys branch from cd50619 to 472fda2 Compare July 31, 2025 08:21
@zorbash zorbash merged commit 7de53cb into open-api-spex:master Jul 31, 2025
21 of 27 checks passed
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