Bug Report Checklist
Description
Generating samples for rust-axum using ./bin/generate-samples.sh bin/configs/manual/rust-axum-* leads to the manually written tests getting overridden with the default implementation.
Theoretically, this line of code should prevent this for occurring, but the tests get reverted to the default regardless.
Tests in rust need to be present on the generation template due to how cargo test checks for tests on the library, as they cannot be made independent outside the src folder unlike other forms of testing such as cargo bench.
This behaviour is problematic as it makes updating the rust-axum samples in future updates more annoying that it could be, as the tests need to be manually reverted after being overriden by the generator, not to mention the issues that could occurr if someone forgets to do so.
A curious behaviour that happens is that while the command is running, the manually made tests get formatted before getting overwritten shortly after. This may be due cargo fmt getting called multiple times while the source is still being generated, but I thought it was worth noting in case the override is done at a later stage.
openapi-generator version
This is an issue introduced on 3d65786 for 7.11.0 and it is not a regression.
OpenAPI declaration file content or URL
Any declaration will do, but currently the issue is present on the 2 tests implemented in the commit:
Generation Details
The issue is exclusive to the rust-axum generator with the default options. See the reproduction steps listed below.
Steps to reproduce
Run:
./mvnw clean
./bin/generate-samples.sh bin/configs/manual/rust-axum-*
- See how both manually written tests get restored to the default
tests.rs template.
Related issues/PRs
This was pointed out in a review on #20336 and a comment was left on the source code to acknowledge the issue.
Suggest a fix
I was not able to find a way to prevent this behaviour other than calling doNotOverwrite(), which is already being done and it makes no difference.
Bug Report Checklist
Description
Generating samples for
rust-axumusing./bin/generate-samples.sh bin/configs/manual/rust-axum-*leads to the manually written tests getting overridden with the default implementation.Theoretically, this line of code should prevent this for occurring, but the tests get reverted to the default regardless.
Tests in rust need to be present on the generation template due to how
cargo testchecks for tests on the library, as they cannot be made independent outside thesrcfolder unlike other forms of testing such ascargo bench.This behaviour is problematic as it makes updating the
rust-axumsamples in future updates more annoying that it could be, as the tests need to be manually reverted after being overriden by the generator, not to mention the issues that could occurr if someone forgets to do so.A curious behaviour that happens is that while the command is running, the manually made tests get formatted before getting overwritten shortly after. This may be due
cargo fmtgetting called multiple times while the source is still being generated, but I thought it was worth noting in case the override is done at a later stage.openapi-generator version
This is an issue introduced on 3d65786 for
7.11.0and it is not a regression.OpenAPI declaration file content or URL
Any declaration will do, but currently the issue is present on the 2 tests implemented in the commit:
Generation Details
The issue is exclusive to the
rust-axumgenerator with the default options. See the reproduction steps listed below.Steps to reproduce
Run:
./mvnw clean./bin/generate-samples.sh bin/configs/manual/rust-axum-*tests.rstemplate.Related issues/PRs
This was pointed out in a review on #20336 and a comment was left on the source code to acknowledge the issue.
Suggest a fix
I was not able to find a way to prevent this behaviour other than calling
doNotOverwrite(), which is already being done and it makes no difference.