def get_metaschemas(*args, **kwargs):
    """
    List metaschemas with which a draft registration may be created. Only fetch the newest version for each schema.

    :return: serialized metaschemas
    :rtype: dict
    """
    count = request.args.get('count', 100)
    include = request.args.get('include', 'latest')

    meta_schema_collection = database['metaschema']

    meta_schemas = []
    if include == 'latest':
        schema_names = meta_schema_collection.distinct('name')
        for name in schema_names:
            meta_schema_set = MetaSchema.find(
                Q('name', 'eq', name) &
                Q('schema_version', 'eq', 2)
            )
            meta_schemas = meta_schemas + [s for s in meta_schema_set]
    else:
        meta_schemas = MetaSchema.find()
    meta_schemas = [
        schema
        for schema in meta_schemas
        if schema.name in ACTIVE_META_SCHEMAS
    ]
    meta_schemas.sort(key=lambda a: ACTIVE_META_SCHEMAS.index(a.name))
    return {
        'meta_schemas': [
            serialize_meta_schema(ms) for ms in meta_schemas[:count]
        ]
    }, http.OK
dataset/ETHPy150Open CenterForOpenScience/osf.io/website/project/views/drafts.py/get_metaschemas/original