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

skip added required properties in the response-property-became-required check #487

Merged
merged 2 commits into from
Feb 5, 2024
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
15 changes: 10 additions & 5 deletions checker/check-response-property-became-required.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ func ResponsePropertyBecameRequiredCheck(diffReport *diff.Diff, operationsSource

if mediaTypeDiff.SchemaDiff.RequiredDiff != nil {
for _, changedRequiredPropertyName := range mediaTypeDiff.SchemaDiff.RequiredDiff.Added {
id := ResponsePropertyBecameRequiredId
if mediaTypeDiff.SchemaDiff.Base.Properties[changedRequiredPropertyName] == nil {
// added properties are processed by ResponseRequiredPropertyUpdatedCheck check
continue
}
if mediaTypeDiff.SchemaDiff.Revision.Properties[changedRequiredPropertyName] == nil {
// removed properties processed by the ResponseRequiredPropertyUpdatedCheck check
continue
}
id := ResponsePropertyBecameRequiredId
if mediaTypeDiff.SchemaDiff.Revision.Properties[changedRequiredPropertyName].Value.WriteOnly {
id = ResponseWriteOnlyPropertyBecameRequiredId
}
Expand All @@ -69,17 +73,18 @@ func ResponsePropertyBecameRequiredCheck(diffReport *diff.Diff, operationsSource
return
}
for _, changedRequiredPropertyName := range requiredDiff.Added {
id := ResponsePropertyBecameRequiredId
if propertyDiff.Base.Properties[changedRequiredPropertyName] == nil {
// added properties are processed by ResponseRequiredPropertyUpdatedCheck check
continue
}
if propertyDiff.Base.Properties[changedRequiredPropertyName].Value.WriteOnly {
id = ResponseWriteOnlyPropertyBecameRequiredId
}
if propertyDiff.Revision.Properties[changedRequiredPropertyName] == nil {
// removed properties processed by the ResponseRequiredPropertyUpdatedCheck check
continue
}
id := ResponsePropertyBecameRequiredId
if propertyDiff.Base.Properties[changedRequiredPropertyName].Value.WriteOnly {
id = ResponseWriteOnlyPropertyBecameRequiredId
}

result = append(result, ApiChange{
Id: id,
Expand Down
94 changes: 49 additions & 45 deletions data/checker/response_property_became_optional_base.yaml
Original file line number Diff line number Diff line change
@@ -1,45 +1,49 @@
openapi: 3.0.1
info:
title: Tufin
version: "2.0"
servers:
- url: https://localhost:9080
paths:
/api/v1.0/groups:
post:
operationId: createOneGroup
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/GroupView'
description: OK
summary: Create One Project
components:
parameters:
groupId:
in: path
name: groupId
required: true
schema:
type: string
schemas:
GroupView:
type: object
properties:
data:
type: object
properties:
created:
type: string
format: date-time
readOnly: true
pattern: "^[a-z]+$"
id:
type: string
readOnly: true
name:
type: string
required:
- name
openapi: 3.0.1
info:
title: Tufin
version: "2.0"
servers:
- url: https://localhost:9080
paths:
/api/v1.0/groups:
post:
operationId: createOneGroup
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/GroupView'
description: OK
summary: Create One Project
components:
parameters:
groupId:
in: path
name: groupId
required: true
schema:
type: string
schemas:
GroupView:
type: object
properties:
data:
type: object
properties:
created:
type: string
format: date-time
readOnly: true
pattern: "^[a-z]+$"
id:
type: string
readOnly: true
name:
type: string
required:
- name
location:
type: string
required:
- location
Loading