Search in sources :

Example 1 with ChangedParameter

use of org.openapitools.openapidiff.core.model.ChangedParameter in project openapi-diff by OpenAPITools.

the class HtmlRender method li_changedParam.

private LiTag li_changedParam(ChangedParameter changeParam) {
    if (changeParam.isDeprecated()) {
        return li_deprecatedParam(changeParam);
    }
    boolean changeRequired = changeParam.isChangeRequired();
    boolean changeDescription = Optional.ofNullable(changeParam.getDescription()).map(ChangedMetadata::isDifferent).orElse(false);
    Parameter rightParam = changeParam.getNewParameter();
    Parameter leftParam = changeParam.getNewParameter();
    LiTag li = li().withText(changeParam.getName() + " in " + changeParam.getIn());
    if (changeRequired) {
        li.withText(" change into " + (rightParam.getRequired() ? "required" : "not required"));
    }
    if (changeDescription) {
        li.withText(" Notes ").with(del(leftParam.getDescription()).withClass(COMMENT)).withText(" change into ").with(span(rightParam.getDescription()).withClass(COMMENT));
    }
    return li;
}
Also used : LiTag(j2html.tags.specialized.LiTag) Parameter(io.swagger.v3.oas.models.parameters.Parameter) ChangedParameter(org.openapitools.openapidiff.core.model.ChangedParameter)

Example 2 with ChangedParameter

use of org.openapitools.openapidiff.core.model.ChangedParameter in project openapi-diff by OpenAPITools.

the class HtmlRender method ul_param.

private UlTag ul_param(ChangedParameters changedParameters) {
    List<Parameter> addParameters = changedParameters.getIncreased();
    List<Parameter> delParameters = changedParameters.getMissing();
    List<ChangedParameter> changed = changedParameters.getChanged();
    UlTag ul = ul().withClass("change param");
    for (Parameter param : addParameters) {
        ul.with(li_addParam(param));
    }
    for (ChangedParameter param : changed) {
        ul.with(li_changedParam(param));
    }
    for (Parameter param : delParameters) {
        ul.with(li_missingParam(param));
    }
    return ul;
}
Also used : UlTag(j2html.tags.specialized.UlTag) Parameter(io.swagger.v3.oas.models.parameters.Parameter) ChangedParameter(org.openapitools.openapidiff.core.model.ChangedParameter) ChangedParameter(org.openapitools.openapidiff.core.model.ChangedParameter)

Example 3 with ChangedParameter

use of org.openapitools.openapidiff.core.model.ChangedParameter in project openapi-diff by OpenAPITools.

the class ParameterDiff method computeDiff.

@Override
protected DeferredChanged<ChangedParameter> computeDiff(HashSet<String> refSet, Parameter left, Parameter right, DiffContext context) {
    left = refPointer.resolveRef(this.leftComponents, left, left.get$ref());
    right = refPointer.resolveRef(this.rightComponents, right, right.get$ref());
    DeferredBuilder<Changed> builder = new DeferredBuilder<>();
    ChangedParameter changedParameter = new ChangedParameter(right.getName(), right.getIn(), context).setOldParameter(left).setNewParameter(right).setChangeRequired(getBooleanDiff(left.getRequired(), right.getRequired())).setDeprecated(!Boolean.TRUE.equals(left.getDeprecated()) && Boolean.TRUE.equals(right.getDeprecated())).setChangeAllowEmptyValue(getBooleanDiff(left.getAllowEmptyValue(), right.getAllowEmptyValue())).setChangeStyle(!Objects.equals(left.getStyle(), right.getStyle())).setChangeExplode(getBooleanDiff(left.getExplode(), right.getExplode()));
    builder.with(openApiDiff.getSchemaDiff().diff(left.getSchema(), right.getSchema(), context.copyWithRequired(true))).ifPresent(changedParameter::setSchema);
    builder.with(openApiDiff.getMetadataDiff().diff(left.getDescription(), right.getDescription(), context)).ifPresent(changedParameter::setDescription);
    builder.with(openApiDiff.getContentDiff().diff(left.getContent(), right.getContent(), context)).ifPresent(changedParameter::setContent);
    builder.with(openApiDiff.getExtensionsDiff().diff(left.getExtensions(), right.getExtensions(), context)).ifPresent(changedParameter::setExtensions);
    return builder.buildIsChanged(changedParameter);
}
Also used : Changed(org.openapitools.openapidiff.core.model.Changed) DeferredChanged(org.openapitools.openapidiff.core.model.deferred.DeferredChanged) DeferredBuilder(org.openapitools.openapidiff.core.model.deferred.DeferredBuilder) ChangedParameter(org.openapitools.openapidiff.core.model.ChangedParameter)

Aggregations

ChangedParameter (org.openapitools.openapidiff.core.model.ChangedParameter)3 Parameter (io.swagger.v3.oas.models.parameters.Parameter)2 LiTag (j2html.tags.specialized.LiTag)1 UlTag (j2html.tags.specialized.UlTag)1 Changed (org.openapitools.openapidiff.core.model.Changed)1 DeferredBuilder (org.openapitools.openapidiff.core.model.deferred.DeferredBuilder)1 DeferredChanged (org.openapitools.openapidiff.core.model.deferred.DeferredChanged)1