Skip to content

Commit 250107f

Browse files
committed
fix: schema for server option
1 parent 6d060ed commit 250107f

File tree

4 files changed

+35
-18
lines changed

4 files changed

+35
-18
lines changed

lib/options.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -636,9 +636,6 @@
636636
{
637637
"$ref": "#/definitions/ServerEnum"
638638
},
639-
{
640-
"$ref": "#/definitions/ServerString"
641-
},
642639
{
643640
"$ref": "#/definitions/ServerObject"
644641
}
@@ -655,13 +652,6 @@
655652
"exclude": true
656653
}
657654
},
658-
"ServerString": {
659-
"type": "string",
660-
"minLength": 1,
661-
"cli": {
662-
"exclude": true
663-
}
664-
},
665655
"ServerObject": {
666656
"type": "object",
667657
"properties": {

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ exports[`options validate should throw an error on the "server" option with '{"t
617617
exports[`options validate should throw an error on the "server" option with '{"type":"https","options":{"ca":true}}' value 1`] = `
618618
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
619619
- options.server should be one of these:
620-
\\"http\\" | \\"https\\" | \\"spdy\\" | non-empty string | object { type?, options? }
620+
\\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? }
621621
-> Allows to set server and options (by default 'http').
622622
-> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver
623623
Details:
@@ -634,7 +634,7 @@ exports[`options validate should throw an error on the "server" option with '{"t
634634
exports[`options validate should throw an error on the "server" option with '{"type":"https","options":{"cert":true}}' value 1`] = `
635635
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
636636
- options.server should be one of these:
637-
\\"http\\" | \\"https\\" | \\"spdy\\" | non-empty string | object { type?, options? }
637+
\\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? }
638638
-> Allows to set server and options (by default 'http').
639639
-> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver
640640
Details:
@@ -651,7 +651,7 @@ exports[`options validate should throw an error on the "server" option with '{"t
651651
exports[`options validate should throw an error on the "server" option with '{"type":"https","options":{"key":10}}' value 1`] = `
652652
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
653653
- options.server should be one of these:
654-
\\"http\\" | \\"https\\" | \\"spdy\\" | non-empty string | object { type?, options? }
654+
\\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? }
655655
-> Allows to set server and options (by default 'http').
656656
-> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver
657657
Details:
@@ -674,7 +674,7 @@ exports[`options validate should throw an error on the "server" option with '{"t
674674
exports[`options validate should throw an error on the "server" option with '{"type":"https","options":{"pfx":10}}' value 1`] = `
675675
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
676676
- options.server should be one of these:
677-
\\"http\\" | \\"https\\" | \\"spdy\\" | non-empty string | object { type?, options? }
677+
\\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? }
678678
-> Allows to set server and options (by default 'http').
679679
-> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver
680680
Details:
@@ -694,6 +694,19 @@ exports[`options validate should throw an error on the "server" option with '{"t
694694
-> Request for an SSL certificate."
695695
`;
696696

697+
exports[`options validate should throw an error on the "server" option with 'invalid' value 1`] = `
698+
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
699+
- options.server should be one of these:
700+
\\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? }
701+
-> Allows to set server and options (by default 'http').
702+
-> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver
703+
Details:
704+
* options.server should be one of these:
705+
\\"http\\" | \\"https\\" | \\"spdy\\"
706+
* options.server should be an object:
707+
object { type?, options? }"
708+
`;
709+
697710
exports[`options validate should throw an error on the "static" option with '' value 1`] = `
698711
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
699712
- options.static should be a non-empty string."

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ exports[`options validate should throw an error on the "server" option with '{"t
617617
exports[`options validate should throw an error on the "server" option with '{"type":"https","options":{"ca":true}}' value 1`] = `
618618
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
619619
- options.server should be one of these:
620-
\\"http\\" | \\"https\\" | \\"spdy\\" | non-empty string | object { type?, options? }
620+
\\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? }
621621
-> Allows to set server and options (by default 'http').
622622
-> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver
623623
Details:
@@ -634,7 +634,7 @@ exports[`options validate should throw an error on the "server" option with '{"t
634634
exports[`options validate should throw an error on the "server" option with '{"type":"https","options":{"cert":true}}' value 1`] = `
635635
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
636636
- options.server should be one of these:
637-
\\"http\\" | \\"https\\" | \\"spdy\\" | non-empty string | object { type?, options? }
637+
\\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? }
638638
-> Allows to set server and options (by default 'http').
639639
-> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver
640640
Details:
@@ -651,7 +651,7 @@ exports[`options validate should throw an error on the "server" option with '{"t
651651
exports[`options validate should throw an error on the "server" option with '{"type":"https","options":{"key":10}}' value 1`] = `
652652
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
653653
- options.server should be one of these:
654-
\\"http\\" | \\"https\\" | \\"spdy\\" | non-empty string | object { type?, options? }
654+
\\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? }
655655
-> Allows to set server and options (by default 'http').
656656
-> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver
657657
Details:
@@ -674,7 +674,7 @@ exports[`options validate should throw an error on the "server" option with '{"t
674674
exports[`options validate should throw an error on the "server" option with '{"type":"https","options":{"pfx":10}}' value 1`] = `
675675
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
676676
- options.server should be one of these:
677-
\\"http\\" | \\"https\\" | \\"spdy\\" | non-empty string | object { type?, options? }
677+
\\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? }
678678
-> Allows to set server and options (by default 'http').
679679
-> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver
680680
Details:
@@ -694,6 +694,19 @@ exports[`options validate should throw an error on the "server" option with '{"t
694694
-> Request for an SSL certificate."
695695
`;
696696

697+
exports[`options validate should throw an error on the "server" option with 'invalid' value 1`] = `
698+
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
699+
- options.server should be one of these:
700+
\\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? }
701+
-> Allows to set server and options (by default 'http').
702+
-> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver
703+
Details:
704+
* options.server should be one of these:
705+
\\"http\\" | \\"https\\" | \\"spdy\\"
706+
* options.server should be an object:
707+
object { type?, options? }"
708+
`;
709+
697710
exports[`options validate should throw an error on the "static" option with '' value 1`] = `
698711
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
699712
- options.static should be a non-empty string."

test/validate-options.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ const tests = {
415415
},
416416
],
417417
failure: [
418+
"invalid",
418419
{
419420
type: "https",
420421
additional: "test",

0 commit comments

Comments
 (0)