HTTP-APIs / hydrus

REST server - Flask Hydra-powered for Semantic Web
https://pypi.org/project/hydrus/
MIT License
195 stars 130 forks source link

Added full IRIs in response for POST and PUT requests. #574

Closed farazkhanfk7 closed 3 years ago

farazkhanfk7 commented 3 years ago

Fixes #573

Checklist

Current behaviour

Presently, we do not return any IRI or id for created/updated objects in response schema that is returned after a POST or PUT request.

{
    "@context": "http://www.w3.org/ns/hydra/context.jsonld",
    "@type": "Status",
    "description": "Object with ID f3744cd9-1921-49f6-9caa-c6676678b029 successfully added",
    "statusCode": 201,
    "title": "Object successfully added."
}

New expected behaviour

The format of response after the changes:

{
    "@context": "http://www.w3.org/ns/hydra/context.jsonld",
    "@type": "Status",
    "description": "Object with ID f3744cd9-1921-49f6-9caa-c6676678b029 successfully added",
    "iri": "http://localhost:8080/serverapi/Movie/f3744cd9-1921-49f6-9caa-c6676678b029",
    "statusCode": 201,
    "title": "Object successfully added."
}

Also a list of IRIs is returned, in case a PUT request is made to add multiple objects. Response schema in the case of multiple ids :

{
    "@context": "http://www.w3.org/ns/hydra/context.jsonld",
    "@type": "Status",
    "description": "Objects with ID ['d82b5942-f8fe-483f-9d5a-87ce89e80026', 'e82b5942-f8fe-483f-9d5a-87ce89e80026'] successfully added",
    "iri": [
        "http://localhost:8080/serverapi/Movie/d82b5942-f8fe-483f-9d5a-87ce89e80026",
        "http://localhost:8080/serverapi/Movie/e82b5942-f8fe-483f-9d5a-87ce89e80026"
    ],
    "statusCode": 201,
    "title": "Objects successfully added"
}

Change logs

sameshl commented 3 years ago

LGTM :+1: . Although can you add tests for this in our test suite?

farazkhanfk7 commented 3 years ago

Thanks for reviewing @sameshl . Actually I skipped the tests because currently, we were only testing the status_code, but now I'll add those in test suite. :+1:

Mec-iS commented 3 years ago

well done people