Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

fix: filter out nullish arrays from generated HAR objects #648

Merged
merged 2 commits into from
Apr 28, 2020

Conversation

erunion
Copy link
Member

@erunion erunion commented Apr 28, 2020

🧰 What's being changed?

This resolves a funky case with HAR generation where if a user clicks add an entry to an array<primitive> parameter, we would immediately add [null] into their code sample.

Screen Shot 2020-04-28 at 12 27 38 PM

Why this was happening because if you supply [undefined] to JSON.stringify, it'll transform that into [null], and we didn't have any work to filter out nullish items from arrays.

Screen Shot 2020-04-28 at 12 28 32 PM

🧪 Testing

Load up http://localhost:9966/?selected=swagger-files%2Ftypes.json, head to the "Arrays of different data types" operation and play around with adding and removing arrays.

🗳 Checklist

  • 🐛 I'm fixing a bug!

@erunion erunion added the type:bug Something isn't working label Apr 28, 2020
Copy link
Member

@domharrington domharrington left a comment

Choose a reason for hiding this comment

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

Happy with this change, tested locally and it works great. Can you look into the history of why this file was added, and make sure it still carries out the original intention? I'm guessing it was fixing a similar issue with object types, but i'm not sure?

This little utility should probably be it's own npm package at this point!

@erunion erunion merged commit 53b6d74 into master Apr 28, 2020
@erunion erunion deleted the fix/empty-array branch April 28, 2020 19:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type:bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants