Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

ReadMe.md

Examples


3) Look at editorInputToHtml.ts to handle editors by yourself

editorInputToHtml.ts

Example of using editorInputToHtml.ts

Download this file

https://petstore.swagger.io/v2/swagger.json

Then use this code

import { writeFileSync } from 'fs';
import openapiSchemaExample from './openapiSchemaExample.json';
import { editorInputToHtml, getEditor, OpenApiDocument } from 'openapi-toolkit';

const ex = async () = {
    await axios.get('https://petstore.swagger.io/v2/swagger.json')
    const editors = ['Order', 'User', 'Category', 'Tag', 'Pet', 'ApiResponse'].map(tabName => getEditor((openapiSchemaExample as any) as OpenApiDocument, tabName));
    const html = editorInputToHtml(editors);
    writeFileSync('./openapiSchemaExample.result.json', JSON.stringify(editors, undefined, 4), 'utf-8');
    writeFileSync('./openapiSchemaExample.html', html, 'utf-8');
    var start = process.platform == 'darwin' ? 'open' : process.platform == 'win32' ? 'start' : 'xdg-open';
    require('child_process').exec(start + ' ' + './openapiSchemaExample.html');
}

Result

Example