yonaskolb / SwagGen

OpenAPI/Swagger 3.0 Parser and Swift code generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add a `--use-cache` option to `generate` command

liamnichols opened this issue Β· comments

Background

πŸ‘‹ I'm currently thinking of introducing SwagGen into our project and I am trying to work out the best developer experience when it comes to integrating. So far, I am looking to decide between the following options:

  1. Commit generated source to Git, run SwagGen on-demand whenever the spec needs updating
  2. Commit OpenAPI spec to Git, run SwagGen as part of workspace generation script repeatedly

I'm leaning towards option 2, since this fits in nicely with other tools we use such as XcodeGen and CocoaPods but when evaluating SwagGen, the one thing that I noticed was that for our beefy spec, it seems to take a while to generate the output and if we were to integrate SwagGen as part of our workspace generation process, we'd be running the command numerous times a day when in reality the generated sources will likely change very infrequently.

For this reason, an option to bypass the generation in the event that the inputs (template, options, spec) haven't changed would be super beneficial to me and hopefully other users of the tool.

Description

With the above in mind, I am proposing the introduction of a --use-cache option that operates in a very similar way to the one that exists in XcodeGen.

Before I dig further into implementing such functionality, I first wanted to check if this makes sense for the direction of the tool? Additionally if it does make sense, I want to check that the caching system in XcodeGen is the best approach in retrospective? From my perspective it seems to do the job well, but you might have better insights after implementing it once already that I am unaware of πŸ˜„

I imagine that this can integrate into GenerateCommand also. I did however wonder if there was the opportunity to extract some of the implementation from XcodeGen into its own library to share it? Although it looks relatively small anyway so maybe this is overkill, I'm not sure πŸ˜…

I think the one difference might be that with SwagGen, I want to be able to fingerprint the template directory files to detect if they have been modified whereas XcodeGen doesn't care about the file contents that it tracks.

Anyway, please let me know your initial thoughts @yonaskolb. I'd be happy to think through a more detailed plan and take the implementation on if the overall idea makes sense. Thanks!