Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing path parameters go unnoticed #52

Open
fenollp opened this issue Sep 18, 2018 · 1 comment · May be fixed by #100
Open

Missing path parameters go unnoticed #52

fenollp opened this issue Sep 18, 2018 · 1 comment · May be fixed by #100

Comments

@fenollp
Copy link
Contributor

fenollp commented Sep 18, 2018

Using https://editor.swagger.io/ I just caught a few errors that so far had gone unnoticed. I had a few routes with path parameters (e.g. get("/dota2/abilities/:dota2_ability_id", Dota2.AbilityController, :show)) but I forgot to declare :dota2_ability_id in the parameters list. Here it is, commented out:

  @spec open_api_operation(atom()) :: Op.t()
  # /dota2/abilities/:dota2_ability_id
  def open_api_operation(:show),
    do: %Op{
    # parameters: [OpenAPI.param(:dota2_ability_id)],
      responses: OpenAPI.resp_Dota2Ability()
    }

Could we add some check that makes the ....OpenAPI.spec() call fail if path parameters are missing?
I'm not sure what could be done for missing parameters of other kinds.

@mbuhot
Copy link
Collaborator

mbuhot commented Sep 19, 2018

Yes I think some logic could be added to the from_routes function.
https://github.com/mbuhot/open_api_spex/blob/master/lib/open_api_spex/path_item.ex#L57

In that situation you can parse the route coming from Phoenix and compare it to the declared parameters, emitting a warning if something doesn't match up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants