-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add paths with get requests for tables WIP
- Loading branch information
1 parent
315e9fb
commit 43092d3
Showing
3 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
-- Functions to build the Paths Object of the OAS document | ||
|
||
create or replace function oas_build_paths( | ||
path_name text, | ||
path_item_object jsonb, | ||
schemas text[] | ||
) | ||
returns jsonb language sql as | ||
$$ | ||
select json_build_object( | ||
'/' || path_name, path_item_object | ||
) | ||
$$; | ||
|
||
create or replace function oas_build_path_items_from_tables(schemas text[]) | ||
returns jsonb language sql as | ||
$$ | ||
select jsonb_object_agg(x.path, x.oas_path_item) | ||
from ( | ||
select '/' || table_name as path, | ||
oas_path_item_object( | ||
description := table_description, | ||
get :=oas_operation_object( | ||
parameters := jsonb_build_array( | ||
oas_build_reference_to_parameters('') | ||
) | ||
) | ||
) as oas_path_item | ||
from postgrest_get_all_tables(schemas) | ||
where table_schema = any(schemas) | ||
) x; | ||
$$; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters