Skip to content

Fix ObsoleteAttribute not applied to classes with a base class#1902

Merged
lahma merged 1 commit intoRicoSuter:masterfrom
lahma:fix/1820-obsolete-with-base-class
Mar 7, 2026
Merged

Fix ObsoleteAttribute not applied to classes with a base class#1902
lahma merged 1 commit intoRicoSuter:masterfrom
lahma:fix/1820-obsolete-with-base-class

Conversation

@lahma
Copy link
Copy Markdown
Collaborator

@lahma lahma commented Mar 7, 2026

Summary

  • When a class uses allOf for inheritance, the deprecated/x-deprecated flag may be on an allOf sub-schema rather than the root schema
  • ClassTemplateModel.IsDeprecated only checked _schema.IsDeprecated, missing deprecation in allOf sub-schemas
  • Now checks both the root schema and all allOf sub-schemas for deprecated status and message
  • This matches the workaround the issue reporter had to implement manually

Test plan

  • 2 new tests in ObsoleteTests.cs:
    • Class with base class and x-deprecated: true + x-deprecatedMessage in allOf → [Obsolete("message")] rendered
    • Class with base class and x-deprecated: true (no message) in allOf → [Obsolete] rendered
  • All 4 existing obsolete tests still pass
  • All 214 C# codegen tests pass with no regressions

Fixes #1820

🤖 Generated with Claude Code

When a class uses allOf for inheritance, the deprecated/x-deprecated flag
may be on an allOf sub-schema rather than the root schema. The
ClassTemplateModel only checked the root schema's IsDeprecated property.

Now checks both the root schema and allOf sub-schemas for deprecated
status and message.

Fixes RicoSuter#1820

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lahma lahma merged commit 0ce6bf1 into RicoSuter:master Mar 7, 2026
2 checks passed
This was referenced Apr 8, 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.

Bug: ObsoleteAttribute is not applied to classes that have a base class.

1 participant