public void ArmApiOperationRepresentation(string typeName) { JObject rep = Fhir2Apim.ArmApiOperationRepresentation("Body"); Assert.Equal("application/json", (string)rep["contentType"]); Assert.Equal(typeName, (string)rep["typeName"]); }
public void ArmApiOperationTemplateParameter(string name, string typeName, bool required) { JObject templateParameter = Fhir2Apim.ArmApiOperationTemplateParameter(name, typeName, required); Assert.Equal(typeName, (string)templateParameter["type"]); Assert.Equal(required, (bool)templateParameter["required"]); }
public async Task <ActionResult> Get(string fhirserver, string metadata_endpoint, string interaction_list, string resource_list) { string metadataEndpoint = "metadata?_format=json"; string[] interactionList = { "all" }; string[] resourceList = { "all" }; if (!String.IsNullOrEmpty(metadata_endpoint)) { metadataEndpoint = metadata_endpoint; } if (!String.IsNullOrEmpty(interaction_list)) { interactionList = interaction_list.Split(","); } if (!String.IsNullOrEmpty(resource_list)) { resourceList = resource_list.Split(","); } string arm = await Fhir2Apim.GetArmApiFromMetadata(fhirserver, metadataEndpoint, interactionList, resourceList); return(new ContentResult() { Content = arm, StatusCode = 200, ContentType = "application/json" }); }
public void ArmApiQueryParameter(string name, string typeName, string description) { JObject parm = Fhir2Apim.ArmApiOperationQueryParameter(name, typeName, description); Assert.Equal(typeName, (string)parm["type"]); Assert.Equal(name, (string)parm["name"]); Assert.Equal(description, (string)parm["description"]); }
public void ArmApiOperation(string urlTemplate, string method) { JObject op = Fhir2Apim.ArmApiOperation(urlTemplate, method); Assert.Equal("2017-03-01", (string)op["apiVersion"]); Assert.Equal(method, (string)op["properties"]["method"]); Assert.Equal($"{urlTemplate} - {method}", (string)op["properties"]["displayName"]); Assert.Equal(urlTemplate, (string)op["properties"]["urlTemplate"]); }
public void ArmApiValidForHapi() { string serviceUrl = "http://hapi.fhir.org/baseDstu3/"; Uri fhirServer = new Uri(serviceUrl); JObject armApi = Fhir2Apim.ArmApimApi(serviceUrl); Assert.Equal("2017-03-01", (string)armApi["apiVersion"]); Assert.Equal("http", (string)armApi["properties"]["protocols"][0]); }
public void SwaggerBaseApiIsValid() { string serviceUrl = "http://hapi.fhir.org/baseDstu3/"; Uri fhirServer = new Uri(serviceUrl); JObject swaggerApi = Fhir2Apim.SwaggerApi(fhirServer); Assert.Equal("2.0", swaggerApi["swagger"]); Assert.Equal("Get conformance statement.", swaggerApi["paths"]["/metadata"]["get"]["summary"]); }
public async Task ArmApiGeneration(string fhirServerUrl, string description) { string [] interactionList = { "all " }; string [] resourceList = { "all " }; string metadataEndpoint = "metadata?_format=json"; string armApiString = await Fhir2Apim.GetArmApiFromMetadata(fhirServerUrl, metadataEndpoint, interactionList, resourceList); JObject armApi = JObject.Parse(armApiString); Assert.Equal(description, (string)armApi["resources"][0]["properties"]["description"]); }
public async Task GetSwaggerApiReturnsDefinitionWithExclusions(string fhirServerUrl, string description) { string [] interactionList = { "delete" }; string [] resourceList = { "Account" }; string metadataEndpoint = "metadata?_format=json"; string swaggerApiString = await Fhir2Apim.GetSwaggerFromMetadata(fhirServerUrl, metadataEndpoint, interactionList, resourceList); JObject swaggerApi = JObject.Parse(swaggerApiString); Assert.Equal("2.0", swaggerApi["swagger"]); Assert.Equal(description, (string)swaggerApi["info"]["description"]); Assert.Equal("Get conformance statement.", swaggerApi["paths"]["/metadata"]["get"]["summary"]); Assert.Null(swaggerApi["paths"]["/Patient"]); Assert.NotNull(swaggerApi["paths"]["/Account/{id}"]["delete"]); }
public void SwaggerParameterIsValid(string name, string inName, string typeName, string description) { JObject parm = Fhir2Apim.SwaggerParameter(name, inName, typeName, description); Assert.Equal(name, (string)parm["name"]); Assert.Equal(inName, (string)parm["in"]); Assert.Equal(typeName, (string)parm["type"]); if (description != null) { Assert.Equal(description, (string)parm["description"]); } else { Assert.Null(parm["description"]); } }
public void SwaggerOperationIsValid() { JObject swagop = Fhir2Apim.SwaggerOperation(); Assert.Equal("Success", (string)swagop["responses"]["200"]["description"]); }
public void ArmParameterStringDefaultValuue() { JObject p = Fhir2Apim.ArmParameter("string", "test string"); Assert.Equal("test string", (string)p["defaultValue"]); }
public static async Task Main(string[] args) { string fhirServerUrl = null; string metadataEndpoint = "metadata?_format=json"; string outFileName = "out.json"; string format = "swagger"; string[] interactionList = { "all" }; string[] resourceList = { "all" }; int arg = 0; while (arg < args.Length) { if (args[arg] == "-s" || args[arg] == "--server") { arg++; fhirServerUrl = args[arg++]; } else if (args[arg] == "-m" || args[arg] == "--meta") { arg++; metadataEndpoint = args[arg++]; } else if (args[arg] == "-o" || args[arg] == "--out") { arg++; outFileName = args[arg++]; } else if (args[arg] == "-r" || args[arg] == "--resources") { arg++; resourceList = args[arg++].Split(","); } else if (args[arg] == "-i" || args[arg] == "--interactions") { arg++; interactionList = args[arg++].Split(","); } else if (args[arg] == "-f" || args[arg] == "--format") { arg++; if (args[arg] != "swagger" && args[arg] != "arm") { Console.WriteLine("Valid formats are 'swagger' or 'arm'"); PrintUsage(); return; } format = args[arg++]; } else { Console.WriteLine($"Unknow command line argument: {args[arg]}"); PrintUsage(); return; } } if (String.IsNullOrEmpty(fhirServerUrl)) { Console.WriteLine("No FHIR server URL provided"); PrintUsage(); return; } string output = null; if (format == "swagger") { output = await Fhir2Apim.GetSwaggerFromMetadata(fhirServerUrl, metadataEndpoint, interactionList, resourceList); } else { output = await Fhir2Apim.GetArmApiFromMetadata(fhirServerUrl, metadataEndpoint, interactionList, resourceList); } System.IO.File.WriteAllText($"{outFileName}", output); }