Skip to content

CSharp code generator - property names changed to fit language convention #727

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

Closed
boazsapir opened this issue May 7, 2015 · 12 comments
Closed

Comments

@boazsapir
Copy link

I have a property name in my schema which is lower-case, e.g.:

*@swg\Definition(definition="TimeIntput", type="object",
* required={ "time" },
* @swg\Property(property="time", type="integer", description="timestamp"),
* )

This property should be included as part of a request body:

*   @SWG\Parameter(name="Input", in="body", @SWG\Schema(ref="#/definitions/TimeInput")),

The CSharp code generator creates a class where the property name is capitalized according to the language conventions:
namespace io.swagger.Model {
public class TimeInput {

/* timestamp */

public int? Time { get; set; }

public override string ToString()  {
  var sb = new StringBuilder();
  sb.Append("class TimeInput {\n");

  sb.Append("  Time: ").Append(Time).Append("\n");

  sb.Append("}\n");
  return sb.ToString();
}

}

When sending the request by APIInvoker, the CSharp object which is an instance of the above class is serialized so the parameter in the request body has the capitalized name.
This means that the server does not get the parameter with the expected name as defined in the schema.

@wing328
Copy link
Contributor

wing328 commented May 7, 2015

The issue should be addressed by #700

I wonder if you can do a test to help confirm.

@boazsapir
Copy link
Author

I want to do the test but I am not able to merge the change request, it says:
Only those with write access to this repository can merge pull requests.

@wing328
Copy link
Contributor

wing328 commented May 7, 2015

please pull the fix from https://github.com/wing328/swagger-codegen/tree/csharp_restcsharp instead as the PR #700 has not been merged into develop_2.0 branch.

@boazsapir
Copy link
Author

Thank you, the problem is solved in the csharp_rescsharp codeline.
When do you expect that it will be merged into the branch?

@wing328
Copy link
Contributor

wing328 commented May 7, 2015

No problem. Thanks for your time in testing the change.

I believe @fehguy is quite busy these days. How urgent do you need the change ? (the change will be merged into develop_2.0 branch but not master)

@boazsapir
Copy link
Author

Within one week would be great.

@webron
Copy link
Contributor

webron commented May 7, 2015

Can't guarantee that. The earliest we can make it is probably next weekend, but again, no guarantee.

@boazsapir
Copy link
Author

ok, thank you anyway.
I am going to open some more issues as I am building a sample C# program to test our API and I encountered some problems.

@webron
Copy link
Contributor

webron commented May 7, 2015

Keep in mind #700 may be merged sooner and you could use the develop_2.0 branch easily.

@wing328
Copy link
Contributor

wing328 commented May 21, 2015

@boazsapir FYI. csharp_restsharp has been merged into develop_2.0. Please kindly close this issue if the property names for CSharp are all good.

@boazsapir
Copy link
Author

@wing328 I cannot test now because of the build error in develop_2.0. Will try later today

@fehguy
Copy link
Contributor

fehguy commented Jun 5, 2015

merged.

@fehguy fehguy closed this as completed Jun 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants