public void ExecutionEnvironmentUtils_GetOpenAPIOutputForService_ScalarInputsNoOutputs_ValidOpenAPIDefinition() { //------------Setup for test-------------------------- var mockResource = new Mock <IWarewolfResource>(); mockResource.Setup(resource => resource.ResourceName).Returns("resourceName"); var versionInfo = new VersionInfo { VersionNumber = "1.0" }; mockResource.Setup(resource => resource.VersionInfo).Returns(versionInfo); const string expectedOpenapi = "\"openapi\":\"3.0.1\""; const string expectedInfo = "\"info\":{\"title\":\"resourceName\",\"description\":\"resourceName\",\"version\":\"1.0\"}"; const string expectedServers = "\"servers\":[{\"url\":\"https://servername\"}]"; const string expectedParameters = "\"parameters\":[{\"name\":\"Name\",\"in\":\"query\",\"required\":true,\"schema\":{\"type\":\"string\"}}]"; const string expectedEmptyResponse = "\"responses\":{\"200\":{\"description\":\"Success\",\"content\":{\"application/json\":{\"schema\":{\"type\":\"object\",\"properties\":{}}}}}}}}}}"; //------------Execute Test--------------------------- var openAPIOutputForService = ExecutionEnvironmentUtils.GetOpenAPIOutputForService(mockResource.Object, "<DataList><Name Description=\"\" IsEditable=\"True\" ColumnIODirection=\"Input\" /></DataList>", "https://serverName:3142/public/resourceName.api").Replace(Environment.NewLine, "").Replace(" ", ""); //------------Assert Results------------------------- StringAssert.Contains(openAPIOutputForService, expectedOpenapi); StringAssert.Contains(openAPIOutputForService, expectedInfo); StringAssert.Contains(openAPIOutputForService, expectedServers); StringAssert.Contains(openAPIOutputForService, expectedParameters); StringAssert.Contains(openAPIOutputForService, expectedEmptyResponse); }
static string GetExecutePayload(IDSFDataObject dataObject, IWarewolfResource resource, WebRequestTO webRequest, ref DataListFormat formatter) { var notDebug = !dataObject.IsDebug || dataObject.RemoteInvoke || dataObject.RemoteNonDebugInvoke; if (notDebug && resource?.DataList != null) { switch (dataObject.ReturnType) { case EmitionTypes.XML: { return(ExecutionEnvironmentUtils.GetXmlOutputFromEnvironment(dataObject, resource.DataList.ToString(), 0)); } case EmitionTypes.OPENAPI: { formatter = DataListFormat.CreateFormat("OPENAPI", EmitionTypes.OPENAPI, "application/json"); return(ExecutionEnvironmentUtils.GetOpenAPIOutputForService(resource, resource.DataList.ToString(), webRequest.WebServerUrl)); } default: case EmitionTypes.JSON: { formatter = DataListFormat.CreateFormat("JSON", EmitionTypes.JSON, "application/json"); return(ExecutionEnvironmentUtils.GetJsonOutputFromEnvironment(dataObject, resource.DataList.ToString(), 0)); } } } return(string.Empty); }
public void ExecutionEnvironmentUtils_GetOpenAPIOutputForService_NullDataList_ExpectedException() { //------------Setup for test-------------------------- //------------Execute Test--------------------------- ExecutionEnvironmentUtils.GetOpenAPIOutputForService(new Mock <IResource>().Object, null, ""); //------------Assert Results------------------------- }
public void ExecutionEnvironmentUtils_GetOpenAPIOutputForService_NullServiceName_ExpectedException() { //------------Setup for test-------------------------- //------------Execute Test--------------------------- ExecutionEnvironmentUtils.GetOpenAPIOutputForService(null, "", ""); //------------Assert Results------------------------- }