Files
shields/scripts/export-openapi-cli.js
dependabot[bot]andPierre-Yves Bigourdan 12956aad4b chore(deps): bump js-yaml from 4.2.0 to 5.0.0; run [dynamicyaml ros conan wingetreleasedate] (#11943)
* chore(deps): bump js-yaml from 4.2.0 to 5.0.0

Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 4.2.0 to 5.0.0.
- [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nodeca/js-yaml/compare/4.2.0...5.0.0)

---
updated-dependencies:
- dependency-name: js-yaml
  dependency-version: 5.0.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* Migrate code

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Pierre-Yves Bigourdan <10694593+PyvesB@users.noreply.github.com>
2026-06-28 10:33:05 +00:00

54 lines
1.4 KiB
JavaScript

import fs from 'fs'
import path from 'path'
import * as yaml from 'js-yaml'
import { collectDefinitions } from '../core/base-service/loader.js'
import { category2openapi } from '../core/base-service/openapi.js'
const specsPath = path.join('frontend', 'categories')
function writeSpec(filename, spec) {
// Omit undefined
// https://github.com/nodeca/js-yaml/issues/356#issuecomment-312430599
const cleaned = JSON.parse(JSON.stringify(spec))
fs.writeFileSync(
filename,
yaml.dump(cleaned, { flowLevel: 5, quoteStyle: 'double' }),
)
}
;(async () => {
const definitions = await collectDefinitions()
for (const category of definitions.categories) {
const services = definitions.services.filter(
service => service.category === category.id && !service.isRetired,
)
writeSpec(
path.join(specsPath, `${category.id}.yaml`),
category2openapi({ category, services, sort: true }),
)
}
let coreServices = []
coreServices = coreServices.concat(
definitions.services.filter(
service => service.category === 'static' && !service.isRetired,
),
)
coreServices = coreServices.concat(
definitions.services.filter(
service => service.category === 'dynamic' && !service.isRetired,
),
)
writeSpec(
path.join(specsPath, '1core.yaml'),
category2openapi({
category: { name: 'Core' },
services: coreServices,
sort: false,
}),
)
})()