Skip to content

#124 make type detector smarter #138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Aug 30, 2023
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Changelog
## [7.0.0] - 2023-08-14
*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>'.

## [6.3.0] - 2023-06-05
- Fixed the deprecated `ignore` field. Added
```
```yaml
includeFromJson: false
includeToJson: false
```
Expand Down
107 changes: 49 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ UserModel:
path: webservice/user
equals_and_hash_code: false
properties:
id:
type: int
id: int
```

### Ignored fields
Expand All @@ -87,8 +86,7 @@ UserModel:
id:
type: int
ignore_equality: true
include:
type: String
include: String
```

## explicit_to_json
Expand All @@ -108,8 +106,7 @@ UserModel:
path: webservice/user
explicit_to_json: false
properties:
id:
type: int
id: int
```

## toString
Expand All @@ -129,8 +126,7 @@ UserModel:
path: webservice/user
to_string: false
properties:
id:
type: int
id: int
```

## Extra imports and annotations
Expand All @@ -154,8 +150,7 @@ UserModel:
extra_annotations:
- '@someAnnotation'
properties:
id:
type: int
id: int
```

## Default values
Expand All @@ -178,7 +173,6 @@ UserModel:
default_value: 1
name:
type: String
required: true
default_value: "'an example quoted string'"
```

Expand Down Expand Up @@ -208,7 +202,6 @@ UserModel:
default_value: 1
name:
type: String
required: true
default_value: "'an example quoted string'"
```

Expand All @@ -223,7 +216,6 @@ UserModel:
default_value: 1
name:
type: String
required: true
default_value: "'an example quoted string'"
disallow_null: true
```
Expand All @@ -246,8 +238,7 @@ UserModel:
converters:
- DateTimeConverter
properties:
id:
type: int
id: int
```

## Extends
Expand All @@ -261,8 +252,7 @@ UserDetails:
path: webservice/user
extends: UserModel
properties:
name:
type: String
name: String
```

## Builtin types
Expand All @@ -288,37 +278,21 @@ UserModel:
converters:
- DateTimeConverter
properties:
id:
type: int
name:
type: String
salary:
type: double
something:
type: dynamic
id: int
name: String
salary: double
something: dynamic
isLoggedIn:
type: bool
default_value: false
roles:
type: array
items:
type: String
birthday:
type: date
addresses:
type: array
items:
type: Address
idToAddress:
type: map
items:
key: String
value: Address
roles: List<String>
birthday: date
addresses: List<Address>
idToAddress: Map<String, Address>
securityRole:
type: String
jsonKey: securityIndicator
dynamicField:
type: dynamic
dynamicField: dynamic
includeIfNullField:
include_if_null: false #If this field is null, this field will not be added to your json object (used for PATCH models)
type: String
Expand All @@ -335,26 +309,20 @@ UserModel:
non_final: true #Field will not be marked final
type: String
changedAt:
type: datetime
idToAddressList:
type: map
items:
key: String
value: List<Address>
type: DateTime
idToAddressList: Map<String, List<Address>>

Address:
path: webservice/user #Can also be package:... and/or end with the actual file (.dart)
properties:
street:
type: String
street: String

#Custom base_directory
CustomBaseDirectoryObject:
base_directory: custom_models
path: webservice
properties:
path:
type: String
path: String

#Custom json converter. Use with converters property on models
DateTimeConverter:
Expand All @@ -378,6 +346,32 @@ UserModel:
roles: List<string>
customProperties: Map<String, Property>?
```
since 7.0.0 inline types are supported now even when adding extra configuration:

before:
```yaml
BookCase:
path: webservice/BookCases
properties:
id: int
books:
type: array
items:
type: Book
required: false
include_if_null: false
```

now:
```yaml
BookCase:
path: webservice/BookCases
properties:
id: int
books:
type: List<Book>?
include_if_null: false
```

Currently all basic types are supported, simple Lists and Maps (no nested types, no nullable generic parameters) as well as references to other objects.
Items post-fixed with `?` will be marked optional.
Expand Down Expand Up @@ -537,8 +531,7 @@ UserModel:
converters:
- DateTimeConverter
properties:
changedAt:
type: datetime
changedAt: DateTime
```

Specify the custom JsonConverter object as a known type to resolve it
Expand All @@ -561,8 +554,7 @@ UserModel:
- DateTimeConverter
properties:
description: The time at which the user has last updated his information
changedAt:
type: datetime
changedAt: DateTime
```

## Static creator support
Expand All @@ -575,8 +567,7 @@ UserModel:
path: webservice/user
static_create: true
properties:
changedAt:
type: datetime
changedAt: DateTime
```

## Retrofit compute support
Expand Down
Loading