Skip to content

♻️ Use 'AsParameters' in Endpoint signatures #114

@sam-s-maher

Description

@sam-s-maher

The current syntax for our Endpoint requests is slightly clunky when mixing Route and Parameter based values, let's use 'AsParameters' to clean this up.

e.g. the following syntax

public record Request(
        string Name,
        string Alias,
        IEnumerable<UpdateHeroPowerDto> Powers) : IRequest<ErrorOr<Guid>>
    {
        [JsonIgnore]
        public Guid HeroId { get; set; }
    }

could be simplified to

    public record Request(
        [FromRoute] Guid HeroId,
        [FromBody] string Name,
        [FromBody] string Alias,
        [FromBody] IEnumerable<UpdateHeroPowerDto> Powers) : IRequest<ErrorOr<Guid>>;

and then

.MapGet("/{heroId:guid}",
                    async (Guid id, Request request, ISender sender, CancellationToken cancellationToken) => { ... }

could be...

.MapGet("/{heroId:guid}",
                    async ([AsParameters] Request request, ISender sender, CancellationToken cancellationToken) => { ... }

Tasks

  • Update the syntax for all endpoints
  • Ensure all the endpoint signatures are consistent

Acceptance Criteria

  1. [AsParameters] used to simplify requests
  2. Apply this to both the CA and VSA templates

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions