Map the definitions from a Swagger model
@param {object} model      - Swagger model
@return                    - Map of definition name to definition body
181184
function mapDefinitionsFromModel(model) {
  const definitionMap = [];

  /* istanbul ignore else */
  if (model && model.definitions) {
    debug('Parsing %s definitions', Object.keys(model.definitions).length);
    for (const definitionName of Object.keys(model.definitions)) {
      debug('  Reading definition for %s', definitionName);
      const definitionKey = util.format('#/definitions/%s', definitionName);
      const currentDef = model.definitions[definitionName];
      currentDef.definitionName = definitionName;
      currentDef.referencePath = definitionKey;
      definitionMap[definitionKey] = currentDef;
    }
  }

  return definitionMap;
}
392023
def _to_swagger(base=None, description=None, resource=None, options=None):
    # type: (Dict[str, str], str, Resource, Dict[str, str]) -> Dict[str, str]
    
    definition = dict_filter(base or {}, options or {})

    if description:
        definition['description'] = description.format(
            name=getmeta(resource).name if resource else "UNKNOWN"
        )

    if resource:
        definition['schema'] = {
            '$ref': '#/definitions/{}'.format(getmeta(resource).resource_name)
        }

    return definition
758587
function getModelProperty(model) {
    const className = model.constructor.name;
    const propsForModel = getProperties(model);
    return (prop) => {
        return propsForModel.find(value => {
            return value.property === prop;
        });
    };
}
1268304
function (bodySchemaModels, defName) {
        for (var i in bodySchemaModels) {
            if (bodySchemaModels[i]["name"] == defName) {
                return bodySchemaModels[i];
            }
        }
        return null;
    }
16665
function mapType(model) {
    types[model.modelName] = {
        generated: false,
        name: model.modelName,
        meta: {
            category: 'TYPE',
            fields: {}
        }
    };

    _.forEach(model.definition.properties, (property, key) => {
        mapProperty(model, property, model.modelName, key);
    });

    _.forEach(sharedRelations(model), (rel) => {
        mapRelation(rel, model.modelName, rel.name);
    });
}
146085
function(definition, client) {

  this.client = client;

  this.schema = null;

  this.ddlHelper = {
    tableName: null,
    pkAttrName: null,
    pkAutoIncrement: false,
    attrNamesToColNames: {},
    attrTypes: {},
    colNamesToAttrNames: {},
    colTypes: {},
    defaultValues: {},
    cqlCreateTable: null,
    indexes: {}
  };

  this._parseDefinition(definition);
}
848993
function(model) {
		var _d = this._d,
			model = this.collection.get(model.id ? model.id : model),
			sortingValue = this.sortBy(model),
			cacheValue = { s: sortingValue, m: model };

		return _.sortedIndex(_d.listCache, cacheValue, 's');
	}
690898
function getModel(model) {
  const schemaPaths = model.schema.paths;
  const name = model.modelName;

  const fields = extractPaths(schemaPaths, { name });

  return {
    name,
    fields,
    model
  };
}
1152940
function map(tree, method, args) {
    return tree.model[method].apply(tree.model, args);
}
309288
public function getDefinition($model)
    {
        if(!($model instanceof Model)) return false;

        $fields = array();
        $keys = array();
        $unique = array();
        $definition = $model->getDefinition();
        if (isset($definition['fields'])) {
            $definitionFields = $definition['fields'];
            if (is_array($definition['index'])) {
                $definitionFields = array($definition['index']['field'] => $definition['index']) + $definitionFields;
                $definitionFields[$definition['index']['field']]['primary'] = true;
            } else {
                $definitionFields = array(
                        $definition['index'] => array(
                            'type' => 'int(11)',
                            'autoincrement' => true
                        )
                    ) + $definitionFields;
            }
            foreach ($definitionFields as $field => $props) {
                if (is_array($props)) {
                    $fields[$field] = array(
                        'field' => $field,
                    );

                    if (isset($props['type'])) {
                        $fields[$field]['type'] = $props['type'];
                    }
                    if (isset($props['default'])) {
                        $fields[$field]['default'] = $props['default'];
                    } else {
                        $fields[$field]['default'] = '';
                    }
                    if (isset($props['autoincrement'])) {
                        $fields[$field]['autoincrement'] = $props['autoincrement'];
                    }
                    if (isset($props['primary'])) {
                        $fields[$field]['primary'] = $props['primary'];
                    }
                } else {
                    $fields[$field] = array(
                        'field' => $field,
                        'type' => $props,
                        'default' => '',
                        //                'null' => 1
                    );
                }
            }
        }
        if (isset($definition['keys'])) {
            foreach ($definition['keys'] as $field => $value) {
                if (isset($fields[$field])) {
                   $model1 = key($value); // Para extrar datos del tipo key => value
                   $column = current($value);
                   $modelObj = Model::newInstance($model1);
                   if ($modelObj and $modelObj instanceof Model) {
                       $keys[] = array(
                           'field' => $field,
                           'table' => $modelObj->getTableName(),
                           'target' => $column

                       );
//                       $fields[$field]['index'] = true;
                   }

                }
            }
        }

        if (isset($definition['unique'])) {
            foreach ($definition['unique'] as $field) {
                $unique[] = array('field' => $field);
            }
        }

        $result = array();
        $result['table'] = $model->getTableName();
        $result['fields'] = $fields;
        $result['keys'] = $keys;
        $result['unique'] = $unique;
//        $result['engine'] = $model->getEngine();

        return $result;
    }
