Swagger is absolutely unrelated to Moodle. If you need help with that go to stackoverflow or some other general public site.
If you need to build REST web service that exposes some Moodle functionality that you should do it in Moodle way:
https://docs.moodle.org/dev/Web_services_API
Clarify what you want to do if you want better response.
If you need to build REST web service that exposes some Moodle functionality that you should do it in Moodle way:
https://docs.moodle.org/dev/Web_services_API
Clarify what you want to do if you want better response.