Skip to content

Commit ad4d6ad

Browse files
committed
refactor(dynamite): rename Schema to JsonSchema
Signed-off-by: Nikolas Rimikis <leptopoda@users.noreply.github.com>
1 parent 8d2e44d commit ad4d6ad

24 files changed

+241
-233
lines changed

packages/dynamite/dynamite/lib/src/builder/built_object_serializer.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Spec buildBuiltClassSerializer(
1212
State state,
1313
String identifier,
1414
openapi.OpenAPI spec,
15-
json_schema.Schema schema,
15+
json_schema.JsonSchema schema,
1616
) =>
1717
Class(
1818
(b) => b
@@ -137,7 +137,7 @@ Iterable<String> deserializeProperty(
137137
State state,
138138
String identifier,
139139
openapi.OpenAPI spec,
140-
json_schema.Schema schema,
140+
json_schema.JsonSchema schema,
141141
) sync* {
142142
for (final property in schema.properties!.entries) {
143143
final propertyName = property.key;
@@ -169,7 +169,7 @@ Iterable<String> serializePropertyNullable(
169169
State state,
170170
String identifier,
171171
openapi.OpenAPI spec,
172-
json_schema.Schema schema,
172+
json_schema.JsonSchema schema,
173173
) sync* {
174174
for (final property in schema.properties!.entries) {
175175
final propertyName = property.key;
@@ -204,7 +204,7 @@ Iterable<String> serializeProperty(
204204
State state,
205205
String identifier,
206206
openapi.OpenAPI spec,
207-
json_schema.Schema schema,
207+
json_schema.JsonSchema schema,
208208
) sync* {
209209
for (final property in schema.properties!.entries) {
210210
final propertyName = property.key;

packages/dynamite/dynamite/lib/src/builder/client.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ return ${allocate(responseType)}.fromRawResponse(_rawResponse);
488488
spec,
489489
state,
490490
identifierBuilder.toString(),
491-
json_schema.Schema(
491+
json_schema.JsonSchema(
492492
(b) => b
493493
..properties.replace(
494494
response.headers!.map(

packages/dynamite/dynamite/lib/src/builder/resolve_enum.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ TypeResult resolveEnum(
1414
openapi.OpenAPI spec,
1515
State state,
1616
String identifier,
17-
json_schema.Schema schema,
17+
json_schema.JsonSchema schema,
1818
TypeResult subResult, {
1919
bool nullable = false,
2020
}) {

packages/dynamite/dynamite/lib/src/builder/resolve_interface.dart

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Spec buildInterface(
1515
openapi.OpenAPI spec,
1616
State state,
1717
String identifier,
18-
json_schema.Schema schema, {
18+
json_schema.JsonSchema schema, {
1919
bool isHeader = false,
2020
bool nullable = false,
2121
}) {
@@ -32,9 +32,9 @@ Spec buildInterface(
3232
final defaults = StringBuffer();
3333
final validators = BlockBuilder();
3434

35-
if (schema case json_schema.Schema(:final allOf) when allOf != null) {
35+
if (schema case json_schema.JsonSchema(:final allOf) when allOf != null) {
3636
for (final schema in allOf) {
37-
if (schema case json_schema.Schema(properties: != null)) {
37+
if (schema case json_schema.JsonSchema(properties: != null)) {
3838
_generateProperties(
3939
schema,
4040
spec,
@@ -136,7 +136,7 @@ Spec buildInterface(
136136
}
137137

138138
void _generateProperties(
139-
json_schema.Schema schema,
139+
json_schema.JsonSchema schema,
140140
openapi.OpenAPI spec,
141141
State state,
142142
String identifier,
@@ -193,7 +193,7 @@ void _generateProperty(
193193
ClassBuilder b,
194194
String propertyName,
195195
TypeResult result,
196-
json_schema.Schema schema,
196+
json_schema.JsonSchema schema,
197197
StringSink defaults,
198198
BlockBuilder validators,
199199
) {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ TypeResultObject resolveObject(
99
openapi.OpenAPI spec,
1010
State state,
1111
String identifier,
12-
json_schema.Schema schema, {
12+
json_schema.JsonSchema schema, {
1313
bool nullable = false,
1414
bool isHeader = false,
1515
}) {

packages/dynamite/dynamite/lib/src/builder/resolve_ofs.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ TypeResult resolveSomeOf(
1212
openapi.OpenAPI spec,
1313
State state,
1414
String identifier,
15-
json_schema.Schema schema, {
15+
json_schema.JsonSchema schema, {
1616
bool nullable = false,
1717
}) {
1818
final subResults = schema.ofs!

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

+18-18
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ TypeResult resolveType(
1515
openapi.OpenAPI spec,
1616
State state,
1717
String identifier,
18-
json_schema.Schema schema, {
18+
json_schema.JsonSchema schema, {
1919
bool nullable = false,
2020
}) {
2121
final result = _resolveType(
@@ -34,11 +34,11 @@ TypeResult _resolveType(
3434
openapi.OpenAPI spec,
3535
State state,
3636
String identifier,
37-
json_schema.Schema schema, {
37+
json_schema.JsonSchema schema, {
3838
bool nullable = false,
3939
}) {
4040
switch (schema) {
41-
case json_schema.Schema($enum: != null):
41+
case json_schema.JsonSchema($enum: != null):
4242
final subResult = resolveType(
4343
spec,
4444
state,
@@ -58,7 +58,7 @@ TypeResult _resolveType(
5858
nullable: nullable,
5959
);
6060

61-
case json_schema.Schema(allOf: != null):
61+
case json_schema.JsonSchema(allOf: != null):
6262
return resolveObject(
6363
spec,
6464
state,
@@ -67,13 +67,13 @@ TypeResult _resolveType(
6767
nullable: nullable,
6868
);
6969

70-
case json_schema.Schema(ref: null, ofs: null, type: null):
70+
case json_schema.JsonSchema(ref: null, ofs: null, type: null):
7171
return TypeResultBase(
7272
'JsonObject',
7373
nullable: nullable,
7474
);
7575

76-
case json_schema.Schema(ref: != null):
76+
case json_schema.JsonSchema(ref: != null):
7777
final name = schema.ref!.fragment.split('/').last;
7878
final subResult = resolveType(
7979
spec,
@@ -85,7 +85,7 @@ TypeResult _resolveType(
8585

8686
return subResult.asTypeDef;
8787

88-
case json_schema.Schema(anyOf: != null) || json_schema.Schema(oneOf: != null):
88+
case json_schema.JsonSchema(anyOf: != null) || json_schema.JsonSchema(oneOf: != null):
8989
return resolveSomeOf(
9090
spec,
9191
state,
@@ -94,7 +94,7 @@ TypeResult _resolveType(
9494
nullable: nullable,
9595
);
9696

97-
case json_schema.Schema(isContentString: true):
97+
case json_schema.JsonSchema(isContentString: true):
9898
final subResult = resolveType(
9999
spec,
100100
state,
@@ -108,43 +108,43 @@ TypeResult _resolveType(
108108
nullable: nullable,
109109
);
110110

111-
case json_schema.Schema(type: json_schema.SchemaType.boolean):
111+
case json_schema.JsonSchema(type: json_schema.JsonSchemaType.boolean):
112112
return TypeResultBase(
113113
'bool',
114114
nullable: nullable,
115115
);
116116

117-
case json_schema.Schema(type: json_schema.SchemaType.integer):
117+
case json_schema.JsonSchema(type: json_schema.JsonSchemaType.integer):
118118
return TypeResultBase(
119119
'int',
120120
nullable: nullable,
121121
);
122122

123-
case json_schema.Schema(type: json_schema.SchemaType.number, format: 'float' || 'double'):
123+
case json_schema.JsonSchema(type: json_schema.JsonSchemaType.number, format: 'float' || 'double'):
124124
return TypeResultBase(
125125
'double',
126126
nullable: nullable,
127127
);
128128

129-
case json_schema.Schema(type: json_schema.SchemaType.number):
129+
case json_schema.JsonSchema(type: json_schema.JsonSchemaType.number):
130130
return TypeResultBase(
131131
'num',
132132
nullable: nullable,
133133
);
134134

135-
case json_schema.Schema(type: json_schema.SchemaType.string, format: 'binary'):
135+
case json_schema.JsonSchema(type: json_schema.JsonSchemaType.string, format: 'binary'):
136136
return TypeResultBase(
137137
'Uint8List',
138138
nullable: nullable,
139139
);
140140

141-
case json_schema.Schema(type: json_schema.SchemaType.string):
141+
case json_schema.JsonSchema(type: json_schema.JsonSchemaType.string):
142142
return TypeResultBase(
143143
'String',
144144
nullable: nullable,
145145
);
146146

147-
case json_schema.Schema(type: json_schema.SchemaType.array):
147+
case json_schema.JsonSchema(type: json_schema.JsonSchemaType.array):
148148
final TypeResult subResult;
149149
if (schema.maxItems == 0) {
150150
subResult = TypeResultBase('Never');
@@ -165,7 +165,7 @@ TypeResult _resolveType(
165165
nullable: nullable,
166166
);
167167

168-
case json_schema.Schema(type: json_schema.SchemaType.object, properties: null):
168+
case json_schema.JsonSchema(type: json_schema.JsonSchemaType.object, properties: null):
169169
if (schema.additionalProperties == null) {
170170
return TypeResultBase(
171171
'JsonObject',
@@ -185,15 +185,15 @@ TypeResult _resolveType(
185185
);
186186
}
187187

188-
case json_schema.Schema(type: json_schema.SchemaType.object, :final properties)
188+
case json_schema.JsonSchema(type: json_schema.JsonSchemaType.object, :final properties)
189189
when properties != null && properties.isEmpty:
190190
return TypeResultMap(
191191
'BuiltMap',
192192
TypeResultBase('JsonObject'),
193193
nullable: nullable,
194194
);
195195

196-
case json_schema.Schema(type: json_schema.SchemaType.object):
196+
case json_schema.JsonSchema(type: json_schema.JsonSchemaType.object):
197197
return resolveObject(
198198
spec,
199199
state,

packages/dynamite/dynamite/lib/src/helpers/dynamite.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ String clientName(String tag) => '\$${toDartName(tag, className: true)}Client';
88

99
bool isDartParameterNullable(
1010
bool required,
11-
json_schema.Schema? schema,
11+
json_schema.JsonSchema? schema,
1212
) =>
1313
(!required && schema?.$default == null) || (schema?.nullable ?? false);
1414

1515
bool isRequired(
1616
bool required,
17-
json_schema.Schema? schema,
17+
json_schema.JsonSchema? schema,
1818
) =>
1919
required && schema?.$default == null;
2020

packages/dynamite/dynamite/lib/src/helpers/pattern_check.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import 'package:code_builder/code_builder.dart';
22
import 'package:dynamite/src/models/json_schema.dart' as json_schema;
33

44
Iterable<Expression> buildPatternCheck(
5-
json_schema.Schema schema,
5+
json_schema.JsonSchema schema,
66
String value,
77
String name,
88
) sync* {
99
switch (schema.type) {
10-
case json_schema.SchemaType.string:
10+
case json_schema.JsonSchemaType.string:
1111
if (schema.pattern != null) {
1212
yield refer('checkPattern', 'package:dynamite_runtime/utils.dart').call([
1313
refer(value).asA(refer('String?')),
@@ -29,7 +29,7 @@ Iterable<Expression> buildPatternCheck(
2929
literalString(name),
3030
]);
3131
}
32-
case json_schema.SchemaType.array:
32+
case json_schema.JsonSchemaType.array:
3333
if (schema.minItems != null) {
3434
yield refer('checkMinItems', 'package:dynamite_runtime/utils.dart').call([
3535
refer(value).nullSafeProperty('length'),

packages/dynamite/dynamite/lib/src/models/json_schema.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export 'json_schema/schema.dart';
1010
part 'json_schema.g.dart';
1111

1212
@SerializersFor([
13-
Schema,
14-
SchemaType,
13+
JsonSchema,
14+
JsonSchemaType,
1515
])
1616
final Serializers serializers = (_$serializers.toBuilder()
1717
..addBuilderFactory(

packages/dynamite/dynamite/lib/src/models/json_schema.g.dart

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)