Skip to content

Commit

Permalink
fix(appium): restrict address to ipv6/hostname (#18824)
Browse files Browse the repository at this point in the history
This resolves #18716.

For whatever reason, `json-schema-to-typescript` needed `"type": "string"` in there.  See bcherny/json-schema-to-typescript#528 for further discussion
  • Loading branch information
boneskull committed Jun 30, 2023
1 parent 97fe159 commit f09fbb6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
4 changes: 4 additions & 0 deletions packages/appium/test/fixtures/flattened-schema.js
Expand Up @@ -16,6 +16,10 @@ export default [
description: 'IPv4/IPv6 address or a hostname to listen on',
title: 'address config',
type: 'string',
anyOf: [
{format: 'hostname', type: 'string'},
{format: 'ipv6', type: 'string'}
]
},
},
{
Expand Down
11 changes: 10 additions & 1 deletion packages/schema/lib/appium-config-schema.js
Expand Up @@ -26,7 +26,16 @@ export const AppiumConfigJsonSchema = /** @type {const} */ ({
description: 'IPv4/IPv6 address or a hostname to listen on',
title: 'address config',
type: 'string',
// this should be anyOf [format: "hostname" or format: "ipv6"], but there seems to be a bug in json-schema-to-typescript preventing "ipv6" from converting to type "string"'
anyOf: [
{
type: 'string',
format: 'hostname',
},
{
type: 'string',
format: 'ipv6',
},
],
},
'allow-cors': {
description:
Expand Down
12 changes: 11 additions & 1 deletion packages/schema/lib/appium-config.schema.json
Expand Up @@ -20,7 +20,17 @@
"default": "0.0.0.0",
"description": "IPv4/IPv6 address or a hostname to listen on",
"title": "address config",
"type": "string"
"type": "string",
"anyOf": [
{
"type": "string",
"format": "hostname"
},
{
"type": "string",
"format": "ipv6"
}
]
},
"allow-cors": {
"description": "Whether the Appium server should allow web browser connections from any host",
Expand Down
4 changes: 3 additions & 1 deletion packages/types/lib/appium-config.ts
Expand Up @@ -8,7 +8,9 @@
/**
* IPv4/IPv6 address or a hostname to listen on
*/
export type AddressConfig = string;
export type AddressConfig = AddressConfig1 & AddressConfig2;
export type AddressConfig1 = string;
export type AddressConfig2 = string;
/**
* Whether the Appium server should allow web browser connections from any host
*/
Expand Down

0 comments on commit f09fbb6

Please sign in to comment.