Closed vinckr closed 2 years ago
Could you @ the dev here please?
I assume @bennihz or @sashatalalasha?
Yes it was @sashatalalasha who reported the issue, sorry missed that.
@sashatalalasha have you been able to use the Dart SDK at all or does this prevent you from embedding it? Also, what version of the SDK have you been using?
Unfortunately the tool we use to generate the Dart code generates really bad code that sometimes doesn’t even compile. I have raised an issue in our pipeline on this (https://github.com/ory/sdk/issues/109) and also opened/track several issues in openapi-generator:
I would suggest that when I am back next week we sit down together and try out the different options for Dart generation available and choose the least terrible one 😅
Alternatively we could also use the REST API in raw format for now. What do you think?
@aeneasr I can't build the app as it constantly throws errors. The SDK version is 2.13.4.
Actually, I didn't plan to use the ory client package as Benni is working on a backend that will serve as a mediator between the app and Kratos. Just wanted to check how direct communication works :)
Sure we can look for a good code generator together when you're back.
Thanks!
Ah ok! That works also :) If any of you both need help just drop an issue or GitHub discussion here!
It would also be great if we could sit together for an hour or so to look at your use of Dart and how we could get our SDKs up to speed as we have flows for native apps :)
https://github.com/ory/sdk/issues/109#issuecomment-922347730 I want to fix this issue, as it would be great to have a correctly working dart generator.
Any news?
I haven't tried using ory with a dart client in a while, but i've successfully used the dart2 generator from the openapi-generator 6.0.x branch. It has null-safety and seems to be working just fine. It is not released yet, so I don't know if ory wants to use it, but I'd say better use (maybe) unstable than outright broken code.
Oh nice! Yeah, 6.0x is still pretty broken I think but as soon as it becomes stable we wil definitely switch to it. Maybe we can also use individual versions for each SDK type, would require some refactoring though.
We have updated to the latest versions - not sure if that brings some improvements already?
We have updated to the latest versions - not sure if that brings some improvements already?
FWIW still getting the following 5 months later :(
What version?
The 6.x.x version of the generator is now stable and should produce valid code (although not everything ory uses in the specs is supported).
What version?
@aeneasr
in my flutter project's pubspec.yaml ory_kratos_client: ^0.7.3-alpha.8
, but I see the version available is ory_kratos_client: ^0.10.1
-- weird because I used flutter pub get ory_kratos_client
and it didn't install latest
when I attempted to change manually I got
Running "flutter pub get" in ory_flutter...
Because ory_kratos_client >=0.7.5-alpha.2 depends on dio ^3.0.9 which depends on http_parser >=0.0.1 <4.0.0, ory_kratos_client >=0.7.5-alpha.2 requires http_parser >=0.0.1 <4.0.0.
And because http 0.13.4 depends on http_parser ^4.0.0 and no versions of http match >0.13.4 <0.14.0, ory_kratos_client >=0.7.5-alpha.2 is incompatible with http ^0.13.4.
So, because ory_flutter depends on both http ^0.13.4 and ory_kratos_client ^0.10.1, version solving failed.
pub get failed (1; So, because ory_flutter depends on both http ^0.13.4 and ory_kratos_client ^0.10.1, version solving failed.)
in my pubspec.yaml I also had http: ^0.13.4
which seemed to stop dio (pre req for openapi doc) and forced kratos api to a lower version that did not have null safety
I'm going to remove the http (in lieu of using dio which is a dep for openapi) and see how things go!
Following up now that I am on ory_kratos_client: ^0.10.1
I still seem to have an error building https://gist.github.com/b62c1cba39eecd6a51fdb5ae61417c49
flutter analyze
output shows
allen@ALPHA MINGW64 /c/dev/ory_flutter
$ flutter analyze
Running "flutter pub get" in flutter_tools... 21.4s
Analyzing ory_flutter...
info - Avoid using private types in public APIs - lib\screens\sign_in.dart:13:3 - library_private_types_in_public_api
info - The library 'package:ory_kratos_client/api.dart' is legacy, and shouldn't be imported into a null safe library - lib\services\auth_service.dart:3:8 - import_of_legacy_library_into_null_safe
info - The library 'package:ory_kratos_client/model/session.dart' is legacy, and shouldn't be imported into a null safe library - lib\services\auth_service.dart:4:8 - import_of_legacy_library_into_null_safe
info - The library 'package:ory_kratos_client/model/submit_self_service_login_flow_body.dart' is legacy, and shouldn't be imported into a null safe library - lib\services\auth_service.dart:5:8 - import_of_legacy_library_into_null_safe
info - The library 'package:ory_kratos_client/model/submit_self_service_logout_flow_without_browser_body.dart' is legacy, and shouldn't be imported into a null safe library - lib\services\auth_service.dart:6:8 - import_of_legacy_library_into_null_safe
info - The library 'package:ory_kratos_client/model/submit_self_service_registration_flow_body.dart' is legacy, and shouldn't be imported into a null safe library - lib\services\auth_service.dart:7:8 - import_of_legacy_library_into_null_safe
info - The library 'package:ory_kratos_client/model/successful_self_service_login_without_browser.dart' is legacy, and shouldn't be imported into a null safe library - lib\services\auth_service.dart:8:8 - import_of_legacy_library_into_null_safe
info - The library 'package:ory_kratos_client/model/successful_self_service_registration_without_browser.dart' is legacy, and shouldn't be imported into a null safe library - lib\services\auth_service.dart:9:8 - import_of_legacy_library_into_null_safe
Looking closer, all files are for dart 2.7 and pub.dev shows failing null safety
Taking a look at versioning it looks like there was some regression where previous versions had null safety -- weird since ory/sdk/scripts has dart with openapi generator v6.0.0 they actually still opt out of null safety :/
Hey again @aeneasr!
So I think this might have to do with openapi generating using dart-dio
over dart
from this change https://github.com/ory/sdk/commit/77fab2552304967e86b3de9074002ebac7e472cf -- this was much before flutter 3 release fwiw
regardless, I'm not sure if dart-dio
was already updated for null safety or if dart-dio
still requires this PR in openapi repo to be merged https://github.com/OpenAPITools/openapi-generator/pull/12295 -- it does seem to be working with a user in the PR saying they have to use the PR's branch in production to get things working if you do want to use the branch
Regardless, it seems openapi gen v6.0.0 added support for dart
null-safety here https://github.com/OpenAPITools/openapi-generator/pull/10637
It would be great if the branched dart-dio or the non-dio dart generator can be used in a (pre)release on pub.dev -- at least until the PR is merged
This is a blocking issue for anyone using Flutter 3 (requires >= Dart 2.12 that added null safety) much appreciated 🙏
Got it, so shall we use the dart or dart2 generator?
dart2, but you just set the generator to dart for that. idk it's weird, but that's how it works.
Ok nice, if anyone is up for the small change, PRs welcomed :)
@aeneasr PR here https://github.com/ory/sdk/pull/202
Thank you - merged! A new release has also been triggered - let's see if it works now :)
@aeneasr not sure if the release should be live yet, but I'm not seeing it on pub.dev yet https://pub.dev/packages/ory_kratos_client/versions
fwiw I see https://github.com/ory/sdk/tree/master/clients/client/dart was regenerated and anonymously published here https://pub.dev/packages/ory_client, but not https://github.com/ory/sdk/tree/master/clients/kratos/dart
Current using the following in my pubspec.yaml
until its on pub.dev
ory_client:
git:
url: https://github.com/ory/sdk.git
path: clients/client/dart
Ran into an OpenAPI issue for which I've opened an issue here https://github.com/OpenAPITools/openapi-generator/issues/12914
Other than that the library is now working with null safety
Sorry for the late reply, please use the meta Ory SDK: https://pub.dev/packages/ory_client/versions
The Ory Kratos / Hydra / ... SDKs will only be released when we release a new tag for those. The Ory SDK is being regenerated everytime we make changes to console.ory.sh production!
The Dart SDK is now null safe! :) :)
Awesome!
Report from amorevino developer:
Describe the bug
We have an SDK for Dart: https://pub.dev/packages/ory_client
This is created with Dart version 2.0. Dart support for null safety was added in 2.8 (https://dart.dev/null-safety).
This leads to errors when developing Flutter apps.
To Reproduce
https://pub.dev/packages/ory_client/score
Expected behavior
Package is null safe.
Additional context
I do not have experience using the package, so let me know if this is a trivial error or can be worked around easily.