Пример #1
0
        public void Validate()
        {
            if (Apis == null || !Apis.Any())
            {
                throw new Exception("No apis configured");
            }

            if (Apis.Any(a => string.IsNullOrEmpty(a.Url)))
            {
                throw new Exception("At least one api has no url configured");
            }

            var responses = Apis.Where(a => a.Responses != null).SelectMany(a => a.Responses).ToList();

            if (string.IsNullOrEmpty(DefaultMethod) &&
                (!responses.Any() || responses.Any(r => string.IsNullOrEmpty(r.Method))))
            {
                throw new Exception("At least one api has no http method configured");
            }

            if (string.IsNullOrEmpty(DefaultResponse) &&
                (!responses.Any() ||
                 responses.Any(r => !r.HasFile && !r.HasFiles && !r.HasWebException && !r.HasCustomException && string.IsNullOrEmpty(r.Response))))
            {
                throw new Exception("At least one api has no response configured");
            }
        }
Пример #2
0
        public async Task OnGetAsync()
        {
            Apis = await _apiManager.LoadApisAsync();

            ApiDescriptions = _provider.ApiDescriptionGroups.Items.SelectMany(x => x.Items)
                              .Where(x => Apis.Any(api => api.Name.Equals(x.RelativePath, StringComparison.OrdinalIgnoreCase)))
                              .ToList();
        }
Пример #3
0
        public async Task <IActionResult> OnGetAsync(int id)
        {
            Application = await _apiManager.FindAsync(id);

            if (Application == null)
            {
                return(ErrorPage("应用不存在!"));
            }
            Apis = await _apiManager.LoadApplicationApisAsync(id);

            ApiDescriptions = _provider.ApiDescriptionGroups.Items.SelectMany(x => x.Items)
                              .Where(x => Apis.Any(api => api.Name.Equals(x.RelativePath, StringComparison.OrdinalIgnoreCase)))
                              .ToList();
            return(Page());
        }
Пример #4
0
 public bool Any()
 {
     return(HubVariables.Any() ||
            Datajobs.Any() ||
            Datalinks.Any() ||
            Connections.Any() ||
            Tables.Any() ||
            ColumnValidations.Any() ||
            CustomFunctions.Any() ||
            FileFormats.Any() ||
            RemoteAgentHubs.Any() ||
            DatalinkTests.Any() ||
            Views.Any() ||
            Apis.Any() ||
            Dashboards.Any() ||
            ListOfValues.Any() ||
            Tags.Any() ||
            TagObjects.Any());
 }