Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@kmudrick/io-ts-openapi

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kmudrick/io-ts-openapi - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

dist/index.d.ts

18

package.json
{
"name": "@kmudrick/io-ts-openapi",
"version": "0.0.1",
"version": "0.0.2",
"license": "MIT",
"main": "./dist/index.js",
"module": "./dist/index.js",
"type": "commonjs",
"files": [
"bin",
"dist",
"src"
],
"bin": {
"io-ts-openapi": "./bin/index.ts"
"io-ts-openapi": "./dist/index.js"
},
"scripts": {
"build": "rm -rf dist && tsc && chmod +x ./dist/index.js",
"format": "npm run prettier -w .",
"lint": "eslint .",
"prepare": "npm run build"
},
"devDependencies": {

@@ -9,0 +23,0 @@ "@tsconfig/node16": "^1.0.2",

52

src/index.ts

@@ -1,38 +0,18 @@

import { parseFile } from "./parser";
import { JSONSchema } from "./json-schema";
import { isRight } from "fp-ts/lib/Either";
import { toDeclarations, getRuntime, getStatic } from "./type-codegen";
import fs from "fs/promises";
import path from "path";
#!/usr/bin/env node
import yargs from "yargs/yargs";
import { hideBin } from "yargs/helpers";
import { runProgram } from "./program";
export async function runProgram(
inputFile: string,
outputFile: string
): Promise<void> {
const unparsedSchemas = await parseFile(inputFile);
const parser = yargs(hideBin(process.argv)).options({
input: { type: "string", demandOption: true },
output: { type: "string", demandOption: true },
});
const parsed: Record<string, JSONSchema> = unparsedSchemas.reduce(
(acc, entry) => {
const { name, content } = entry;
const decoded = JSONSchema.decode(content);
if (isRight(decoded)) {
const schema = decoded.right;
return { ...acc, [name]: schema };
} else {
console.error(
`Could not decode ${name}: ${JSON.stringify(decoded.left)}`
);
return acc;
}
},
{}
);
const declarations = toDeclarations(parsed);
const runtimeContents = getRuntime(declarations);
const staticContents = getStatic(declarations);
const contents = [staticContents, runtimeContents].join("\n");
await fs.mkdir(path.dirname(outputFile), { recursive: true });
await fs.writeFile(outputFile, contents, "utf8");
}
(async () => {
const { input, output } = await parser.argv;
await runProgram(input, output);
return output;
})().then(
(fileWritten) => console.log(`Successfully wrote ${fileWritten}`),
(err) => console.error("Unsuccessful", err)
);
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc