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

717 issue fix #718

Merged
merged 3 commits into from
Jan 27, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ private DiffResult calculateCoreChanged() {
if (!changedType
&& (oldSchema == null && newSchema == null || oldSchema != null && newSchema != null)
&& !changeFormat
&& !changeDefault
&& increasedProperties.isEmpty()
&& missingProperties.isEmpty()
&& changedProperties.values().isEmpty()
Expand Down
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 core/src/test/resources/issue-717-schema-defaults-handling-1.yaml
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 core/src/test/resources/issue-717-schema-defaults-handling-2.yaml
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