WLED icon indicating copy to clipboard operation
WLED copied to clipboard

Add OpenApi support (formerly Swagger)

Open RobThree opened this issue 2 months ago • 0 comments

It would be really cool if the json api also served a (static) swagger.json file which would make 'discovering' and more importantly implementing the API a lot simpler (automatic client generation on most plaforms and languages). It also serves as (machine readable) documentation. Adding a (also static) swagger-UI would be extra bonuspoints.

Basic steps:

  • [ ] Write the swagger.json
  • [ ] handle the /json/swagger.json request by serving the static file (I guess here somehwere)
  • [ ] (Optional) Also serve the required (static) swagger-ui files

Ofcourse, this would mean that when changes are made to the api this document needs to be kept in sync. But I do really think it would be worth the effort.

This would require some storage, naturally, but the files can be saved pre-gzipped (or brotli or whatever is hot nowadays) and served as-is (with the correct headers).

I could (help with) write the swagger.json file, but I'm not sure on the other two steps. If anyone is interested in helping or teaming up I would love to prepare a PR. But if there's no interest then I won't make all these efforts in the first place. So: is there interest?

RobThree avatar Apr 28 '24 01:04 RobThree