Bug with Update operations.
UPDATE: We need to go deep understanding if supportedFeatures is mandatory (optional in swagger, but not in definition)
Bug detected with Update Operations.
capif_api_publish_service-8
If Request with optional parameter removed(for example service API Description with supportedFeatured removed) is received by CCF and previously that optional parameter was set to some value, then the parameter will remain in db.
This problem occurs due to update operation in db, this update request use $set properly, then if parameter is not present, then this parameter will remain with same value.
One way to solve this is checking the previously present parameter when db is checked, for example changing this update with this code:
# Create update variable with all not present values from original service api description
update = { "$set": {**service_api_description}}
immutable_service_api_description_keys = ["_id", "apf_id", "onboarding_date", "api_id"]
for key in serviceapidescription:
if key not in service_api_description and key not in immutable_service_api_description_keys:
update["$set"][key] = None
result = mycol.find_one_and_update(serviceapidescription, update, projection={"_id": 0, "api_name": 1, "api_id": 1, "aef_profiles": 1, "description": 1, "supported_features": 1, "shareable_info": 1, "service_api_category": 1, "api_supp_feats": 1, "pub_api_path": 1, "ccf_id": 1}, return_document=ReturnDocument.AFTER, upsert=False)
Edited by Jorge Moratinos