fix:parser
This commit is contained in:
@@ -621,18 +621,29 @@ class InputParser:
|
||||
# Find primary key by looking for top-level "identityId" array.
|
||||
identity_id_list = model.get("identityId")
|
||||
if isinstance(identity_id_list, list) and len(identity_id_list) > 0:
|
||||
pk_name = identity_id_list[0]
|
||||
self.logger.info(f"Found identityId property '{pk_name}' for model '{name}'.")
|
||||
|
||||
# Fallback to original behavior if no identityId found
|
||||
candidate_pk_name = identity_id_list[0]
|
||||
# 🔧 验证identityId指向的字段是否真的存在于properties中
|
||||
if candidate_pk_name in model['properties']:
|
||||
pk_name = candidate_pk_name
|
||||
self.logger.info(f"Found identityId property '{pk_name}' for model '{name}'.")
|
||||
else:
|
||||
self.logger.warning(f"identityId property '{candidate_pk_name}' not found in model properties for '{name}'. Will use fallback.")
|
||||
|
||||
# Fallback to original behavior if no identityId found or identityId field doesn't exist
|
||||
if not pk_name:
|
||||
pk_name = next(iter(model['properties']), None)
|
||||
if pk_name:
|
||||
self.logger.warning(f"No 'identityId' array found for model '{name}'. Falling back to using the first property '{pk_name}' as the primary key.")
|
||||
self.logger.warning(f"No valid 'identityId' found for model '{name}'. Falling back to using the first property '{pk_name}' as the primary key.")
|
||||
|
||||
if not pk_name:
|
||||
self.logger.warning(f"Skipping API '{name}' because no properties found in model to identify a primary key.")
|
||||
continue
|
||||
|
||||
# 🔧 再次验证pk_name确实存在于properties中(双重保险)
|
||||
if pk_name not in model['properties']:
|
||||
self.logger.error(f"Critical error: Primary key '{pk_name}' not found in model properties for '{name}'. Skipping this model.")
|
||||
continue
|
||||
|
||||
pk_schema = model['properties'][pk_name]
|
||||
|
||||
version = model_data.get('version', '1.0.0')
|
||||
|
||||
Reference in New Issue
Block a user