Skip to content

Commit f02112e

Browse files
fix(hydra): store and use hydra context as static asset
1 parent 001d771 commit f02112e

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

src/Hydra/Serializer/DocumentationNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ private function computeDoc(Documentation $object, array $classes, string $hydra
573573
private function getContext(string $hydraPrefix = ContextBuilder::HYDRA_PREFIX): array
574574
{
575575
return [
576-
ContextBuilderInterface::HYDRA_CONTEXT,
576+
'/bundles/apiplatform/hydra/context.jsonld',
577577
[
578578
'@vocab' => $this->urlGenerator->generate('api_doc', ['_format' => self::FORMAT], UrlGeneratorInterface::ABS_URL).'#',
579579
'hydra' => ContextBuilderInterface::HYDRA_NS,

src/JsonLd/ContextBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ private function getResourceContextWithShortname(string $resourceClass, int $ref
185185
}
186186

187187
if (false === ($this->defaultContext[self::HYDRA_CONTEXT_HAS_PREFIX] ?? true)) {
188-
return [ContextBuilderInterface::HYDRA_CONTEXT, $context];
188+
return ['/bundles/apiplatform/hydra/context.jsonld', $context];
189189
}
190190

191191
return $context;

src/JsonLd/ContextBuilderInterface.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
*/
2424
interface ContextBuilderInterface
2525
{
26-
public const HYDRA_CONTEXT = 'http://www.w3.org/ns/hydra/context.jsonld';
2726
public const HYDRA_NS = 'http://www.w3.org/ns/hydra/core#';
2827
public const JSONLD_NS = 'http://www.w3.org/ns/json-ld#';
2928
public const RDF_NS = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#';

update-js.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,12 @@ fi
9494
mkdir -p "$dest"
9595
cp node_modules/redoc/bundles/redoc.standalone.js "$dest"
9696

97+
dest=src/Symfony/Bundle/Resources/public/hydra/
98+
if [[ -d "$dest" ]]; then
99+
rm -Rf "$dest"
100+
fi
101+
mkdir -p "$dest"
102+
curl -L -A "Mozilla/5.0" -o "${dest}context.jsonld" http://www.w3.org/ns/hydra/context.jsonld
103+
97104
rm -Rf package.json node_modules/
98105
# TODO Laravel public files

0 commit comments

Comments
 (0)