summaryrefslogtreecommitdiff
path: root/src/idl_gen_json_schema.cpp
diff options
context:
space:
mode:
authorMarc Butler <mockbutler@gmail.com>2020-03-13 06:10:30 +1100
committerGitHub <noreply@github.com>2020-03-12 12:10:30 -0700
commit0e3fdd0eeac998974179fd48874a2d98dbf9af83 (patch)
tree6de77eae5f782a665a4c580c9a8e4539cdfdc6b6 /src/idl_gen_json_schema.cpp
parent45a2b07cbd83c14c233bafd0f7d850bc52f9aa24 (diff)
downloadflatbuffers-0e3fdd0eeac998974179fd48874a2d98dbf9af83.tar.gz
flatbuffers-0e3fdd0eeac998974179fd48874a2d98dbf9af83.tar.bz2
flatbuffers-0e3fdd0eeac998974179fd48874a2d98dbf9af83.zip
Escape characters in jsonschema descriptions (#5644)
* Escape JSON Schema comments * Add quotes to monster comment Thus exercising the JSON Schema comment escape support.
Diffstat (limited to 'src/idl_gen_json_schema.cpp')
-rw-r--r--src/idl_gen_json_schema.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/idl_gen_json_schema.cpp b/src/idl_gen_json_schema.cpp
index ecdb587b..a1d0704d 100644
--- a/src/idl_gen_json_schema.cpp
+++ b/src/idl_gen_json_schema.cpp
@@ -155,7 +155,12 @@ class JsonSchemaGenerator : public BaseGenerator {
comment.append(*comment_line);
}
if (comment.size() > 0) {
- code_ += " \"description\" : \"" + comment + "\",";
+ std::string description;
+ if (!EscapeString(comment.c_str(), comment.length(), &description, true,
+ true)) {
+ return false;
+ }
+ code_ += " \"description\" : " + description + ",";
}
code_ += " \"properties\" : {";