Open
Description
Description
The generated curl sample code doesn't escape single quote for JSON body.
Reproduction
This can be reproduced with the OpenAPI spec below:
{
"openapi": "3.0.0",
"paths": {
"/": {
"post": {
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"text": {
"type": "string"
}
}
},
"examples": {
"Message": {
"value": {
"text": "The user's message"
}
}
}
}
}
}
}
}
}
}
The corresponding curl syntax doesn't escape '
for -d
:
curl -X POST "http://localhost:3000/" \
-H "content-type: application/json" \
-d '{"text":"The user's message"}'
The correct syntax is:
curl -X POST "http://localhost:3000/" \
-H "content-type: application/json" \
-d '{"text":"The user'\''s message"}'
Suggestion
Change this line to:
curlData = ` -d '${JSON.stringify(JSON.parse(exampleTextAreaEl.value.replace(/'/g, "'\\''")))}' \\\n`;
Metadata
Metadata
Assignees
Labels
No labels