|
5 | 5 | branches: |
6 | 6 | - master # Adjust to your default branch (e.g., main) if different |
7 | 7 | paths: |
8 | | - - 'finfeedapi/sec-api/spec/sec-api-historical.yaml' |
| 8 | + - 'finfeedapi/sec-api/spec/sec-api-historical.json' |
9 | 9 | pull_request: |
10 | 10 | branches: |
11 | 11 | - master # Adjust to your default branch (e.g., main) if different |
12 | 12 | paths: |
13 | | - - 'finfeedapi/sec-api/spec/sec-api-historical.yaml' |
| 13 | + - 'finfeedapi/sec-api/spec/sec-api-historical.json' |
14 | 14 |
|
15 | 15 | jobs: |
16 | 16 | build-and-commit-sdk: |
|
66 | 66 | # You can list available versions with: openapi-generator-cli version-manager list |
67 | 67 | openapi-generator-cli version-manager set 7.5.0 # Example: Set to a specific stable version |
68 | 68 |
|
69 | | - - name: Prepare OpenAPI Spec for Generator |
70 | | - run: | |
71 | | - echo "Original spec file: finfeedapi/sec-api/spec/sec-api-historical.yaml" |
72 | | - NEW_SPEC_FILE_PATH="finfeedapi/sec-api/spec/sec-api-historical.json" |
73 | | - OLD_SPEC_FILE_NAME="sec-api-historical.yaml" |
74 | | - NEW_SPEC_FILE_NAME="sec-api-historical.json" |
75 | | -
|
76 | | - # Rename the spec file to .json to ensure correct parsing |
77 | | - if [ -f "finfeedapi/sec-api/spec/${OLD_SPEC_FILE_NAME}" ]; then |
78 | | - echo "Renaming finfeedapi/sec-api/spec/${OLD_SPEC_FILE_NAME} to ${NEW_SPEC_FILE_PATH}" |
79 | | - mv "finfeedapi/sec-api/spec/${OLD_SPEC_FILE_NAME}" "${NEW_SPEC_FILE_PATH}" |
80 | | - else |
81 | | - echo "Warning: Expected spec file finfeedapi/sec-api/spec/${OLD_SPEC_FILE_NAME} not found. Assuming it might have been already renamed or path is incorrect." |
82 | | - # If the .json file already exists, we assume it's the correct one |
83 | | - if [ ! -f "${NEW_SPEC_FILE_PATH}" ]; then |
84 | | - echo "Error: Neither ${OLD_SPEC_FILE_NAME} nor ${NEW_SPEC_FILE_NAME} found in spec directory. Cannot proceed." |
85 | | - exit 1 |
86 | | - fi |
87 | | - fi |
88 | | - |
89 | | - echo "Updating inputSpec in generator config files to point to ${NEW_SPEC_FILE_NAME}..." |
90 | | - CONFIG_DIR="finfeedapi/sec-api/sdk-config" |
91 | | - find "${CONFIG_DIR}" -type f -name '*.yaml' -print0 | while IFS= read -r -d $'\\0' configFile; do |
92 | | - echo "Processing ${configFile}..." |
93 | | - # Using a temporary file for sed to ensure compatibility, especially with -i |
94 | | - sed "s|\\(inputSpec:.*\\)${OLD_SPEC_FILE_NAME}|\\1${NEW_SPEC_FILE_NAME}|g" "${configFile}" > "${configFile}.tmp" && mv "${configFile}.tmp" "${configFile}" |
95 | | - echo "Updated inputSpec in ${configFile} if necessary." |
96 | | - done |
97 | | - echo "Finished preparing OpenAPI spec and config files." |
98 | | -
|
99 | 69 | - name: Generate SDKs |
100 | 70 | run: | |
101 | 71 | set -e # Exit immediately if a command exits with a non-zero status. |
|
0 commit comments