Skip to content

Commit

Permalink
fix(dynamite): Escape wireNames
Browse files Browse the repository at this point in the history
Signed-off-by: provokateurin <kate@provokateurin.de>
  • Loading branch information
provokateurin committed Aug 30, 2024
1 parent 2f3fcf0 commit 5915c57
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packages/dynamite/lib/src/builder/resolve_interface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:dynamite/src/helpers/dynamite.dart';
import 'package:dynamite/src/helpers/pattern_check.dart';
import 'package:dynamite/src/models/json_schema.dart' as json_schema;
import 'package:dynamite/src/models/type_result.dart';
import 'package:source_helper/source_helper.dart';

Spec buildInterface(
State state,
Expand Down Expand Up @@ -245,7 +246,7 @@ void _generateProperty(

final builtValueFieldAnnotations = <String, Expression>{};
if (dartName != propertyName) {
builtValueFieldAnnotations['wireName'] = literalString(propertyName);
builtValueFieldAnnotations['wireName'] = refer(escapeDartString(propertyName));
}

if (builtValueFieldAnnotations.isNotEmpty) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ abstract class Base implements $BaseInterface, Built<Base, BaseBuilder> {
@BuiltValue(instantiable: false)
sealed class $BaseInterfaceInterface {
String? get attribute;
@BuiltValueField(wireName: r'$property')
String? get property;

/// Rebuilds the instance.
///
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"properties": {
"attribute": {
"type": "string"
},
"$property": {
"type": "string"
}
}
}
Expand Down

0 comments on commit 5915c57

Please sign in to comment.