37bed1cd4e
Docs Check / Markdown lint (push) Successful in 1m6s
Licence Check / Licence compatibility and copyright header verification (push) Successful in 1m20s
Build and Push Docker Image / build (push) Successful in 1m35s
CI / Swagger Validation & Coverage (push) Failing after 2m0s
CI / Security audit (push) Successful in 2m6s
Docs Check / Mermaid diagram parse check (push) Successful in 2m20s
CI / Tests & coverage (push) Failing after 2m30s
- Add RAML generation scripts (generate-openapi, downgrade-openapi, simple-raml-converter, package-raml) - Add /api/swagger.json endpoint to server/app.js - Add minimal .spectral.yml ruleset for OpenAPI linting - Add npm scripts for OpenAPI/RAML generation and packaging - Extend CI swagger job with RAML generation steps - Upload raml-package artifact with 14-day retention - Update CHANGELOG.md for v1.7.1
48 lines
1.4 KiB
JavaScript
48 lines
1.4 KiB
JavaScript
// Copyright (c) 2026 Gordon Bolton. MIT License.
|
|
/**
|
|
* Downgrades OpenAPI 3.1.0 to 3.0.0 for compatibility with RAML converters.
|
|
* OpenAPI 3.1 has limited support in existing RAML conversion tools.
|
|
*/
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const INPUT_FILE = path.join(process.cwd(), 'dist/openapi-merged.json');
|
|
const OUTPUT_FILE = path.join(process.cwd(), 'dist/openapi-30.json');
|
|
|
|
function downgradeOpenApi30(spec) {
|
|
// Change version from 3.1.0 to 3.0.0
|
|
spec.openapi = '3.0.0';
|
|
|
|
// OpenAPI 3.1 uses "type" with array for nullable, 3.0 uses nullable: true
|
|
// This is a simple pass-through for now - complex schemas may need more handling
|
|
// For this spec, most nullable fields are already using 3.0-compatible syntax
|
|
|
|
return spec;
|
|
}
|
|
|
|
async function main() {
|
|
if (!fs.existsSync(INPUT_FILE)) {
|
|
throw new Error(`Input file not found: ${INPUT_FILE}`);
|
|
}
|
|
|
|
console.log(`Reading OpenAPI 3.1 spec from ${INPUT_FILE}`);
|
|
const spec = JSON.parse(fs.readFileSync(INPUT_FILE, 'utf-8'));
|
|
|
|
console.log('Downgrading to OpenAPI 3.0.0...');
|
|
const downgraded = downgradeOpenApi30(spec);
|
|
|
|
fs.writeFileSync(OUTPUT_FILE, JSON.stringify(downgraded, null, 2));
|
|
console.log(`✓ Downgraded spec written to ${OUTPUT_FILE}`);
|
|
}
|
|
|
|
main()
|
|
.then(() => {
|
|
console.log('Downgrade complete');
|
|
process.exit(0);
|
|
})
|
|
.catch((error) => {
|
|
console.error('Failed to downgrade spec:', error);
|
|
process.exit(1);
|
|
});
|