You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
I also did the curl to get
And I am about to modify the nginx config as suggested here or here
Or should I create a different container for each schema like mentioned [here] (#1106) or here?
Environment
PostgreSQL version: postgres/postgres:16.2
PostgREST version: postgrest/postgrest:v12.0.2
Operating system: Linux RedHat
Description of issue
I end up displaying one schema, not two, in swagger.
Curl calls to switch schemas usin Accept-Profile and Content-Profile headers works, but I cannot switch schemas in swagger:
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/tabletest1 I got the JSON string i want
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
Which one is the current recommended approach- the one that would work to display all schemas I enabled in swagger and via curl calls?
=========================================================
(Steps to reproduce: Include a minimal SQL definition plus how you make the request to PostgREST and the response body)
docker-compose.yaml
services:
##################
# postgresqldb #
##################
#
# PostgreSQL database
#
postgresqldb:
image: postgres
container_name: postgresqldb
ports:
- ${POSTGRES_PORT}
volumes:
- pgdata:/var/lib/postgresql/data
- ./initdb:/docker-entrypoint-initdb.d
environment:
- POSTGRES_DB
- POSTGRES_USER
- POSTGRES_PASSWORD
- PGPASSWORD
- POSTGRES_INITDB_ARGS
- DB_ANON_ROLE
- DB_SCHEMA
env_file:
- ./.env
networks:
- postgresqldb_network
- docknet
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $POSTGRES_USER -d $POSTGRES_DB"]
interval: 5s
timeout: 5s
retries: 5
#############
# postgREST #
#############
#
# Standalone web server that turns your PostgreSQL database directly into a RESTful API.
# https://postgrest.org/en/v12/references/configuration.html#config-full-list
#
postgrest:
container_name: postgrest
image: postgrest/postgrest
ports:
- ${PGRST_PORT}
# Available environment variables documented here:
# https://postgrest.org/en/latest/configuration.html#environment-variables
environment:
# The standard connection URI format, documented at
# https://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-CONNSTRING
# "postgres://app_user:password@localhost/postgres"
- PGRST_DB_URI=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_DB}:${POSTGRES_PORT}/${POSTGRES_DB}
- CI_COMMIT_REF_SLUG
- PGRST_ADDRESS
- PGRST_DB_URI=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_DB}:${POSTGRES_EXPOSED_PORT}/${POSTGRES_DB}
###############################################
- PGRST_DB_SCHEMA=public,public2 ############ ONLY TAKES THE FIRST IN THE LIST
###############################################
- PGRST_DB_ANON_ROLE=${DB_ANON_ROLE}
# Overrides the base URL used within the OpenAPI self-documentation hosted at the API root path. changed to 3001 because port 3000 is used in Watchlist
- PGRST_OPENAPI_SERVER_PROXY_URI=http://localhost:3000
- PGRST_DB_POOL=100
- PGRST_DB_POOL_ACQUISITION_TIMEOUT=10
- PGRST_JWT_SECRET=${TODO_SECRET}
#- PGRST_DB_ROOT_SPEC="root" # checkc if rewriteing OPENAI (https://postgrest.org/en/v12/references/api/openapi.html) !!! IN which files goes these steps from my dockerfile?
#command: postgrest ./postgrest_proxy/postgrest.conf # An alternative way to call postgrest variables. here we will use the ENVIRONMENT VARIABLES CALL
networks:
- postgresqldb_network
#- docknet
restart: always
healthcheck:
test: ["CMD-SHELL", "postgrest --help"]
interval: 5s
timeout: 5s
retries: 5
depends_on:
postgresqldb:
condition: service_healthy
##############
# swagger-ui #
##############
swagger-ui:
container_name: swagger-ui
image: swaggerapi/swagger-ui:latest
ports:
- "8080:8080"
expose:
- "8080"
environment:
- API_URL=http://localhost:3000/
restart: always
networks:
- postgresqldb_network
#- docknet
depends_on:
postgresqldb:
condition: service_healthy
volumes:
pgdata:
networks:
postgresqldb_network:
docknet:
name: docknet
initdb/initidb.sql
CREATETABLEIF NOT EXISTS public.table_test1 (
id numericPRIMARY KEY,
stringtest VARCHAR
);
INSERT INTOpublic.table_test1 (id, stringtest) VALUES
(1, 'Cheese'),
(2, 'Bread'),
(3, 'Milk');
CREATESCHEMAIF NOT EXISTS public2.table_test1b (
id numericPRIMARY KEY,
stringtest VARCHAR
)
INSERT INTOpublic2.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 GRANTSELECTON TABLES TO anon;
GRANTSELECTON ALL SEQUENCES IN SCHEMA public2 TO anon;
GRANTSELECTON ALL TABLES IN SCHEMA public2 TO anon;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANTSELECTON TABLES TO anon;
GRANTSELECTON ALL SEQUENCES IN SCHEMA public TO anon;
GRANTSELECTON ALL TABLES IN SCHEMA public TO anon;
create role authenticator noinherit login password 'mysecretpassword';
grant anon to authenticator;
ALTER ROLE authenticator SETpgrst.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!
The text was updated successfully, but these errors were encountered:
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
I also did the curl to get
And I am about to modify the nginx config as suggested here or here
Or should I create a different container for each schema like mentioned [here] (#1106) or here?
Environment
Description of issue
I end up displaying one schema, not two, in swagger.
Curl calls to switch schemas usin Accept-Profile and Content-Profile headers works, but I cannot switch schemas in swagger:
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/tabletest1 I got the JSON string i want
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
=========================================================
(Steps to reproduce: Include a minimal SQL definition plus how you make the request to PostgREST and the response body)
docker-compose.yaml
initdb/initidb.sql
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!
The text was updated successfully, but these errors were encountered: