Skip to content

Conversation

eaglethrost
Copy link
Contributor

@eaglethrost eaglethrost commented Sep 10, 2025

🚥 Resolves ISSUE_ID

🧰 Changes

This PR is part of the work for the readme ticket RM-9906 Not displaying null values in an array and should get merged ONLY after the corresponding PR changes in the remove-undefined-objects repo is shipped

The aim of the ticket is we want user-added null values in arrays to be visible in requests.

This requires adjustments in the oas-to-har package, with two separate causes of why the nulls in array are being dropped

  1. For postData (body):
  • Issue: remove-undefined-objects was filtering out null values in arrays.
  • Fix: Replaced JSON.parse/stringify approach with a custom function to distinguish actual null vs. undefined.
    Updated stripEmptyObjects to stop removing null values in arrays, while still removing undefined, empty objects, and empty arrays.
  1. For Non-postData (parameters, cookies, etc.):
  • Issue: encodeArray in style-serializer used .join, which dropped null values.
  • Fix: Convert null values to the string "null" before joining, so they’re preserved.

TODO Before Merging:

🧬 QA & Testing

  • Temporarily migrated tests for remove-undefined-objects to show the changes works
  • Run oasToHar or oasToSnippet in a script with an OAS object containing arrays of null, undefined, and undefined objects

@eaglethrost eaglethrost reopened this Sep 10, 2025
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we vendoring and forking remove-undefined-objects in here instead of adding a new option to that library for preserving empty arrays? thats what @mjcuva and i talked about out what i thought needed to happen for this ticket

Copy link
Contributor Author

@eaglethrost eaglethrost Sep 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry this PR is not for that ticket, but a different one, which tries to solve a different issue of null values in arrays getting dropped in the request snippet.

The PR's related to the ticket you were referring to are these:

@eaglethrost eaglethrost marked this pull request as ready for review September 12, 2025 03:25
Copy link
Member

@kanadgupta kanadgupta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use the latest release of [email protected] here?

@erunion erunion requested a review from kanadgupta October 6, 2025 19:19
@erunion erunion enabled auto-merge (squash) October 6, 2025 22:00
@erunion erunion disabled auto-merge October 6, 2025 22:00
@erunion erunion merged commit ff4e23b into readmeio:main Oct 6, 2025
6 of 7 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.

3 participants