@@ -36,7 +36,7 @@ def validate_schema_content_and_exit(client: InfrahubClient, schemas: list[Schem
36
36
has_error : bool = False
37
37
for schema_file in schemas :
38
38
try :
39
- client .schema .validate (data = schema_file .content )
39
+ client .schema .validate (data = schema_file .payload )
40
40
except ValidationError as exc :
41
41
console .print (f"[red]Schema not valid, found '{ len (exc .errors ())} ' error(s) in { schema_file .location } " )
42
42
has_error = True
@@ -48,7 +48,7 @@ def validate_schema_content_and_exit(client: InfrahubClient, schemas: list[Schem
48
48
raise typer .Exit (1 )
49
49
50
50
51
- def display_schema_load_errors (response : dict [str , Any ], schemas_data : list [dict ]) -> None :
51
+ def display_schema_load_errors (response : dict [str , Any ], schemas_data : list [SchemaFile ]) -> None :
52
52
console .print ("[red]Unable to load the schema:" )
53
53
if "detail" not in response :
54
54
handle_non_detail_errors (response = response )
@@ -87,7 +87,7 @@ def handle_non_detail_errors(response: dict[str, Any]) -> None:
87
87
if "error" in response :
88
88
console .print (f" { response .get ('error' )} " )
89
89
elif "errors" in response :
90
- for error in response . get ( "errors" ) :
90
+ for error in response [ "errors" ] :
91
91
console .print (f" { error .get ('message' )} " )
92
92
else :
93
93
console .print (f" '{ response } '" )
@@ -97,9 +97,9 @@ def valid_error_path(loc_path: list[Any]) -> bool:
97
97
return len (loc_path ) >= 6 and loc_path [0 ] == "body" and loc_path [1 ] == "schemas"
98
98
99
99
100
- def get_node (schemas_data : list [dict ], schema_index : int , node_index : int ) -> dict | None :
101
- if schema_index < len (schemas_data ) and node_index < len (schemas_data [schema_index ].content ["nodes" ]):
102
- return schemas_data [schema_index ].content ["nodes" ][node_index ]
100
+ def get_node (schemas_data : list [SchemaFile ], schema_index : int , node_index : int ) -> dict | None :
101
+ if schema_index < len (schemas_data ) and node_index < len (schemas_data [schema_index ].payload ["nodes" ]):
102
+ return schemas_data [schema_index ].payload ["nodes" ][node_index ]
103
103
return None
104
104
105
105
@@ -122,7 +122,7 @@ async def load(
122
122
validate_schema_content_and_exit (client = client , schemas = schemas_data )
123
123
124
124
start_time = time .time ()
125
- response = await client .schema .load (schemas = [item .content for item in schemas_data ], branch = branch )
125
+ response = await client .schema .load (schemas = [item .payload for item in schemas_data ], branch = branch )
126
126
loading_time = time .time () - start_time
127
127
128
128
if response .errors :
@@ -170,10 +170,10 @@ async def check(
170
170
client = initialize_client ()
171
171
validate_schema_content_and_exit (client = client , schemas = schemas_data )
172
172
173
- success , response = await client .schema .check (schemas = [item .content for item in schemas_data ], branch = branch )
173
+ success , response = await client .schema .check (schemas = [item .payload for item in schemas_data ], branch = branch )
174
174
175
175
if not success :
176
- display_schema_load_errors (response = response , schemas_data = schemas_data )
176
+ display_schema_load_errors (response = response or {} , schemas_data = schemas_data )
177
177
else :
178
178
for schema_file in schemas_data :
179
179
console .print (f"[green] schema '{ schema_file .location } ' is Valid!" )
0 commit comments