Issue #3262 [ASPNET5] Server Bug - doesn't properly serialize JSON pr…#3263
Issue #3262 [ASPNET5] Server Bug - doesn't properly serialize JSON pr…#3263daviddodsworth wants to merge 1 commit intoswagger-api:masterfrom
Conversation
…ize JSON properties in camelCase
Adding suggested fix of [JsonProperty (PropertyName = "{{baseName}}")]
| /// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}} | ||
| /// </summary>{{#description}} | ||
| /// <value>{{{description}}}</value>{{/description}} | ||
| [JsonProperty(PropertyName = "{{baseName}}")] |
There was a problem hiding this comment.
For the indentation, can we use 4-space instead of tab?
|
@daviddodsworth thanks for the PR. I've left you a comment about the indentation style. Please take a look. |
|
cc @jimschubert |
|
I'm not sure this is the proper solution. Many APIs prefer snake case to differentiate between server side data and client data. This forces all APIs to use camel case. I feel like this should actually be a NewtonSoft JSON concern, and a generator option. But I'd have to look into it. |
|
Oh, I see from the linked issue your comment relates to matching the case of the swagger definition. This may be a partial solution to the exposed API. However, the aspnet5 generator also includes generated Swagger API documentation. This should match the swagger document you provided, but if I remember correctly Ahoy (the .NET Core version of Swashbuckle) works with |
|
@jimschubert just want to share that for PHP, we plan to reuse the same set of model-related mustache templates for PHP API clients and server stubs (Slim, Silex, Lumen) so as to make the code for PHP model more consistent across PHP API client and server stub and more easily to maintain. Not sure if we can do the same for C# API client and server stub. |
|
@wing328 If we stick with |
|
@jimschubert I would vote for the [DataMember] solution, and I would agree that it's more portable, I just didn't have cycles to fully vet it. With that said, we're doing a contract first design with Swagger and not code first (with Swashbuckle). That's how we noticed the issue in the first place, since we need the Swagger definition of the JSON objects to be properly generated for server and several client APIs from a "on the wire" perspective. I'll take a look at flipping over to the [DataMember] solution later this week. |
|
I figured that's what it was. I had a similar issue when doing contract first in node.js before I knew of swagger-codegen. I defined custom jsdoc comments as the contract and parsed those out on build to generate the swagger definition used by swagger UI. I was going to take a look this weekend at the DataMember implementation, which should be pretty simple. But, I've had problems with my Windows VM (left the employer to whom it was licensed). I had to buy Windows 10, then set it up and realized I installed 32 bit... so I had to start over. :/ |
|
@daviddodsworth did you make progress on the |
|
@daviddodsworth @wing328 since there wasn't a response for a little over a month, I went ahead and opened a PR with the |
…operties in camelCase
Adding suggested fix of [JsonProperty (PropertyName = "{{baseName}}")]