Swagger-php: How to escape the " (double quotes) character on Parameter Description

Created on 30 Jan 2017  路  3Comments  路  Source: zircote/swagger-php

Hi all,
I have a question about writing description on swagger-php.
For example I have the following parameter description:

* ...
* @SWG\Parameter(
*          name="products",
*          in="formData",
*          type="string",
*          description="set of json from products eg:<br>'{ '0' : { 'id' : '1', 'sku' : 'SKU00614803', 'name' : 'Oncom Gondrong', 'image' : 'oncom.jpg', 'price' : '100000' }, '1' : { 'id' : '2', 'sku' : 'SKU00614804', 'name' : 'Tempe Bacem', 'image' : 'tempe.jpg', 'price' : '150000' }}'",
*          required=true
*      ),
* ...

I want to write the JSON sample to one of the parameter. Actually if I wrote the sample like above, the swagger can be generated successfully, but that is the wrong JSON format. JSON should be use " (double quotes) character instead of ' (single quote).
But if I replace all the ' to ", I cannot generate the swagger. I says an error:

[Syntax Error] Expected DoctrineCommonAnnotationsDocLexer::T_CLOSE_PARENTHESIS, got 'id' in...

Anybody know how to solve my problem,.?

thanks

Most helpful comment

Use " to escape a "

<br>'{ ""id"" : 0,

All 3 comments

Use " to escape a "

<br>'{ ""id"" : 0,

how do you get rid of the backslash it adds to the example?
example="{""code"":""3088"",""quantity"":""2""},{""code"":""3089"",""quantity"":""1""}",

ends up as

"items": "{"code":"3088","quantity":"2"},{"code":"3089","quantity":"1"}"

I am running into the same issue.

Due to this the swagger ui generates the request like:
{ "query": { "params": "{ \"ci_id\": 12 }" } }

327

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Dalabad picture Dalabad  路  4Comments

aqlx86 picture aqlx86  路  3Comments

ricardovanlaarhoven picture ricardovanlaarhoven  路  5Comments

huksley picture huksley  路  4Comments

DerManoMann picture DerManoMann  路  3Comments