Description
C-Sharp generator doesn't support complex serialization in form data. For example, the Slack example here under Complex Serialization in Form Data (after removing application/json block under content) will send form data like "payload=class Message...etc" instead of "payload={"text":"Swagger is awesome"}", since it uses the ToString on the object instead of ToJson.
openapi-generator version
Tested on 4.3 and 5.0
OpenAPI declaration file content or url
openapi: 3.0.0
info:
version: 1.0.0
title: Slack Incoming Webhook
externalDocs:
url: https://api.slack.com/incoming-webhooks
paths:
/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX:
post:
summary: Post a message to Slack
requestBody:
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
payload: # <--- form field that contains the JSON message
$ref: '#/components/schemas/Message'
encoding:
payload:
contentType: application/json
responses:
'200':
description: OK
components:
schemas:
Message:
title: A Slack message
type: object
properties:
text:
type: string
description: Message text
required:
- text
Command line used for generation
./mvn clean install
Steps to reproduce
- Generator the CSharp client
- Use the API
- Notice that the form value for "payload" will not be valid json
Related issues/PRs
Similar issue in Java - #724
Suggest a fix/enhancement
- Add jsonEncoding field to CodegenParameter
- In DefaultCodegen, check for encoding override in fromRequestBodyToFormParameters
- Modify the csharp api.mustache to use ToJson instead of ParameterToString if jsonEncoding is true
Description
C-Sharp generator doesn't support complex serialization in form data. For example, the Slack example here under Complex Serialization in Form Data (after removing application/json block under content) will send form data like "payload=class Message...etc" instead of "payload={"text":"Swagger is awesome"}", since it uses the ToString on the object instead of ToJson.
openapi-generator version
Tested on 4.3 and 5.0
OpenAPI declaration file content or url
Command line used for generation
./mvn clean installSteps to reproduce
Related issues/PRs
Similar issue in Java - #724
Suggest a fix/enhancement