openapi-library / OpenAPIValidators

Use Jest or Chai to assert that HTTP responses satisfy an OpenAPI spec
MIT License
189 stars 35 forks source link

Support ESM #265

Open mikicho opened 2 years ago

mikicho commented 2 years ago

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.

rwalle61 commented 2 years ago

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)

mikicho commented 2 years ago

I'll try to figure it out

ypolishchuk-ledger commented 1 year ago

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?

mikicho commented 1 year ago

Unfortunately, no proper solution