Skip to content

Commit 4ef9cb4

Browse files
committed
Verbatim context documentation
1 parent 6c1bc61 commit 4ef9cb4

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

docs/source/configuration.rst

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,45 @@ templates using dataset level templating. To learn more about Jinja2 templates,
667667
context:
668668
- datetime: https://schema.org/DateTime
669669
670+
Injecting verbatim JSON-LD contexts
671+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
672+
673+
Sometimes it is desirable to override pygeoapi's default handling of JSON and JSON-LD resources
674+
so that the provided ``context`` entries inside ``linked-data`` are injected into the objects
675+
exactly as provided.
676+
677+
This behavior can be enabled by setting ``inject_verbatim_context`` to ``true`` inside
678+
the Linked Data configuration for the resource:
679+
680+
.. code-block:: yaml
681+
682+
linked-data:
683+
context:
684+
- https://example.com/my-context.jsonld
685+
inject_verbatim_context: true
686+
687+
With ``inject_verbatim_context`` enabled, both JSON and JSON-LD item resources will have
688+
a ``@context`` property with the provided linked data context entries, and no JSON-LD
689+
manipulation will be performed by pygeoapi.
690+
691+
Additionally, some semantically enabled resources may provide their own ``@id`` (i.e., URI) value,
692+
which may be different from the one used by pygeoapi. The ``replace_id_field`` setting
693+
inside ``linked-data`` can be used to instruct pygeoapi to override a given property
694+
in the object with its own item URL:
695+
696+
.. code-block:: yaml
697+
698+
linked-data:
699+
context:
700+
- https://example.com/my-context.jsonld
701+
inject_verbatim_context: true
702+
replace_id_field: id
703+
704+
In the example above, the ``id`` field will be overwritten with the item URL on
705+
the pygeoapi service.
706+
707+
.. Important::
708+
``inject_verbatim_context`` must be enabled for ``replace_id_field`` to work.
670709

671710
Validating the configuration
672711
----------------------------

0 commit comments

Comments
 (0)