OpenAPIValidators icon indicating copy to clipboard operation
OpenAPIValidators copied to clipboard

Support ESM

Open mikicho opened this issue 3 years ago • 4 comments

Are you using OpenAPI 2, 3.0.X, or 3.1.0? All of them

Would this solve a problem or make something easier? Solve a problem

What would you like to happen? I'd be able to import jest-openpi in ESM module like this:

import jestOpenApi from 'jest-openapi';
jestOpenApi(..);

Describe alternatives you've considered use it like this:

import jestOpenAPI from 'jest-openapi';

// @ts-expect-error - jest-openapi types doesn't properly support esm
jestOpenAPI.default(join(process.cwd(), './docs/oas3.json'));

// @ts-expect-error - jest-openapi types doesn't properly support esm
expect(res).toSatisfyApiSpec();

Additional context or screenshots

Are you going to resolve the issue? I'd love to, but I need some guidance on how we want to do this.

mikicho avatar Jan 11 '22 08:01 mikicho

hey @mikicho thanks for suggesting this 🙂 I'm not sure what we need to do to import jest-openapi in an ESM module. Happy for you to suggest how it should be done, if you have time and know how to.

Otherwise I will look at it later (but can't right now as I'm quite busy at work)

rwalle61 avatar Jan 17 '22 11:01 rwalle61

I'll try to figure it out

mikicho avatar Jan 17 '22 16:01 mikicho

Hello @mikicho @rwalle61 do you have news about this issue? I'm not able to use latest jest-openapi version with ESM. Maybe you know a workaround while waiting for permanent solution?

ypolishchuk-ledger avatar Jun 21 '23 12:06 ypolishchuk-ledger

Unfortunately, no proper solution

mikicho avatar Jun 21 '23 12:06 mikicho