-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Hello, in my workplace a collegue changed the local jar we have from version 7.12.0 to version 7.17.0 and first everything seemed fine. Then it was noticed that the dates are not correct any more. In the generated *Apis.ts files on the requestParameters the .toISOString().substring() part were missing. I had a look through some old Issues, PR's and changelog but couldn't find a reason why this is now happening. I also tested the versions before and until 7.16 its fine.
Version 7.17.0
const queryParameters: any = {};
if (requestParameters['dateFrom'] != null) {
queryParameters['date_from'] = requestParameters['dateFrom'];
}
if (requestParameters['dateTo'] != null) {
queryParameters['date_to'] = requestParameters['dateTo'];
}
if (requestParameters['startPosition'] != null) {
queryParameters['start_position'] = requestParameters['startPosition'];
}
if (requestParameters['maxResults'] != null) {
queryParameters['max_results'] = requestParameters['maxResults'];
}
const headerParameters: runtime.HTTPHeaders = {};
if (requestParameters['accept'] != null) {
headerParameters['Accept'] = String(requestParameters['accept']);
}
let urlPath = `/list/data`;
Version 7.16.0
const queryParameters: any = {};
if (requestParameters['dateFrom'] != null) {
queryParameters['date_from'] = (requestParameters['dateFrom'] as any).toISOString();
}
if (requestParameters['dateTo'] != null) {
queryParameters['date_to'] = (requestParameters['dateTo'] as any).toISOString().substring(0,10);
}
if (requestParameters['startPosition'] != null) {
queryParameters['start_position'] = requestParameters['startPosition'];
}
if (requestParameters['maxResults'] != null) {
queryParameters['max_results'] = requestParameters['maxResults'];
}
const headerParameters: runtime.HTTPHeaders = {};
if (requestParameters['accept'] != null) {
headerParameters['Accept'] = String(requestParameters['accept']);
}
let urlPath = `/list/data`;
openapi-generator version
now: openapi-generator-cli-7.17.0.jar
before: openapi-generator-cli-7.12.0.jar
OpenAPI declaration file content or url
This is a very shorten example from our codebase
openapi: 3.0.0
info:
contact:
name: Test
url: test
description: Test API for demonstrating generator issue
title: Test API
version: 1.0.0
servers:
- description: Local server
url: http://localhost:8080/
paths:
/list/data:
description: List data endpoint.
get:
operationId: get-data-items
parameters:
- description: Accept header
in: header
name: Accept
required: true
schema:
type: string
- description: Start date
in: query
name: date_from
schema:
format: date-time
type: string
- description: End date
in: query
name: date_to
schema:
format: date
type: string
- description: Start position
in: query
name: start_position
required: true
schema:
format: int32
type: integer
- description: Max results
in: query
name: max_results
required: true
schema:
format: int32
type: integer
responses:
'200':
content:
application/json:
schema:
items:
$ref: '#/components/schemas/Item'
type: array
description: Array of items
tags:
- Items
summary: Get Items
components:
parameters:
Accept:
description: Accept header
in: header
name: Accept
required: true
schema:
type: string
ContentType:
description: Content type header
in: header
name: Content-Type
required: true
schema:
type: string
schemas:
Item:
example:
id: 1
name: 'Sample Item'
status: 'ACTIVE'
createdDate: '2000-01-23T04:56:07.000+00:00'
properties:
id:
format: int64
type: integer
name:
type: string
status:
type: string
createdDate:
format: date-time
type: string
required:
- id
- name
type: objectGeneration Details
Nothing much to say. We run it via package.json script, that looks like this
"gen-api": "npx @openapitools/openapi-generator-cli generate -i src/api/openapi/test_openapi.yaml -g typescript-fetch -o src/api/openapi/bundle --skip-validate-spec --additional-properties=stringEnums=true",
and we have a openapitools.json
{
"$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "openapi-generator-cli-7.17.0",
"storageDir": "./src/api/openapi"
}
}
Steps to reproduce
Run the command with version 7.17 and 7.12 and check the ItemsApi.ts