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 swagger = await Fhir2Apim.GetSwaggerFromMetadata(fhirserver, metadataEndpoint, interactionList, resourceList); return(new ContentResult() { Content = swagger, StatusCode = 200, ContentType = "application/json" }); }
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 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); }