OpenAPITools / OpenAPITools/openapi-generator

[REQ] Generated date should be reproducible (or disabled by default)

Open
#21,066 3 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Is your feature request related to a problem? Please describe.

To meet the requirements of Reproducible Builds, generated timestamps should be predicable (so that packages can be rebuild with the same source and produce the same output)

Describe the solution you'd like

For projects using the Maven plugin, this could mean that the generatedDate would be set to Maven's project.build.outputTimestamp property.

https://github.com/OpenAPITools/openapi-generator/blob/6da343a8ad1176875f27e7a4465164646574dc3d/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java#L289

Gradle's approach to this is to use a fixed date:
https://github.com/gradle/gradle/blob/f4fcd0b4f2c6a1903f80a4299a540d73d722f127/platforms/core-runtime/files/src/main/java/org/gradle/api/internal/file/archive/ZipEntryConstants.java#L24-L39

Describe alternatives you've considered

Alternatively configOptions.hideGenerationTimestamp could be set to true by default.

Another alternative would be to use the timestamp of the openapi spec file. There are a lot of edge cases around this, the file could be downloaded and timestamp not preserved, file could be copied at build time (and timestamp not preserved). Additionally, other inputs to the generator could change resulting in different code using the same source spec. So this probably isn't a valid option.

Additional context

See:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java around line 289 and trace how generatedDate is set for Maven plugin users. Compare using Maven's project.build.outputTimestamp with disabling the timestamp by default, then define and verify behavior where repeated builds from the same inputs produce identical output.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.