Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for readOnly and writeOnly keywords with v2 APIs. #807

Merged
merged 3 commits into from
Aug 13, 2024

Conversation

VShingala
Copy link
Member

@VShingala VShingala commented Jul 18, 2024

Overview

Fixes postmanlabs/postman-app-support#12255 and #98.

This PR adds correct support for resolution of readOnly and writeOnly keywords while generating collections from it. i.e. readOnly properties will not be present in request part anymore and writeOnly properties will not be present in responses.

To read up more on working of readOnly and writeOnly, take a look here.

Implementation details

To optimize the schema resolution that happens for each schema object mentioned in OpenAPI, we use function resolveSchema and also make sure that resolved schemas are cached for further usage.

Now in case of readOnly and writeOnly properties case, if we don't resolve certain property based on where it's at within request or response, we'll end up with incorrect schema based on where it might be used again from cache.

With this PR, we're adding support for caching where exactly readOnly and writeOnly properties are present and we'll be using it further to make sure correct schema is returned as return value of resolveSchema. To do this, we're making sure that we don't change the schema we cached and only change return value base on if there were any readOnly and/or writeOnly properties were found or not making sure no performance overhead for usecases without readOnly and writeOnly props.

For storing the location of readOnly and writeOnly that are cached, we're using JSON Pointer. We're also appropriately escaping and unescaping related special characters.

@thim81
Copy link
Contributor

thim81 commented Aug 7, 2024

@VShingala Do you think this will land in the next release of openapi-to-postman?

@VShingala
Copy link
Member Author

@thim81 Yeah, I'm trying to get this reviewed by teammates but this should be added by next week with the next release. Feel free to review it as well and let me know if you find any issues.

@VShingala VShingala merged commit 083b837 into develop Aug 13, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OpenAPI 3.0 readOnly fields show up in request body
3 participants