In a large pot, heat the olive oil over medium heat. Add the chopped onion and cook until translucent, about 5 minutes.
Add the minced garlic, oregano, basil, and red pepper flakes. Cook for another minute until fragrant.
If using dried beans, soak them overnight and rinse well. Add the beans to the pot, along with chicken or vegetable broth, and crushed tomatoes. Bring to a boil, then reduce heat to a simmer.
Simmer the soup for about 30 minutes, or until the beans are tender. If using canned beans, add them and cook for about 10 minutes instead.
Add the pasta and continue to cook until the pasta is al dente, stirring occasionally, about 10 minutes.
Season with salt and black pepper to taste.
Ladle the soup into bowls. Top each serving with grated Parmesan cheese before serving.