Skip to content

Commit b1d5034

Browse files
author
Genevieve Nuebel
committed
Update config validator and includes in all docs
1 parent 460df9e commit b1d5034

8 files changed

Lines changed: 90 additions & 474 deletions

.github/config_validator.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,6 @@ def validate_semantic_versioning!
7575
end
7676
end
7777
end
78+
79+
# CLI Interface - allows direct execution from GitHub Actions
80+
ConfigValidator.validate!(ARGV[0], ARGV[1]) if __FILE__ == $0

.github/workflows/generate.yml

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,37 +28,17 @@ jobs:
2828
spec_url: ${{ steps.validate.outputs.spec_url }}
2929
steps:
3030
- uses: actions/checkout@v3
31+
- uses: ruby/setup-ruby@v1
32+
with:
33+
ruby-version: 3.1
3134
- name: Validate configuration
3235
id: validate
3336
run: |
3437
API_VERSION="${{ github.event.inputs.api_version }}"
3538
CONFIG_FILE="openapi/config-${API_VERSION}.yml"
36-
# Versioned spec URLs (manual workflow uses 'master' branch)
37-
# Note: Manual workflow doesn't need commit SHA since developer controls timing
38-
# CDN cache race condition only affects automated repository_dispatch triggers
39-
# v20111101 -> https://raw.githubusercontent.com/mxenabled/openapi/master/openapi/v20111101.yml
40-
# v20250224 -> https://raw.githubusercontent.com/mxenabled/openapi/master/openapi/v20250224.yml
4139
SPEC_URL="https://raw.githubusercontent.com/mxenabled/openapi/master/openapi/${API_VERSION}.yml"
4240
43-
# Check config file exists
44-
if [ ! -f "$CONFIG_FILE" ]; then
45-
echo "❌ Config file not found: $CONFIG_FILE"
46-
exit 1
47-
fi
48-
49-
# Validate semantic versioning (major must match API version)
50-
CURRENT_VERSION=$(grep 'npmVersion' "$CONFIG_FILE" | cut -d':' -f2 | tr -d ' ')
51-
MAJOR_VERSION=$(echo "$CURRENT_VERSION" | cut -d'.' -f1)
52-
53-
if [ "$API_VERSION" = "v20111101" ] && [ "$MAJOR_VERSION" != "2" ]; then
54-
echo "❌ Semantic versioning error: v20111101 must have major version 2, found $MAJOR_VERSION"
55-
exit 1
56-
fi
57-
58-
if [ "$API_VERSION" = "v20250224" ] && [ "$MAJOR_VERSION" != "3" ]; then
59-
echo "❌ Semantic versioning error: v20250224 must have major version 3, found $MAJOR_VERSION"
60-
exit 1
61-
fi
41+
ruby .github/config_validator.rb "$CONFIG_FILE" "$API_VERSION"
6242
6343
echo "✅ Validation passed"
6444
echo "config_file=$CONFIG_FILE" >> $GITHUB_OUTPUT

.github/workflows/generate_publish_release.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ jobs:
5959
- uses: ruby/setup-ruby@v1
6060
with:
6161
ruby-version: 3.1
62+
- name: Validate configuration
63+
run: ruby .github/config_validator.rb "${{ matrix.config_file }}" "${{ matrix.api_version }}"
6264
- name: Bump version
6365
id: bump_version
6466
run: |
@@ -75,7 +77,7 @@ jobs:
7577
# Versioned spec URLs with commit SHA to avoid GitHub CDN cache race condition
7678
# Problem: GitHub's raw.githubusercontent.com CDN caches files for 5 minutes
7779
# If openapi repo commits and immediately triggers this workflow, CDN may serve stale spec
78-
# Solution: Use commit SHA in URL to bypass cache and guarantee correct spec version
80+
# Using commit SHA in URL to bypass cache and guarantee correct spec version
7981
# Falls back to 'master' if openapi doesn't send commit_sha
8082
openapi-generator-cli generate \
8183
-i https://raw.githubusercontent.com/mxenabled/openapi/${{ github.event.client_payload.commit_sha || 'master' }}/openapi/${{ matrix.api_version }}.yml \

