IBlogPost porte IsPublished : le endpoint liste ne le lâche plus sur le wire

Le blog API (Yavsc.Blogs/Program.cs) sérialise en System.Text.Json
(.AddControllers() par défaut), et BlogApiController.GetBlogspot retourne
IEnumerable<IBlogPost>. STJ n'émet que les membres du type déclaré
(l'interface), donc IsPublished — qui n'était que sur les classes
concrètes BlogPost / BlogPostDto — était dropped du payload liste.
PostIt lisait alors IsPublished=false pour tout billet, y compris
publiés (cas prod /BlogSpot/Details/13).

Fix : déclarer IsPublished sur IBlogPost. BlogPost et BlogPostDto
l'implémentent déjà. Tests de wire-shape
(IBlogPostWireShapeTests) ajoutés pour verrouiller le contrat au
niveau du boundary.

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
Paul Schneider 2026-09-25 15:11:25 +01:00
commit 384f6bc300
Signed by: notazof
GPG key ID: AD4B9B545FBD7D12
2 changed files with 105 additions and 0 deletions

View file

@ -15,5 +15,23 @@ namespace Yavsc.Blogspot
// BlogPost entity implements this getter by mapping its
// ApplicationUser navigation to a BlogPostAuthorDto.
BlogPostAuthorDto? Author { get; }
/// <summary>
/// Whether this post is published. The server derives this
/// from the existence of a row in <c>BlogSpotPublication</c>
/// and serves it on the wire so clients (PostIt) can render
/// the current publication state without a follow-up request.
///
/// <para>This MUST be declared on the interface — not just on
/// the concrete <c>BlogPost</c> entity / <c>BlogPostDto</c> —
/// because the blog API's list endpoint returns
/// <c>IEnumerable&lt;IBlogPost&gt;</c>, and the blog API host
/// serialises with System.Text.Json, which emits only the
/// members of the declared (interface) type. When
/// <c>IsPublished</c> lived only on the concrete classes, STJ
/// dropped it from the list payload and PostIt read
/// <c>false</c> for every post, including published ones.</para>
/// </summary>
bool IsPublished { get; set; }
}
}