GALAglobal / translationapi

The API is for anyone who wants to adopt best practices for a translation services API to interact with counterparts directly from your application or content management system. The API helps ensure interoperability for the most common tasks.
https://translate.taus.net/translate/taus-translation-api
MIT License
12 stars 3 forks source link

Updating an existing translation ignores modificationDatetime value/wrong attribute name #27

Closed achimr closed 9 years ago

achimr commented 9 years ago

Steps to reproduce:

  1. Launch server with "node tausapiserver.js"
  2. Post new translation request: { "translationRequest": { "id": "2b575fdc-f6af-4b9e-850d-9dc0884c6595", "sourceLanguage": "de-DE", "targetLanguage": "en-US", "source": "Hallo Welt", "professional": true, "mt": false, "creationDatetime": "2014-05-20T19:20+01:00", "updateCounter": 0, "status": "initial" } } Result: Successful creation of request: { "id": "2b575fdc-f6af-4b9e-850d-9dc0884c6595", "sourceLanguage": "de-DE", "targetLanguage": "en-US", "source": "Hallo Welt", "mt": false, "professional": true, "status": "initial", "creationDatetime": "2014-10-14T14:51:06.670Z", "updateCounter": 0, "links": [ { "rel": "translation", "href": "http://localhost:3412/v2.0/translation/2b575fdc-f6af-4b9e-850d-9dc0884c6595", "type": "application/json", "title": "Newly created translation request 2b575fdc-f6af-4b9e-850d-9dc0884c6595 + created on Tue Oct 14 2014 10:51:06 GMT-0400 (Eastern Daylight Time)", "verb": "GET" }, { "rel": "translation.cancel", "href": "http://localhost:3412/v2.0/translation/cancel/2b575fdc-f6af-4b9e-850d-9dc0884c6595", "title": "Cancel translation request 2b575fdc-f6af-4b9e-850d-9dc0884c6595", "type": "application/json", "verb": "PATCH" }, { "rel": "translation.reject", "href": "http://localhost:3412/v2.0/translation/reject/2b575fdc-f6af-4b9e-850d-9dc0884c6595", "title": "Reject translation request 2b575fdc-f6af-4b9e-850d-9dc0884c6595", "type": "application/json", "verb": "PATCH" }, { "rel": "translation.confirm", "href": "http://localhost:3412/v2.0/translation/confirm/2b575fdc-f6af-4b9e-850d-9dc0884c6595", "title": "Confirm translation request 2b575fdc-f6af-4b9e-850d-9dc0884c6595", "type": "application/json", "verb": "PATCH" }, { "rel": "translation.accept", "href": "http://localhost:3412/v2.0/translation/accept/2b575fdc-f6af-4b9e-850d-9dc0884c6595", "title": "Accept translation request 2b575fdc-f6af-4b9e-850d-9dc0884c6595", "type": "application/json", "verb": "PATCH" }, { "rel": "translation.patch", "href": "http://localhost:3412/v2.0/translation/2b575fdc-f6af-4b9e-850d-9dc0884c6595", "title": "Patch translation request 2b575fdc-f6af-4b9e-850d-9dc0884c6595", "type": "application/json", "verb": "PATCH" } ] }
  3. Update the newly created translation request by PUTting the follwing JSON data to http://localhost:3412/v2.0/translation/2b575fdc-f6af-4b9e-850d-9dc0884c6595 { "translationRequest": { "id": "2b575fdc-f6af-4b9e-850d-9dc0884c6595", "sourceLanguage": "de-AT", "targetLanguage": "en-US", "source": "Hallo Welt", "professional": true, "mt": false, "creationDatetime": "2014-05-20T19:20+01:00", "modificationDatetime": "2014-05-20T19:20Z", "updateCounter": 0, "status": "initial" } }

Result: translation request successfully updated: { "translationRequest": { "id": "2b575fdc-f6af-4b9e-850d-9dc0884c6595", "sourceLanguage": "de-AT", "targetLanguage": "en-US", "source": "Hallo Welt", "mt": false, "professional": true, "status": "initial", "creationDatetime": "2014-10-14T14:51:06.670Z", "updateCounter": 7, "links": [ { "rel": "translation", "href": "http://localhost:3412/v2.0/translation/2b575fdc-f6af-4b9e-850d-9dc0884c6595", "type": "application/json", "title": "Newly created translation request 2b575fdc-f6af-4b9e-850d-9dc0884c6595 + created on Tue Oct 14 2014 10:51:06 GMT-0400 (Eastern Daylight Time)", "verb": "GET" }, { "rel": "translation.cancel", "href": "http://localhost:3412/v2.0/translation/cancel/2b575fdc-f6af-4b9e-850d-9dc0884c6595", "title": "Cancel translation request 2b575fdc-f6af-4b9e-850d-9dc0884c6595", "type": "application/json", "verb": "PATCH" }, { "rel": "translation.reject", "href": "http://localhost:3412/v2.0/translation/reject/2b575fdc-f6af-4b9e-850d-9dc0884c6595", "title": "Reject translation request 2b575fdc-f6af-4b9e-850d-9dc0884c6595", "type": "application/json", "verb": "PATCH" }, { "rel": "translation.confirm", "href": "http://localhost:3412/v2.0/translation/confirm/2b575fdc-f6af-4b9e-850d-9dc0884c6595", "title": "Confirm translation request 2b575fdc-f6af-4b9e-850d-9dc0884c6595", "type": "application/json", "verb": "PATCH" }, { "rel": "translation.accept", "href": "http://localhost:3412/v2.0/translation/accept/2b575fdc-f6af-4b9e-850d-9dc0884c6595", "title": "Accept translation request 2b575fdc-f6af-4b9e-850d-9dc0884c6595", "type": "application/json", "verb": "PATCH" }, { "rel": "translation.patch", "href": "http://localhost:3412/v2.0/translation/2b575fdc-f6af-4b9e-850d-9dc0884c6595", "title": "Patch translation request 2b575fdc-f6af-4b9e-850d-9dc0884c6595", "type": "application/json", "verb": "PATCH" } ], "modificationDate": "2014-10-14T17:49:11.918Z" } }

Two issues:

heartsomeXPhantom commented 9 years ago

Corrected in version 2.0i.

achimr commented 9 years ago

The parameter is correctly renamed and the parameter value is not ignored anymore. However, there is no parameter checking. So PUTing a JSON structure like this is allowed: { "translationRequest": { "id": "2b575fdc-f6af-4b9e-850d-9dc0884c6595", "sourceLanguage": "de-CH", "targetLanguage": "en-US", "source": "Gruezi Welt", "professional": true, "mt": false, "creationDatetime": "2014-05-20T19:20+01:00", "modificationDatetime": "2014-05-20T19:20sdfkdsjflsjdfZ", "updateCounter": 0, "status": "initial" } } Expected: Parameter modificationDatetime to be checked for correct date/time format (ISO 8601 with UTC time zone).

heartsomeXPhantom commented 9 years ago

Date checking added. 2.0j