forked from janus-idp/backstage-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(orchestrator): add openapi client generation support (janus-idp…
…#1649) * Generate Typescript OpenAPI client Signed-off-by: Gloria Ciavarrini <[email protected]> * Add openapi check dependencies in turbo Signed-off-by: Gloria Ciavarrini <[email protected]> * Lint ingore generated client Signed-off-by: Gloria Ciavarrini <[email protected]> * Ignore generated client files Signed-off-by: Gloria Ciavarrini <[email protected]> --------- Signed-off-by: Gloria Ciavarrini <[email protected]>
- Loading branch information
1 parent
7e0a3dd
commit 3b14d9c
Showing
14 changed files
with
41 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname); | ||
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname, { | ||
ignorePatterns: ['src/generated/client/**'], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
src/generated/client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,23 @@ | |
pwd | ||
set -e | ||
|
||
GENERATED_FOLDER="./src/generated" | ||
OPENAPI_SPEC_FILE="./src/openapi/openapi.yaml" | ||
SCHEMA_FILE="./src/auto-generated/api/models/schema.ts" | ||
DEFINITION_FILE="./src/auto-generated/api/definition.ts" | ||
METADATA_FILE="./src/auto-generated/.METADATA.sha1" | ||
API_FOLDER="${GENERATED_FOLDER}/api" | ||
SCHEMA_FILE="${API_FOLDER}/models/schema.ts" | ||
DEFINITION_FILE="${API_FOLDER}/definition.ts" | ||
METADATA_FILE="${GENERATED_FOLDER}/.METADATA.sha1" | ||
CLIENT_FOLDER="${GENERATED_FOLDER}/client" | ||
|
||
openapi_generate() { | ||
# TypeScript Client generation | ||
openapi-ts --input ${OPENAPI_SPEC_FILE} --output ${CLIENT_FOLDER} | ||
|
||
## Schema generation | ||
npx --yes [email protected] ${OPENAPI_SPEC_FILE} -o ${SCHEMA_FILE} | ||
npx --yes @openapitools/[email protected] generate -g asciidoc -i ./src/openapi/openapi.yaml -o ./src/auto-generated/docs/index.adoc | ||
# Docs generation | ||
npx --yes @openapitools/[email protected] generate -g asciidoc -i ./src/openapi/openapi.yaml -o ./src/generated/docs/index.adoc | ||
|
||
npx --yes [email protected] -- yaml2json -f ${OPENAPI_SPEC_FILE} | ||
|
||
OPENAPI_SPEC_FILE_JSON=$(tr -d '[:space:]' < "$(dirname $OPENAPI_SPEC_FILE)"/openapi.json) | ||
|
@@ -51,10 +60,10 @@ openapi_check() { | |
|
||
# Check if the stored and current SHA-1 checksums differ | ||
if [ "${STORED_SHA1}" != "${NEW_SHA1}" ]; then | ||
echo "Changes detected in auto-generated files or openapi.yaml. Please run 'yarn openapi:generate' to update." | ||
echo "Changes detected in generated files or openapi.yaml. Please run 'yarn openapi:generate' to update." | ||
exit 1 | ||
else | ||
echo "No changes detected in auto-generated files or openapi.yaml. Auto-generated files are up to date." | ||
echo "No changes detected in generated files or openapi.yaml. generated files are up to date." | ||
fi | ||
} | ||
|
||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,24 @@ | ||
{ | ||
"extends": ["//"], | ||
"pipeline": { | ||
"start": { | ||
"dependsOn": ["openapi:check"] | ||
}, | ||
"tsc": { | ||
"outputs": ["../../dist-types/plugins/orchestrator-common/**"], | ||
"dependsOn": ["^tsc"] | ||
"dependsOn": ["^tsc", "openapi:check"] | ||
}, | ||
"openapi:check": { | ||
"outputs": ["src/generated/**"] | ||
}, | ||
"openapi:generate": { | ||
"outputs": ["src/generated/**"] | ||
}, | ||
"test": { | ||
"dependsOn": ["openapi:check"] | ||
}, | ||
"export-dynamic": { | ||
"dependsOn": ["openapi:check"] | ||
} | ||
} | ||
} |