knuckleswtf / scribe

Generate API documentation for humans from your Laravel codebase.✍
https://scribe.knuckles.wtf/laravel/
MIT License
1.58k stars 280 forks source link

How to write multiple examples in response body? #837

Open Hao1995 opened 2 months ago

Hao1995 commented 2 months ago

Scribe version

4.35.0

Your question

I want to add multiple examples to the response bodies. It is mentioned by swagger doc.

responses:
  '200':
    description: A user object.
    content:
      application/json:
        schema:
          $ref: '#/components/schemas/User'   # Reference to an object
        examples:
          Jessica:
            value:
              id: 10
              name: Jessica Smith
          Ron:
            value:
              id: 20
              name: Ron Stewart

Does it work on scribe?

Docs

shalvah commented 1 month ago

Hey, yes Scribe supports multiple response samples using the "scenario" field. Check out https://scribe.knuckles.wtf/laravel/documenting/responses But I'm not sure it's exactly handled correctly in OpenAPI, since OpenAPI doesn't let you add descriptions for examples.

Dinushasilva commented 1 month ago

@shalvah @Hao1995 This is introduced in https://github.com/knuckleswtf/scribe/pull/855

Hao1995 commented 1 month ago

@shalvah @Hao1995 This is introduced in https://github.com/knuckleswtf/scribe/pull/855

Thanks your PR!!