* WIP export OpenAPI definitions from service examples * allow services to optionally define an OpenApi Paths Object instead of examples * make use of param descriptions and required query params * convert other 'core' services to declare openApi.. ..instead of examples * tweak descriptions for standard query params * move stuff around, add a high-level integration test for category2openapi * update simple-icons text refs #9054 * remove legacy param names
25 lines
783 B
JavaScript
25 lines
783 B
JavaScript
import yaml from 'js-yaml'
|
|
import { collectDefinitions } from '../core/base-service/loader.js'
|
|
;(async () => {
|
|
const definitions = await collectDefinitions()
|
|
|
|
// filter out static, dynamic and debug badge examples
|
|
const publicCategories = definitions.categories.map(c => c.id)
|
|
definitions.services = definitions.services.filter(s =>
|
|
publicCategories.includes(s.category)
|
|
)
|
|
|
|
// drop the openApi property for the "legacy" frontend
|
|
for (const service of definitions.services) {
|
|
if (service.openApi) {
|
|
service.openApi = undefined
|
|
}
|
|
}
|
|
|
|
// Omit undefined
|
|
// https://github.com/nodeca/js-yaml/issues/356#issuecomment-312430599
|
|
const cleaned = JSON.parse(JSON.stringify(definitions))
|
|
|
|
process.stdout.write(yaml.dump(cleaned, { flowLevel: 5 }))
|
|
})()
|