I am using openapi-generator to generate api client from swagger json using command similar to below
openapi-generator generate -i http://localhost:5001/swagger/v1/swagger.json -g csharp-netcore -c config.json
Is it possible to generate single client using open api generator for multiple version of Api.
http://localhost:5001/swagger/v1/swagger.json
http://localhost:5001/swagger/v2/swagger.json
I looked at the documentation but couldn't find any reference for the same. Any help on the same or other alternatives. I am creating my api using .net core framework - doesn't really matter for generating clients but as an information if it helps in any way.
Well yes and no. You basically have two API definitions in two different files. Moreover, these files contain API definitions that are similar but not exactly the same: some parameters are new, some old entities have new members (or, worse, lost some members). Some methods are probably not there. You are potentially running into compatibility issues here, so same codebase for two different versions is probably not even possible. Depending on the APIs and your requiments, you can though automate a few things:
Edit: Also why would you need a single client for several versions? I can imagine a single server that supports multiple versions, but client? Wouldn't it be better off by just using the latest version?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With