@@ -74,6 +74,7 @@ public function normalize(mixed $object, ?string $format = null, array $context
7474 }
7575
7676 $ shortName = $ resourceMetadata ->getShortName ();
77+
7778 $ prefixedShortName = $ resourceMetadata ->getTypes ()[0 ] ?? "# $ shortName " ;
7879 $ this ->populateEntrypointProperties ($ resourceMetadata , $ shortName , $ prefixedShortName , $ entrypointProperties , $ hydraPrefix , $ resourceMetadataCollection );
7980 $ classes [] = $ this ->getClass ($ resourceClass , $ resourceMetadata , $ shortName , $ prefixedShortName , $ context , $ hydraPrefix , $ resourceMetadataCollection );
@@ -243,8 +244,7 @@ private function getHydraOperations(bool $collection, ?ResourceMetadataCollectio
243244 if (('POST ' === $ operation ->getMethod () || $ operation instanceof CollectionOperationInterface) !== $ collection ) {
244245 continue ;
245246 }
246-
247- $ hydraOperations [] = $ this ->getHydraOperation ($ operation , $ operation ->getTypes ()[0 ] ?? "# {$ operation ->getShortName ()}" , $ hydraPrefix );
247+ $ hydraOperations [] = $ this ->getHydraOperation ($ operation , $ operation ->getShortName (), $ hydraPrefix );
248248 }
249249 }
250250
@@ -430,7 +430,7 @@ private function getClasses(array $entrypointProperties, array $classes, string
430430 '@type ' => $ hydraPrefix .'Operation ' ,
431431 $ hydraPrefix .'method ' => 'GET ' ,
432432 'rdfs:label ' => 'The API entrypoint. ' ,
433- 'returns ' => '# EntryPoint ' ,
433+ 'returns ' => 'EntryPoint ' ,
434434 ],
435435 ];
436436
@@ -573,18 +573,19 @@ private function computeDoc(Documentation $object, array $classes, string $hydra
573573 private function getContext (string $ hydraPrefix = ContextBuilder::HYDRA_PREFIX ): array
574574 {
575575 return [
576- '@vocab ' => $ this ->urlGenerator ->generate ('api_doc ' , ['_format ' => self ::FORMAT ], UrlGeneratorInterface::ABS_URL ).'# ' ,
577- 'hydra ' => ContextBuilderInterface::HYDRA_NS ,
578- 'rdf ' => ContextBuilderInterface::RDF_NS ,
579- 'rdfs ' => ContextBuilderInterface::RDFS_NS ,
580- 'xmls ' => ContextBuilderInterface::XML_NS ,
581- 'owl ' => ContextBuilderInterface::OWL_NS ,
582- 'schema ' => ContextBuilderInterface::SCHEMA_ORG_NS ,
583- 'domain ' => ['@id ' => 'rdfs:domain ' , '@type ' => '@id ' ],
584- 'range ' => ['@id ' => 'rdfs:range ' , '@type ' => '@id ' ],
585- 'subClassOf ' => ['@id ' => 'rdfs:subClassOf ' , '@type ' => '@id ' ],
586- 'expects ' => ['@id ' => $ hydraPrefix .'expects ' , '@type ' => '@id ' ],
587- 'returns ' => ['@id ' => $ hydraPrefix .'returns ' , '@type ' => '@id ' ],
576+ ContextBuilderInterface::HYDRA_CONTEXT ,
577+ [
578+ '@vocab ' => $ this ->urlGenerator ->generate ('api_doc ' , ['_format ' => self ::FORMAT ], UrlGeneratorInterface::ABS_URL ).'# ' ,
579+ 'hydra ' => ContextBuilderInterface::HYDRA_NS ,
580+ 'rdf ' => ContextBuilderInterface::RDF_NS ,
581+ 'rdfs ' => ContextBuilderInterface::RDFS_NS ,
582+ 'xmls ' => ContextBuilderInterface::XML_NS ,
583+ 'owl ' => ContextBuilderInterface::OWL_NS ,
584+ 'schema ' => ContextBuilderInterface::SCHEMA_ORG_NS ,
585+ 'domain ' => ['@id ' => 'rdfs:domain ' , '@type ' => '@id ' ],
586+ 'range ' => ['@id ' => 'rdfs:range ' , '@type ' => '@id ' ],
587+ 'subClassOf ' => ['@id ' => 'rdfs:subClassOf ' , '@type ' => '@id ' ],
588+ ],
588589 ];
589590 }
590591
0 commit comments