Mass Refactoring to use IsString and other BASE_TYPE helpers (#6193)

* Updated SupportsAdvancedUnionFeatures to look out for string

* Mass refactoring to use BASE_TYPE helper functions.

Co-authored-by: Casper Neo <cneo@google.com>
This commit is contained in:
Casper
2020-10-20 08:00:31 -07:00
committed by GitHub
parent 8f6fa4b715
commit fe8e3c7e5d
15 changed files with 125 additions and 128 deletions

View File

@@ -87,7 +87,7 @@ std::string GenType(BaseType type) {
std::string GenBaseType(const Type &type) {
if (type.struct_def != nullptr) { return GenTypeRef(type.struct_def); }
if (type.enum_def != nullptr) { return GenTypeRef(type.enum_def); }
if (type.base_type == BASE_TYPE_ARRAY || type.base_type == BASE_TYPE_VECTOR) {
if (IsArray(type) || IsVector(type)) {
return "\"type\" : \"array\", \"items\" : {" + GenType(type.element) + "}";
}
return GenType(type.base_type);
@@ -206,7 +206,7 @@ class JsonSchemaGenerator : public BaseGenerator {
std::string arrayInfo = "";
if (IsArray(property->value.type)) {
arrayInfo = "," + NewLine() + Indent(8) + "\"minItems\": " +
NumToString(property->value.type.fixed_length) +
NumToString(property->value.type.fixed_length) +
"," + NewLine() + Indent(8) + "\"maxItems\": " +
NumToString(property->value.type.fixed_length);
}