Add rebuild-doc-api util to regenerate swagger stuff

This commit is contained in:
Alexandre Aubin 2023-01-06 22:50:34 +01:00
parent 646e449995
commit 618d46aadb

28
ynh-dev
View file

@ -19,11 +19,13 @@ function show_usage() {
test [PKG] Deploy, update and run tests for some packages test [PKG] Deploy, update and run tests for some packages
Tests for single modules and functions can ran with Tests for single modules and functions can ran with
e.g. ./ynh-dev test yunohost/appurl:urlavailable e.g. ./ynh-dev test yunohost/appurl:urlavailable
catalog catalog
build Rebuild the custom catalog build Rebuild the custom catalog
add Add the custom catalog in Yunohost catalog list add Add the custom catalog in Yunohost catalog list
override Override default catalog with the custom catalog override Override default catalog with the custom catalog
reset Reset the catalog list to Yunohost's default reset Reset the catalog list to Yunohost's default
rebuild-api-doc Rebuild the API swagger doc
EOF EOF
} }
@ -49,6 +51,8 @@ function main()
catalog|--catalog) catalog $ARGUMENTS ;; catalog|--catalog) catalog $ARGUMENTS ;;
rebuild-api-doc|--rebuild-api-doc) rebuild_api_doc $ARGUMENTS ;;
*) critical "Unknown action ${ACTION}." ;; *) critical "Unknown action ${ACTION}." ;;
esac esac
} }
@ -526,4 +530,26 @@ function catalog()
esac esac
} }
function rebuild_api_doc()
{
test -d yunohost || critical "Expected to find a 'yunohost' folder ?"
cd yunohost/doc
if ! test -d swagger
then
# Download swagger ui
info "Downloading swagger UI"
curl -L https://github.com/swagger-api/swagger-ui/archive/refs/tags/v4.15.5.tar.gz | tar -xvz swagger-ui-4.15.5/dist/;
mv swagger-ui-4.15.5/dist/ swagger
rmdir swagger-ui-4.15.5
fi
info "Rebuild swagger json/js according to actionsmap"
python3 generate_api_doc.py
success "You should now open yunohost/doc/api.html using your favorite browser"
}
main $@ main $@