Skip to content

Commit

Permalink
Add fixture for nested objects
Browse files Browse the repository at this point in the history
Summary: Adding this fixture in a standalone diff so it is easier to see the change on the next one.

Reviewed By: JoshuaGross

Differential Revision: D16852439

fbshipit-source-id: 3f167509b78ebb95f31e44fbf40e9551d4a5500b
  • Loading branch information
TheSavior authored and facebook-github-bot committed Aug 19, 2019
1 parent 685a25c commit e9ef560
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,32 @@ const OBJECT_PROPS: SchemaType = {
],
},
},
{
name: 'nestedPropA',
optional: false,
typeAnnotation: {
type: 'ObjectTypeAnnotation',
properties: [
{
name: 'nestedPropB',
optional: false,
typeAnnotation: {
type: 'ObjectTypeAnnotation',
properties: [
{
name: 'nestedPropC',
optional: true,
typeAnnotation: {
type: 'StringTypeAnnotation',
default: '',
},
},
],
},
},
],
},
},
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,40 @@ static inline std::string toString(const ObjectPropsObjectPropObjectPrimitiveReq
return \\"[Object ObjectPropsObjectPropObjectPrimitiveRequiredPropStruct]\\";
}
struct ObjectPropsObjectPropNestedObjectPropNestedObjectInObjectPropStruct {
std::string stringProp;
};
static inline void fromRawValue(const RawValue &value, ObjectPropsObjectPropNestedObjectPropNestedObjectInObjectPropStruct &result) {
auto map = (better::map<std::string, RawValue>)value;
auto stringProp = map.find(\\"stringProp\\");
if (stringProp != map.end()) {
fromRawValue(stringProp->second, result.stringProp);
}
}
static inline std::string toString(const ObjectPropsObjectPropNestedObjectPropNestedObjectInObjectPropStruct &value) {
return \\"[Object ObjectPropsObjectPropNestedObjectPropNestedObjectInObjectPropStruct]\\";
}
struct ObjectPropsObjectPropNestedObjectPropStruct {
ObjectPropsNestedObjectInObjectPropStruct nestedObjectInObjectProp;
};
static inline void fromRawValue(const RawValue &value, ObjectPropsObjectPropNestedObjectPropStruct &result) {
auto map = (better::map<std::string, RawValue>)value;
auto nestedObjectInObjectProp = map.find(\\"nestedObjectInObjectProp\\");
if (nestedObjectInObjectProp != map.end()) {
fromRawValue(nestedObjectInObjectProp->second, result.nestedObjectInObjectProp);
}
}
static inline std::string toString(const ObjectPropsObjectPropNestedObjectPropStruct &value) {
return \\"[Object ObjectPropsObjectPropNestedObjectPropStruct]\\";
}
struct ObjectPropsObjectPropStruct {
std::string stringProp;
bool booleanProp;
Expand All @@ -803,6 +837,7 @@ struct ObjectPropsObjectPropStruct {
ObjectPropsStringEnumProp stringEnumProp;
ObjectPropsObjectArrayPropStruct objectArrayProp;
ObjectPropsObjectPrimitiveRequiredPropStruct objectPrimitiveRequiredProp;
ObjectPropsNestedObjectPropStruct nestedObjectProp;
};
static inline void fromRawValue(const RawValue &value, ObjectPropsObjectPropStruct &result) {
Expand Down Expand Up @@ -836,6 +871,10 @@ static inline void fromRawValue(const RawValue &value, ObjectPropsObjectPropStru
if (objectPrimitiveRequiredProp != map.end()) {
fromRawValue(objectPrimitiveRequiredProp->second, result.objectPrimitiveRequiredProp);
}
auto nestedObjectProp = map.find(\\"nestedObjectProp\\");
if (nestedObjectProp != map.end()) {
fromRawValue(nestedObjectProp->second, result.nestedObjectProp);
}
}
static inline std::string toString(const ObjectPropsObjectPropStruct &value) {
Expand Down

0 comments on commit e9ef560

Please sign in to comment.