Node app running in a bash environment runs openapi-ts-generator.
187
mkdir -p /tmp/ts
node index.js $(find $openapiTmp -maxdepth 2 -type f)
/tmp/ts is referenced as the output for the generated TS. This image doesn't allow any other output destinations. Sorry.
# This version of linux lets us get all things we want.
FROM node:15.5.0-alpine3.10
RUN apk update && apk add bash=5.0.0-r0
ADD generator /app
WORKDIR /app
RUN npm i
COPY ./ts.sh /usr/bin/gen
const { readFileSync, writeFileSync } = require("fs");
const swaggerToTS = require("openapi-typescript").default
const swaggerKey = ".swagger.json"
const openapiKey = "openapi.json"
const files = process.argv.filter((arg) => arg.includes(openapiKey))
const opts = {
propertyMapper: (swaggerDefinition, property) => {
// console.log({ swaggerDefinition, property });
// if (swaggerDefinition.format === "date-time") ...
return {
...property,
}
}
}
files.forEach(file => {
const input = JSON.parse(readFileSync(file, "utf8")); // Input can be any JS object (OpenAPI format)
// sharedUUID is a special snowflake
if(input.components && input.components.schemas && input.components.schemas.sharedUUID){
delete input.components.schemas.sharedUUID.properties.Bytes;
}
let output = swaggerToTS(input, opts);
// replace file prefix
let out = file.replace(swaggerKey + "/" + openapiKey, ".ts");
// switch to out dir.
out = out.replace("tmp/openapis", "tmp/ts")
console.log({ file, out })
writeFileSync(out, output);
});
Content type
Image
Digest
Size
49.4 MB
Last updated
over 5 years ago
docker pull thomasvaladez/openapi-to-ts:0.1