Skip to content

Notify build_runner of Dependency on API Spec #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
PvtPuddles opened this issue Apr 11, 2025 · 0 comments
Open

Notify build_runner of Dependency on API Spec #186

PvtPuddles opened this issue Apr 11, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@PvtPuddles
Copy link

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


@PvtPuddles PvtPuddles added the bug Something isn't working label Apr 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant