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

26
ynh-dev
View file

@ -24,6 +24,8 @@ function show_usage() {
add Add the custom catalog in Yunohost catalog list
override Override default catalog with the custom catalog
reset Reset the catalog list to Yunohost's default
rebuild-api-doc Rebuild the API swagger doc
EOF
}
@ -49,6 +51,8 @@ function main()
catalog|--catalog) catalog $ARGUMENTS ;;
rebuild-api-doc|--rebuild-api-doc) rebuild_api_doc $ARGUMENTS ;;
*) critical "Unknown action ${ACTION}." ;;
esac
}
@ -526,4 +530,26 @@ function catalog()
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 $@