fix: Detect default values for String types in OpenAPI output (#1928)
This commit is contained in:
@@ -425,6 +425,62 @@ spec actualPgVersion = describe "OpenAPI" $ do
|
||||
}
|
||||
|]
|
||||
|
||||
describe "Detects default values" $ do
|
||||
|
||||
it "text" $ do
|
||||
r <- simpleBody <$> get "/"
|
||||
|
||||
let defaultValue = r ^? key "definitions" . key "openapi_defaults" . key "properties" . key "text" . key "default"
|
||||
|
||||
liftIO $
|
||||
|
||||
defaultValue `shouldBe` Just "default"
|
||||
|
||||
it "boolean" $ do
|
||||
r <- simpleBody <$> get "/"
|
||||
|
||||
let types = r ^? key "definitions" . key "openapi_defaults" . key "properties" . key "boolean" . key "default"
|
||||
|
||||
liftIO $
|
||||
|
||||
types `shouldBe` Just (Bool False)
|
||||
|
||||
it "integer" $ do
|
||||
r <- simpleBody <$> get "/"
|
||||
|
||||
let types = r ^? key "definitions" . key "openapi_defaults" . key "properties" . key "integer" . key "default"
|
||||
|
||||
liftIO $
|
||||
|
||||
types `shouldBe` Just (Number 42)
|
||||
|
||||
it "numeric" $ do
|
||||
r <- simpleBody <$> get "/"
|
||||
|
||||
let types = r ^? key "definitions" . key "openapi_defaults" . key "properties" . key "numeric" . key "default"
|
||||
|
||||
liftIO $
|
||||
|
||||
types `shouldBe` Just (Number 42.2)
|
||||
|
||||
it "date" $ do
|
||||
r <- simpleBody <$> get "/"
|
||||
|
||||
let types = r ^? key "definitions" . key "openapi_defaults" . key "properties" . key "date" . key "default"
|
||||
|
||||
liftIO $
|
||||
|
||||
types `shouldBe` Just "1900-01-01"
|
||||
|
||||
it "time" $ do
|
||||
r <- simpleBody <$> get "/"
|
||||
|
||||
let types = r ^? key "definitions" . key "openapi_defaults" . key "properties" . key "time" . key "default"
|
||||
|
||||
liftIO $
|
||||
|
||||
types `shouldBe` Just "13:00:00"
|
||||
|
||||
describe "RPC" $ do
|
||||
|
||||
it "includes function summary/description and body schema for arguments" $ do
|
||||
|
||||
Vendored
+1
@@ -115,6 +115,7 @@ GRANT ALL ON TABLE
|
||||
, pgrst_reserved_chars
|
||||
, authors_w_entities
|
||||
, openapi_types
|
||||
, openapi_defaults
|
||||
, getallprojects_view
|
||||
, get_projects_above_view
|
||||
, web_content
|
||||
|
||||
Vendored
+9
@@ -1751,6 +1751,15 @@ CREATE TABLE test.openapi_types(
|
||||
"a_double_precision" double precision
|
||||
);
|
||||
|
||||
CREATE TABLE test.openapi_defaults(
|
||||
"text" text default 'default',
|
||||
"boolean" boolean default false,
|
||||
"integer" integer default 42,
|
||||
"numeric" numeric default 42.2,
|
||||
"date" date default '1900-01-01'::date,
|
||||
"time" time default '13:00:00'::time without time zone
|
||||
);
|
||||
|
||||
create function add_them(a integer, b integer)
|
||||
returns integer as $$
|
||||
select a + b;
|
||||
|
||||
Reference in New Issue
Block a user