Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSharp client generation fails but PHP and Java works for the the json schema #6456

Closed
nimisha84 opened this issue Sep 8, 2017 · 5 comments

Comments

@nimisha84
Copy link

Description

I am using the attached json file for run the swagger codegen for getting the SDK in CSharp.
However I get this error everytime-
C:\Users\DevAdmin\Documents>java -jar swagger-codegen-cli-2.2.1.jar generate -i
V4schema.json -l csharp
[main] INFO io.swagger.parser.Swagger20Parser - reading from V4schema.json
[main] INFO io.swagger.codegen.languages.CSharpClientCodegen - Generating code f
or .NET Framework v4.5
Exception in thread "main" java.lang.RuntimeException: Could not process model '
access/CompanyAccess'.Please make sure that your schema is correct!
at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:29
7)
at io.swagger.codegen.cmd.Generate.run(Generate.java:223)
at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:36)
Caused by: java.lang.NullPointerException
at io.swagger.codegen.languages.AbstractCSharpCodegen.getSwaggerType(Abs
tractCSharpCodegen.java:509)
at io.swagger.codegen.DefaultCodegen.getTypeDeclaration(DefaultCodegen.j
ava:1119)
at io.swagger.codegen.languages.AbstractCSharpCodegen.getTypeDeclaration
(AbstractCSharpCodegen.java:532)
at io.swagger.codegen.languages.AbstractCSharpCodegen.getTypeDeclaration
(AbstractCSharpCodegen.java:525)
at io.swagger.codegen.DefaultCodegen.fromProperty(DefaultCodegen.java:15
72)
at io.swagger.codegen.DefaultCodegen.addVars(DefaultCodegen.java:2738)
at io.swagger.codegen.DefaultCodegen.addVars(DefaultCodegen.java:2709)
at io.swagger.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:1270)

    at io.swagger.codegen.languages.CSharpClientCodegen.fromModel(CSharpClie

ntCodegen.java:313)
at io.swagger.codegen.DefaultGenerator.processModels(DefaultGenerator.ja
va:875)
at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:29
0)
... 2 more

If the schema was not correct it should have failed for PHP and Java as well. Can you help me figure out the issue?

Swagger-codegen version

Latest version- 2.2.1

Swagger declaration file content or url

Added in the gist here-https://gist.github.com/nimisha84/6f7af0e607eb6aa2a764a095d6424ec2

Command line used for generation

java -jar swagger-codegen-cli-2.2.1.jar generate -i V4schema.json -l csharp

Steps to reproduce

Run the cmd above in either mac or windows. I tried both.

@wing328
Copy link
Contributor

wing328 commented Sep 8, 2017

The latest version if 2.2.3. Please give it a try: https://github.com/swagger-api/swagger-codegen#compatibility

or you can use the latest master (snapshot version), which has a few API clients refactored (e.g. C#, PHP, etc)

@nimisha84
Copy link
Author

nimisha84 commented Sep 9, 2017

Unfortunately I got the same error with latest master snapshot version-

C:\Users\DevAdmin\Documents>java -jar swagger-codegen-cli-2.3.0-20170906.155839-
135.jar generate -i V4schema.json -l csharp
[main] INFO io.swagger.parser.Swagger20Parser - reading from V4schema.json
[main] INFO io.swagger.codegen.languages.CSharpClientCodegen - Generating code f
or .NET Framework v4.5
Exception in thread "main" java.lang.RuntimeException: Could not process model '
access/CompanyAccess'.Please make sure that your schema is correct!
at io.swagger.codegen.DefaultGenerator.generateModels(DefaultGenerator.j
ava:358)
at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:72
7)
at io.swagger.codegen.cmd.Generate.run(Generate.java:285)
at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:35)
Caused by: java.lang.NullPointerException
at io.swagger.codegen.languages.AbstractCSharpCodegen.getSwaggerType(Abs
tractCSharpCodegen.java:556)
at io.swagger.codegen.DefaultCodegen.getTypeDeclaration(DefaultCodegen.j
ava:1221)
at io.swagger.codegen.languages.AbstractCSharpCodegen.getTypeDeclaration
(AbstractCSharpCodegen.java:579)
at io.swagger.codegen.languages.AbstractCSharpCodegen.getTypeDeclaration
(AbstractCSharpCodegen.java:572)
at io.swagger.codegen.DefaultCodegen.fromProperty(DefaultCodegen.java:17
94)
at io.swagger.codegen.DefaultCodegen.addVars(DefaultCodegen.java:3116)
at io.swagger.codegen.DefaultCodegen.addVars(DefaultCodegen.java:3087)
at io.swagger.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:1442)

    at io.swagger.codegen.languages.CSharpClientCodegen.fromModel(CSharpClie

ntCodegen.java:446)
at io.swagger.codegen.DefaultGenerator.processModels(DefaultGenerator.ja
va:995)
at io.swagger.codegen.DefaultGenerator.generateModels(DefaultGenerator.j
ava:353)
... 3 more

@wing328
Copy link
Contributor

wing328 commented Sep 9, 2017

@nimisha84 I've fixed the NPE issue via #6462. Please pull the latest master to give it a try.

@nimisha84
Copy link
Author

Thanks it worked!

@wing328
Copy link
Contributor

wing328 commented Sep 11, 2017

FYI. I also reviewed other generators and found only ObjC client generator had similar issue, which has been fixed by #6465

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants