Files
galaxy/client/openapi_to_schema.mjs
T
2024-01-08 12:17:42 +01:00

18 lines
594 B
JavaScript

// this is a helper script that fixes const values
// upstream fix in https://github.com/drwpow/openapi-typescript/pull/1014
import openapiTS from "openapi-typescript";
const inputFilePath = process.argv[2];
const localPath = new URL(inputFilePath, import.meta.url);
openapiTS(localPath, {
transform(schemaObject, metadata) {
if (
"const" in schemaObject &&
(typeof schemaObject.const === "string" || schemaObject.const instanceof String)
) {
return `"${schemaObject.const}"`;
}
},
}).then((output) => console.log(output));