From 0598c1db1114d921a04d8ba251a51112a0e274f0 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Sat, 10 Jun 2023 16:46:20 -0500 Subject: http-api: T5263: add base model for generalization --- src/services/vyos-http-api-server | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'src/services') diff --git a/src/services/vyos-http-api-server b/src/services/vyos-http-api-server index 51dafe922..206d3176d 100755 --- a/src/services/vyos-http-api-server +++ b/src/services/vyos-http-api-server @@ -91,10 +91,9 @@ def success(data): class ApiModel(BaseModel): key: StrictStr -class BaseConfigureModel(BaseModel): +class BasePathModel(BaseModel): op: StrictStr path: List[StrictStr] - value: StrictStr = None @validator("path") def check_non_empty(cls, path): @@ -102,17 +101,10 @@ class BaseConfigureModel(BaseModel): raise ValueError('path must be non-empty') return path -class ConfigureModel(ApiModel): - op: StrictStr - path: List[StrictStr] +class BaseConfigureModel(BasePathModel): value: StrictStr = None - @validator("path") - def check_non_empty(cls, path): - if not len(path) > 0: - raise ValueError('path must be non-empty') - return path - +class ConfigureModel(ApiModel, BaseConfigureModel): class Config: schema_extra = { "example": { -- cgit v1.2.3