Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ jobs:
name: Validate Specs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Install dependencies
run: npm ci

- name: Validate local spec references
run: npm run validate:refs -- specs

- name: Validate all specs against Swagger Validator
run: |
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ Thumbs.db
# Temp files
*.tmp
*.bak

# Dependencies
node_modules/
180 changes: 180 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@
"files": [
"examples",
"specs"
]
],
"scripts": {
"validate:refs": "node scripts/validate-local-refs.js"
},
"devDependencies": {
"@apidevtools/swagger-parser": "^12.1.0"
}
}
76 changes: 76 additions & 0 deletions scripts/validate-local-refs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/env node

const fs = require('fs');
const path = require('path');

const root = process.argv[2] || 'specs';

async function loadSwaggerParser() {
const module = await import('@apidevtools/swagger-parser');
return module.default || module;
}

function collectJsonFiles(dir) {
const stat = fs.statSync(dir);

if (stat.isFile()) {
return dir.endsWith('.json') ? [dir] : [];
}

const entries = fs.readdirSync(dir, { withFileTypes: true });
const files = [];

for (const entry of entries) {
const fullPath = path.join(dir, entry.name);

if (entry.isDirectory()) {
files.push(...collectJsonFiles(fullPath));
} else if (entry.isFile() && entry.name.endsWith('.json')) {
files.push(fullPath);
}
}

return files.sort();
}

async function main() {
const specFiles = collectJsonFiles(root);

if (specFiles.length === 0) {
console.error(`No JSON spec files found under ${root}`);
process.exit(1);
}

const SwaggerParser = await loadSwaggerParser();
let failed = 0;
let passed = 0;

for (const specFile of specFiles) {
try {
await SwaggerParser.dereference(specFile, {
validate: {
schema: false,
spec: false,
},
});
console.log(`${specFile}: OK`);
passed += 1;
} catch (error) {
console.error(`${specFile}: FAILED`);
console.error(` ${error.message}`);
failed += 1;
}
}

console.log('');
console.log(`Results: ${passed} passed, ${failed} failed`);

if (failed > 0) {
process.exit(1);
}
}

main().catch((error) => {
console.error(error);
process.exit(1);
});
2 changes: 1 addition & 1 deletion specs/0.12.x/open-api3-0.12.x-console.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion specs/0.12.x/swagger2-0.12.x-console.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion specs/0.13.x/open-api3-0.13.x-console.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion specs/0.13.x/swagger2-0.13.x-console.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion specs/0.14.x/open-api3-0.14.x-console.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion specs/0.14.x/swagger2-0.14.x-console.json

Large diffs are not rendered by default.

48 changes: 0 additions & 48 deletions specs/1.8.x/open-api3-1.8.x-console.json
Original file line number Diff line number Diff line change
Expand Up @@ -63098,18 +63098,6 @@
{
"$ref": "#\/components\/schemas\/attributePolygon"
},
{
"$ref": "#\/components\/schemas\/attributeVarchar"
},
{
"$ref": "#\/components\/schemas\/attributeText"
},
{
"$ref": "#\/components\/schemas\/attributeMediumtext"
},
{
"$ref": "#\/components\/schemas\/attributeLongtext"
},
{
"$ref": "#\/components\/schemas\/attributeString"
}
Expand Down Expand Up @@ -63220,18 +63208,6 @@
{
"$ref": "#\/components\/schemas\/attributePolygon"
},
{
"$ref": "#\/components\/schemas\/attributeVarchar"
},
{
"$ref": "#\/components\/schemas\/attributeText"
},
{
"$ref": "#\/components\/schemas\/attributeMediumtext"
},
{
"$ref": "#\/components\/schemas\/attributeLongtext"
},
{
"$ref": "#\/components\/schemas\/attributeString"
}
Expand Down Expand Up @@ -64587,18 +64563,6 @@
{
"$ref": "#\/components\/schemas\/columnPolygon"
},
{
"$ref": "#\/components\/schemas\/columnVarchar"
},
{
"$ref": "#\/components\/schemas\/columnText"
},
{
"$ref": "#\/components\/schemas\/columnMediumtext"
},
{
"$ref": "#\/components\/schemas\/columnLongtext"
},
{
"$ref": "#\/components\/schemas\/columnString"
}
Expand Down Expand Up @@ -64709,18 +64673,6 @@
{
"$ref": "#\/components\/schemas\/columnPolygon"
},
{
"$ref": "#\/components\/schemas\/columnVarchar"
},
{
"$ref": "#\/components\/schemas\/columnText"
},
{
"$ref": "#\/components\/schemas\/columnMediumtext"
},
{
"$ref": "#\/components\/schemas\/columnLongtext"
},
{
"$ref": "#\/components\/schemas\/columnString"
}
Expand Down
Loading