Skip to content

Commit 934b1ef

Browse files
committed
fixes tests
1 parent d87eca6 commit 934b1ef

File tree

2 files changed

+46
-26
lines changed

2 files changed

+46
-26
lines changed

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

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Any, Literal
22

33
from pydantic import BaseModel, ConfigDict, Field
4+
from pydantic.config import JsonDict
45

56
from ..basic_regex import PUBLIC_VARIABLE_NAME_RE
67
from ..services import ServiceInput, ServiceOutput
@@ -25,32 +26,40 @@ class ServicePortGet(BaseModel):
2526
description="jsonschema for the port's value. SEE https://json-schema.org/understanding-json-schema/",
2627
)
2728

28-
model_config = ConfigDict(
29-
json_schema_extra={
30-
"examples": [
31-
{
32-
"key": "input_1",
33-
"kind": "input",
34-
"content_schema": {
35-
"title": "Sleep interval",
36-
"type": "integer",
37-
"x_unit": "second",
38-
"minimum": 0,
39-
"maximum": 5,
40-
},
41-
},
42-
{
43-
"key": "output_1",
44-
"kind": "output",
45-
"content_media_type": "text/plain",
46-
"content_schema": {
47-
"type": "string",
48-
"title": "File containing one random integer",
49-
"description": "Integer is generated in range [1-9]",
50-
},
51-
},
52-
]
29+
@staticmethod
30+
def _update_json_schema_extra(schema: JsonDict) -> None:
31+
input_example = {
32+
"key": "input_1",
33+
"kind": "input",
34+
"content_schema": {
35+
"title": "Sleep interval",
36+
"type": "integer",
37+
"x_unit": "second",
38+
"minimum": 0,
39+
"maximum": 5,
40+
},
5341
}
42+
schema.update(
43+
{
44+
"example": input_example,
45+
"examples": [
46+
input_example,
47+
{
48+
"key": "output_1",
49+
"kind": "output",
50+
"content_media_type": "text/plain",
51+
"content_schema": {
52+
"type": "string",
53+
"title": "File containing one random integer",
54+
"description": "Integer is generated in range [1-9]",
55+
},
56+
},
57+
],
58+
}
59+
)
60+
61+
model_config = ConfigDict(
62+
json_schema_extra=_update_json_schema_extra,
5463
)
5564

5665
@classmethod

services/catalog/openapi.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3145,7 +3145,18 @@
31453145
"key",
31463146
"kind"
31473147
],
3148-
"title": "ServicePortGet"
3148+
"title": "ServicePortGet",
3149+
"example": {
3150+
"content_schema": {
3151+
"maximum": 5,
3152+
"minimum": 0,
3153+
"title": "Sleep interval",
3154+
"type": "integer",
3155+
"x_unit": "second"
3156+
},
3157+
"key": "input_1",
3158+
"kind": "input"
3159+
}
31493160
},
31503161
"ServiceSpec": {
31513162
"properties": {

0 commit comments

Comments
 (0)