Skip to content

Commit

Permalink
fix: respect readOnly and writeOnly properties for required checks (#130
Browse files Browse the repository at this point in the history
)

* fix:  respect readOnly and writeOnly properties for required checks

* Update breaking-changes.md

* re worked

* fix description

* additional use-cases for readonly/writeonly

* update breaking-changes doc

* comment

Co-authored-by: Reuven <rh@tufin.com>
  • Loading branch information
gssbzn and Reuven committed Aug 9, 2022
1 parent 789538a commit dd26a84
Show file tree
Hide file tree
Showing 21 changed files with 1,101 additions and 94 deletions.
68 changes: 37 additions & 31 deletions breaking-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ These examples are automatically generated from unit tests.
[changing an existing property in request header to required is breaking](diff/breaking_property_test.go?plain=1#L55)
[changing an existing property in response body to optional is breaking](diff/breaking_property_test.go?plain=1#L105)
[changing an existing request body from optional to required is breaking](diff/breaking_test.go?plain=1#L47)
[changing an existing required property in response body to not-write-only is breaking](diff/breaking_property_test.go?plain=1#L396)
[changing an existing response header from required to optional is breaking](diff/breaking_test.go?plain=1#L147)
[changing max length from nil to any value is breaking](diff/breaking_min_max_test.go?plain=1#L62)
[deleting a media-type from response is breaking](diff/breaking_test.go?plain=1#L162)
Expand All @@ -25,34 +26,39 @@ These examples are automatically generated from unit tests.
[reducing max length is breaking](diff/breaking_min_max_test.go?plain=1#L11)

## Examples of non-breaking changes
[adding a media-type to response isn't breaking](diff/not_breaking_test.go?plain=1#L148)
[adding a new required property in response body isn't breaking](diff/breaking_property_test.go?plain=1#L207)
[adding a new required property under AllOf in response body isn't breaking but when multiple inline (without $ref) schemas under AllOf are modified simultaneously, we detect is as breaking](diff/breaking_property_test.go?plain=1#L275)
[adding a new required property under AllOf in response body isn't breaking](diff/breaking_property_test.go?plain=1#L241)
[adding an enum value isn't breaking](diff/not_breaking_test.go?plain=1#L59)
[adding an optional request body isn't breaking](diff/not_breaking_test.go?plain=1#L16)
[both max lengths are nil isn't breaking](diff/breaking_min_max_test.go?plain=1#L96)
[changing a link to operation ID isn't breaking](diff/not_breaking_test.go?plain=1#L140)
[changing an existing header param to optional isn't breaking](diff/not_breaking_test.go?plain=1#L98)
[changing an existing property in request body to optional isn't breaking](diff/breaking_property_test.go?plain=1#L139)
[changing an existing property in request header to optional isn't breaking](diff/breaking_property_test.go?plain=1#L80)
[changing an existing property in response body to required isn't breaking](diff/breaking_property_test.go?plain=1#L122)
[changing an existing request body from required to optional isn't breaking](diff/not_breaking_test.go?plain=1#L32)
[changing comments isn't breaking](diff/not_breaking_test.go?plain=1#L77)
[changing extensions isn't breaking](diff/not_breaking_test.go?plain=1#L67)
[changing max length from any value to nil isn't breaking](diff/breaking_min_max_test.go?plain=1#L79)
[changing operation ID isn't breaking](diff/not_breaking_test.go?plain=1#L132)
[changing servers isn't breaking](diff/not_breaking_test.go?plain=1#L221)
[deleting a required property in request isn't breaking](diff/breaking_property_test.go?plain=1#L190)
[deleting a tag isn't breaking](diff/not_breaking_test.go?plain=1#L52)
[deprecating a header isn't breaking](diff/not_breaking_test.go?plain=1#L193)
[deprecating a parameter isn't breaking](diff/not_breaking_test.go?plain=1#L179)
[deprecating a schema isn't breaking](diff/not_breaking_test.go?plain=1#L207)
[deprecating an operation isn't breaking](diff/not_breaking_test.go?plain=1#L165)
[increasing max length isn't breaking](diff/breaking_min_max_test.go?plain=1#L44)
[new optional header param isn't breaking](diff/not_breaking_test.go?plain=1#L83)
[new optional property in request header isn't breaking](diff/breaking_property_test.go?plain=1#L36)
[new required response header param isn't breaking](diff/not_breaking_test.go?plain=1#L117)
[no change isn't breaking](diff/not_breaking_test.go?plain=1#L11)
[reducing min items isn't breaking](diff/breaking_min_max_test.go?plain=1#L111)
[reducing min length isn't breaking](diff/breaking_min_max_test.go?plain=1#L29)
[adding a media-type to response is not breaking](diff/not_breaking_test.go?plain=1#L148)
[adding a new required property in response body is not breaking](diff/breaking_property_test.go?plain=1#L207)
[adding a new required property under AllOf in response body is not breaking but when multiple inline (without $ref) schemas under AllOf are modified simultaneously, we detect is as breaking](diff/breaking_property_test.go?plain=1#L275)
[adding a new required property under AllOf in response body is not breaking](diff/breaking_property_test.go?plain=1#L241)
[adding a new required read-only property in request body is not breaking](diff/breaking_property_test.go?plain=1#L294)
[adding an enum value is not breaking](diff/not_breaking_test.go?plain=1#L59)
[adding an optional request body is not breaking](diff/not_breaking_test.go?plain=1#L16)
[both max lengths are nil is not breaking](diff/breaking_min_max_test.go?plain=1#L96)
[changing a link to operation ID is not breaking](diff/not_breaking_test.go?plain=1#L140)
[changing an existing header param to optional is not breaking](diff/not_breaking_test.go?plain=1#L98)
[changing an existing property in request body to optional is not breaking](diff/breaking_property_test.go?plain=1#L139)
[changing an existing property in request header to optional is not breaking](diff/breaking_property_test.go?plain=1#L80)
[changing an existing property in response body to required is not breaking](diff/breaking_property_test.go?plain=1#L122)
[changing an existing request body from required to optional is not breaking](diff/not_breaking_test.go?plain=1#L32)
[changing an existing required property in response body to write-only is not breaking](diff/breaking_property_test.go?plain=1#L379)
[changing an existing write-only property in response body to optional is not breaking](diff/breaking_property_test.go?plain=1#L362)
[changing comments is not breaking](diff/not_breaking_test.go?plain=1#L77)
[changing extensions is not breaking](diff/not_breaking_test.go?plain=1#L67)
[changing max length from any value to nil is not breaking](diff/breaking_min_max_test.go?plain=1#L79)
[changing operation ID is not breaking](diff/not_breaking_test.go?plain=1#L132)
[changing servers is not breaking](diff/not_breaking_test.go?plain=1#L221)
[deleting a non-required non-write-only property in response body is not breaking](diff/breaking_property_test.go?plain=1#L345)
[deleting a required property in request is not breaking](diff/breaking_property_test.go?plain=1#L190)
[deleting a required write-only property in response body is not breaking](diff/breaking_property_test.go?plain=1#L328)
[deleting a tag is not breaking](diff/not_breaking_test.go?plain=1#L52)
[deprecating a header is not breaking](diff/not_breaking_test.go?plain=1#L193)
[deprecating a parameter is not breaking](diff/not_breaking_test.go?plain=1#L179)
[deprecating a schema is not breaking](diff/not_breaking_test.go?plain=1#L207)
[deprecating an operation is not breaking](diff/not_breaking_test.go?plain=1#L165)
[increasing max length is not breaking](diff/breaking_min_max_test.go?plain=1#L44)
[new optional header param is not breaking](diff/not_breaking_test.go?plain=1#L83)
[new optional property in request header is not breaking](diff/breaking_property_test.go?plain=1#L36)
[new required response header param is not breaking](diff/not_breaking_test.go?plain=1#L117)
[no change is not breaking](diff/not_breaking_test.go?plain=1#L11)
[reducing min items is not breaking](diff/breaking_min_max_test.go?plain=1#L111)
[reducing min length is not breaking](diff/breaking_min_max_test.go?plain=1#L29)
2 changes: 1 addition & 1 deletion data/openapi31-test2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ components:
required:
- id
- name
- nickname
- tag
properties:
id:
type: integer
Expand Down
61 changes: 61 additions & 0 deletions data/required-properties/read-only-base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
openapi: 3.0.1
info:
title: Test Inc.
version: "1.0"
servers:
- url: https://localhost:9080
paths:
/api/atlas/v1.0/groups:
post:
operationId: createOneGroup
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/GroupView"
description: Creates one group.
required: true
responses:
"200":
content:
application/json:
schema:
$ref: "#/components/schemas/GroupView"
description: OK
summary: Create One Group
/api/atlas/v1.0/groups/{groupId}:
get:
operationId: returnOneGroup
parameters:
- $ref: "#/components/parameters/groupId"
responses:
"200":
content:
application/json:
schema:
$ref: "#/components/schemas/GroupView"
description: OK
summary: Return One Group
components:
parameters:
groupId:
in: path
name: groupId
required: true
schema:
type: string
schemas:
GroupView:
type: object
properties:
created:
type: string
format: date-time
readOnly: true
id:
type: string
readOnly: true
name:
type: string
required:
- name
54 changes: 54 additions & 0 deletions data/required-properties/read-only-new-base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
openapi: 3.0.1
info:
title: Test Inc.
version: "1.0"
servers:
- url: https://localhost:9080
paths:
/api/atlas/v1.0/groups:
post:
operationId: createOneGroup
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/GroupView"
description: Creates one project.
required: true
responses:
"200":
content:
application/json:
schema:
$ref: "#/components/schemas/GroupView"
description: OK
summary: Create One Group
/api/atlas/v1.0/groups/{groupId}:
get:
operationId: returnOneGroup
parameters:
- $ref: "#/components/parameters/groupId"
responses:
"200":
content:
application/json:
schema:
$ref: "#/components/schemas/GroupView"
description: OK
summary: Return One Group
components:
parameters:
groupId:
in: path
name: groupId
required: true
schema:
type: string
schemas:
GroupView:
type: object
properties:
name:
type: string
required:
- name
63 changes: 63 additions & 0 deletions data/required-properties/read-only-new-revision.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
openapi: 3.0.1
info:
title: Test Inc.
version: "1.0"
servers:
- url: https://localhost:9080
paths:
/api/atlas/v1.0/groups:
post:
operationId: createOneGroup
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/GroupView"
description: Creates one project.
required: true
responses:
"200":
content:
application/json:
schema:
$ref: "#/components/schemas/GroupView"
description: OK
summary: Create One Group
/api/atlas/v1.0/groups/{groupId}:
get:
operationId: returnOneGroup
parameters:
- $ref: "#/components/parameters/groupId"
responses:
"200":
content:
application/json:
schema:
$ref: "#/components/schemas/GroupView"
description: OK
summary: Return One Group
components:
parameters:
groupId:
in: path
name: groupId
required: true
schema:
type: string
schemas:
GroupView:
type: object
properties:
created:
type: string
format: date-time
readOnly: true
id:
type: string
readOnly: true
name:
type: string
required:
- created
- id
- name
63 changes: 63 additions & 0 deletions data/required-properties/read-only-revision.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
openapi: 3.0.1
info:
title: Test Inc.
version: "1.0"
servers:
- url: https://localhost:9080
paths:
/api/atlas/v1.0/groups:
post:
operationId: createOneGroup
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/GroupView"
description: Creates one project.
required: true
responses:
"200":
content:
application/json:
schema:
$ref: "#/components/schemas/GroupView"
description: OK
summary: Create One Group
/api/atlas/v1.0/groups/{groupId}:
get:
operationId: returnOneGroup
parameters:
- $ref: "#/components/parameters/groupId"
responses:
"200":
content:
application/json:
schema:
$ref: "#/components/schemas/GroupView"
description: OK
summary: Return One Group
components:
parameters:
groupId:
in: path
name: groupId
required: true
schema:
type: string
schemas:
GroupView:
type: object
properties:
created:
type: string
format: date-time
readOnly: true
id:
type: string
readOnly: true
name:
type: string
required:
- created
- id
- name
65 changes: 65 additions & 0 deletions data/required-properties/write-only-base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
openapi: 3.0.1
info:
title: Test Inc.
version: "1.0"
servers:
- url: https://localhost:9080
paths:
/api/atlas/v1.0/groups:
post:
operationId: createOneGroup
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/GroupView"
description: Creates one group.
required: true
responses:
"200":
content:
application/json:
schema:
$ref: "#/components/schemas/GroupView"
description: OK
summary: Create One Group
/api/atlas/v1.0/groups/{groupId}:
get:
operationId: returnOneGroup
parameters:
- $ref: "#/components/parameters/groupId"
responses:
"200":
content:
application/json:
schema:
$ref: "#/components/schemas/GroupView"
description: OK
summary: Return One Group
components:
parameters:
groupId:
in: path
name: groupId
required: true
schema:
type: string
schemas:
GroupView:
type: object
properties:
created:
type: string
format: date-time
readOnly: true
id:
type: string
readOnly: true
name:
type: string
test:
type: string
writeOnly: true
required:
- name
- test
Loading

0 comments on commit dd26a84

Please sign in to comment.