Skip to content

fix: reuse referenced enum component types - #189

Merged
nikcio merged 1 commit into
Nikcio-labs:mainfrom
geirsagberg-udir:geir/fix-referenced-enum-duplication
Sep 5, 2026
Merged

fix: reuse referenced enum component types#189
nikcio merged 1 commit into
Nikcio-labs:mainfrom
geirsagberg-udir:geir/fix-referenced-enum-duplication

Conversation

@geirsagberg-udir

Copy link
Copy Markdown
Contributor

Summary

  • exclude $ref schemas from inline-enum discovery and property emission
  • reuse the declared component enum instead of generating a duplicate property-named enum
  • add a regression test for an enum reference whose component and property both map to MessageType

Why

Microsoft.OpenApi exposes the referenced enum values through OpenApiSchemaReference. The emitter therefore classified the reference as an inline enum, emitted both MessageType and MessageType2, and used MessageType2 in the containing record.

This changes generated property types from the property-derived enum name to the referenced component name. That can be source-breaking when consumers regenerate, but it removes an incorrect duplicate public type rather than preserving it behind a compatibility mode.

Verification

  • dotnet build --no-restore --configuration Release
  • dotnet test --no-build --configuration Release --verbosity normal (272 passed, 1 intentionally skipped)

@nikcio
nikcio enabled auto-merge (squash) September 5, 2026 14:28
@nikcio
nikcio merged commit b251aee into Nikcio-labs:main Sep 5, 2026
2 checks passed
@nikcio

nikcio commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@geirsagberg-udir Thanks for this fix

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