summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2023-06-10 16:46:20 -0500
committerJohn Estabrook <jestabro@vyos.io>2023-06-10 22:39:28 -0500
commit0598c1db1114d921a04d8ba251a51112a0e274f0 (patch)
tree7e3deeaf224334a03302fab46a7c1d5d8db57b59 /src
parent1c0d91fab1c430fcfd44cf5af80f5170b9a23156 (diff)
downloadvyos-1x-0598c1db1114d921a04d8ba251a51112a0e274f0.tar.gz
vyos-1x-0598c1db1114d921a04d8ba251a51112a0e274f0.zip
http-api: T5263: add base model for generalization
Diffstat (limited to 'src')
-rwxr-xr-xsrc/services/vyos-http-api-server14
1 files changed, 3 insertions, 11 deletions
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": {