OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
[ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
We are using openapi-generator-cli to generate typescript-fetch code based on an openapi 3.x spec generated by Swashbuckle. When the specification contains a path with a request body content type of multipart/form-data the resulting generated code will look like
if (requestParameters.someDate !== undefined) {
formParams.append('someDate', requestParameters.someDate as any);
}
regardless of any format values provided in the specification. When the content type is application/json format values are honored. For example a property with a date-time format will call value.someDate.toISOString() when constructing the request as part of the <ModelName>ToJSON function
create a openapi.json file with the contents above
execute the open api generator command above to generate typescript code
observe the generated code constructs form params with code like formParams.append('someDate', requestParameters.someDate as any); for the someDate property even though someDate has a format attribute.
Related issues/PRs
Suggest a fix
The when appending form data properties the generated code should inspect the format attribute if provided and provide any necessary transforms
conceptually
switch(format) {
case 'date-time':
formParams.append({propertyName} requestParameters.{propertyName}.toISOString());
break;
case 'other-format':
...
default:
formParams.append({propertyName} requestParameters.{propertyName} as any);
}
Bug Report Checklist
Description
We are using openapi-generator-cli to generate typescript-fetch code based on an openapi 3.x spec generated by Swashbuckle. When the specification contains a path with a request body content type of
multipart/form-data
the resulting generated code will look likeregardless of any
format
values provided in the specification. When the content type isapplication/json
format values are honored. For example a property with adate-time
format will callvalue.someDate.toISOString()
when constructing the request as part of the<ModelName>ToJSON
functionopenapi-generator version
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
formParams.append('someDate', requestParameters.someDate as any);
for the someDate property even though someDate has a format attribute.Related issues/PRs
Suggest a fix
The when appending form data properties the generated code should inspect the format attribute if provided and provide any necessary transforms
conceptually