Skip to content

Commit 9401913

Browse files
feat: serve values-schema to api endpoint (#1678)
1 parent 015f8f8 commit 9401913

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/server.ts

+9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
/* eslint-disable @typescript-eslint/no-misused-promises, @typescript-eslint/require-await */
2+
import $RefParser from '@apidevtools/json-schema-ref-parser'
23
import express, { Request, Response } from 'express'
34
import { Server } from 'http'
45
import { bootstrapSops } from 'src/cmd/bootstrap'
56
import { validateValues } from 'src/cmd/validate-values'
67
import { decrypt, encrypt } from 'src/common/crypt'
78
import { terminal } from 'src/common/debug'
89
import { hfValues } from './common/hf'
10+
import { loadYaml, rootDir } from './common/utils'
911
import { objectToYaml } from './common/values'
1012

1113
const d = terminal('server')
@@ -80,6 +82,13 @@ app.get('/otomi/values', async (req: Request, res: Response) => {
8082
}
8183
})
8284

85+
app.get('/apl/schema', async (req: Request, res: Response) => {
86+
const schema = await loadYaml(`${rootDir}/values-schema.yaml`)
87+
const derefSchema = await $RefParser.dereference(schema as $RefParser.JSONSchema)
88+
res.setHeader('Content-type', 'application/json')
89+
res.status(200).send(derefSchema)
90+
})
91+
8392
export const startServer = (): void => {
8493
server = app.listen(17771, '0.0.0.0')
8594
d.log(`Server listening on http://0.0.0.0:17771`)

0 commit comments

Comments
 (0)