Open karlismelderis-mckinsey opened 6 months ago
@karlismelderis-mckinsey
The generateEachHttpStatus option allows you to generate each http response
that you define as a schema within OpenAPI
. Does it solve your question?
I think this is similar to #1318, do you have any use case outside of when an endpoint returns a oneOf response? The linked pr solves that use case in the next release
our use-case is testing of BE services we can easily reuse faker data for plenty of service code tests and in rare cases where Schema is missing we can always inject required schema to generate faker
Beauty of our situation is that we are attaching Swagger decorators to every key out of the box due to reusable decorators within our code and even internal data structures end up having Swagger schema if needed
but because tests don't think about Request/Response
it would be very weird for back-end developers to use getShoppingCartControllerGetByIdResponseMock
instead of shoppingCartDtoMock
Also currently Orval is generating only faker code for Response but many our test cases would benefit from access to request mock
that would allow us to replace huge pile of static test data with generated faker code
@karlismelderis-mckinsey well, i don't think about backend testing. I wanna more understand, so could you show me some sample code for testing ?
Let's narrow down the scope for our ask
if Orval can generate faker code to cover Request Schema that will help us to generate data for e2e/black-box tests
anything we need for integration/unit tests we will solve differently not to couple things up to much
What happens?
currently msw code is generating only faker code for response which is fine for mocking away API spec
we're looking for an option to generate faker code for each schema mentioned within API spec and use it in our unit/integration tests Some schemas in API spec describe real data entities and we even have an option to "inject" extra schemas that represent internal data types to generate extra faker code
In any case testing would be easier if users would be working with
shoppingCartDtoMock
instead ofgetShoppingCartControllerGetByIdResponseMock
something similar is available within kubb but I would like to avoid to add another tool if possible
Do you happen to have some hidden configuration option or if not would you be willing to accept change to generate such code?
if yes, how do you see it? as part of
mock
configuration or as brand new client?What were you expecting to happen?
I would like to see folder that holds file per schema with faker code due to sheer amount of possible schemas I don't think it would be possible to put all in one file or split it somehow else