public async Task <JToken> LoadSchemaAsync(IEnumerable <string> documentUris, string?authorization) { var docs = documentUris.ToArray(); if (docs.Length == 1) { var loader = new ReferenceLoader(docs[0], ReferenceLoaderStrategy.CopyRefContent, authorization); var jObj = await loader.GetRefResolvedJObjectAsync(); return(jObj); } else { var merger = new OpenApiMerger(documentUris.Select(u => u.GetAbsoluteUri()).ToArray(), authorization: authorization); var jObj = await merger.GetMergedJObjectAsync(); return(jObj); } }
public async Task Test_Merger_Duplicated_Definition() { var merger = new OpenApiMerger(new[] { new Uri("./_yamlSamples/merger/petstore-minimal.json", UriKind.RelativeOrAbsolute), new Uri("./_yamlSamples/merger/example-minimal2.json", UriKind.RelativeOrAbsolute) }); var result = await merger.GetMergedJObjectAsync(); var paths = result[OpenApiConstants.PATHS_KEYWORD]?.Children().ToArray() ?? throw new NullReferenceException(); var definitions = result[OpenApiConstants.DEFINITIONS_KEYWORD]?.Children().ToArray() ?? throw new NullReferenceException(); paths.Length.ShouldBe(2); definitions.Length.ShouldBe(1); ((JProperty)paths[0]).Name.ShouldBe("/petBasePath/pets"); ((JProperty)paths[1]).Name.ShouldBe("/fooBasePath/foos"); ((JProperty)definitions[0]).Name.ShouldBe("Pet"); }