public async Task ProcessAsync <TSchemaType>(EndpointDocJsonSchemaCustomizerContext <TSchemaType> context) where TSchemaType : JsonSchema4, new() { //Walk the type to find the PagedCollectionViewWithQuery var pagedCollectionType = context.Type; while (pagedCollectionType != null) { if (pagedCollectionType.IsGenericType) { if (pagedCollectionType.GetGenericTypeDefinition() == pagedCollectionWithViewGenericType) { break; } } pagedCollectionType = pagedCollectionType.BaseType; } if (pagedCollectionType == null) { throw new InvalidOperationException($"Could not find {nameof(PagedCollectionViewWithQuery<Object, PagedCollectionQuery>)} superclass on {context.Type.Name}. That superclass must be implemented to use the {nameof(PagedCollectionViewWithQueryEndpointDocJsonSchemaCustomizer)}."); } var queryType = pagedCollectionType.GenericTypeArguments[1]; //Remove offset and limit from schema, the query will add them back context.Schema.Properties.Remove("offset"); context.Schema.Properties.Remove("limit"); var originalTitle = context.Schema.Title; await context.Generator.GenerateAsync <TSchemaType>(queryType, Enumerable.Empty <Attribute>(), context.Schema, context.SchemaResolver); context.Schema.Title = originalTitle; }
public Task ProcessAsync <TSchemaType>(EndpointDocJsonSchemaCustomizerContext <TSchemaType> context) where TSchemaType : JsonSchema4, new() { EnsureCustomizer(); return(customizer.ProcessAsync(context)); }