Skip to content

Commit

Permalink
doc: Add the default value to the examples
Browse files Browse the repository at this point in the history
  • Loading branch information
marcbachmann committed Apr 7, 2021
1 parent acfcf8b commit e490e5b
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,19 +208,55 @@ output = {
}
```

Add title and description:
Add `title` and `description` annotations to the schema:
```js
ms.obj({
displayName: 'string',
}, {title: 'Title', description: 'Desc.'})

output = {
type: 'object',
title: 'Title',
description: 'Desc.',
properties: {
displayName: {type: 'string'}
}
}
```

Add dependencies:
Add `dependencies`:
```js
ms.obj({
creditCard: 'string',
address: 'string'
}, {dependencies: {creditCard: 'address'}})

output = {
type: 'object',
properties: {
creditCard: {type: 'string'},
address: {type: 'string'}
},
dependencies: {
creditCard: ['address']
}
}
```

Set a `default` value in case the property is absent:
```js
ms.obj({
creditCard: 'string',
address: 'string'
}, {default: {}})

output = {
type: 'object',
default: {},
properties: {
count: {type: 'integer'}
}
}
```


Expand Down

0 comments on commit e490e5b

Please sign in to comment.