Skip to content

Commit b2a4cc6

Browse files
committed
PROVCON-4978 - removed "type" from portal_product_toc_markdown_patch
PROVCON-4978 - added extra "if" statement to handle missing "source" property
1 parent b312217 commit b2a4cc6

1 file changed

Lines changed: 25 additions & 19 deletions

File tree

docs/scripts/publish-portal-content.sh

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ function portal_product_toc_markdown_upsert() {
687687
portal_product_toc_markdown_post "$section_id" "$markdown_title" "$markdown_slug" "$content_order" "$parent_toc_id" "$type" "$source"
688688
else
689689
log_message $INFO "Patching markdown TOC: $section_id, $product_toc_id, $markdown_title, $markdown_slug, $content_order, $parent_toc_id"
690-
portal_product_toc_markdown_patch "$section_id" "$product_toc_id" "$markdown_title" "$markdown_slug" "$content_order" "$product_toc_slug" "$parent_toc_id" "$type"
690+
portal_product_toc_markdown_patch "$section_id" "$product_toc_id" "$markdown_title" "$markdown_slug" "$content_order" "$product_toc_slug" "$parent_toc_id"
691691
fi
692692

693693
log_message $DEBUG "Returning document_id: $document_id"
@@ -738,7 +738,6 @@ function portal_product_toc_markdown_patch() {
738738
local content_order=$5
739739
local product_toc_slug=$6
740740
local parent_toc_id=$7
741-
local type=$8
742741

743742
log_message $INFO "Updating markdown TOC: $markdown_title in product $product_id with parent $parent_toc_id ..."
744743
if [ "$markdown_slug" == "$product_toc_slug" ]; then
@@ -750,10 +749,7 @@ function portal_product_toc_markdown_patch() {
750749
--data "{
751750
\"title\": \"$markdown_title\",
752751
\"order\": $content_order,
753-
\"parentId\": \"$parent_toc_id\",
754-
\"content\": {
755-
\"type\": \"$type\"
756-
}
752+
\"parentId\": \"$parent_toc_id\"
757753
}")
758754
else
759755
local response=$(curl -s --request PATCH \
@@ -764,10 +760,7 @@ function portal_product_toc_markdown_patch() {
764760
\"title\": \"$markdown_title\",
765761
\"slug\": \"$markdown_slug\",
766762
\"order\": $content_order,
767-
\"parentId\": \"$parent_toc_id\",
768-
\"content\": {
769-
\"type\": \"$type\"
770-
}
763+
\"parentId\": \"$parent_toc_id\"
771764
}")
772765
fi
773766

@@ -791,19 +784,32 @@ function portal_product_document_markdown_patch() {
791784
log_message $DEBUG "Enter portal_product_document_markdown_patch"
792785
local contents=$1
793786
local type=$2
787+
local source=$3
794788

795789
log_message $INFO "Updating markdown document in product $product_id for document $document_id..."
796790
local escaped_contents=$(jq -Rs . <<< "$contents")
797791

798-
local response=$(curl -s --request PATCH \
799-
--url "$PORTAL_URL/documents/$document_id" \
800-
--header "Authorization: Bearer $SWAGGERHUB_API_KEY" \
801-
--header "Content-Type: application/json" \
802-
--data "{
803-
\"content\": $escaped_contents,
804-
\"type\": \"$type\",
805-
\"source\": \"$source\"
806-
}")
792+
if [ "$source" == null ] || [ "$source" == "" ]; then
793+
local response=$(curl -s --request PATCH \
794+
--url "$PORTAL_URL/documents/$document_id" \
795+
--header "Authorization: Bearer $SWAGGERHUB_API_KEY" \
796+
--header "Content-Type: application/json" \
797+
--data "{
798+
\"content\": $escaped_contents,
799+
\"type\": \"$type\",
800+
}")
801+
else
802+
local response=$(curl -s --request PATCH \
803+
--url "$PORTAL_URL/documents/$document_id" \
804+
--header "Authorization: Bearer $SWAGGERHUB_API_KEY" \
805+
--header "Content-Type: application/json" \
806+
--data "{
807+
\"content\": $escaped_contents,
808+
\"type\": \"$type\",
809+
\"source\": \"$source\"
810+
}")
811+
fi
812+
807813

808814
log_message $DEBUG "Document patch response: $response"
809815
log_message $INFO "Done updating $type document."

0 commit comments

Comments
 (0)