Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Spec/Swagger2.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,14 @@ public function getDefinitions() {
$sch = [
"name" => $key,
"properties"=> $schema['properties'] ?? [],
"description"=> $schema['description'] ?? [],
"required" => $schema['required'] ?? [],
"additionalProperties" => $schema['additionalProperties'] ?? []
];
if(isset($sch['properties'])) {
foreach($sch['properties'] as $name => $def) {
$sch['properties'][$name]['name'] = $name;
$sch['properties'][$name]['description'] = $def['description'];
$sch['properties'][$name]['required'] = in_array($name,$sch['required']);
if(isset($def['items']['$ref'])) {
//nested model
Expand Down
1 change: 0 additions & 1 deletion templates/flutter/lib/package.dart.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import 'src/redirect_stub.dart'
if (dart.library.html) 'src/redirect_browser.dart';
import 'src/enums.dart';
import 'src/client.dart';
import 'src/response.dart';
import 'src/service.dart';
import 'models.dart' as models;

Expand Down
2 changes: 2 additions & 0 deletions templates/flutter/lib/src/models/model.dart.twig
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{% macro sub_schema(property) %}{% if property.sub_schema %}{% if property.type == 'array' %}List<{{property.sub_schema | caseUcfirst}}>{% else %}{{property.sub_schema | caseUcfirst}}{% endif %}{% else %}{{property.type | typeName}}{% endif %}{% endmacro %}
part of {{ language.params.packageName }}.models;

/// {{ definition.description }}
class {{ definition.name | caseUcfirst }} {
{% for property in definition.properties %}
/// {{ property.description }}
final {% if not property.required %}{{_self.sub_schema(property)}}? {{ property.name | escapeKeyword }}{% else %}{{_self.sub_schema(property)}} {{ property.name | escapeKeyword }}{% endif %};
{% endfor %}
{% if definition.additionalProperties %}
Expand Down
12 changes: 6 additions & 6 deletions templates/flutter/lib/src/realtime_mixin.dart.twig
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ mixin RealtimeMixin {
late WebSocketFactory getWebSocket;
GetFallbackCookie? getFallbackCookie;

_closeConnection() {
_websok?.sink.close(normalClosure);
Future<dynamic> _closeConnection() async {
return await _websok?.sink.close(normalClosure);
}

_createSocket() async {
Expand All @@ -32,7 +32,7 @@ mixin RealtimeMixin {
if (_lastUrl == uri.toString() && _websok?.closeCode == null) {
return;
}
_closeConnection();
await _closeConnection();
_lastUrl = uri.toString();
print('subscription: $_lastUrl');
_websok = await getWebSocket(uri);
Expand Down Expand Up @@ -112,7 +112,7 @@ mixin RealtimeMixin {
Future.delayed(Duration.zero, () => _createSocket());
RealtimeSubscription subscription = RealtimeSubscription(
stream: controller.stream,
close: () {
close: () async {
controller.close();
channels.forEach((channel) {
this._channels[channel]!.remove(controller);
Expand All @@ -121,9 +121,9 @@ mixin RealtimeMixin {
}
});
if(this._channels.isNotEmpty) {
Future.delayed(Duration.zero, () => _createSocket());
await Future.delayed(Duration.zero, () => _createSocket());
} else {
_closeConnection();
await _closeConnection();
}
});
return subscription;
Expand Down
2 changes: 1 addition & 1 deletion templates/flutter/lib/src/realtime_subscription.dart.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'realtime_message.dart';

class RealtimeSubscription {
final Stream<RealtimeMessage> stream;
final Function() close;
final Future<void> Function() close;

RealtimeSubscription({required this.stream, required this.close});
}