Revert "add: configs as json GUC for db-root-spec"
This reverts commit f34ca15e84.
This commit is contained in:
@@ -8,29 +8,19 @@ import Test.Hspec.Wai.JSON
|
||||
|
||||
import PostgREST.Config (AppConfig (..))
|
||||
import PostgREST.SchemaCache.Identifiers (QualifiedIdentifier (..))
|
||||
import PostgREST.Version (prettyVersion)
|
||||
|
||||
import Protolude hiding (get)
|
||||
import SpecHelper
|
||||
|
||||
spec :: SpecWithConfig
|
||||
spec withConfig = withConfig (baseCfg
|
||||
{ configDbRootSpec = Just $ QualifiedIdentifier mempty "root"
|
||||
, configDbSchemas = "test" :| ["v1"]
|
||||
, configOpenApiServerProxyUri = Just "https://example.com/base"
|
||||
}) $
|
||||
spec withConfig = withConfig (baseCfg { configDbRootSpec = Just $ QualifiedIdentifier mempty "root" }) $
|
||||
describe "root spec function" $ do
|
||||
it "accepts application/openapi+json" $ do
|
||||
request methodGet "/"
|
||||
[("Accept","application/openapi+json")] "" `shouldRespondWith`
|
||||
[json|{
|
||||
"swagger": "2.0",
|
||||
"info": {"title": "PostgREST API", "description": "This is a dynamic API generated by PostgREST"},
|
||||
"pgrst_server_host": "localhost",
|
||||
"pgrst_server_port": "3000",
|
||||
"pgrst_openapi_server_proxy_uri": "https://example.com/base",
|
||||
"pgrst_db_schemas": ["test", "v1"],
|
||||
"pgrst_version": #{decodeUtf8 prettyVersion}
|
||||
"info": {"title": "PostgREST API", "description": "This is a dynamic API generated by PostgREST"}
|
||||
}|]
|
||||
{ matchHeaders = ["Content-Type" <:> "application/openapi+json; charset=utf-8"] }
|
||||
|
||||
@@ -39,25 +29,6 @@ spec withConfig = withConfig (baseCfg
|
||||
[("Accept","application/json")] "" `shouldRespondWith`
|
||||
[json|{
|
||||
"swagger": "2.0",
|
||||
"info": {"title": "PostgREST API", "description": "This is a dynamic API generated by PostgREST"},
|
||||
"pgrst_server_host": "localhost",
|
||||
"pgrst_server_port": "3000",
|
||||
"pgrst_openapi_server_proxy_uri": "https://example.com/base",
|
||||
"pgrst_db_schemas": ["test", "v1"],
|
||||
"pgrst_version": #{decodeUtf8 prettyVersion}
|
||||
"info": {"title": "PostgREST API", "description": "This is a dynamic API generated by PostgREST"}
|
||||
}|]
|
||||
{ matchHeaders = ["Content-Type" <:> "application/json; charset=utf-8"] }
|
||||
|
||||
it "returns null GUCs on non-root paths" $ do
|
||||
request methodGet "/rpc/root"
|
||||
[("Accept","application/openapi+json")] "" `shouldRespondWith`
|
||||
[json|{
|
||||
"swagger": "2.0",
|
||||
"info": {"title": "PostgREST API", "description": "This is a dynamic API generated by PostgREST"},
|
||||
"pgrst_server_host": null,
|
||||
"pgrst_server_port": null,
|
||||
"pgrst_openapi_server_proxy_uri": null,
|
||||
"pgrst_db_schemas": null,
|
||||
"pgrst_version": null
|
||||
}|]
|
||||
{ matchHeaders = ["Content-Type" <:> "application/openapi+json; charset=utf-8"] }
|
||||
|
||||
Vendored
+11
-15
@@ -1866,22 +1866,18 @@ $$ language sql;
|
||||
|
||||
create or replace function root() returns "application/openapi+json" as $_$
|
||||
declare
|
||||
pgrst_config json := nullif(current_setting('request.root.configs', true), '')::json;
|
||||
openapi json = $$
|
||||
{
|
||||
"swagger": "2.0",
|
||||
"info":{
|
||||
"title":"PostgREST API",
|
||||
"description":"This is a dynamic API generated by PostgREST"
|
||||
}
|
||||
}
|
||||
$$;
|
||||
begin
|
||||
return (
|
||||
select json_build_object(
|
||||
'swagger', '2.0',
|
||||
'info', json_build_object(
|
||||
'title', 'PostgREST API',
|
||||
'description', 'This is a dynamic API generated by PostgREST'
|
||||
),
|
||||
'pgrst_server_host', pgrst_config->>'server_host',
|
||||
'pgrst_server_port', pgrst_config->>'server_port',
|
||||
'pgrst_openapi_server_proxy_uri', pgrst_config->>'openapi_server_proxy_uri',
|
||||
'pgrst_db_schemas', pgrst_config->'db_schemas',
|
||||
'pgrst_version', pgrst_config->>'version'
|
||||
)::json);
|
||||
end;
|
||||
return openapi;
|
||||
end
|
||||
$_$ language plpgsql;
|
||||
|
||||
create or replace function welcome() returns "text/plain" as $$
|
||||
|
||||
Reference in New Issue
Block a user