|
1 | 1 | from typing import Final |
2 | 2 |
|
3 | | -from pydantic import BaseModel, ConfigDict, Field, field_validator |
| 3 | +from pydantic import BaseModel, ConfigDict, Field, JsonValue, field_validator |
4 | 4 | from pydantic.config import JsonDict |
5 | 5 | from pydantic.types import ByteSize, NonNegativeInt |
6 | 6 |
|
@@ -66,38 +66,42 @@ class ServiceExtras(BaseModel): |
66 | 66 |
|
67 | 67 | @staticmethod |
68 | 68 | def _update_json_schema_extra(schema: JsonDict) -> None: |
69 | | - examples = [ |
70 | | - *( |
71 | | - {"node_requirements": node_example} |
72 | | - for node_example in NodeRequirements.model_json_schema()["examples"] |
73 | | - ), |
74 | | - *( |
75 | | - { |
76 | | - "node_requirements": node_example, |
77 | | - "service_build_details": { |
78 | | - "build_date": "2021-08-13T12:56:28Z", |
79 | | - "vcs_ref": "8251ade", |
80 | | - "vcs_url": "[email protected]:ITISFoundation/osparc-simcore.git", |
81 | | - }, |
82 | | - } |
83 | | - for node_example in NodeRequirements.model_json_schema()["examples"] |
84 | | - ), |
85 | | - *( |
86 | | - { |
87 | | - "node_requirements": node_example, |
88 | | - "service_build_details": { |
89 | | - "build_date": "2021-08-13T12:56:28Z", |
90 | | - "vcs_ref": "8251ade", |
91 | | - "vcs_url": "[email protected]:ITISFoundation/osparc-simcore.git", |
92 | | - }, |
93 | | - "container_spec": {"Command": ["run", "subcommand"]}, |
94 | | - } |
95 | | - for node_example in NodeRequirements.model_json_schema()["examples"] |
96 | | - ), |
| 69 | + |
| 70 | + node_requirements_examples = NodeRequirements.model_json_schema()["examples"] |
| 71 | + |
| 72 | + examples: list[JsonValue] = [ |
| 73 | + {"node_requirements": node_example} |
| 74 | + for node_example in node_requirements_examples |
| 75 | + ] |
| 76 | + examples += [ |
| 77 | + { |
| 78 | + "node_requirements": node_example, |
| 79 | + "service_build_details": { |
| 80 | + "build_date": "2021-08-13T12:56:28Z", |
| 81 | + "vcs_ref": "8251ade", |
| 82 | + "vcs_url": "[email protected]:ITISFoundation/osparc-simcore.git", |
| 83 | + }, |
| 84 | + } |
| 85 | + for node_example in node_requirements_examples |
97 | 86 | ] |
| 87 | + examples += [ |
| 88 | + { |
| 89 | + "node_requirements": node_example, |
| 90 | + "service_build_details": { |
| 91 | + "build_date": "2021-08-13T12:56:28Z", |
| 92 | + "vcs_ref": "8251ade", |
| 93 | + "vcs_url": "[email protected]:ITISFoundation/osparc-simcore.git", |
| 94 | + }, |
| 95 | + "container_spec": {"Command": ["run", "subcommand"]}, |
| 96 | + } |
| 97 | + for node_example in node_requirements_examples |
| 98 | + ] |
| 99 | + |
98 | 100 | schema.update({"examples": examples}) |
99 | 101 |
|
100 | | - model_config = ConfigDict(json_schema_extra=_update_json_schema_extra) |
| 102 | + model_config = ConfigDict( |
| 103 | + json_schema_extra=_update_json_schema_extra, |
| 104 | + ) |
101 | 105 |
|
102 | 106 |
|
103 | 107 | CHARS_IN_VOLUME_NAME_BEFORE_DIR_NAME: Final[NonNegativeInt] = 89 |
|
0 commit comments