go-mokapi 0.9.14 → 0.9.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "go-mokapi",
3
- "version": "0.9.14",
3
+ "version": "0.9.16",
4
4
  "description": "Easy and flexible API mocking",
5
5
  "homepage": "https://mokapi.io",
6
6
  "repository": {
package/types/faker.d.ts CHANGED
@@ -12,7 +12,7 @@ import { JSONValue } from ".";
12
12
  * console.log(fake({type: 'string', pattern: '^\d{3}-\d{2}-\d{4}$'})) // 123-45-6789
13
13
  * }
14
14
  */
15
- export function fake(schema: Schema): JSONValue;
15
+ export function fake(schema: Schema | FakeRequest): JSONValue;
16
16
 
17
17
  /**
18
18
  * Gets the tree node with the given name
@@ -26,56 +26,182 @@ export function fake(schema: Schema): JSONValue;
26
26
  */
27
27
  export function findByName(name: string): Tree
28
28
 
29
- export const RootName = ''
29
+ export const RootName = 'Faker'
30
30
 
31
31
  export interface Tree {
32
32
  name: string
33
- test: () => boolean
34
- fake: () => JSONValue
33
+ readonly test: () => boolean
34
+ readonly fake: () => JSONValue
35
35
 
36
- append?: (node: Tree) => void
37
- insert?: (index: number, node: Tree) => void
36
+ append: (node: Tree | CustomTree) => void
37
+ insert: (index: number, node: Tree | CustomTree) => void
38
+ removeAt: (index: number) => void
39
+ remove: (name: string) => void
38
40
  }
39
41
 
40
- export interface Request {
42
+ export interface CustomTree {
43
+ name: string
44
+ test: (r: Request) => boolean
45
+ fake: (r: Request) => JSONValue
46
+ }
47
+
48
+ export interface FakeRequest {
41
49
  names: string[]
42
50
  schema: JSONSchema
43
51
  }
44
52
 
53
+ export interface Request {
54
+ Path: PathElement[]
55
+
56
+ last: () => PathElement
57
+ lastName: () => string
58
+ lastSchema: () => JSONSchema
59
+ }
60
+
61
+ export interface PathElement {
62
+ name: string
63
+ schema: JSONSchema
64
+ }
65
+
66
+ /**
67
+ * JSON Schema defines a JSON-based format for describing the structure of JSON data
68
+ * @example
69
+ * {
70
+ * "type": "string",
71
+ * "format": "email"
72
+ * }
73
+ */
45
74
  export interface JSONSchema {
75
+ /**
76
+ * Specifies the data type for a schema.
77
+ */
46
78
  type: string | string[]
79
+
80
+ /**
81
+ * The enum keyword is used to restrict a value to a fixed set of values.
82
+ */
47
83
  enum: unknown[]
84
+
85
+ /**
86
+ * The const keyword is used to restrict a value to a single value.
87
+ */
48
88
  const: unknown
89
+
90
+ /**
91
+ * Contains a list of valid examples.
92
+ */
49
93
  examples: unknown[]
50
94
 
51
95
  // Numbers
96
+ /**
97
+ * Restricts the number to a multiple of the given number
98
+ */
52
99
  multipleOf: number | undefined
100
+
101
+ /**
102
+ * Restricts the number to a maximum number
103
+ */
53
104
  maximum: number | undefined
105
+
106
+ /**
107
+ * Restricts the number to a exclusive maximum number
108
+ */
54
109
  exclusiveMaximum: number | undefined
110
+
111
+ /**
112
+ * Restricts the number to a minimum number
113
+ */
55
114
  minimum: number | undefined
115
+
116
+ /**
117
+ * Restricts the number to a exclusive minimum number
118
+ */
56
119
  exclusiveMinimum: number | undefined
57
120
 
58
121
  // Strings
122
+ /**
123
+ * Restricts the string to a maximum length
124
+ */
59
125
  maxLength: number | undefined
126
+
127
+ /**
128
+ * Restricts the string to a minimum length
129
+ */
60
130
  minLength: number | undefined
131
+
132
+ /**
133
+ * The pattern keyword is used to restrict a string to a particular regular expression.
134
+ */
61
135
  pattern: string
136
+
137
+ /**
138
+ * The format keyword allows for basic semantic identification of certain kinds of string values that are commonly used.
139
+ */
62
140
  format: string
63
141
 
64
142
  // Arrays
143
+ /**
144
+ * Specifies the schema of the items in the array.
145
+ */
65
146
  items: JSONSchema | undefined
147
+
148
+ /**
149
+ * Restricts the array to have a maximum length
150
+ */
66
151
  maxItems: number | undefined
152
+
153
+ /**
154
+ * Restricts the array to have a minimum length
155
+ */
67
156
  minItems: number | undefined
157
+
158
+ /**
159
+ * Restricts the array to have unique items
160
+ */
68
161
  uniqueItems: boolean
69
162
 
70
163
  // Objects
164
+ /**
165
+ * Specifies the properties of an object
166
+ */
71
167
  properties: { [name: string]: JSONSchema }
168
+
169
+ /**
170
+ * Restricts the object to have a maximum of properties
171
+ */
72
172
  maxProperties: number | undefined
173
+
174
+ /**
175
+ * Restricts the object to have a minimum of properties
176
+ */
73
177
  minProperties: number | undefined
178
+
179
+ /**
180
+ * Specifies the required properties for an object
181
+ */
74
182
  required: string[] | undefined
183
+
184
+ /**
185
+ * The additionalProperties keyword is used to control the handling of extra stuff,
186
+ * that is, properties whose names are not listed in the properties keyword or match
187
+ * any of the regular expressions in the patternProperties keyword. By default, any
188
+ * additional properties are allowed.
189
+ */
75
190
  additionalProperties: boolean | JSONSchema | undefined
76
191
 
192
+ /**
193
+ * A value must be valid against all the schemas
194
+ */
77
195
  allOf: JSONSchema[] | undefined
196
+
197
+ /**
198
+ * A value must be valid against any the schemas
199
+ */
78
200
  anyOf: JSONSchema[] | undefined
201
+
202
+ /**
203
+ * A value must be valid against exactly one the schemas
204
+ */
79
205
  oneOf: JSONSchema[] | undefined
80
206
 
81
207
  isAny: () => boolean