Configuration

← Configuration

Ashterix

docs: rewrite JsonRpcBundle docs, add SDK docs, move them under docs/api

en/docs/api/rest-bundle/config.md new file +54 −0

Configuration

The bundle has no configuration tree of its own: REST entry points are defined by routes files, and everything else comes from the JsonRpcBundle settings ufo_json_rpc (Bundle configuration).

Routes

Each REST entry point is a separate import of the bundle's config/router.yaml:

# config/routes/ufo_rest_api.yaml
ufo_rest_api:
    resource: ../../vendor/ufo-tech/rest-bundle/config/router.yaml
    prefix: /rest
    trailing_slash_on_root: false
Import key What it sets
prefix The entry point address; documentation is at the prefix itself, methods are under it
defaults: { api_group: <group> } The API group of the entry point; without it, general
name_prefix An extra route name prefix when one group is imported twice
trailing_slash_on_root false, so that documentation answers at /rest, not /rest/

Details are in Routing.

What is used from ufo_json_rpc

Parameter Purpose in REST
security.protected_api Check the token for REST calls
security.protected_doc Check the token for OpenAPI and Postman
security.token_name Name of the token header
security.clients_tokens, security.providers Valid tokens, separately for API groups
docs.project_name, docs.project_description info.title and info.description in OpenAPI, the Postman collection name
translations.paths Extra directories with translations of method titles and descriptions (since 1.3)
# config/packages/ufo_json_rpc.yaml
ufo_json_rpc:
    security:
        protected_api: true
        protected_doc: false
        token_name: 'Ufo-RPC-Token'
        clients_tokens:
            - '%env(resolve:UFO_API_TOKEN)%'

    docs:
        project_name: 'My Project'
        project_description: 'Public API'

Changes to these parameters apply equally to JSON-RPC and REST. REST cannot be configured separately, for example to open the REST documentation while keeping the RPC one closed.

How tokens work for REST is described on the Security page.