3

In swagger's documentation using OpenApi specification, you can wrap schema in parameter to content with application/json:

parameters:
  - in: query
    name: filter

    # Wrap 'schema' into 'content.<media-type>'
    content:
      application/json:  # <---- media type indicates how to serialize / deserialize the parameter content
        schema:
          type: object
          properties:
            type:
              type: string
            color:
              type: string 

to send objects like this filter={"type":"t-shirt","color":"blue"}. How to do it in swagger-php?

  • 1
    `@OA\Parameter` has the [`content`](https://github.com/zircote/swagger-php/blob/master/src/Annotations/Parameter.php#L144-L147) field of type `MediaType[]`, but it looks like `@OA\Parameter` [does not actually support](https://github.com/zircote/swagger-php/blob/master/src/Annotations/Parameter.php#L213-L216) nested `@OA\MediaType` or `@OA\JsonContent` elements. Consider asking in the swagger-php repository: https://github.com/zircote/swagger-php/issues – Helen Jan 20 '20 at 14:02

1 Answers1

4

The swagger-editor and swagger-ui have added support for http://swagger.io/docs/specification/describing-parameters

The swagger-php library has added support too, it will be part of the 3.0.4 release.

Bob Fanger
  • 28,949
  • 7
  • 62
  • 78
  • 1
    https://swagger.io/docs/specification/describing-parameters/ in "schema vs content" paragraph is described what i want. I've tried it with swagger-editor and it works. Anyway, thanks for answer! – Madiyar Orazaly Jan 20 '20 at 04:34