This is a repost of the same question in the old forum - for which I never got an answer. So I'm hoping to have more luck here.
Secondly, I find the new forum quite confusing when it comes to chosing the correct subforum. I hope I'm not totally wrong here.
To my problem:
I'm currently trying to write my own swagger codegen plugin and came across a "problem" when generating the client code for the PetStore api example.
It's about the "placeOrder" operation (POST on /store/order): This operation has an "in body" parameter but no "consumes" list (neither on the operation nor on the api itself).
While the mime type in this particular example is most likely "application/json", my question is: What should a codegen plugin do about this? I mean should it always assume "application/json" (which could be totally wrong)? Or should it error out?
Or is this actually a "bug" in the PetStore api spec?
Unfortunately, the Swagger 2.0 spec doesn't seem to say anything about this case (at least nothing I could find).
As you noticed, the Swagger 2 (or OAS2) spec doesn't specify a default value nor does it make it a mandatory field, making the processing a bit more challenging. This is one of the things we made sure are fixed with OpenAPI 3, making that disambiguation disappear.
What you end up doing in that case is up to you. Generally speaking, we do end up assuming "application/json", even though it's not necessarily correct.
As for the pet store definition itself - it's not perfect. The OpenAPI 3 version of the pet store will be more accurate. However, the current version also exhibits what might happen with real life APIs - they may not contain the important details, and the codegen still needs to handle these cases as best it can.
Hope this helps,
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