From cb57de71bd3f96eaf425fb41de3a8106ab6d01d0 Mon Sep 17 00:00:00 2001 From: Aldo Ortega Date: Tue, 7 Feb 2023 20:05:46 -0500 Subject: [PATCH 1/2] Add support to str for dl_type --- db/models/__init__.py | 4 ++-- openapi.yml | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/db/models/__init__.py b/db/models/__init__.py index db9966e..f3749c5 100644 --- a/db/models/__init__.py +++ b/db/models/__init__.py @@ -6,7 +6,7 @@ from datetime import datetime from decimal import Decimal from enum import Enum -from typing import List, Optional +from typing import List, Optional, Union from bson.decimal128 import Decimal128 from pydantic import BaseModel, Field, validator @@ -50,7 +50,7 @@ class MatchSubDoc(BaseModel): dl_src: Optional[str] dl_dst: Optional[str] dl_type: Optional[int] - dl_vlan: Optional[int] + dl_vlan: Union[int, str] dl_vlan_pcp: Optional[int] nw_src: Optional[str] nw_dst: Optional[str] diff --git a/openapi.yml b/openapi.yml index 1fe6294..f996000 100644 --- a/openapi.yml +++ b/openapi.yml @@ -252,9 +252,11 @@ components: type: string example: '00:15:af:d5:38:98' dl_type: - type: integer - format: int16 - example: 2048 + oneOf: + - type: integer + format: int32 + - type: string + example: 2048, any dl_vlan: type: integer format: int16 From 27a05d4783fb2f7017cb95e0da54dfe77bf368d0 Mon Sep 17 00:00:00 2001 From: Aldo Ortega Date: Wed, 8 Feb 2023 12:54:28 -0500 Subject: [PATCH 2/2] Changed dl_vlan to optional --- db/models/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/models/__init__.py b/db/models/__init__.py index f3749c5..923d08a 100644 --- a/db/models/__init__.py +++ b/db/models/__init__.py @@ -50,7 +50,7 @@ class MatchSubDoc(BaseModel): dl_src: Optional[str] dl_dst: Optional[str] dl_type: Optional[int] - dl_vlan: Union[int, str] + dl_vlan: Union[int, str, None] dl_vlan_pcp: Optional[int] nw_src: Optional[str] nw_dst: Optional[str]