From adc5884d7f72b7df262cec0ed1408c30637704e1 Mon Sep 17 00:00:00 2001 From: Emerson Rocha Date: Sat, 8 May 2021 11:32:09 -0300 Subject: [PATCH] openapi-generator (#6): openapi-exportandum.sh, melhorado template customizado --- .gitignore | 6 +- _config.yml | 17 ++- api/BR/portais-arcgis-brasil/por/index.html | 29 ----- api/BR/portais-ckan-brasil/por/index.html | 29 ----- api/UN/CODV2API/eng/index.html | 29 ----- api/UN/HDX/eng/index.html | 29 ----- eng.md | 13 ++- por.md | 12 +- systema/programma/openapi-exportandum.sh | 105 ++++-------------- .../programma/tmpl}/eng/index.html | 8 +- systema/programma/tmpl/por/index.html | 8 +- 11 files changed, 65 insertions(+), 220 deletions(-) delete mode 100644 api/BR/portais-arcgis-brasil/por/index.html delete mode 100644 api/BR/portais-ckan-brasil/por/index.html delete mode 100644 api/UN/CODV2API/eng/index.html delete mode 100644 api/UN/HDX/eng/index.html rename {api/BR/brazilian-ckan-portals => systema/programma/tmpl}/eng/index.html (71%) diff --git a/.gitignore b/.gitignore index f1631e1..fdd6346 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,8 @@ openapitools.json # api/BR/portais-ckan-brasil/por/html # openapi-generator-cli api/*/*/*/html -api/*/*/*/html2 \ No newline at end of file +api/*/*/*/html2 + +# Our custom index page per project per language +# @see systema/programma/openapi-exportandum.sh +api/*/*/*/index.html diff --git a/_config.yml b/_config.yml index b3a5874..4ed0185 100644 --- a/_config.yml +++ b/_config.yml @@ -19,4 +19,19 @@ twitter: # GitHub pages related # - https://docs.github.com/en/enterprise-server@3.0/pages/setting-up-a-github-pages-site-with-jekyll/about-github-pages-and-jekyll # - https://pages.github.com/versions/ -# - https://jekyllrb.com/docs/front-matter/ \ No newline at end of file +# - https://jekyllrb.com/docs/front-matter/ + +# @see https://github.com/jekyll/jekyll-sitemap +url: "https://hapi.etica.ai" # the base hostname & protocol for your site +plugins: + - jekyll-sitemap + +defaults: + - scope: + path: "api/*/*/*/html" + values: + sitemap: false + - scope: + path: "api/*/*/*/html2" + values: + sitemap: false diff --git a/api/BR/portais-arcgis-brasil/por/index.html b/api/BR/portais-arcgis-brasil/por/index.html deleted file mode 100644 index ef093da..0000000 --- a/api/BR/portais-arcgis-brasil/por/index.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - -
- - - \ No newline at end of file diff --git a/api/BR/portais-ckan-brasil/por/index.html b/api/BR/portais-ckan-brasil/por/index.html deleted file mode 100644 index ef093da..0000000 --- a/api/BR/portais-ckan-brasil/por/index.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - -
- - - \ No newline at end of file diff --git a/api/UN/CODV2API/eng/index.html b/api/UN/CODV2API/eng/index.html deleted file mode 100644 index 475c6d6..0000000 --- a/api/UN/CODV2API/eng/index.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - -
- - - \ No newline at end of file diff --git a/api/UN/HDX/eng/index.html b/api/UN/HDX/eng/index.html deleted file mode 100644 index 475c6d6..0000000 --- a/api/UN/HDX/eng/index.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - -
- - - \ No newline at end of file diff --git a/eng.md b/eng.md index f57eb64..f34b3b4 100644 --- a/eng.md +++ b/eng.md @@ -49,22 +49,22 @@ open industry standard to document REST APIs.** #### HDX - The Humanitarian Data Exchange ##### HDX-eng +- **Preview/Execute**: - **OpenAPI File**: [api/UN/HDX/eng/openapi.yaml](api/UN/HDX/eng/openapi.yaml) -- **Preview/Execute**: #### CODV2API ##### CODV2API-eng +- **Preview/Execute**: - **OpenAPI File**: [api/UN/CODV2API/eng/openapi.yaml](api/UN/CODV2API/eng/openapi.yaml) -- **Preview/Execute**: ### XZ #### HXL-Proxy - Humanitarian Exchange Language Proxy ##### HXL-Proxy +- **Preview/Execute**: - **OpenAPI File**: [api/XZ/HXL-Proxy/eng/openapi.yaml](api/XZ/HXL-Proxy/eng/openapi.yaml) -- **Preview/Execute**: ### BR @@ -72,18 +72,19 @@ open industry standard to document REST APIs.** ##### portais-ckan-brasil-por +- **Preview/Execute**: - **OpenAPI File**: [api/BR/portais-ckan-brasil/por/openapi.yaml](api/BR/portais-ckan-brasil/por/openapi.yaml) -- **Preview/Execute**: ##### portais-arcgis-brasil-por +- **Preview/Execute**: - **OpenAPI File**: [api/BR/portais-arcgis-brasil/por/openapi.yaml](api/BR/portais-arcgis-brasil/por/openapi.yaml) -- **Preview/Execute**: + ##### brazilian-ckan-portals-eng +- **Preview/Execute**: - **OpenAPI File**: [api/BR/brazilian-ckan-portals/eng/openapi.yaml](api/BR/brazilian-ckan-portals/eng/openapi.yaml) -- **Preview/Execute**: ## Schema diff --git a/por.md b/por.md index db0334a..a5bfcc0 100644 --- a/por.md +++ b/por.md @@ -46,22 +46,22 @@ documentar APIs REST.** #### HDX - The Humanitarian Data Exchange ##### HDX-eng +- **Pré-visualizar/executar online**: - **Arquivo OpenAPI**: [api/UN/HDX/eng/openapi.yaml](api/UN/HDX/eng/openapi.yaml) -- **Pré-visualizar/executar online**: #### CODV2API ##### CODV2API-eng +- **Pré-visualizar/executar online**: - **Arquivo OpenAPI**: [api/UN/CODV2API/eng/openapi.yaml](api/UN/CODV2API/eng/openapi.yaml) -- **Pré-visualizar/executar online**: ### XZ #### HXL-Proxy - Proxy da Linguagem de Intercâmbio Humanitária ##### HXL-Proxy +- **Pré-visualizar/executar online**: - **Arquivo OpenAPI**: [api/XZ/HXL-Proxy/eng/openapi.yaml](api/XZ/HXL-Proxy/eng/openapi.yaml) -- **Pré-visualizar/executar online**: ### BR @@ -69,18 +69,18 @@ documentar APIs REST.** ##### brazilian-ckan-portals-eng +- **Pré-visualizar/executar online**: - **Arquivo OpenAPI**: [api/BR/brazilian-ckan-portals/eng/openapi.yaml](api/BR/brazilian-ckan-portals/eng/openapi.yaml) -- **Pré-visualizar/executar online**: ##### portais-ckan-brasil-por +- **Pré-visualizar/executar online**: - **Arquivo OpenAPI**: [api/BR/portais-ckan-brasil/por/openapi.yaml](api/BR/portais-ckan-brasil/por/openapi.yaml) -- **Pré-visualizar/executar online**: ##### portais-arcgis-brasil-por +- **Pré-visualizar/executar online**: - **Arquivo OpenAPI**: [api/BR/portais-arcgis-brasil/por/openapi.yaml](api/BR/portais-arcgis-brasil/por/openapi.yaml) -- **Pré-visualizar/executar online**: ## Schema diff --git a/systema/programma/openapi-exportandum.sh b/systema/programma/openapi-exportandum.sh index eefb293..9897372 100755 --- a/systema/programma/openapi-exportandum.sh +++ b/systema/programma/openapi-exportandum.sh @@ -59,11 +59,19 @@ OPENAPI_EXPORTANDUM=( 'html2' ) + +# Git user ID, e.g. openapitools. +OPENAPI_GIT_USER_ID="HXL-CPLP" +# Git repo ID, e.g. openapi-generator. +OPENAPI_GIT_REPO_ID="Auxilium-Humanitarium-API" + + #### CUSTOMIZATIONS, end _______________________________________________________ # Trivia: 'errōrem', https://en.wiktionary.org/wiki/error#Latin ERROREM=0 + # @see https://stackoverflow.com/questions/4332478 # /read-the-current-text-color-in-a-xterm/4332530#4332530 # BLACK=$(tput setaf 0) @@ -73,7 +81,7 @@ RED=$(tput setaf 1) # LIME_YELLOW=$(tput setaf 190) # POWDER_BLUE=$(tput setaf 153) # BLUE=$(tput setaf 4) -# MAGENTA=$(tput setaf 5) +MAGENTA=$(tput setaf 5) CYAN=$(tput setaf 6) # WHITE=$(tput setaf 7) BRIGHT=$(tput bold) @@ -82,20 +90,8 @@ NORMAL=$(tput sgr0) # REVERSE=$(tput smso) # UNDERLINE=$(tput smul) -# Split -# Author: https://stackoverflow.com/questions/918886 -# /how-do-i-split-a-string-on-a-delimiter-in-bash/44153302#44153302 -split() { - local string="$1" - local delimiter="$2" - if [ -n "$string" ]; then - local part - while read -r -d "$delimiter" part; do - echo "$part" - done <<< "$string" - echo "$part" - fi -} +PATHSCRIPT=$(dirname "$(readlink -f "$0")") +TMPL="${PATHSCRIPT}/tmpl" for oas_meta in "${OPENAPI_RADICEM[@]}" do @@ -108,68 +104,16 @@ do printf '\n%s%sopenapi-exportandum.sh: %s %s\n' \ "$BRIGHT" "$CYAN" "$oas_radix" "$NORMAL" - # https://stackoverflow.com/questions/918886 - # /how-do-i-split-a-string-on-a-delimiter-in-bash - # oas_meta_split="(${oas_meta//;/ })" - # IFS='|'; oas_meta_split=("$oas_meta"); unset IFS; - # oas_meta='api/BR/brazilian-ckan-portals/eng eng' - # A=$(echo "$oas_meta" | awk -F: "{print $1}") - # B=$(echo "$oas_meta" | awk -F: "{print $2}") - # B=$(echo one_two_three_four_five | awk -F_ '{print $2}') - # C=$(echo one_two_three_four_five | awk -F_ '{print $3}') - # $(echo "$oas_meta" | cut -f1 | read str1) - # $(echo "$oas_meta" | cut -f2 | read str2) - # echo $str1 - # echo $str2 - # echo $C - # echo $D - - # var1=$(echo "bla@some.com;john@home.com" | cut -d ";" -f 1) - # echo "$var1" - - # echo 'ooi' - - # string='one_two_three_four_five' - # IFS='_' read -r a second a fourth a <<<"$string" - # echo "$second $fourth" - - # string='oas_meta' - # IFS='|' read -r a second a fourth a <<<"$oas_meta" - # echo "$a $second" - - # # arr=(`echo $IN | tr ';' ' '`) - # IN="bla@some.com;john@home.com" - # IN="bla@some.com;john@home.com" - # read -r ADDR1 ADDR2 <<<$(IFS=';'; echo $IN) - # # read -r ADDR1 ADDR2 <<<$(IFS='|'; echo $oas_meta) - # echo $oas_meta - # echo $ADDR1 - # echo $ADDR2 - # echo "fin" - # exit 1 - - # oas_radix="${oas_meta_split[0]}" - - # For each exporter + ### For each openapi-generator-cli exporter for oas_exporto in "${OPENAPI_EXPORTANDUM[@]}" do oas_exporto_radix="${oas_radix}/${oas_exporto}" printf '\n%s%s openapi-exportandum.sh: %s/%s %s\n' \ "$BRIGHT" "$CYAN" "$oas_radix" "$oas_exporto" "$NORMAL" - # echo $oas_exporto_radix - - # # printf '\t\t%s%s%s%s\n\n' "$GREEN" "$BLINK" "$oas_filum" "$NORMAL" - # printf '\n%s%sopenapi-validum.sh: %s validum? %s\n' \ - # "$BRIGHT" "$CYAN" "$oas_filum" "$NORMAL" - # # echo ">>> $oas_filum\n\n\n" - # if ! openapi-generator-cli validate --input-spec "$oas_filum"; then - # printf '\n%s%sopenapi-validum.sh: %s validum? %s\n' \ - # "$BRIGHT" "$RED" "$oas_filum" "$NORMAL" - # # printf '\t\t%s%s%s%s\n\n' "$RED" "$BLINK" "$oas_filum" "$NORMAL" - # ERROREM=$((ERROREM + 1)) - # fi - if ! openapi-generator-cli generate \ + if ! openapi-generator-cli generate --minimal-update \ + --git-user-id "${OPENAPI_GIT_USER_ID}" \ + --git-repo-id "${OPENAPI_GIT_REPO_ID}" \ --generator-name "$oas_exporto" \ --input-spec "$oas_filum" \ --output "$oas_exporto_radix" ; then @@ -180,20 +124,13 @@ do fi done - # Create new index file - # echo - + ### Our custom index page per project per language + printf '\n%s%sopenapi-exportandum.sh: %s/index.html custom index %s\n' \ + "$BRIGHT" "$MAGENTA" "$oas_radix" "$NORMAL" + cp "${TMPL}/${linguam_iso6393}/index.html" "$oas_radix/index.html" + # echo "${TMPL}/${linguam_iso6393}/index.html" + # echo "$oas_radix/index.html" - # # printf '\t\t%s%s%s%s\n\n' "$GREEN" "$BLINK" "$oas_filum" "$NORMAL" - # printf '\n%s%sopenapi-validum.sh: %s validum? %s\n' \ - # "$BRIGHT" "$CYAN" "$oas_filum" "$NORMAL" - # # echo ">>> $oas_filum\n\n\n" - # if ! openapi-generator-cli validate --input-spec "$oas_filum"; then - # printf '\n%s%sopenapi-validum.sh: %s validum? %s\n' \ - # "$BRIGHT" "$RED" "$oas_filum" "$NORMAL" - # # printf '\t\t%s%s%s%s\n\n' "$RED" "$BLINK" "$oas_filum" "$NORMAL" - # ERROREM=$((ERROREM + 1)) - # fi done if [ "$ERROREM" != 0 ]; then diff --git a/api/BR/brazilian-ckan-portals/eng/index.html b/systema/programma/tmpl/eng/index.html similarity index 71% rename from api/BR/brazilian-ckan-portals/eng/index.html rename to systema/programma/tmpl/eng/index.html index 475c6d6..011eee5 100644 --- a/api/BR/brazilian-ckan-portals/eng/index.html +++ b/systema/programma/tmpl/eng/index.html @@ -1,10 +1,8 @@ - + +