Browse Source

refactor(dynamite): cleanup valueToEscapedValue api

Signed-off-by: Nikolas Rimikis <leptopoda@users.noreply.github.com>
pull/694/head
Nikolas Rimikis 1 year ago
parent
commit
04a080f28c
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 2
      packages/dynamite/dynamite/lib/src/builder/resolve_object.dart
  2. 2
      packages/dynamite/dynamite/lib/src/builder/resolve_type.dart
  3. 6
      packages/dynamite/dynamite/lib/src/helpers/type_result.dart
  4. 4
      packages/dynamite/dynamite/lib/src/openapi_builder.dart

2
packages/dynamite/dynamite/lib/src/builder/resolve_object.dart

@ -3,7 +3,7 @@ import 'package:dynamite/src/builder/resolve_type.dart';
import 'package:dynamite/src/builder/state.dart'; import 'package:dynamite/src/builder/state.dart';
import 'package:dynamite/src/helpers/dart_helpers.dart'; import 'package:dynamite/src/helpers/dart_helpers.dart';
import 'package:dynamite/src/helpers/dynamite.dart'; import 'package:dynamite/src/helpers/dynamite.dart';
import 'package:dynamite/src/helpers/typeresult.dart'; import 'package:dynamite/src/helpers/type_result.dart';
import 'package:dynamite/src/models/open_api.dart'; import 'package:dynamite/src/models/open_api.dart';
import 'package:dynamite/src/models/schema.dart'; import 'package:dynamite/src/models/schema.dart';
import 'package:dynamite/src/type_result/type_result.dart'; import 'package:dynamite/src/type_result/type_result.dart';

2
packages/dynamite/dynamite/lib/src/builder/resolve_type.dart

@ -2,7 +2,7 @@ import 'package:code_builder/code_builder.dart';
import 'package:dynamite/src/builder/resolve_object.dart'; import 'package:dynamite/src/builder/resolve_object.dart';
import 'package:dynamite/src/builder/state.dart'; import 'package:dynamite/src/builder/state.dart';
import 'package:dynamite/src/helpers/dart_helpers.dart'; import 'package:dynamite/src/helpers/dart_helpers.dart';
import 'package:dynamite/src/helpers/typeresult.dart'; import 'package:dynamite/src/helpers/type_result.dart';
import 'package:dynamite/src/models/open_api.dart'; import 'package:dynamite/src/models/open_api.dart';
import 'package:dynamite/src/models/schema.dart'; import 'package:dynamite/src/models/schema.dart';
import 'package:dynamite/src/type_result/type_result.dart'; import 'package:dynamite/src/type_result/type_result.dart';

6
packages/dynamite/dynamite/lib/src/helpers/typeresult.dart → packages/dynamite/dynamite/lib/src/helpers/type_result.dart

@ -1,7 +1,7 @@
import 'package:dynamite/src/helpers/dart_helpers.dart'; import 'package:dynamite/src/helpers/dart_helpers.dart';
import 'package:dynamite/src/type_result/type_result.dart'; import 'package:dynamite/src/type_result/type_result.dart';
String valueToEscapedValue(final TypeResult result, final dynamic value) { String valueToEscapedValue(final TypeResult result, final String value) {
if (result is TypeResultBase && result.name == 'String') { if (result is TypeResultBase && result.name == 'String') {
return "'$value'"; return "'$value'";
} }
@ -9,7 +9,7 @@ String valueToEscapedValue(final TypeResult result, final dynamic value) {
return 'const $value'; return 'const $value';
} }
if (result is TypeResultEnum) { if (result is TypeResultEnum) {
return '${result.name}.${toDartName(value.toString())}'; return '${result.name}.${toDartName(value)}';
} }
return value.toString(); return value;
} }

4
packages/dynamite/dynamite/lib/src/openapi_builder.dart

@ -10,7 +10,7 @@ import 'package:dynamite/src/builder/serializer.dart';
import 'package:dynamite/src/builder/state.dart'; import 'package:dynamite/src/builder/state.dart';
import 'package:dynamite/src/helpers/dart_helpers.dart'; import 'package:dynamite/src/helpers/dart_helpers.dart';
import 'package:dynamite/src/helpers/dynamite.dart'; import 'package:dynamite/src/helpers/dynamite.dart';
import 'package:dynamite/src/helpers/typeresult.dart'; import 'package:dynamite/src/helpers/type_result.dart';
import 'package:dynamite/src/models/open_api.dart'; import 'package:dynamite/src/models/open_api.dart';
import 'package:dynamite/src/models/path_item.dart'; import 'package:dynamite/src/models/path_item.dart';
import 'package:dynamite/src/models/schema.dart'; import 'package:dynamite/src/models/schema.dart';
@ -424,7 +424,7 @@ class OpenAPIBuilder implements Builder {
} }
final defaultValueCode = parameter.schema?.default_ != null final defaultValueCode = parameter.schema?.default_ != null
? valueToEscapedValue(result, parameter.schema!.default_) ? valueToEscapedValue(result, parameter.schema!.default_.toString())
: null; : null;
b.optionalParameters.add( b.optionalParameters.add(

Loading…
Cancel
Save