Can you share more details (or write a blog post π)? How do you generate the code? Are you using some library? What structure does apiOptions have?
I have a similar solution, but I wrote the generator myself. I'm not sure if I did it completely right, though.