Preheat your oven to 375°F (190°C).
In a large skillet, heat the olive oil and butter over medium heat.
Add the thinly sliced onions and cook, stirring frequently, until they are golden brown and caramelized, about 20-25 minutes.
Add the minced garlic, thyme, and rosemary, and cook for another 1-2 minutes until fragrant.
Sprinkle the flour over the onions and stir to coat.
Gradually add the beef broth, stirring constantly, until the mixture thickens and becomes a sauce.
Season with salt and pepper to taste.
While the onions are caramelizing, season the chicken breasts with salt and pepper.
In a baking dish, arrange the chicken breasts in a single layer.
Pour the onion sauce over the chicken breasts, making sure they are well covered.
Sprinkle the shredded Gruyère or Swiss cheese evenly over the top.
Place the baking dish in the preheated oven and bake for 25-30 minutes, or until the chicken is cooked through and the cheese is melted and bubbly.
Garnish with fresh parsley, if desired.