Bug Report Checklist
Description
If you define the response type of an API to return something of "type":"string" and "format":"date" the generated exposes the value as Date but looking at the source the JSON-Content is used as is and hence the returned value is of type "string".
openapi-generator version
7.22-SNAPSHOT
OpenAPI declaration file content or url
{
"openapi": "3.0.1",
"info": {
"title": "RSD Test",
"version": "1.0.0"
},
"paths": {
"/api/date": {
"get": {
"description": "",
"parameters": [],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"type": "string",
"format": "date"
}
}
}
}
}
}
}
}
}
Generation Details
I generated using
docker run --rm \
-v $PWD:/local openapitools/openapi-generator-cli:latest generate \
-i /local/openapi.json \
-g typescript-fetch --additional-properties=importFileExtension=.js \
-o /local/src
Steps to reproduce
- Run the generator
- Inspect the generated source
The relevant code part generated from above is
async apiDateGetRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Date>> {
const requestOptions = await this.apiDateGetRequestOpts();
const response = await this.request(requestOptions, initOverrides);
if (this.isJsonMime(response.headers.get('content-type'))) {
return new runtime.JSONApiResponse<Date>(response);
} else {
return new runtime.TextApiResponse(response) as any;
}
}
Related issues/PRs
None I'm aware of
Suggest a fix
If the return value is a "Date" a transformer has to be passed so the line should look like
return new runtime.JSONApiResponse<Date>(response, isoDate => new Date(isoDate));
Bug Report Checklist
Description
If you define the response type of an API to return something of
"type":"string"and"format":"date"the generated exposes the value asDatebut looking at the source the JSON-Content is used as is and hence the returned value is of type "string".openapi-generator version
7.22-SNAPSHOT
OpenAPI declaration file content or url
{ "openapi": "3.0.1", "info": { "title": "RSD Test", "version": "1.0.0" }, "paths": { "/api/date": { "get": { "description": "", "parameters": [], "responses": { "200": { "description": "", "content": { "application/json": { "schema": { "type": "string", "format": "date" } } } } } } } } }Generation Details
I generated using
Steps to reproduce
The relevant code part generated from above is
Related issues/PRs
None I'm aware of
Suggest a fix
If the return value is a "Date" a transformer has to be passed so the line should look like