533961
protected Map<String, Object> getModelAttributes(final Map<String, Object> model) {
        return (Map<String, Object>) model.get(CasProtocolConstants.VALIDATION_CAS_MODEL_ATTRIBUTE_NAME_ATTRIBUTES);
    }
361438
function(model, options) {
            options || (options = {});
            if (!(model instanceof Model)) {
                var attrs = model;
                options.collection = this;
                model = new this.model(options, attrs);
            } else if (!model.collection) {
                model.collection = this;
            }
            return model;
        }
135349
def object_to_http_body(model)
      return if model.nil?
      _body = nil
      if model.is_a?(Array)
        _body = model.map{|m| object_to_hash(m) }
      else
        _body = object_to_hash(model)
      end
      _body.to_json
    end
1016714
private Definition getDefinition(final HttpServletRequest req) {
        final String definitionToken = req.getHeader(Headers.DEFINITION.getName());
        return StringUtils.isNotBlank(definitionToken)
                ? definitionService.parseDefinition(definitionToken)
                : MissingModelElement.DEFINITION;
    }
169271
function(model, options) {
            model = this._prepareModel(model, options);
            this.add(model, options);
            return model;
        }
774344
function mapProperty(model, property, modelName, propertyName, isInputType = false) {

    // If property is deprecated, ignore it.
    if (property.deprecated) {
        return;
    }

    // Bootstrap basic property object
    types[modelName].meta.fields[propertyName] = {
        generated: false,
        meta: {
            required: property.required,
            hidden: model.definition.settings.hidden && model.definition.settings.hidden.indexOf(propertyName) !== -1
        }
    };
    const currentProperty = types[modelName].meta.fields[propertyName];

    const typeName = `${modelName}_${propertyName}`;
    let propertyType = property.type;

    // Add resolver
    currentProperty.resolve = (obj, args, context) => (_.isNil(obj[propertyName]) ? null : obj[propertyName]);

    // If it's an Array type, map it to JSON Scalar
    if (propertyType.name === 'Array') { // JSON Array
        currentProperty.meta.list = true;
        currentProperty.meta.type = 'JSON';
        currentProperty.meta.scalar = true;
        return;
    }

    // If it's an Array type, map it to JSON Scalar
    if (propertyType.name === 'GeoPoint') { // JSON Array
        currentProperty.meta.type = (isInputType) ? 'GeoPointInput' : 'GeoPoint';
        return;
    }

    // If property.type is an array, its a list type.
    if (_.isArray(property.type)) {
        currentProperty.meta.list = true;
        propertyType = property.type[0];
    }

    // See if this property is a scalar.
    let scalar = getScalar(propertyType.name);

    if (property.defaultFn) {
        scalar = getScalar(property.defaultFn);
    }

    if (scalar) {
        currentProperty.meta.scalar = true;
        currentProperty.meta.type = scalar;

        if (property.enum) { // enum has a dedicated type but no input type is required
            types[typeName] = {
                generated: false,
                name: typeName,
                values: property.enum,
                meta: {
                    category: 'ENUM'
                }
            };
            currentProperty.type = typeName;
        }
    }

    // If this property is another Model
    if (propertyType.name === 'ModelConstructor' && property.defaultFn !== 'now') {
        currentProperty.meta.type = (!isInputType) ? propertyType.modelName : `${propertyType.modelName}Input`;
        const union = propertyType.modelName.split('|');

        // type is a union
        if (union.length > 1) { // union type
            types[typeName] = { // creating a new union type
                generated: false,
                name: typeName,
                meta: {
                    category: 'UNION'
                },
                values: toTypes(union)
            };
        } else if (propertyType.settings && propertyType.settings.anonymous && propertyType.definition) {
            currentProperty.meta.type = typeName;
            types[typeName] = {
                generated: false,
                name: typeName,
                meta: {
                    category: 'TYPE',
                    input: isInputType,
                    fields: {}
                }
            }; // creating a new type
            _.forEach(propertyType.definition.properties, (p, key) => {
                mapProperty(propertyType, p, typeName, key, isInputType);
            });
        }
    }
}
449597
function Schema(model) {
        var _this = this;
        /**
         * List of generated schemas.
         */
        this.schemas = {};
        this.model = model;
        var models = model.database().models();
        Object.keys(models).forEach(function (name) { _this.one(models[name]); });
    }