-
Notifications
You must be signed in to change notification settings - Fork 6k
CSharp code generator - Class for array property is generated without any data member #729
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
Comments
Is it correct to say that the issue also occurs in the "csharp_restcsharp" PR #700 ? |
Yes, I am testing now on the #700 code (note the [DataContract] annotation in the generqted code) |
OK. I'll spend some time to look into the issue tomorrow. |
Are you trying to define a property, which is an array of model ? If that's the case, I think you need to set the type to "array". Using the Pet object in http://petstore.swagger.io/v2/swagger.json as an example, it has a property named tags, which is an array of Tag.
If my guess is not correct, please kindly share with us the Swagger spec for repeating the issue. |
I do use the "array" type but still the generated class does not inherit any base class. Here is my swagger spec:
|
@boazsapir - that's an array of strings, not an array of a model. |
@webron do I have to change it to an array of model or is it a bug that it does not work for array of strings? |
@boazsapir Array of strings should also work. For Pet object in the petstore example, the property "photoUrls" is an array of strings:
which works fine with the CSharp codegen. Do you have the full Swagger spec that you can share with us to look into the issue (assuming the spec can share publicly)? |
Sorry I cannot publicly share the full spec. I will try to isolate the reason why the behavior in my case is different than in the petstore example |
@boazsapir understood. Did you encounter the same issue using Ruby, PHP client codegen? |
I did not try those clients, only Java and CSharp. Had no problem with Java |
Please reopen if you're still having an issue with this. |
I have a property defined as an array:
* @swg\Definition(definition="Tokens", type="array", @swg\Items(type="string", maxLength=64, maxItems=32), description="a list of tokens")
* @swg\Property(property="tokens", ref="#/definitions/Tokens")
In the generated CSharp code, the corresponding class is created empty without any data members and it does not inherit from any other class (in the Java generated code, for instance, it extends ArrayList).
namespace io.swagger.Model {
[DataContract]
public class Tokens {
}
}
The text was updated successfully, but these errors were encountered: