Subclass typesystem.objects


Whats the best way in apistar to deal with “inheritance” of typesystem.objects derived class.

Since every attribute is not a class attribute but a dict (from properties) attribute.

here is what I tried, but I do not think it’s a good thing :

class PatientSchema(typesystem.Object):
    properties = {
        'name': typesystem.string(max_length=50),
        'firstname': typesystem.string(max_length=50),

class PatientSchemaId(typesystem.Object):
    """the same with just id more"""
    properties = dict(
                'id': typesystem.Integer,

thanks for answer


Your approach seems correct to me if using the APIStar typesystem. It is much more a system to marshall and validate data from and to the server. Seems that it isn’t really designed for general models or anything.

You may also try this brand new library that integrates APIStar with pydantic. In fact is not yet on PyPi as stated on documentation but you can try it anyway.

pydantic models are much more versatile than APIStar types.

I’m open to suggestions, please open issues here or at Github if something needs to be changed.