Exemplo n.º 1
0
        private static string Items(string propName, ChangedSchemaBO schema)
        {
            var sb = new StringBuilder();

            sb.Append(Incompatibilities(propName + "[]", schema));
            return(sb.ToString());
        }
Exemplo n.º 2
0
        private void CompareAdditionalProperties(OpenApiSchema leftSchema,
                                                 OpenApiSchema rightSchema, DiffContextBO context)
        {
            var left  = leftSchema.AdditionalProperties;
            var right = rightSchema.AdditionalProperties;

            if (left != null || right != null)
            {
                var apChangedSchema = new ChangedSchemaBO
                {
                    Context   = context,
                    OldSchema = left,
                    NewSchema = right
                };
                if (left != null && right != null)
                {
                    var addPropChangedSchemaOp =
                        OpenApiDiff
                        .SchemaDiff
                        .Diff(left, right, context.CopyWithRequired(false));
                    apChangedSchema = addPropChangedSchemaOp ?? apChangedSchema;
                }

                var changed = ChangedUtils.IsChanged(apChangedSchema);
                if (changed != null)
                {
                    ChangedSchema.AddProp = changed;
                }
            }
        }
Exemplo n.º 3
0
        private static string Incompatibilities(string propName, ChangedSchemaBO schema)
        {
            var sb = new StringBuilder();

            if (schema.Items != null)
            {
                sb.Append(Items(propName, schema.Items));
            }
            if (schema.IsCoreChanged().DiffResult == DiffResultEnum.Incompatible && schema.IsChangedType)
            {
                var type = schema.OldSchema.GetSchemaType() + " -> " + schema.OldSchema.GetSchemaType();
                sb.Append(Property(propName, "Changed property type", type));
            }

            var prefix = propName.IsNullOrEmpty() ? "" : propName + ".";

            sb.Append(
                Properties(prefix, "Missing property", schema.MissingProperties, schema.Context));
            foreach (var(name, value) in schema.ChangedProperties)
            {
                sb.Append(Incompatibilities(prefix + name, value));
            }
            return(sb.ToString());
        }
Exemplo n.º 4
0
 private static string Incompatibilities(ChangedSchemaBO schema)
 {
     return(Incompatibilities("", schema));
 }
Exemplo n.º 5
0
 public SchemaDiffResult(OpenApiDiff openApiDiff)
 {
     OpenApiDiff   = openApiDiff;
     ChangedSchema = new ChangedSchemaBO();
 }