Giter VIP home page Giter VIP logo

mediatr.aspnetcore.endpoints's Introduction

Hi there ๐Ÿ‘‹

mediatr.aspnetcore.endpoints's People

Contributors

kahbazi avatar mdissel 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  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

mediatr.aspnetcore.endpoints's Issues

Can't handle Json deserialization exceptions

As I see in the code, the deserialization exceptions (JsonException..) is swallowed. There is no Log entry written and the exception is not re-thrown. So When the exception happens, we only get Status Code 400 but not error why.

Error with a GUID route parameter

I'm seeing an error when using a System.Guid type route parameter:

Sample code:

namespace Test2
{
    public class SampleRequest2 : IRequest<SampleResponse2>
    {
        public Guid Id { get; set; }
    }

    public class SampleResponse2
    {
        public Guid Id { get; set; }

        public DateTime Timestamp { get; set; }
    }

    [ApiController]
    public class SampleRequestHandler : IRequestHandler<SampleRequest2, SampleResponse2>
    {
        [HttpGet("Test/{id}")]
        public async Task<SampleResponse2> Handle([FromRoute] SampleRequest2 request, CancellationToken cancellationToken)
        {
            return new SampleResponse2
            {
                Id = request.Id,
                Timestamp = DateTime.Now
            };
        }
    }
}

Error message:

System.InvalidCastException: Invalid cast from 'System.String' to 'System.Guid'.
at System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider)
at System.String.System.IConvertible.ToType(Type type, IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType)
at MediatR.AspNetCore.Endpoints.EndpointRouteBuilderExtensions.MapRouteData(IMediatorEndpointMetadata requestMetadata, RouteData routeData, Object model)
at MediatR.AspNetCore.Endpoints.EndpointRouteBuilderExtensions.MediatorRequestDelegate(HttpContext context)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Serilog.AspNetCore.RequestLoggingMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Method not found IMediator.Send

I'm using MediatR v9.0.0 which has separated the IMediatR interface into ISender and IPublisher which I think is a breaking change.

Would you consider updating this package to support the latest MediatR?

Is it possible to use this project with HttpGet and query parameters?

I can't seem to make a GET request pick up query parameters:

Sample code:

using System;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
using Microsoft.AspNetCore.Mvc;

namespace Test
{
    public class SampleRequest : IRequest<SampleResponse>
    {
        public int Id { get; set; }
    }

    public class SampleResponse
    {
        public int Id { get; set; }

        public DateTime Timestamp { get; set; }
    }

    [ApiController]
    public class SampleRequestHandler : IRequestHandler<SampleRequest, SampleResponse>
    {
        [HttpGet("Test")]
        public async Task<SampleResponse> Handle([FromQuery]SampleRequest request, CancellationToken cancellationToken)
        {
            return new SampleResponse
            {
                Id = request.Id,
                Timestamp = DateTime.Now
            };
        }
    }
}

Json serialization configuration

Currently, there is no way to configure the Syste.Text.Json serializer, this leads to camel case data sent from most SPA apps not be deserialized properly, we need some way to configure this or have at least

new JsonSerializerOptions { PropertyNameCaseInsensitive = true, PropertyNamingPolicy = JsonNamingPolicy.CamelCase }

in the EndpointRouteBuilderExtensions.cs

Use Source Generator and minimal Api?

Just wondering if there is any interest in brining this project to .net6 using Source Generator and Minimal Api?

Considering Mvc seems to be on the back burner now.

The swagger document contains no request body examples

Hi.
When I use standard controllers, the swagger documentation generates a request body examples from model (dto) classes. In case of MediatrEndpoints those body examples are not generated.
In the attached picture I can see Request body example
viber_image_2022-03-30_10-30-57-179
But in MediatR.Endpoints that schema is not generated.
How can I tell it to generate the Request body schema?

Map RouteData on Request Type with get request

Any tips how to map values from the Url and/or querystring on the Request Type object?

public class ViewEntityRequest : IRequest<ViewEntityRequest.Response> {

		public long Id { get; set; }

		public string Type { get; set; }
}

[HttpGet("view/{type}/{id}")]

Sample get request with url: /view/entity/5

Thanks
Marco

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.