Skip to content

Bugfix: hide Self link in included resources for missing controller #1141

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

Merged
merged 3 commits into from
Mar 11, 2022

Conversation

bart-degreed
Copy link
Contributor

@bart-degreed bart-degreed commented Mar 2, 2022

Bugfix: hide Self link in included resources when there's no registered controller for it. Before, it would use the controller URL from the current request in the Self link, which is wrong.

Example response from GET /photoLocations, assuming PhotoAlbumsController does not exist:

{
  "data": {
    "type": "photoLocations"
    ...
  },
  "included": [
    {
      "type": "photoAlbums",
      },
      "relationships": {
        "photos": {
          "links": {
            "self": "http://localhost/photoLocations/e8467a26-a8d8-4ba4-934c-646c26dd6ebd/relationships/photos",
            "related": "http://localhost/photoLocations/e8467a26-a8d8-4ba4-934c-646c26dd6ebd/photos"
          }
        }
      }
      "links": {
        "self": "http://localhost/photoLocations/7e15ef84-0182-4fb4-805f-62b1e8f8a6e1" // <-- WRONG
      }
    }
  ]
}

After the fix:

{
  "data": {
    "type": "photoLocations"
    ...
  },
  "included": [
    {
      "type": "photoAlbums",
      },
      "relationships": {
        "photos": {
          "links": {
            "self": "http://localhost/photoLocations/e8467a26-a8d8-4ba4-934c-646c26dd6ebd/relationships/photos",
            "related": "http://localhost/photoLocations/e8467a26-a8d8-4ba4-934c-646c26dd6ebd/photos"
          }
        }
      }
    }
  ]
}

QUALITY CHECKLIST

…ed controller for it. Before, it would use the controller URL from the current request in the Self link, which is wrong.
@bart-degreed bart-degreed requested a review from maurei March 2, 2022 10:05
@codecov
Copy link

codecov bot commented Mar 2, 2022

Codecov Report

Merging #1141 (ab67c86) into master (bc5fbe0) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1141   +/-   ##
=======================================
  Coverage   89.46%   89.46%           
=======================================
  Files         242      242           
  Lines        7211     7213    +2     
=======================================
+ Hits         6451     6453    +2     
  Misses        760      760           
Impacted Files Coverage Δ
...piDotNetCore/Serialization/Response/LinkBuilder.cs 98.31% <100.00%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bc5fbe0...ab67c86. Read the comment docs.

@maurei maurei merged commit e623e84 into master Mar 11, 2022
@maurei maurei deleted the self-links-fix branch March 11, 2022 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants