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

Add Date types to openapi (and conversions) #890

Open
slodge opened this issue Nov 29, 2022 · 1 comment
Open

Add Date types to openapi (and conversions) #890

slodge opened this issue Nov 29, 2022 · 1 comment
Labels
theme: OpenAPI pertains to OpenAPI type: enhancement Adds a new, backwards-compatible feature

Comments

@slodge
Copy link

slodge commented Nov 29, 2022

Much of the work I do involves time series

For these, date, and to a lesser extent, datetime parameters are very common.

It would be very useful to be able to supply date hints in the api definitions - e.g.

#* Get the stock prices
#* @param ticker:string The ticker
#* @param from:date The first date to include (inclusive)
#* @param to:date The last date to include (inclusive)
#* @get /prices
function(ticker, from, to) {
   # code here...
}

From https://swagger.io/docs/specification/data-models/data-types/#string this can be done using:

String Formats

An optional format modifier serves as a hint at the contents and format of the string. OpenAPI defines the following built-in string formats:

  • date – full-date notation as defined by RFC 3339, section 5.6, for example, 2017-07-21
  • date-time – the date-time notation as defined by RFC 3339, section 5.6, for example, 2017-07-21T17:32:28Z
  • password – a hint to UIs to mask the input
  • byte – base64-encoded characters, for example, U3dhZ2dlciByb2Nrcw==
  • binary – binary data, used to describe files (see Files below)
@meztez meztez added type: enhancement Adds a new, backwards-compatible feature theme: OpenAPI pertains to OpenAPI labels Nov 24, 2023
@meztez meztez added this to the should address milestone Nov 24, 2023
@slodge
Copy link
Author

slodge commented Nov 25, 2023

There's easy workarounds to this - date parameters can be cast from incoming strings inside the API functions.

Leaving this open for maintainers to decide if/when to implement. Happy for them to close it if required.

@slodge slodge closed this as completed Nov 25, 2023
@slodge slodge reopened this Nov 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: OpenAPI pertains to OpenAPI type: enhancement Adds a new, backwards-compatible feature
Projects
None yet
Development

No branches or pull requests

2 participants