mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-02 15:08:20 +00:00
support deprecated flag in json schema (#6022)
This commit is contained in:
@@ -127,7 +127,7 @@ class JsonSchemaGenerator : public BaseGenerator {
|
|||||||
if (parser_.root_struct_def_ == nullptr) { return false; }
|
if (parser_.root_struct_def_ == nullptr) { return false; }
|
||||||
code_.Clear();
|
code_.Clear();
|
||||||
code_ += "{";
|
code_ += "{";
|
||||||
code_ += " \"$schema\": \"http://json-schema.org/draft-04/schema#\",";
|
code_ += " \"$schema\": \"https://json-schema.org/draft/2019-09/schema\",";
|
||||||
code_ += " \"definitions\": {";
|
code_ += " \"definitions\": {";
|
||||||
for (auto e = parser_.enums_.vec.cbegin(); e != parser_.enums_.vec.cend();
|
for (auto e = parser_.enums_.vec.cbegin(); e != parser_.enums_.vec.cend();
|
||||||
++e) {
|
++e) {
|
||||||
@@ -174,9 +174,16 @@ class JsonSchemaGenerator : public BaseGenerator {
|
|||||||
",\n \"maxItems\": " +
|
",\n \"maxItems\": " +
|
||||||
NumToString(property->value.type.fixed_length);
|
NumToString(property->value.type.fixed_length);
|
||||||
}
|
}
|
||||||
|
std::string deprecated_info = "";
|
||||||
|
if (property->deprecated) {
|
||||||
|
deprecated_info = ",\n \"deprecated\" : true,";
|
||||||
|
}
|
||||||
std::string typeLine =
|
std::string typeLine =
|
||||||
" \"" + property->name + "\" : {\n" + " " +
|
" \"" + property->name + "\" : {\n" + " ";
|
||||||
GenType(property->value.type) + arrayInfo + "\n }";
|
typeLine += GenType(property->value.type);
|
||||||
|
typeLine += arrayInfo;
|
||||||
|
typeLine += deprecated_info;
|
||||||
|
typeLine += "\n }";
|
||||||
if (property != properties.back()) { typeLine.append(","); }
|
if (property != properties.back()) { typeLine.append(","); }
|
||||||
code_ += typeLine;
|
code_ += typeLine;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
"$schema": "https://json-schema.org/draft/2019-09/schema",
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"MyGame_Example_TestEnum" : {
|
"MyGame_Example_TestEnum" : {
|
||||||
"type" : "string",
|
"type" : "string",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
"$schema": "https://json-schema.org/draft/2019-09/schema",
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"MyGame_OtherNameSpace_FromInclude" : {
|
"MyGame_OtherNameSpace_FromInclude" : {
|
||||||
"type" : "string",
|
"type" : "string",
|
||||||
@@ -162,7 +162,8 @@
|
|||||||
"type" : "string"
|
"type" : "string"
|
||||||
},
|
},
|
||||||
"friendly" : {
|
"friendly" : {
|
||||||
"type" : "boolean"
|
"type" : "boolean",
|
||||||
|
"deprecated" : true,
|
||||||
},
|
},
|
||||||
"inventory" : {
|
"inventory" : {
|
||||||
"type" : "array", "items" : { "type" : "number" }
|
"type" : "array", "items" : { "type" : "number" }
|
||||||
|
|||||||
Reference in New Issue
Block a user