DB_SCHEMAS does not display all schemas in Swagger #3476
-
I am reading and doing all searches in the official documentation, in this github project and even in google, because I struggle about best practise when creating my docker-compose reading multiple schemas (I set up in the database and in the environment variables the schemas i want to read from), as described in here: https://postgrest.org/en/v12/references/api/schemas.html#multiple-schemas Environment
Description of issue
Works fine. so I guess main issue I got is displaying all schemas I want and enable in Swagger when I paste in my URL : localhost:8080 I see swagger when I paste in my URL: localhost:8080/table_test1b I get this error: when I paste in my URL: localhost:8080/public/table_test1 I got an empty string
========================================================= docker-compose.yaml
initdb/initidb.sql CREATE TABLE IF NOT EXISTS public.table_test1 (
id numeric PRIMARY KEY,
stringtest VARCHAR
);
INSERT INTO public.table_test1 (id, stringtest) VALUES
(1, 'Cheese'),
(2, 'Bread'),
(3, 'Milk');
CREATE SCHEMA IF NOT EXISTS public2.table_test1b (
id numeric PRIMARY KEY,
stringtest VARCHAR
)
INSERT INTO public2.table_test1b (id, stringtest) VALUES
(1, 'Butter'),
(2, 'Ham'),
(3, 'Toast');
-- ****************************************
-- create anonymous user for RESTAPI request - for SAMPLE request issue:
-- *****************************************
create role anon nologin;
--create user anon;
GRANT usage ON SCHEMA public TO anon;
GRANT usage ON SCHEMA public2 TO anon;
--grant select on api.todos to web_anon;
ALTER DEFAULT PRIVILEGES IN SCHEMA public2 GRANT SELECT ON TABLES TO anon;
GRANT SELECT ON ALL SEQUENCES IN SCHEMA public2 TO anon;
GRANT SELECT ON ALL TABLES IN SCHEMA public2 TO anon;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO anon;
GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO anon;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO anon;
create role authenticator noinherit login password 'mysecretpassword';
grant anon to authenticator;
ALTER ROLE authenticator SET pgrst.db_schemas = "public, public2";
After running I get this nice webapp at localhost:8080 It calls the db schema public, but not public2. so that what I though i should intervene at nginx level? to specify the ports? So at the end I could see in the same page all tables related to all the schemas I am enabled to access (switching the Schemas dropdown button to other names). Many thanks for this great work! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I'm converting this to a discussion, since the main issue is the same as this one: #1547 (btw, thanks for all the info/reproduction steps, they're useful for future testing).
Yes, this is the ideal scenario and the drop-down button for headers should include the Accept and Content-Profile headers in every request (#1547). We're working on it in the There's also the issue #2157, that you mentioned, which may change the need to use headers/Nginx but the design does not seem to be complete yet.
So to answer your questions, both options are good workarounds to the issue. It depends on how you want to handle your schemas. The only difference I see is that if you don't want to manage more than one PostgREST instance, or your design isn't meant to work that way, then the first solution should be better: adding both headers according to the schema path in Nginx. |
Beta Was this translation helpful? Give feedback.
I'm converting this to a discussion, since the main issue is the same as this one: #1547 (btw, thanks for all the info/reproduction steps, they're useful for future testing).
Yes, this is the ideal scenario and the drop-down button for headers should include the Accept and Content-Profile headers in every request (#1547). We're working on it in the
postgrest-openapi
project (but there's no ETA y…