Forum Discussion
Hi again,
I was just asked by my company if there were any updates on this - I was kind of hoping that you joejoyce were going to come with an official answer 😉
So - how should I solve the fact that I want all birthdays after a specific point in time as a query parameter?
HenrikHL there's no straighforward way to do this. You can try defining the birthday schema as an object with four properites "birthday:gt", "birthday:gte", "birthday:lt", "birthday:lte" and limit this object to at most 1 property. By default, objects in queries are serialized so that the property name become the actual parameter names, i.e.
{
"birthday:gt": "2021-06-30T20:50:27.577Z"
}
will be sent as
/something?birthday:gt=2021-06-30T20:50:27.577Z
The parameter definition would look like this:
parameters:
- in: query
name: birthday
description: ...
schema:
type: object
minProperties: 1
maxProperties: 1
additionalProperties: false
properties:
birthday:gt:
type: string
format: date-time
birthday:gte:
type: string
format: date-time
birthday:lt:
type: string
format: date-time
birthday:lte:
type: string
format: date-time
OpenAPI 3.1's new keywords patternProperties and propertyNames will make this a bit easier by supporting regexes like ^birthday:([gl]te?)$ to define the allowed property names in schemas.
Related Content
Recent Discussions
- 2 hours ago
- 17 days ago