OpenAPITools / OpenAPITools/openapi-generator

[BUG] [multiplatform] unintentionally convert a datetime without a time zone to a datetime with UTC time zone.

Open
#10,603 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

The generator unintentionally convert a datetime without a time zone to a datetime with UTC time zone.

write in yaml

          dateTime2:
            type: string
            example: "2021-09-01 00:00:00"

but web ui shows:
"dateTime2": "2021-09-01T00:00:00.000Z"

At least, there are the problem with "python-flask" and "nodejs-express-server" .
but there aren't the problem with "html".

openapi-generator version

5.2.1.

OpenAPI declaration file content or url
openapi: 3.0.3
info:
  title: test
  version: 1.0.0
paths:
  /test/{dateTime}/:
    get:
      parameters:
        - name: "dateTime"
          in: "path"
          required: true
          schema:
            type: string
            example: "2021-09-01 00:00:00"
      responses:
        "200":
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  dateTime2:
                    type: string
                    example: "2021-09-01 00:00:00"
Generation Details

java -jar openapi-generator-cli-5.2.1.jar generate -i test.yaml -g python-flask -o test-openapi-flask

java -jar openapi-generator-cli-5.2.1.jar generate -i test.yaml -g nodejs-express-server -o test-openapi-nodejs-express-server

java -jar openapi-generator-cli-5.2.1.jar generate -i test.yaml -g html -o test-openapi-html

Steps to reproduce

java -jar openapi-generator-cli-5.2.1.jar generate -i test.yaml -g python-flask -o test-openapi-flask
cd test-openapi-flask
python -m openapi_server

access
http://localhost:8080/ui/#/default/test_date_time_get

Related issues/PRs

https://app.slack.com/client/TLQFRCNJZ/CLSB0U0R5

Suggest a fix

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided OpenAPI 3.0.3 YAML and the generation commands for python-flask and nodejs-express-server, then compare their output with the html generator. Trace how the example value is handled in the generated servers; done means a timezone-less datetime remains timezone-less in the affected outputs while the reproduction still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
express, flask, nodejs, openapi, python
Domain
api, backend, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
43/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.