OpenAPI: overriding a reference, referencing a single field

Viewed 559

I'm using two files :

common.yaml contains :

components:

  schemas:
    GenericError:
      type: object
      properties:
        code:
          description: The error code.
          type: integer
        message:
          description: The error description.
          type: string
        details:
          description: Optional details.
          type: object

  examples:
    Bamboozled:
      value:
        code: 10
        message: Bamboozled
        details: You've been bamboozled

services.yaml` contains :

paths:
  /logistic:
    post:

      description: Logistic

      responses:
        403:
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '../common.yaml#/components/schemas/GenericError'
              examples:
                Bamboozled:
                  value:
                    $ref: '../common.yaml#/components/examples/Bamboozled/value'

In services.yaml, I would like to override the details field. I tried the following :

              examples:
                Bamboozled:
                  value:
                    $ref: '../common.yaml#/components/examples/Bamboozled/value'
                    details: my custom details

but this doesn't work, it will render :

{
  "$ref":

  "#/paths/~1logistic/post/responses/403/content/application~1json/examples/Bamboozled/value",
"details": "my custom details"
}

Is there a way I can override it correctly ?

Alternatively, can I reference only specific fields ? So I would have services.yaml something such as :

              examples:
                Bamboozled:
                  value:
                    $ref: '../common.yaml#/components/examples/Bamboozled/value/code'
                    $ref: '../common.yaml#/components/examples/Bamboozled/value/message'
                    details: my custom details

(this doesn't work)

0 Answers
Related