forked from OpenAPITools/openapi-diff
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Option to allow response enum additions
- Addresses issue OpenAPITools#303 - Default behavior unchanged to not allow response enum additions. - Adds option to allow response enum additions, both in CLI and programmatically - Tests added for new behavior related to lenient vs strict response enum behavior - Tests also added for request enum behavior (which has been left unchanged).
- Loading branch information
Showing
12 changed files
with
292 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
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
31 changes: 31 additions & 0 deletions
31
core/src/main/java/org/openapitools/openapidiff/core/compare/OpenApiDiffOptions.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,31 @@ | ||
package org.openapitools.openapidiff.core.compare; | ||
|
||
public class OpenApiDiffOptions { | ||
// Whether to fail backward compatibility check when enum values are added to responses | ||
private final boolean allowResponseEnumAdditions; | ||
|
||
private OpenApiDiffOptions(boolean allowResponseEnumAdditions) { | ||
this.allowResponseEnumAdditions = allowResponseEnumAdditions; | ||
} | ||
|
||
public boolean isAllowResponseEnumAdditions() { | ||
return allowResponseEnumAdditions; | ||
} | ||
|
||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
public static class Builder { | ||
private OpenApiDiffOptions built = new OpenApiDiffOptions(false); | ||
|
||
public Builder allowResponseEnumAdditions(boolean allowResponseEnumAdditions) { | ||
built = new OpenApiDiffOptions(allowResponseEnumAdditions); | ||
return this; | ||
} | ||
|
||
public OpenApiDiffOptions build() { | ||
return built; | ||
} | ||
} | ||
} |
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
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
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
37 changes: 37 additions & 0 deletions
37
core/src/test/resources/backwardCompatibility/bc_enum_base.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,37 @@ | ||
openapi: 3.0.0 | ||
info: | ||
description: test backward compatibility for enums | ||
version: 1.0.0 | ||
title: test backward compatibility for enums | ||
paths: | ||
/test-back-compat-enums: | ||
get: | ||
operationId: search | ||
parameters: | ||
- name: param-inline-enum | ||
in: query | ||
required: true | ||
schema: | ||
type: string | ||
enum: | ||
- param-inline-enum-val-1 | ||
- param-inline-enum-val-2 | ||
default: param-inline-enum-val-1 | ||
responses: | ||
'200': | ||
description: successful operation | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/SchemaWithEnum' | ||
components: | ||
schemas: | ||
SchemaWithEnum: | ||
type: object | ||
properties: | ||
enum-prop: | ||
type: string | ||
enum: | ||
- enum-prop-val-1 | ||
- enum-prop-val-2 | ||
default: enum-prop-val-1 |
Oops, something went wrong.