The description either tells you the weapon type, or leaves it up to the DM.
We see in the Dungeon Master's Guide, chapter 7, the section "Magic Item Categories", subheading "Weapons", pg. 140:
Some magic weapons specify the type of weapon they are in their descriptions, such as a longsword or longbow. If a magic weapon doesn’t specify its weapon type, you may choose the type or determine it randomly.
So we see in the description of the Dragon Slayer:
Weapon (any sword)
So you decide what type of sword this is when you give it to a player character. In contrast, some items are more specific, such as the Dagger of Venom, which says in its description:
And some weapons don't specify at all, such as the description of the Hellfire Weapon in Baldur's Gate: Descent into Avernus:
Once you have have decided what type of weapon a particular magic weapon is, it uses the usual damage dice stated in the Weapons table in chapter of 5 of the Player's Handbook.
That said, it should be noted that some magic weapons add additional damage dice to the weapon's attacks, such as the Flame Tongue:
While the sword is ablaze, it deals an extra 2d6 fire damage to any target it hits.
So a blazing Flame Tongue Longsword would deal 1d8 slashing + 2d6 fire damage on a hit (plus relevant modifiers).
Finally, though the rules do assign specific weapon types to many magic weapons, you probably aren’t going to break anything if you go off-script and change the weapon types to whatever you want.