swagger-api / swagger-api/swagger-codegen

[CSharp] custom property attribute

Open
#9,508 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Please help me with a question about source code generation.

Description

I have custom attribute implemented in my source code, like LostAttribute. I'd like to add this custom attribute on the object property using the swagger generator. Is it possible?
May be using the specificationExtensions. Is there a way to achieve this for codegen ?

For example, using something like x-attribute (whatever) to ask codegen to mark ErrorDetails.Message property with Lost attribute

Swagger declaration file content or url

I'd like to get from the definition like below

  ErrorDetails:
    type: object
      Message:
        type: string
        x-attribute: Lost

result to be like

public class ErrorDetails
{
    [Lost]
    public string Message { get; set; }
}

Is there any possibility to get it? Like with codegen addon whatever?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no source file, test, or generator entry point. Start by tracing the C# generator's property-template path and how specification extensions are exposed, then determine whether a property-level custom attribute can be represented; done would be a tested, documented mapping from x-attribute to [Lost], or a clear explanation that it is unsupported.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.