Preheat oven to 350°F
Chop onion
Cook spaghetti according to directions
Drain spaghetti
Preheat olive oil in skillet over medium-high heat
Cook Italian sausage and onion in preheated skillet until meat is no longer pink
Drain meat and onion mixture
Add mushrooms, tomato sauce, tomato paste, sugar, garlic powder, and dried oregano to meat mixture
Stir pasta into meat sauce
Spray casserole dish with cooking spray
Transfer pasta and meat mixture into the casserole dish
Top mixture with mozzarella cheese, pepperoni, and parmesan cheese
Cover the casserole dish with foil
Bake for 20 minutes in preheated oven
Remove foil
Bake 15 minutes more
Serve