@@ -69,7 +69,7 @@ def asdict(self) -> Dict[str, Any]:
6969            "featureSchemaId" : self .feature_schema_id ,
7070            "label" : self .label ,
7171            "value" : self .value ,
72-             "options" : [o .asdict () for  o  in  self .options ]
72+             "options" : [o .asdict (is_subclass = True ) for  o  in  self .options ]
7373        }
7474
7575    def  add_option (self , option : 'Classification' ) ->  None :
@@ -159,29 +159,25 @@ def from_dict(cls, dictionary: Dict[str, Any]) -> Dict[str, Any]:
159159                   feature_schema_id = dictionary .get ("featureSchemaId" , None ),
160160                   scope = cls .Scope (dictionary .get ("scope" , cls .Scope .GLOBAL )))
161161
162-     def  asdict (self ) ->  Dict [str , Any ]:
162+     def  asdict (self ,  is_subclass :  bool   =   False ) ->  Dict [str , Any ]:
163163        if  self .class_type  in  self ._REQUIRES_OPTIONS  \
164164                and  len (self .options ) <  1 :
165165            raise  InconsistentOntologyException (
166166                f"Classification '{ self .instructions }  )
167-         return  {
168-             "type" :
169-                 self .class_type .value ,
170-             "instructions" :
171-                 self .instructions ,
172-             "name" :
173-                 self .name ,
174-             "required" :
175-                 self .required ,
167+         classification  =  {
168+             "type" : self .class_type .value ,
169+             "instructions" : self .instructions ,
170+             "name" : self .name ,
171+             "required" : self .required ,
176172            "options" : [o .asdict () for  o  in  self .options ],
177-             "schemaNodeId" :
178-                 self .schema_id ,
179-             "featureSchemaId" :
180-                 self .feature_schema_id ,
181-             "scope" :
182-                 self .scope .value 
183-                 if  self .scope  is  not None  else  self .Scope .GLOBAL .value 
173+             "schemaNodeId" : self .schema_id ,
174+             "featureSchemaId" : self .feature_schema_id 
184175        }
176+         if  is_subclass :
177+             return  classification 
178+         classification [
179+             "scope" ] =  self .scope .value  if  self .scope  is  not None  else  self .Scope .GLOBAL .value 
180+         return  classification 
185181
186182    def  add_option (self , option : Option ) ->  None :
187183        if  option .value  in  (o .value  for  o  in  self .options ):
@@ -258,7 +254,9 @@ def asdict(self) -> Dict[str, Any]:
258254            "name" : self .name ,
259255            "required" : self .required ,
260256            "color" : self .color ,
261-             "classifications" : [c .asdict () for  c  in  self .classifications ],
257+             "classifications" : [
258+                 c .asdict (is_subclass = True ) for  c  in  self .classifications 
259+             ],
262260            "schemaNodeId" : self .schema_id ,
263261            "featureSchemaId" : self .feature_schema_id 
264262        }
0 commit comments