Skip to content

Commit 67b9676

Browse files
committed
Evaluate expects declarations for operations
1 parent 773051c commit 67b9676

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/hydra/parseHydraDocumentation.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ export default function parseHydraDocumentation(entrypointUrl, options = {}) {
209209
entrypointOperation['http://www.w3.org/2000/01/rdf-schema#label'][0]['@value'],
210210
{
211211
method: entrypointOperation['http://www.w3.org/ns/hydra/core#method'][0]['@value'],
212+
expects: entrypointOperation['http://www.w3.org/ns/hydra/core#expects'] && entrypointOperation['http://www.w3.org/ns/hydra/core#expects'][0]['@id'],
212213
returns: range,
213214
types: entrypointOperation['@type'],
214215
},
@@ -230,6 +231,7 @@ export default function parseHydraDocumentation(entrypointUrl, options = {}) {
230231
supportedOperation['http://www.w3.org/2000/01/rdf-schema#label'][0]['@value'],
231232
{
232233
method: supportedOperation['http://www.w3.org/ns/hydra/core#method'][0]['@value'],
234+
expects: supportedOperation['http://www.w3.org/ns/hydra/core#expects'] && supportedOperation['http://www.w3.org/ns/hydra/core#expects'][0]['@id'],
233235
returns: range,
234236
types: supportedOperation['@type'],
235237
},

src/hydra/parseHydraDocumentation.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ const book = {
623623
{
624624
"name": "Replaces the Book resource.",
625625
"method": "PUT",
626+
"expects": "http://schema.org/Book",
626627
"returns": "http://schema.org/Book",
627628
"types": ["http://www.w3.org/ns/hydra/core#ReplaceResourceOperation"],
628629
},
@@ -739,6 +740,7 @@ const review = {
739740
{
740741
"name": "Creates a Review resource.",
741742
"method": "POST",
743+
"expects": "http://schema.org/Review",
742744
"returns": "http://schema.org/Review",
743745
"types": [
744746
"http://www.w3.org/ns/hydra/core#CreateResourceOperation"
@@ -753,6 +755,7 @@ const review = {
753755
{
754756
"name": "Replaces the Review resource.",
755757
"method": "PUT",
758+
"expects": "http://schema.org/Review",
756759
"returns": "http://schema.org/Review",
757760
"types": ["http://www.w3.org/ns/hydra/core#ReplaceResourceOperation"],
758761
},
@@ -860,6 +863,7 @@ const customResource = {
860863
{
861864
"name": "Creates a custom resource.",
862865
"method": "POST",
866+
"expects": "http://localhost/docs.jsonld#CustomResource",
863867
"returns": "http://localhost/docs.jsonld#CustomResource",
864868
"types": [
865869
"http://www.w3.org/ns/hydra/core#CreateResourceOperation"
@@ -874,6 +878,7 @@ const customResource = {
874878
{
875879
"name": "Creates a custom resource.",
876880
"method": "POST",
881+
"expects": "http://localhost/docs.jsonld#CustomResource",
877882
"returns": "http://localhost/docs.jsonld#CustomResource",
878883
"types": ["http://www.w3.org/ns/hydra/core#CreateResourceOperation"],
879884
}

0 commit comments

Comments
 (0)