MCPcopy Create free account
hub / github.com/apolloconfig/apollo / object_schema_state

Function object_schema_state

scripts/openapi/check_openapi_compatibility.py:146–175  ·  view source on GitHub ↗
(candidate: Any)

Source from the content-addressed store, hash-verified

144 schema: Dict[str, Any], head_schema_signatures: Dict[str, str]
145) -> bool:
146 def object_schema_state(candidate: Any) -> str:
147 if not isinstance(candidate, dict):
148 return "reject"
149
150 schema_name = component_schema_name(candidate.get("$ref"))
151 if schema_name:
152 return object_schema_state(load_schema_signature(head_schema_signatures.get(schema_name, "")))
153
154 schema_type = candidate.get("type")
155 if schema_type and schema_type != "object":
156 return "reject"
157
158 all_of = candidate.get("allOf")
159 if isinstance(all_of, list):
160 if not all_of:
161 return "reject"
162 member_states = [object_schema_state(member) for member in all_of]
163 if "reject" in member_states:
164 return "reject"
165 if "accept" in member_states:
166 return "accept"
167 return "neutral"
168
169 if (
170 schema_type == "object"
171 or "properties" in candidate
172 or "additionalProperties" in candidate
173 ):
174 return "accept"
175 return "neutral"
176
177 return object_schema_state(schema) == "accept"
178

Callers 1

Calls 3

component_schema_nameFunction · 0.85
load_schema_signatureFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected