All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.elibracha.compare.schemadiffresult.ArraySchemaDiffResult Maven / Gradle / Ivy

There is a newer version: 2.3.6
Show newest version
package com.github.elibracha.compare.schemadiffresult;

import com.github.elibracha.compare.OpenApiDiff;
import com.github.elibracha.model.ChangedSchema;
import com.github.elibracha.model.DiffContext;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import java.util.HashSet;
import java.util.Optional;

/** Created by adarsh.sharma on 18/12/17. */
public class ArraySchemaDiffResult extends SchemaDiffResult {
  public ArraySchemaDiffResult(OpenApiDiff openApiDiff) {
    super("array", openApiDiff);
  }

  @Override
  public , X> Optional diff(
      HashSet refSet,
      Components leftComponents,
      Components rightComponents,
      T left,
      T right,
      DiffContext context) {
    ArraySchema leftArraySchema = (ArraySchema) left;
    ArraySchema rightArraySchema = (ArraySchema) right;
    super.diff(refSet, leftComponents, rightComponents, left, right, context);
    openApiDiff
        .getSchemaDiff()
        .diff(
            refSet,
            leftArraySchema.getItems(),
            rightArraySchema.getItems(),
            context.copyWithRequired(true))
        .ifPresent(changedSchema::setItems);
    return isApplicable(context);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy