...
Now the question is how to keep the Swagger documentation up to date,
There was an idea to try to generate the OpenAPI specification from the scratch from recent sources (by ignoring the existing XML Documentation comments) but currently this is not possible by means of GitHub Copilot because :
- it is not possible to schedule this action from outside the IDE (GitHub Copilot does not have its own command line interface).
- it is not possible to generate OpenAPI specification for bigger contextual scope (I've tried it for a smaller controller but for multiple controllers or the entire solution it would definitely not produce any usable result)
- sources are not optimized for that, it would be necessary to refactor all parts where optional query parameters and request body are parsed dynamically (GitHub Copilot is only able to recognize them if they are defined as method parameters)
I can try to investigate if any other tool could be used for that but for now I do not have any solution for that.
Other option would be to ask developers to keep the XML Documentation comments up to date whenever making changes in the source code. There is no need to generate the comments again, just add response code or query parameter into XML comments if needed, or modify the existing <remarks> section to keep the method description up to date.
Recommendations for developers
- please keep the documentation up to date by yourself, it is a responsibility of each developer to keep the documentation aligned to recent source code changes
- add or modify the <response> tag(s) and[ProduceResponseType] attribute(s) in the existing XML comments according to recent source code changes
- add or modify the [QueryParameter] and/or [QueryParameters] attribute in the existing XML comments if needed
- add the [SwaggerOperationFilter] attribute into the existing XML comments if optional request body is needed
- modify the <remarks> section in the existing XML comments according to recent changes in the method behavior
- generate the XML Documentation comments for newly created API endpoint(s) using GitHub Copilot as described above