MCPcopy Index your code
hub / github.com/OpenBMB/ChatDev / build_schema_response

Function build_schema_response

utils/schema_exporter.py:110–132  ·  view source on GitHub ↗

Return a JSON-serializable schema response for the provided breadcrumbs.

(
    breadcrumbs_raw: Sequence[Mapping[str, Any]] | None = None,
    *,
    root_cls: Type[BaseConfig] = DesignConfig,
)

Source from the content-addressed store, hash-verified

108
109
110def build_schema_response(
111 breadcrumbs_raw: Sequence[Mapping[str, Any]] | None = None,
112 *,
113 root_cls: Type[BaseConfig] = DesignConfig,
114) -> Dict[str, Any]:
115 """Return a JSON-serializable schema response for the provided breadcrumbs."""
116
117 breadcrumbs = _normalize_breadcrumbs(breadcrumbs_raw)
118 target_cls = _resolve_config_class(breadcrumbs, root_cls=root_cls)
119 schema_node = target_cls.collect_schema()
120 field_specs = target_cls.field_specs()
121 ordered_fields = _ordered_field_names(field_specs)
122 fields_payload = [_serialize_field(target_cls, name, field_specs) for name in ordered_fields]
123
124 response = {
125 "schemaVersion": SCHEMA_VERSION,
126 "node": schema_node.node,
127 "fields": fields_payload,
128 "constraints": [constraint.to_json() for constraint in schema_node.constraints],
129 "breadcrumbs": [crumb.to_json() for crumb in breadcrumbs],
130 }
131 response["cacheKey"] = _hash_payload({"node": schema_node.node, "breadcrumbs": response["breadcrumbs"]})
132 return response
133
134
135__all__ = [

Callers 3

mainFunction · 0.90
_resolve_schemaFunction · 0.90
get_schemaFunction · 0.90

Calls 8

_normalize_breadcrumbsFunction · 0.85
_resolve_config_classFunction · 0.85
_ordered_field_namesFunction · 0.85
_serialize_fieldFunction · 0.85
_hash_payloadFunction · 0.85
collect_schemaMethod · 0.80
field_specsMethod · 0.45
to_jsonMethod · 0.45

Tested by

no test coverage detected