kevinswiber / postman2openapi

Convert a Postman collection to an OpenAPI definition.
Apache License 2.0
340 stars 54 forks source link

Node transpile function is not maintaining put bodies #80

Closed ScriptAlchemist closed 1 month ago

ScriptAlchemist commented 1 month ago

I'm building an api that is using a postman schema as the base. We transpile it to openapi spec to allow for an autogenerated webpage. I noticed that in the transpilation. That the Update routes have no bodies in them

There are bodies in the postman

image

Which don't seem to make it after the transpile.

image image

Compared to the post routes that seem to fill out the schema after the transpiling.

image
ScriptAlchemist commented 1 month ago

My easy fix. You just be to take all the puts and replace the parameters with a similar body for the posts.

I'd much rather not add more complexity to the next person. If I don't have to.

So I'd appreciate if anyone knows what I'm doing wrong. Maybe this is a bug or maybe it's functioning correctly and I just don't understand.

ScriptAlchemist commented 1 month ago

My current solution is to just take the transpiled code and placing the parameters from the post route into the put routes. It's working now. So I won't really be worried about this for now.

kevinswiber commented 1 month ago

@ScriptAlchemist For the request in Postman, make sure you're selecting "JSON" as the type, save it, and try again. Also, make sure the request doesn't have an example with an empty request body. I don't remember if I implemented request body schema merging in that scenario.

image
ScriptAlchemist commented 1 month ago

@kevinswiber So I had one example where it was sending an empty object. On purpose because it's supposed to have it fail based on validation.

So adding in a json object seems to make it work. Thanks.

I'm not sure if that's the better solution though. Cause inside of the postman doc that I give others. It's going to have a technically incorrect example. So maybe I'll just programmatically delete it after

image