Skip to content

Commit

Permalink
generate openapi spec api-doc
Browse files Browse the repository at this point in the history
FLPATH-1774
https://issues.redhat.com/browse/FLPATH-1774

Signed-off-by: Yaron Dayagi <[email protected]>
  • Loading branch information
ydayagi committed Dec 2, 2024
1 parent 0703b6a commit 3af2c24
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
5 changes: 5 additions & 0 deletions workspaces/orchestrator/.changeset/polite-chicken-applaud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@red-hat-developer-hub/backstage-plugin-orchestrator-common': patch
---

generate openapi spec api-doc
2 changes: 1 addition & 1 deletion workspaces/orchestrator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"prettier:check": "prettier --check .",
"prettier:fix": "prettier --write .",
"new": "backstage-cli new --scope @red-hat-developer-hub",
"postinstall": "cd ../../ && yarn install"
"postinstall": "./scripts/postinstall"
},
"workspaces": {
"packages": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,22 @@ API_FOLDER="${GENERATED_FOLDER}/api"
DEFINITION_FILE="${API_FOLDER}/definition.ts"
METADATA_FILE="${GENERATED_FOLDER}/.METADATA.sha1"
CLIENT_FOLDER="${GENERATED_FOLDER}/client"
APIDOC_TEMPLATE_FILE="./src/openapi/api-doc-template.yaml"
APIDOC_GENERATED_FILE=${GENERATED_FOLDER}/docs/api-doc/orchestrator-api.yaml

openapi_generate() {
# TypeScript Client generation
rm -rf ${CLIENT_FOLDER}
openapi-generator-cli generate -g typescript-axios -i ${OPENAPI_SPEC_FILE} -o ${CLIENT_FOLDER}

# Docs generation
rm -rf ./src/generated/docs/markdown ./src/generated/docs/html
rm -rf ./src/generated/docs/markdown ./src/generated/docs/html ./src/generated/docs/api-doc
openapi-generator-cli generate -g markdown -i ${OPENAPI_SPEC_FILE} -o ./src/generated/docs/markdown/
openapi-generator-cli generate -g html2 -i ${OPENAPI_SPEC_FILE} -o ./src/generated/docs/html
mkdir ./src/generated/docs/api-doc
cp $APIDOC_TEMPLATE_FILE $APIDOC_GENERATED_FILE
cat $OPENAPI_SPEC_FILE | sed 's/^/ /g' >> $APIDOC_GENERATED_FILE


yaml2json -f ${OPENAPI_SPEC_FILE}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: backstage.io/v1alpha1
kind: API
metadata:
name: orchestrator-backend
description: The Orchestrator backend plugin API
tags:
- orchestrator
spec:
type: openapi
lifecycle: experimental
owner: development
definition: |
6 changes: 6 additions & 0 deletions workspaces/orchestrator/scripts/postinstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
mydir=`pwd`
cd ../../ && yarn install
cd $mydir
cd plugins/orchestrator-common
yarn openapi:check

0 comments on commit 3af2c24

Please sign in to comment.