From b6161a02967f0ba5c2348d1f6a3274e8b1eb2d12 Mon Sep 17 00:00:00 2001 From: Laurence Isla Date: Thu, 26 Sep 2024 17:21:04 -0500 Subject: [PATCH] test: the regression test queries now run faster It doesn't call the main function that generates the OpenAPI spec directly anymore. It saves the output in a table and the tests will query that table instead (via a function). --- test/expected/info.out | 12 +-- test/expected/parameters.out | 14 +-- test/expected/paths.out | 174 +++++++++++++++++------------------ test/expected/reqbodies.out | 14 +-- test/expected/responses.out | 72 +++++++-------- test/expected/schemas.out | 92 +++++++++--------- test/expected/security.out | 4 +- test/fixtures.sql | 30 +++++- test/sql/info.sql | 12 +-- test/sql/parameters.sql | 14 +-- test/sql/paths.sql | 174 +++++++++++++++++------------------ test/sql/reqbodies.sql | 14 +-- test/sql/responses.sql | 72 +++++++-------- test/sql/schemas.sql | 92 +++++++++--------- test/sql/security.sql | 4 +- 15 files changed, 410 insertions(+), 384 deletions(-) diff --git a/test/expected/info.out b/test/expected/info.out index 7e60be5..657c267 100644 --- a/test/expected/info.out +++ b/test/expected/info.out @@ -1,33 +1,33 @@ -- shows the first line of the comment on the schema as title -select jsonb_pretty(postgrest_openapi_spec('{test}')->'info'->'title'); +select jsonb_pretty(get_openapi_document('{test}')->'info'->'title'); jsonb_pretty ---------------- "My API title" (1 row) -- shows the second line of the comment on the schema as summary -select jsonb_pretty(postgrest_openapi_spec('{test}')->'info'->'summary'); +select jsonb_pretty(get_openapi_document('{test}')->'info'->'summary'); jsonb_pretty ------------------ "My API summary" (1 row) -- shows the third line of the comment on the schema as description -select jsonb_pretty(postgrest_openapi_spec('{test}')->'info'->'description'); +select jsonb_pretty(get_openapi_document('{test}')->'info'->'description'); jsonb_pretty -------------------------------------------------- "My API description\nthat spans\nmultiple lines" (1 row) -- shows default title when there is no comment on the schema -select jsonb_pretty(postgrest_openapi_spec('{types}')->'info'->'title'); +select jsonb_pretty(get_openapi_document('{types}')->'info'->'title'); jsonb_pretty ----------------- "PostgREST API" (1 row) -- shows no summary when there is no comment on the schema -select postgrest_openapi_spec('{types}')->'info' ? 'summary'; +select get_openapi_document('{types}')->'info' ? 'summary'; ?column? ---------- f @@ -35,7 +35,7 @@ select postgrest_openapi_spec('{types}')->'info' ? 'summary'; -- shows default description when there is no comment on the schema -select jsonb_pretty(postgrest_openapi_spec('{types}')->'info'->'description'); +select jsonb_pretty(get_openapi_document('{types}')->'info'->'description'); jsonb_pretty ------------------------------------------------ "This is a dynamic API generated by PostgREST" diff --git a/test/expected/parameters.out b/test/expected/parameters.out index fba8030..6fb01f6 100644 --- a/test/expected/parameters.out +++ b/test/expected/parameters.out @@ -1,6 +1,6 @@ -- shows common query parameters select * -from jsonb_each(postgrest_openapi_spec('{test}')->'components'->'parameters') +from jsonb_each(get_openapi_document('{test}')->'components'->'parameters') where key in ('select', 'order', 'limit', 'offset', 'on_conflict', 'columns', 'or', 'and', 'not.or', 'not.and'); key | value -------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -18,7 +18,7 @@ where key in ('select', 'order', 'limit', 'offset', 'on_conflict', 'columns', 'o -- shows common headers select key, jsonb_pretty(value) -from jsonb_each(postgrest_openapi_spec('{test}')->'components'->'parameters') +from jsonb_each(get_openapi_document('{test}')->'components'->'parameters') where key in ('preferGet', 'preferPost', 'preferPut', 'preferPatch', 'preferDelete', 'preferPostRpc', 'range'); key | jsonb_pretty ---------------+------------------------------------------------------------------------------ @@ -283,7 +283,7 @@ where key in ('preferGet', 'preferPost', 'preferPut', 'preferPatch', 'preferDele -- shows table columns as parameters select key, jsonb_pretty(value) -from jsonb_each(postgrest_openapi_spec('{test}')->'components'->'parameters') +from jsonb_each(get_openapi_document('{test}')->'components'->'parameters') where key like 'rowFilter.products.%'; key | jsonb_pretty --------------------------------+---------------------------- @@ -333,7 +333,7 @@ where key like 'rowFilter.products.%'; -- shows view columns as parameters select key, jsonb_pretty(value) -from jsonb_each(postgrest_openapi_spec('{test}')->'components'->'parameters') +from jsonb_each(get_openapi_document('{test}')->'components'->'parameters') where key like 'rowFilter.big_products.%'; key | jsonb_pretty -----------------------------+-------------------------- @@ -369,7 +369,7 @@ where key like 'rowFilter.big_products.%'; -- shows `IN` function arguments as RPC parameters select key, jsonb_pretty(value) -from jsonb_each(postgrest_openapi_spec('{test}')->'components'->'parameters') +from jsonb_each(get_openapi_document('{test}')->'components'->'parameters') where key like 'rpcParam.has_in_parameters.%'; key | jsonb_pretty ------------------------------+----------------------------------------- @@ -413,7 +413,7 @@ where key like 'rpcParam.has_in_parameters.%'; -- shows `INOUT` function arguments as RPC parameters select key, jsonb_pretty(value) -from jsonb_each(postgrest_openapi_spec('{test}')->'components'->'parameters') +from jsonb_each(get_openapi_document('{test}')->'components'->'parameters') where key like 'rpcParam.has_inout_parameters.%'; key | jsonb_pretty ---------------------------------+----------------------------------------- @@ -457,7 +457,7 @@ where key like 'rpcParam.has_inout_parameters.%'; -- shows `VARIADIC` function arguments as RPC parameters select key, jsonb_pretty(value) -from jsonb_each(postgrest_openapi_spec('{test}')->'components'->'parameters') +from jsonb_each(get_openapi_document('{test}')->'components'->'parameters') where key like 'rpcParam.has_variadic_parameter.%'; key | jsonb_pretty -----------------------------------+----------------------------------- diff --git a/test/expected/paths.out b/test/expected/paths.out index 519bd11..3883c4f 100644 --- a/test/expected/paths.out +++ b/test/expected/paths.out @@ -1,5 +1,5 @@ -- shows root path for the OpenAPI output -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/'); jsonb_pretty -------------------------------------------------------------- { + @@ -32,7 +32,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/'); -- Tables -- GET operation object -- shows the table name as tag -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'get'->'tags'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'get'->'tags'); jsonb_pretty ---------------- [ + @@ -41,7 +41,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'get (1 row) -- uses a reference for the 200 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'get'->'responses'->'200'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'get'->'responses'->'200'); jsonb_pretty --------------------------------------------------------- { + @@ -51,7 +51,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'get (1 row) -- uses a reference for the 206 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'get'->'responses'->'206'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'get'->'responses'->'206'); jsonb_pretty --------------------------------------------------------- { + @@ -61,7 +61,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'get (1 row) -- uses a reference for error responses -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'get'->'responses'->'default'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'get'->'responses'->'default'); jsonb_pretty ---------------------------------------------------- { + @@ -72,7 +72,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'get -- uses references for columns as query parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/products'->'get'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/products'->'get'->'parameters') where value->>'$ref' like '#/components/parameters/rowFilter.products.%'; value -------------------------------------------------------------------- @@ -85,14 +85,14 @@ where value->>'$ref' like '#/components/parameters/rowFilter.products.%'; (6 rows) -- shows the first line of the comment on the table as summary -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'get'->'summary'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'get'->'summary'); jsonb_pretty -------------------- "Products summary" (1 row) -- shows the second line of the comment on the table as description -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'get'->'description'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'get'->'description'); jsonb_pretty ----------------------------------------------------- "Products description\nthat spans\nmultiple lines." @@ -100,7 +100,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'get -- uses references for common parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/products'->'get'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/products'->'get'->'parameters') where value->>'$ref' not like '#/components/parameters/rowFilter.products.%'; value ----------------------------------------------- @@ -118,7 +118,7 @@ where value->>'$ref' not like '#/components/parameters/rowFilter.products.%'; -- POST operation object -- shows the table name as tag -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'post'->'tags'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'post'->'tags'); jsonb_pretty ---------------- [ + @@ -127,7 +127,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'pos (1 row) -- uses a reference for the 201 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'post'->'responses'->'201'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'post'->'responses'->'201'); jsonb_pretty ----------------------------------------------------------- { + @@ -137,7 +137,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'pos (1 row) -- uses a reference for error responses -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'post'->'responses'->'default'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'post'->'responses'->'default'); jsonb_pretty ---------------------------------------------------- { + @@ -147,21 +147,21 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'pos (1 row) -- uses a reference for request body -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'post'->'requestBody'->'$ref'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'post'->'requestBody'->'$ref'); jsonb_pretty --------------------------------------- "#/components/requestBodies/products" (1 row) -- shows the first line of the comment on the table as summary -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'post'->'summary'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'post'->'summary'); jsonb_pretty -------------------- "Products summary" (1 row) -- shows the second line of the comment on the table as description -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'post'->'description'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'post'->'description'); jsonb_pretty ----------------------------------------------------- "Products description\nthat spans\nmultiple lines." @@ -169,7 +169,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'pos -- uses references for common parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/products'->'post'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/products'->'post'->'parameters') where value->>'$ref' like '#/components/parameters/%'; value ------------------------------------------------ @@ -180,7 +180,7 @@ where value->>'$ref' like '#/components/parameters/%'; -- PATCH operation object -- shows the table name as tag -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'patch'->'tags'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'patch'->'tags'); jsonb_pretty ---------------- [ + @@ -189,7 +189,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'pat (1 row) -- uses a reference for the 200 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'patch'->'responses'->'200'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'patch'->'responses'->'200'); jsonb_pretty --------------------------------------------------------- { + @@ -199,7 +199,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'pat (1 row) -- uses a reference for the 204 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'patch'->'responses'->'204'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'patch'->'responses'->'204'); jsonb_pretty --------------------------------------------- { + @@ -209,7 +209,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'pat (1 row) -- uses a reference for error responses -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'patch'->'responses'->'default'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'patch'->'responses'->'default'); jsonb_pretty ---------------------------------------------------- { + @@ -219,21 +219,21 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'pat (1 row) -- uses a reference for request body -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'patch'->'requestBody'->'$ref'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'patch'->'requestBody'->'$ref'); jsonb_pretty --------------------------------------- "#/components/requestBodies/products" (1 row) -- shows the first line of the comment on the table as summary -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'patch'->'summary'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'patch'->'summary'); jsonb_pretty -------------------- "Products summary" (1 row) -- shows the second line of the comment on the table as description -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'patch'->'description'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'patch'->'description'); jsonb_pretty ----------------------------------------------------- "Products description\nthat spans\nmultiple lines." @@ -241,7 +241,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'pat -- uses references for columns as query parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/products'->'patch'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/products'->'patch'->'parameters') where value->>'$ref' like '#/components/parameters/rowFilter.products.%'; value -------------------------------------------------------------------- @@ -255,7 +255,7 @@ where value->>'$ref' like '#/components/parameters/rowFilter.products.%'; -- uses references for common parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/products'->'patch'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/products'->'patch'->'parameters') where value->>'$ref' not like '#/components/parameters/rowFilter.products.%'; value ------------------------------------------------- @@ -272,7 +272,7 @@ where value->>'$ref' not like '#/components/parameters/rowFilter.products.%'; -- DELETE operation object -- shows the table name as tag -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'delete'->'tags'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'delete'->'tags'); jsonb_pretty ---------------- [ + @@ -281,7 +281,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'del (1 row) -- uses a reference for the 200 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'delete'->'responses'->'200'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'delete'->'responses'->'200'); jsonb_pretty --------------------------------------------------------- { + @@ -291,7 +291,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'del (1 row) -- uses a reference for the 204 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'delete'->'responses'->'204'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'delete'->'responses'->'204'); jsonb_pretty --------------------------------------------- { + @@ -301,7 +301,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'del (1 row) -- uses a reference for error responses -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'delete'->'responses'->'default'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'delete'->'responses'->'default'); jsonb_pretty ---------------------------------------------------- { + @@ -311,14 +311,14 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'del (1 row) -- shows the first line of the comment on the table as summary -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'delete'->'summary'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'delete'->'summary'); jsonb_pretty -------------------- "Products summary" (1 row) -- shows the second line of the comment on the table as description -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'delete'->'description'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'delete'->'description'); jsonb_pretty ----------------------------------------------------- "Products description\nthat spans\nmultiple lines." @@ -326,7 +326,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'del -- uses references for columns as query parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/products'->'delete'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/products'->'delete'->'parameters') where value->>'$ref' like '#/components/parameters/rowFilter.products.%'; value -------------------------------------------------------------------- @@ -340,7 +340,7 @@ where value->>'$ref' like '#/components/parameters/rowFilter.products.%'; -- uses references for common parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/products'->'delete'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/products'->'delete'->'parameters') where value->>'$ref' not like '#/components/parameters/rowFilter.products.%'; value -------------------------------------------------- @@ -357,7 +357,7 @@ where value->>'$ref' not like '#/components/parameters/rowFilter.products.%'; -- Views -- GET operation object -- shows the table name as tag -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'get'->'tags'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'get'->'tags'); jsonb_pretty -------------------- [ + @@ -366,7 +366,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'-> (1 row) -- uses a reference for the 200 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'get'->'responses'->'200'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'get'->'responses'->'200'); jsonb_pretty ------------------------------------------------------------- { + @@ -376,7 +376,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'-> (1 row) -- uses a reference for the 206 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'get'->'responses'->'206'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'get'->'responses'->'206'); jsonb_pretty ------------------------------------------------------------- { + @@ -386,7 +386,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'-> (1 row) -- uses a reference for error responses -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'get'->'responses'->'default'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'get'->'responses'->'default'); jsonb_pretty ---------------------------------------------------- { + @@ -396,14 +396,14 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'-> (1 row) -- shows the first line of the comment on the table as summary -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'get'->'summary'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'get'->'summary'); jsonb_pretty ------------------------ "Big products summary" (1 row) -- shows the second line of the comment on the table as description -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'get'->'description'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'get'->'description'); jsonb_pretty --------------------------------------------------------- "Big products description\nthat spans\nmultiple lines." @@ -411,7 +411,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'-> -- uses references for columns as query parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'get'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/big_products'->'get'->'parameters') where value->>'$ref' like '#/components/parameters/rowFilter.big_products.%'; value ----------------------------------------------------------------- @@ -423,7 +423,7 @@ where value->>'$ref' like '#/components/parameters/rowFilter.big_products.%'; -- uses references for common parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'get'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/big_products'->'get'->'parameters') where value->>'$ref' not like '#/components/parameters/rowFilter.big_products.%'; value ----------------------------------------------- @@ -440,7 +440,7 @@ where value->>'$ref' not like '#/components/parameters/rowFilter.big_products.%' (10 rows) -- shows a GET operation object for non auto-updatable views -select postgrest_openapi_spec('{test}')->'paths'->'/non_auto_updatable' ? 'get' as value; +select get_openapi_document('{test}')->'paths'->'/non_auto_updatable' ? 'get' as value; value ------- t @@ -448,7 +448,7 @@ select postgrest_openapi_spec('{test}')->'paths'->'/non_auto_updatable' ? 'get' -- POST operation object -- shows the table name as tag -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'post'->'tags'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'post'->'tags'); jsonb_pretty -------------------- [ + @@ -457,7 +457,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'-> (1 row) -- uses a reference for the 201 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'post'->'responses'->'201'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'post'->'responses'->'201'); jsonb_pretty --------------------------------------------------------------- { + @@ -467,7 +467,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'-> (1 row) -- uses a reference for error responses -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'post'->'responses'->'default'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'post'->'responses'->'default'); jsonb_pretty ---------------------------------------------------- { + @@ -477,21 +477,21 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'-> (1 row) -- uses a reference for request body -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'post'->'requestBody'->'$ref'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'post'->'requestBody'->'$ref'); jsonb_pretty ------------------------------------------- "#/components/requestBodies/big_products" (1 row) -- shows the first line of the comment on the table as summary -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'post'->'summary'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'post'->'summary'); jsonb_pretty ------------------------ "Big products summary" (1 row) -- shows the second line of the comment on the table as description -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'post'->'description'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'post'->'description'); jsonb_pretty --------------------------------------------------------- "Big products description\nthat spans\nmultiple lines." @@ -499,7 +499,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'-> -- uses references for common parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'post'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/big_products'->'post'->'parameters') where value->>'$ref' like '#/components/parameters/%'; value ------------------------------------------------ @@ -509,7 +509,7 @@ where value->>'$ref' like '#/components/parameters/%'; (3 rows) -- does not show a POST operation object for non auto-updatable views -select postgrest_openapi_spec('{test}')->'paths'->'/non_auto_updatable' ? 'post' as value; +select get_openapi_document('{test}')->'paths'->'/non_auto_updatable' ? 'post' as value; value ------- f @@ -517,7 +517,7 @@ select postgrest_openapi_spec('{test}')->'paths'->'/non_auto_updatable' ? 'post' -- PATCH operation object -- shows the table name as tag -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'patch'->'tags'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'patch'->'tags'); jsonb_pretty -------------------- [ + @@ -526,7 +526,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'-> (1 row) -- uses a reference for the 200 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'patch'->'responses'->'200'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'patch'->'responses'->'200'); jsonb_pretty ------------------------------------------------------------- { + @@ -536,7 +536,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'-> (1 row) -- uses a reference for the 204 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'patch'->'responses'->'204'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'patch'->'responses'->'204'); jsonb_pretty --------------------------------------------- { + @@ -546,7 +546,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'-> (1 row) -- uses a reference for error responses -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'patch'->'responses'->'default'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'patch'->'responses'->'default'); jsonb_pretty ---------------------------------------------------- { + @@ -556,21 +556,21 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'-> (1 row) -- uses a reference for request body -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'patch'->'requestBody'->'$ref'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'patch'->'requestBody'->'$ref'); jsonb_pretty ------------------------------------------- "#/components/requestBodies/big_products" (1 row) -- shows the first line of the comment on the table as summary -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'patch'->'summary'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'patch'->'summary'); jsonb_pretty ------------------------ "Big products summary" (1 row) -- shows the second line of the comment on the table as description -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'patch'->'description'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'patch'->'description'); jsonb_pretty --------------------------------------------------------- "Big products description\nthat spans\nmultiple lines." @@ -578,7 +578,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'-> -- uses references for columns as query parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'patch'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/big_products'->'patch'->'parameters') where value->>'$ref' like '#/components/parameters/rowFilter.big_products.%'; value ----------------------------------------------------------------- @@ -590,7 +590,7 @@ where value->>'$ref' like '#/components/parameters/rowFilter.big_products.%'; -- uses references for common parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'patch'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/big_products'->'patch'->'parameters') where value->>'$ref' not like '#/components/parameters/rowFilter.big_products.%'; value ------------------------------------------------- @@ -606,7 +606,7 @@ where value->>'$ref' not like '#/components/parameters/rowFilter.big_products.%' (9 rows) -- does not show a PATCH operation object for non auto-updatable views -select postgrest_openapi_spec('{test}')->'paths'->'/non_auto_updatable' ? 'patch' as value; +select get_openapi_document('{test}')->'paths'->'/non_auto_updatable' ? 'patch' as value; value ------- f @@ -614,7 +614,7 @@ select postgrest_openapi_spec('{test}')->'paths'->'/non_auto_updatable' ? 'patch -- DELETE operation object -- shows the table name as tag -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'delete'->'tags'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'delete'->'tags'); jsonb_pretty -------------------- [ + @@ -623,7 +623,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'-> (1 row) -- uses a reference for the 200 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'delete'->'responses'->'200'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'delete'->'responses'->'200'); jsonb_pretty ------------------------------------------------------------- { + @@ -633,7 +633,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'-> (1 row) -- uses a reference for the 204 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'delete'->'responses'->'204'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'delete'->'responses'->'204'); jsonb_pretty --------------------------------------------- { + @@ -643,7 +643,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'-> (1 row) -- uses a reference for error responses -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'delete'->'responses'->'default'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'delete'->'responses'->'default'); jsonb_pretty ---------------------------------------------------- { + @@ -653,14 +653,14 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'-> (1 row) -- shows the first line of the comment on the table as summary -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'delete'->'summary'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'delete'->'summary'); jsonb_pretty ------------------------ "Big products summary" (1 row) -- shows the second line of the comment on the table as description -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'delete'->'description'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'delete'->'description'); jsonb_pretty --------------------------------------------------------- "Big products description\nthat spans\nmultiple lines." @@ -668,7 +668,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'-> -- uses references for columns as query parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'delete'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/big_products'->'delete'->'parameters') where value->>'$ref' like '#/components/parameters/rowFilter.big_products.%'; value ----------------------------------------------------------------- @@ -680,7 +680,7 @@ where value->>'$ref' like '#/components/parameters/rowFilter.big_products.%'; -- uses references for common parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'delete'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/big_products'->'delete'->'parameters') where value->>'$ref' not like '#/components/parameters/rowFilter.big_products.%'; value -------------------------------------------------- @@ -695,7 +695,7 @@ where value->>'$ref' not like '#/components/parameters/rowFilter.big_products.%' (8 rows) -- does not show a DELETE operation object for non auto-updatable views -select postgrest_openapi_spec('{test}')->'paths'->'/non_auto_updatable' ? 'delete' as value; +select get_openapi_document('{test}')->'paths'->'/non_auto_updatable' ? 'delete' as value; value ------- f @@ -704,7 +704,7 @@ select postgrest_openapi_spec('{test}')->'paths'->'/non_auto_updatable' ? 'delet -- Functions -- GET operation object -- shows the function name as tag -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/get_products_by_size'->'get'->'tags'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/rpc/get_products_by_size'->'get'->'tags'); jsonb_pretty ---------------------------------- [ + @@ -713,7 +713,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/get_product (1 row) -- uses a reference for the 200 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/get_products_by_size'->'get'->'responses'->'200'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/rpc/get_products_by_size'->'get'->'responses'->'200'); jsonb_pretty ---------------------------------------------------------------- { + @@ -723,7 +723,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/get_product (1 row) -- uses a reference for the 206 HTTP code response on `RETURNS SET OF` functions -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/get_products_by_size'->'get'->'responses'->'206'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/rpc/get_products_by_size'->'get'->'responses'->'206'); jsonb_pretty ---------------------------------------------------------------- { + @@ -733,7 +733,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/get_product (1 row) -- uses a reference for error responses -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/get_products_by_size'->'get'->'responses'->'default'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/rpc/get_products_by_size'->'get'->'responses'->'default'); jsonb_pretty ---------------------------------------------------- { + @@ -743,14 +743,14 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/get_product (1 row) -- shows the first line of the comment on the table as summary -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/get_products_by_size'->'get'->'summary'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/rpc/get_products_by_size'->'get'->'summary'); jsonb_pretty -------------------------------- "Get Products By Size summary" (1 row) -- shows the second line of the comment on the table as description -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/get_products_by_size'->'get'->'description'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/rpc/get_products_by_size'->'get'->'description'); jsonb_pretty ----------------------------------------------------------------- "Get Products By Size description\nthat spans\nmultiple lines." @@ -758,7 +758,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/get_product -- uses references for common parameters on `RETURNS ` functions select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/rpc/get_attribute'->'get'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/rpc/get_attribute'->'get'->'parameters') where value->>'$ref' not like '#/components/parameters/rpcParam.get_attribute.%'; value ----------------------------------------------- @@ -776,7 +776,7 @@ where value->>'$ref' not like '#/components/parameters/rpcParam.get_attribute.%' -- uses references for common parameters on `RETURNS TABLE` functions select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/rpc/returns_table'->'get'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/rpc/returns_table'->'get'->'parameters') where value->>'$ref' not like '#/components/parameters/rpcParam.returns_table.%'; value ----------------------------------------------- @@ -794,7 +794,7 @@ where value->>'$ref' not like '#/components/parameters/rpcParam.returns_table.%' -- uses references for common parameters on functions with INOUT/OUT parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/rpc/returns_inout_out'->'get'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/rpc/returns_inout_out'->'get'->'parameters') where value->>'$ref' not like '#/components/parameters/rpcParam.returns_inout_out.%'; value ----------------------------------------------- @@ -811,7 +811,7 @@ where value->>'$ref' not like '#/components/parameters/rpcParam.returns_inout_ou (10 rows) -- does not use a reference for the 206 HTTP code response on functions that do not return `SET OF` -select postgrest_openapi_spec('{test}')->'paths'->'/rpc/get_attribute'->'get'->'responses' ? '206' as value; +select get_openapi_document('{test}')->'paths'->'/rpc/get_attribute'->'get'->'responses' ? '206' as value; value ------- f @@ -819,7 +819,7 @@ select postgrest_openapi_spec('{test}')->'paths'->'/rpc/get_attribute'->'get'->' -- does not use a reference for common parameters (except for prefer headers) on functions that do not return composite types select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/rpc/returns_simple_type'->'get'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/rpc/returns_simple_type'->'get'->'parameters') where value->>'$ref' not like '#/components/parameters/rpcParam.returns_simple_type.%'; value ----------------------------------------------- @@ -827,7 +827,7 @@ where value->>'$ref' not like '#/components/parameters/rpcParam.returns_simple_t (1 row) -- shows a function with a single unnamed parameter of accepted types -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/single_unnamed_json_param'->'get'->'tags'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/rpc/single_unnamed_json_param'->'get'->'tags'); jsonb_pretty --------------------------------------- [ + @@ -835,7 +835,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/single_unna ] (1 row) -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/single_unnamed_jsonb_param'->'get'->'tags'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/rpc/single_unnamed_jsonb_param'->'get'->'tags'); jsonb_pretty ---------------------------------------- [ + @@ -843,7 +843,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/single_unna ] (1 row) -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/single_unnamed_text_param'->'get'->'tags'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/rpc/single_unnamed_text_param'->'get'->'tags'); jsonb_pretty --------------------------------------- [ + @@ -851,7 +851,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/single_unna ] (1 row) -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/single_unnamed_xml_param'->'get'->'tags'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/rpc/single_unnamed_xml_param'->'get'->'tags'); jsonb_pretty -------------------------------------- [ + @@ -860,21 +860,21 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/single_unna (1 row) -- does not show a function with a single unnamed parameter of non-accepted types -select postgrest_openapi_spec('{test}')->'paths' ? '/rpc/single_unnamed_unrecognized_param' as value; +select get_openapi_document('{test}')->'paths' ? '/rpc/single_unnamed_unrecognized_param' as value; value ------- f (1 row) -- does not show a function with unnamed parameters -select postgrest_openapi_spec('{test}')->'paths' ? '/rpc/unnamed_params' as value; +select get_openapi_document('{test}')->'paths' ? '/rpc/unnamed_params' as value; value ------- f (1 row) -- does not show a function with named and unnamed parameters -select postgrest_openapi_spec('{test}')->'paths' ? '/rpc/named_and_unnamed_params' as value; +select get_openapi_document('{test}')->'paths' ? '/rpc/named_and_unnamed_params' as value; value ------- f diff --git a/test/expected/reqbodies.out b/test/expected/reqbodies.out index 32b15d4..06d68c7 100644 --- a/test/expected/reqbodies.out +++ b/test/expected/reqbodies.out @@ -1,6 +1,6 @@ -- Tables -- defines an application/json request body -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'requestBodies'->'products'->'content'->'application/json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'requestBodies'->'products'->'content'->'application/json'); jsonb_pretty ------------------------------------------------------------- { + @@ -21,7 +21,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'requestBodi (1 row) -- defines an application/x-www-form-urlencoded request body -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'requestBodies'->'products'->'content'->'application/x-www-form-urlencoded'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'requestBodies'->'products'->'content'->'application/x-www-form-urlencoded'); jsonb_pretty ------------------------------------------------- { + @@ -32,7 +32,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'requestBodi (1 row) -- defines a text/csv request body -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'requestBodies'->'products'->'content'->'text/csv'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'requestBodies'->'products'->'content'->'text/csv'); jsonb_pretty --------------------------- { + @@ -45,7 +45,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'requestBodi -- Views -- defines an application/json request body -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'requestBodies'->'big_products'->'content'->'application/json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'requestBodies'->'big_products'->'content'->'application/json'); jsonb_pretty ----------------------------------------------------------------- { + @@ -66,7 +66,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'requestBodi (1 row) -- defines an application/x-www-form-urlencoded request body -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'requestBodies'->'big_products'->'content'->'application/x-www-form-urlencoded'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'requestBodies'->'big_products'->'content'->'application/x-www-form-urlencoded'); jsonb_pretty ----------------------------------------------------- { + @@ -77,7 +77,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'requestBodi (1 row) -- defines a text/csv request body -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'requestBodies'->'big_products'->'content'->'text/csv'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'requestBodies'->'big_products'->'content'->'text/csv'); jsonb_pretty --------------------------- { + @@ -89,7 +89,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'requestBodi (1 row) -- does not define a request body for non auto-updatable views -select postgrest_openapi_spec('{test}')->'components'->'requestBodies' ? 'non_auto_updatable' as value; +select get_openapi_document('{test}')->'components'->'requestBodies' ? 'non_auto_updatable' as value; value ------- f diff --git a/test/expected/responses.out b/test/expected/responses.out index bf944d1..2bf6d60 100644 --- a/test/expected/responses.out +++ b/test/expected/responses.out @@ -1,5 +1,5 @@ -- defines a default error response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'defaultError'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'defaultError'); jsonb_pretty -------------------------------------------- { + @@ -29,7 +29,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- (1 row) -- defines an empty response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'empty'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'empty'); jsonb_pretty ----------------------------------------------------------------- { + @@ -40,7 +40,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- -- Tables -- Non-empty response body -- defines an application/json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'notEmpty.products'->'content'->'application/json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'notEmpty.products'->'content'->'application/json'); jsonb_pretty ----------------------------------------------------- { + @@ -54,7 +54,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- (1 row) -- defines an application/vnd.pgrst.object+json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'notEmpty.products'->'content'->'application/vnd.pgrst.object+json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'notEmpty.products'->'content'->'application/vnd.pgrst.object+json'); jsonb_pretty ------------------------------------------------- { + @@ -65,7 +65,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- (1 row) -- defines an application/vnd.pgrst.object+json;nulls=stripped response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'notEmpty.products'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'notEmpty.products'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); jsonb_pretty ------------------------------------------------- { + @@ -76,7 +76,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- (1 row) -- defines a text/csv response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'notEmpty.products'->'content'->'text/csv'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'notEmpty.products'->'content'->'text/csv'); jsonb_pretty --------------------------- { + @@ -89,7 +89,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- -- Empty or non-empty response body -- defines an application/json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'mayBeEmpty.products'->'content'->'application/json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'mayBeEmpty.products'->'content'->'application/json'); jsonb_pretty ------------------------------------------------------------- { + @@ -110,7 +110,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- (1 row) -- defines an application/vnd.pgrst.object+json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'mayBeEmpty.products'->'content'->'application/vnd.pgrst.object+json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'mayBeEmpty.products'->'content'->'application/vnd.pgrst.object+json'); jsonb_pretty --------------------------------------------------------- { + @@ -128,7 +128,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- (1 row) -- defines an application/vnd.pgrst.object+json;nulls=stripped response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'mayBeEmpty.products'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'mayBeEmpty.products'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); jsonb_pretty --------------------------------------------------------- { + @@ -146,7 +146,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- (1 row) -- defines a text/csv response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'mayBeEmpty.products'->'content'->'text/csv'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'mayBeEmpty.products'->'content'->'text/csv'); jsonb_pretty --------------------------- { + @@ -159,7 +159,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- -- Views -- Non-empty response body -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'notEmpty.big_products'->'content'->'application/json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'notEmpty.big_products'->'content'->'application/json'); jsonb_pretty --------------------------------------------------------- { + @@ -173,7 +173,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- (1 row) -- defines an application/vnd.pgrst.object+json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'notEmpty.big_products'->'content'->'application/vnd.pgrst.object+json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'notEmpty.big_products'->'content'->'application/vnd.pgrst.object+json'); jsonb_pretty ----------------------------------------------------- { + @@ -184,7 +184,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- (1 row) -- defines an application/vnd.pgrst.object+json;nulls=stripped response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'notEmpty.big_products'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'notEmpty.big_products'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); jsonb_pretty ----------------------------------------------------- { + @@ -195,7 +195,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- (1 row) -- defines a text/csv response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'notEmpty.big_products'->'content'->'text/csv'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'notEmpty.big_products'->'content'->'text/csv'); jsonb_pretty --------------------------- { + @@ -207,7 +207,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- (1 row) -- defines a non-empty response body for non auto-updatable views -select postgrest_openapi_spec('{test}')->'components'->'responses' ? 'notEmpty.non_auto_updatable' as value; +select get_openapi_document('{test}')->'components'->'responses' ? 'notEmpty.non_auto_updatable' as value; value ------- t @@ -215,7 +215,7 @@ select postgrest_openapi_spec('{test}')->'components'->'responses' ? 'notEmpty.n -- Empty or non-empty response body -- defines an application/json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'mayBeEmpty.big_products'->'content'->'application/json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'mayBeEmpty.big_products'->'content'->'application/json'); jsonb_pretty ----------------------------------------------------------------- { + @@ -236,7 +236,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- (1 row) -- defines an application/vnd.pgrst.object+json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'mayBeEmpty.big_products'->'content'->'application/vnd.pgrst.object+json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'mayBeEmpty.big_products'->'content'->'application/vnd.pgrst.object+json'); jsonb_pretty ------------------------------------------------------------- { + @@ -254,7 +254,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- (1 row) -- defines an application/vnd.pgrst.object+json;nulls=stripped response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'mayBeEmpty.big_products'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'mayBeEmpty.big_products'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); jsonb_pretty ------------------------------------------------------------- { + @@ -272,7 +272,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- (1 row) -- defines a text/csv response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'mayBeEmpty.big_products'->'content'->'text/csv'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'mayBeEmpty.big_products'->'content'->'text/csv'); jsonb_pretty --------------------------- { + @@ -284,7 +284,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- (1 row) -- does not define an empty or non-empty response body for non auto-updatable views -select postgrest_openapi_spec('{test}')->'components'->'responses' ? 'mayBeEmpty.non_auto_updatable' as value; +select get_openapi_document('{test}')->'components'->'responses' ? 'mayBeEmpty.non_auto_updatable' as value; value ------- f @@ -293,7 +293,7 @@ select postgrest_openapi_spec('{test}')->'components'->'responses' ? 'mayBeEmpty -- Functions -- Returning composite types -- defines an application/json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.get_attribute'->'content'->'application/json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.get_attribute'->'content'->'application/json'); jsonb_pretty ------------------------------------------------------------ { + @@ -304,7 +304,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- (1 row) -- defines an application/vnd.pgrst.object+json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.get_attribute'->'content'->'application/vnd.pgrst.object+json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.get_attribute'->'content'->'application/vnd.pgrst.object+json'); jsonb_pretty ------------------------------------------------------------ { + @@ -315,7 +315,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- (1 row) -- defines an application/vnd.pgrst.object+json;nulls=stripped response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.get_attribute'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.get_attribute'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); jsonb_pretty ------------------------------------------------------------ { + @@ -326,7 +326,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- (1 row) -- defines a text/csv response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.get_attribute'->'content'->'text/csv'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.get_attribute'->'content'->'text/csv'); jsonb_pretty --------------------------- { + @@ -339,7 +339,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- -- Returning SET OF composite types -- defines an application/json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.get_products_by_size'->'content'->'application/json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.get_products_by_size'->'content'->'application/json'); jsonb_pretty ----------------------------------------------------- { + @@ -353,7 +353,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- (1 row) -- defines an application/vnd.pgrst.object+json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.get_products_by_size'->'content'->'application/vnd.pgrst.object+json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.get_products_by_size'->'content'->'application/vnd.pgrst.object+json'); jsonb_pretty ------------------------------------------------- { + @@ -364,7 +364,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- (1 row) -- defines an application/vnd.pgrst.object+json;nulls=stripped response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.get_products_by_size'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.get_products_by_size'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); jsonb_pretty ------------------------------------------------- { + @@ -375,7 +375,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- (1 row) -- defines a text/csv response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.get_products_by_size'->'content'->'text/csv'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.get_products_by_size'->'content'->'text/csv'); jsonb_pretty --------------------------- { + @@ -388,7 +388,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- -- Returning non-composite types -- defines an application/json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.returns_inout_out'->'content'->'application/json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.returns_inout_out'->'content'->'application/json'); jsonb_pretty -------------------------------------------------------------- { + @@ -399,7 +399,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- (1 row) -- defines an application/vnd.pgrst.object+json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.returns_inout_out'->'content'->'application/vnd.pgrst.object+json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.returns_inout_out'->'content'->'application/vnd.pgrst.object+json'); jsonb_pretty -------------------------------------------------------------- { + @@ -410,7 +410,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- (1 row) -- defines an application/vnd.pgrst.object+json;nulls=stripped response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.returns_inout_out'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.returns_inout_out'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); jsonb_pretty -------------------------------------------------------------- { + @@ -421,7 +421,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- (1 row) -- defines a text/csv response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.returns_inout_out'->'content'->'text/csv'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.returns_inout_out'->'content'->'text/csv'); jsonb_pretty --------------------------- { + @@ -434,7 +434,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- -- Returning SET OF non-composite types -- defines an application/json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.returns_table'->'content'->'application/json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.returns_table'->'content'->'application/json'); jsonb_pretty -------------------------------------------------------------- { + @@ -448,7 +448,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- (1 row) -- defines an application/vnd.pgrst.object+json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.returns_table'->'content'->'application/vnd.pgrst.object+json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.returns_table'->'content'->'application/vnd.pgrst.object+json'); jsonb_pretty ---------------------------------------------------------- { + @@ -459,7 +459,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- (1 row) -- defines an application/vnd.pgrst.object+json;nulls=stripped response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.returns_table'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.returns_table'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); jsonb_pretty ---------------------------------------------------------- { + @@ -470,7 +470,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'- (1 row) -- defines a text/csv response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.returns_table'->'content'->'text/csv'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.returns_table'->'content'->'text/csv'); jsonb_pretty --------------------------- { + diff --git a/test/expected/schemas.out b/test/expected/schemas.out index 63390aa..e0686ff 100644 --- a/test/expected/schemas.out +++ b/test/expected/schemas.out @@ -1,13 +1,13 @@ -- Tables -- detects tables as objects -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'products'->'type'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'products'->'type'); jsonb_pretty -------------- "object" (1 row) -- detects columns with enum types as an enum property -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'products'->'properties'->'size'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'products'->'properties'->'size'); jsonb_pretty ---------------------------- { + @@ -24,7 +24,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' (1 row) -- references a composite type column from a table to a component definition -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'products'->'properties'->'attr'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'products'->'properties'->'attr'); jsonb_pretty ---------------------------------------------------- { + @@ -33,7 +33,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' (1 row) -- identifies the required columns -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'products'->'required'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'products'->'required'); jsonb_pretty ------------------- [ + @@ -45,21 +45,21 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' (1 row) -- detects comments done on a table and shows it as description -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'products'->'description'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'products'->'description'); jsonb_pretty ------------------------------------------------------------------------- "Products summary\n\nProducts description\nthat spans\nmultiple lines." (1 row) -- detects comments done on a table column and shows it as description -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'products'->'properties'->'id'->'description'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'products'->'properties'->'id'->'description'); jsonb_pretty --------------------------- "identifier of a product" (1 row) -- maps sql types to OpenAPI types correctly -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'openapi_types'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'openapi_types'); jsonb_pretty ----------------------------------------------- { + @@ -191,21 +191,21 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' (1 row) -- does not show tables outside the exposed schema -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'secret_table'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'secret_table'); jsonb_pretty -------------- (1 row) -- detects composite types as objects -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.attribute'->'type'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.attribute'->'type'); jsonb_pretty -------------- "object" (1 row) -- references a composite type column from another composite type to a component definition -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.attribute'->'properties'->'dim'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.attribute'->'properties'->'dim'); jsonb_pretty ---------------------------------------------------- { + @@ -214,7 +214,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' (1 row) -- detects a composite type inside another composite type -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.dimension'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.dimension'); jsonb_pretty --------------------------------- { + @@ -237,7 +237,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' (1 row) -- detects an array composite type inside another composite type -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.color'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.color'); jsonb_pretty ------------------------------------ { + @@ -257,28 +257,28 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' (1 row) -- does not show a composite type that is not used by an exposed table -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.hiddentype'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.hiddentype'); jsonb_pretty -------------- (1 row) -- detects comments done on a composite type and shows it as description -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.attribute'->'description'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.attribute'->'description'); jsonb_pretty --------------------------------------------------------------------------- "Attribute summary\n\nAttribute description\nthat spans\nmultiple lines." (1 row) -- detects comments done on a composite type column and shows it as description -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.attribute'->'properties'->'other'->'description'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.attribute'->'properties'->'other'->'description'); jsonb_pretty ----------------------------------------- "other information about the attribute" (1 row) -- references a composite type column from an array composite type inside the items property -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.attribute'->'properties'->'colors'->'items'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.attribute'->'properties'->'colors'->'items'); jsonb_pretty ------------------------------------------------ { + @@ -289,14 +289,14 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' -- Functions -- Composite types inside arguments -- detects composite types as objects -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.attribute_arg'->'type'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.attribute_arg'->'type'); jsonb_pretty -------------- "object" (1 row) -- references a composite type column from another composite type to a component definition -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.attribute_arg'->'properties'->'dim'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.attribute_arg'->'properties'->'dim'); jsonb_pretty -------------------------------------------------------- { + @@ -305,7 +305,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' (1 row) -- detects a composite type inside another composite type -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.dimension_arg'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.dimension_arg'); jsonb_pretty --------------------------------- { + @@ -328,7 +328,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' (1 row) -- detects an array composite type inside another composite type -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.color_arg'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.color_arg'); jsonb_pretty ------------------------------------ { + @@ -348,7 +348,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' (1 row) -- references a composite type column from an array composite type inside the items property -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.attribute_arg'->'properties'->'colors'->'items'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.attribute_arg'->'properties'->'colors'->'items'); jsonb_pretty ---------------------------------------------------- { + @@ -358,14 +358,14 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' -- Composite types inside returning values -- detects composite types as objects -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.attribute_ret'->'type'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.attribute_ret'->'type'); jsonb_pretty -------------- "object" (1 row) -- references a composite type column from another composite type to a component definition -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.attribute_ret'->'properties'->'dim'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.attribute_ret'->'properties'->'dim'); jsonb_pretty -------------------------------------------------------- { + @@ -374,7 +374,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' (1 row) -- detects a composite type inside another composite type -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.dimension_ret'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.dimension_ret'); jsonb_pretty --------------------------------- { + @@ -397,7 +397,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' (1 row) -- detects an array composite type inside another composite type -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.color_ret'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.color_ret'); jsonb_pretty ------------------------------------ { + @@ -417,7 +417,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' (1 row) -- references a composite type column from an array composite type inside the items property -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.attribute_ret'->'properties'->'colors'->'items'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.attribute_ret'->'properties'->'colors'->'items'); jsonb_pretty ---------------------------------------------------- { + @@ -427,7 +427,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' -- Non-composite return values -- detects a function that returns a simple type -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.returns_simple_type'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.returns_simple_type'); jsonb_pretty ----------------------- { + @@ -437,7 +437,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' (1 row) -- detects a function that returns a simple array type -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.returns_simple_type_arr'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.returns_simple_type_arr'); jsonb_pretty --------------------------- { + @@ -451,7 +451,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' (1 row) -- detects a function that returns table -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.returns_table'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.returns_table'); jsonb_pretty ---------------------------------------------------------------- { + @@ -473,7 +473,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' (1 row) -- detects a function that returns table with array columns -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.returns_table_arr'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.returns_table_arr'); jsonb_pretty -------------------------------------------------------------------- { + @@ -507,7 +507,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' (1 row) -- detects a function that returns a record with inout arguments -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.returns_inout'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.returns_inout'); jsonb_pretty ------------------------------------------------------------ { + @@ -525,7 +525,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' (1 row) -- detects a function that returns a record with inout array arguments -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.returns_inout_arr'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.returns_inout_arr'); jsonb_pretty ---------------------------------------------------------------- { + @@ -551,7 +551,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' (1 row) -- detects a function that returns a record with out arguments -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.returns_out'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.returns_out'); jsonb_pretty ------------------------------------------------------------ { + @@ -569,7 +569,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' (1 row) -- detects a function that returns a record with out array arguments -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.returns_out_arr'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.returns_out_arr'); jsonb_pretty ---------------------------------------------------------------- { + @@ -595,7 +595,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' (1 row) -- detects a function that returns a record with inout and out arguments -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.returns_inout_out'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.returns_inout_out'); jsonb_pretty ------------------------------------------------------------ { + @@ -613,7 +613,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' (1 row) -- detects a function that returns a record with inout and out array arguments -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.returns_inout_out_arr'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.returns_inout_out_arr'); jsonb_pretty ---------------------------------------------------------------- { + @@ -639,7 +639,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' (1 row) -- detects a function that returns an unknown record as a free-form object -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.returns_unknown_record'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.returns_unknown_record'); jsonb_pretty ------------------------ { + @@ -649,7 +649,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' (1 row) -- detects a function with a single unnamed json parameter -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.single_unnamed_json_param'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.single_unnamed_json_param'); jsonb_pretty ----------------------- { + @@ -659,7 +659,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' (1 row) -- detects a function with a single unnamed jsonb parameter -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.single_unnamed_jsonb_param'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.single_unnamed_jsonb_param'); jsonb_pretty ----------------------- { + @@ -669,7 +669,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' (1 row) -- detects a function with a single unnamed text parameter -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.single_unnamed_text_param'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.single_unnamed_text_param'); jsonb_pretty ----------------------- { + @@ -679,7 +679,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' (1 row) -- detects a function with a single unnamed xml parameter -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.single_unnamed_xml_param'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.single_unnamed_xml_param'); jsonb_pretty ----------------------- { + @@ -689,28 +689,28 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' (1 row) -- ignores a function with a single unnamed unrecognized parameter -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.single_unnamed_unrecognized_param'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.single_unnamed_unrecognized_param'); jsonb_pretty -------------- (1 row) -- ignores a function with unnamed parameters -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.single_unnamed_unrecognized_param'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.single_unnamed_unrecognized_param'); jsonb_pretty -------------- (1 row) -- ignores a function with named and unnamed parameters -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.single_unnamed_unrecognized_param'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.single_unnamed_unrecognized_param'); jsonb_pretty -------------- (1 row) -- ignores a function outside of the exposed schemas -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.private.secret_function'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.private.secret_function'); jsonb_pretty -------------- @@ -719,7 +719,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->' -- Common -- defines all the available prefer headers select key, jsonb_pretty(value) -from jsonb_each(postgrest_openapi_spec('{test}')->'components'->'schemas') +from jsonb_each(get_openapi_document('{test}')->'components'->'schemas') where key like 'header.prefer%'; key | jsonb_pretty --------------------------+-------------------------------------------------------------------------- diff --git a/test/expected/security.out b/test/expected/security.out index 6bc03eb..cf4e37f 100644 --- a/test/expected/security.out +++ b/test/expected/security.out @@ -1,5 +1,5 @@ -- shows the JWT security scheme -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'securitySchemes'->'JWT'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'securitySchemes'->'JWT'); jsonb_pretty -------------------------------------------------------------------------------------------- { + @@ -11,7 +11,7 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'securitySch (1 row) -- lists the JWT scheme as a security requirement object -select postgrest_openapi_spec('{test}')->'security' <@ '[{"JWT": []}]'::jsonb as has_jwt; +select get_openapi_document('{test}')->'security' <@ '[{"JWT": []}]'::jsonb as has_jwt; has_jwt --------- t diff --git a/test/fixtures.sql b/test/fixtures.sql index 5471785..81bd2f3 100644 --- a/test/fixtures.sql +++ b/test/fixtures.sql @@ -256,5 +256,31 @@ returns void as $$ ; $$ language sql; --- Emulate PostgREST search_path setting -alter database contrib_regression set search_path = test, public; +-- Table that stores openapi documents for different schemas. It speeds up the testing process. +create table public.postgrest_openapi( + schemas text[] primary key, + document jsonb +); + +-- Wrapper function to retrieve openapi documents according to the schema +create or replace function public.get_openapi_document(schemas text[]) +returns jsonb +immutable language sql as +$$ + select document + from public.postgrest_openapi p + where p.schemas = $1; +$$; + +create or replace function public.insert_openapi_document(schemas text[]) +returns void +language plpgsql as +$$begin + -- Before inserting the openapi document, we emulate the PostgREST search path + perform set_config('search_path', array_to_string(schemas || '{public}', ','), true); + insert into public.postgrest_openapi + select schemas, public.postgrest_openapi_spec(schemas); +end$$; + +select public.insert_openapi_document('{test}'); +select public.insert_openapi_document('{types}'); diff --git a/test/sql/info.sql b/test/sql/info.sql index 2c0e2db..34d7fda 100644 --- a/test/sql/info.sql +++ b/test/sql/info.sql @@ -1,19 +1,19 @@ -- shows the first line of the comment on the schema as title -select jsonb_pretty(postgrest_openapi_spec('{test}')->'info'->'title'); +select jsonb_pretty(get_openapi_document('{test}')->'info'->'title'); -- shows the second line of the comment on the schema as summary -select jsonb_pretty(postgrest_openapi_spec('{test}')->'info'->'summary'); +select jsonb_pretty(get_openapi_document('{test}')->'info'->'summary'); -- shows the third line of the comment on the schema as description -select jsonb_pretty(postgrest_openapi_spec('{test}')->'info'->'description'); +select jsonb_pretty(get_openapi_document('{test}')->'info'->'description'); -- shows default title when there is no comment on the schema -select jsonb_pretty(postgrest_openapi_spec('{types}')->'info'->'title'); +select jsonb_pretty(get_openapi_document('{types}')->'info'->'title'); -- shows no summary when there is no comment on the schema -select postgrest_openapi_spec('{types}')->'info' ? 'summary'; +select get_openapi_document('{types}')->'info' ? 'summary'; -- shows default description when there is no comment on the schema -select jsonb_pretty(postgrest_openapi_spec('{types}')->'info'->'description'); +select jsonb_pretty(get_openapi_document('{types}')->'info'->'description'); -- TODO: tests for versions diff --git a/test/sql/parameters.sql b/test/sql/parameters.sql index f7a913a..8cf1421 100644 --- a/test/sql/parameters.sql +++ b/test/sql/parameters.sql @@ -1,34 +1,34 @@ -- shows common query parameters select * -from jsonb_each(postgrest_openapi_spec('{test}')->'components'->'parameters') +from jsonb_each(get_openapi_document('{test}')->'components'->'parameters') where key in ('select', 'order', 'limit', 'offset', 'on_conflict', 'columns', 'or', 'and', 'not.or', 'not.and'); -- shows common headers select key, jsonb_pretty(value) -from jsonb_each(postgrest_openapi_spec('{test}')->'components'->'parameters') +from jsonb_each(get_openapi_document('{test}')->'components'->'parameters') where key in ('preferGet', 'preferPost', 'preferPut', 'preferPatch', 'preferDelete', 'preferPostRpc', 'range'); -- shows table columns as parameters select key, jsonb_pretty(value) -from jsonb_each(postgrest_openapi_spec('{test}')->'components'->'parameters') +from jsonb_each(get_openapi_document('{test}')->'components'->'parameters') where key like 'rowFilter.products.%'; -- shows view columns as parameters select key, jsonb_pretty(value) -from jsonb_each(postgrest_openapi_spec('{test}')->'components'->'parameters') +from jsonb_each(get_openapi_document('{test}')->'components'->'parameters') where key like 'rowFilter.big_products.%'; -- shows `IN` function arguments as RPC parameters select key, jsonb_pretty(value) -from jsonb_each(postgrest_openapi_spec('{test}')->'components'->'parameters') +from jsonb_each(get_openapi_document('{test}')->'components'->'parameters') where key like 'rpcParam.has_in_parameters.%'; -- shows `INOUT` function arguments as RPC parameters select key, jsonb_pretty(value) -from jsonb_each(postgrest_openapi_spec('{test}')->'components'->'parameters') +from jsonb_each(get_openapi_document('{test}')->'components'->'parameters') where key like 'rpcParam.has_inout_parameters.%'; -- shows `VARIADIC` function arguments as RPC parameters select key, jsonb_pretty(value) -from jsonb_each(postgrest_openapi_spec('{test}')->'components'->'parameters') +from jsonb_each(get_openapi_document('{test}')->'components'->'parameters') where key like 'rpcParam.has_variadic_parameter.%'; diff --git a/test/sql/paths.sql b/test/sql/paths.sql index eebfeb3..5d1cb89 100644 --- a/test/sql/paths.sql +++ b/test/sql/paths.sql @@ -1,311 +1,311 @@ -- shows root path for the OpenAPI output -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/'); -- Tables -- GET operation object -- shows the table name as tag -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'get'->'tags'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'get'->'tags'); -- uses a reference for the 200 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'get'->'responses'->'200'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'get'->'responses'->'200'); -- uses a reference for the 206 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'get'->'responses'->'206'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'get'->'responses'->'206'); -- uses a reference for error responses -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'get'->'responses'->'default'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'get'->'responses'->'default'); -- uses references for columns as query parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/products'->'get'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/products'->'get'->'parameters') where value->>'$ref' like '#/components/parameters/rowFilter.products.%'; -- shows the first line of the comment on the table as summary -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'get'->'summary'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'get'->'summary'); -- shows the second line of the comment on the table as description -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'get'->'description'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'get'->'description'); -- uses references for common parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/products'->'get'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/products'->'get'->'parameters') where value->>'$ref' not like '#/components/parameters/rowFilter.products.%'; -- POST operation object -- shows the table name as tag -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'post'->'tags'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'post'->'tags'); -- uses a reference for the 201 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'post'->'responses'->'201'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'post'->'responses'->'201'); -- uses a reference for error responses -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'post'->'responses'->'default'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'post'->'responses'->'default'); -- uses a reference for request body -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'post'->'requestBody'->'$ref'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'post'->'requestBody'->'$ref'); -- shows the first line of the comment on the table as summary -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'post'->'summary'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'post'->'summary'); -- shows the second line of the comment on the table as description -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'post'->'description'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'post'->'description'); -- uses references for common parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/products'->'post'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/products'->'post'->'parameters') where value->>'$ref' like '#/components/parameters/%'; -- PATCH operation object -- shows the table name as tag -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'patch'->'tags'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'patch'->'tags'); -- uses a reference for the 200 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'patch'->'responses'->'200'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'patch'->'responses'->'200'); -- uses a reference for the 204 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'patch'->'responses'->'204'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'patch'->'responses'->'204'); -- uses a reference for error responses -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'patch'->'responses'->'default'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'patch'->'responses'->'default'); -- uses a reference for request body -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'patch'->'requestBody'->'$ref'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'patch'->'requestBody'->'$ref'); -- shows the first line of the comment on the table as summary -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'patch'->'summary'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'patch'->'summary'); -- shows the second line of the comment on the table as description -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'patch'->'description'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'patch'->'description'); -- uses references for columns as query parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/products'->'patch'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/products'->'patch'->'parameters') where value->>'$ref' like '#/components/parameters/rowFilter.products.%'; -- uses references for common parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/products'->'patch'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/products'->'patch'->'parameters') where value->>'$ref' not like '#/components/parameters/rowFilter.products.%'; -- DELETE operation object -- shows the table name as tag -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'delete'->'tags'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'delete'->'tags'); -- uses a reference for the 200 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'delete'->'responses'->'200'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'delete'->'responses'->'200'); -- uses a reference for the 204 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'delete'->'responses'->'204'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'delete'->'responses'->'204'); -- uses a reference for error responses -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'delete'->'responses'->'default'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'delete'->'responses'->'default'); -- shows the first line of the comment on the table as summary -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'delete'->'summary'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'delete'->'summary'); -- shows the second line of the comment on the table as description -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'delete'->'description'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/products'->'delete'->'description'); -- uses references for columns as query parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/products'->'delete'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/products'->'delete'->'parameters') where value->>'$ref' like '#/components/parameters/rowFilter.products.%'; -- uses references for common parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/products'->'delete'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/products'->'delete'->'parameters') where value->>'$ref' not like '#/components/parameters/rowFilter.products.%'; -- Views -- GET operation object -- shows the table name as tag -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'get'->'tags'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'get'->'tags'); -- uses a reference for the 200 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'get'->'responses'->'200'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'get'->'responses'->'200'); -- uses a reference for the 206 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'get'->'responses'->'206'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'get'->'responses'->'206'); -- uses a reference for error responses -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'get'->'responses'->'default'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'get'->'responses'->'default'); -- shows the first line of the comment on the table as summary -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'get'->'summary'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'get'->'summary'); -- shows the second line of the comment on the table as description -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'get'->'description'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'get'->'description'); -- uses references for columns as query parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'get'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/big_products'->'get'->'parameters') where value->>'$ref' like '#/components/parameters/rowFilter.big_products.%'; -- uses references for common parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'get'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/big_products'->'get'->'parameters') where value->>'$ref' not like '#/components/parameters/rowFilter.big_products.%'; -- shows a GET operation object for non auto-updatable views -select postgrest_openapi_spec('{test}')->'paths'->'/non_auto_updatable' ? 'get' as value; +select get_openapi_document('{test}')->'paths'->'/non_auto_updatable' ? 'get' as value; -- POST operation object -- shows the table name as tag -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'post'->'tags'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'post'->'tags'); -- uses a reference for the 201 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'post'->'responses'->'201'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'post'->'responses'->'201'); -- uses a reference for error responses -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'post'->'responses'->'default'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'post'->'responses'->'default'); -- uses a reference for request body -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'post'->'requestBody'->'$ref'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'post'->'requestBody'->'$ref'); -- shows the first line of the comment on the table as summary -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'post'->'summary'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'post'->'summary'); -- shows the second line of the comment on the table as description -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'post'->'description'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'post'->'description'); -- uses references for common parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'post'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/big_products'->'post'->'parameters') where value->>'$ref' like '#/components/parameters/%'; -- does not show a POST operation object for non auto-updatable views -select postgrest_openapi_spec('{test}')->'paths'->'/non_auto_updatable' ? 'post' as value; +select get_openapi_document('{test}')->'paths'->'/non_auto_updatable' ? 'post' as value; -- PATCH operation object -- shows the table name as tag -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'patch'->'tags'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'patch'->'tags'); -- uses a reference for the 200 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'patch'->'responses'->'200'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'patch'->'responses'->'200'); -- uses a reference for the 204 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'patch'->'responses'->'204'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'patch'->'responses'->'204'); -- uses a reference for error responses -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'patch'->'responses'->'default'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'patch'->'responses'->'default'); -- uses a reference for request body -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'patch'->'requestBody'->'$ref'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'patch'->'requestBody'->'$ref'); -- shows the first line of the comment on the table as summary -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'patch'->'summary'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'patch'->'summary'); -- shows the second line of the comment on the table as description -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'patch'->'description'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'patch'->'description'); -- uses references for columns as query parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'patch'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/big_products'->'patch'->'parameters') where value->>'$ref' like '#/components/parameters/rowFilter.big_products.%'; -- uses references for common parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'patch'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/big_products'->'patch'->'parameters') where value->>'$ref' not like '#/components/parameters/rowFilter.big_products.%'; -- does not show a PATCH operation object for non auto-updatable views -select postgrest_openapi_spec('{test}')->'paths'->'/non_auto_updatable' ? 'patch' as value; +select get_openapi_document('{test}')->'paths'->'/non_auto_updatable' ? 'patch' as value; -- DELETE operation object -- shows the table name as tag -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'delete'->'tags'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'delete'->'tags'); -- uses a reference for the 200 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'delete'->'responses'->'200'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'delete'->'responses'->'200'); -- uses a reference for the 204 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'delete'->'responses'->'204'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'delete'->'responses'->'204'); -- uses a reference for error responses -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'delete'->'responses'->'default'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'delete'->'responses'->'default'); -- shows the first line of the comment on the table as summary -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'delete'->'summary'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'delete'->'summary'); -- shows the second line of the comment on the table as description -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'delete'->'description'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/big_products'->'delete'->'description'); -- uses references for columns as query parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'delete'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/big_products'->'delete'->'parameters') where value->>'$ref' like '#/components/parameters/rowFilter.big_products.%'; -- uses references for common parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'delete'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/big_products'->'delete'->'parameters') where value->>'$ref' not like '#/components/parameters/rowFilter.big_products.%'; -- does not show a DELETE operation object for non auto-updatable views -select postgrest_openapi_spec('{test}')->'paths'->'/non_auto_updatable' ? 'delete' as value; +select get_openapi_document('{test}')->'paths'->'/non_auto_updatable' ? 'delete' as value; -- Functions -- GET operation object -- shows the function name as tag -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/get_products_by_size'->'get'->'tags'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/rpc/get_products_by_size'->'get'->'tags'); -- uses a reference for the 200 HTTP code response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/get_products_by_size'->'get'->'responses'->'200'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/rpc/get_products_by_size'->'get'->'responses'->'200'); -- uses a reference for the 206 HTTP code response on `RETURNS SET OF` functions -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/get_products_by_size'->'get'->'responses'->'206'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/rpc/get_products_by_size'->'get'->'responses'->'206'); -- uses a reference for error responses -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/get_products_by_size'->'get'->'responses'->'default'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/rpc/get_products_by_size'->'get'->'responses'->'default'); -- shows the first line of the comment on the table as summary -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/get_products_by_size'->'get'->'summary'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/rpc/get_products_by_size'->'get'->'summary'); -- shows the second line of the comment on the table as description -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/get_products_by_size'->'get'->'description'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/rpc/get_products_by_size'->'get'->'description'); -- uses references for common parameters on `RETURNS ` functions select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/rpc/get_attribute'->'get'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/rpc/get_attribute'->'get'->'parameters') where value->>'$ref' not like '#/components/parameters/rpcParam.get_attribute.%'; -- uses references for common parameters on `RETURNS TABLE` functions select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/rpc/returns_table'->'get'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/rpc/returns_table'->'get'->'parameters') where value->>'$ref' not like '#/components/parameters/rpcParam.returns_table.%'; -- uses references for common parameters on functions with INOUT/OUT parameters select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/rpc/returns_inout_out'->'get'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/rpc/returns_inout_out'->'get'->'parameters') where value->>'$ref' not like '#/components/parameters/rpcParam.returns_inout_out.%'; -- does not use a reference for the 206 HTTP code response on functions that do not return `SET OF` -select postgrest_openapi_spec('{test}')->'paths'->'/rpc/get_attribute'->'get'->'responses' ? '206' as value; +select get_openapi_document('{test}')->'paths'->'/rpc/get_attribute'->'get'->'responses' ? '206' as value; -- does not use a reference for common parameters (except for prefer headers) on functions that do not return composite types select value -from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/rpc/returns_simple_type'->'get'->'parameters') +from jsonb_array_elements(get_openapi_document('{test}')->'paths'->'/rpc/returns_simple_type'->'get'->'parameters') where value->>'$ref' not like '#/components/parameters/rpcParam.returns_simple_type.%'; -- shows a function with a single unnamed parameter of accepted types -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/single_unnamed_json_param'->'get'->'tags'); -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/single_unnamed_jsonb_param'->'get'->'tags'); -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/single_unnamed_text_param'->'get'->'tags'); -select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/rpc/single_unnamed_xml_param'->'get'->'tags'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/rpc/single_unnamed_json_param'->'get'->'tags'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/rpc/single_unnamed_jsonb_param'->'get'->'tags'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/rpc/single_unnamed_text_param'->'get'->'tags'); +select jsonb_pretty(get_openapi_document('{test}')->'paths'->'/rpc/single_unnamed_xml_param'->'get'->'tags'); -- does not show a function with a single unnamed parameter of non-accepted types -select postgrest_openapi_spec('{test}')->'paths' ? '/rpc/single_unnamed_unrecognized_param' as value; +select get_openapi_document('{test}')->'paths' ? '/rpc/single_unnamed_unrecognized_param' as value; -- does not show a function with unnamed parameters -select postgrest_openapi_spec('{test}')->'paths' ? '/rpc/unnamed_params' as value; +select get_openapi_document('{test}')->'paths' ? '/rpc/unnamed_params' as value; -- does not show a function with named and unnamed parameters -select postgrest_openapi_spec('{test}')->'paths' ? '/rpc/named_and_unnamed_params' as value; +select get_openapi_document('{test}')->'paths' ? '/rpc/named_and_unnamed_params' as value; diff --git a/test/sql/reqbodies.sql b/test/sql/reqbodies.sql index f929f55..2ccc9c6 100644 --- a/test/sql/reqbodies.sql +++ b/test/sql/reqbodies.sql @@ -1,24 +1,24 @@ -- Tables -- defines an application/json request body -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'requestBodies'->'products'->'content'->'application/json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'requestBodies'->'products'->'content'->'application/json'); -- defines an application/x-www-form-urlencoded request body -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'requestBodies'->'products'->'content'->'application/x-www-form-urlencoded'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'requestBodies'->'products'->'content'->'application/x-www-form-urlencoded'); -- defines a text/csv request body -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'requestBodies'->'products'->'content'->'text/csv'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'requestBodies'->'products'->'content'->'text/csv'); -- Views -- defines an application/json request body -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'requestBodies'->'big_products'->'content'->'application/json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'requestBodies'->'big_products'->'content'->'application/json'); -- defines an application/x-www-form-urlencoded request body -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'requestBodies'->'big_products'->'content'->'application/x-www-form-urlencoded'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'requestBodies'->'big_products'->'content'->'application/x-www-form-urlencoded'); -- defines a text/csv request body -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'requestBodies'->'big_products'->'content'->'text/csv'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'requestBodies'->'big_products'->'content'->'text/csv'); -- does not define a request body for non auto-updatable views -select postgrest_openapi_spec('{test}')->'components'->'requestBodies' ? 'non_auto_updatable' as value; +select get_openapi_document('{test}')->'components'->'requestBodies' ? 'non_auto_updatable' as value; diff --git a/test/sql/responses.sql b/test/sql/responses.sql index 707f8c5..764f99c 100644 --- a/test/sql/responses.sql +++ b/test/sql/responses.sql @@ -1,125 +1,125 @@ -- defines a default error response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'defaultError'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'defaultError'); -- defines an empty response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'empty'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'empty'); -- Tables -- Non-empty response body -- defines an application/json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'notEmpty.products'->'content'->'application/json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'notEmpty.products'->'content'->'application/json'); -- defines an application/vnd.pgrst.object+json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'notEmpty.products'->'content'->'application/vnd.pgrst.object+json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'notEmpty.products'->'content'->'application/vnd.pgrst.object+json'); -- defines an application/vnd.pgrst.object+json;nulls=stripped response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'notEmpty.products'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'notEmpty.products'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); -- defines a text/csv response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'notEmpty.products'->'content'->'text/csv'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'notEmpty.products'->'content'->'text/csv'); -- Empty or non-empty response body -- defines an application/json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'mayBeEmpty.products'->'content'->'application/json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'mayBeEmpty.products'->'content'->'application/json'); -- defines an application/vnd.pgrst.object+json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'mayBeEmpty.products'->'content'->'application/vnd.pgrst.object+json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'mayBeEmpty.products'->'content'->'application/vnd.pgrst.object+json'); -- defines an application/vnd.pgrst.object+json;nulls=stripped response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'mayBeEmpty.products'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'mayBeEmpty.products'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); -- defines a text/csv response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'mayBeEmpty.products'->'content'->'text/csv'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'mayBeEmpty.products'->'content'->'text/csv'); -- Views -- Non-empty response body -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'notEmpty.big_products'->'content'->'application/json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'notEmpty.big_products'->'content'->'application/json'); -- defines an application/vnd.pgrst.object+json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'notEmpty.big_products'->'content'->'application/vnd.pgrst.object+json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'notEmpty.big_products'->'content'->'application/vnd.pgrst.object+json'); -- defines an application/vnd.pgrst.object+json;nulls=stripped response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'notEmpty.big_products'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'notEmpty.big_products'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); -- defines a text/csv response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'notEmpty.big_products'->'content'->'text/csv'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'notEmpty.big_products'->'content'->'text/csv'); -- defines a non-empty response body for non auto-updatable views -select postgrest_openapi_spec('{test}')->'components'->'responses' ? 'notEmpty.non_auto_updatable' as value; +select get_openapi_document('{test}')->'components'->'responses' ? 'notEmpty.non_auto_updatable' as value; -- Empty or non-empty response body -- defines an application/json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'mayBeEmpty.big_products'->'content'->'application/json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'mayBeEmpty.big_products'->'content'->'application/json'); -- defines an application/vnd.pgrst.object+json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'mayBeEmpty.big_products'->'content'->'application/vnd.pgrst.object+json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'mayBeEmpty.big_products'->'content'->'application/vnd.pgrst.object+json'); -- defines an application/vnd.pgrst.object+json;nulls=stripped response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'mayBeEmpty.big_products'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'mayBeEmpty.big_products'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); -- defines a text/csv response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'mayBeEmpty.big_products'->'content'->'text/csv'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'mayBeEmpty.big_products'->'content'->'text/csv'); -- does not define an empty or non-empty response body for non auto-updatable views -select postgrest_openapi_spec('{test}')->'components'->'responses' ? 'mayBeEmpty.non_auto_updatable' as value; +select get_openapi_document('{test}')->'components'->'responses' ? 'mayBeEmpty.non_auto_updatable' as value; -- Functions -- Returning composite types -- defines an application/json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.get_attribute'->'content'->'application/json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.get_attribute'->'content'->'application/json'); -- defines an application/vnd.pgrst.object+json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.get_attribute'->'content'->'application/vnd.pgrst.object+json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.get_attribute'->'content'->'application/vnd.pgrst.object+json'); -- defines an application/vnd.pgrst.object+json;nulls=stripped response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.get_attribute'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.get_attribute'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); -- defines a text/csv response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.get_attribute'->'content'->'text/csv'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.get_attribute'->'content'->'text/csv'); -- Returning SET OF composite types -- defines an application/json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.get_products_by_size'->'content'->'application/json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.get_products_by_size'->'content'->'application/json'); -- defines an application/vnd.pgrst.object+json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.get_products_by_size'->'content'->'application/vnd.pgrst.object+json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.get_products_by_size'->'content'->'application/vnd.pgrst.object+json'); -- defines an application/vnd.pgrst.object+json;nulls=stripped response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.get_products_by_size'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.get_products_by_size'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); -- defines a text/csv response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.get_products_by_size'->'content'->'text/csv'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.get_products_by_size'->'content'->'text/csv'); -- Returning non-composite types -- defines an application/json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.returns_inout_out'->'content'->'application/json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.returns_inout_out'->'content'->'application/json'); -- defines an application/vnd.pgrst.object+json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.returns_inout_out'->'content'->'application/vnd.pgrst.object+json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.returns_inout_out'->'content'->'application/vnd.pgrst.object+json'); -- defines an application/vnd.pgrst.object+json;nulls=stripped response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.returns_inout_out'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.returns_inout_out'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); -- defines a text/csv response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.returns_inout_out'->'content'->'text/csv'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.returns_inout_out'->'content'->'text/csv'); -- Returning SET OF non-composite types -- defines an application/json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.returns_table'->'content'->'application/json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.returns_table'->'content'->'application/json'); -- defines an application/vnd.pgrst.object+json response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.returns_table'->'content'->'application/vnd.pgrst.object+json'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.returns_table'->'content'->'application/vnd.pgrst.object+json'); -- defines an application/vnd.pgrst.object+json;nulls=stripped response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.returns_table'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.returns_table'->'content'->'application/vnd.pgrst.object+json;nulls=stripped'); -- defines a text/csv response -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'responses'->'rpc.returns_table'->'content'->'text/csv'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'responses'->'rpc.returns_table'->'content'->'text/csv'); diff --git a/test/sql/schemas.sql b/test/sql/schemas.sql index 79cda5a..c8997b1 100644 --- a/test/sql/schemas.sql +++ b/test/sql/schemas.sql @@ -1,151 +1,151 @@ -- Tables -- detects tables as objects -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'products'->'type'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'products'->'type'); -- detects columns with enum types as an enum property -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'products'->'properties'->'size'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'products'->'properties'->'size'); -- references a composite type column from a table to a component definition -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'products'->'properties'->'attr'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'products'->'properties'->'attr'); -- identifies the required columns -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'products'->'required'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'products'->'required'); -- detects comments done on a table and shows it as description -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'products'->'description'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'products'->'description'); -- detects comments done on a table column and shows it as description -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'products'->'properties'->'id'->'description'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'products'->'properties'->'id'->'description'); -- maps sql types to OpenAPI types correctly -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'openapi_types'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'openapi_types'); -- does not show tables outside the exposed schema -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'secret_table'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'secret_table'); -- detects composite types as objects -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.attribute'->'type'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.attribute'->'type'); -- references a composite type column from another composite type to a component definition -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.attribute'->'properties'->'dim'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.attribute'->'properties'->'dim'); -- detects a composite type inside another composite type -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.dimension'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.dimension'); -- detects an array composite type inside another composite type -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.color'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.color'); -- does not show a composite type that is not used by an exposed table -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.hiddentype'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.hiddentype'); -- detects comments done on a composite type and shows it as description -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.attribute'->'description'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.attribute'->'description'); -- detects comments done on a composite type column and shows it as description -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.attribute'->'properties'->'other'->'description'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.attribute'->'properties'->'other'->'description'); -- references a composite type column from an array composite type inside the items property -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.attribute'->'properties'->'colors'->'items'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.attribute'->'properties'->'colors'->'items'); -- Functions -- Composite types inside arguments -- detects composite types as objects -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.attribute_arg'->'type'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.attribute_arg'->'type'); -- references a composite type column from another composite type to a component definition -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.attribute_arg'->'properties'->'dim'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.attribute_arg'->'properties'->'dim'); -- detects a composite type inside another composite type -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.dimension_arg'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.dimension_arg'); -- detects an array composite type inside another composite type -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.color_arg'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.color_arg'); -- references a composite type column from an array composite type inside the items property -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.attribute_arg'->'properties'->'colors'->'items'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.attribute_arg'->'properties'->'colors'->'items'); -- Composite types inside returning values -- detects composite types as objects -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.attribute_ret'->'type'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.attribute_ret'->'type'); -- references a composite type column from another composite type to a component definition -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.attribute_ret'->'properties'->'dim'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.attribute_ret'->'properties'->'dim'); -- detects a composite type inside another composite type -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.dimension_ret'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.dimension_ret'); -- detects an array composite type inside another composite type -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.color_ret'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.color_ret'); -- references a composite type column from an array composite type inside the items property -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'types.attribute_ret'->'properties'->'colors'->'items'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'types.attribute_ret'->'properties'->'colors'->'items'); -- Non-composite return values -- detects a function that returns a simple type -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.returns_simple_type'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.returns_simple_type'); -- detects a function that returns a simple array type -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.returns_simple_type_arr'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.returns_simple_type_arr'); -- detects a function that returns table -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.returns_table'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.returns_table'); -- detects a function that returns table with array columns -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.returns_table_arr'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.returns_table_arr'); -- detects a function that returns a record with inout arguments -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.returns_inout'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.returns_inout'); -- detects a function that returns a record with inout array arguments -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.returns_inout_arr'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.returns_inout_arr'); -- detects a function that returns a record with out arguments -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.returns_out'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.returns_out'); -- detects a function that returns a record with out array arguments -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.returns_out_arr'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.returns_out_arr'); -- detects a function that returns a record with inout and out arguments -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.returns_inout_out'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.returns_inout_out'); -- detects a function that returns a record with inout and out array arguments -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.returns_inout_out_arr'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.returns_inout_out_arr'); -- detects a function that returns an unknown record as a free-form object -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.returns_unknown_record'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.returns_unknown_record'); -- detects a function with a single unnamed json parameter -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.single_unnamed_json_param'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.single_unnamed_json_param'); -- detects a function with a single unnamed jsonb parameter -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.single_unnamed_jsonb_param'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.single_unnamed_jsonb_param'); -- detects a function with a single unnamed text parameter -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.single_unnamed_text_param'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.single_unnamed_text_param'); -- detects a function with a single unnamed xml parameter -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.single_unnamed_xml_param'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.single_unnamed_xml_param'); -- ignores a function with a single unnamed unrecognized parameter -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.single_unnamed_unrecognized_param'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.single_unnamed_unrecognized_param'); -- ignores a function with unnamed parameters -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.single_unnamed_unrecognized_param'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.single_unnamed_unrecognized_param'); -- ignores a function with named and unnamed parameters -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.single_unnamed_unrecognized_param'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.single_unnamed_unrecognized_param'); -- ignores a function outside of the exposed schemas -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'schemas'->'rpc.private.secret_function'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'schemas'->'rpc.private.secret_function'); -- Common -- defines all the available prefer headers select key, jsonb_pretty(value) -from jsonb_each(postgrest_openapi_spec('{test}')->'components'->'schemas') +from jsonb_each(get_openapi_document('{test}')->'components'->'schemas') where key like 'header.prefer%'; diff --git a/test/sql/security.sql b/test/sql/security.sql index 26081e0..faafbff 100644 --- a/test/sql/security.sql +++ b/test/sql/security.sql @@ -1,5 +1,5 @@ -- shows the JWT security scheme -select jsonb_pretty(postgrest_openapi_spec('{test}')->'components'->'securitySchemes'->'JWT'); +select jsonb_pretty(get_openapi_document('{test}')->'components'->'securitySchemes'->'JWT'); -- lists the JWT scheme as a security requirement object -select postgrest_openapi_spec('{test}')->'security' <@ '[{"JWT": []}]'::jsonb as has_jwt; +select get_openapi_document('{test}')->'security' <@ '[{"JWT": []}]'::jsonb as has_jwt;