Skip to content

Add TypeSpec examples to flat-bag, facets and subtypes pattern docs (#1061)#588

Open
mary-wan wants to merge 5 commits into
microsoft:vNextfrom
mary-wan:marynjenga/graph-patterns
Open

Add TypeSpec examples to flat-bag, facets and subtypes pattern docs (#1061)#588
mary-wan wants to merge 5 commits into
microsoft:vNextfrom
mary-wan:marynjenga/graph-patterns

Conversation

@mary-wan

@mary-wan mary-wan commented Jun 23, 2026

Copy link
Copy Markdown

Summary

  • Adds a TypeSpec representation section to graph/patterns/flat-bag.md with a runnable @flatBag("type") + @variant(...) example

  • Adds a TypeSpec representation section to graph/patterns/subtypes.md with an @abstract + extends example using the directoryObject → user/group hierarchy

  • graph/patterns/facets.md — new Facets in TypeSpec section: a driveItem example (audio/file/folder/image/video as @facet nullable @complex properties), the linter rules, and the compiled CSDL.

  • graph/GuidelinesGraph.md — reconciles the TypeSpec representation column so all three rows are correct:

    Pattern TypeSpec
    Type hierarchy @abstract + extends
    Facets @facet
    Flat bag @flatBag + @variant

Companion to issue #1061 (@flatBag / @variant decorators shipped in @microsoft/typespec-msgraph Issue#1061). The API guidelines previously documented these patterns in CSDL/JSON only; this PR adds the TypeSpec authoring guidance developers need now that the pattern decorators ship.

Mary Njenga and others added 2 commits June 8, 2026 16:28
Documents how the facets API design pattern is authored in TypeSpec using
the @facet decorator from @microsoft/typespec-msgraph (issue
microsoftgraph/typespec-msgraph#1061, Phase 6):

- facets.md: new "Facets in TypeSpec" section with a driveItem example
  (audio/file/folder/image/video as @facet nullable @complex properties),
  the linter rules, and the compiled CSDL (a standard nullable complex
  property -- @facet is authoring/lint-only and emits no CSDL annotation).
- GuidelinesGraph.md: add a "TypeSpec representation" column to the
  modeling-variants comparison table and a pointer to the new section.
@mary-wan mary-wan requested a review from a team as a code owner June 23, 2026 07:55
- Type hierarchy: @abstract + extends
- Flat bag: @flatBag + @variant
- Facets: left blank pending separate work

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Merges marynjenga/graph-patterns (PR microsoft#588) into the facets branch and
resolves the GuidelinesGraph.md conflict where both branches rewrote the
modeling-variants comparison table.

Reconciled the shared 'TypeSpec representation' column so all three rows are
correct against @microsoft/typespec-msgraph v1.1.0 (verified by compiling
canaries):
- Type hierarchy -> `@abstract` + `extends`
- Facets         -> `@facet` on a nullable `@complex` property
- Flat bag       -> `@flatBag` + `@variant`

The prior facets-branch cell ('plain entity properties (no dedicated
decorator)') was incorrect -- @flatBag/@variant ship in v1.1.0 -- and Mary's
'Facets = —' cell was incomplete since @facet ships as well. The merged table
captures both decorator sets.
Add facets TypeSpec docs + reconcile pattern comparison table
@mary-wan mary-wan changed the title Add TypeSpec examples to flat-bag and subtypes pattern docs (#1061) Add TypeSpec examples to flat-bag, facets and subtypes pattern docs (#1061) Jun 24, 2026
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.

2 participants