swagger-api / swagger-api/swagger-codegen

C# code gen does not compile

Open
#9,160 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

Getting this code:
a space is needed after null or body. Please note that the Java code gen is working without issues.

public Document ApiCall2(string packageId, byte[] file = null, Object payload = nullDocument body = null)

System.Threading.Tasks.Task<ApiResponse<Group>> ApiGroupsGroupIdInvitePostAsyncWithHttpInfo (User bodystring groupId);

also, got this wrong code which is all wrong


public Account(string  = default(string), DateTime?  = default(DateTime?), string  = default(string), string  = default(string), Dictionary  = default(Dictionary), List<CustomField>  = default(List<CustomField>), AccountProviders  = default(AccountProviders), string  = default(string), List<License>  = default(List<License>), Company  = default(Company), DateTime?  = default(DateTime?), string  = default(string), string  = default(string))
        {
            // to ensure "" is required (not null)
            if ( == null)
            {
                throw new InvalidDataException(" is a required property for Account and cannot be null");
            }
            else
            {
                this.Name = ;
            }
            // to ensure "" is required (not null)
            if ( == null)
            {
                throw new InvalidDataException(" is a required property for Account and cannot be null");
            }
            else
            {
                this.Created = ;
            }
            // to ensure "" is required (not null)
            if ( == null)
            {
                throw new InvalidDataException(" is a required property for Account and cannot be null");
            }
            else
            {
                this.Owner = ;
            }
            // to ensure "" is required (not null)
            if ( == null)
            {
                throw new InvalidDataException(" is a required property for Account and cannot be null");
            }
            else
            {
                this.Id = ;
            }
            // to ensure "" is required (not null)
            if ( == null)
            {
                throw new InvalidDataException(" is a required property for Account and cannot be null");
            }
            else
            {
                this.CustomFields = ;
            }
            // to ensure "" is required (not null)
            if ( == null)
            {
                throw new InvalidDataException(" is a required property for Account and cannot be null");
            }
            else
            {
                this.TimezoneId = ;
            }
            // to ensure "" is required (not null)
            if ( == null)
            {
                throw new InvalidDataException(" is a required property for Account and cannot be null");
            }
            else
            {
                this.Licenses = ;
            }
            // to ensure "" is required (not null)
            if ( == null)
            {
                throw new InvalidDataException(" is a required property for Account and cannot be null");
            }
            else
            {
                this.Company = ;
            }
            // to ensure "" is required (not null)
            if ( == null)
            {
                throw new InvalidDataException(" is a required property for Account and cannot be null");
            }
            else
            {
                this.Updated = ;
            }
            this.Data = ;
            this.Providers = ;
            this.LogoUrl = ;
            this.LogoAltTextKey = ;
        }
        

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

Use the reported C# snippets as the reproduction, focusing on the malformed method signatures and Account constructor output. Compare the generated C# with the working Java output and identify the relevant code-generation templates or entry points; done means the generated C# compiles and preserves parameter and property names.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, openapi
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.