public Task <ApiMockInfo> CreateAsync(string name, string description, string apiMethod, List <FieldFormat> requestFormats, List <FieldFormat> responseFormats) { if (!s_db.TryGetValue(name, out ApiMockInfo _)) { ApiMockInfo info = new ApiMockInfo { Name = name, Description = description, ApiMethod = apiMethod, RequestFormats = JsonConvert.SerializeObject(requestFormats), ResponseFormats = JsonConvert.SerializeObject(responseFormats) }; s_db.AddOrUpdate(name, info, (a, b) => info); return(Task.FromResult(info)); } throw new Exception($"The ApiMock info with the name '{name}' is exist."); }
public async Task <IActionResult> Add([FromBody] CreateApiMockerRequest request) { ApiMockInfo result = await _apiMockerService.CreateAsync(request.Name, request.Description, request.ApiMethod, request.RequestFormats, request.ResponseFormats); return(Ok(result)); }