postmanlabs / openapi-to-postman

Plugin for converting OpenAPI 3.0 specs to the Postman Collection (v2) format
Apache License 2.0
928 stars 200 forks source link

#776: Fixed bug for request body not resolving schema when using $ref #830

Open aakankshabhende opened 1 month ago

aakankshabhende commented 1 month ago

Fixes #776

aakankshabhende commented 1 month ago

@VShingala please review my PR

aakankshabhende commented 1 month ago

@VShingala Please correct me if I'm wrong, libV2/shemaUtils.js file already has a function resolveRefFromSchema which seems to resolve the ref.

VShingala commented 1 month ago

@aakankshabhende It does but it seems actual handling is not considering it.

https://github.com/postmanlabs/openapi-to-postman/blob/c6b3852c7ff51b94707c83978c9b14c1a16e8949/libV2/schemaUtils.js#L1748

Here, the schema passed to the corresponding function should be resolved but it seems it's need resolved first hand. Due to this, we see issues with even v2 APIs.

aakankshabhende commented 1 month ago

@VShingala I'm new to contributing to this project and am eager to get involved, but I’m having some trouble understanding how to reflect changes in my local dev environment as there is no contribution guide available. Could you please provide some guidance on this?

VShingala commented 1 month ago

@aakankshabhende Sure, If you mean setting up local development environment, below is what I usually follow.

  1. Checkout debug/setup branch.
  2. There are 3 files that I've created temporarily named test.js, spec, .vscode/launch.json on this branch. You can avoid committing them in your PR changes.
  3. You can keep pull debug/setup branch into your branch as well.
  4. test.js can consume APIs exposed by this module and generate collection in new file named collection.json. Simply run node test.js from CLI to see it working.
  5. I've also included vscode debug action named Conversion which does the same thing, you can use that to debug properly if you're using VSCode.

how to reflect changes in my local dev environment

I didn't exactly get above part so feel free to add more details if above guide doesn't help you with your question.

aakankshabhende commented 1 month ago

Thanks a lot for the info, I have made changes in libV2/shemaUtils.js to fix this bug but I'm not able to test it because I'm not able to log anything in the console for this particular libV2/shemaUtils.js file.

VShingala commented 1 month ago

@aakankshabhende Not sure why you're not getting logs. Are you able to generate the collection from the steps I mentioned?

aakankshabhende commented 1 month ago

Yes, I'm able to generate logs. Thank you @VShingala