add openapi overriding
This commit is contained in:
committed by
Steve Chavez
parent
cb7d70c197
commit
1de06f5332
@@ -43,3 +43,53 @@ You can use a tool like `Swagger UI <https://swagger.io/tools/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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 <external_connection_poolers>` 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
|
||||
|
||||
@@ -9,6 +9,11 @@ Horizontal Filtering
|
||||
|
||||
- New ``isdistinct`` :ref:`operator <operators>`. It is a direct translation of `IS DINTINCT FROM <https://www.postgresql.org/docs/current/functions-comparison.html#FUNCTIONS-COMPARISON-PRED-TABLE>`_.
|
||||
|
||||
OpenAPI
|
||||
~~~~~~~
|
||||
|
||||
- Allow :ref:`override_openapi`.
|
||||
|
||||
Admin
|
||||
~~~~~
|
||||
|
||||
|
||||
Reference in New Issue
Block a user