fix download system

This commit is contained in:
Malte Teichert
2024-05-30 23:44:19 +02:00
parent b3b9ffc3c2
commit 022d03e6d8
2 changed files with 6 additions and 9 deletions

View File

@@ -5,11 +5,9 @@
$: fileName = filenamify($openApiStore?.info?.title) || 'openapi';
// TODO: Refactor this to use the new storage instead of localstorage
const saveYAML = () => {
const openApiStorage = localStorage.getItem(`${localStoragePrefix}openApi`);
if (!openApiStorage) return;
const openApi = JSON.parse(openApiStorage);
if (!$openApiStore) return;
const openApi = $openApiStore;
const blob = new Blob([stringify(openApi, null, { indent: 2, aliasDuplicateObjects: false })], {
type: 'application/yaml'
});
@@ -21,12 +19,10 @@
a.click();
window.URL.revokeObjectURL(url);
};
// TODO: Refactor this to use the new storage instead of localstorage
const saveJSON = () => {
const openApiStorage = localStorage.getItem(`${localStoragePrefix}openApi`);
if (!openApiStorage) return;
const openApi = JSON.parse(openApiStorage);
if (!$openApiStore) return;
const openApi = $openApiStore;
const blob = new Blob([JSON.stringify(openApi, null, 2)], {
type: 'application/json'
});

View File

@@ -5,6 +5,7 @@ export const localStoragePrefix = 'openapigen-';
export const blankSpec: OpenAPIV3_1.Document = {
openapi: '3.1.0', // OpenAPI version
jsonSchemaDialect: 'https://json-schema.org/draft/2020-12/schema', // JSON Schema version
info: {
/** Title of the API (required) */
title: '',