Skip to content

Commit

Permalink
fix: Generate Api portal client in code review & deploy (#517) (#519)
Browse files Browse the repository at this point in the history
Co-authored-by: Jacopo Carlini <jacopo.carlini@gmail.com>
  • Loading branch information
svariant and jacopocarlini authored May 29, 2024
1 parent 1f4cfa2 commit 2895df0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/ci_code_review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ jobs:


yarn install
yarn generate
if [ "${{ github.base_ref }}" = "main" ]; then
yarn run generate:api-portal
else
yarn run generate:api-portal-next
fi
yarn build
mkdir ./out
mv ./build ./out/ui
Expand Down Expand Up @@ -143,7 +147,11 @@ jobs:
- name: Unit Tests
run: |
yarn install
yarn generate
if [ "${{ github.base_ref }}" = "main" ]; then
yarn run generate:api-portal
else
yarn run generate:api-portal-next
fi
yarn test:coverage --watchAll=false
- name: SonarCloud Scan
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/deploy_on_cdn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ jobs:
fi
yarn install
yarn generate
if [ "${{ inputs.environment }}" = "dev" ]; then
yarn run generate:api-portal-next
else
yarn run generate:api-portal
fi
yarn build
- name: Login
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
"lint-autofix": "eslint . -c .eslintrc.js --ext .ts,.tsx --fix",
"lint": "eslint . -c .eslintrc.js --ext .ts,.tsx ",
"prettify": "prettier --write \"./**/*.{ts,tsx}\"",
"generate": "npm-run-all generate:*",
"generate": "npm run generate:api-portal",
"clean:api-portal": "rimraf src/api/generated/portal && rimraf openApi/generated",
"generate:api-portal": "wget https://raw.githubusercontent.com/pagopa/pagopa-selfcare-ms-backoffice-backend/main/openapi/openapi.json -O ./openApi/portal-api-docs.json && jq 'walk(if type == \"object\" and has(\"parameters\") then .parameters |= map(select(.name != \"X-Request-Id\")) else . end)' ./openApi/portal-api-docs.json > ./openApi/portal-api-docs.json.temp && mv ./openApi/portal-api-docs.json.temp ./openApi/portal-api-docs.json && yarn run clean:api-portal && mkdirp openApi/generated && api-spec-converter --from=openapi_3 --to=swagger_2 openApi/portal-api-docs.json > openApi/generated/portal-swagger20.json && node openApi/scripts/api-portal_fixPreGen.js && node ./node_modules/@pagopa/selfcare-common-frontend/utils/fixSwagger20ArraySchemaDef.js openApi/generated/portal-swagger20.json && gen-api-models --api-spec openApi/generated/portal-swagger20.json --out-dir src/api/generated/portal --no-strict --request-types --response-decoders --client && node openApi/scripts/api-portal_fixPostGen.js"
"generate:api-portal": "wget https://raw.githubusercontent.com/pagopa/pagopa-selfcare-ms-backoffice-backend/main/openapi/openapi.json -O ./openApi/portal-api-docs.json && jq 'walk(if type == \"object\" and has(\"parameters\") then .parameters |= map(select(.name != \"X-Request-Id\")) else . end)' ./openApi/portal-api-docs.json > ./openApi/portal-api-docs.json.temp && mv ./openApi/portal-api-docs.json.temp ./openApi/portal-api-docs.json && yarn run clean:api-portal && mkdirp openApi/generated && api-spec-converter --from=openapi_3 --to=swagger_2 openApi/portal-api-docs.json > openApi/generated/portal-swagger20.json && node openApi/scripts/api-portal_fixPreGen.js && node ./node_modules/@pagopa/selfcare-common-frontend/utils/fixSwagger20ArraySchemaDef.js openApi/generated/portal-swagger20.json && gen-api-models --api-spec openApi/generated/portal-swagger20.json --out-dir src/api/generated/portal --no-strict --request-types --response-decoders --client && node openApi/scripts/api-portal_fixPostGen.js",
"generate:api-portal-next": "wget https://raw.githubusercontent.com/pagopa/pagopa-selfcare-ms-backoffice-backend/next/openapi/openapi.json -O ./openApi/portal-api-docs.json && jq 'walk(if type == \"object\" and has(\"parameters\") then .parameters |= map(select(.name != \"X-Request-Id\")) else . end)' ./openApi/portal-api-docs.json > ./openApi/portal-api-docs.json.temp && mv ./openApi/portal-api-docs.json.temp ./openApi/portal-api-docs.json && yarn run clean:api-portal && mkdirp openApi/generated && api-spec-converter --from=openapi_3 --to=swagger_2 openApi/portal-api-docs.json > openApi/generated/portal-swagger20.json && node openApi/scripts/api-portal_fixPreGen.js && node ./node_modules/@pagopa/selfcare-common-frontend/utils/fixSwagger20ArraySchemaDef.js openApi/generated/portal-swagger20.json && gen-api-models --api-spec openApi/generated/portal-swagger20.json --out-dir src/api/generated/portal --no-strict --request-types --response-decoders --client && node openApi/scripts/api-portal_fixPostGen.js"
},
"dependencies": {
"@mui/base": "5.0.0-alpha.79",
Expand Down

0 comments on commit 2895df0

Please sign in to comment.