swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

bug in c# code generation

Open jemprince opened this issue 10 years ago • 4 comments

this json: "SupplierPartPrice": { "type": "object", "properties": { "Description": { "type": "string" }, "PartNumber": { "type": "string" }, "Manufacturer": { "type": "string" }, "Status": { "type": "string" }, "Availability": { "format": "int32", "type": "integer", "readOnly": true }, "Quantity": { "format": "int32", "type": "integer" }, "Price": { "format": "double", "type": "number" } }

generates this constuctor:

public SupplierPartPrice(string Description = null, string PartNumber = null, string Manufacturer = null, string Status = nullint? Quantity = null, double? Price = null) { this.Description = Description; this.PartNumber = PartNumber; this.Manufacturer = Manufacturer; this.Status = Status; this.Quantity = Quantity; this.Price = Price;

    }

which causes this error: Microsoft (R) Visual C# Compiler version 4.6.1055.0 for C# 5 Copyright (C) Microsoft Corporation. All rights reserved.

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240

c:\Users\ukthjpri\AppData\Local\Temp\SupplierPartPrice\csharp-client\src\main\csharp\IO\Swagger\Model\SupplierPartPrice.cs(32,155): error CS1003: Syntax error, ':' expected

I suspect this is caused by the readOnly attribute on "Availability" which is missing from the constructor arguments and results in merging together of its neighbours....

jemprince avatar Apr 15 '16 08:04 jemprince

@jemprince yes, we'd this issue before and should be fixed in the latest master.

I wonder if you can give it a try with the latest master of swagger codegen and see if the issue persists.

wing328 avatar Apr 15 '16 08:04 wing328

Sorry - can't try that because we are using https://generator.swagger.io/api/gen/clients/csharp when will this be updated to latest master?

jemprince avatar Apr 15 '16 08:04 jemprince

There's ETA on when the latest master will be pushed to generator.swagger.io.

You can also host your own generator.swagger.io in your environment to run the latest master of swagger codegen.

Another workaround is to update the spec to remove "readOnly": true for the time being.

wing328 avatar Apr 15 '16 08:04 wing328

its ok we can wait - its only a test failing not an application issue

jemprince avatar Apr 15 '16 08:04 jemprince