Ben Randall Ben Randall - 1 year ago 203
YAML Question

Define shared path parameter that can be re-used by multiple paths with Swagger

I've got a series of paths that use the same path parameter:


I would like the {id} parameter to be defined once with a description and type so that I can reuse it, but this appears to be invalid:

catalogItemId: # <-- Not a valid parameter definition
name: id
in: path
description: The ID of the catalog item to update.
required: false
type: integer
format: int64

It doesn't seem like this should be invalid according to the schema linked by the editor (, but for some reason this is rejected by the online editor.

Is there anyway to share path parameter definitions?

Answer Source

Shortly after posting this I realized that the path parameter was listed as

required: false

Path parameters MUST be required for Swagger API definitions. Changing that to true fixed everything up. It's just a side effect of the way the schema validation occurs that causes a non descriptive error to get dumped out.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download