mswjs / source

Generate MSW request handlers from various sources (HAR files, OpenAPI documents, etc).
https://source.mswjs.io
134 stars 5 forks source link

feat(fromOpenApi): support mapping and filtering operations #57

Open jauniusmentimeter opened 2 months ago

jauniusmentimeter commented 2 months ago

Add possibility to filter open api spec spec and not mock the whole spec.

The reason for introducing this is that it's quite common case that one has open api spec with lots of endpoint definitions, but for a specific tests we want to mock just specific endpoints. Due to that, it's good to be possible to do filtering on both url and method.

jauniusmentimeter commented 1 month ago

@kettanaito @weyert these new commits improve types for mapper function, so please re-review: https://github.com/mswjs/source/pull/57/commits/898c44385b7694356ea113dd2d7b6f37f15dc066 https://github.com/mswjs/source/pull/57/commits/a214ae2cc4805fa67a223e3dcae2d7426cba0ec4

Path in the mapper function will now be union of real paths instead of being just string

weyert commented 1 month ago

@kettanaito @weyert these new commits improve types for mapper function, so please re-review: 898c443 a214ae2

Path in the mapper function will now be union of real paths instead of being just string

Looks good. Not sure why all those description fields needs to be added, though

kettanaito commented 1 month ago

This looks extremely good, @jauniusmentimeter! ❤️ Thank you so much for your hard work here. I skimmed through the discussions, and most seem to be resolved. Please let me also test this locally sometime this week, hopefully. Would love to get this merged.