From 3a0272a600b66e7a3aefbbae5adb8c39fa82af50 Mon Sep 17 00:00:00 2001 From: Maciej Niemcewicz Date: Tue, 2 Jan 2024 14:24:20 +0100 Subject: [PATCH 1/4] add script that checks for snippets that arent excluded from search --- .github/check-excluded-snippets.sh | 21 +++++++++++++++++++++ .github/workflows/snippet-check.yml | 15 +++++++++++++++ 2 files changed, 36 insertions(+) create mode 100755 .github/check-excluded-snippets.sh create mode 100644 .github/workflows/snippet-check.yml diff --git a/.github/check-excluded-snippets.sh b/.github/check-excluded-snippets.sh new file mode 100755 index 00000000..91472286 --- /dev/null +++ b/.github/check-excluded-snippets.sh @@ -0,0 +1,21 @@ +#!/bin/bash +filelist=$(find ./docs -type f -name "*.md") +pattern='```' + + +for file in $filelist +do + echo $file + for line in $(grep -Fn $pattern $file | sed -e's/:.*//' | sed -n 'n;p') + do + if ! [[ $(awk "NR==$line+1" $file) == *"{ data-search-exclude }"* ]]; then + echo "Snippet in line $line in file $file is not excluded from search" >> status.txt + fi + done +done + +if [ -s "status.txt" ] || [ -f "status.txt" ] ;then + cat status.txt + exit 7 +fi + diff --git a/.github/workflows/snippet-check.yml b/.github/workflows/snippet-check.yml new file mode 100644 index 00000000..c97fc41a --- /dev/null +++ b/.github/workflows/snippet-check.yml @@ -0,0 +1,15 @@ +name: Snippet check script +# Controls when the action will run. Triggers the workflow on push +# events but only for the master branch +on: + pull_request + + +jobs: + build: + runs-on: ubuntu-latest # The type of runner that the job will run on + steps: # Steps represent a sequence of tasks that will be executed as part of the job + - name: Check out the repository + uses: actions/checkout@v2 + - name: Run the script + run: .github/check-excluded-snippets.sh From c602cf2279d328b9d65470843b6facd643629b7e Mon Sep 17 00:00:00 2001 From: Maciej Niemcewicz Date: Tue, 2 Jan 2024 14:31:21 +0100 Subject: [PATCH 2/4] remove echo and fix few snippets --- .github/check-excluded-snippets.sh | 1 - docs/API/open-api-schema.md | 5 ++++- docs/API/search.md | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/check-excluded-snippets.sh b/.github/check-excluded-snippets.sh index 91472286..18bfed72 100755 --- a/.github/check-excluded-snippets.sh +++ b/.github/check-excluded-snippets.sh @@ -5,7 +5,6 @@ pattern='```' for file in $filelist do - echo $file for line in $(grep -Fn $pattern $file | sed -e's/:.*//' | sed -n 'n;p') do if ! [[ $(awk "NR==$line+1" $file) == *"{ data-search-exclude }"* ]]; then diff --git a/docs/API/open-api-schema.md b/docs/API/open-api-schema.md index 14440cb8..81eefbac 100644 --- a/docs/API/open-api-schema.md +++ b/docs/API/open-api-schema.md @@ -24,6 +24,7 @@ curl -X GET "https://api.flotiq.com/api/v1/open-api-schema.json" \ -H 'X-AUTH-TOKEN: YOUR_API_KEY' \ -H 'Content-Type: application/json' ``` +{ data-search-exclude } Possible request parameters: @@ -51,6 +52,7 @@ as not all tools can handle the whole Open API Schema format. -H 'X-AUTH-TOKEN: YOUR_API_KEY' \ -H 'Content-Type: application/json' ``` + { data-search-exclude } Response ``` @@ -3346,7 +3348,8 @@ as not all tools can handle the whole Open API Schema format. -H 'X-AUTH-TOKEN: YOUR_API_KEY' \ -H 'Content-Type: application/json' ``` - + { data-search-exclude } + Response ``` diff --git a/docs/API/search.md b/docs/API/search.md index 77bb4631..7f6dcd08 100644 --- a/docs/API/search.md +++ b/docs/API/search.md @@ -29,7 +29,7 @@ Request: ``` GET https://api.flotiq.com/api/v1/search?q=Flotiq&content_type[]=post ``` - +{ data-search-exclude } Response: ```json From a03575cdea446797617ded8ff3adfbb967264834 Mon Sep 17 00:00:00 2001 From: Maciej Niemcewicz Date: Tue, 2 Jan 2024 14:52:44 +0100 Subject: [PATCH 3/4] fix script for additional line, fix snippet excludes --- .github/check-excluded-snippets.sh | 3 ++- docs/API/content-type/creating-co.md | 2 ++ docs/API/content-type/updating-co.md | 2 ++ docs/API/generate-package.md | 2 ++ docs/API/generate-package/sdk-nodejs.md | 4 ++++ docs/API/open-api-schema.md | 6 ++++-- 6 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/check-excluded-snippets.sh b/.github/check-excluded-snippets.sh index 18bfed72..6b6e01b6 100755 --- a/.github/check-excluded-snippets.sh +++ b/.github/check-excluded-snippets.sh @@ -5,9 +5,10 @@ pattern='```' for file in $filelist do + for line in $(grep -Fn $pattern $file | sed -e's/:.*//' | sed -n 'n;p') do - if ! [[ $(awk "NR==$line+1" $file) == *"{ data-search-exclude }"* ]]; then + if ! [[ $(awk "NR==$line+1" $file) == *"{ data-search-exclude }"* || $(awk "NR==$line+2" $file) == *"{ data-search-exclude }"* ]]; then echo "Snippet in line $line in file $file is not excluded from search" >> status.txt fi done diff --git a/docs/API/content-type/creating-co.md b/docs/API/content-type/creating-co.md index 29100895..a8f6eeb2 100644 --- a/docs/API/content-type/creating-co.md +++ b/docs/API/content-type/creating-co.md @@ -27,6 +27,8 @@ to the supporting endpoint `https://api.flotiq.com/api/v1/content/{name}` "postContent": "This will be the new content" } ``` +{ data-search-exclude } + !!! note The maximum size of a single CO in the system is 1MB. If your project requires a larger CO size, please contact Flotiq support. diff --git a/docs/API/content-type/updating-co.md b/docs/API/content-type/updating-co.md index 8713550b..3bfd7893 100644 --- a/docs/API/content-type/updating-co.md +++ b/docs/API/content-type/updating-co.md @@ -32,6 +32,8 @@ to the supporting endpoint `https://api.flotiq.com/api/v1/content/{name}/{id}` t "postContent": "This will be the new content" } ``` +{ data-search-exclude } + * `name` is the name of the content type definition * `id` is the ID of the object to update diff --git a/docs/API/generate-package.md b/docs/API/generate-package.md index fe3f884b..099d8a91 100644 --- a/docs/API/generate-package.md +++ b/docs/API/generate-package.md @@ -31,6 +31,7 @@ Flotiq always provides your up-to-date API definition in an OpenAPI 3.0 compatib ``` shell npm install @openapitools/openapi-generator-cli@cli-4.2.3 -g ``` +{ data-search-exclude } This will instal the OpenAPI generator that will allow you to generate more packages. List of supported generators is mentioned [here](https://openapi-generator.tech/docs/generators) @@ -38,6 +39,7 @@ This will instal the OpenAPI generator that will allow you to generate more pack ``` openapi-generator generate -g -i --skip-validate-spec -o ``` +{ data-search-exclude } Parameters description: diff --git a/docs/API/generate-package/sdk-nodejs.md b/docs/API/generate-package/sdk-nodejs.md index 3fbbb352..bbfee816 100644 --- a/docs/API/generate-package/sdk-nodejs.md +++ b/docs/API/generate-package/sdk-nodejs.md @@ -84,21 +84,25 @@ by changing into the directory containing package.json (and this README). Let's ```shell npm install ``` +{ data-search-exclude } Next, link it globally in npm with the following, also from JAVASCRIPT_CLIENT_DIR: ```shell npm link ``` +{ data-search-exclude } To use the link you just defined in your project, switch to the directory you want to use your flotiq_user_api from, and run: ```shell npm link /path/to/ ``` +{ data-search-exclude } Finally, you need to build the module: ``` npm run build ``` +{ data-search-exclude } \ No newline at end of file diff --git a/docs/API/open-api-schema.md b/docs/API/open-api-schema.md index 81eefbac..2478d6de 100644 --- a/docs/API/open-api-schema.md +++ b/docs/API/open-api-schema.md @@ -3349,7 +3349,7 @@ as not all tools can handle the whole Open API Schema format. -H 'Content-Type: application/json' ``` { data-search-exclude } - + Response ``` @@ -4427,6 +4427,7 @@ as not all tools can handle the whole Open API Schema format. -H 'X-AUTH-TOKEN: YOUR_API_KEY' \ -H 'Content-Type: application/json' ``` + { data-search-exclude } Response ``` @@ -7290,7 +7291,8 @@ as not all tools can handle the whole Open API Schema format. -H 'X-AUTH-TOKEN: YOUR_API_KEY' \ -H 'Content-Type: application/json' ``` - + { data-search-exclude } + Response ``` { From 2c3308f1b2afdcd3e76cadac5046277c18952fbe Mon Sep 17 00:00:00 2001 From: Maciej Niemcewicz Date: Tue, 2 Jan 2024 14:59:45 +0100 Subject: [PATCH 4/4] add echo when scripts finishes successfully --- .github/check-excluded-snippets.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/check-excluded-snippets.sh b/.github/check-excluded-snippets.sh index 6b6e01b6..47b2a2b8 100755 --- a/.github/check-excluded-snippets.sh +++ b/.github/check-excluded-snippets.sh @@ -17,5 +17,7 @@ done if [ -s "status.txt" ] || [ -f "status.txt" ] ;then cat status.txt exit 7 +else + echo "Every snippet has been excluded from search results" fi