Burgyn/MMLib.SwaggerForOcelot

Refactor Swagger EndPoint Validation and Improve Options Handling Mechanism

Opened this issue · 1 comments

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

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