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

[QUESTION] Chooper 4.x.x? #248

Closed
masseelch opened this issue Sep 22, 2021 · 14 comments · Fixed by #250
Closed

[QUESTION] Chooper 4.x.x? #248

masseelch opened this issue Sep 22, 2021 · 14 comments · Fixed by #250
Assignees
Labels
question Further information is requested

Comments

@masseelch
Copy link

Please describe a problem.
I am wondering: Current published version is flaged as nullsafe but is using a non-nullsafe version of chopper (3.x) while there already is a published nullsafe version (4.x).

Describe the solution you'd like
Clarify whether 4.x is supported and if so update the readme.

@masseelch masseelch added the question Further information is requested label Sep 22, 2021
@Vovanella95
Copy link
Collaborator

Hi @masseelch , We're not using chopper to generate our code. You can use latest version of our generator and latest version of chopper at the same time. Where did you found chopper 3.x version?

Please find our our example https://github.com/epam-cross-platform-lab/swagger-dart-code-generator/blob/master/example/pubspec.yaml

So because we already support null-safe version, I'm not going to update Readme. It's fine?

@masseelch
Copy link
Author

Chopper started to use null-safety with version 4.0.0. With the constraints given in the current readme the user will not get 4.0.x but the not null-safe version 3.0.6.

I did not know I can use the generator without generating chopper. This works for me :-)

@masseelch
Copy link
Author

The example does not compile though 😢

» flutter pub run build_runner build
[INFO] Generating build script...
[INFO] Generating build script completed, took 542ms

[WARNING] Invalidated precompiled build script due to missing asset graph.
[INFO] Precompiling build script......
[INFO] Precompiling build script... completed, took 1.4s



You have hit a bug in build_runner
Please file an issue with reproduction steps at https://github.com/dart-lang/build/issues


Bad state: No element
dart:core                                                                   Iterable.first
package:swagger_dart_code_generator/swagger_dart_code_generator.dart 37:20  _generateExtensions
package:swagger_dart_code_generator/swagger_dart_code_generator.dart 51:32  SwaggerDartCodeGenerator.buildExtensions
package:build_runner_core/src/package_graph/apply_builders.dart 400:33      _validateBuilder
package:build_runner_core/src/package_graph/apply_builders.dart 181:9       new BuilderApplication.forBuilder.<fn>.<fn>
package:build_runner_core/src/package_graph/apply_builders.dart 343:27      _createBuildPhasesForBuilderInCycle.<fn>.<fn>
dart:core                                                                   Iterable.toList
package:build_runner_core/src/package_graph/apply_builders.dart 290:8       createBuildPhases
package:build_runner_core/src/generate/build_impl.dart 110:29               BuildImpl.create
package:build_runner_core/src/generate/build_runner.dart 34:42              BuildRunner.create
package:build_runner/src/generate/build.dart 109:35                         build
package:build_runner/src/entrypoint/build.dart 35:18                        BuildCommand._run
package:args/command_runner.dart 209:13                                     CommandRunner.runCommand
package:build_runner/src/entrypoint/run.dart 26:18                          run
.dart_tool/build/entrypoint/build.dart 31:16                                main

pub finished with exit code 1

@Vovanella95
Copy link
Collaborator

@masseelch did you find out why example not compiles? Any questions?

@masseelch
Copy link
Author

masseelch commented Sep 22, 2021

No I did not look any further. I think I won't use this package. There are some things, that bother me, to be honest:

  • Outdated readme
  • Examples don't compile Was my mistake, sorry.
  • Does not follow naming conventions on spec file (openapi.json -> *.swagger has been deprecated a while ago). It does, sorry.

@masseelch
Copy link
Author

Okay, my fault: my IDE removed the build.yaml. After re-adding it I get another error though:

[WARNING] swagger_dart_code_generator:swagger_dart_code_generator on lib/openapi.json:
[WARNING] Code formatting failed.
          Please raise an issue on https://github.com/epam-cross-platform-lab/swagger-dart-code-generator/issues/
          Reason: Could not format because the source could not be parsed:

line 962, column 10 of .: Unexpected text '$Errors'.
    ╷
