-
Notifications
You must be signed in to change notification settings - Fork 187
/
Copy pathSearchOrCreatesSchema.js
60 lines (57 loc) · 1.71 KB
/
SearchOrCreatesSchema.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
'use strict';
const makeSchema = require('../utils/makeSchema');
const { SKIP_KEY } = require('../constants');
const SearchOrCreateSchema = require('./SearchOrCreateSchema');
module.exports = makeSchema(
{
id: '/SearchOrCreatesSchema',
description:
'Enumerates the search-or-creates your app has available for users.',
type: 'object',
patternProperties: {
'^[a-zA-Z]+[a-zA-Z0-9_]*$': {
description:
'Any unique key can be used and its values will be validated against the SearchOrCreateSchema.',
$ref: SearchOrCreateSchema.id,
},
},
examples: [
{
searchOrCreateWidgets: {
key: 'searchOrCreateWidgets',
display: {
label: 'Search or Create Widgets',
description:
'Searches for a widget matching the provided query, or creates one if it does not exist.',
important: true,
hidden: false,
},
search: 'searchWidgets',
create: 'createWidget',
},
},
],
antiExamples: [
{
[SKIP_KEY]: true, // Cannot validate that keys match
example: {
searchOrCreateWidgets: {
key: 'socWidgets',
display: {
label: 'Search or Create Widgets',
description:
'Searches for a widget matching the provided query, or creates one if it does not exist.',
important: true,
hidden: false,
},
search: 'searchWidgets',
create: 'createWidget',
},
},
reason:
'Key must match the key of the associated /SearchOrCreateSchema',
},
],
},
[SearchOrCreateSchema]
);