fix: json/jsonb columns should not have type "string" in OpenAPI spec (#2203)
* Switch to no type for json/jsonb
This commit is contained in:
+6
-4
@@ -883,17 +883,19 @@ def test_admin_live_dependent_on_main_app(defaultenv):
|
||||
response = postgrest.admin.get("/live")
|
||||
assert response.status_code == 503
|
||||
|
||||
|
||||
@pytest.mark.parametrize("specialhostvalue", FIXTURES["specialhostvalues"])
|
||||
def test_admin_works_with_host_special_values(specialhostvalue, defaultenv):
|
||||
"Should get a success from the admin live and ready endpoints when using special host values for the main app"
|
||||
|
||||
with run(env=defaultenv, port=freeport(), host=specialhostvalue) as postgrest:
|
||||
|
||||
response = postgrest.admin.get("/live")
|
||||
assert response.status_code == 200
|
||||
response = postgrest.admin.get("/live")
|
||||
assert response.status_code == 200
|
||||
|
||||
response = postgrest.admin.get("/ready")
|
||||
assert response.status_code == 200
|
||||
|
||||
response = postgrest.admin.get("/ready")
|
||||
assert response.status_code == 200
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"level, has_output",
|
||||
|
||||
@@ -430,6 +430,34 @@ spec actualPgVersion = describe "OpenAPI" $ do
|
||||
}
|
||||
|]
|
||||
|
||||
it "json to any" $ do
|
||||
r <- simpleBody <$> get "/"
|
||||
|
||||
let types = r ^? key "definitions" . key "openapi_types" . key "properties" . key "a_json"
|
||||
|
||||
liftIO $
|
||||
|
||||
types `shouldBe` Just
|
||||
[aesonQQ|
|
||||
{
|
||||
"format": "json"
|
||||
}
|
||||
|]
|
||||
|
||||
it "jsonb to any" $ do
|
||||
r <- simpleBody <$> get "/"
|
||||
|
||||
let types = r ^? key "definitions" . key "openapi_types" . key "properties" . key "a_jsonb"
|
||||
|
||||
liftIO $
|
||||
|
||||
types `shouldBe` Just
|
||||
[aesonQQ|
|
||||
{
|
||||
"format": "jsonb"
|
||||
}
|
||||
|]
|
||||
|
||||
describe "Detects default values" $ do
|
||||
|
||||
it "text" $ do
|
||||
@@ -548,12 +576,10 @@ spec actualPgVersion = describe "OpenAPI" $ do
|
||||
"type": "integer"
|
||||
},
|
||||
"json": {
|
||||
"format": "json",
|
||||
"type": "string"
|
||||
"format": "json"
|
||||
},
|
||||
"jsonb": {
|
||||
"format": "jsonb",
|
||||
"type": "string"
|
||||
"format": "jsonb"
|
||||
}
|
||||
},
|
||||
"type": "object",
|
||||
|
||||
Vendored
+3
-1
@@ -1807,7 +1807,9 @@ CREATE TABLE test.openapi_types(
|
||||
"a_bigint" bigint,
|
||||
"a_numeric" numeric,
|
||||
"a_real" real,
|
||||
"a_double_precision" double precision
|
||||
"a_double_precision" double precision,
|
||||
"a_json" json,
|
||||
"a_jsonb" jsonb
|
||||
);
|
||||
|
||||
CREATE TABLE test.openapi_defaults(
|
||||
|
||||
Reference in New Issue
Block a user