Add support for path level parameters#455
Conversation
* Create `clean_parameters` function to avoid duplicate code * Extracted `get_ref` from `clean_operations` to reuse it in `clean_parameters` * Added `parameters` argument to `APISpec.path()` * Sending `parameters` argument to `plugin.path_helper` as a kwargs, allowing plugins to update it * Added tests for global parameters feature * Added tests for duplicate parameters in operations * Added name to existing parameters in tests as required by OpenAPI specification * Now raising an `APISpecError` in case of duplicate parameters in path / operations
|
Looks pretty good, thanks. Nitpick: Splitting the changes in two commits (one for the refactor and one for the new feature) would make it easier to review, but not big deal. It is a small changeset. |
* Raise this new error instead of `APIError` when finding duplicates in parameters * Update tests to check if that exception is raised instead of base `APISpecError` * Split tests for duplicate parameters
* New exception `InvalidParameterError` * Now raising `InvalidParameterError` on `clean_parameters` * Added tests to check that correct exception is thrown
|
This PR adds an This change could break applications that don't provide a name or location. Those are applications with broken documentation since name and location are required. But broken doc is not broken app. Should we consider this a breaking change? Major releases are cheap, webargs is already 5.x, bumping apispec to 2.0 wouldn't be an issue. @sloria, what do you think? |
* Update `clean_parameters` to factorize loops * Typo fix in `get_ref` docstring * Mark `test_invalid_parameter` as parametrized
* Forced `required` value to `True` if parameter location is set to "path" * Updated `test_parameter` according to this
|
Also, the signature of |
|
@karec, looks like you committed with two different email addresses, one of which is not connected to your GH account. I absolutely don't mind but if you wish to change that, better now than never. |
Yes, I've no issue bumping to 2.0. I won't have time to review this PR for at least a week or so, so go ahead and handle this as you please @lafrech |
* Updated docstring to include kwargs decription * Updated `apispec.plugin.BasePlugin.path` docstring to include `parameters` * Updated `writing_plugins.rst` to reflect parameters changes and include `kwargs` example * Updated `test_core.TestPlugins.test_plugin_path_hlper_is_used` to include `parameters` argument
For #453
clean_parametersfunction to avoid duplicate codeget_reffromclean_operationsto reuse it inclean_parametersparametersargument toAPISpec.path()parametersargument toplugin.path_helperas a kwargs,allowing plugins to update it
specification
APISpecErrorin case of duplicate parameters inpath / operations