From Legend, Wikipedia:
In the narrow Christian sense, legenda (“things to be read [on a certain day, in church]”) were hagiographical accounts, often collected in a legendry.
Because saints’ lives are often included many miracle stories, legend in a wider sense came to refer to any story that is set in a historical context but that contains supernatural or fantastic elements.
In 1613, English-speaking Protestants began to use the word when they wished to imply that an event (especially the story of any saint not acknowledged in John Foxe’s Actes and Monuments) was fictitious.[6] Thus, legend gained its modern connotations of “undocumented” and “spurious”, which distinguish it from the meaning of chronicle.
A legend (Latin, legenda, “things to be read”) is a narrative of human actions that are perceived both by teller and listeners to take place within human history and to possess certain qualities that give the tale verisimilitude. Legend, for its active and passive participants includes no happenings that are outside the realm of “possibility”, defined by a highly flexible set of parameters, which may include miracles that are perceived as actually having happened, within the specific tradition of indoctrination where the legend arises, and within which it may be transformed over time, in order to keep it fresh and vital, and realistic. A majority of legends operate within the realm of uncertainty, never being entirely believed by the participants, but also never being resolutely doubted. [1]
Now, one has to consider the historical context: few were literate and many stories were passed down through the generations. This particular story seems not to have been mentioned in writing for a few hundred years after the events; and records do not show that the Pope who dedicated the basilica mentioned it at that time, and so the event does not have sufficient evidence to consider it true, but that does not mean that it did not happen.
After all, who would have thought a story like that up?