Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swagger corrupted when table name contains '/' => v1/mytable #3771

Open
rv2931 opened this issue Nov 7, 2024 · 4 comments
Open

Swagger corrupted when table name contains '/' => v1/mytable #3771

rv2931 opened this issue Nov 7, 2024 · 4 comments
Labels

Comments

@rv2931
Copy link

rv2931 commented Nov 7, 2024

Environment

  • PostgreSQL version: 10
  • PostgREST version: 12.
  • Operating system: Windows/Docker/Podman

Description of issue

I was trying to manage API versions by using a unique schema but prefixing version in my table names like "v1/mytable"

CREATE TABLE my_schema."v1/my_endpoint_table" (
	id serial4 NOT NULL, -- unique identifier
	uuid varchar NOT NULL, -- natural key
	label varchar NULL, -- label
	CONSTRAINT my_endpoint_table_pk PRIMARY KEY (id),
	CONSTRAINT my_endpoint_table_unique UNIQUE (uuid)
);
COMMENT ON TABLE "v1/my_endpoint_table" IS 'My table';

This throw no errors in Postgres Side, neither in PostGREST or swagger but after taking a look closer as soon as you expand the Swagger Ui section, Swagger show errors at the begining of the web page

Errors
Resolver error at paths./v1/my_endpoint_table.get.parameters.0.$ref
Could not resolve reference: Could not resolve pointer: /parameters/rowFilter.v1/my_endpoint_table.id does not exist in document

The same for each table column

I found that some information is missing too by comparing both swagger Ui file with or without "/" in table name just by renaming mytable and restartint swagger ui container

  • all "summary" fileds in JSON "path"/"get"|"post"|"delete"|"patch" sections are missing in the swagger Ui difinition of the table with "/" in its name

As soon as Postgres allow table name with "/", PostgRest should manage it correctly

@wolfgangwalther
Copy link
Member

Ah, that's a nice observation, which I consider a feature (for us, nonetheless), not a bug.

This is because when we know / can't be used properly in names right now, we are not going to break existing setups when we do something similar to #1086 or #2166.

@rv2931
Copy link
Author

rv2931 commented Nov 7, 2024

version management could be a very nice feature, by allowing/managing table names with '/' is it is question here or via another way to customize url in some way.

@rv2931
Copy link
Author

rv2931 commented Nov 7, 2024

But for the moment it's a bug :)

@rv2931
Copy link
Author

rv2931 commented Nov 7, 2024

And if done something on that, maybe try all kind of version syntax or all caracters allowed by postgresql schema/table names
v1
v1.0
v1.0~build
v1.0#patch
and so on with all special caracters $%^<>...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants