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 int and list<???> are not reconized #4372

Closed
nanohex opened this Issue Dec 12, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@nanohex

nanohex commented Dec 12, 2016

Description

When using the csharp langauge we are receiving the following errors, when looking at the code list are not missing there parameters as well. So for example List we only get List in the code generation. We are getting int is a reserved word.

We are sing swagger from servicestack the latest version, hope this helps.

[main] INFO io.swagger.parser.Swagger20Parser - reading from http://win7.tag.de.com/api/resources
[main] INFO io.swagger.parser.Swagger20Parser - reading from http://win7.tag.de.com/api/resources
[main] INFO io.swagger.codegen.languages.CSharpClientCodegen - Generating code for .NET Framework v4.5
[main] WARN io.swagger.codegen.languages.AbstractCSharpCodegen - int (reserved word) cannot be used as model name. Renamed to ModelInt
[main] WARN io.swagger.codegen.languages.AbstractCSharpCodegen - int (reserved word) cannot be used as model name. Renamed to ModelInt
[main] WARN io.swagger.codegen.languages.AbstractCSharpCodegen - int (reserved word) cannot be used as model name. Renamed to ModelInt
[main] WARN io.swagger.codegen.languages.AbstractCSharpCodegen - int (reserved word) cannot be used as model name. Renamed to ModelInt
[main] WARN io.swagger.codegen.languages.AbstractCSharpCodegen - int (reserved word) cannot be used as model name. Renamed to ModelInt
[main] WARN io.swagger.codegen.languages.AbstractCSharpCodegen - int (reserved word) cannot be used as model name. Renamed to ModelInt
....
[main] WARN io.swagger.codegen.languages.AbstractCSharpCodegen - Object (reserved word) cannot be used as model name. Renamed to ModelObject
[main] WARN io.swagger.codegen.languages.AbstractCSharpCodegen - Object (reserved word) cannot be used as model name. Renamed to ModelObject
[main] WARN io.swagger.codegen.languages.AbstractCSharpCodegen - Object (reserved word) cannot be used as model name. Renamed to ModelObject
[main] WARN io.swagger.codegen.languages.AbstractCSharpCodegen - Object (reserved word) cannot be used as model name. Renamed to ModelObject
[main] WARN io.swagger.codegen.languages.AbstractCSharpCodegen - Object (reserved word) cannot be used as model name. Renamed to ModelObject
....
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /Users/jasonpeixoto/tmp/csharp_api_client/docs//ValidateLoginResponse.md
[main] WARN io.swagger.codegen.DefaultCodegen - generated unique operationId C2BGetDistrictInfoRequest_0
com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: io.swagger.models.properties.RefProperty["$ref"])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:210)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:177)
at com.fasterxml.jackson.databind.ser.std.StdSerializer.wrapAndThrow(StdSerializer.java:187)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:647)
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:152)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:128)
at com.fasterxml.jackson.databind.ObjectWriter._configAndWriteValue(ObjectWriter.java:800)
at com.fasterxml.jackson.databind.ObjectWriter.writeValueAsString(ObjectWriter.java:676)
at io.swagger.util.Json.pretty(Json.java:23)
at io.swagger.codegen.DefaultCodegen.fromProperty(DefaultCodegen.java:1440)
at io.swagger.codegen.DefaultCodegen.fromParameter(DefaultCodegen.java:2281)
at io.swagger.codegen.DefaultCodegen.fromOperation(DefaultCodegen.java:2045)
at io.swagger.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:752)
at io.swagger.codegen.DefaultGenerator.processPaths(DefaultGenerator.java:705)
at io.swagger.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:334)
at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:645)
at io.swagger.codegen.cmd.Generate.run(Generate.java:223)
at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:41)
Caused by: java.lang.NullPointerException
at io.swagger.models.properties.RefProperty.get$ref(RefProperty.java:52)
at sun.reflect.GeneratedMethodAccessor47.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:466)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:639)
... 14 more
[main] WARN io.swagger.codegen.DefaultCodegen - Error obtaining the datatype from RefProperty:io.swagger.models.properties.RefProperty@e8fe9c77. Datatype default to Object
[main] ERROR io.swagger.codegen.DefaultCodegen - null
java.lang.NullPointerException
at io.swagger.models.properties.RefProperty.get$ref(RefProperty.java:52)
at io.swagger.codegen.DefaultCodegen.getSwaggerType(DefaultCodegen.java:1113)
at io.swagger.codegen.languages.AbstractCSharpCodegen.getSwaggerType(AbstractCSharpCodegen.java:507)
at io.swagger.codegen.DefaultCodegen.fromProperty(DefaultCodegen.java:1444)
at io.swagger.codegen.DefaultCodegen.fromParameter(DefaultCodegen.java:2281)
at io.swagger.codegen.DefaultCodegen.fromOperation(DefaultCodegen.java:2045)
at io.swagger.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:752)
at io.swagger.codegen.DefaultGenerator.processPaths(DefaultGenerator.java:705)
at io.swagger.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:334)
at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:645)
at io.swagger.codegen.cmd.Generate.run(Generate.java:223)
at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:41)
[main] WARN io.swagger.codegen.DefaultCodegen - Error obtaining the datatype from RefProperty:io.swagger.models.properties.RefProperty@e8fe9c77. Datatype default to Object
.....

[main] WARN io.swagger.codegen.DefaultCodegen - generated unique operationId C2BGetTeacherInfoRequest_0
[main] WARN io.swagger.codegen.DefaultCodegen - generated unique operationId C2BPostContractRequest_0
[main] WARN io.swagger.codegen.DefaultCodegen - generated unique operationId CreateAEPayRecordRequest_0
[main] WARN io.swagger.codegen.DefaultCodegen - generated unique operationId CustomerRequest_0
[main] WARN io.swagger.codegen.DefaultCodegen - generated unique operationId CustomerOrdersRequest_0
[main] WARN io.swagger.codegen.DefaultCodegen - generated unique operationId GetCustomerHistoryRequest_0
[main] WARN io.swagger.codegen.DefaultCodegen - generated unique operationId GetCustomerTokensRequest_0
[main] WARN io.swagger.codegen.DefaultCodegen - generated unique operationId GetInstructorScheduleRequest_0
[main] WARN io.swagger.codegen.DefaultCodegen - generated unique operationId GetTeeSlotsRequest_0
[main] WARN io.swagger.codegen.DefaultCodegen - generated unique operationId Hello_0
[main] WARN io.swagger.codegen.DefaultCodegen - generated unique operationId OAuthTokenRequest_0
.....

Swagger-codegen version

Use ServiceStack as api server, and ServiceStack.Swagger as well.

https://servicestack.net/
http://docs.servicestack.net/swagger-api
http://www.nuget.org/packages/ServiceStack.Api.Swagger/

Swagger 1.2 supported.

the latest version from github.

Swagger declaration file content or url

http://win7.tag.de.com/api/resources

Command line used for generation

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate
-i http://win7.tag.de.com/api/resources
-l csharp
-o ~/tmp/csharp_api_client

Steps to reproduce

use the command line above.

Related issues
Suggest a Fix
@wing328

This comment has been minimized.

Show comment
Hide comment
@wing328

wing328 Dec 13, 2016

Contributor

[main] WARN io.swagger.codegen.languages.AbstractCSharpCodegen - int (reserved word) cannot be used as model name. Renamed to ModelInt

In your swagger spec (v1.2), you name the model as "int", which is a reserved word in C#. I believe you actually mean the property/parameter is an integer (type: integer) instead. Ref: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types

I would suggest you to contact ServiceStack on how to define that in the ServiceStack.

You may also want to explore the option to export the Swagger spec in the latest version 2.0 instead of 1.2 from ServiceStack.

Contributor

wing328 commented Dec 13, 2016

[main] WARN io.swagger.codegen.languages.AbstractCSharpCodegen - int (reserved word) cannot be used as model name. Renamed to ModelInt

In your swagger spec (v1.2), you name the model as "int", which is a reserved word in C#. I believe you actually mean the property/parameter is an integer (type: integer) instead. Ref: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types

I would suggest you to contact ServiceStack on how to define that in the ServiceStack.

You may also want to explore the option to export the Swagger spec in the latest version 2.0 instead of 1.2 from ServiceStack.

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