public StatisticsMetadataModule(ISwaggerModelCatalog modelCatalog, ISwaggerTagCatalog tagCatalog) : base(modelCatalog, tagCatalog) { SwaggerTypeMapping.AddTypeMapping(typeof(DateTime), typeof(DateTime)); RouteDescriber.AddBaseTag(new Tag { Description = "Operations for getting projection statistics", Name = "Statistics" }); RouteDescriber.DescribeRoute <IEnumerable <ProjectorSummary> >("GetAll", "", "Returns a list of all known projectors and a summary of their status", new[] { new HttpResponseMetadata { Code = 200, Message = "OK" } }); RouteDescriber .DescribeRoute <ProjectorDetails>("GetSpecific", "", "Returns the details of a specific projector", new[] { new HttpResponseMetadata { Code = 200, Message = "OK" } }) .Parameter(p => p.Name("id").In(ParameterIn.Path).Description("Identifies the projector")); RouteDescriber .DescribeRoute <ProjectorEventCollection>("GetEvents", "", "Returns the events logged for a specific projector", new[] { new HttpResponseMetadata { Code = 200, Message = "OK" } }) .Parameter(p => p.Name("id").In(ParameterIn.Path).Description("Identifies the projector"));; RouteDescriber .DescribeRoute <string>("GetEta", "", "Returns the ETA for a specific projector to reach a certain checkpoint", new[] { new HttpResponseMetadata { Code = 200, Message = "OK" } }) .Parameter(p => p.Name("id").In(ParameterIn.Path).Description("Identifies the projector")) .Parameter(p => p.Name("targetCheckpoint").In(ParameterIn.Path).Description("The target checkpoint for which to calculate the ETA")); RouteDescriber.AddAdditionalModels( typeof(ProjectorEvent), typeof(ProjectorProperty), typeof(ProjectorSummary)); }
public void ShouldAdd_AndGet_NestedTypeMappings() { SwaggerTypeMapping.ResetMappedTypes(); Assert.False(SwaggerTypeMapping.IsMappedType(typeof(long))); SwaggerTypeMapping.AddTypeMapping(typeof(int), typeof(long)); SwaggerTypeMapping.AddTypeMapping(typeof(long), typeof(double)); Assert.True(SwaggerTypeMapping.IsMappedType(typeof(int))); Assert.True(SwaggerTypeMapping.IsMappedType(typeof(long))); Assert.Equal(typeof(double), SwaggerTypeMapping.GetMappedType(typeof(int))); }
public void ShouldAdd_AndGet_NestedTypeMappings() { SwaggerTypeMapping.ResetMappedTypes(); Assert.False(SwaggerTypeMapping.IsMappedType(typeof(OriginalType))); SwaggerTypeMapping.AddTypeMapping(typeof(AnotherOriginalType), typeof(OriginalType)); SwaggerTypeMapping.AddTypeMapping(typeof(OriginalType), typeof(MappedType)); Assert.True(SwaggerTypeMapping.IsMappedType(typeof(AnotherOriginalType))); Assert.True(SwaggerTypeMapping.IsMappedType(typeof(OriginalType))); Assert.Equal(typeof(MappedType), SwaggerTypeMapping.GetMappedType(typeof(AnotherOriginalType))); }
private static void InitSwagger(IAppConfiguration config) { SwaggerMetadataProvider.SetInfo( config["SvcMetaTitle"], config["SvcMetaVer"], $"[ Base URL: {config["HostUrl"]} ]", new Contact { EmailAddress = config["SvcMetaContact"] }); SwaggerConfig.ResourceListingPath = config["SwaggerResourceListingPath"]; SwaggerTypeMapping.AddTypeMapping(typeof(DateTime), typeof(string)); SwaggerTypeMapping.AddTypeMapping(typeof(DateTime?), typeof(string)); SwaggerTypeMapping.AddTypeMapping(typeof(TimeSpan), typeof(string)); SwaggerTypeMapping.AddTypeMapping(typeof(TimeSpan?), typeof(string)); SwaggerTypeMapping.AddTypeMapping(typeof(Guid), typeof(string)); }