private void ShemeModelToParameters(DefinitionModel model) { if (model == null || model.properties == null) { return; } foreach (KeyValuePair <string, PropertyModel> property in model.properties) { ParameterModel parameter = new ParameterModel { In = ParameterPosition.body, name = property.Key }; if (!string.IsNullOrEmpty(property.Value.type)) { parameter.type = property.Value.type; } if (model.required.IndexOf(property.Key) != -1) { parameter.required = true; } else { parameter.required = false; } parameter = ReplaceType(parameter); BodyParams.Add(parameter); Params.Add(parameter); } }
private void LoadBodyParams(ParameterModel parameter) { if (parameter.schema != null && !string.IsNullOrEmpty(parameter.schema.refName)) { parameter.shemeModel = GetShemeModelFunc.Invoke(parameter.schema.refName); ShemeModelToParameters(parameter.shemeModel); } }
private ParameterModel ReplaceType(ParameterModel parameter) { if (!string.IsNullOrEmpty(parameter.type) && TypesMapping.ContainsKey(parameter.type)) { TypesMapping.TryGetValue(parameter.type, out parameter.type); } return(parameter); }
private List <ParameterModel> ResponceShemeToParameters(DefinitionModel model) { List <ParameterModel> responces = new List <ParameterModel>(); if (model == null || model.properties == null) { return(responces); } foreach (KeyValuePair <string, PropertyModel> property in model.properties) { ParameterModel parameter = new ParameterModel { In = ParameterPosition.responce, name = property.Key }; if (!string.IsNullOrEmpty(property.Value.type)) { parameter.type = property.Value.type; } if (model.required.IndexOf(property.Key) != -1) { parameter.required = true; } else { parameter.required = false; } if (property.Value.items != null && !string.IsNullOrEmpty(property.Value.items.refName)) { DefinitionModel itemsModel = GetShemeModelFunc.Invoke(property.Value.items.refName); parameter.items = ResponceShemeToParameters(itemsModel); } else if (!string.IsNullOrEmpty(property.Value.refName) && property.Value.refName == "#/definitions/representation.Money") { parameter.type = "Price"; } parameter = ReplaceType(parameter); responces.Add(parameter); } return(responces); }