diff --git a/docs/references/api/openapi.rst b/docs/references/api/openapi.rst index 31d23b52a..f2ba5d476 100644 --- a/docs/references/api/openapi.rst +++ b/docs/references/api/openapi.rst @@ -43,3 +43,53 @@ You can use a tool like `Swagger UI `_ to The OpenAPI information can go out of date as the schema changes under a running server. To learn how to refresh the cache see :ref:`schema_reloading`. +.. _override_openapi: + +Overriding OpenAPI response +--------------------------- + +You can override the default response with a function result. To do this, set the function on :ref:`db-root-spec`. + +.. code:: bash + + db-root-spec = "root" + +.. code:: postgres + + create or replace function root() returns json as $_$ + declare + openapi json = $$ + { + "swagger": "2.0", + "info":{ + "title":"Overridden", + "description":"This is a my own API" + } + } + $$; + begin + return openapi; + end + $_$ language plpgsql; + +.. tabs:: + + .. code-tab:: http + + GET / HTTP/1.1 + + .. code-tab:: bash Curl + + curl http://localhost:3000 + +.. code-block:: http + + HTTP/1.1 200 OK + + { + "swagger": "2.0", + "info":{ + "title":"Overridden", + "description":"This is a my own API" + } + } diff --git a/docs/references/configuration.rst b/docs/references/configuration.rst index 64906661b..557972a15 100644 --- a/docs/references/configuration.rst +++ b/docs/references/configuration.rst @@ -387,6 +387,18 @@ db-prepared-statements You should only set this to ``false`` when using PostgresSQL behind an external connection pooler such as PgBouncer working in transaction pooling mode. See :ref:`this section ` for more information. +.. _db-root-spec: + +db-root-spec +------------ + + =============== ================= + **Environment** PGRST_DB_ROOT_SPEC + **In-Database** pgrst.db_root_spec + =============== ================= + + Function to override the OpenAPI response. See :ref:`override_openapi`. + .. _db-schemas: db-schemas diff --git a/docs/releases/v11.0.0.rst b/docs/releases/v11.0.0.rst index da5aa1d3e..7e67adb7e 100644 --- a/docs/releases/v11.0.0.rst +++ b/docs/releases/v11.0.0.rst @@ -9,6 +9,11 @@ Horizontal Filtering - New ``isdistinct`` :ref:`operator `. It is a direct translation of `IS DINTINCT FROM `_. +OpenAPI +~~~~~~~ + +- Allow :ref:`override_openapi`. + Admin ~~~~~