Skip to content

Commit 8feb918

Browse files
Merge pull request #138 from icapps/#124-make-type-detector-smarter
#124 make type detector smarter
2 parents 212efb5 + db19c2b commit 8feb918

File tree

53 files changed

+263
-361
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+263
-361
lines changed

CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Changelog
2+
## [7.0.0] - 2023-08-14
3+
*BREAKING CHANGE*: Every type is now defined inline, this means that 'required' is no longer supported, if a field isn't nullable it is automatically required. This also means that the 'array' type is no longer supported and is instead just defined like 'List<T>'.
4+
25
## [6.3.0] - 2023-06-05
36
- Fixed the deprecated `ignore` field. Added
4-
```
7+
```yaml
58
includeFromJson: false
69
includeToJson: false
710
```

README.md

+49-58
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ UserModel:
6969
path: webservice/user
7070
equals_and_hash_code: false
7171
properties:
72-
id:
73-
type: int
72+
id: int
7473
```
7574

7675
### Ignored fields
@@ -87,8 +86,7 @@ UserModel:
8786
id:
8887
type: int
8988
ignore_equality: true
90-
include:
91-
type: String
89+
include: String
9290
```
9391

9492
## explicit_to_json
@@ -108,8 +106,7 @@ UserModel:
108106
path: webservice/user
109107
explicit_to_json: false
110108
properties:
111-
id:
112-
type: int
109+
id: int
113110
```
114111

115112
## toString
@@ -129,8 +126,7 @@ UserModel:
129126
path: webservice/user
130127
to_string: false
131128
properties:
132-
id:
133-
type: int
129+
id: int
134130
```
135131

136132
## Extra imports and annotations
@@ -154,8 +150,7 @@ UserModel:
154150
extra_annotations:
155151
- '@someAnnotation'
156152
properties:
157-
id:
158-
type: int
153+
id: int
159154
```
160155

161156
## Default values
@@ -178,7 +173,6 @@ UserModel:
178173
default_value: 1
179174
name:
180175
type: String
181-
required: true
182176
default_value: "'an example quoted string'"
183177
```
184178

@@ -208,7 +202,6 @@ UserModel:
208202
default_value: 1
209203
name:
210204
type: String
211-
required: true
212205
default_value: "'an example quoted string'"
213206
```
214207

@@ -223,7 +216,6 @@ UserModel:
223216
default_value: 1
224217
name:
225218
type: String
226-
required: true
227219
default_value: "'an example quoted string'"
228220
disallow_null: true
229221
```
@@ -246,8 +238,7 @@ UserModel:
246238
converters:
247239
- DateTimeConverter
248240
properties:
249-
id:
250-
type: int
241+
id: int
251242
```
252243

253244
## Extends
@@ -261,8 +252,7 @@ UserDetails:
261252
path: webservice/user
262253
extends: UserModel
263254
properties:
264-
name:
265-
type: String
255+
name: String
266256
```
267257

268258
## Builtin types
@@ -288,37 +278,21 @@ UserModel:
288278
converters:
289279
- DateTimeConverter
290280
properties:
291-
id:
292-
type: int
293-
name:
294-
type: String
295-
salary:
296-
type: double
297-
something:
298-
type: dynamic
281+
id: int
282+
name: String
283+
salary: double
284+
something: dynamic
299285
isLoggedIn:
300286
type: bool
301287
default_value: false
302-
roles:
303-
type: array
304-
items:
305-
type: String
306-
birthday:
307-
type: date
308-
addresses:
309-
type: array
310-
items:
311-
type: Address
312-
idToAddress:
313-
type: map
314-
items:
315-
key: String
316-
value: Address
288+
roles: List<String>
289+
birthday: date
290+
addresses: List<Address>
291+
idToAddress: Map<String, Address>
317292
securityRole:
318293
type: String
319294
jsonKey: securityIndicator
320-
dynamicField:
321-
type: dynamic
295+
dynamicField: dynamic
322296
includeIfNullField:
323297
include_if_null: false #If this field is null, this field will not be added to your json object (used for PATCH models)
324298
type: String
@@ -335,26 +309,20 @@ UserModel:
335309
non_final: true #Field will not be marked final
336310
type: String
337311
changedAt:
338-
type: datetime
339-
idToAddressList:
340-
type: map
341-
items:
342-
key: String
343-
value: List<Address>
312+
type: DateTime
313+
idToAddressList: Map<String, List<Address>>
344314
345315
Address:
346316
path: webservice/user #Can also be package:... and/or end with the actual file (.dart)
347317
properties:
348-
street:
349-
type: String
318+
street: String
350319
351320
#Custom base_directory
352321
CustomBaseDirectoryObject:
353322
base_directory: custom_models
354323
path: webservice
355324
properties:
356-
path:
357-
type: String
325+
path: String
358326
359327
#Custom json converter. Use with converters property on models
360328
DateTimeConverter:
@@ -378,6 +346,32 @@ UserModel:
378346
roles: List<string>
379347
customProperties: Map<String, Property>?
380348
```
349+
since 7.0.0 inline types are supported now even when adding extra configuration:
350+
351+
before:
352+
```yaml
353+
BookCase:
354+
path: webservice/BookCases
355+
properties:
356+
id: int
357+
books:
358+
type: array
359+
items:
360+
type: Book
361+
required: false
362+
include_if_null: false
363+
```
364+
365+
now:
366+
```yaml
367+
BookCase:
368+
path: webservice/BookCases
369+
properties:
370+
id: int
371+
books:
372+
type: List<Book>?
373+
include_if_null: false
374+
```
381375

382376
Currently all basic types are supported, simple Lists and Maps (no nested types, no nullable generic parameters) as well as references to other objects.
383377
Items post-fixed with `?` will be marked optional.
@@ -537,8 +531,7 @@ UserModel:
537531
converters:
538532
- DateTimeConverter
539533
properties:
540-
changedAt:
541-
type: datetime
534+
changedAt: DateTime
542535
```
543536
544537
Specify the custom JsonConverter object as a known type to resolve it
@@ -561,8 +554,7 @@ UserModel:
561554
- DateTimeConverter
562555
properties:
563556
description: The time at which the user has last updated his information
564-
changedAt:
565-
type: datetime
557+
changedAt: DateTime
566558
```
567559

568560
## Static creator support
@@ -575,8 +567,7 @@ UserModel:
575567
path: webservice/user
576568
static_create: true
577569
properties:
578-
changedAt:
579-
type: datetime
570+
changedAt: DateTime
580571
```
581572

582573
## Retrofit compute support

0 commit comments

Comments
 (0)