public void RequestBodyObjectConverter_ResultHasMatchingDescription() { OperationObjectConverter converter = new OperationObjectConverter(_urlCoverterMock.Object, _headerConverterMock.Object, _bodyConverterMock.Object, new DefaultValueFactory()); PostmanCollectionItem result = converter.Convert("/api/action/:id", PostmanHttpMethod.POST, _validOperation, _validDoc); Assert.Equal(_validOperation.Description, result.Description.Content); }
public void RequestBodyObjectConverter_ResultNameMatchesPath() { OperationObjectConverter converter = new OperationObjectConverter(_urlCoverterMock.Object, _headerConverterMock.Object, _bodyConverterMock.Object, new DefaultValueFactory()); PostmanCollectionItem result = converter.Convert("/api/action/:id", PostmanHttpMethod.POST, _validOperation, _validDoc); Assert.Equal("/api/action/:id", result.Name); }
public void RequestBodyObjectConverter_ResultEventsArrayIsNotNull() { OperationObjectConverter converter = new OperationObjectConverter(_urlCoverterMock.Object, _headerConverterMock.Object, _bodyConverterMock.Object, new DefaultValueFactory()); PostmanCollectionItem result = converter.Convert("/api/action/:id", PostmanHttpMethod.POST, _validOperation, _validDoc); Assert.NotNull(result.Events); }
public void RequestBodyObjectConverter_DoesNotModifyUrlResultFromUrlMapper() { OperationObjectConverter converter = new OperationObjectConverter(_urlCoverterMock.Object, _headerConverterMock.Object, _bodyConverterMock.Object, new DefaultValueFactory()); PostmanCollectionItem result = converter.Convert("/api/action/:id", PostmanHttpMethod.POST, _validOperation, _validDoc); Assert.Equal("", result.Request.Url.Hash); Assert.Equal("mysite.com", result.Request.Url.Host); Assert.Equal(new string[] { "api", "action", ":id" }, result.Request.Url.Path); Assert.Equal("80", result.Request.Url.Port); Assert.Equal("http", result.Request.Url.Protocol); Assert.Equal(new List <PostmanQueryParam> { new PostmanQueryParam("filter", "test") }, result.Request.Url.QueryParams, new PostmanQueryParamComparer()); Assert.Equal("http://mysite.com/api/action/:id?filter={{filter}}", result.Request.Url.Raw); Assert.Equal(new List <PostmanVariable>(), result.Request.Url.Variables); }
public PostmanCollectionItem Convert(string path, PostmanHttpMethod method, Operation operation, SwaggerDocument swaggerDoc) { IList <IParameter> parameters = operation.Parameters; if (parameters == null) { parameters = new List <IParameter>(); } PostmanUrl urlObject = this.urlConverter.Convert(path, parameters.ToList(), swaggerDoc.Host, swaggerDoc.BasePath); List <PostmanHeader> headerList = this.headerConverter.Convert(parameters.OfType <NonBodyParameter>().ToList()); BodyParameter bodyParam = parameters.OfType <BodyParameter>().FirstOrDefault(p => p is BodyParameter); PostmanRequestBody body = requestBodyConverter.Convert(bodyParam, parameters.ToList(), swaggerDoc.Definitions); var collectionItem = new PostmanCollectionItem() { Description = new PostmanDescription { Content = operation.Description }, Id = operation.OperationId, Name = path, Request = new PostmanRequest { Method = method, Description = new PostmanDescription { Content = operation.Description ?? "" }, Url = urlObject, Headers = headerList, Body = body } }; return(collectionItem); }