swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
16.98k stars 6.03k forks source link

[C#] Generating client with empty variable names #9241

Open SzabKel opened 5 years ago

SzabKel commented 5 years ago
Description

Using version 3, I tried to generate C# code for Magento 2.3's API. The generated code did not compile.

I used Windows 10 x64, Oracle JDK 1.8_201

Command line used for generation

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i https://devdocs.magento.com/swagger/schemas/latest-2.3.schema.json -l csharp -o C:\workspace\swagger-codegen\generated-v3-190606

Steps to reproduce
  1. Clone the repo
  2. mvn clean package -Dmaven.test.skip=true
  3. java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i https://devdocs.magento.com/swagger/schemas/latest-2.3.schema.json -l csharp -o C:\workspace\swagger-codegen\generated-v3-190606
  4. Because I also encountered this issue, I first fixed it.
  5. Restore nuget packages, build --> Errors
Ryan-Palmer commented 5 years ago

I can confirm I am seeing the same thing, missing variable names in the model constructors (as well as the broken sln file).

jweisman commented 5 years ago

I have the same issue. Note this doesn't work even on the Petstore example:

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i https://gist.githubusercontent.com/danielflower/5c5ae8a46a0a49aee508690c19b33ada/raw/b06ff4d9764b5800424f6a21a40158c35277ee65/petstore.json -l csharp --additional-properties targetFramework=v5.0 useDateTimeOffset=true netCoreProjectFile=true -o ~/Downloads/csharp2/
mjirous commented 5 years ago

The cause of this problem is that the template modelGeneric.mustache uses {{#lambda.camelcase_param}} helper that is not supported in handlebars.

From handlebars docs: The optional Mustache-style lambdas are not supported. Instead Handlebars provides its own lambda resolution that follows the behaviors of helpers.

The bug is actually in the other repo: https://github.com/swagger-api/swagger-codegen-generators

I created a bug in that repo: https://github.com/swagger-api/swagger-codegen-generators/issues/358