Skip to content

Commit 1c83533

Browse files
refactor: fix schema (#3315)
1 parent 2721ab2 commit 1c83533

File tree

3 files changed

+105
-105
lines changed

3 files changed

+105
-105
lines changed

lib/options.json

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616
},
1717
"publicPath": {
1818
"anyOf": [
19-
{
20-
"type": "string",
21-
"minLength": 1
22-
},
2319
{
2420
"type": "array",
2521
"items": {
2622
"type": "string",
2723
"minLength": 1
2824
},
2925
"minItems": 1
26+
},
27+
{
28+
"type": "string",
29+
"minLength": 1
3030
}
3131
],
3232
"description": "The bundled files will be available in the browser under this path."
@@ -74,37 +74,37 @@
7474
"properties": {
7575
"target": {
7676
"anyOf": [
77-
{
78-
"type": "boolean"
79-
},
80-
{
81-
"type": "string",
82-
"minLength": 1
83-
},
8477
{
8578
"type": "array",
8679
"items": {
8780
"type": "string",
8881
"minLength": 1
8982
},
9083
"minItems": 1
84+
},
85+
{
86+
"type": "boolean"
87+
},
88+
{
89+
"type": "string",
90+
"minLength": 1
9191
}
9292
],
9393
"description": "Open specified route in browser."
9494
},
9595
"app": {
9696
"anyOf": [
97-
{
98-
"type": "string",
99-
"minLength": 1
100-
},
10197
{
10298
"type": "array",
10399
"items": {
104100
"type": "string",
105101
"minLength": 1
106102
},
107103
"minItems": 1
104+
},
105+
{
106+
"type": "string",
107+
"minLength": 1
108108
}
109109
],
110110
"description": "Open specified browser."
@@ -120,16 +120,16 @@
120120
"properties": {
121121
"paths": {
122122
"anyOf": [
123-
{
124-
"type": "string",
125-
"minLength": 1
126-
},
127123
{
128124
"type": "array",
129125
"items": {
130126
"type": "string",
131127
"minLength": 1
132128
}
129+
},
130+
{
131+
"type": "string",
132+
"minLength": 1
133133
}
134134
]
135135
},
@@ -457,15 +457,6 @@
457457
},
458458
"open": {
459459
"anyOf": [
460-
{
461-
"$ref": "#/definitions/OpenBoolean"
462-
},
463-
{
464-
"$ref": "#/definitions/OpenString"
465-
},
466-
{
467-
"$ref": "#/definitions/OpenObject"
468-
},
469460
{
470461
"type": "array",
471462
"items": {
@@ -479,6 +470,15 @@
479470
]
480471
},
481472
"minItems": 1
473+
},
474+
{
475+
"$ref": "#/definitions/OpenBoolean"
476+
},
477+
{
478+
"$ref": "#/definitions/OpenString"
479+
},
480+
{
481+
"$ref": "#/definitions/OpenObject"
482482
}
483483
],
484484
"description": "Tells dev-server to open the browser after server had been started. Set it to true to open your default browser. https://webpack.js.org/configuration/dev-server/#devserveropen"
@@ -529,15 +529,6 @@
529529
},
530530
"static": {
531531
"anyOf": [
532-
{
533-
"type": "boolean"
534-
},
535-
{
536-
"$ref": "#/definitions/StaticString"
537-
},
538-
{
539-
"$ref": "#/definitions/StaticObject"
540-
},
541532
{
542533
"type": "array",
543534
"items": {
@@ -551,18 +542,21 @@
551542
]
552543
},
553544
"minItems": 1
545+
},
546+
{
547+
"type": "boolean"
548+
},
549+
{
550+
"$ref": "#/definitions/StaticString"
551+
},
552+
{
553+
"$ref": "#/definitions/StaticObject"
554554
}
555555
],
556556
"description": "It is possible to configure advanced options for serving static files from directory. See the Express documentation for the possible options. https://webpack.js.org/configuration/dev-server/#devserverstatic"
557557
},
558558
"watchFiles": {
559559
"anyOf": [
560-
{
561-
"$ref": "#/definitions/WatchFilesString"
562-
},
563-
{
564-
"$ref": "#/definitions/WatchFilesObject"
565-
},
566560
{
567561
"type": "array",
568562
"items": {
@@ -575,6 +569,12 @@
575569
}
576570
]
577571
}
572+
},
573+
{
574+
"$ref": "#/definitions/WatchFilesString"
575+
},
576+
{
577+
"$ref": "#/definitions/WatchFilesObject"
578578
}
579579
],
580580
"description": "List of files to watch for file changes and serve. https://webpack.js.org/configuration/dev-server/#devserverwatchfiles"

