@@ -150,7 +150,8 @@ def dataclasses_to_fixcore_model(
150150 aggregate_root : Optional [Type [Any ]] = None ,
151151 walk_subclasses : bool = True ,
152152 use_optional_as_required : bool = False ,
153- with_description : bool = True ,
153+ with_kind_description : bool = False ,
154+ with_prop_description : bool = False ,
154155) -> List [Json ]:
155156 """
156157 Analyze all transitive dataclasses and create the model
@@ -163,7 +164,8 @@ def dataclasses_to_fixcore_model(
163164 :param aggregate_root: if a type is a subtype of this type, it will be considered an aggregate root.
164165 :param walk_subclasses: if true, all subclasses of the given classes will be analyzed as well.
165166 :param use_optional_as_required: if true, all non-optional fields will be considered required.
166- :param with_description: if true, include the description for classes and properties.
167+ :param with_kind_description: if true, include the description for classes.
168+ :param with_prop_description: if true, include the description for properties.
167169 :return: the model definition in the fixcore json format.
168170 """
169171
@@ -176,7 +178,7 @@ def prop(field: Attribute) -> List[Json]: # type: ignore
176178 meta = field .metadata .copy ()
177179 kind = meta .pop ("type_hint" , model_name (field .type ))
178180 desc = meta .pop ("description" , None )
179- desc = desc if with_description else None
181+ desc = desc if with_prop_description else None
180182 required = meta .pop ("required" , use_optional_as_required and not is_optional (field .type )) # type: ignore
181183 synthetic = meta .pop ("synthetic" , None )
182184 synthetic = synthetic if synthetic else {}
@@ -253,7 +255,13 @@ def export_data_class(clazz: type) -> None:
253255 metadata ["service" ] = s
254256 if (slc := getattr (clazz , "categories" , None )) and callable (slc ) and (sl := slc ()):
255257 metadata ["categories" ] = sl
256- if with_description and (s := clazz .__dict__ .get ("kind_description" , None )) and isinstance (s , str ):
258+ if ( # only export kind description on aggregate roots
259+ with_kind_description
260+ and (ar := aggregate_root )
261+ and issubclass (clazz , ar )
262+ and (s := clazz .__dict__ .get ("kind_description" , None ))
263+ and isinstance (s , str )
264+ ):
257265 metadata ["description" ] = s
258266
259267 model .append (
@@ -293,9 +301,9 @@ def literal_name(en: Enum) -> str:
293301# Use this model exporter, if a dynamic object is exported
294302# with given name and properties.
295303def dynamic_object_to_fixcore_model (
296- name : str , properties : Dict [str , type ], aggregate_root : bool = True , traverse_dependant : bool = True
304+ name : str , properties : Dict [str , type ], aggregate_root : bool = True , traverse_dependant : bool = True , ** kwargs : Any
297305) -> List [Json ]:
298- dependant = dataclasses_to_fixcore_model (set (properties .values ())) if traverse_dependant else []
306+ dependant = dataclasses_to_fixcore_model (set (properties .values ()), ** kwargs ) if traverse_dependant else []
299307 # append definition for top level object
300308 dependant .append (
301309 {
0 commit comments