gbv / cocoda-sdk

SDK for Cocoda and coli-conc services
https://gbv.github.io/cocoda-sdk/
MIT License
5 stars 1 forks source link

Use (a subset of) JSON Schema to indicate required parameters for function calls #51

Open stefandesu opened 2 years ago

stefandesu commented 2 years ago

For example, many calls to getMappings require either parameter from or to to be given. There are certain cases in which Cocoda is calling getMappings even though not all required parameters are available because it doesn't know which are required. It would be nice if client applications could detect beforehand which parameters are required.

The big question is how we should implement the validation for these Schemas. If we use only a very specific subset of JSON Schema features, we could write a very simple validation method and add it to cocoda-sdk so that no additional dependencies are needed. Validation code could also be generated by Ajv during build time. I haven't tested it, but the resulting validation code should be really small.

Other options if we're willing to add a dependency: