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

openapi-to-md

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openapi-to-md - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

25

dist/index.js

@@ -74,4 +74,11 @@ #!/usr/bin/env node

};
const getRefName = (refObjecgt) => {
if (typeof refObjecgt === "object" && refObjecgt && "$ref" in refObjecgt) {
return refObjecgt["$ref"];
}
return undefined;
};
const getApiObject = ({ references }, object, refs) => {
if (typeof object === "object" && object && "$ref" in object) {
const refName = getRefName(object);
if (refName) {
const ref = object["$ref"];

@@ -115,2 +122,3 @@ if (refs) {

if (apiObject.type === "object") {
output += outputComment(apiObject, 0);
output += outputObject(apiDocument, undefined, apiObject);

@@ -127,2 +135,14 @@ }

const SP = (size) => "".padEnd(size);
const outputRefComment = (apiObject, level) => {
const refName = getRefName(apiObject);
return refName ? SP(level) + `// ${refName}\n` : "";
};
const outputComment = (apiObject, level) => {
return apiObject.description
? SP(level * 2) +
apiObject.description
.split("\n")
.reduce((a, b) => a + SP(level) + `// ${b}\n`, "")
: "";
};
const outputObject = (apiDocument, name, schemas, required, refs, level) => {

@@ -139,2 +159,4 @@ const nowLevel = level || 0;

else if (apiObject.type === "object") {
output += outputRefComment(schemas, nowLevel);
output += outputComment(apiObject, nowLevel);
output += name ? SP(nowLevel * 2) + `${name}: {\n` : "{\n";

@@ -155,2 +177,3 @@ apiObject.properties &&

else {
output += outputComment(apiObject, nowLevel);
const type = Array.isArray(apiObject.type)

@@ -157,0 +180,0 @@ ? apiObject.type

4

package.json
{
"name": "openapi-to-md",
"version": "1.0.2",
"version": "1.0.3",
"main": "dist/index.js",

@@ -9,3 +9,3 @@ "bin": {

"scripts": {
"test": "ts-node dist/index.js test/test.yaml test/readme.md",
"test": "ts-node src/index.ts test/test.yaml test/readme.md",
"build": "tsc -b",

@@ -12,0 +12,0 @@ "lint": "eslint src",

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