diff --git a/docs/NATIVE_SCHEMA.md b/docs/NATIVE_SCHEMA.md index 6ef47ffd..192a6e4d 100644 --- a/docs/NATIVE_SCHEMA.md +++ b/docs/NATIVE_SCHEMA.md @@ -20,6 +20,7 @@ classes. Below is a basic outline of the schema's structure: ```json { + "version": "v0.0.0", "endpoints": { "/endpoint/url/path": { ... diff --git a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/DHCPServer.inc b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/DHCPServer.inc index bd254cd9..b36aad34 100644 --- a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/DHCPServer.inc +++ b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/DHCPServer.inc @@ -261,7 +261,7 @@ class DHCPServer extends Model { # Loop through each defined interface foreach ($this->get_config('interfaces', []) as $if_id => $if) { # Skip this interface if it is not a static interface or the subnet value is greater than or equal to 31 - if (empty($if['ipaddr']) or $if['ipaddr'] !== 'static' or $if->subnet->value >= 31) { + if (empty($if['ipaddr']) or !is_ipaddrv4($if['ipaddr']) or $if->subnet->value >= 31) { continue; } diff --git a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Schemas/NativeSchema.inc b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Schemas/NativeSchema.inc index 75efcf1a..a42e2db3 100644 --- a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Schemas/NativeSchema.inc +++ b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Schemas/NativeSchema.inc @@ -10,6 +10,7 @@ use RESTAPI\Core\Model; use RESTAPI\Core\Schema; use RESTAPI\Fields\ForeignModelField; use RESTAPI\Fields\NestedModelField; +use RESTAPI\Models\RESTAPIVersion; use function RESTAPI\Core\Tools\get_classes_from_namespace; /** @@ -129,7 +130,8 @@ class NativeSchema extends Schema { * @return string The full schema string for this Schema class in JSON format */ public function get_schema_str(): string { - $schema = ['endpoints' => [], 'models' => []]; + $version = new RESTAPIVersion(); + $schema = ['version' => $version->current_version->value, 'endpoints' => [], 'models' => []]; # Get all endpoint metadata foreach (get_classes_from_namespace('RESTAPI\Endpoints') as $endpoint_class) { diff --git a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APIModelsDHCPServerTestCase.inc b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APIModelsDHCPServerTestCase.inc index 90173bf4..fb7196cd 100644 --- a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APIModelsDHCPServerTestCase.inc +++ b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APIModelsDHCPServerTestCase.inc @@ -523,6 +523,9 @@ class APIModelsDHCPServerTestCase extends TestCase { * Ensures non-static interfaces are exempt from DHCP server initialization. This is a regression test for #781 */ public function test_non_static_interfaces_exempt_from_dhcp_server_initialization(): void { + # Ensure no config entry exists for the `opt1` DHCP server + Model::del_config('dhcpd/opt1'); + # Temporarily add a mock interface using pppoe for IPv4 Model::set_config('interfaces/opt1/ipaddr', 'pppoe');