liveBook · Manning

Reusable parameter

As explained in The Design of Web APIs, Second Edition

A reusable parameter is an OpenAPI parameter defined in the components section for reference by multiple API elements.

A reusable parameter is an OpenAPI Parameter Object stored under components.parameters and referenced wherever the same request parameter must remain consistent. Centralization reduces duplication while allowing a reference-specific description override. section 17.3.2 section 17.8

Choose the reuse level that matches the design problem:

  • Use a path-level parameters list when every operation under one path shares the parameter. section 17.3
  • Use components.parameters when the parameter is shared across different paths or operations. section 17.3.2
  • Use one reusable object query parameter for a group such as pagination instead of repeating individual parameters. section 17.3.3

Sharing a product identifier

Define ProductId once under components.parameters with name: productId, in: path, and required: true. Reference it from /products/{productId} and /products/{productId}/suppliers with $ref: "#/components/parameters/ProductId". A second path may add a local description without redefining the parameter. section 17.3.2

Grouping pagination parameters

Define a reusable query parameter whose schema is an object with next and limit properties. Reference it once in a search operation; default serialization represents the request as .../?next=s00999&limit=10. Document this representation because tools may render it unclearly. section 17.3.3

How The Design of Web APIs, Second Edition covers it

How deep it goes
Defines components.parameters, JSON Pointer references, description overrides, and grouped query serialization, but defers detailed serialization tuning.
Examples
Uses ProductId path references and a Pagination object containing next and limit query properties.
What it assumes
Builds on path-level parameters, reusable schemas, components, and $ref JSON Pointers.
What you can do after
Apply it via OpenAPI by defining shared parameters once and referencing them across paths, operations, or grouped queries.
How it connects
Connects OpenAPI components, path parameters, query parameters, JSON Pointer, parameter serialization, and pagination.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Design of Web APIs, Second Edition. The section links point to the parts of the book it draws on.