Fixed missing entity_did in ServiceBase
All checks were successful
checks-impure / test (pull_request) Successful in 2m28s
checks / test (pull_request) Successful in 10m45s

This commit is contained in:
2024-01-15 15:57:31 +01:00
parent e47b0b4911
commit 390ded6dff
3 changed files with 5 additions and 11 deletions

View File

@@ -100,15 +100,14 @@ class ServiceBase(BaseModel):
other: dict = Field(
..., example={"action": ["register", "deregister", "delete", "create"]}
)
entity_did: str = Field(..., example="did:sov:test:120")
class ServiceCreate(ServiceBase):
entity_did: str = Field(..., example="did:sov:test:120")
usage: List[ServiceUsageCreate]
class Service(ServiceBase):
entity: Entity
usage: List[ServiceUsage]
class Config:
@@ -116,7 +115,6 @@ class Service(ServiceBase):
class ServicesByName(BaseModel):
entity: Entity
services: List[Service]
class Config:

View File

@@ -10,7 +10,7 @@
| **endpoint_url** | **str** | |
| **status** | **str** | |
| **other** | **object** | |
| **entity** | [**Entity**](Entity.md) | |
| **entity_did** | **str** | |
| **usage** | [**List[ServiceUsage]**](ServiceUsage.md) | |
## Example

View File

@@ -20,7 +20,6 @@ import json
from typing import Any, Dict, List
from pydantic import BaseModel, Field, StrictStr, conlist
from openapi_client.models.entity import Entity
from openapi_client.models.service_usage import ServiceUsage
class Service(BaseModel):
@@ -33,9 +32,9 @@ class Service(BaseModel):
endpoint_url: StrictStr = Field(...)
status: StrictStr = Field(...)
other: Dict[str, Any] = Field(...)
entity: Entity = Field(...)
entity_did: StrictStr = Field(...)
usage: conlist(ServiceUsage) = Field(...)
__properties = ["uuid", "service_name", "service_type", "endpoint_url", "status", "other", "entity", "usage"]
__properties = ["uuid", "service_name", "service_type", "endpoint_url", "status", "other", "entity_did", "usage"]
class Config:
"""Pydantic configuration"""
@@ -61,9 +60,6 @@ class Service(BaseModel):
exclude={
},
exclude_none=True)
# override the default output from pydantic by calling `to_dict()` of entity
if self.entity:
_dict['entity'] = self.entity.to_dict()
# override the default output from pydantic by calling `to_dict()` of each item in usage (list)
_items = []
if self.usage:
@@ -89,7 +85,7 @@ class Service(BaseModel):
"endpoint_url": obj.get("endpoint_url"),
"status": obj.get("status"),
"other": obj.get("other"),
"entity": Entity.from_dict(obj.get("entity")) if obj.get("entity") is not None else None,
"entity_did": obj.get("entity_did"),
"usage": [ServiceUsage.from_dict(_item) for _item in obj.get("usage")] if obj.get("usage") is not None else None
})
return _obj