-
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.
* Improve change detection to consider changeDefault field in ChangedSchema * Add test for defaults handling in Schema * Add test for defaults handling in Schema
- Loading branch information
Showing
4 changed files
with
69 additions
and
0 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
26 changes: 26 additions & 0 deletions
26
core/src/test/java/org/openapitools/openapidiff/core/SchemaDefaultsTest.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,26 @@ | ||
package org.openapitools.openapidiff.core; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.openapitools.openapidiff.core.model.ChangedOpenApi; | ||
import org.openapitools.openapidiff.core.model.ChangedSchema; | ||
|
||
public class SchemaDefaultsTest { | ||
|
||
@Test | ||
public void issue717DefaultsInSchema() { | ||
ChangedOpenApi changedOpenApi = | ||
OpenApiCompare.fromLocations( | ||
"issue-717-schema-defaults-handling-1.yaml", | ||
"issue-717-schema-defaults-handling-2.yaml"); | ||
|
||
assertEquals(1, changedOpenApi.getChangedOperations().size()); | ||
assertEquals(1, changedOpenApi.getChangedSchemas().size()); | ||
ChangedSchema changedSchema = changedOpenApi.getChangedSchemas().get(0); | ||
assertEquals(1, changedSchema.getChangedProperties().size()); | ||
assertTrue(changedSchema.getChangedProperties().containsKey("field1")); | ||
assertTrue(changedSchema.getChangedProperties().get("field1").isChangeDefault()); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
core/src/test/resources/issue-717-schema-defaults-handling-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,21 @@ | ||
openapi: 3.1.0 | ||
info: | ||
description: Schema defaults handling | ||
title: defaults | ||
version: 1.0.0 | ||
paths: | ||
/defaults/property-schema/: | ||
post: | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/TestDTO' | ||
components: | ||
schemas: | ||
TestDTO: | ||
type: object | ||
properties: | ||
field1: | ||
default: default value | ||
type: string |
21 changes: 21 additions & 0 deletions
21
core/src/test/resources/issue-717-schema-defaults-handling-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,21 @@ | ||
openapi: 3.1.0 | ||
info: | ||
description: Schema defaults handling | ||
title: defaults | ||
version: 1.0.0 | ||
paths: | ||
/defaults/property-schema/: | ||
post: | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/TestDTO' | ||
components: | ||
schemas: | ||
TestDTO: | ||
type: object | ||
properties: | ||
field1: | ||
default: default value updated | ||
type: string |