Some fantasy is certainly based on mediaeval Europe, from William Morris to George R. R. Martin, but it's only one of many models that traditional fantasy authors have used (though it's undeniable that most have been centred on Europe or the Middle East).
Tolkien is often cited as an author who uses a mediaeval model, but in fact there's very little mediaeval, as usually understood, in Lord of the Rings. The Shire is an idealised version of 19th century England without guns; Rohan is early Anglo-Saxon; the Dwarves are ancient Norse; Gondor has a distinctly Babylonian feel, although I suspect Tolkien was going for Solomon's Israel; and some of the other cultures, such as Lorien, have no real-world model.
Similarly, most of the pulp fantasy of the 30s and 40s, such as the Conan stories, tend to be set in a mashed-up imagining of the classical world and the pre-classical Middle East. Fafhrd and the Gray Mouser's environment, on the other hand, had a lot in common with the Renaissance Mediterranean. And so on. Some mediaeval influence was there, but it was only one type of setting among many.
The problem seems to be that it's often assumed any time before gunpowder is mediaeval, but really the term only refers to a few hundred years (for part of which gunpowder was in use) on one of the world's smallest continents. To give some sense of perspective, besides Europe, civilisation has existed (before modern colonisation) in Asia, Africa, North America and South America**, and the earliest known civilisation (i.e. people living in a city) was over 11,000 years ago in the town later known as Jericho.
In reality, the Middle Ages (also known as the mediaeval period) didn't exist. It was a sneering term coined in the Renaissance to dismiss western Europe between the fallen of the classical world (good) and the birth of the new age (nearly as good). In the same way, the sometimes exquisite art and architecture of the period was described as Gothic, implying it was the work of barbarians.
The period the Renaissance scholars thus consigned to the scrapheap actually covers many different cultures, over both its timespan and its geographical distribution, although there are certain generalisations that can be made.
There isn't even any clear agreement as to when it started or finished. To some extent, of course, all historical periods are just convenient places for historians to start and finish their books. Some periods have more obvious beginnings and ends, but it's rare to have such a significant change that people living at the time would notice it.
My own view, with all possible disclaimers in place, is that the Middle Ages (to the extent that they existed at all) started in 732 AD*** and finished in 1453. On a Tuesday. At teatime.
Everyone knows that the Roman Empire fell in the 5th century. Except that it didn't. The Roman Empire had been changing and evolving throughout its lifetime, most obviously after the reforms of Diocletian (right) in the late 3rd century, and by this time it consisted mainly of barbarian warlords controlling their own territories and paying nominal fealty to the emperor. When the last western emperor was deposed in 476, they just carried on the same way, except that they paid even more nominal fealty to the eastern emperor in Constantinople, where the Roman Empire continued till the 15th century.
For the most part, the barbarian warlords were proud of being part of the empire — they fought the legions internally, as when the Emperor Honorius double-crossed the Visigoths and they besieged Rome, but they'd no wish to tear it down. Well, except for the Huns, but they were a rival empire, not a ravening horde.
Nothing substantially changed. Civilisation and culture had been declining through the later part of the imperium and continued to do so, but western Europe didn't really move on to anything new till the Frankish leader Charles Martel (below) smashed the Moors at the Battle of Poitiers in 732.
There are two reasons why this was crucial. For one thing, although Charles was never actually king of the Franks, his son was crowned and his grandson became Charles the Great — Charlemagne. By the time the Carolingian dynasty had played out, only a few generations later, the map of Europe had changed, the first signs of our modern nations were stirring, and the concept of empire had been updated.
The second reason was the reason why Charles Martel had won the battle: a radical new type of fighting-man he'd copied from the Byzantine Empire, called the knight.
Aristocrats in older civilisations are sometimes described as knights, but this is retrospective. The knight as we know him first arose in Persia, due to the introduction of stirrups, which made heavy cavalry possible for the first time. Unfortunately, the equipment and, in particular, the great war-horses were expensive to keep up. The Persians solved the problem by imposing crippling taxes on the cities, with the result that, when the Arabs invaded, the cities opened their gates and went over to a more reasonable enemy.
The Byzantines, learning from this, came up with a new idea: to give each knight a parcel of land and let him pay his own way. It was this concept Charles adopted, and so the feudal system was born.
The feudal system was, if anything was, the central institution of the Middle Ages, and any fantasy setting that doesn't have it can't be described as mediaeval. In reality, it was two separate but complementary systems. One was a contract the king made with his nobles and knights, whereby he granted them land and they undertook to fight for him when called on. In fact, many knights were more interested in running their estates, and it became increasingly common during the period for knights to pay money in lieu of service, which the king would use to hire mercenaries.
The other, which had existed since the later Roman period, was manorial serfdom. Serfs were distinct from slaves in that, though they weren't free to leave or refuse to work, they belonged to a manor, not to a person. They had rights, too, although that varied considerably from kingdom to kingdom. English serfs tended to have most rights. The feudal system wasn't used in England till after 1066, and many of the people's ancestral rights were restored a few decades later. Serfs in other kingdoms were usually a lot worse off, but the lord of the manor didn't legally have power of life or death over them. Though the question was whether anybody bothered with the law.
And what about the end of the Middle Ages? 1453 was the year that Constantinople, the last remnant of the Roman Empire, fell to the Turks. The immediate significance was that many scholars and artists fled to the west, fuelling the already growing Renaissance in learning and the arts.
In fact, the Renaissance wasn't a sudden development, and the Middle Ages weren't quite as bleak a period for learning as they're often painted, although certainly a low point. Knowledge had been seeping in, especially from the Islamic world, at that time the most culturally advanced civilisation in the west. Art certainly took a huge step forward in the Renaissance, but it's been suggested that the biggest academic change was that they started following Plato instead of Aristotle.
Besides the Renaissance, though, the mid-15th century marks a point where most of the characteristics of the age that followed were already being established. Gunpowder had come to stay and was making the transition from field guns to hand guns, rendering knights obsolete. Gutenberg was setting up his printing press in Mainz, and the voyages of discovery were well under way, with the Portuguese venturing down the African coast en route to India, leading the Spanish eventually to try another direction.
Social mobility was growing, too, as was religious dissent. Neither were anything like as absent from the Middle Ages as is often assumed, but both increased immensely after the Black Death. The mediaeval Church was either divided or powerless for much of the period, and there'd been radical preachers from at least the 12th century saying essentially the same as Luther did four hundred years later. By the 15th century, religious movements led by Wycliffe, Ball, Huss and many others became bigger and better organised. Luther was just the most successful of these.
There had been towns and cities throughout the Middle Ages, and industries had flourished there. It wasn't easy to escape from serfdom, except by going into the Church, but those who did had the chance of getting rich. Again, after the Black Death the feudal restraints became untenable, due to the shortage of manpower making labour a marketable commodity. The powers that be fought a long rearguard action against change, but it was becoming inevitable.
The Middle Ages were a long and varied period, even leaving out everything that was happening outside western Europe, and almost everything changed in their course. The armour worn by knights, for instance, went from ring-mail sewn onto leather to the familiar suits of plate armour (which were not too heavy to manoeuvre in), driven by changing weapon technology.
At any given time, none of the typical mediaeval institution were present everywhere, and some areas — Scandinavia, for instance — were barely affected till very late in the period.
So, if you want to create a fantasy setting "based on the mediaeval period", by all means do — you'll be in good company — but decide what you actually mean by that, and do plenty of research on the specific country and era that interests you. On the other hand, if all you want is for your hero to wield a sword or use a bow and arrow, you have an entire world and eleven thousand years of civilisation to choose your model.
** Pre-settlement Australia can't really be described as civilised, though that doesn't make its cultures any less rich and fascinating.
*** Yes, I use BC and AD, which have served perfectly well for the past 1500 years. Get over it.