Forum Discussion
joejoyce does SwaggerHub have an official way to do this?
How should the above queryParameters be defined in order to be Swagger Compliant?
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?
- HKosova4 years agoSmartBear Alumni (Retired)
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
- 16 days ago
- 2 months ago