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

Return date-time in OpenApi/autorest-compatible format #1891

Open
davidyuk opened this issue Aug 14, 2024 · 2 comments
Open

Return date-time in OpenApi/autorest-compatible format #1891

davidyuk opened this issue Aug 14, 2024 · 2 comments

Comments

@davidyuk
Copy link
Member

davidyuk commented Aug 14, 2024

Currently, dates have been returned in milliseconds since 1970, encoded as integers:

          "time": {
            "description": "The time",
            "type": "integer"
          },

The closest date format supported by autorest is:

          "time": {
            "description": "The time",
            "type": "integer",
            "format": "unixtime"
          },

But the value is expected to be a number of seconds. And it can't be a fraction as I see.

The format which supports milliseconds is RFC3339, e.g. "2024-08-14T12:21:37.468Z":

          "time": {
            "description": "The time",
            "type": "string",
            "format": "date-time"
          },

An advantage of this format is that it is human-readable.

So, to improve the developer experience, I propose returning all times in one of the above formats. The way it is currently implemented in the middleware is the same as in the node, but I'm going to propose the same thing to the node.

https://swagger.io/docs/specification/data-models/data-types/#string
http://azure.github.io/autorest/openapi/formats.html

@davidyuk
Copy link
Member Author

davidyuk commented Aug 16, 2024

Field names that are good to convert to dates:

  • time
  • micro_time
  • approximate_activation_time
  • approximate_expire_time
  • register_time
  • block_time
  • activation_time
  • creation_time
  • microtime
  • last_updated_time

Also, start_date and end_date in stats.

@vatanasov
Copy link
Contributor

I think it is best we keep it the same as the node. If a consensus is reached on the node issue, that leads to a change, we can then also make the change.

@davidyuk davidyuk changed the title Return date-time in swagger/autorest-compatible format Return date-time in OpenApi/autorest-compatible format Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants