Fixes for broader compatibility
This PR contains a handful of fixes for compatibility with the OpenAPI spec.
My target API yaml was from a 3rd party API, so I didn't have the liberty to change the structure of the file (though I did fix some bugs in it. The yaml file is for the Binance Client API. The bug-fixed version of their doc is here https://github.com/rrichardson/coinnect_codegen/blob/main/binance_spot_api.yaml
Here is an incomplete list of the compatibility fixes:
- Request contents might not contain an
operationId
(so synthesize one from the path and method) - Request parameters might be
$ref
- Request parameters might have their own complex sub-objects (requiring >schema)
- Responses might contain a content schema with an empty object (annoying, but valid)
- Enum values might be case sensitive (e.g. M and m in the same set of enums (for dates, etc)
- Enums might start with numbers
For everything except fixing up the operationId and the parameters $ref
features, everything is implemented via changes to the templates and the addition of some rust-specific helpers.
Synthesizing the operationId was just easier for me to do in Rust. It's pretty simple and I think it's a fundamental piece, so I'm OK with it being in the core part of the generator.
As far as resolving the $refs for parameters, I did it in Rust because I'm not a master of handlebars and it was much easier for me to do it in Rust. However, there are other examples of doing similar in hbs code.
Also note that compiling server
against the above YAML file still produces hundreds of errors. I am not interested in code-genning a server, only a client, so I haven't fixed up the server templates yet.