Burgyn / MMLib.SwaggerForOcelot

This repo contains swagger extension for ocelot.
MIT License
354 stars 94 forks source link

Refactor Swagger EndPoint Validation and Improve Options Handling Mechanism #314

Open rabdulatif opened 1 month ago

rabdulatif commented 1 month ago

The current implementation of the AddSwaggerEndPoints method in BuilderExtensions.cs has some areas that can be improved, particularly in terms of argument validation and options management. Below are the identified areas for improvement:

1.Argument Validation in AddSwaggerEndPoints The existing argument validation logic is embedded directly in the method, which increases complexity and reduces code clarity. Refactoring this validation process to use an external validation interface would improve readability and maintainability.

2.Limitations of IOptionsMonitor.OnChange The default IOptionsMonitor.OnChange method only triggers changes based on configuration file (JSON) updates and does not handle options added programmatically at runtime. A custom OnChange handler is needed to address this limitation, allowing the system to respond to both configuration-based options and programmatically added options.

Expected Solution: Refactor the AddSwaggerEndPoints method to utilize an IEndPointValidator interface for cleaner and more modular validation logic. Implement a custom OnChange handler to handle changes for both configuration-based options and programmatically added options, ensuring dynamic updates work seamlessly across both scenarios. This improvement will lead to more maintainable code, greater flexibility, and improved options management within the application

rabdulatif commented 1 month ago

Hello @Burgyn Could you help? After this i will deploy my project to the server