Parameters reuse in OpenAPI 3

Viewed 1610

While defining an API in OpenAPI v3, if multiple API paths use the same list of query parameters, is there a way to define them once and reference them from each path?

Imagine a common scenario where I have 5 different APIs for searching, but they all share the same query parameters such as "limit, bookmark, page, sort" etc.

Response to possible duplicate

I am not asking about referencing 1 specific parameter at a time, but rather re-use a SET of parameters in several API paths. Therefore I don't think it is a duplicate of How to define global parameters in OpenAPI?)

1 Answers

If you want all the common parameters to be included with a single line in the YAML specification, that doesn't seem possible as far as the specification itself is concerned. Frameworks such as Springdoc (for Java) provides an OperationCustomizer interface that can be implemented to achieve such functionalities.

Related