Closed bpar476 closed 1 year ago
Try https://pub.dev/packages/ory_client instead!
Oh that one resolves just fine, thanks! Are both packages needed? Should the ory_kratos_client
be deprecated?
We will eventually deprecate them. ory_client is always ahead because it is in sync with Ory Cloud. The other SDKs need an open source release to be updated
Hmm, so I was able to resolve dependencies, but my app does not compile. You can see the same errors in the "Pass Static Analysis" section of https://pub.dev/packages/ory_client/score, pasted below for convenience:
../../Library/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/ory_client-0.2.0-alpha.4/lib/model/generic_error.dart:186:22: Error: Member not found:
'Map.listFromJson'.
details: Map.listFromJson(json[r'details']) ?? const [],
^^^^^^^^^^^^
../../Library/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/ory_client-0.2.0-alpha.4/lib/model/identity.dart:205:42: Warning: Operand of null-aware
operation '??' has type 'Map<String, IdentityCredentials>' which excludes null.
- 'Map' is from 'dart:core'.
- 'IdentityCredentials' is from 'package:ory_client/api.dart'
('../../Library/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/ory_client-0.2.0-alpha.4/lib/api.dart').
credentials: IdentityCredentials.mapFromJson(json[r'credentials']) ?? const {},
That would probably be: https://github.com/OpenAPITools/openapi-generator/issues/4887
Looks like this is resolved but not yet released. Once it's released, we can upgrade the dart generator to resolve this bug. Sorry but it's out of our hands :(
Wrong issue, looksl ike it's: https://github.com/OpenAPITools/openapi-generator/issues/11462
Should I open a separate issue for the ory_client build issues?
Also there's another issue besides the Map listFromJson method: the bill coalescing operator being used on non-nullable type. I'll have a look at the generator some time and see if there's an issue for that and maybe if there's a quick fix.
We can use this one to track this :)
Any fixes you're able to make towards openapi generator would highly be appreciated! Unfortunately I don't know Dart/Flutter which is why I can't really help to fix it :)
After a bit of digging, it looks like the issue for both packages is resolved for the latest version of open-api-generator 6.0.1 when using the dart-dio generator. Looks like we're currently using 5.2.1. Is it possible to upgrade?
I have the same problem and generated a version for myself with dart-dio and open-api-generator 6.0.1. I have now the problem that the serialization is not working. When doing:
String basePath = "http://10.10.20.20:4433";
OryClient client = OryClient(basePathOverride: basePath);
V0alpha2Api apiV2 = client.getV0alpha2Api();
try {
final response = await apiV2.initializeSelfServiceLoginFlowWithoutBrowser();
print(response);
} catch (e) {
print("Exception when calling MetadataApi->getVersion: $e\n");
}
I get the error:
I/flutter (15686): Exception when calling MetadataApi->getVersion: DioError [DioErrorType.other]: Deserializing '[id, ddc45483-fccb-4940-af32-05722db008c9, type, api, expires_at, 2022-08-02T...' to 'SelfServiceLoginFlow' failed due to: Deserializing '[action, http://127.0.0.1:4433/self-service/login?flow=ddc45483-fccb-4940-af3...' to 'UiContainer' failed due to: Deserializing '[{type: input, group: default, attributes: {name: csrf_token, type: hidden, v...' to 'BuiltList<UiNode>' failed due to: Deserializing '[type, input, group, default, attributes, {name: csrf_token, type: hidden, va...' to 'UiNode' failed due to: Deserializing '[name, csrf_token, type, hidden, value, , required, true, disabled, false, no...' to 'UiNodeAttributes' failed due to: Tried to build class "UiNodeAttributes" but nested builder for field "text" threw: Tried to construct class "UiText" with null field "id". This is forbidden; to allow it, mark "id" with @nullable.
As a kratos server I am using the one from the quickstart (https://www.ory.sh/docs/kratos/quickstart). Do I need to use a different version?
Hmm, I've just tried using the kratos sdk generated with the dart-dio exporter I couldn't get it to compile. I think I'm just going to have to continue with a manually implemented client for now.
When trying with the newest version of OpenAPIGenerator and the dart
exporter this also failed. Looks like the dart tooling for open-api-generator is maybe not mature enough.
Looks like spec now generates with type safety, but there are generation errors for which I new ticket here https://github.com/ory/sdk/issues/230
Ok, closing this issue then
Preflight checklist
Describe the bug
When importing the dart ory_kratos_client https://pub.dev/packages/ory_kratos_client, it fails to resolve dependencies when using many other packages with null-safety features. For example the latest
http
package https://pub.dev/packages/http or thegoogle_fonts
package https://pub.dev/packages/google_fonts. This basically makes the SDK unusable for modern flutter projects where null-safety is the default.When trying to resolve the dependencies, we see the culprit is a dependency of the ory_kratos_client package itself which depends on a version of the
dio
library which in turn depends on a non-null-safe version of thehttp_parser
package.Reproducing the bug
flutter create helloworld
http
package:flutter pub add http
ory_kratos_client
package topubspec.yaml
:ory_kratos_client: ^0.10.1
flutter pub get
Resultant pubspec.yaml:
Relevant log output
Relevant configuration
No response
Version
0.10.1
On which operating system are you observing this issue?
macOS
In which environment are you deploying?
No response
Additional Context
No response