From bd286cf03a64ee5820adfeb24f4f12d598cdfc89 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Sat, 28 Oct 2023 08:17:39 +0200 Subject: [PATCH] feat(tool): Allow patching specs Signed-off-by: jld3103 --- .cspell/tools.txt | 1 + CONTRIBUTING.md | 7 ++++++- tool/generate-specs.sh | 11 +++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.cspell/tools.txt b/.cspell/tools.txt index fbe515cd..37cb3681 100644 --- a/.cspell/tools.txt +++ b/.cspell/tools.txt @@ -30,6 +30,7 @@ icudtl inkscape intellij jetbrains +jsonpatch jvmargs klass lcov diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0c67f962..0797d3b6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,11 +11,16 @@ Currently included are: To set up all these tools run the `./tool/setup.sh` script. Note that you need to have Dart installed and [`~/.pub-cache/bin/` needs to be in your PATH](https://dart.dev/tools/pub/cmd/pub-global#running-a-script-from-your-path) before running the script. -You will need to have the following packages installed: +You will need to have the following dependencies installed to get the app running: - [yq](https://github.com/kislyuk/yq) - [sqlite3](https://pub.dev/packages/sqflite_common_ffi#getting-started) - [appindicator3](https://pub.dev/packages/tray_manager#quick-start) +For working with lower levels like generating the OpenAPI specifications a few more dependencies are required: +- [jsonpatch](https://pypi.org/project/jsonpatch) +- [PHP](https://www.php.net) +- [composer](https://getcomposer.org) + ## Picking an issue You may wish to start with our list of [good first issues](https://github.com/nextcloud/neon/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) diff --git a/tool/generate-specs.sh b/tool/generate-specs.sh index 3680fea0..1bdfc4b5 100755 --- a/tool/generate-specs.sh +++ b/tool/generate-specs.sh @@ -50,6 +50,17 @@ done generate_spec "." "notifications" ) +for spec in packages/nextcloud/lib/src/api/*.openapi.json; do + name="$(basename "$spec" | cut -d "." -f 1)" + dir="packages/nextcloud/lib/src/patches/$name" + if [ -d "$dir" ]; then + for patch in "$dir/"*; do + cp "$spec" "/tmp/nextcloud-neon/$name.json" + jsonpatch --indent 4 "/tmp/nextcloud-neon/$name.json" "$patch" > "$spec" + done + fi +done + ( cd external/nextcloud-server composer exec merge-specs -- --core ../../packages/nextcloud/lib/src/api/core.openapi.json --merged /tmp/nextcloud-neon/merged.json ../../packages/nextcloud/lib/src/api/*.openapi.json --openapi-version 3.1.0