fetchDatabaseSwagger function
Fetches the PostgREST schema of each of schemas (the first is the
primary, see DatabaseSwagger.fromSchemas), or null if any fails.
Implementation
Future<DatabaseSwagger?> fetchDatabaseSwagger(String url, String apiKey,
Map<String, List<String>> mapOfEnums, bool jsonbToDynamic,
{List<String> schemas = const ['public'],
Map<String, JsonbModelConfig>? jsonbModels,
http.Client? client}) async {
url = withScheme(url);
try {
final specs = <String, Map<String, dynamic>>{};
for (final schema in schemas) {
final spec = await _fetchSchema(url, apiKey, schema, client);
if (spec == null) return null;
specs[schema] = spec;
}
return DatabaseSwagger.fromSchemas(specs, mapOfEnums, jsonbToDynamic,
jsonbModels: jsonbModels);
} catch (e) {
print("Error fetching Supabase Swagger: $e");
}
return null;
}