diff --git a/gns3server/schemas/ethernet_hub.py b/gns3server/schemas/ethernet_hub.py index 363ad470..71873bc4 100644 --- a/gns3server/schemas/ethernet_hub.py +++ b/gns3server/schemas/ethernet_hub.py @@ -17,28 +17,30 @@ import copy +ETHERNET_HUB_PORT_SCHEMA = { + "description": "Ethernet port", + "properties": { + "name": { + "description": "Port name", + "type": "string", + "minLength": 1, + }, + "port_number": { + "description": "Port number", + "type": "integer", + "minimum": 0 + }, + }, + "required": ["name", "port_number"], + "additionalProperties": False +} + ETHERNET_HUB_CREATE_SCHEMA = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Request validation to create a new Ethernet hub instance", "type": "object", "definitions": { - "EthernetHubPort": { - "description": "Ethernet port", - "properties": { - "name": { - "description": "Port name", - "type": "string", - "minLength": 1, - }, - "port_number": { - "description": "Port number", - "type": "integer", - "minimum": 0 - }, - }, - "required": ["name", "port_number"], - "additionalProperties": False - }, + "EthernetHubPort": ETHERNET_HUB_PORT_SCHEMA }, "properties": { "name": { @@ -57,12 +59,9 @@ ETHERNET_HUB_CREATE_SCHEMA = { }, "ports_mapping": { "type": "array", - "items": [ - {"type": "object", - "oneOf": [ - {"$ref": "#/definitions/EthernetHubPort"} - ]}, - ] + "items": { + "$ref": "#/definitions/EthernetHubPort" + } }, }, "additionalProperties": False, @@ -74,23 +73,7 @@ ETHERNET_HUB_OBJECT_SCHEMA = { "description": "Ethernet hub instance", "type": "object", "definitions": { - "EthernetHubPort": { - "description": "Ethernet port", - "properties": { - "name": { - "description": "Port name", - "type": "string", - "minLength": 1, - }, - "port_number": { - "description": "Port number", - "type": "integer", - "minimum": 0 - }, - }, - "required": ["name", "port_number"], - "additionalProperties": False - }, + "EthernetHubPort": ETHERNET_HUB_PORT_SCHEMA }, "properties": { "name": { @@ -114,12 +97,9 @@ ETHERNET_HUB_OBJECT_SCHEMA = { }, "ports_mapping": { "type": "array", - "items": [ - {"type": "object", - "oneOf": [ - {"$ref": "#/definitions/EthernetHubPort"} - ]}, - ] + "items": { + "$ref": "#/definitions/EthernetHubPort" + } }, "status": { "description": "Node status", diff --git a/gns3server/schemas/ethernet_switch.py b/gns3server/schemas/ethernet_switch.py index 52951d3b..e8738b83 100644 --- a/gns3server/schemas/ethernet_switch.py +++ b/gns3server/schemas/ethernet_switch.py @@ -17,40 +17,42 @@ import copy +ETHERNET_SWITCH_PORT_SCHEMA = { + "description": "Ethernet switch port", + "properties": { + "name": { + "description": "Port name", + "type": "string", + "minLength": 1, + }, + "port_number": { + "description": "Port number", + "type": "integer", + "minimum": 0 + }, + "type": { + "description": "Port type", + "enum": ["access", "dot1q", "qinq"], + }, + "vlan": {"description": "VLAN number", + "type": "integer", + "minimum": 1 + }, + "ethertype": { + "description": "QinQ Ethertype", + "enum": ["", "0x8100", "0x88A8", "0x9100", "0x9200"], + }, + }, + "required": ["name", "port_number", "type"], + "additionalProperties": False +} + ETHERNET_SWITCH_CREATE_SCHEMA = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Request validation to create a new Ethernet switch instance", "type": "object", "definitions": { - "EthernetSwitchPort": { - "description": "Ethernet port", - "properties": { - "name": { - "description": "Port name", - "type": "string", - "minLength": 1, - }, - "port_number": { - "description": "Port number", - "type": "integer", - "minimum": 0 - }, - "type": { - "description": "Port type", - "enum": ["access", "dot1q", "qinq"], - }, - "vlan": {"description": "VLAN number", - "type": "integer", - "minimum": 1 - }, - "ethertype": { - "description": "QinQ Ethertype", - "enum": ["", "0x8100", "0x88A8", "0x9100", "0x9200"], - }, - }, - "required": ["name", "port_number", "type"], - "additionalProperties": False - }, + "EthernetSwitchPort": ETHERNET_SWITCH_PORT_SCHEMA }, "properties": { "name": { @@ -79,12 +81,9 @@ ETHERNET_SWITCH_CREATE_SCHEMA = { }, "ports_mapping": { "type": "array", - "items": [ - {"type": "object", - "oneOf": [ - {"$ref": "#/definitions/EthernetSwitchPort"} - ]}, - ] + "items": { + "$ref": "#/definitions/EthernetSwitchPort" + } }, }, "additionalProperties": False, @@ -96,35 +95,7 @@ ETHERNET_SWITCH_OBJECT_SCHEMA = { "description": "Ethernet switch instance", "type": "object", "definitions": { - "EthernetSwitchPort": { - "description": "Ethernet port", - "properties": { - "name": { - "description": "Port name", - "type": "string", - "minLength": 1, - }, - "port_number": { - "description": "Port number", - "type": "integer", - "minimum": 0 - }, - "type": { - "description": "Port type", - "enum": ["access", "dot1q", "qinq"], - }, - "vlan": {"description": "VLAN number", - "type": "integer", - "minimum": 1 - }, - "ethertype": { - "description": "QinQ Ethertype", - "enum": ["", "0x8100", "0x88A8", "0x9100", "0x9200"], - }, - }, - "required": ["name", "port_number", "type"], - "additionalProperties": False - }, + "EthernetSwitchPort": ETHERNET_SWITCH_PORT_SCHEMA }, "properties": { "name": { @@ -148,12 +119,9 @@ ETHERNET_SWITCH_OBJECT_SCHEMA = { }, "ports_mapping": { "type": "array", - "items": [ - {"type": "object", - "oneOf": [ - {"$ref": "#/definitions/EthernetSwitchPort"} - ]}, - ] + "items": { + "$ref": "#/definitions/EthernetSwitchPort" + } }, "status": { "description": "Node status",