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

Dart build 0.7.1-alpha.1 does not compile #94

Closed
yholkamp opened this issue Aug 4, 2021 · 17 comments
Closed

Dart build 0.7.1-alpha.1 does not compile #94

yholkamp opened this issue Aug 4, 2021 · 17 comments

Comments

@yholkamp
Copy link
Contributor

yholkamp commented Aug 4, 2021

Describe the bug

The 0.7.1-alpha.1 build of the Dart Kratos client library does not compile as it calls an invalid method.

To Reproduce

Steps to reproduce the behavior:

  1. Include the library in a Flutter project

  2. Run flutter build appbundle

  3. Observe the following errors:

     ../../../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.1-alpha.1/lib/model/generic_error.dart:101:20: Error: Method not found: 'Object.mapFromJson'.
               : Object.mapFromJson(json[r'details']),                       
                        ^^^^^^^^^^^                                          
     ../../../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/ory_kratos_client-0.7.1-alpha.1/lib/model/volume.dart:117:20: Error: Method not found: 'Object.mapFromJson'.
               : Object.mapFromJson(json[r'Status']),                        
                        ^^^^^^^^^^^                                          
    

Expected behavior

These lines attempt to deserialize a map of string to object properties from JSON, in the case of Dart the goal should be a Map here and not an Object as the spec dictates. One way to adjust that may be to change such lines in to a json[r'details'] as Map cast rather, as the input is already deserialized and maybe in the right format.

Environment

  • Version: Flutter 2.0.2
  • Dart v2.12.1

Additional context

The root cause seems to be with the code generator:

@aeneasr
Copy link
Member

aeneasr commented Aug 4, 2021

Could you try alpha.3?

@yholkamp
Copy link
Contributor Author

yholkamp commented Aug 5, 2021

@aeneasr I'm happy to but I'm not seeing that version released yet at https://pub.dev/packages/ory_kratos_client/versions, is that underway?

@aeneasr
Copy link
Member

aeneasr commented Aug 5, 2021

Whoops, my bad, looks like I was in the future already. We only released 0.7.1 :D

@provokateurin
Copy link

I just tried the fix @yholkamp suggested and it works: https://github.com/stack11/sdk

@aeneasr
Copy link
Member

aeneasr commented Aug 12, 2021

Probably caused by: swagger-api/swagger-codegen#7418 (comment)

@aeneasr
Copy link
Member

aeneasr commented Aug 12, 2021

I just saw that the dart generator is probably outdated and also does not support OAS3 which we are now using. It looks like we have some alternatives:

I don't know any Dart so I don't know the differences between dio / dio-next and jaguar. From what I see on the forums, dart-dio looks like it's better supported?

@provokateurin
Copy link

Those are frameworks. I only know dio, but it's pretty good as far as I remember.

@provokateurin
Copy link

I tried dio and it also seems horribly outdated. Stuff like null-safety is also not there.

@yholkamp
Copy link
Contributor Author

@aeneasr since adding this ticket I've had success with the dart2 generator. One limitation was the lack of DELETE call support (for logout) but that's resolved in master via OpenAPITools/openapi-generator#10100 , it will be in the 5.2.1 release but is not out yet. Once it's released I'd propose moving the dart client over to that, alternatively the generator works right now in 5.2.0 with the note that the logout endpoint fails.

@aeneasr
Copy link
Member

aeneasr commented Aug 12, 2021

Ah nice! What's the difference between dart and dart2? Is it just the generator or more?

@provokateurin
Copy link

Dart 1 is deprecated as a whole. Nobody should use it anymore. Maybe that also fixes other issues I/we have been facing?

@aeneasr
Copy link
Member

aeneasr commented Aug 12, 2021

Ahhh, ok, that makes sense! Then yeah, all for going with dart2 generator!

@provokateurin
Copy link

But the generated code is dart 2 compliant (see the @dart=2.0) comments in the files.

@aeneasr
Copy link
Member

aeneasr commented Aug 23, 2021

So should we change to the dart2 generator? It isn't documented yet :/

@aeneasr
Copy link
Member

aeneasr commented Aug 23, 2021

Ok, so I have merged the changes and triggered a release. Let's see if it works now. A few questions from my side:

  1. How would testing the SDK look like for Dart? Can we ensure that it compiles before we push it to remote?
  2. Should we switch to dart2 and if so, are there some resources on its maturity? And how would we switch (couldn't find an officially supported page)
  3. Can you check if the newest release compiles now?

@aeneasr
Copy link
Member

aeneasr commented Aug 23, 2021

@aeneasr
Copy link
Member

aeneasr commented Sep 8, 2021

Superseded #109

@aeneasr aeneasr closed this as completed Sep 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants