Search code examples
angulartypescriptswaggerocelot

Generate api and models in TS with openapi-generator-cli from multiple definitions from ocelote


I'm trying to setup a dotnet micro-service backend with a gateway using Ocelote. Doing this as described, Ocelote provides me with multiple swagger definitions (for each micro-service)


Since the API now has multiple definition, each definition has its own defining json file.

How can i generate the API services and Models using openapi-generator-cli in this case. Previously i only had one definition which i generated with the command below, passing it the published json file directly

openapi-generator-cli generate -g typescript-angular -o ./openapi -i http://localhost:xxxx/swagger/docs/v1/project

Additionally how should those definitions be used? Should the services even be split up like this?


Solution

  • Since there was no fitting tool for my problem or an answer for 6 months, i decided to write an open source tool myself. It is still a WIP but it may already be enough for you, just like it is for my current needs.

    Basically what it does is detecting the swagger definitions, merge them and then run the openapi-cli-generator. At the end there are no duplicate files and a single Configuration. For more details on how what it does and how you can set it up check it out on Github https://github.com/Deitsch/angler.

    If you find any bugs or unhandled edge cases please contribute via Github!

    brew tap deitsch/angler
    brew install deitsch/tap/angler
    

    EDIT
    It also includes a fix for openapi-generator/issues/10864 until an official one is released
    Has been fixed in the openapi-generator and the fix removed from angler