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
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 }"
}
}
Most helpful comment
Use
"to escape a "<br>'{ ""id"" : 0,