-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Closed
Description
Please clarify: Are values like 1.0 valid for the integer data type?
JSON schema allows values like 1.0 for integers. But the OpenAPI specification contains this sentence:
Note that
integeras a type is also supported and is defined as a JSON number without a fraction or exponent part.
"without a fraction or exponent part" - does that mean that the number is not allowed to have a fraction part at all, e.g. 1 is valid but 1.0 is invalid? Or does it mean that a fraction of 0 is allowed, so 1 is valid and 1.0 is also valid?
Are the rules the same for JSON parameters and for query parameters?
For example, consider this OpenAPI specification:
{
"openapi": "3.0.0",
"info": {
"title": "Integers",
"version": "1.0"
},
"paths": {
"/path1": {
"post": {
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"value": {
"type": "integer"
}
}
}
}
}
},
"responses": {
"default": {
"description": "test"
}
}
}
},
"/path2": {
"get": {
"parameters": [
{
"in": "query",
"name": "a",
"schema": {
"type": "integer"
}
}
],
"responses": {
"default": {
"description": "test"
}
}
}
}
}
}
Are these requests valid?
- Request 1:
curl -H "Content-Type: application/json" --data '{ "value": 1.0 }' 'http://localhost/path1'
- Request 2:
curl 'http://localhost/path2?a=1.0'
Metadata
Metadata
Assignees
Labels
No labels