-
Notifications
You must be signed in to change notification settings - Fork 12
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 client is not working #2240
Comments
Here's how I used the OpenAPI Dart Dio Generator to build a library from our OpenAPI spec: docker run --rm \
-v "${PWD}:/local" openapitools/openapi-generator-cli generate \
-i /local/openapi.yaml \
-g dart-dio \
-o fusionauth_dart_client \
-c openapi-generator-dart-dio-config.yaml I started building an example client to be added to the fusionauth-example-client-libraries repo, but I'm waiting for any suggestions on what we should do with the Dart library itself to finish this. import 'package:dio/dio.dart';
import 'package:fusionauth_dart_client/fusionauth_dart_client.dart';
Future<Tenant> getTenant(DefaultApi api) async {
final response = await api.retrieveTenantWithId(tenantId: "");
final Tenant? tenant = response.data?.tenants?[0];
if (tenant == null) {
throw Exception("Couldn't find any tenants");
}
return tenant;
}
Future<void> patchTenant(DefaultApi api, Tenant tenant, String issuer) async {
final patched = new Tenant((b) => b..issuer = issuer);
await api.patchTenantWithId(
tenantId: tenant.id!,
tenantRequest: new TenantRequest((b) => b..tenant = patched.toBuilder())
);
}
void main() async {
final client = FusionauthDartClient();
client.setApiKey('ApiKeyAuth', 'Api-Key Here'); // Change this
final api = client.getDefaultApi();
final issuer = "http://localhost:9011";
try {
print('Searching Tenant...');
final Tenant tenant = await getTenant(api);
print(' [ ] Found: ${tenant.id}');
print('Updating Tenant issuer: ${issuer}');
await patchTenant(api, tenant, issuer);
} on DioError catch (e) {
print(e);
print(e.response);
}
} |
So I think we should definitely replace the dart client library with the one you've generated, especially after FusionAuth/fusionauth-client-builder#68 is merged. The question is, how. Options I see are:
@andrewpai @robotdan any thoughts? |
Dart client is not working
Description
As stated in FusionAuth/fusionauth-dart-client#13, our Dart client library is throwing a lot of errors.
I tried fixing it by changing the
char
type toString
as it was complaining thatchar
doesn't even exist and I solved allError: The parameter '...' can't have a value of 'null' because of its type 'String', but the implicit default value is 'null'
errors by making a lot of parameters nullable.I still received a bunch of
Error: A value of type 'Future<ClientResponse<dynamic, dynamic>>' can't be returned from a function with return type 'Future<ClientResponse<ActionResponse, Errors>>'
that I tried solving by changing a few things in how we use Generics but couldn't get anywhere.Finally, I tried downgrading Dart SDK from 2.19 to 2.7 (which was the last SDK change introduced by FusionAuth/fusionauth-dart-client@b8496c5) and our lib to 1.21.0 (which is mentioned in README) and I still got errors, so I gave up.
I then tried using OpenAPI Dart Generator but got other errors. There's an open PR OpenAPITools/openapi-generator#12574 that tries to fix some of them, so I built from source and tried using it but still no luck. Finally, I tried using the OpenAPI Dart Dio Generator (that uses dio HTTP client) and it finally worked, but I still need to tweak a lot of settings to generate correct docs (that are currently wrong).
Affects versions
Community guidelines
All issues filed in this repository must abide by the FusionAuth community guidelines.
The text was updated successfully, but these errors were encountered: