As your post is a little vague, it's hard to give an accurate diagnosis/advice online. I'd suggest you see a physio (if your GP can refer you) as the pain has been there for a few months and as far as I know (please correct me if I'm wrong more experience physios), GPs can sometimes tend to diagnose musculoskeletal problems that they aren't very experienced in because they are triage, so always better to get it checked over by someone with more thorough knowledge.
Sounds like there's definitely an inflammatory component due to the recurrent swelling and pain you're getting....seems to be patellofemoral pain (to do with the kneecap). Possibly bursitis? Bursae are small sacs of fluid that cushion the joints and can become inflamed and swollen due to direct trauma or abnormal forces (e.g. if your walking pattern is altered/ muscles are slightly imbalanced). Have you tried any supports or worn any compress like tubigrip on your knee? If so, does this help? Might be all you need to keep going with things, but I'd stand by getting a second opinion and seeing a physio - may be that they can give you some treatment or advice that will speed things along for you.