public ApiDocumentation GetApiDocumentation() { var routeData = _metadataProvider.RetrieveSwaggerRouteData(); var modelsData = _metadataProvider.RetrieveSwaggerModelData(); var rootDocumentation = _metadataProvider.RetrieveRootDocumentation(); var apiDocumentation = new ApiDocumentation() { Version = "2.0", Info = rootDocumentation.rootInfo, Host = rootDocumentation.Host, Schemes = rootDocumentation.Schemes, basePath = rootDocumentation.basePath, Paths = routeData }; apiDocumentation.Definitions = _metadataProvider.RetrieveSwaggerModelData() .SelectMany(m => m.ToModel(modelsData)) .GroupBy(m => m.Id) .Select(g => g.First()) .OrderBy(m => m.Id) .ToDictionary(m => m.Id, m => { m.Id = null; return(m); }); return(apiDocumentation); }
public static void Serialize_StockApiDocumentation_GeneratesExpectedJsonLD() { // Arrange string expectedJsonLD = File.ReadAllText( "expected-api-documentation-with-stock.jsonld"); var apiDocumentation = new ApiDocumentation(new Uri("https://api.example.com/doc")); apiDocumentation.Context.TryAddMapping("doc", new Uri("https://api.example.com/doc#")); apiDocumentation.AddSupportedClass <Stock>(); // Act //string jsonLD = JsonConvert.SerializeObject(apiDocumentation, Formatting.Indented); string jsonLD = JsonSerializer.Serialize(apiDocumentation, new JsonSerializerOptions { WriteIndented = true }); // Assert Assert.Equal(expectedJsonLD, jsonLD); }
public ApiDocumentation GetApiDocumentation() { var apiDocumentation = new ApiDocumentation { Version = "2.0", Host = "localhost" }; return(apiDocumentation); }
/// <summary> /// Creates the API documentation. /// </summary> public ApiDocumentation Create() { var apiDocumentation = new ApiDocumentation(this.settings.EntryPoint); var types = (from type in this.sources.SelectMany(source => source.FindTypes()).Distinct() let classId = this.rdfClassProvider.Create(type) select type) .ToDictionary(t => t, type => this.rdfClassProvider.Create(type)); var classes = types.Select(type => this.classFactory.Create(type.Key, types)); apiDocumentation.SupportedClasses = classes.ToList(); return(apiDocumentation); }
public static void Deserialize_StockApiDocumentation_CreatesApiDocumentationWithStockClass() { // Arrange string expectedSupportedClassId = "doc:Stock"; string apiDocumentationWithStockClassJsonLD = File.ReadAllText("expected-api-documentation-with-stock.jsonld"); // Act //ApiDocumentation apiDocumentation = JsonConvert.DeserializeObject<ApiDocumentation>( // apiDocumentationWithStockClassJsonLD); ApiDocumentation apiDocumentation = JsonSerializer.Deserialize <ApiDocumentation>( apiDocumentationWithStockClassJsonLD); // Assert Assert.Equal( expectedSupportedClassId, apiDocumentation.SupportedClasses.First().Id.ToString()); }
static HypermediaProcessorBase() { MulticastObject .ImplementationOf <IApiDocumentation>() .ForFunction(_ => _.GetEntryPoint()) .ImplementedBy(_ => ApiDocumentation.GetEntryPoint(_)); MulticastObject .ImplementationOf <IApiDocumentation>() .ForFunction(_ => _.GetEntryPoint(CancellationToken.None)) .ImplementedBy(_ => ApiDocumentation.GetEntryPoint(_, CancellationToken.None)); MulticastObject .ImplementationOf <ICollection>() .ForFunction(_ => _.GetIterator()) .ImplementedBy(_ => Collection.GetIterator(_)); MulticastObject .ImplementationOf <ITemplatedLink>() .ForFunction(_ => _.ExpandTarget((IDictionary <string, string>)null)) .ImplementedBy(_ => TemplatedLink.ExpandTarget(_, (IDictionary <string, string>)null)); MulticastObject .ImplementationOf <ITemplatedLink>() .ForFunction(_ => _.ExpandTarget((Action <MappingsBuilder>)null)) .ImplementedBy(_ => TemplatedLink.ExpandTarget(_, (Action <MappingsBuilder>)null)); MulticastObject .ImplementationOf <ITemplatedOperation>() .ForFunction(_ => _.ExpandTarget((IDictionary <string, string>)null)) .ImplementedBy(_ => TemplatedOperation.ExpandTarget(_, (IDictionary <string, string>)null)); MulticastObject .ImplementationOf <ITemplatedOperation>() .ForFunction(_ => _.ExpandTarget((Action <MappingsBuilder>)null)) .ImplementedBy(_ => TemplatedOperation.ExpandTarget(_, (Action <MappingsBuilder>)null)); MulticastObject .ImplementationOf <IResource>() .ForProperty(_ => _.DisplayName) .ImplementedBy(_ => ResourceExtensions.GetDisplayName(_)); MulticastObject .ImplementationOf <IResource>() .ForProperty(_ => _.TextDescription) .ImplementedBy(_ => ResourceExtensions.GetTextDescription(_)); }
public async Task TheTest() { Result = await ApiDocumentation.GetEntryPoint(); }
public void should_obtain_an_API_documentation() { ApiDocumentation.Awaiting(_ => _.GetEntryPoint()).Should().NotThrow(); }
public override async Task TheTest() { await base.TheTest(); EntryPoint = await ApiDocumentation.GetEntryPoint(); }