public override string MidOperationBody(OperationModel operationModel) { if (operationModel.GetHttpSettings().Verb().IsGET()) { return(string.Empty); } return($@" await _dbContext.SaveChangesAsync(cancellationToken);"); }
private string GetParameterBindingAttribute(OperationModel operation, ParameterModel parameter) { if (parameter.GetParameterSettings().Source().IsDefault()) { if ((operation.GetHttpSettings().Verb().IsGET() || operation.GetHttpSettings().Verb().IsDELETE()) && (!parameter.TypeReference.Element.IsTypeDefinitionModel())) { return("[FromQuery]"); } if ((operation.GetHttpSettings().Verb().IsPOST() || operation.GetHttpSettings().Verb().IsPUT()) && (!parameter.TypeReference.Element.IsTypeDefinitionModel())) { return("[FromBody]"); } if (parameter.TypeReference.Element.IsTypeDefinitionModel() && operation.GetHttpSettings().Route()?.Contains($"{{{parameter.Name}}}") == true) { return("[FromRoute]"); } return(""); } if (parameter.GetParameterSettings().Source().IsFromBody()) { return("[FromBody]"); } if (parameter.GetParameterSettings().Source().IsFromHeader()) { return("[FromHeader]"); } if (parameter.GetParameterSettings().Source().IsFromQuery()) { return("[FromQuery]"); } if (parameter.GetParameterSettings().Source().IsFromRoute()) { return("[FromRoute]"); } return(""); }
private string GetPath(OperationModel operation) { var path = operation.GetHttpSettings().Route(); return(!string.IsNullOrWhiteSpace(path) ? $"/{path.RemovePrefix("/")}" : null); }
private HttpVerb GetHttpVerb(OperationModel operation) { var verb = operation.GetHttpSettings().Verb(); return(Enum.TryParse(verb.Value, out HttpVerb verbEnum) ? verbEnum : HttpVerb.POST); }
private string GetPath(OperationModel operation) { var path = operation.GetHttpSettings().Route(); return(!string.IsNullOrWhiteSpace(path) ? path : null); }