Skip to content
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

[BUG] Cannot generate chopper file #515

Closed
langtu200987 opened this issue Dec 7, 2022 · 5 comments
Closed

[BUG] Cannot generate chopper file #515

langtu200987 opened this issue Dec 7, 2022 · 5 comments
Assignees
Labels
bug Something isn't working Triage needed

Comments

@langtu200987
Copy link

Describe the bug
When I run: flutter packages pub run build_runner build --delete-conflicting-outputs
The swagger file is generated but chopper file can't be generated. The log show:
flutter packages pub run build_runner build --delete-conflicting-outputs
[SEVERE] chopper_generator on lib/swagger_generated_code/swagger.swagger.dart:

line 1, column 8192 of package:azota_teacher/swagger_generated_code/swagger.swagger.dart: Could not resolve annotation for {required int? id}.

1 │ @path('id')

and
[WARNING] json_serializable on lib/swagger_generated_code/swagger.swagger.dart:
Could not read the "pubspec.yaml` file associated with this package. Usage of package:json_annotation could not be verified.

To Reproduce
pubspec.yaml
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
webview_flutter: ^3.0.4
chopper: ^5.1.0
json_serializable: ^6.1.4
json_annotation: ^4.7.0

dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
swagger_dart_code_generator: ^2.8.7
build_runner: ^2.3.2
chopper_generator: ^5.1.0+1

build.yaml
targets:
$default:
sources:
- lib/**
- input_folder/**
- $package$
builders:
chopper_generator:
options:
header: "//Generated code"
swagger_dart_code_generator:
options:
input_folder: "input_folder/"
output_folder: "lib/swagger_generated_code/"
build_only_models: false
with_base_url: false

input_urls: ["https://prodazt_main.textandtool.com/swagger/api-mobile-v1/swagger.json"]

swagger: https://prodazt_main.textandtool.com/swagger/api-mobile-v1/swagger.json

@mfrischbutter
Copy link
Contributor

Hey @langtu200987
To fix the Warning you should add your pubspec.yaml to your build.yaml

[WARNING] json_serializable on lib/swagger_generated_code/swagger.swagger.dart:
Could not read the "pubspec.yaml` file associated with this package. Usage of package:json_annotation could not be verified.

Example build.yaml

targets:
  $default:
    sources:
      - lib/**
      - swaggers/**
      - swaggers2/**
      - input_folder/**
      - swagger_examples/**
      - $package$
      - pubspec.yaml

@Vovanella95
Copy link
Collaborator

@mfrischbutter I've faced with such problem too. But I don't remember how I solved it. Try to launch terminal with Administrator rules maybe

@mfrischbutter
Copy link
Contributor

@Vovanella95 I'm fine. I just provided a solution for his issue :) I think there is no need to start the terminal as Administrator.
I faced the same Warning as i started working with this package. Maybe we should add this line to the example build.yaml.
I'm working on a Mac, so there is basically no admin except for sudo.

Idk how you manage to get the generator running, but without this line, i will get the Warning every time.

targets:
  $default:
    sources:
      - pubspec.yaml

@Vovanella95
Copy link
Collaborator

@mfrischbutter ahh thanks!

Vovanella95 pushed a commit that referenced this issue Dec 16, 2022
Vovanella95 added a commit that referenced this issue Dec 16, 2022
* Fixed baseUrl type (Issue #515)

* Fixed generation of nullable fields (Issue #506)

Co-authored-by: Uladzimir Paliukhovich <uladzimir_paliukhovich@epam.com>
@Vovanella95
Copy link
Collaborator

Hi, root issue about required int? id is not reproduced. Closing the issue.

Vovanella95 added a commit that referenced this issue Dec 16, 2022
* Fixed baseUrl type (Issue #515)

* Fixed generation of nullable fields (Issue #506)

* Fixed generation of @OptionalBody()

* Updated pubspec and changelog

Co-authored-by: Uladzimir Paliukhovich <uladzimir_paliukhovich@epam.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Triage needed
Projects
None yet
Development

No branches or pull requests

4 participants