You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+48
Original file line number
Diff line number
Diff line change
@@ -179,6 +179,52 @@ UserModel:
179
179
default_value: "'an example quoted string'"
180
180
```
181
181
182
+
### Default values and null
183
+
184
+
Since version `5.9.0` fields with default values can accept null values in json. In which case the default value will be used instead.
185
+
186
+
If you wish to control this behaviour, you can add `disallow_null_for_defaults: true` to either the `model_generator` config or the model property. Alternatively you can specify
187
+
the behaviour per field by using `disallow_null`.
188
+
189
+
Example:
190
+
191
+
```yaml
192
+
model_generator:
193
+
disallow_null_for_defaults: true
194
+
```
195
+
196
+
Example 2:
197
+
198
+
```yaml
199
+
UserModel:
200
+
path: webservice/user
201
+
disallow_null_for_defaults: true
202
+
properties:
203
+
id:
204
+
type: int
205
+
default_value: 1
206
+
name:
207
+
type: string
208
+
required: true
209
+
default_value: "'an example quoted string'"
210
+
```
211
+
212
+
Example 3:
213
+
214
+
```yaml
215
+
UserModel:
216
+
path: webservice/user
217
+
properties:
218
+
id:
219
+
type: int
220
+
default_value: 1
221
+
name:
222
+
type: string
223
+
required: true
224
+
default_value: "'an example quoted string'"
225
+
disallow_null: true
226
+
```
227
+
182
228
## Generics support support
183
229
184
230
If you want your models to generate code that can be used in combination with generics. use this:
@@ -202,9 +248,11 @@ UserModel:
202
248
```
203
249
204
250
## Extends
251
+
205
252
If you want your models to expand any other model use extends:
206
253
207
254
*Note: It is not supported to extend custom models*
0 commit comments