mirror of
https://github.com/LukeHagar/openapi-definition-generator.git
synced 2025-12-06 04:20:23 +00:00
Version Bumps, input formatting
This commit is contained in:
34
package.json
34
package.json
@@ -12,28 +12,28 @@
|
||||
"format": "prettier --plugin-search-dir . --write ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"@skeletonlabs/skeleton": "^1.2.5",
|
||||
"@sveltejs/adapter-auto": "^2.0.0",
|
||||
"@sveltejs/kit": "^1.5.0",
|
||||
"@tailwindcss/forms": "^0.5.3",
|
||||
"@skeletonlabs/skeleton": "^1.10.0",
|
||||
"@sveltejs/adapter-auto": "^2.1.0",
|
||||
"@sveltejs/kit": "^1.22.3",
|
||||
"@tailwindcss/forms": "^0.5.4",
|
||||
"@tailwindcss/typography": "^0.5.9",
|
||||
"@typescript-eslint/eslint-plugin": "^5.45.0",
|
||||
"@typescript-eslint/parser": "^5.45.0",
|
||||
"@typescript-eslint/eslint-plugin": "^6.1.0",
|
||||
"@typescript-eslint/parser": "^6.1.0",
|
||||
"autoprefixer": "^10.4.14",
|
||||
"eslint": "^8.28.0",
|
||||
"eslint": "^8.45.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-plugin-svelte3": "^4.0.0",
|
||||
"json-to-pretty-yaml": "^1.2.2",
|
||||
"postcss": "^8.4.23",
|
||||
"prettier": "^2.8.0",
|
||||
"prettier-plugin-svelte": "^2.8.1",
|
||||
"svelte": "^3.54.0",
|
||||
"svelte-check": "^3.0.1",
|
||||
"tailwindcss": "^3.3.2",
|
||||
"tslib": "^2.4.1",
|
||||
"typescript": "^5.0.0",
|
||||
"vite": "^4.2.0",
|
||||
"yaml": "^2.2.2"
|
||||
"postcss": "^8.4.26",
|
||||
"prettier": "^3.0.0",
|
||||
"prettier-plugin-svelte": "^3.0.0",
|
||||
"svelte": "^4.1.0",
|
||||
"svelte-check": "^3.4.6",
|
||||
"tailwindcss": "^3.3.3",
|
||||
"tslib": "^2.6.0",
|
||||
"typescript": "^5.1.6",
|
||||
"vite": "^4.4.4",
|
||||
"yaml": "^2.3.1"
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
|
||||
@@ -1,25 +1,42 @@
|
||||
<script lang="ts">
|
||||
import { RadioGroup, RadioItem, clipboard } from '@skeletonlabs/skeleton';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
//@ts-ignore
|
||||
import { stringify } from 'yaml';
|
||||
|
||||
let sampleInput = `{
|
||||
"numbersMock": {
|
||||
"smallInt": -20,
|
||||
"bigInt": 2147483647,
|
||||
"unsafeInt": 9999999999999999,
|
||||
"notInt": 12.2
|
||||
},
|
||||
"stringsMock": {
|
||||
"stringTest": "Hello World",
|
||||
"isoDate": "1999-12-31",
|
||||
"isoDateTime": "1999-12-31T23:59:59Z"
|
||||
},
|
||||
"objectsMock": {
|
||||
"child": {"child": true},
|
||||
"childList": [{"child": true}],
|
||||
"childMatrix": [[{"child": true}]],
|
||||
"nullable": null
|
||||
}
|
||||
}`
|
||||
let inJSON: any;
|
||||
let inputJSON = '';
|
||||
let outSwagger = '';
|
||||
|
||||
let requestExamples: boolean = true;
|
||||
let noInt: boolean;
|
||||
let yamlOut: boolean = true;
|
||||
let parseErr: Error | null;
|
||||
let timeOut: any;
|
||||
let tabCount: number;
|
||||
let indentator: string;
|
||||
let nullType: string;
|
||||
let parseErr: Error | null;
|
||||
let timeOut: any;
|
||||
let noInt: boolean;
|
||||
let requestExamples: boolean = true;
|
||||
let yamlOut: boolean = true;
|
||||
|
||||
const trigger = (evt: Event) => {
|
||||
clearTimeout(timeOut);
|
||||
timeOut = setTimeout(() => convert(), 100);
|
||||
timeOut = setTimeout(() => convert(), 200);
|
||||
};
|
||||
|
||||
const convert = () => {
|
||||
@@ -31,6 +48,9 @@
|
||||
parseErr = e;
|
||||
return;
|
||||
}
|
||||
|
||||
inputJSON = JSON.stringify(JSON.parse(inputJSON), null, '\t')
|
||||
|
||||
//For recursive functions to keep track of the tab spacing
|
||||
tabCount = 0;
|
||||
indentator = '\n';
|
||||
@@ -128,7 +148,7 @@
|
||||
}
|
||||
if (requestExamples) {
|
||||
//Log example if checkbox is checked
|
||||
outSwagger += ',' + indentator + '"example": "' + num + '"';
|
||||
outSwagger += ',' + indentator + '"example": ' + num ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,12 +245,7 @@
|
||||
}
|
||||
|
||||
function format(value: string) {
|
||||
/*
|
||||
Convert JSON to YAML if yaml checkbox is checked
|
||||
Global variables updated:
|
||||
NONE
|
||||
*/
|
||||
|
||||
// Convert JSON to YAML if yaml option is selected
|
||||
value = JSON.stringify(JSON.parse(value), null, '\t');
|
||||
|
||||
if (yamlOut) {
|
||||
@@ -245,25 +260,7 @@
|
||||
if (tempJSON !== null && tempJSON !== '') {
|
||||
inputJSON = tempJSON;
|
||||
} else {
|
||||
inputJSON = `{
|
||||
"numbersMock": {
|
||||
"smallInt": -20,
|
||||
"bigInt": 2147483647,
|
||||
"unsafeInt": 9999999999999999,
|
||||
"notInt": 12.2
|
||||
},
|
||||
"stringsMock": {
|
||||
"stringTest": "Hello World",
|
||||
"isoDate": "1999-12-31",
|
||||
"isoDateTime": "1999-12-31T23:59:59Z"
|
||||
},
|
||||
"objectsMock": {
|
||||
"child": {"child": true},
|
||||
"childList": [{"child": true}],
|
||||
"childMatrix": [[{"child": true}]],
|
||||
"nullable": null
|
||||
}
|
||||
}`;
|
||||
inputJSON = sampleInput;
|
||||
}
|
||||
convert();
|
||||
});
|
||||
@@ -302,7 +299,7 @@
|
||||
</div>
|
||||
<div class="grow">
|
||||
<p class="text-center py-2">
|
||||
And here is that JSON Response formatted as a YAML OpenAPI Specification
|
||||
And here is that JSON Response formatted as a {yamlOut === true ? "YAML" : "JSON"} OpenAPI Specification
|
||||
</p>
|
||||
<div class="relative">
|
||||
<textarea
|
||||
|
||||
Reference in New Issue
Block a user