apple / swift-openapi-generator

Generate Swift client and server code from an OpenAPI document.
https://swiftpackageindex.com/apple/swift-openapi-generator/documentation
Apache License 2.0
1.45k stars 120 forks source link

Check for updated spec before generating #584

Closed OurBigAdventure closed 4 months ago

OurBigAdventure commented 4 months ago

Motivation

For a large API spec, generating the code can take a long time. Each time a build happens the code gets re-generated and that makes development and testing a slow process.

Proposed solution

It seems simple enough to check the modified date of the spec file (or config file) and if it is older than the date of the generated code file(s) then skip the generator because the spec hasn't changed.

This way the generator only runs if:

Alternatives considered

Disable the plugin for development and try to remember to re-enable it for any release builds.

Additional information

No response

czechboy0 commented 4 months ago

Hi @OurBigAdventure,

this is how build plugins, and thus Swift OpenAPI Generator's build plugin, already work today. If you're seeing reruns of the generator when none of its inputs have changed, can you provide more diagnostics or repro steps? Thanks

OurBigAdventure commented 4 months ago

Just tested in my updated project and it appears that is the case. The issue was coming from that old project where I had the strange errors, I'm just going to finish the migration from that project and ignore the strange behaviors.

Thanks for the quick reply!