Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use API version when returning CreatedAtAction #16243

Open
wants to merge 1 commit into
base: v14/dev
Choose a base branch
from

Conversation

bergmania
Copy link
Member

Description

This adds functionality that gets the version from the attribute and use that for generating the urls.

Test

  • Create a version 2 endpoint and create an action that use this when the action is created.
    • E.g, I created a version two of ByKeyDictionaryController.ByKey
      [HttpGet($"{{{nameof(id)}:guid}}")]
      [MapToApiVersion("2.0")]
      [ProducesResponseType(typeof(DictionaryItemResponseModel), StatusCodes.Status200OK)]
      [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)]
      public async Task<IActionResult> ByKey2(CancellationToken cancellationToken, Guid id)
      {
          IDictionaryItem? dictionary = await _dictionaryItemService.GetAsync(id);
          if (dictionary == null)
          {
              return DictionaryItemNotFound();
          }
    
          return Ok(await _dictionaryPresentationFactory.CreateDictionaryItemViewModelAsync(dictionary));
      }
    and updated CreateDictionaryController.Create to use nameof(controller.ByKey2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant