コード例 #1
0
        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.");
        }
コード例 #2
0
        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));
        }