6

I'm using swagger-php annotations to generatee the documentation of my REST API, and I'd like to use pre-defined examples for describing responses.

The YAML code below works:

components:
  examples:
    exampleUser:
      value:
        id: 1
        name:   "Alan Cool"
        email:  "joe@cool.com.br"
        password:   "string"
        status: "string"
        ultimo_acesso:  155850122
        cpf:    "string"
        rg: "string"
        cargo:  "string"
        grupo_id:   7
        empresa_id: 88
        thumbnail_id:   99
        loja_id:    1299

But, when trying to generate the code above via annotations, I can't get it to work. 'm trying:

/**
 * @OA\Examples(
 *    summary = "exampleUser",
 *    description = "exampleUser",
 *    value = "exampleUser"
 * )
 */

It seems that there is no doumentation for PHP annotations so far. Any suggestions?

Alan PS
  • 197
  • 2
  • 12
  • 1
    1) What do you mean by "cannot get it to work"? Do these annotations not produce any YAML, or produce wrong YAML, or something else? 2) The example definition in the first snippet is not valid - it needs an extra `value` key under `exampleUser`, as shown [here](https://swagger.io/docs/specification/adding-examples/#reuse). – Helen Apr 02 '19 at 09:02
  • @Helen it's missing the value key, that's true, I'll edit the question. But nevertheless I dont know how to generate this particular yaml code using annotations. The second block, the PHP code it's my start, based on a quick analysys of the swagger-php classes, but couldnt advance more than that. I cant find any reference documentation either, just YAML reference... – Alan PS Apr 02 '19 at 16:56
  • 1
    You might have better luck asking this question in the Swagger-PHP repository: https://github.com/zircote/swagger-php/issues – Helen Apr 03 '19 at 07:52
  • Hi! Might be worth mentioning that just in case you managed to find a solution to your problem, it's encouraged by the StackOverflow community that you post it as an answer to your own question and mark it as accepted. :) – gyohza Oct 04 '20 at 00:41

0 Answers0