962 │ class 500$Errors {
    │          ^^^^^^^
    ╵
line 764, column 19 of .: Expected to find ')'.
    ╷
764 │         (other is 404 &&
    │                   ^^^
    ╵
line 783, column 28 of .: Expected a method, getter, setter or operator declaration.
    ╷
783 │ extension $404Extension on 404 { 404 copyWith({int? code, 404$Errors? errors, String? status}) { return 404(code: code ?? this.code,
    │                            ^^^
    ╵
line 943, column 2 of .: Expected a class member.
    ╷
943 │     409$Errors();
    │     ^^^
    ╵
line 783, column 32 of .: Expected a method, getter, setter or operator declaration.
    ╷
783 │ extension $404Extension on 404 { 404 copyWith({int? code, 404$Errors? errors, String? status}) { return 404(code: code ?? this.code,
    │                                ^
    ╵
line 922, column 10 of .: Unexpected text '$Errors'.
    ╷
922 │ class 404$Errors {
    │          ^^^^^^^
    ╵
line 655, column 2 of .: Expected to find ';'.
    ╷
655 │     factory 400.fromJson(Map<String, dynamic> json) => _$400FromJson(json);
    │     ^^^^^^^
    ╵
line 885, column 13 of .: The name of a constructor must match the name of the enclosing class.
    ╷
885 │     factory 400$Errors.fromJson(Map<String, dynamic> json) => _$400$ErrorsFromJson(json);
    │                ^^^^^^^
    ╵
line 945, column 10 of .: Expected a class member.
    ╷
945 │     factory 409$Errors.fromJson(Map<String, dynamic> json) => _$409$ErrorsFromJson(json);
    │             ^^^
    ╵
line 882, column 10 of .: Unexpected text '$Errors'.
    ╷
882 │ class 400$Errors {
    │          ^^^^^^^
    ╵
(105 more errors...)
[INFO] Generating SDK summary...
[INFO] 4.8s elapsed, 1/5 actions completed.
[INFO] Generating SDK summary completed, took 4.2s

[SEVERE] chopper_generator:chopper_generator on lib/swagger_generated_code/openapi.swagger.dart:

This builder requires Dart inputs without syntax errors.
However, package:manager/swagger_generated_code/openapi.swagger.dart (or an existing part) contains the following errors.
openapi.swagger.dart:736:32: Expected a method, getter, setter or operator declaration.
openapi.swagger.dart:736:28: Expected a method, getter, setter or operator declaration.
openapi.swagger.dart:702:2: Expected to find ';'.
And 112 more...

Try fixing the errors and re-running the build.

[SEVERE] json_serializable:json_serializable on lib/swagger_generated_code/openapi.swagger.dart:

This builder requires Dart inputs without syntax errors.
However, package:manager/swagger_generated_code/openapi.swagger.dart (or an existing part) contains the following errors.
openapi.swagger.dart:736:32: Expected a method, getter, setter or operator declaration.
openapi.swagger.dart:736:28: Expected a method, getter, setter or operator declaration.
openapi.swagger.dart:702:2: Expected to find ';'.
And 112 more...

Try fixing the errors and re-running the build.

[INFO] Running build completed, took 5.2s

[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 91ms

[SEVERE] Failed after 5.3s
pub finished with exit code 1

@masseelch
Copy link
Author

Part of my spec:

 "responses": {
      "400": {
        "description": "invalid input, data invalid",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "integer",
                  "format": "int32",
                  "example": 400
                },
                "errors": {
                  "type": "object",
                  "properties": {}
                },
                "status": {
                  "type": "string",
                  "example": "Bad Request"
                }
              }
            }
          }
        }
      },

The above is valid OAS 3.0.3 schema. Will you accept a PR prefixing numeric names with an X or something like that?

@Vovanella95
Copy link
Collaborator

@masseelch , Ahh, looks like your swagger file has some border cases. I'm reopening the issue. Can you swagger code for at least one model with such name? I will fix it ASAP. Will try to do this today.

@Vovanella95 Vovanella95 reopened this Sep 22, 2021
@masseelch
Copy link
Author

I am using this one

@Vovanella95
Copy link
Collaborator

@masseelch thanks, I will try to handle it soon. Will let you know.

@masseelch
Copy link
Author

Thank you very much 🥰

Vovanella95 pushed a commit that referenced this issue Sep 22, 2021
@Vovanella95
Copy link
Collaborator

Hi again @masseelch ,
I've released 2.1.3+1. Now your file generated without any issues. Thanks for this issue.

@masseelch
Copy link
Author

masseelch commented Sep 22, 2021

You are awesome ❤️

@masseelch
Copy link
Author

Can confirm, build runs green. I will now checkout the generated code. Awesome work!

fryette pushed a commit that referenced this issue Sep 23, 2021
* Fix #248

* Updated changelog and pubspec

* Added ability to include or exclude paths

* Fixed ability to set exclude_path and include_path

Co-authored-by: uladzimir_paliukhovich <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants