Skip to content

Commit 34825f6

Browse files
committed
refactor: use Annotated for key and content_schema fields in ServicePortGet model
1 parent 7c5b1bb commit 34825f6

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

packages/models-library/src/models_library/api_schemas_catalog/services_ports.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Literal
1+
from typing import Annotated, Any, Literal
22

33
from pydantic import BaseModel, ConfigDict, Field
44
from pydantic.config import JsonDict
@@ -13,18 +13,22 @@
1313

1414

1515
class ServicePortGet(BaseModel):
16-
key: str = Field(
17-
...,
18-
description="Port identifier name",
19-
pattern=PUBLIC_VARIABLE_NAME_RE,
20-
title="Key name",
21-
)
16+
key: Annotated[
17+
str,
18+
Field(
19+
description="Port identifier name",
20+
pattern=PUBLIC_VARIABLE_NAME_RE,
21+
title="Key name",
22+
),
23+
]
2224
kind: Literal["input", "output"]
2325
content_media_type: str | None = None
24-
content_schema: dict[str, Any] | None = Field(
25-
None,
26-
description="jsonschema for the port's value. SEE https://json-schema.org/understanding-json-schema/",
27-
)
26+
content_schema: Annotated[
27+
dict[str, Any] | None,
28+
Field(
29+
description="jsonschema for the port's value. SEE https://json-schema.org/understanding-json-schema/",
30+
),
31+
] = None
2832

2933
@staticmethod
3034
def _update_json_schema_extra(schema: JsonDict) -> None:

0 commit comments

Comments
 (0)