How can a group find out how to break Imprisonment?

Mario the Magic Plumber was captured by a big dragon named Bowser one thousand years ago. He used Imprisonment on him and made him sleep for one thousand years. Only the kiss of a real princess could break the curse. How can my group learn about the condition (kiss of a real princess)? I am more familiar with “Das schwarze Auge” and there is a spell called “Analysis” which tells you what kind of spell is laying on a person and how to break it. Is there something like this in D&D? Would detect magic be enough?

During the casting of the spell, in any of its versions, you can specify a condition that will cause the spell to end and release the target. The condition can be as specific or as elaborate as you choose, but the DM must agree that the condition is reasonable and has a likelihood of coming to pass. The conditions can be based on a creature’s name, identity, or deity but otherwise must be based on observable actions or qualities and not based on intangibles such as level, class, or hit points.