Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Date and DateTime enums do not work in many languages #2404

Closed
5 of 6 tasks
spacether opened this issue Mar 14, 2019 · 10 comments
Closed
5 of 6 tasks

[BUG] Date and DateTime enums do not work in many languages #2404

spacether opened this issue Mar 14, 2019 · 10 comments

Comments

@spacether
Copy link
Contributor

spacether commented Mar 14, 2019

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

Generators in python, java, csharp and others fail to generate valid datetime and date enum values. The expected behavior is that valid libraries are generated that cast date and datetime enums as the correct datatypes in the chosen languages.

Which version of openapi-generator are you using?
  • master branch latest commit
OpenAPI declaration file content or url
swagger: "2.0"
info:
  title: Sample API
  description: API description in Markdown.
  version: 1.0.0
host: api.example.com
basePath: /v1
schemes:
  - https
paths:
  /users:
    get:
      summary: Returns a list of users.
      description: Optional extended description in Markdown.
      produces:
        - application/json
      responses:
        200:
          description: OK
definitions:
  TypeHolderExample:
    type: object
    description: a model to test required properties with an example and length one enum
    required:
      - date_item
      - datetime_item
    properties:
      date_item:
        type: string
        format: date
        example: 2017-07-21
        enum: [2017-07-21]
      datetime_item:
        type: string
        format: date-time
        example: 2017-07-21T17:32:28Z
        enum:
          - 2017-07-21T17:32:28Z
Command line used for generation

generate -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g java -c bin/java-petstore-jersey2.json -o samples/client/petstore/java/jersey2 -DhideGenerationTimestamp=true

Steps to reproduce
  • Add the TypeHolderExample mode to the sample spec and run all generators
  • Or generate the csharp or java jersey2 or python client and attempt to use them
Related issues/PRs

#1312
#1299
#926

Suggest a fix

We should add the ability to these generators to handle date and datetime enums

@auto-labeler
Copy link

auto-labeler bot commented Mar 14, 2019

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@spacether
Copy link
Contributor Author

spacether commented Mar 14, 2019

I am working on this in #2297 for python only

@chikki1982
Copy link

This one is still open, do we have any update on resolution?

@spacether
Copy link
Contributor Author

spacether commented Mar 18, 2021

So this will having to be fixed on a generator by generator basis. Do you want to fix the generator that you need this in? I can point you to where to start.

@chikki1982
Copy link

@spacether yes please let me know.

@spacether
Copy link
Contributor Author

spacether commented Mar 19, 2021

@chikki1982 which generator do you need it working in?

@SCSreekanth
Copy link

Hi @spacether ,
Apologies for the delayed reply. Could you please let me know specifically, what are you requesting? I didn't quite get it when you said, which generator.
Thanks,
Sree

@spacether
Copy link
Contributor Author

We support generating code in many languages and frameworks.
Each context of generating code for x language is called a generator. Sometimes we have multiple generators for the same language for old or new versions or different frameworks.
We have docs on each of our generators here:
https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/README.md
So which generator are you interested in improving?

@SCSreekanth
Copy link

Ok. Thanks. I would be needing the fix for the Java-based generator. Thanks. HTH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants