33from typing import Literal , TypeAlias
44
55from pydantic import AnyUrl , BaseModel , ConfigDict , Field , HttpUrl , field_validator
6+ from pydantic .config import JsonDict
67from pydantic .types import NonNegativeInt
78
89from .groups import GroupID
@@ -36,18 +37,22 @@ class TLSAuthentication(_AuthenticationBase):
3637 tls_client_cert : Path
3738 tls_client_key : Path
3839
39- model_config = ConfigDict (
40- json_schema_extra = {
41- "examples" : [
42- {
43- "type" : "tls" ,
44- "tls_ca_file" : "/path/to/ca_file" ,
45- "tls_client_cert" : "/path/to/cert_file" ,
46- "tls_client_key" : "/path/to/key_file" ,
47- },
48- ]
49- }
50- )
40+ @staticmethod
41+ def _update_json_schema_extra (schema : JsonDict ) -> None :
42+ schema .update (
43+ {
44+ "examples" : [
45+ {
46+ "type" : "tls" ,
47+ "tls_ca_file" : "/path/to/ca_file" ,
48+ "tls_client_cert" : "/path/to/cert_file" ,
49+ "tls_client_key" : "/path/to/key_file" ,
50+ },
51+ ]
52+ }
53+ )
54+
55+ model_config = ConfigDict (json_schema_extra = _update_json_schema_extra )
5156
5257
5358ClusterAuthentication : TypeAlias = NoAuthentication | TLSAuthentication
@@ -71,36 +76,41 @@ class BaseCluster(BaseModel):
7176 create_enums_pre_validator (ClusterTypeInModel )
7277 )
7378
74- model_config = ConfigDict (
75- use_enum_values = True ,
76- json_schema_extra = {
77- "examples" : [
78- {
79- "name" : "My awesome cluster" ,
80- "type" : ClusterTypeInModel .ON_PREMISE ,
81- "owner" : 12 ,
82- "endpoint" : "https://registry.osparc-development.fake.dev" ,
83- "authentication" : {
84- "type" : "tls" ,
85- "tls_ca_file" : "/path/to/ca_file" ,
86- "tls_client_cert" : "/path/to/cert_file" ,
87- "tls_client_key" : "/path/to/key_file" ,
79+ @staticmethod
80+ def _update_json_schema_extra (schema : JsonDict ) -> None :
81+ schema .update (
82+ {
83+ "examples" : [
84+ {
85+ "name" : "My awesome cluster" ,
86+ "type" : ClusterTypeInModel .ON_PREMISE ,
87+ "owner" : 12 ,
88+ "endpoint" : "https://registry.osparc-development.fake.dev" ,
89+ "authentication" : {
90+ "type" : "tls" ,
91+ "tls_ca_file" : "/path/to/ca_file" ,
92+ "tls_client_cert" : "/path/to/cert_file" ,
93+ "tls_client_key" : "/path/to/key_file" ,
94+ },
8895 },
89- },
90- {
91- "name " : "My AWS cluster" ,
92- "type " : ClusterTypeInModel . AWS ,
93- "owner " : 154 ,
94- "endpoint " : "https://registry.osparc-development.fake.dev" ,
95- "authentication " : {
96- "type " : "tls " ,
97- "tls_ca_file " : "/path/to/ca_file " ,
98- "tls_client_cert " : "/path/to/cert_file " ,
99- "tls_client_key" : "/path/to/key_file" ,
96+ {
97+ "name" : "My AWS cluster" ,
98+ "type " : ClusterTypeInModel . AWS ,
99+ "owner " : 154 ,
100+ "endpoint " : "https://registry.osparc-development.fake.dev" ,
101+ "authentication " : {
102+ "type " : "tls" ,
103+ "tls_ca_file " : "/path/to/ca_file " ,
104+ "tls_client_cert " : "/path/to/cert_file " ,
105+ "tls_client_key " : "/path/to/key_file " ,
106+ } ,
100107 },
101- },
102- ]
103- },
108+ ]
109+ }
110+ )
111+
112+ model_config = ConfigDict (
113+ use_enum_values = True , json_schema_extra = _update_json_schema_extra
104114 )
105115
106116
0 commit comments