During our game, the DM claimed that a sword forged of adamantine would not take any damage from a spell's magical fire. In this instance, it was an animated sword that attacked us, and therefore a creature, no longer just an object. His rationale was that once forged, only certain kinds of damage would affect it, and fire damage was not among them. Does this ruling have a factual basis?
This ruling isn't "standard" D&D5e. (Assuming the GM was using the Flying Sword as presented in the Monster Manual.)
(Of course, this effectively is a homebrewed animated sword. In which case the GM is free to give it whatever damage immunities they would like.)
The Flying Sword (MM p.20) has no immunity to fire. (It is immune to poison and psychic damage, so even in that stat block we can see it'd have been easy to add "fire" to that list, but the developers didn't.)
Additionally, adamantium in 5e traditionally grants the nullification of critical hits, rather than immunity to fire. See DMG p.150, for example.
That said, I've seen this sort of misunderstanding/mistake/mismatch in expectations cause too much grief at tables. I strongly recommend that out of session you take a moment to ask the GM about it, rather than let it fester. And that conversation doesn't have to be confrontational: "hey, that's neat that some materials grant fire immunity--can I quest for some of that and have it crafted into a shield?" can work just as well as "oh, so I guess I'm going to have to have cantrips ready to deal two different damage types, now?"
There is no clear rule that an adamantine animated sword can or can't take damage from magical fire. Reasonable people may disagree as to whether it should, but absent a specific rule, it is at the discretion of the the DM.
The ruling "has a basis in fact" insofar as the DMG account of how objects are effected by different damage types is extremely permissive (DMG p. 246):
Objects and Damage Types: Objects are immune to poison and psychic damage. You might decide that some damage types are more effective against a particular object or substance than others. For example, bludgeoning damage works well for smashing things but not for cutting through rope or leather. Paper or cloth objects might be vulnerable to fire and lightning damage. A pick can chip away stone but can't effectively cut down a tree. As always, use your best judgment.
Note that this doesn't even establish, for example, a hard and fast rule for paper being vulnerable to fire damage. So it is certainly not the case that the rules clearly state that adamantine objects can't be immune to fire damage.
Of course, these rules specifically apply to inanimate objects. You say:
In this instance, it was an animated sword that was attacking us, and therefore a creature, no longer just an object.
I feel that this undercuts your concern over an object's damage resistances/vulnerabilities/immunities. After all, if it is a creature, the Monster Manual isn't the only source of creatures, and the DM can modify a creature's stat block to make it a different creature, or to make an encounter more or less challenging.
Your argument seems to turn on the DM using the construct's object material to make the case that the adamantine sword was immune to fire damage. But construct stats cannot be cleanly derived from object materials. You don't specifically say that the "animated sword" is a Monster Manual flying sword, but let's assume that it is. Steel has a suggested AC of 19, so presumably a flying sword would have an AC of 19 (natural armor) or 21 (natural armor +2 DEX modifier). Instead, the MM flying sword has an AC of 17.
So, either it's a creature, in which case the DM has wide leeway, or it's an object, in which case the DM has wide leeway.
For what it's worth, I probably wouldn't make adamantine immune to fire damage. If it was forged in fire, fire can unmake it (except for artifacts). Maybe resistant? But I also wouldn't spend a lot of time thinking about precise damage types for objects, unless it was really critical to the narrative.
Yes and no.
When the DM is writing up a custom monster stat block -- often by modifying a monster that's in one of the books already -- he can of course add (or remove) any damage resistances or immunities that seem appropriate. We can argue about whether or not the logic behind those immunities is valid, but it's entirely the DM's right to make such determinations.
That said, I'm much less sanguine about the habit some DMs have of hearing what the players want to do and then on-the-fly determining that "oh, that shouldn't work, it's immune to that". To me, once you get into combat, you should run the monster as you've written it; otherwise you risk talking yourself into a lot of bad decisions based on what "makes sense" in that moment, regardless of how it'll impact the actual strength of the creature. This depends largely on your degree of experience as a DM, of course; an experienced DM can often play fast and loose with the rules because they have a strong sense of how much they're affecting the creature's challenge.
As an example, if you've decided that a flying adamantine sword is immune to fire, should it also be immune to Cold as well? Should it resist all physical damage? It's easy to come up with justifications for a lot of resistance and immunity, but it's rarely fun for the players to hear that they just can't really damage this enemy.
From a rules perspective, there's no real reason for Adamantine to be more fire-resistant than steel. That would imply that magic fire used on an animated steel item is actually heating that steel to the melting point, which is probably not sensible. In game terms, adamantine is associated with damaging objects and resisting critical hits. And in any case if you're fighting an animated object, arguably you're mostly attacking the animating magic rather than the physical form of the object.
Your DM created a custom monster.
A custom adamantite flying sword that is immune to fire is reasonable. It wouldn't even have that much impact on its challenge rating.
OTOH, if the DM instead was simply looking for an excuse for a given tactic of a PC to not work on the fly, that is often a bad habit.
As the creator of a world, deciding things don't work for arbitrary reasons is really easy to do, and it results in a "guess the DM's mind" game for Players.