REST API

Openapi really rocks. I have used it at work and it was the first time in my professional career that I truly had a formal specification that I could turn into code. At openapi-generator.tech you can find generators for almost all programming languages. I use it to generate client code for testing the API.

You find the full API specification in REST/openapi.yml Using the swagger editor you can even execute the API calls.

While in another project I also used it to generate server code for pistache I opted against generating server code for DigitalRoosterGui. I came to the conclusion that the generated C++ code was not something I wanted to integrate. Partially because it uses a different JSON library, partially because I couldn’t get the generator to use the classes I already had (Alarm, PodcastSource etc.).

But still it works really nice using curl to manipulate the lists. You can find out more in documentation/rest.md

One small example of how to add a radio station:

 curl -X POST localhost:6666/api/1.0/radios/ \
    -d "{\"url\":\"http://foo.bar\", \"name\":\"FooRadio\"}"