test/__snapshots__/validate-options.test.js.snap.webpack4

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -335,16 +335,16 @@ exports[`options validate should throw an error on the "open" option with '[]' v
335335
exports[`options validate should throw an error on the "open" option with '{"app":true}' value 1`] = `
336336
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
337337
- configuration.open should be one of these:
338-
boolean | non-empty string | object { target?, app? } | [non-empty string | object { target?, app? }, ...] (should not have fewer than 1 item)
338+
[non-empty string | object { target?, app? }, ...] (should not have fewer than 1 item) | boolean | non-empty string | object { target?, app? }
339339
-> Tells dev-server to open the browser after server had been started. Set it to true to open your default browser. https://webpack.js.org/configuration/dev-server/#devserveropen
340340
Details:
341341
* configuration.open.app should be one of these:
342-
non-empty string | [non-empty string, ...] (should not have fewer than 1 item)
342+
[non-empty string, ...] (should not have fewer than 1 item) | non-empty string
343343
-> Open specified browser.
344344
Details:
345-
* configuration.open.app should be a non-empty string.
346345
* configuration.open.app should be an array:
347-
[non-empty string, ...] (should not have fewer than 1 item)"
346+
[non-empty string, ...] (should not have fewer than 1 item)
347+
* configuration.open.app should be a non-empty string."
348348
`;
349349

350350
exports[`options validate should throw an error on the "open" option with '{"foo":"bar"}' value 1`] = `
@@ -356,17 +356,17 @@ exports[`options validate should throw an error on the "open" option with '{"foo
356356
exports[`options validate should throw an error on the "open" option with '{"target":90}' value 1`] = `
357357
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
358358
- configuration.open should be one of these:
359-
boolean | non-empty string | object { target?, app? } | [non-empty string | object { target?, app? }, ...] (should not have fewer than 1 item)
359+
[non-empty string | object { target?, app? }, ...] (should not have fewer than 1 item) | boolean | non-empty string | object { target?, app? }
360360
-> Tells dev-server to open the browser after server had been started. Set it to true to open your default browser. https://webpack.js.org/configuration/dev-server/#devserveropen
361361
Details:
362362
* configuration.open.target should be one of these:
363-
boolean | non-empty string | [non-empty string, ...] (should not have fewer than 1 item)
363+
[non-empty string, ...] (should not have fewer than 1 item) | boolean | non-empty string
364364
-> Open specified route in browser.
365365
Details:
366-
* configuration.open.target should be a boolean.
367-
* configuration.open.target should be a non-empty string.
368366
* configuration.open.target should be an array:
369-
[non-empty string, ...] (should not have fewer than 1 item)"
367+
[non-empty string, ...] (should not have fewer than 1 item)
368+
* configuration.open.target should be a boolean.
369+
* configuration.open.target should be a non-empty string."
370370
`;
371371

372372
exports[`options validate should throw an error on the "port" option with 'false' value 1`] = `
@@ -440,22 +440,22 @@ exports[`options validate should throw an error on the "static" option with '{"d
440440
exports[`options validate should throw an error on the "static" option with '{"publicPath":false}' value 1`] = `
441441
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
442442
- configuration.static should be one of these:
443-
boolean | non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? } | [non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item)
443+
[non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item) | boolean | non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }
444444
-> It is possible to configure advanced options for serving static files from directory. See the Express documentation for the possible options. https://webpack.js.org/configuration/dev-server/#devserverstatic
445445
Details:
446446
* configuration.static.publicPath should be one of these:
447-
non-empty string | [non-empty string, ...] (should not have fewer than 1 item)
447+
[non-empty string, ...] (should not have fewer than 1 item) | non-empty string
448448
-> The bundled files will be available in the browser under this path.
449449
Details:
450-
* configuration.static.publicPath should be a non-empty string.
451450
* configuration.static.publicPath should be an array:
452-
[non-empty string, ...] (should not have fewer than 1 item)"
451+
[non-empty string, ...] (should not have fewer than 1 item)
452+
* configuration.static.publicPath should be a non-empty string."
453453
`;
454454

455455
exports[`options validate should throw an error on the "static" option with '{"serveIndex":"true"}' value 1`] = `
456456
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
457457
- configuration.static should be one of these:
458-
boolean | non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? } | [non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item)
458+
[non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item) | boolean | non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }
459459
-> It is possible to configure advanced options for serving static files from directory. See the Express documentation for the possible options. https://webpack.js.org/configuration/dev-server/#devserverstatic
460460
Details:
461461
* configuration.static.serveIndex should be one of these:
@@ -470,7 +470,7 @@ exports[`options validate should throw an error on the "static" option with '{"s
470470
exports[`options validate should throw an error on the "static" option with '{"watch":10}' value 1`] = `
471471
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
472472
- configuration.static should be one of these:
473-
boolean | non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? } | [non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item)
473+
[non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item) | boolean | non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }
474474
-> It is possible to configure advanced options for serving static files from directory. See the Express documentation for the possible options. https://webpack.js.org/configuration/dev-server/#devserverstatic
475475
Details:
476476
* configuration.static.watch should be one of these:
@@ -486,55 +486,55 @@ exports[`options validate should throw an error on the "static" option with '{"w
486486
exports[`options validate should throw an error on the "static" option with '0' value 1`] = `
487487
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
488488
- configuration.static should be one of these:
489-
boolean | non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? } | [non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item)
489+
[non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item) | boolean | non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }
490490
-> It is possible to configure advanced options for serving static files from directory. See the Express documentation for the possible options. https://webpack.js.org/configuration/dev-server/#devserverstatic
491491
Details:
492+
* configuration.static should be an array:
493+
[non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item)
492494
* configuration.static should be a boolean.
493495
* configuration.static should be a non-empty string.
494496
* configuration.static should be an object:
495-
object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }
496-
* configuration.static should be an array:
497-
[non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item)"
497+
object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }"
498498
`;
499499

500500
exports[`options validate should throw an error on the "static" option with 'null' value 1`] = `
501501
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
502502
- configuration.static should be one of these:
503-
boolean | non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? } | [non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item)
503+
[non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item) | boolean | non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }
504504
-> It is possible to configure advanced options for serving static files from directory. See the Express documentation for the possible options. https://webpack.js.org/configuration/dev-server/#devserverstatic
505505
Details:
506+
* configuration.static should be an array:
507+
[non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item)
506508
* configuration.static should be a boolean.
507509
* configuration.static should be a non-empty string.
508510
* configuration.static should be an object:
509-
object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }
510-
* configuration.static should be an array:
511-
[non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item)"
511+
object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }"
512512
`;
513513

514514
exports[`options validate should throw an error on the "watchFiles" option with '123' value 1`] = `
515515
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
516516
- configuration.watchFiles should be one of these:
517-
non-empty string | object { paths?, options? } | [non-empty string | object { paths?, options? }, ...]
517+
[non-empty string | object { paths?, options? }, ...] | non-empty string | object { paths?, options? }
518518
-> List of files to watch for file changes and serve. https://webpack.js.org/configuration/dev-server/#devserverwatchfiles
519519
Details:
520+
* configuration.watchFiles should be an array:
521+
[non-empty string | object { paths?, options? }, ...]
520522
* configuration.watchFiles should be a non-empty string.
521523
* configuration.watchFiles should be an object:
522-
object { paths?, options? }
523-
* configuration.watchFiles should be an array:
524-
[non-empty string | object { paths?, options? }, ...]"
524+
object { paths?, options? }"
525525
`;
526526

527527
exports[`options validate should throw an error on the "watchFiles" option with 'false' value 1`] = `
528528
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
529529
- configuration.watchFiles should be one of these:
530-
non-empty string | object { paths?, options? } | [non-empty string | object { paths?, options? }, ...]
530+
[non-empty string | object { paths?, options? }, ...] | non-empty string | object { paths?, options? }
531531
-> List of files to watch for file changes and serve. https://webpack.js.org/configuration/dev-server/#devserverwatchfiles
532532
Details:
533+
* configuration.watchFiles should be an array:
534+
[non-empty string | object { paths?, options? }, ...]
533535
* configuration.watchFiles should be a non-empty string.
534536
* configuration.watchFiles should be an object:
535-
object { paths?, options? }
536-
* configuration.watchFiles should be an array:
537-
[non-empty string | object { paths?, options? }, ...]"
537+
object { paths?, options? }"
538538
`;
539539

540540
exports[`options validate should throw an error on the "webSocketServer" option with '{"notAnOption":true}' value 1`] = `

0 commit comments

Comments
 (0)