docs/Adding-a-New-API-Version.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -85,28 +85,28 @@ api_version:
8585
- v20300101 # NEW
8686
```
8787

88-
**Location 2: Semantic versioning validation**
88+
**Location 2: Update ConfigValidator**
8989

90-
In the `Validate` job's validation step, add a new conditional check for your version:
90+
In `.github/config_validator.rb`, add your new version to the `SUPPORTED_VERSIONS` mapping:
9191

92-
```yaml
93-
if [ "$API_VERSION" = "v20111101" ] && [ "$MAJOR_VERSION" != "2" ]; then
94-
echo "❌ Semantic versioning error: v20111101 must have major version 2, found $MAJOR_VERSION"
95-
exit 1
96-
fi
97-
98-
if [ "$API_VERSION" = "v20250224" ] && [ "$MAJOR_VERSION" != "3" ]; then
99-
echo "❌ Semantic versioning error: v20250224 must have major version 3, found $MAJOR_VERSION"
100-
exit 1
101-
fi
102-
103-
if [ "$API_VERSION" = "v20300101" ] && [ "$MAJOR_VERSION" != "4" ]; then
104-
echo "❌ Semantic versioning error: v20300101 must have major version 4, found $MAJOR_VERSION"
105-
exit 1
106-
fi
92+
```ruby
93+
class ConfigValidator
94+
SUPPORTED_VERSIONS = {
95+
"v20111101" => 2, # Major version must be 2
96+
"v20250224" => 3, # Major version must be 3
97+
"v20300101" => 4 # Major version must be 4 (NEW)
98+
}.freeze
99+
# ... rest of class unchanged
100+
end
107101
```
108102

109-
This ensures the major version in your config file matches the expected value for that API version.
103+
The `ConfigValidator` automatically validates that:
104+
- The API version is in `SUPPORTED_VERSIONS`
105+
- The major version in your config file matches the expected value (e.g., v20300101 → major version 4)
106+
- The config file syntax is valid YAML
107+
- The file exists at the specified path
108+
109+
**No workflow changes needed** — the existing validation step in `generate.yml` calls `ConfigValidator` with your new version, and it automatically validates using the updated mapping.
110110

111111
### 2.2 Update generate_publish_release.yml
112112

@@ -363,7 +363,7 @@ Use this checklist to verify you've completed all steps:
363363
- [ ] Created `openapi/config-v20300101.yml` with correct syntax
364364
- [ ] Major version in config is unique and sequential (4.0.0 for v20300101)
365365
- [ ] Updated `.github/workflows/generate.yml` with new version in dropdown options
366-
- [ ] Updated `.github/workflows/generate.yml` with semantic versioning validation
366+
- [ ] Updated `.github/config_validator.rb` with new version in `SUPPORTED_VERSIONS` mapping
367367
- [ ] Updated `.github/workflows/generate_publish_release.yml` with version-to-config mapping in Setup job
368368
- [ ] Updated `.github/changelog_manager.rb` with new version in `API_VERSION_ORDER` array
369369
- [ ] Updated `.github/workflows/on-push-master.yml` path triggers with `v20300101/**`
@@ -397,16 +397,16 @@ Use this checklist to verify you've completed all steps:
397397
**Solution**: Verify the version is listed in the `on.workflow_dispatch.inputs.api_version.options` section and YAML syntax is valid
398398

399399
### Semantic versioning validation fails
400-
**Cause**: Validation check missing for new version or major version mismatch
401-
**Solution**: Ensure the validation check for your version is added to generate.yml and the major version in your config matches the expected value
400+
**Cause**: ConfigValidator not updated with new version or major version mismatch
401+
**Solution**: Ensure the new version is added to `SUPPORTED_VERSIONS` in `.github/config_validator.rb` and the major version in your config file matches the expected value
402402

403403
### Generated version is 2.x.x or 3.x.x instead of 4.0.0
404404
**Cause**: Wrong major version in config file
405405
**Solution**: Update `npmVersion: 4.0.0` in config file to use unique major version
406406

407407
### generate_publish_release.yml doesn't recognize new version
408-
**Cause**: Version-to-config mapping missing in Setup job or ChangelogManager not updated
409-
**Solution**: Verify two locations in generate_publish_release.yml are updated: (1) version-to-config mapping in Setup job, and (2) add version to API_VERSION_ORDER in changelog_manager.rb
408+
**Cause**: Version-to-config mapping missing in Setup job, ChangelogManager not updated, or ConfigValidator not updated
409+
**Solution**: Verify three locations are updated: (1) version-to-config mapping in generate_publish_release.yml Setup job, (2) add version to `API_VERSION_ORDER` in `changelog_manager.rb`, and (3) add version to `SUPPORTED_VERSIONS` in `config_validator.rb`
410410

411411
### on-push-master.yml doesn't trigger after merge
412412
**Cause**: Path trigger syntax incorrect or matrix not updated

docs/Multi-Version-SDK-Flow.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
**Document Purpose**: Quick-reference guide to the multi-version SDK generation, publishing, and release system. This is your entry point to understanding how the system works.
44

5-
**Last Updated**: January 27, 2026
5+
**Last Updated**: January 28, 2026
66
**Read Time**: 5-10 minutes
77
**Audience**: Anyone joining the team or needing a system overview
88

0 commit comments

Comments
 (0)