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

Add custom message support for missing parameters #390

Merged
merged 2 commits into from
Dec 18, 2015

Conversation

jcalvert
Copy link
Contributor

ParamMissing can take the entire ParamDescription object instead of just the name, allowing it to interrogate the object to produce a custom missing message instead of the boilerplate "Missing parameter #{@param.name}". Support is for a basic string or function.

A primary use case for this is when an API is returning an error message that a client can then surface directly to a user without having to maintain a mapping of parameter names to human readable names IE
Missing parameter user_id to A user must be supplied to complete this action.. An additional benefit in allowing a Proc is that we can evaluate runtime conditions to create the message, thereby allowing internationalization and providing greater usefulness in the error message.

This would also address the feature request in issue #360

@Pajk
Copy link
Member

Pajk commented Dec 12, 2015

@jcalvert Nice! I find that very useful. Could you also mention this in the readme?

@Pajk Pajk added this to the v0.3.6 milestone Dec 12, 2015
@Pajk Pajk added the rfe label Dec 12, 2015
…message as a supported option for parameters.
@jcalvert
Copy link
Contributor Author

@Pajk Updated branch and added changes to README under the Parameter Description section.

Pajk added a commit that referenced this pull request Dec 18, 2015
Add custom message support for missing parameters
@Pajk Pajk merged commit f71ccc0 into Apipie:master Dec 18, 2015
@iNecas
Copy link
Member

iNecas commented Feb 18, 2016

v0.3.6 with this change has just been released. Thanks @jcalvert

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

Successfully merging this pull request may close these issues.

3 participants