Skip to content

boniestlawyer/PartialResponseRequest

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Azure DevOps tests with custom labels Coverage Nuget Nuget Nuget

Partial response

A simple set of libraries that enables you to parse, interpret, serialize and build simple queries for fields that could be used in building flexible REST endpoints (but not limited to API): https://my-app.com/animals?fields=id,photoUrl,guardian{name}&filters=id(gt:5)

Quick start

Response pruner

Nuget

Add a dependency using the NuGet package manager (console):

Install-Package PartialResponseRequest.AspNetCore.ResponsePruner.System.Text.Json

Use services.AddPartialResponse() to add a custom json output formatter, that will search for ?fields=... query string that would be used to prune the response for the client.

public void ConfigureServices(IServiceCollection services)
{
    services.AddHttpContextAccessor();
    services.AddPartialResponse();
}

Read more

Fields Queries

Nuget

Add a dependency using the NuGet package manager (console):

Install-Package PartialResponseRequest.Fields

Allows you to parse fields query for processing/interpreting and reacting based on it, like building a custom optimized SQL query:

var parser = new FieldsQueryParser();
IEnumerable<FieldToken> fields = parser.Parse("id,name,photoUrl");
var interpreter = new FieldsQueryInterpreter(fields);

// Use the interpreter to build queries
if (interpreter.Includes("id"))
{
    // include id field
}

Read more

Documentation

View the documentation here

Cake build tasks

https://cakebuild.net/

Build the project build.ps1 --target=Build [--configuration=Release]

Run tests build.ps1 --target=Test [--outputDirectory=./output]

Run a test coverage report build.ps1 --target=Report [--testResultsDirectory=./test-results/]

Create nuget packages build.ps1 --target=Pack [--outputDirectory=./output] [--configuration=Release] [--package-version=1.0.0.0]

About

A set of libraries for supporting partial web api responses

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 85.1%
  • PowerShell 10.8%
  • Shell 4.1%