Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cant't found types to use it with typescript #74

Open
jyeros opened this issue Nov 12, 2020 · 1 comment
Open

Cant't found types to use it with typescript #74

jyeros opened this issue Nov 12, 2020 · 1 comment

Comments

@jyeros
Copy link

jyeros commented Nov 12, 2020

I am using typescript and install swagger2-postman2, but when I import it i got the error

Could not find a declaration file for module 'swagger2-postman2'. 'node_modules/swagger2-postman2/index.js' implicitly has an 'any' type.
  Try `npm install @types/swagger2-postman2` if it exists or add a new declaration (.d.ts) file containing `declare module 'swagger2-postman2';`ts(7016)

If i try npm install @types/swagger2-postman2 the response is no found.

Could you provide .d.ts file with typescript types.

@jyeros
Copy link
Author

jyeros commented Nov 12, 2020

I generated a declaration (.d.ts) file containing declare module 'swagger2-postman2', it could be used as an started point, but would be nice if there is one official. I needed to add 2 devDependencies for types, openapi-types and @types/postman-collection

declare module 'swagger2-to-postmanv2' {
	interface ConvertOptions {
		requestNameSource?: 'URL' | 'Fallback';
		indentCharacter?: 'Space' | 'Tab';
		collapseFolders?: boolean;
		optimizeConversion?: boolean;
		requestParametersResolution?: 'Example' | 'Schema';
		exampleParametersResolution?: 'Example' | 'Schema';
		folderStrategy?: 'Paths' | 'Tags';
		includeAuthInfoInExample?: boolean;
	}
	type InputDataType = import('openapi-types').OpenAPIV2.Document | string;
	interface Input {
		type: 'file' | 'json' | 'string';
		data: InputDataType;
	}
	interface OptionDefinition {
		name: string;
		id: string;
		type: string;
		default: unknown;
		availableOptions: string[];
		description: string;
		external: boolean;
	}
	const validate: (
		input: Input
	) => {
		result: boolean;
		reason?: string;
	};
	const convert: <T>(
		input: Input,
		options: ConvertOptions,
		callback: (
			err: Error | null,
			result: {
				result: boolean;
				output?: [
					{
						type: 'collection';
						data: import('postman-collection').Collection;
					}
				];
			}
		) => T
	) => T;
	const getOptions: () => OptionDefinition[];
	const getMetaData: <T>(
		input: InputDataType,
		callback: (
			err: Error | null,
			result: {
				result: boolean;
				swagger?: import('openapi-types').OpenAPIV2.Document;
				reason?: string;
			}
		) => T
	) => T;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant