Does OpenAPI 3.0 supports enum as reusable component for Path Parameters?

Originally posted by ssingh137 on February 14, 2023

Hi There,

Does OpenAPI 3.0 supports enum as reusable component for Path Parameters?

Here is an example"

parameters:

  • in: path
    name: status
    schema:
    type: string
    $ref: “#/components/schemas/Status”

Status:
type: string
enum:
- Approved
- Pending
- Closed
- New

is it valid syntax?

Originally posted by ponelat on February 15, 2023

Hi ssingh137 ,

Yes it’s possible to reuse schemas in Parameters.

See an example here: https://app.swaggerhub.com/apis/SwaggerPMTests/reuseable-enum/1.0.0#/default/get_foo__bar_

For more info around Path Parameters, see: https://swagger.io/docs/specification/describing-parameters/#path-parameters

Note: You cannot have sibling fields next to a $ref. In your example you have type: string next to a $ref: ... and that is invalid.