-
Notifications
You must be signed in to change notification settings - Fork 190
/
Copy pathCreatesSchema.js
78 lines (75 loc) · 2.11 KB
/
CreatesSchema.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
'use strict';
const makeSchema = require('../utils/makeSchema');
const { SKIP_KEY } = require('../constants');
const CreateSchema = require('./CreateSchema');
module.exports = makeSchema(
{
id: '/CreatesSchema',
description: 'Enumerates the 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 CreateSchema.',
$ref: CreateSchema.id,
},
},
examples: [
{
createRecipe: {
key: 'createRecipe',
noun: 'Recipe',
display: {
label: 'Create Recipe',
description: 'Creates a new recipe.',
},
operation: { perform: '$func$2$f$', sample: { id: 1 } },
},
},
{
Create_Recipe_01: {
key: 'Create_Recipe_01',
noun: 'Recipe',
display: {
label: 'Create Recipe',
description: 'Creates a new recipe.',
},
operation: { perform: '$func$2$f$', sample: { id: 1 } },
},
},
],
antiExamples: [
{
[SKIP_KEY]: true, // Cannot validate that key matches pattern
example: {
'01_Create_Recipe': {
key: '01_Create_Recipe',
noun: 'Recipe',
display: {
label: 'Create Recipe',
description: 'Creates a new recipe.',
},
operation: { perform: '$func$2$f$', sample: { id: 1 } },
},
},
reason: 'Key must start with a letter',
},
{
[SKIP_KEY]: true, // Cannot validate that keys match
example: {
Create_Recipe: {
key: 'createRecipe',
noun: 'Recipe',
display: {
label: 'Create Recipe',
description: 'Creates a new recipe.',
},
operation: { perform: '$func$2$f$', sample: { id: 1 } },
},
},
reason: 'Key must match the key field in CreateSchema',
},
],
},
[CreateSchema]
);