There is a bit of an academic game of telephone involved in this. There are several historians, notably Oleg Benesch, who have prominently argued against the idea that 20th century Japanese people followed a "warrior code" called Bushido. This is of course a straw man, at least at the level of academic history. No serious scholar believes that Japanese people in modern times stuck to a code of ethics set up hundreds of years earlier. Benesch and others are responding to popular ideas perhaps originating from karate school mythology.
Through various inaccurate retellings, the debunking has turned into the idea that "Bushido never existed," which is untrue. Christian Etzrodt, in the article "Nitobe Inazō’s Bushido: Science or Fiction?" provides a detailed account of the classic English language text "Bushido" by Nitobe Inazō, a modern convert to Christianity who was attempting to explain the deep roots of Japanese culture to Americans and Europeans. Etzrodt finds that the virtues Nitobe writes about in "Bushido" correspond well to a group of 29 samurai ethics texts written in premodern times.
The objection is often seen that samurai historically failed to follow these ethical codes, which is a bit of a strange thing to say -- I think any historian would be hard pressed to find a society where an ethical code was always adhered to, and Europe's comparable codes of etiquette and chivalry were often honored in the breach. It has also been claimed that Nitobe purported that there was only ever a single code of samurai ethics, but this is untrue: Nitobe explictly says the opposite in his text.
Nitobe chose to write about Bushido because it has a strong legacy in Japanese culture. A really good example of this is the tale of the Chūshingura, or the 47 rōnin. From the very beginning, Japan's Confucian ethicists struggled to explain how this straightforward tale of revenge could be celebrated to the extent that it was in period society. Neither the letter of the law nor Confucian ethics could justify such extreme revenge. It is generally held that the 47 rōnin were adhering to Bushido principles which were widely accepted in popular culture. (This does not mean they were universally accepted by samurai, but that the controversy helped define bushido; see Henry D. Smith, "The Capacity of Chūshingura", Monumenta Nipponica 58.1) The Chūshingura story has been retold many times as the 47 rōnin were seen as heroes well into the modern period. One three-hour film adaption hit theaters in 1941, and another version arrived in 1962. Both achieved lasting fame even though the political environment was quite different in these two situations, and new productions continued to be made into the 21st century.
In conclusion, to make a European analogy, early modern European ethics were shaped by Enlightenment egalitarianism and liberalism, but also by chivalry, by a code of dueling, and by, like, racism and countless other things. It would be useful to write a book about codes of dueling, but not to misrepresent this as the basis of all European ethics. Similarly, Tokugawa period Japanese ethics were shaped by Neo-Confucianism, by Buddhism, and many other things. Neo-Confucianism certainly fails to explain all of Tokugawa society. "Bushido" is a term that Nitobe and others gave to some ethical concepts taught by premodern samurai clans. It does not encompass all of premodern ethics, was never a set of laws, and certainly was not the sole basis of 20th century politics, but that's different from saying it didn't exist.
I think the most concise way to explain this is by analogy.
Most people in the west would be familiar with the code of chivalry, at least in abstract. Many people would also know that the code of chivalry is a highly romanticized ideal, and not exactly accurate to how the medieval feudal system functioned on a day to day basis.
Bushido is basically the same thing. Though in the last 200 years it would be accurate to say 'Bushido' coalesced into a more definitive, romanticized, ideal it wasn't 'made up.' Bushido defines a range of ideas and ethics that go back a long way in Japan's history. Much like the feudal knights of Europe though, Bushido (like Chivalry) is a very romantic reflection of a much more complex reality.
Much of the modern understanding of Bushido is defined by a small band of sources. Most of them are much more recent than you'd think. The Book of Five Rings, by Miyamoto Mushashi comes from the mid-17th century. Hagakure comes from the early 18th century, written by Yamamoto Tsumetono. Nitobe Inazo's writing is mentioned by another answer and well explained there. His work comes from the mid-19th century.
All of these works have something in common; they were written by Samurai in an age of relative peace, under the Tokugawa Shogunate. In many ways, they're indeed not picture perfect reflections of the Samurai (men from earlier ages hardly seemed to live by them in any rigorous standard), but they are reflections on the Samurai class from a Samurai class that no longer had wars to fight in. Much like the aristocrates of Western Europe, "Bushido" or "the way of the warrior" (whatever we call it), is not a fiction but is a look at the past through a later lens.
Mushashi was among the last generation of Samurai to see warfare in Japan for 200 years. Yamamoto in fact never fought a duel or a war. Nitobe Inazo was trying to explain elements of Japanese culture to westerners. The end result is that a lot of what people call "Bushido" is more a list of stereotypes about the Samurai created by men who were looking back on an idealized period of their history.
The principles it espouses or describes are not fake or made up, but they are highly generalized and often much more complex than the idea of a 'code of the Samurai' would lead on to believe. Much like chivalry.
A notable example of this (and I bring this up to offer a different angle than the other answer provides) is the debate over the actions of the 47 Ronin. While their actions became immortalized and romanticized as an embodiment of the Samurai's ethics on honor, it often gets overlook that in their own time there was extensive debate over whether or not what they did was honorable.
Yamamoto Tsunetomo, the author of Hagakure, actually criticized the Ronin in a surprising way; what if in the 14 months between the death of their lord and the extraction of their revenge, their target died of disease or age? Yamamoto's own answer to the question was that they would have lost their change at revenge and thus would not have regained their honor. Yamamoto discounted the actions of the 47 to a degree because in his eyes they prioritized their own personal desire to succeed in their revenge over the honor of their lord. If their lords honor had really been what mattered, they should have attacked immediately rather than wait.
It's a curiously hardcore opinion, especially from a man who never fought a war or bore arms in battle. Yamamoto was a clerk. He lived in a time when most samurai were not soldiers, but administrators and government functionaries.
So, do we take his opinion as an accurate one based on long ancient Samurai ethics, or do we interpret it a bit more skeptically, as the wistful thinking of a man who wish he lived in an earlier age?
As you can guess, Yamamoto's opinion is not the one that prevails in the popular memory of the 47, but it's an interesting opinion to note. Yamamoto was a contemporary to these events and held a divergent opinion from the one that came to dominate it's memory. Yet, his collected sayings in Hagakure became highly influential in the 20th century as Imperial Japan began idealizing the Samurai and re-romanticizing their military history. When history is romanticized, the reality of things and their complexity is often pushed aside in favor of simpler moral aesops. It's from this process that (which is itself far more complex than this post can fully describe) that "Bushido" as we know it today emerged.
TLDR; Bushido wasn't made up in the past 200 years, but it is in many ways the product of several centuries of romanticizing the past, a process that often simplifies things and swipes away nuances to create images of a rosey ideal.