Esempio n. 1
0
        public ApiDeclaration GetDeclaration(string basePath, string version, string resourceName)
        {
            var apiDescriptionGroup = GetApplicableApiDescriptions(version)
                                      .Single(apiDescGrp => apiDescGrp.Key == resourceName);

            var dataTypeRegistry   = new DataTypeRegistry(_customTypeMappings, _polymorphicTypes, _modelFilters);
            var operationGenerator = new OperationGenerator(dataTypeRegistry, _operationFilters);

            // Group further by relative path - each group corresponds to an Api
            var apis = apiDescriptionGroup
                       .GroupBy(apiDesc => apiDesc.RelativePathSansQueryString())
                       .Select(apiDescGrp => CreateApi(apiDescGrp, operationGenerator))
                       .OrderBy(api => api.Path)
                       .ToList();

            return(new ApiDeclaration
            {
                SwaggerVersion = SwaggerVersion,
                ApiVersion = version,
                BasePath = basePath,
                ResourcePath = "/" + resourceName,
                Apis = apis,
                Models = dataTypeRegistry.GetModels()
            });
        }
Esempio n. 2
0
        public ApiDeclaration GetDeclaration(string basePath, string version, string resourceName)
        {
            var apiDescriptionGroup = GetApplicableApiDescriptions(version)
                .Single(apiDescGrp => apiDescGrp.Key == resourceName);

            var dataTypeRegistry = new DataTypeRegistry(_customTypeMappings, _polymorphicTypes, _modelFilters);
            var operationGenerator = new OperationGenerator(dataTypeRegistry, _operationFilters);

            // Group further by relative path - each group corresponds to an Api
            var apis = apiDescriptionGroup
                .GroupBy(apiDesc => apiDesc.RelativePathSansQueryString())
                .Select(apiDescGrp => CreateApi(apiDescGrp, operationGenerator))
                .OrderBy(api => api.Path)
                .ToList();

            return new ApiDeclaration
            {
                SwaggerVersion = SwaggerVersion,
                ApiVersion = version,
                BasePath = basePath,
                ResourcePath = "/" + resourceName,
                Apis = apis,
                Models = dataTypeRegistry.GetModels()
            };
        }
        public ApiDeclaration GetDeclaration(string resourceName)
        {
            var apiDescriptionGroup = _apiDescriptions
                .GroupBy(apiDesc => _options.ResourceNameResolver(apiDesc))
                .SingleOrDefault(apiDescGrp => apiDescGrp.Key == resourceName);

            if (apiDescriptionGroup == null)
                throw new ApiDeclarationNotFoundException(resourceName);

            var dataTypeRegistry = new DataTypeRegistry(
                _options.CustomTypeMappings,
                _options.PolymorphicTypes,
                _options.ModelFilters);

            var operationGenerator = new OperationGenerator(
                dataTypeRegistry,
                _options.OperationFilters);

            // Group further by relative path - each group corresponds to an Api
            var apis = apiDescriptionGroup
                .GroupBy(apiDesc => apiDesc.RelativePathSansQueryString())
                .Select(apiDescGrp => CreateApi(apiDescGrp, operationGenerator))
                .OrderBy(api => api.Path)
                .ToList();

            return new ApiDeclaration
            {
                SwaggerVersion = SwaggerVersion,
                ApiVersion = _apiVersion,
                BasePath = _basePath,
                ResourcePath = "/" + resourceName,
                Apis = apis,
                Models = dataTypeRegistry.GetModels()
            };
        }
Esempio n. 4
0
        public ApiDeclaration GetDeclaration(string resourceName)
        {
            var apiDescriptionGroup = _apiDescriptions
                                      .GroupBy(apiDesc => _options.ResourceNameResolver(apiDesc))
                                      .SingleOrDefault(apiDescGrp => apiDescGrp.Key == resourceName);

            if (apiDescriptionGroup == null)
            {
                throw new ApiDeclarationNotFoundException(resourceName);
            }

            var dataTypeRegistry = new DataTypeRegistry(
                _options.CustomTypeMappings,
                _options.PolymorphicTypes,
                _options.ModelFilters);

            var operationGenerator = new OperationGenerator(
                dataTypeRegistry,
                _options.OperationFilters);

            // Group further by relative path - each group corresponds to an Api
            var apis = apiDescriptionGroup
                       .GroupBy(apiDesc => apiDesc.RelativePathSansQueryString())
                       .Select(apiDescGrp => CreateApi(apiDescGrp, operationGenerator))
                       .OrderBy(api => api.Path)
                       .ToList();

            return(new ApiDeclaration
            {
                SwaggerVersion = SwaggerVersion,
                ApiVersion = _apiVersion,
                BasePath = _basePath,
                ResourcePath = "/" + resourceName,
                Apis = apis,
                Models = dataTypeRegistry.GetModels()
            });
        }