Description
Description of the bug
There is a work-around in-place for the Openapi
annotation: forceAlwaysRun
.
From the docs:
If true, the annotated file will be modified after code generation completes.
This is a workaround to ensure this library runs every time you execute the build_runner command.
Why modify the file?
build_runner only processes files that have changed since the last run. By modifying the file, you force build_runner to recognize it as changed and re-run the generation process.
Note: Setting this to true can lead to merge conflicts in team environments, as each developer may end up modifying the annotated file.
It is not necessary to run the builder every time build_runner
is called; users only need to run it when the API spec changes.
If the spec file can be loaded by build_runner
(IE: the spec file is in the lib directory of the annotated package), the builder should notify build_runner
the file is read. See this discussion.
Steps to reproduce
To reproduce the issue, use the Openapi
annotation and make sure forceAlwaysRun
is set to false.
Modify the API Specification and run dart run build_runner build -d
. Observe that the Openapi
generator is not run.
Minimal openapi specification
N/A
Annotation used
@Openapi(
additionalProperties: DioProperties(
pubName: "my_package",
pubAuthor: "myself",
),
generatorName: Generator.dio,
inputSpec: InputSpec(path: 'lib/src/services/mp_package/my-open-api.yml'),
outputDirectory: 'generated/my_package',
forceAlwaysRun: false,
skipIfSpecIsUnchanged: false,
)
Expected behavior
The generator should be re-run every time my-open-api.yml
is modified, without having to update the "Generator last run: ..." timestamp.
Logs
Screenshots
No response
Platform
macOS
Library version
6.1.0
Flutter version
3.29.2
Flutter channel
stable
Additional context