-
Notifications
You must be signed in to change notification settings - Fork 6k
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
C#: Constructor is malformed if last property is readOnly: true #2795
Comments
@ggood I believe I've addressed this in the latest master. I wonder if you can pull the latest master and give it a try. |
We should probably include a unit test if this is fixed. I noticed code for required properties last night which I thought might result in this malformed constructor, but I didn't have time to verify my assumption. If this isn't yet fixed, I can grab it early next week. |
@jimschubert totally agree about adding a test case to cover issues moving forward. I added this before: https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml#L807 Let me know that looks good from your perspective (I welcome better and more tests to cover the same issue) |
@wing328 I think it'd be a great idea to add a sample type to |
@ggood may I know if you've a chance to try the latest master to see if the issue still persists? |
I just did a git pull, mvn clean install, and re-ran the generator on my sample. The generated constructor still looks wrong:
Full constructed class here: https://gist.github.com/ggood/93a39701368e98e5d59faed56f499857 |
@ggood Thanks for checking. I'll take another look today. |
@ggood it's my fault that my major PR to add better enum support for csharp, php, etc removed part of fix by #2670. I've added back the fix via #2818. I'll be more careful rebasing PRs moving forward. Sorry for the inconvenience caused by this. @jimschubert I misread "snake_case" as the last property but it's not. I've added another property "123Number" (readonly) as the last property and could repeat the issue before the fix so we've this issue covered moving forward. Sorry for the oversight. |
Swagger-codegen 2.1.6. With the OpenAPI spec in this Gist:
https://gist.github.com/ggood/099933cdf7aba3cab4867abd500d1b25
the generated c# constructor won't compile, due to a missing argument:
This happens when the last property in a definition is readOnly.
The text was updated successfully, but these errors were encountered: