Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove lombok #175

Merged
merged 1 commit into from
Oct 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,54 @@
package com.qdesrame.openapi.diff.core.compare;

import com.qdesrame.openapi.diff.core.model.DiffContext;
import lombok.Value;
import java.util.Objects;

@Value
public class CacheKey {
public final class CacheKey {
private final String left;
private final String right;
private final DiffContext context;

String left;
String right;
DiffContext context;
public CacheKey(final String left, final String right, final DiffContext context) {
this.left = left;
this.right = right;
this.context = context;
}

public String getLeft() {
return this.left;
}

public String getRight() {
return this.right;
}

public DiffContext getContext() {
return this.context;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CacheKey cacheKey = (CacheKey) o;
return Objects.equals(left, cacheKey.left)
&& Objects.equals(right, cacheKey.right)
&& Objects.equals(context, cacheKey.context);
}

@Override
public int hashCode() {
return Objects.hash(left, right, context);
}

@java.lang.Override
public java.lang.String toString() {
return "CacheKey(left="
+ this.getLeft()
+ ", right="
+ this.getRight()
+ ", context="
+ this.getContext()
+ ")";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,12 @@
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import lombok.Getter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Getter
public class OpenApiDiff {

public static final String SWAGGER_VERSION_V2 = "2.0";

private static final Logger logger = LoggerFactory.getLogger(OpenApiDiff.class);

private PathsDiff pathsDiff;
private PathDiff pathDiff;
private SchemaDiff schemaDiff;
Expand All @@ -47,7 +42,6 @@ public class OpenApiDiff {
private OAuthFlowDiff oAuthFlowDiff;
private ExtensionsDiff extensionsDiff;
private MetadataDiff metadataDiff;

private final OpenAPI oldSpecOpenApi;
private final OpenAPI newSpecOpenApi;
private List<Endpoint> newEndpoints;
Expand Down Expand Up @@ -132,7 +126,6 @@ private void setChangedExtension(ChangedExtensions changedExtension) {

private void preProcess(OpenAPI openApi) {
List<SecurityRequirement> securityRequirements = openApi.getSecurity();

if (securityRequirements != null) {
List<SecurityRequirement> distinctSecurityRequirements =
securityRequirements.stream().distinct().collect(Collectors.toList());
Expand Down Expand Up @@ -171,4 +164,104 @@ private ChangedOpenApi getChangedOpenApi() {
.setChangedOperations(changedOperations)
.setChangedExtensions(changedExtensions);
}

public PathsDiff getPathsDiff() {
return this.pathsDiff;
}

public PathDiff getPathDiff() {
return this.pathDiff;
}

public SchemaDiff getSchemaDiff() {
return this.schemaDiff;
}

public ContentDiff getContentDiff() {
return this.contentDiff;
}

public ParametersDiff getParametersDiff() {
return this.parametersDiff;
}

public ParameterDiff getParameterDiff() {
return this.parameterDiff;
}

public RequestBodyDiff getRequestBodyDiff() {
return this.requestBodyDiff;
}

public ResponseDiff getResponseDiff() {
return this.responseDiff;
}

public HeadersDiff getHeadersDiff() {
return this.headersDiff;
}

public HeaderDiff getHeaderDiff() {
return this.headerDiff;
}

public ApiResponseDiff getApiResponseDiff() {
return this.apiResponseDiff;
}

public OperationDiff getOperationDiff() {
return this.operationDiff;
}

public SecurityRequirementsDiff getSecurityRequirementsDiff() {
return this.securityRequirementsDiff;
}

public SecurityRequirementDiff getSecurityRequirementDiff() {
return this.securityRequirementDiff;
}

public SecuritySchemeDiff getSecuritySchemeDiff() {
return this.securitySchemeDiff;
}

public OAuthFlowsDiff getOAuthFlowsDiff() {
return this.oAuthFlowsDiff;
}

public OAuthFlowDiff getOAuthFlowDiff() {
return this.oAuthFlowDiff;
}

public ExtensionsDiff getExtensionsDiff() {
return this.extensionsDiff;
}

public MetadataDiff getMetadataDiff() {
return this.metadataDiff;
}

public OpenAPI getOldSpecOpenApi() {
return this.oldSpecOpenApi;
}

public OpenAPI getNewSpecOpenApi() {
return this.newSpecOpenApi;
}

public List<Endpoint> getNewEndpoints() {
return this.newEndpoints;
}

public List<Endpoint> getMissingEndpoints() {
return this.missingEndpoints;
}

public List<ChangedOperation> getChangedOperations() {
return this.changedOperations;
}

public ChangedExtensions getChangedExtensions() {
return this.changedExtensions;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,25 @@
import io.swagger.v3.oas.models.security.SecurityScheme;
import java.util.List;
import java.util.Optional;
import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class SecurityDiffInfo {

private String ref;
private SecurityScheme securityScheme;
private List<String> scopes;

public SecurityDiffInfo(
final String ref, final SecurityScheme securityScheme, final List<String> scopes) {
this.ref = ref;
this.securityScheme = securityScheme;
this.scopes = scopes;
}

public static SecurityRequirement getSecurityRequirement(
List<SecurityDiffInfo> securityDiffInfoList) {
SecurityRequirement securityRequirement = new SecurityRequirement();
for (SecurityDiffInfo securityDiffInfo : securityDiffInfoList) {
securityRequirement.put(securityDiffInfo.getRef(), securityDiffInfo.getScopes());
}

return securityRequirement;
}

Expand All @@ -47,9 +48,7 @@ public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) {
return false;
}

SecurityDiffInfo that = (SecurityDiffInfo) o;

if (securityScheme != null
? !securityScheme.equals(that.securityScheme)
: that.securityScheme != null) {
Expand All @@ -64,4 +63,39 @@ public int hashCode() {
result = 31 * result + (scopes != null ? scopes.hashCode() : 0);
return result;
}

public String getRef() {
return this.ref;
}

public SecurityScheme getSecurityScheme() {
return this.securityScheme;
}

public List<String> getScopes() {
return this.scopes;
}

public void setRef(final String ref) {
this.ref = ref;
}

public void setSecurityScheme(final SecurityScheme securityScheme) {
this.securityScheme = securityScheme;
}

public void setScopes(final List<String> scopes) {
this.scopes = scopes;
}

@java.lang.Override
public java.lang.String toString() {
return "SecurityDiffInfo(ref="
+ this.getRef()
+ ", securityScheme="
+ this.getSecurityScheme()
+ ", scopes="
+ this.getScopes()
+ ")";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.media.Schema;
import java.util.*;
import lombok.Getter;

@Getter
public class SchemaDiffResult {
protected ChangedSchema changedSchema;
protected OpenApiDiff openApiDiff;
Expand Down Expand Up @@ -55,7 +53,6 @@ public <V extends Schema<X>, X> Optional<ChangedSchema> diff(
.setReadOnly(new ChangedReadOnly(left.getReadOnly(), right.getReadOnly(), context))
.setWriteOnly(new ChangedWriteOnly(left.getWriteOnly(), right.getWriteOnly(), context))
.setMaxLength(new ChangedMaxLength(left.getMaxLength(), right.getMaxLength(), context));

openApiDiff
.getExtensionsDiff()
.diff(left.getExtensions(), right.getExtensions(), context)
Expand All @@ -64,11 +61,9 @@ public <V extends Schema<X>, X> Optional<ChangedSchema> diff(
.getMetadataDiff()
.diff(left.getDescription(), right.getDescription(), context)
.ifPresent(changedSchema::setDescription);

Map<String, Schema> leftProperties = null == left ? null : left.getProperties();
Map<String, Schema> rightProperties = null == right ? null : right.getProperties();
MapKeyDiff<String, Schema> propertyDiff = MapKeyDiff.diff(leftProperties, rightProperties);

for (String key : propertyDiff.getSharedKey()) {
openApiDiff
.getSchemaDiff()
Expand All @@ -80,9 +75,7 @@ public <V extends Schema<X>, X> Optional<ChangedSchema> diff(
.ifPresent(
changedSchema1 -> changedSchema.getChangedProperties().put(key, changedSchema1));
}

compareAdditionalProperties(refSet, left, right, context);

changedSchema
.getIncreasedProperties()
.putAll(filterProperties(Change.Type.ADDED, propertyDiff.getIncreased(), context));
Expand Down Expand Up @@ -157,4 +150,12 @@ private void compareAdditionalProperties(
isChanged(apChangedSchema).ifPresent(changedSchema::setAddProp);
}
}

public ChangedSchema getChangedSchema() {
return this.changedSchema;
}

public OpenApiDiff getOpenApiDiff() {
return this.openApiDiff;
}
}
Loading