0

I have 3 end points start, stop, status that looked like this

paths:
  /users:
    # other endpoint
  /containers/{vendorID}/{pluginID}/{artifactID}/start:
      parameters:
        - in: path
          name: vendorID
          required: true
          type: string
        - in: path
          name: pluginID
          required: true
          type: string
        - in: path
          name: artifactId
          required: true
          type: string
      get:
        # get related stuff
  /containers/{vendorID}/{pluginID}/{artifactID}/stop:
    parameters:
        - in: path
          name: vendorID
          required: true
          type: string
        - in: path
          name: pluginID
          required: true
          type: string
        - in: path
          name: artifactId
          required: true
          type: string
    get:
      # get related stuff
  /containers/{vendorID}/{pluginID}/{artifactID}/status:
    parameters:
        - in: path
          name: vendorID
          required: true
          type: string
        - in: path
          name: pluginID
          required: true
          type: string
        - in: path
          name: artifactId
          required: true
          type: string
    get:
      # get related stuff

All the endpoints start, stop, status has the same parameters but i ended up duplicating it at 3 different places. I am using swagger 2.0 but openApi3.0 is also welcome. Is there a way that I can specify these path params at one place and use it at other places ?

Thank you.

BhanuKiran
  • 2,631
  • 3
  • 20
  • 36
  • 1
    You can define those parameters in the global `components.parameters` section and reference them using `$ref` as shown in the [linked Q&A](https://stackoverflow.com/a/54286746/113116). – Helen Sep 23 '22 at 13:08
  • All definitions can be found here. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md – BhanuKiran Sep 25 '22 at 16:59

0 Answers0