private static IEnumerable <KeyValuePair <String, JsonProperty> > WriteOneSide(JsonSchema4 schema, JsonSchema4 other, RelationshipSettings relationship)
        {
            var name = other.GetKeyName();

            if (!schema.Properties.ContainsKey(name)) //Don't write if schema defined property.
            {
                yield return(new KeyValuePair <string, JsonProperty>
                             (
                                 key: name,
                                 value: new JsonProperty()
                {
                    Type = JsonObjectType.Object,
                    Format = other.GetKeyType().Name,
                    Parent = schema,
                    ExtensionData = relationship.CopyExtensions(),
                }
                             ));
            }

            name = other.Title;

            if (!schema.Properties.ContainsKey(name)) //Don't write if schema defined property.
            {
                yield return(new KeyValuePair <string, JsonProperty>
                             (
                                 key: name,
                                 value: new JsonProperty()
                {
                    Type = JsonObjectType.Object,
                    Format = other.Title + "Entity",
                    Parent = schema,
                    ExtensionData = relationship.CopyExtensions(),
                }
                             ));
            }
        }
        private static async Task <Dictionary <String, JsonProperty> > WriteManySide(JsonSchema4 schema, JsonSchema4 other, RelationshipSettings relationship)
        {
            var name  = other.GetKeyName() + "s"; //Should be xxId so adding s should be fine
            var props = new Dictionary <String, JsonProperty>();

            if (!schema.Properties.ContainsKey(name)) //Don't write if schema defined property.
            {
                props.Add(name, new JsonProperty()
                {
                    Type          = JsonObjectType.Array,
                    Item          = await TypeToSchemaGenerator.CreateSchema(other.GetKeyType()),
                    Parent        = schema,
                    ExtensionData = relationship.CopyExtensions(),
                    Title         = relationship.OriginalPropertyDefinition?.Title
                });
            }

            return(props);
        }
        private static async Task <Dictionary <String, JsonProperty> > WriteOneSide(JsonSchema4 schema, JsonSchema4 other, RelationshipSettings relationship)
        {
            var name  = other.GetKeyName();
            var props = new Dictionary <String, JsonProperty>();

            if (!schema.Properties.ContainsKey(name)) //Don't write if schema defined property.
            {
                var propSchema = await TypeToSchemaGenerator.CreateSchema(other.GetKeyType());

                props.Add(name, new JsonProperty()
                {
                    Type          = propSchema.Type,
                    Format        = propSchema.Format,
                    Parent        = schema,
                    ExtensionData = relationship.CopyExtensions(),
                    Title         = relationship.OriginalPropertyDefinition?.Title
                });
            }

            return(props);
        }
        private static IEnumerable <KeyValuePair <String, JsonProperty> > WriteManyManySide(JsonSchema4 schema, JsonSchema4 other, RelationshipSettings relationship)
        {
            var name = $"Join{relationship.LeftModelName}To{relationship.RightModelName}";

            if (!schema.Properties.ContainsKey(name)) //Don't write if schema defined property.
            {
                yield return(new KeyValuePair <string, JsonProperty>
                             (
                                 key: name,
                                 value: new JsonProperty()
                {
                    Type = JsonObjectType.Array,
                    Item = new JsonSchema4()
                    {
                        Type = JsonObjectType.Object,
                        Format = $"Join{relationship.LeftModelName}To{relationship.RightModelName}Entity",
                    },
                    Parent = schema,
                    ExtensionData = relationship.CopyExtensions(),
                }
                             ));
            }
        }