In addition to the matchup, Swanson will be re-signing with the UFC. The 34-year-old tested free agency after fighting out his previous contract in December, but wanted to remain in the UFC.
This is a rematch from 2014 in which Edgar defeated Swanson by fifth-round submission.
It's a quick turnaround for Edgar (22-6-1), who is coming off the first knockout loss of his career, to Brian Ortega at UFC 222 on March 3.
Fighting out of Toms River, New Jersey, Edgar was originally scheduled to challenge Max Holloway for the UFC title, but Holloway withdrew due to injury. Rather than pull out of the event altogether, Edgar accepted a non-title bout against Ortega and lost via first-round knockout.
Swanson (25-8) is also coming off a loss to Ortega in December. The California native tapped to a guillotine choke in the second round of a UFC main event. Prior to the loss, Swanson had won four in a row.
ESPN ranks Edgar and Swanson the Nos. 4 and 5 featherweights in the world, respectively.