For another example, there's a short story by Larry Niven called
The Soft Weapon. Star Trek: The Animated Series adapted it (mostly just swapping out the characters) for the episode
The Slaver Weapon. Then Alan Dean Foster went and wrote a novelization of the episode.