-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#8 Stack overflow on recursive schemas fix
- Loading branch information
Showing
8 changed files
with
613 additions
and
9 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
5 changes: 3 additions & 2 deletions
5
...ake/integration/NoBreakingChangeTest.java → ...eakingchange/NoBreakingChangeIntTest.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
26 changes: 26 additions & 0 deletions
26
...st/java/io/redskap/swagger/brake/integration/nobreakingchange/RecursiveSchemaIntTest.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 io.redskap.swagger.brake.integration.nobreakingchange; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.Collection; | ||
|
||
import io.redskap.swagger.brake.core.BreakingChange; | ||
import io.redskap.swagger.brake.integration.AbstractSwaggerBrakeIntTest; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.test.context.junit4.SpringRunner; | ||
|
||
@RunWith(SpringRunner.class) | ||
public class RecursiveSchemaIntTest extends AbstractSwaggerBrakeIntTest { | ||
@Test | ||
public void testNoBreakingChangeWorksCorrectly() { | ||
// given | ||
String oldApiPath = "nobreakingchange/recursive/schema.json"; | ||
String newApiPath = "nobreakingchange/recursive/schema_v2.json"; | ||
// when | ||
Collection<BreakingChange> result = execute(oldApiPath, newApiPath); | ||
// then | ||
assertThat(result).isEmpty(); | ||
} | ||
} | ||
|
32 changes: 32 additions & 0 deletions
32
...a/io/redskap/swagger/brake/integration/response/RecursiveTypeAttributeRemovedIntTest.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,32 @@ | ||
package io.redskap.swagger.brake.integration.response; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
|
||
import io.redskap.swagger.brake.core.BreakingChange; | ||
import io.redskap.swagger.brake.core.model.HttpMethod; | ||
import io.redskap.swagger.brake.core.rule.response.ResponseTypeAttributeRemovedBreakingChange; | ||
import io.redskap.swagger.brake.integration.AbstractSwaggerBrakeIntTest; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.test.context.junit4.SpringRunner; | ||
|
||
@RunWith(SpringRunner.class) | ||
public class RecursiveTypeAttributeRemovedIntTest extends AbstractSwaggerBrakeIntTest { | ||
@Test | ||
public void testResponseTypeChangeIsBreakingChangeWhenExistingAttributeRemoved() { | ||
// given | ||
String oldApiPath = "response/recursiveresponseattributeremoved/schema.json"; | ||
String newApiPath = "response/recursiveresponseattributeremoved/schema_v2.json"; | ||
ResponseTypeAttributeRemovedBreakingChange bc1 = | ||
new ResponseTypeAttributeRemovedBreakingChange("/api/v1/audits/summary/{businessId}", HttpMethod.GET, "200", "unverifiedPayoffBreakdown.amountApplied"); | ||
Collection<BreakingChange> expected = Collections.singletonList(bc1); | ||
// when | ||
Collection<BreakingChange> result = execute(oldApiPath, newApiPath); | ||
// then | ||
assertThat(result).hasSize(1); | ||
assertThat(result).hasSameElementsAs(expected); | ||
} | ||
} |
128 changes: 128 additions & 0 deletions
128
src/test/resources/nobreakingchange/recursive/schema.json
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,128 @@ | ||
{ | ||
"swagger": "2.0", | ||
"host": "localhost", | ||
"basePath": "/", | ||
"tags": [ | ||
{ | ||
"name": "audit-controller", | ||
"description": "Audit Controller" | ||
}, | ||
{ | ||
"name": "audit-fee-controller", | ||
"description": "Audit Fee Controller" | ||
}, | ||
{ | ||
"name": "operation-handler", | ||
"description": "Operation Handler" | ||
} | ||
], | ||
"paths": { | ||
"/api/v1/audits/summary/{businessId}": { | ||
"get": { | ||
"tags": [ | ||
"audit-controller" | ||
], | ||
"summary": "fetchAuditSummaryByBusinessId", | ||
"operationId": "fetchAuditSummaryByBusinessIdUsingGET", | ||
"produces": [ | ||
"*/*" | ||
], | ||
"parameters": [ | ||
{ | ||
"name": "businessId", | ||
"in": "path", | ||
"description": "businessId", | ||
"required": true, | ||
"type": "string", | ||
"format": "uuid" | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"schema": { | ||
"$ref": "#/definitions/AuditSummaryDTO" | ||
} | ||
}, | ||
"401": { | ||
"description": "Unauthorized" | ||
}, | ||
"403": { | ||
"description": "Forbidden" | ||
}, | ||
"404": { | ||
"description": "Not Found" | ||
} | ||
}, | ||
"security": [ | ||
{ | ||
"jwt": [ | ||
"global" | ||
] | ||
} | ||
], | ||
"deprecated": false | ||
} | ||
} | ||
}, | ||
"securityDefinitions": { | ||
"jwt": { | ||
"type": "apiKey", | ||
"name": "Authorization", | ||
"in": "header" | ||
} | ||
}, | ||
"definitions": { | ||
"AuditSummaryDTO": { | ||
"type": "object", | ||
"properties": { | ||
"payoffSavings": { | ||
"type": "number" | ||
}, | ||
"unverifiedPayoff": { | ||
"type": "number" | ||
}, | ||
"unverifiedPayoffBreakdown": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/definitions/PaymentItemDTO" | ||
} | ||
}, | ||
"unverifiedVehicles": { | ||
"type": "integer", | ||
"format": "int64" | ||
} | ||
}, | ||
"title": "AuditSummaryDTO" | ||
}, | ||
"PaymentItemDTO": { | ||
"type": "object", | ||
"properties": { | ||
"amountApplied": { | ||
"type": "number" | ||
}, | ||
"children": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/definitions/PaymentItemDTO" | ||
} | ||
}, | ||
"description": { | ||
"type": "string" | ||
}, | ||
"recordType": { | ||
"type": "string", | ||
"enum": [ | ||
"PRINCIPAL", | ||
"INTEREST", | ||
"CPP", | ||
"TRANSPORTATION_FEE", | ||
"AUDIT_FEE", | ||
"OTHER_FEE" | ||
] | ||
} | ||
}, | ||
"title": "PaymentItemDTO" | ||
} | ||
} | ||
} |
Oops, something went wrong.