@@ -13,6 +13,7 @@ import type {
13
13
ExpandedClass ,
14
14
ExpandedDoc ,
15
15
Entrypoint ,
16
+ ExpandedOperation ,
16
17
ExpandedRdfProperty ,
17
18
RequestInitExtended ,
18
19
} from "./types.js" ;
@@ -24,6 +25,19 @@ function guessNameFromUrl(url: string, entrypointUrl: string): string {
24
25
return url . substr ( entrypointUrl . length + 1 ) ;
25
26
}
26
27
28
+ function getTitleOrLabel ( obj : ExpandedOperation ) : string {
29
+ const a =
30
+ obj [ "http://www.w3.org/2000/01/rdf-schema#label" ] ??
31
+ obj [ "http://www.w3.org/ns/hydra/core#title" ] ??
32
+ null ;
33
+
34
+ if ( a === null ) {
35
+ throw new Error ( "No title nor label defined on this operation." ) ;
36
+ }
37
+
38
+ return a [ 0 ] [ "@value" ] ;
39
+ }
40
+
27
41
/**
28
42
* Finds the description of the class with the given id.
29
43
*/
@@ -279,9 +293,12 @@ export default function parseHydraDocumentation(
279
293
) as unknown as string ;
280
294
281
295
const field = new Field (
282
- supportedProperty [ "http://www.w3.org/2000/01/rdf-schema#label " ] [ 0 ] [
296
+ supportedProperties [ "http://www.w3.org/ns/hydra/core#title " ] [ 0 ] [
283
297
"@value"
284
- ] ,
298
+ ] ??
299
+ supportedProperty [
300
+ "http://www.w3.org/2000/01/rdf-schema#label"
301
+ ] [ 0 ] [ "@value" ] ,
285
302
{
286
303
id,
287
304
range,
@@ -369,9 +386,7 @@ export default function parseHydraDocumentation(
369
386
type = "create" ;
370
387
}
371
388
const operation = new Operation (
372
- entrypointOperation [
373
- "http://www.w3.org/2000/01/rdf-schema#label"
374
- ] [ 0 ] [ "@value" ] ,
389
+ getTitleOrLabel ( entrypointOperation ) ,
375
390
type ,
376
391
{
377
392
method,
@@ -424,9 +439,7 @@ export default function parseHydraDocumentation(
424
439
type = "delete" ;
425
440
}
426
441
const operation = new Operation (
427
- supportedOperation [ "http://www.w3.org/2000/01/rdf-schema#label" ] [ 0 ] [
428
- "@value"
429
- ] ,
442
+ getTitleOrLabel ( supportedOperation ) ,
430
443
type ,
431
444
{
432
445
method,
0 commit comments