HydraApi.php
public function getDocumentation()
    {
        $metadata = $this->metadata->getAllMetadata();

        $docu = array(
            '@context' => array(
                'vocab' => $this->vocabUrl . '#',
                'hydra' => 'http://www.w3.org/ns/hydra/core#',
                'ApiDocumentation' => 'hydra:ApiDocumentation',
                'property' => array('@id' => 'hydra:property', '@type' => '@id'),
                'readonly' => 'hydra:readonly',
                'writeonly' => 'hydra:writeonly',
                'supportedClass' => 'hydra:supportedClass',
                'supportedProperty' => 'hydra:supportedProperty',
                'supportedOperation' => 'hydra:supportedOperation',
                'method' => 'hydra:method',
                'expects' =>  array('@id' => 'hydra:expects', '@type' => '@id'),
                'returns' =>  array('@id' => 'hydra:returns', '@type' => '@id'),
                'statusCodes' => 'hydra:statusCodes',
                'code' => 'hydra:statusCode',
                'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
                'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#',
                'label' => 'rdfs:label',
                'description' => 'rdfs:comment',
                'domain' => array('@id' => 'rdfs:domain', '@type' => '@id'),
                'range' =>  array('@id' => 'rdfs:range', '@type' => '@id'),
                'subClassOf' =>  array('@id' => 'rdfs:subClassOf', '@type' => '@id'),
            ),
            '@id' => $this->vocabUrl,
            '@type' => 'ApiDocumentation',
            'supportedClass' => array()
        );

        foreach ($metadata as $class) {
            if ($class->isExternalReference()) {
                $docu['supportedClass'][] = array(
                    '@id' => $class->getIri(),
                    '@type' => 'hydra:Class',
                    'hydra:title' => $class->getTitle(),
                    'hydra:description' => $class->getDescription(),
                    'supportedOperation' => $this->documentOperations($class->getOperations()),
                    'supportedProperty' => $this->documentClassProperties($class),
                );
            } else {
                if (false !== ($superclass = get_parent_class($class->getName()))) {
                    try {
                        $superclass = $this->metadata->getMetadataFor($superclass);

                        $superclass = $superclass->isExternalReference()
                            ? $superclass->getIri()
                            : 'vocab:' . $superclass->getIri();
                    } catch (\Exception $e) {
                        $superclass = null;
                    }
                } else {
                    $superclass = null;
                }

                $docu['supportedClass'][] = array(
                    '@id' => 'vocab:' . $class->getIri(),
                    '@type' => 'hydra:Class',
                    'subClassOf' => $superclass,
                    'label' => $class->getTitle(),
                    'description' => $class->getDescription(),
                    'supportedOperation' => $this->documentOperations($class->getOperations()),
                    'supportedProperty' => $this->documentClassProperties($class),
                );
            }

        }

        return $docu;
    }
public function getDocumentation()
    {
        $metadata = $this->metadata->getAllMetadata();

        $docu = array(
            '@context' => array(
                'vocab' => $this->vocabUrl . '#',
                'hydra' => 'http://www.w3.org/ns/hydra/core#',
                'ApiDocumentation' => 'hydra:ApiDocumentation',
                'property' => array('@id' => 'hydra:property', '@type' => '@id'),
                'readonly' => 'hydra:readonly',
                'writeonly' => 'hydra:writeonly',
                'supportedClass' => 'hydra:supportedClass',
                'supportedProperty' => 'hydra:supportedProperty',
                'supportedOperation' => 'hydra:supportedOperation',
                'method' => 'hydra:method',
                'expects' =>  array('@id' => 'hydra:expects', '@type' => '@id'),
                'returns' =>  array('@id' => 'hydra:returns', '@type' => '@id'),
                'statusCodes' => 'hydra:statusCodes',
                'code' => 'hydra:statusCode',
                'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
                'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#',
                'label' => 'rdfs:label',
                'description' => 'rdfs:comment',
                'domain' => array('@id' => 'rdfs:domain', '@type' => '@id'),
                'range' =>  array('@id' => 'rdfs:range', '@type' => '@id'),
                'subClassOf' =>  array('@id' => 'rdfs:subClassOf', '@type' => '@id'),
            ),
            '@id' => $this->vocabUrl,
            '@type' => 'ApiDocumentation',
            'supportedClass' => array()
        );

        foreach ($metadata as $class) {
            if ($class->isExternalReference()) {
                $docu['supportedClass'][] = array(
                    '@id' => $class->getIri(),
                    '@type' => 'hydra:Class',
                    'hydra:title' => $class->getTitle(),
                    'hydra:description' => $class->getDescription(),
                    'supportedOperation' => $this->documentOperations($class->getOperations()),
                    'supportedProperty' => $this->documentClassProperties($class),
                );
            } else {
                if (false !== ($superclass = get_parent_class($class->getName()))) {
                    try {
                        $superclass = $this->metadata->getMetadataFor($superclass);

                        $superclass = $superclass->isExternalReference()
                            ? $superclass->getIri()
                            : 'vocab:' . $superclass->getIri();
                    } catch (\Exception $e) {
                        $superclass = null;
                    }
                } else {
                    $superclass = null;
                }

                $docu['supportedClass'][] = array(
                    '@id' => 'vocab:' . $class->getIri(),
                    '@type' => 'hydra:Class',
                    'subClassOf' => $superclass,
                    'label' => $class->getTitle(),
                    'description' => $class->getDescription(),
                    'supportedOperation' => $this->documentOperations($class->getOperations()),
                    'supportedProperty' => $this->documentClassProperties($class),
                );
            }

        }

        return $docu;
    }
Get the Hydra ApiDocumentation

@return array The Hydra ApiDocumentation in the form of an array
ready to be serialized to JSON-LD