Ejemplo n.º 1
0
        public void BuildAPIWithSwaggerReader()
        {
            string urlPath = @"http://localhost:2598/swagger/docs/Echo";
            AbstractSwaggerReader swaggerReader = new SwaggerUrlReader(urlPath);
            APIBuilder            builder       = APIBuilder.GetBuilder(swaggerReader);
            API api = builder.BuildAPIAndOperations();

            Assert.IsNotNull(api);
            Assert.IsNotNull(api.Id);
            Assert.IsNotNull(api.Operations);
            Assert.IsTrue(api.Operations.Count > 0);
        }
Ejemplo n.º 2
0
        public void PublishSwaggerAPI()
        {
            string     url     = @"http://localhost:2598/swagger/docs/Profiles";
            APIBuilder builder = APIBuilder.GetBuilder(url);
            API        api     = builder.BuildAPIAndOperations();
            var        entity  = _Client.CreateAPIAsync(api).Result;

            Assert.IsNotNull(entity);
            foreach (var operation in api.Operations)
            {
                var entityOperation = _Client.CreateAPIOperationAsync(entity, operation).Result;
                Assert.IsNotNull(entityOperation);
            }
        }
Ejemplo n.º 3
0
        public void ReadLocalOperation()
        {
            string filePath = @"C:\Users\inter\Downloads\swaggerOperation.json";
            AbstractSwaggerReader swaggerReader = new SwaggerFileReader(filePath);
            APIBuilder            builder       = APIBuilder.GetBuilder(swaggerReader);

            ICollection <APIOperation> operations = builder.BuildAPIAndOperations().Operations;


            string apiId  = "api_577edd5ee62543d297bd5d568af78a82";
            API    entity = _Client.GetAPIAsync(apiId).Result;
            string json   = JsonConvert.SerializeObject(entity.Operations);

            foreach (APIOperation o in operations)
            {
                try
                {
                    APIOperation e = _Client.CreateAPIOperationAsync(entity, o).Result;
                }
                catch (Exception)
                {
                }
            }
        }
Ejemplo n.º 4
0
        public void ReadLocalSwaggerFile()
        {
            var setting = new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            };

            string filePath = @"C:\Users\inter\Downloads\swagger.json";
            AbstractSwaggerReader swaggerReader = new SwaggerFileReader(filePath);
            APIBuilder            builder       = APIBuilder.GetBuilder(swaggerReader);

            API api    = builder.BuildAPIAndOperations();
            API entity = _Client.CreateAPIAsync(api).Result;

            foreach (APIOperation o in api.Operations)
            {
                try
                {
                    APIOperation e = _Client.CreateAPIOperationAsync(entity, o).Result;
                }
                catch (Exception)
                {
                }
            }
        }