Skip to content

Commit

Permalink
Bump version and add NP
Browse files Browse the repository at this point in the history
  • Loading branch information
OzzyCzech committed Apr 23, 2024
1 parent 2ce140a commit 2c8d2c9
Show file tree
Hide file tree
Showing 3 changed files with 3,120 additions and 1,083 deletions.
98 changes: 46 additions & 52 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,54 +1,48 @@
{
"name": "mock-to-openapi",
"version": "1.0.9",
"description": "Cli tool (and library) for converting JSON mock objects to Open API schemas",
"type": "module",
"exports": "./src/index.js",
"license": "MIT",
"homepage": "https://ozana.cz",
"bugs": "https://github.com/OzzyCzech/mock-to-openapi/issues",
"repository": {
"type": "git",
"url": "[email protected]:OzzyCzech/mock-to-openapi.git"
},
"author": {
"name": "Roman Ožana",
"email": "[email protected]",
"url": "https://ozana.cz"
},
"bin": {
"mock-to-openapi": "cli.js"
},
"engines": {
"node": ">=16"
},
"keywords": [
"openapi",
"converter",
"swagger",
"yaml",
"json",
"cli"
],
"scripts": {
"test": "xo && ava",
"examples": "./cli.js ./examples"
},
"private": false,
"dependencies": {
"chalk": "^5.1.2",
"globby": "^13.1.2",
"luxon": "^3.0.4",
"meow": "^11.0.0",
"yaml": "^2.1.3"
},
"devDependencies": {
"ava": "^4.3.3",
"xo": "^0.52.4"
},
"xo": {
"rules": {
"no-await-in-loop": 0
}
}
"name": "mock-to-openapi",
"version": "1.0.9",
"description": "Cli tool (and library) for converting JSON mock objects to Open API schemas",
"type": "module",
"exports": "./src/index.js",
"license": "MIT",
"repository": "OzzyCzech/mock-to-openapi",
"homepage": "https://ozana.cz",
"author": "Roman Ožana <[email protected]> (https://ozana.cz)",
"bin": {
"mock-to-openapi": "cli.js"
},
"engines": {
"node": ">=16"
},
"keywords": [
"openapi",
"converter",
"swagger",
"yaml",
"json",
"cli"
],
"scripts": {
"test": "xo && ava",
"release": "np --no-release-draft",
"examples": "./cli.js ./examples"
},
"private": false,
"dependencies": {
"chalk": "^5.3.0",
"globby": "^14.0.1",
"luxon": "^3.4.4",
"meow": "^13.2.0",
"yaml": "^2.4.1"
},
"devDependencies": {
"ava": "^6.1.2",
"np": "^10.0.3",
"xo": "^0.58.0"
},
"xo": {
"rules": {
"no-await-in-loop": 0
}
}
}
27 changes: 20 additions & 7 deletions src/to-open-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,39 @@ export function toOpenApi(item) {
const example = item;

switch (type) {
case 'object':
case 'object': {
oa.type = 'object';
oa.properties = {};
for (const [key, value] of Object.entries(item)) {
oa.properties[key] = toOpenApi(value);
}

break;
case 'array':
}

case 'array': {
return {type, items: toOpenApi(item[0])};
case 'integer':
}

case 'integer': {
return {type, format, example};
case 'number':
}

case 'number': {
return {type, example};
case 'boolean':
}

case 'boolean': {
return {type, example};
case 'string':
}

case 'string': {
return format ? {type, format, example} : {type, example};
default:
}

default: {
return {type: 'string', format: 'nullable'};
}
}

return oa;
Expand Down
Loading

0 comments on commit 2c8d2c9

Please sign in to comment.