eeditiones / tei-publisher-app

The main TEI Publisher app
https://teipublisher.com
GNU General Public License v3.0
68 stars 33 forks source link

Register API error with type place #176

Open aiolachiara opened 1 year ago

aiolachiara commented 1 year ago

I tried to add a register entry using the api /api/register/{type}/{id} with data

{
    "name":"Pellentesque",
    "note": "Proin magna.",
    "lng": "89",
    "lat": "12"
}

And I obtained this error

{
    "description": "It is a type error if, during the static analysis phase, an expression is found to have a static type that is not appropriate for the context in which the expression occurs, or during the dynamic evaluation phase, the dynamic type of a value does not match a required type as specified by the matching rules in 2.5.4 SequenceType Matching. checking function parameter 1 in call array:subarray($data?links, 2): XPTY0004: The actual cardinality for parameter 1 does not match the cardinality declared in the function's signature: array:subarray($array as array(*), $start as xs:integer) array(*). Expected cardinality: exactly one, got 0. [at line 111 of /db/apps/tei-publisher/modules/annotation-config.xqm]",
    "details": null
}

After checking the error at line at line 111 of /db/apps/tei-publisher/modules/annotation-config.xqm I tried again adding the links property (that cannot be an empty array) and I was able to add the place

{
    "name":"Pellentesque",
    "note": "Proin magna.",
   "links": "http://wwww.domain.tld"
    "lng": "89",
    "lat": "12"
}

So at the moment only for type place to make this API working correctly the links field is required. If it is not a bug maybe it should be indicated in the API documentation

tuurma commented 1 year ago

Thanks for reporting, we have plans to work on the registers over the summer, I'll keep this in mind.