-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
OpenAPI description is missing the default value of postgres columns(?) #1871
Comments
Hello! I've checked, and the default value can be found in the {
"definitions": {
"t": {
"properties": {
"i": {
"default": 42,
"format": "integer",
"type": "integer"
}
},
"type": "object"
}
}
} Is this what you're looking for? If so, maybe the schema needed a reload before making the request again. |
Thanks. Sorry, that was my fault. |
Wait a second... CREATE TABLE pvz.newtable (
name text NOT NULL DEFAULT 'Sepp'::text,
anzahl int4 NULL DEFAULT 42,
rate float4 NULL DEFAULT 1.34,
isvalid bool NOT NULL DEFAULT true,
datum date NULL DEFAULT '1900-01-01'::date,
zeit time NULL DEFAULT '13:37:00'::time without time zone,
CONSTRAINT newtable_pk PRIMARY KEY (name)
);
... yields the following spec: "definitions": {
"newtable": {
"required": [
"name",
"isvalid",
"famstand"
],
"properties": {
"name": {
"format": "text",
"type": "string",
"description": "Note:\nThis is a Primary Key.<pk/>"
},
"anzahl": {
"default": 42,
"format": "integer",
"type": "integer"
},
"rate": {
"default": 1.34,
"format": "real",
"type": "number"
},
"isvalid": {
"default": true,
"format": "boolean",
"type": "boolean"
},
"datum": {
"format": "date",
"type": "string"
},
"zeit": {
"format": "time without time zone",
"type": "string"
}
},
"type": "object"
}, |
Any fixes or at least a confirmation of the problem here? |
@fjf2002 I was checking, and the schema cache shows the default value as: postgrest/src/PostgREST/OpenAPI.hs Lines 108 to 110 in 9568c46
Here, it's decoded, but it looks like it returns That would be a starting point to solve the issue, but for now we are mostly concentrating our efforts on the next v8 release. |
@laurenceisla thank you for your investigation. I'm afraid my haskell knowledge probably does not suffice to solve it on my own. Good luck on v8 release. |
I understand this is a bug then? |
Hello, great work! I'm currently getting to know postgrest, and considering it for my project as a slim "application server" replacement.
Environment
PostgreSQL version: docker image 13
PostgREST version: docker image v7.0.1
Operating system: ubuntu 20.04 on WSL2
Description of issue
Expected behavior vs actual behavior
When a postgres column has a default value, I would wish that the OpenAPI description reflects that (which currently does not seem to be the case?).
Steps to reproduce
CREATE TABLE t (i int DEFAULT 42)
See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.2.md : I would have expected the following:
The text was updated successfully, but these errors were encountered: