@synx-ai/oas3-mdx
Advanced tools
Comparing version 0.4.1 to 0.4.7
@@ -91,3 +91,3 @@ "use strict"; | ||
catch (e) { | ||
return YAML.safeLoad(content); | ||
return YAML.load(content); | ||
} | ||
@@ -94,0 +94,0 @@ }; |
@@ -12,3 +12,3 @@ #!/usr/bin/env node | ||
// this call handles input from argv's and converts it into an object | ||
const argv = yargs_1.default(helpers_1.hideBin(process.argv)) | ||
const argv = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv)) | ||
.usage(yellow("Usage: $0 --specs [file] --target [target path] --templates [template path]")) | ||
@@ -45,5 +45,11 @@ .option("spec", { | ||
}) | ||
.option("extension", { | ||
alias: "e", | ||
describe: "output extension", | ||
type: "string", | ||
default: "mdx", | ||
}) | ||
.help().argv; | ||
// call the convert function from ./index.js | ||
index_1.default(path.resolve(process.cwd(), argv.spec), { | ||
(0, index_1.default)(path.resolve(process.cwd(), argv.spec), { | ||
outPath: path.resolve(process.cwd(), argv.target), | ||
@@ -53,2 +59,3 @@ templatesPath: path.resolve(argv.templates), | ||
prettierParser: argv.parser, | ||
extension: argv.extension, | ||
}) | ||
@@ -55,0 +62,0 @@ .then(() => { |
@@ -10,2 +10,4 @@ declare type Optional = { | ||
prettierParser?: string; | ||
/** @default "mdx" */ | ||
extension?: string; | ||
}; | ||
@@ -12,0 +14,0 @@ /** |
@@ -64,6 +64,6 @@ "use strict"; | ||
return new Promise((resolve, reject) => { | ||
const { outPath = path.resolve(process.cwd(), "./build"), templatesPath = "../templates/", snippetTargets = ["shell"], prettierParser = "mdx", } = options; | ||
const { outPath = path.resolve(process.cwd(), "./build"), templatesPath = "../templates/", snippetTargets = ["shell"], prettierParser = "mdx", extension = "mdx", } = options; | ||
try { | ||
// load the spec from a json into an object | ||
bundler_1.default(specFile, "./") | ||
(0, bundler_1.default)(specFile, "./") | ||
.then((spec) => { | ||
@@ -131,3 +131,3 @@ if (fs.existsSync(outPath)) { | ||
// render the path using Handlebars and save it | ||
fs.writeFileSync(`${outPath}${pathKey}/${methodKey}.md`, prettier.format(pathTemplate({ | ||
fs.writeFileSync(`${outPath}${pathKey}/${methodKey}.${extension}`, prettier.format(pathTemplate({ | ||
slug: _.kebabCase(`${pathKey}-${methodKey}`), | ||
@@ -134,0 +134,0 @@ path: pathKey, |
{ | ||
"name": "@synx-ai/oas3-mdx", | ||
"version": "0.4.1", | ||
"version": "0.4.7", | ||
"description": "Convert OpenAPI spec to Markdown files.", | ||
@@ -36,2 +36,3 @@ "main": "dist/index.js", | ||
}, | ||
"baseUrl": "/oas3-mdx/", | ||
"keywords": [ | ||
@@ -74,2 +75,3 @@ "oas3", | ||
"handlebars": "^4.7.7", | ||
"js-yaml": "^4.1.0", | ||
"json-schema-ref-parser": "^9.0.7", | ||
@@ -76,0 +78,0 @@ "lodash": "^4.17.21", |
@@ -35,2 +35,3 @@ # OpenAPI3 to Markdown converter | ||
-c, --snippets comma separated targets [default: "shell"] | ||
-e, --extension output extension [default: "mdx"] | ||
--help Show help | ||
@@ -41,3 +42,3 @@ ``` | ||
```javascript | ||
const convert = require('openapi2md').default; | ||
const convert = require('@synx-ai/oas3-mdx').default; | ||
@@ -57,2 +58,3 @@ // optional arguments are expected as an object, ie: | ||
| `Prettier parser` | --parser | prettierParser | `mdx` | | ||
| `Output extension` | --extension | extension | `mdx` | | ||
@@ -59,0 +61,0 @@ The tool will try to load the `--templates` relative to current working path first, then will fallback to library path. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
41284
467
188
12
+ Addedjs-yaml@^4.1.0