swaggerblueprint

Blueprint project for spring boot application with OpenApi Swagger docs
git clone git://git.wimdupont.com/swaggerblueprint.git
Log | Files | Refs | README | LICENSE

commit e21915da3005be4b214e7f16170212461466c6c5
parent f785774200199ff34fad1179edd3eea8cfd77489
Author: Wim Dupont <wim@wimdupont.com>
Date:   Sun, 19 Mar 2023 00:53:41 +0100

update playscript to copy id to clipboard

Diffstat:
Msrc/test/resources/play.sh | 22+++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/test/resources/play.sh b/src/test/resources/play.sh @@ -36,32 +36,44 @@ get_url () { echo "${base_url}" } +request= + case ${method^^} in GET) get_id if [ -z "${id}" ]; then - curl -X GET -sw '%{http_code}' "$(get_url)" | jq + request=$(curl -X GET -sw '%{http_code}' $(get_url)) else - curl -X GET -sw '%{http_code}' "$(get_url "/${id}")" | jq + request=$(curl -X GET -sw '%{http_code}' $(get_url "/${id}") | jq) fi ;; POST) - curl -X POST -sw '%{http_code}' "$(get_url)" -H 'Content-Type: application/json' -d '{"name":"Created John","number":120}' | jq + request=$(curl -X POST -sw '%{http_code}' $(get_url) -H 'Content-Type: application/json' -d '{"name":"Created John","number":120}' | jq) ;; PUT) get_id - curl -X PUT -sw '%{http_code}' "$(get_url "/${id}")" -H 'Content-Type: application/json' -d '{"name":null,"number":166}' | jq + request=$(curl -X PUT -sw '%{http_code}' $(get_url "/${id}") -H 'Content-Type: application/json' -d '{"name":"Updated John","number":166}' | jq) ;; DELETE) get_id - curl -k -X 'DELETE' -sw '%{http_code}' "$(get_url "/${id}")" | jq + request=$(curl -k -X 'DELETE' -sw '%{http_code}' $(get_url "/${id}") | jq) ;; *) echo "Unknown http method." ;; esac + +echo "${request}" +retrieved_id=$(echo "${request}" | jq "try .[0].id catch \"JQ_ERROR\"" | head -n 1 | tr -d \") + +if [ "${retrieved_id}" == "JQ_ERROR" ]; then + retrieved_id=$(echo "${request}" | jq "try .id catch \"JQ_ERROR\"" | head -n 1 | tr -d \") +fi + +echo "${retrieved_id}" | xclip +