zoubingwu / msw-auto-mock

A cli tool to generate random mock data from OpenAPI definition for msw.
273 stars 57 forks source link

Handlers are generated in the wrong order #14

Open la55u opened 1 year ago

la55u commented 1 year ago

Due to the inner workings of MSW, handlers must be defined in a certain order to avoid ambiguous paths. See more here. In short handlers with path parameters must be listed after handlers with static paths otherwise they will match to wrong path. A way to solve it would be to sort the handlers array by path. Thank you for the lib!

zoubingwu commented 1 year ago

@la55u how do you maintain your openapi spec? what kind of tool you use to generate the openapi json/yaml file? I think you can sort them by paths when you generate the input file so you don't have to worry about this problem?