swagger-api / swagger-api/swagger-codegen

Alternative property name extension

Open
#10,088 0 comments 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

Description

If I have an object-schema with properties (culture and invariant culture, see example) and one of the name is * to represent the invariant culture. The C# code generator will strip this character away and make invalid C# code. The stripping off the * is correct because it is not a valid value for a property name on the generated class.

Do it exists any extensions/vendor-extensions tags that I can add to my definition to let the code generator create properties with an alternative name but have the [DataMember(Name="*")] attribute set?

Swagger-codegen version

Using swaggerhub so not sure about exact version number.

Swagger declaration file content or url

Example definition in my yaml file

components:
  schemas:
    Fields.Blocks:
      type: object
      properties:
        _name:
          type: object
          properties:
            en-US:
              $ref: '#/components/schemas/FieldMetadata.Text'
            sv-SE:
              $ref: '#/components/schemas/FieldMetadata.Text'
        _audienceTargetGroups:
          type: object
          properties:
            '*':
              $ref: '#/components/schemas/FieldOption.BlockArea._audienceTargetGroups'

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

Read the YAML example and trace the C# generator's property-name handling; check the generator's documented vendor-extension support and generated DataMember output. Done means identifying whether an extension can preserve Name="*" while emitting a valid C# property, or documenting that no such support exists.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, openapi
Domain
devtools
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.