[ckan-dev] API Validation

Toby Dacre toby.okfn at gmail.com
Fri Mar 9 17:57:57 UTC 2012


David,

The api validation should be using the schema specified in the DatasetForm
using the form_to_db_schema_options(options) function where options is a
dict with keys of 'api' (bool) and 'type' (str) of 'create' or 'update'.
If this function is not defined we fall back to form_to_db_schema().
Similar logic is used for GroupForms. See lib.plugins for the default
implementations.  I'd prefer the api/forms to share an identical schema but
currently this isn't the case.

I'm not sure what the error handling issues are I can look at the 500 issue
and see if we can give better feedback.  Question: how should we return
errors from the api are these textual or as a json dict of field error
types?

I'm pretty sure this change has got into the next release.

Toby

On 9 March 2012 16:28, David Read <david.read at hackneyworkshop.com> wrote:

> My clients are using the CKAN API and are suffering a little due to
> the inputs not being validated.
>
> For example, when they ask CKAN to create a dataset, and the JSON they
> include mistakenly has a list instead of dict, they get simply '500
> Server Error' - not very helpful.
>
> The CKAN forms use the excellent validation system, so we are adding
> validators for some of our custom fields. But of course we'd like this
> validation to also apply to metadata coming in via the API too.
>
> I understand you've been talking about making calls to it in the
> RESTful APIs - is that in the works now? Is it headed for the
> forthcoming 1.6.1 release?
>
> Dave
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> http://lists.okfn.org/mailman/listinfo/ckan-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20120309/c538895f/attachment-0001.html>


More information about the ckan-dev mailing list