Skip to content

[core] Share DefaultGenerator's "file was written" step in one helper - #25695

Open
ChihweiLHBird wants to merge 1 commit into
OpenAPITools:masterfrom
ChihweiLHBird:refactor/default-generator-add-generated-file
Open

ChihweiLHBird wants to merge 1 commit into
OpenAPITools:masterfrom
ChihweiLHBird:refactor/default-generator-add-generated-file

Conversation

@ChihweiLHBird

@ChihweiLHBird ChihweiLHBird commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Refactor only; no generated output changes.

DefaultGenerator repeated the same block in eleven places after writing a file: add it to the list of generated files and, unless this is a dry run, pass it to config.postProcessFile with its file type. This replaces those copies with a private addGeneratedFile(files, written, fileType).

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Summary by cubic

Refactors DefaultGenerator so the "file was written" step (adding the file to the generated list and calling postProcessFile unless it's a dry run) lives in a single private addGeneratedFile helper instead of being duplicated across eleven call sites. The generateVersionMetadata path keeps its own block because it tracks a different File instance. No generated output changes. Adds two tests: one verifying the file type passed to postProcessFile for models, APIs, and supporting files, and one confirming postProcessFile is skipped during dry runs.

Written for commit 1b2a2d1. Summary will update on new commits.

View guided diff

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

View guided diff | Re-trigger cubic

DefaultGenerator repeated the same block after writing a file in eleven
places (models, model tests and docs, APIs, API tests and docs, the
three webhook copies, supporting files and the ignore file): add the
file to the list of generated files and, unless this is a dry run, pass
it to config.postProcessFile with its file type. Replace the copies
with a private addGeneratedFile(files, written, fileType).

generateVersionMetadata keeps its own block: it adds
versionMetadataFile (new File(path)) to the list rather than the File
the template manager returns (Paths.get(path).toFile()), and the two
are not guaranteed to be equal on every platform.

postProcessFile had no test. Add two: one pins the file type passed for
a model, an API and a supporting file, the other checks that nothing is
post-processed on a dry run.

No generated output changes.
@ChihweiLHBird
ChihweiLHBird force-pushed the refactor/default-generator-add-generated-file branch from ae22e97 to 1b2a2d1 Compare November 16, 2026 05:16

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant