@@ -36,7 +36,7 @@ def validate_schema_content_and_exit(client: InfrahubClient, schemas: list[Schem
3636 has_error : bool = False
3737 for schema_file in schemas :
3838 try :
39- client .schema .validate (data = schema_file .content )
39+ client .schema .validate (data = schema_file .payload )
4040 except ValidationError as exc :
4141 console .print (f"[red]Schema not valid, found '{ len (exc .errors ())} ' error(s) in { schema_file .location } " )
4242 has_error = True
@@ -48,7 +48,7 @@ def validate_schema_content_and_exit(client: InfrahubClient, schemas: list[Schem
4848 raise typer .Exit (1 )
4949
5050
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 :
5252 console .print ("[red]Unable to load the schema:" )
5353 if "detail" not in response :
5454 handle_non_detail_errors (response = response )
@@ -87,7 +87,7 @@ def handle_non_detail_errors(response: dict[str, Any]) -> None:
8787 if "error" in response :
8888 console .print (f" { response .get ('error' )} " )
8989 elif "errors" in response :
90- for error in response . get ( "errors" ) :
90+ for error in response [ "errors" ] :
9191 console .print (f" { error .get ('message' )} " )
9292 else :
9393 console .print (f" '{ response } '" )
@@ -97,9 +97,9 @@ def valid_error_path(loc_path: list[Any]) -> bool:
9797 return len (loc_path ) >= 6 and loc_path [0 ] == "body" and loc_path [1 ] == "schemas"
9898
9999
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 ]
103103 return None
104104
105105
@@ -122,7 +122,7 @@ async def load(
122122 validate_schema_content_and_exit (client = client , schemas = schemas_data )
123123
124124 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 )
126126 loading_time = time .time () - start_time
127127
128128 if response .errors :
@@ -170,10 +170,10 @@ async def check(
170170 client = initialize_client ()
171171 validate_schema_content_and_exit (client = client , schemas = schemas_data )
172172
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 )
174174
175175 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 )
177177 else :
178178 for schema_file in schemas_data :
179179 console .print (f"[green] schema '{ schema_file .location } ' is Valid!" )
0 commit comments