The Player's Handbook only describes that a melee attack is allowed when making an Opportunity Attack. Does this only mean melee weapon attacks, or does it allow some spells? Also assuming that if it does, then only spells with a casting time of 1 action, right?
[RPG] use a spell to make an Opportunity Attack
dnd-5eopportunity-attackspells
Best Answer
To cast a spell as an Opportunity Attack, you have to pick up the War Caster feat:
There's a more detailed explanation of in the Sage Compendium:
Having said that, if for some reason you cannot pick up War Caster (e.g., GM won't allow feats), the bolded section hints at different ways to use your spell casting ability to improve your OAs (thanks to @Darth Pseudonym for the pointer!). Namely, as long as the spell (or its effect) doesn't require an action, you can use it as part of your OA.
A few examples, available depending on your class: Shillelagh, Alter Self, Elemental Weapon, Magic Weapon.
These will, at best, improve your OA's to the level of most martial classes, but will clearly be inferior to War Caster (even a lowly cantrip will do more damage than many of these spells, as soon as you hit L5). Hence, I only mention these if War Caster is not an option.