-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: #51 Bump versions, change build to only be cjs, add …
…cli (#68) * BREAKING CHANGE: #51 Bump versions, change build to only be cjs, add cli * remove present * add readme
- Loading branch information
Showing
9 changed files
with
1,328 additions
and
1,172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env node | ||
|
||
import yargs from "yargs"; | ||
import { hideBin } from "yargs/helpers"; | ||
import { openapiSchemaToJsonSchema } from "./index.js"; | ||
import fs from "fs/promises"; | ||
import * as process from "process"; | ||
import type { AcceptibleInputSchema } from "./openapi-schema-types"; | ||
const args = yargs(hideBin(process.argv)) | ||
.options({ | ||
input: { type: "string", alias: "f", demandOption: true }, | ||
output: { type: "string", alias: "o" }, | ||
}) | ||
.parseSync(); | ||
|
||
const { input, output } = args; | ||
|
||
const getFileContents = async () => { | ||
try { | ||
const fileContents = await fs.readFile(input, "utf-8"); | ||
return JSON.parse(fileContents) as AcceptibleInputSchema; | ||
} catch (e: any) { | ||
console.error(`Error: ${e.message}`); | ||
process.exit(1); | ||
} | ||
}; | ||
|
||
(async () => { | ||
try { | ||
const fileContents = await getFileContents(); | ||
const convertedSchema = await openapiSchemaToJsonSchema(fileContents); | ||
const outputFile = output || input.replace(/\.json$/, "-converted.json"); | ||
await fs.writeFile(outputFile, JSON.stringify(convertedSchema, null, 2)); | ||
} catch (e: any) { | ||
console.error(`Error: ${e.message}`); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.