Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function getAnnotations()
 {
     $annotations = [];
     $hydraDoc = $this->apiDocumentationBuilder->getApiDocumentation();
     $entrypointHydraDoc = $this->getResourceHydraDoc($hydraDoc, '#Entrypoint');
     /**
      * @var ResourceInterface
      */
     foreach ($this->resourceCollection as $resource) {
         $classMetadata = $this->classMetadataFactory->getMetadataFor($resource->getEntityClass());
         $prefixedShortName = ($iri = $classMetadata->getIri()) ? $iri : '#' . $resource->getShortName();
         $resourceHydraDoc = $this->getResourceHydraDoc($hydraDoc, $prefixedShortName);
         if ($hydraDoc) {
             foreach ($resource->getCollectionOperations() as $operation) {
                 $annotations[] = $this->getApiDoc(true, $resource, $operation, $resourceHydraDoc, $entrypointHydraDoc);
             }
             foreach ($resource->getItemOperations() as $operation) {
                 $annotations[] = $this->getApiDoc(false, $resource, $operation, $resourceHydraDoc);
             }
         }
     }
     return $annotations;
 }
Ejemplo n.º 2
0
 /**
  * Gets API doc.
  *
  * @param Request $request
  *
  * @return array
  */
 public function __invoke(Request $request)
 {
     $request->attributes->set('_api_format', 'jsonld');
     return $this->apiDocumentationBuilder->getApiDocumentation();
 }