-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change of 'multipleof' is not detected (#746)
- Loading branch information
Showing
7 changed files
with
224 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
core/src/main/java/org/openapitools/openapidiff/core/model/schema/ChangedMultipleOf.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package org.openapitools.openapidiff.core.model.schema; | ||
|
||
import java.math.BigDecimal; | ||
import java.util.Objects; | ||
import org.openapitools.openapidiff.core.model.Changed; | ||
import org.openapitools.openapidiff.core.model.DiffResult; | ||
|
||
public class ChangedMultipleOf implements Changed { | ||
|
||
private final BigDecimal left; | ||
private final BigDecimal right; | ||
|
||
public ChangedMultipleOf(BigDecimal leftMultipleOf, BigDecimal rightMultipleOf) { | ||
this.left = leftMultipleOf; | ||
this.right = rightMultipleOf; | ||
} | ||
|
||
@Override | ||
public DiffResult isChanged() { | ||
if (Objects.equals(left, right)) { | ||
return DiffResult.NO_CHANGES; | ||
} | ||
|
||
// multipleof removed -> compatible | ||
if (right == null) { | ||
return DiffResult.COMPATIBLE; | ||
} | ||
|
||
return DiffResult.INCOMPATIBLE; | ||
} | ||
|
||
public BigDecimal getLeft() { | ||
return left; | ||
} | ||
|
||
public BigDecimal getRight() { | ||
return right; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ChangedMultipleOf [left=" + left + ", right=" + right + "]"; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
ChangedMultipleOf that = (ChangedMultipleOf) o; | ||
return Objects.equals(left, that.getLeft()) && Objects.equals(right, that.getRight()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(left, right); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
core/src/test/resources/schemaDiff/schema-multiple-of-diff-1.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
openapi: 3.1.0 | ||
info: | ||
description: Schema diff | ||
title: schema diff | ||
version: 1.0.0 | ||
paths: | ||
/schema/numeric/multiple-of: | ||
post: | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/TestDTO' | ||
components: | ||
schemas: | ||
TestDTO: | ||
type: object | ||
properties: | ||
field1: | ||
type: integer | ||
multipleOf: 10 | ||
field2: | ||
type: integer | ||
multipleOf: 0.01 | ||
field3: | ||
type: integer | ||
field4: | ||
type: integer | ||
multipleOf: 10 |
29 changes: 29 additions & 0 deletions
29
core/src/test/resources/schemaDiff/schema-multiple-of-diff-2.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
openapi: 3.1.0 | ||
info: | ||
description: Schema diff | ||
title: schema diff | ||
version: 1.0.0 | ||
paths: | ||
/schema/numeric/multiple-of: | ||
post: | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/TestDTO' | ||
components: | ||
schemas: | ||
TestDTO: | ||
type: object | ||
properties: | ||
field1: | ||
type: integer | ||
multipleOf: 20 | ||
field2: | ||
type: integer | ||
multipleOf: 0.1 | ||
field3: | ||
type: integer | ||
multipleOf: 10 | ||
field4: | ||
type: integer |