Skip to content

Commit

Permalink
handler anyOf in items
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Gatto <[email protected]>
  • Loading branch information
outscale-mgo committed Oct 11, 2024
1 parent 7cf35c5 commit 5d398bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 0 additions & 2 deletions cognac_gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,6 @@ replace_args()
SDK_VERSION=$(cat sdk-version)
while IFS= read -r line
do
#check ____args____ here

arg_check=$(bin/line_check ____args____ ____func_code____ ____functions_proto____ ____cli_parser____ ____complex_struct_func_parser____ ____complex_struct_to_string_func____ ____call_list_dec____ ____call_list_descriptions____ ____call_list_args_descriptions____ <<< "$line")

if [ "$arg_check" == "____args____" ]; then
Expand Down
11 changes: 9 additions & 2 deletions helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ get_type_direct() {
local have_any_of=$?
if [ $have_any_of == 0 -a "$any_of" != 'null' ]; then
one_of="$any_of"
have_any_of=have_one_of
have_one_of=$have_any_of
fi
if [ $have_type == 0 -a "$types" != 'null' ]; then
if [ "$types" == 'integer' ]; then
Expand All @@ -34,8 +34,15 @@ get_type_direct() {
elif [ "$types" == 'array' ]; then
local item_one_off=$(jq -r .items.oneOf 2> /dev/null <<< $arg_info)
local item_is_one_of=$?
local item_any_of=$(jq -r .items.anyOf 2> /dev/null <<< $arg_info)
local item_have_any_of=$?
local sub_type=$(jq -r .items.type 2> /dev/null <<< $arg_info)
have_stype=$?
if [ $item_have_any_of == 0 -a "$item_any_of" != 'null' ]; then
local the_one=$(jq .[0] <<< $item_any_of)
sub_type=$(get_type_direct "$the_one")
have_stype=0
fi
if [ $item_is_one_of == 0 -a "$item_one_off" != 'null' ]; then
local the_one=$(jq .[0] <<< $item_one_off)
sub_type=$(get_type_direct "$the_one")
Expand Down Expand Up @@ -103,7 +110,7 @@ get_sub_type_description() {
return
fi
for p in $properties; do
local properties=$(json-search $p <<< $st_info)
local properties=$(jq .properties[\"$p\"] <<< $st_info)

local desc=$(jq .description <<< $properties)
local type=$(get_type_direct "$properties")
Expand Down

0 comments on commit 5d398bf

Please sign in to comment.