mirror of
https://github.com/Kong/insomnia
synced 2024-11-07 22:30:15 +00:00
remove SpecInfo type (#4255)
* remove SpecInfo * Update packages/insomnia-app/app/ui/components/modals/generate-config-modal.tsx Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com> Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>
This commit is contained in:
parent
681ee649ee
commit
77d2a5d6b2
@ -4,6 +4,7 @@ import mkdirp from 'mkdirp';
|
||||
import path from 'path';
|
||||
|
||||
import appConfig from '../../config/config.json';
|
||||
import { ParsedApiSpec } from '../common/api-specs';
|
||||
import { PLUGIN_PATH } from '../common/constants';
|
||||
import { resolveHomePath } from '../common/misc';
|
||||
import * as models from '../models';
|
||||
@ -81,18 +82,11 @@ export interface WorkspaceAction extends InternalProperties {
|
||||
icon?: string;
|
||||
}
|
||||
|
||||
export interface SpecInfo {
|
||||
contents: Record<string, any>;
|
||||
rawContents: string;
|
||||
format: string;
|
||||
formatVersion: string;
|
||||
}
|
||||
|
||||
export interface ConfigGenerator extends InternalProperties {
|
||||
label: string;
|
||||
docsLink?: string;
|
||||
generate: (
|
||||
info: SpecInfo,
|
||||
info: ParsedApiSpec,
|
||||
) => Promise<{
|
||||
document?: string;
|
||||
error?: string;
|
||||
@ -100,7 +94,7 @@ export interface ConfigGenerator extends InternalProperties {
|
||||
}
|
||||
|
||||
export interface DocumentAction extends InternalProperties {
|
||||
action: (context: Record<string, any>, documents: SpecInfo) => void | Promise<void>;
|
||||
action: (context: Record<string, any>, documents: ParsedApiSpec) => void | Promise<void>;
|
||||
label: string;
|
||||
hideAfterClick?: boolean;
|
||||
}
|
||||
|
@ -92,7 +92,6 @@ const useDocumentActionPlugins = ({ workspace, apiSpec, project }: Props) => {
|
||||
...pluginContexts.data.init(project._id),
|
||||
...pluginContexts.store.init(p.plugin),
|
||||
};
|
||||
// @ts-expect-error -- TSCONVERSION
|
||||
await p.action(context, parseApiSpec(apiSpec.contents));
|
||||
} catch (err) {
|
||||
showError({
|
||||
|
@ -57,19 +57,17 @@ export class GenerateConfigModal extends PureComponent<{}, State> {
|
||||
docsLink: generatePlugin.docsLink,
|
||||
error: null,
|
||||
};
|
||||
let result;
|
||||
|
||||
try {
|
||||
// @ts-expect-error -- TSCONVERSION
|
||||
result = await generatePlugin.generate(parseApiSpec(apiSpec.contents));
|
||||
const result = await generatePlugin.generate(parseApiSpec(apiSpec.contents));
|
||||
if (result.document) {
|
||||
config.content = result.document;
|
||||
}
|
||||
config.error = result.error || null;
|
||||
return config;
|
||||
} catch (err) {
|
||||
config.error = err.message;
|
||||
return config;
|
||||
}
|
||||
|
||||
config.content = result.document || null;
|
||||
config.error = result.error || null;
|
||||
return config;
|
||||
}
|
||||
|
||||
async show({ activeTabLabel, apiSpec }: ShowOptions) {
|
||||
|
Loading…
Reference in New Issue
Block a user