"Just the Way You Are" was written by Bruno Mars, Philip Lawrence, Ari Levine, Khalil Walton, and Khari Cain (The Smeezingtons) for Mars' debut album Doo-Wops & Hooligans (2010).
Glee covered it in Season 2, Episode 10 ("A Very Glee Christmas," 2010) — sung by Finn (Cory Monteith) to Rachel. The show licensed the track; it didn't create it. This is a common misconception because Glee popularized many songs for younger audiences, but the songwriting credits are unambiguous.