- edited description
Issues with required keyword
Issue #1
resolved
When an object definition has a list of required attributes with multiple objects...
- Data change of required object attribute(s) are no longer detected, unless all required objects were changed.
- Additionally, in this scenario the removal of non-required object attribute(s) are no longer detected.
- Making more attributes required is considered a non-breaking change.
Source:
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "Swagger Petstore",
"description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"name": "Swagger API Team"
},
"license": {
"name": "MIT"
}
},
"host": "petstore.swagger.io",
"basePath": "/api",
"schemes": [
"http"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/pets": {
"get": {
"description": "Returns all pets from the system that the user has access to",
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "A list of pets.",
"schema": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
},
"definitions": {
"Pet": {
"type": "object",
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
},
"animal": {
"type": "string"
},
"foodType": {
"type": "string"
}
}
}
}
}
Destination:
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "Swagger Petstore",
"description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"name": "Swagger API Team"
},
"license": {
"name": "MIT"
}
},
"host": "petstore.swagger.io",
"basePath": "/api",
"schemes": [
"http"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/pets": {
"get": {
"description": "Returns all pets from the system that the user has access to",
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "A list of pets.",
"schema": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
},
"definitions": {
"Pet": {
"type": "object",
"required": [
"id",
"name",
"tag"
],
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "integer",
"format": "int64"
},
"tag": {
"type": "string"
}
}
}
}
}
Key things to note:
- "id" and "name" had their data types swapped, and "animal" and "foodType" were removed.
- Should be reported as breaking changes, but instead no changes are detected at all.
- "tag" was made required.
Comments (4)
-
reporter -
reporter - edited description
-
reporter Oh hold on, probably because it's a response, not request. Will update with PUT/POST and see if it catches that.
Confirmed: issue still persists. The whole thing seems to break when a required attribute has its data type changed.
-
reporter - changed status to resolved
Was fixed with 0.21.0.
- Log in to comment