@@ -13,6 +13,7 @@ import type {
1313 ExpandedClass ,
1414 ExpandedDoc ,
1515 Entrypoint ,
16+ ExpandedOperation ,
1617 ExpandedRdfProperty ,
1718 RequestInitExtended ,
1819} from "./types.js" ;
@@ -24,6 +25,16 @@ function guessNameFromUrl(url: string, entrypointUrl: string): string {
2425 return url . substr ( entrypointUrl . length + 1 ) ;
2526}
2627
28+ function getTitleOrLabel ( obj : ExpandedOperation ) : string {
29+ const a = obj [ "http://www.w3.org/2000/01/rdf-schema#label" ] ?? obj [ "http://www.w3.org/ns/hydra/core#title" ] ?? null ;
30+
31+ if ( a === null ) {
32+ throw new Error ( 'No title nor label defined on this operation.' ) ;
33+ }
34+
35+ return a [ 0 ] [ "@value" ] ;
36+ }
37+
2738/**
2839 * Finds the description of the class with the given id.
2940 */
@@ -279,7 +290,9 @@ export default function parseHydraDocumentation(
279290 ) as unknown as string ;
280291
281292 const field = new Field (
282- supportedProperty [ "http://www.w3.org/2000/01/rdf-schema#label" ] [ 0 ] [
293+ supportedProperties [ "http://www.w3.org/ns/hydra/core#title" ] [ 0 ] [
294+ "@value"
295+ ] ?? supportedProperty [ "http://www.w3.org/2000/01/rdf-schema#label" ] [ 0 ] [
283296 "@value"
284297 ] ,
285298 {
@@ -369,9 +382,7 @@ export default function parseHydraDocumentation(
369382 type = "create" ;
370383 }
371384 const operation = new Operation (
372- entrypointOperation [
373- "http://www.w3.org/2000/01/rdf-schema#label"
374- ] [ 0 ] [ "@value" ] ,
385+ getTitleOrLabel ( entrypointOperation ) ,
375386 type ,
376387 {
377388 method,
@@ -424,9 +435,7 @@ export default function parseHydraDocumentation(
424435 type = "delete" ;
425436 }
426437 const operation = new Operation (
427- supportedOperation [ "http://www.w3.org/2000/01/rdf-schema#label" ] [ 0 ] [
428- "@value"
429- ] ,
438+ getTitleOrLabel ( supportedOperation ) ,
430439 type ,
431440 {
432441 method,
0 commit comments