Giter VIP home page Giter VIP logo

partialresponse's People

Contributors

dotarj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

partialresponse's Issues

WebApi.PartialResponse throwing exception when using Microsoft.AspNet.WebApi.HelpPage

Hi-

I recently installed WebApi.PartialReponse and everything was working great until I noticed an error on the help pages that are generated via Microsoft.AspNet.WebApi.HelpPage.

If I leave the config set as:
GlobalConfiguration.Configuration.Formatters.Add(new JsonMediaTypeFormatter());
it generates the response format samples as expected:
Sample: { "method": "200.8", "context": "USEPA", "desc": "Metals in Waters by ICP/MS" }

However, when I change the config so partial responses actually work:
GlobalConfiguration.Configuration.Formatters.Add(new PartialJsonMediaTypeFormatter() {IgnoreCase = true });

I get the following error message when it tries to create the sample response:

An exception has occurred while using the formatter 'PartialJsonMediaTypeFormatter' to generate sample for media type 'application/json'. Exception message: Value cannot be null. Parameter name: request

It generates another, similar message for media type 'text/json' as well.

It seems like the helpfile stuff isn't recognized the PartialJsonMediaTypeFormatter as JSON, and I'm not sure if that's on their end or if there's some way to force it in the configuration. Thanks!

Bug with leading space then nested properties are specified

Hi
In my project I try to use partial response. I have following response model:

{
  "Limit": 0,
  "Offset": 0,
  "Total": 0,
  "Content": [
    {Some model},
    {Some model}
  ]
}

If I specify nested properties of Content without leading spaces, anything works OK and I receive proper response. For request fields=limit,content(Id,name) I receive:

{
  "Limit": 20,
  "Content": [
    {
      "Id": "9b71be7c-0b29-419d-a89d-23cde2b2a0e0",
      "Name": "string"
    },
    {
      "Id": "468ace91-84a4-4d99-8026-aec839519686",
      "Name": "string"
    }
  ]
}

But if I create request with space before nested property specification only direct properties will be serialized. For example for request fields=limit, content(Id,name) I receive:

{
  "Limit": 20
}

If create request without nested properties or specify nested property one by one (with / character), anything works fine

Characters changing

Hi Arjen,

Well done for Partial Response , could not be easier to implement this. I appreciate your work. Now, I have one question. I have to make filters for json response after specification and should do the same as you wrote but instead of / to be . and instead () be [] , simply I need to change characters. Is it possible to do this without changing your code?

Best regards,
Balsa

asp.net core 2.0

The below exception is being thrown when using the PartialResponse.AspNetCore.Mvc.Formatters.Json package in asp.net core 2.0

MissingMethodException: Method not found: 'Microsoft.Net.Http.Headers.MediaTypeHeaderValue Microsoft.Net.Http.Headers.MediaTypeHeaderValue.Parse(System.String)'
PartialResponse.AspNetCore.Mvc.Formatters.Json.Internal.MvcPartialJsonMvcOptionsSetup.Configure(MvcOptions options)
Microsoft.Extensions.Options.OptionsFactory.Create(string name)
Microsoft.Extensions.Options.OptionsManager+<>c__DisplayClass5_0.b__0()
System.Lazy.ViaFactory(LazyThreadSafetyMode mode)
System.Lazy.ExecutionAndPublication(LazyHelper executionAndPublication, bool useDefaultConstructor)
System.Lazy.CreateValue()
Microsoft.Extensions.Options.OptionsCache.GetOrAdd(string name, Func createOptions)
Microsoft.Extensions.Options.OptionsManager.Get(string name)
Microsoft.Extensions.Options.OptionsManager.get_Value()
Microsoft.AspNetCore.Mvc.Internal.DefaultApplicationModelProvider..ctor(IOptions mvcOptionsAccessor)
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

Don't apply fields deletion when request is not successful

Hi,

So my problem is when my web api returns 400 Bad request code (one of parameter is invalid). In this case I return message in response with description of error. But PartialResponse cut this field (in mu case field is called 'Message').
As a workaround I can specify Message field in 'fields' parameter of request, but it isn't pretty from code perspective.

Is there any possibility to configure PartialResponse to skip deletion of fields in such cases?

Make GetPartialResponseFields a public method

In my WebApi projects I would like to build SQL Queries that return only the partial response fields.
Is it possible to make the GetPartialResponseFields "public", so that I can use the fields in the returned collection?

Parameters default value is not working

I am trying to set default fields by setting default value of fields parameter, see below code, this code not working and ignoring it and returning all fields.

`[Route("")]
[HttpGet]
public HttpResponseMessage GetAllLoginThemes(string Key, string Secret, string fields = "Data(Name,Title,IsPaid)")
{

    }`

AspNetCore support

You have a feature branch feature/aspnetcore. When are you planning on releasing this as a stable package? Or are you planning on releasing a pre-release package? This is perfect for what I need but I need a AspNetCore nuget package. Thanks

Do nothing after implementation

Hi,

I try to use the nugget package but after install and config with :
GlobalConfiguration.Configuration.Filters.Add(new PartialJsonActionFilter()); GlobalConfiguration.Configuration.Formatters.Clear(); GlobalConfiguration.Configuration.Formatters.Add(new PartialJsonMediaTypeFormatter() { IgnoreCase = true });

I return response with :
HttpResponseMessage ReturnResult<T>(HttpStatusCode httpStatusCode, T result) { var response = new HttpResponseMessage(httpStatusCode); response.Content = new ObjectContent<T>(result, new PartialJsonMediaTypeFormatter()); return response; }

and in url I call :
{{domain}}/api/driversapp?fields=Id

I have all data and not just the Id.

Any idea?

Thanks,

Issue with HTTPPOST?

Hi, thanks for making this available! I'm using this in an HTTPPOST-only API and even though I see the querystring coming in (?fields=x,y,z) for example, the output is not filtered accordingly. Are there certain return types that are expected? I'm using ihttpactionresult on my methods.

I added the lines to global.asax as specified:

protected void Application_Start() { GlobalConfiguration.Configure(WebApiConfig.Register); GlobalConfiguration.Configuration.Formatters.Clear(); GlobalConfiguration.Configuration.Formatters.Add(new PartialJsonMediaTypeFormatter() { IgnoreCase = true }); }

Each method was originally coded to flatten a DTO into JSON as follows:
return Json(resp)

where resp is whatever DTO is appropriate for the method.

Can anyone suggest what I am missing?

empty array is removed from json response

Hi congrats for the great work,

so my problem is in my web api where all my request respond the following structure

{
totalCount:12,
data[....]
}

When the are no data

{
totalCount:0,
data[]
}

and apply fields=totalcount,data(field1,field2)
then i get a response with data[] removed

{
totalCount:0
}

thats a problem because it cannot be mapped properly on the client

Handle "data" wrappers

According to https://developers.google.com/drive/api/v3/performance#partial requests to API responses that use "data" wrappers, where the response is nested within a data object that looks like data: { ... }, one should not include "data" in the fields specification.

So instead of "fields=data(a,b)" it should be specified like "fields=a,b".

In this case the filtering is only applied to the data property; any other properties of the wrapper object should not be filtered. Eg. { "success": true, "data": { ... } }

To not break the old versions this could be implemented as a property like with IgnoreCase on PartialJsonMediaTypeFormatter.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.