BostonKevin
6 years agoContributor
requestBody JSON Payload Not Generated Properly in Swagger Inspector
I used Swagger Editor to document the syntax for a requestBody JSON payload. The YAML code for this requestBody is as follows:
requestBody: description: The translation block consists of block_hash, target, and the translation source. required: true content: application/json: schema: type: object properties: block_hash: type: string description: The block hash. example: 1234567893 target: type: object properties: text: type: string description: The translation of the origin text to the target language. example: La blanquette de veau est excellente. translation_source: type: string description: The source of the translated text. example: wordfast
In the Swagger Inspector, the sysntax for the requestBody is documented properly, as shown below:
Unfortunately, however, when you click Execute, the Curl command that is generated is as follows:
Please note the backslashes inserted throughout the JSON payload, and the lack of opening and closing brackets around the JSON payload.
A curl command that works is as follows:
curl -X POST "http://localhost:6060/xapis/BlockTranslation/2B66-3D77-AC7F-EE58?user_key=59C0-75D5-4D39-46B8" -d '[{"block_hash":1234567893,"target":[{"text":"La blanquette de veau est excellente."}],"trans lation_source":"wordfast"}]'
Is there anything in the YAML code that is inaccurate or incorrect? Or is it a known problem in Swagger Inspector that requestBody examples are not generated properly in the Curl commands?
Thanks!