v2 - "readOnly" key should be used in schemas

If it has a value of boolean true,
    this keyword indicates that the instance property SHOULD NOT be changed,
    and attempts by a user agent to modify the value of this property are expected to be rejected by a server.
    The value of this keyword MUST be a boolean.
    The default value is false.

    Further link for reference: http://json-schema.org/latest/json-schema-hypermedia.html#anchor15

Closes-Bug: #1521581
Depends-On: I279fba4099667d193609a31259057b897380d6f0
Change-Id: I96717506259c0d28500b8747369c47029b1dd9b6
This commit is contained in:
zwei
2016-01-18 10:17:14 +08:00
parent b4da8ce5f3
commit 22e3bf0234
7 changed files with 58 additions and 33 deletions

View File

@@ -112,7 +112,8 @@ class TestUtils(testtools.TestCase):
def schema_getter(_type='string', enum=False): def schema_getter(_type='string', enum=False):
prop = { prop = {
'type': ['null', _type], 'type': ['null', _type],
'description': 'Test schema (READ-ONLY)', 'readOnly': True,
'description': 'Test schema',
} }
if enum: if enum:

View File

@@ -96,7 +96,8 @@ schema_fixture = {
"type": "string" "type": "string"
}, },
"checksum": { "checksum": {
"description": "md5 hash of image contents. (READ-ONLY)", "readOnly": True,
"description": "md5 hash of image contents.",
"maxLength": 32, "maxLength": 32,
"type": [ "type": [
"null", "null",
@@ -121,12 +122,14 @@ schema_fixture = {
] ]
}, },
"created_at": { "created_at": {
"description": "Date and time of image registration (READ-ONLY)", "readOnly": True,
"description": "Date and time of image registration",
"type": "string" "type": "string"
}, },
"direct_url": { "direct_url": {
"readOnly": True,
"description": "URL to access the image file kept in external " "description": "URL to access the image file kept in external "
"store (READ-ONLY)", "store",
"type": "string" "type": "string"
}, },
"disk_format": { "disk_format": {
@@ -149,7 +152,8 @@ schema_fixture = {
] ]
}, },
"file": { "file": {
"description": "(READ-ONLY)", "readOnly": True,
"description": "An image file url",
"type": "string" "type": "string"
}, },
"id": { "id": {
@@ -253,22 +257,26 @@ schema_fixture = {
] ]
}, },
"schema": { "schema": {
"description": "(READ-ONLY)", "readOnly": True,
"description": "An image schema url",
"type": "string" "type": "string"
}, },
"self": { "self": {
"description": "(READ-ONLY)", "readOnly": True,
"description": "An image self url",
"type": "string" "type": "string"
}, },
"size": { "size": {
"description": "Size of image file in bytes (READ-ONLY)", "readOnly": True,
"description": "Size of image file in bytes",
"type": [ "type": [
"null", "null",
"integer" "integer"
] ]
}, },
"status": { "status": {
"description": "Status of the image (READ-ONLY)", "readOnly": True,
"description": "Status of the image",
"enum": [ "enum": [
"queued", "queued",
"saving", "saving",
@@ -288,12 +296,14 @@ schema_fixture = {
"type": "array" "type": "array"
}, },
"updated_at": { "updated_at": {
"readOnly": True,
"description": "Date and time of the last image " "description": "Date and time of the last image "
"modification (READ-ONLY)", "modification",
"type": "string" "type": "string"
}, },
"virtual_size": { "virtual_size": {
"description": "Virtual size of image in bytes (READ-ONLY)", "readOnly": True,
"description": "Virtual size of image in bytes",
"type": [ "type": [
"null", "null",
"integer" "integer"

View File

@@ -444,8 +444,9 @@ schema_fixtures = {
}, },
"updated_at": { "updated_at": {
"type": "string", "type": "string",
"readOnly": True,
"description": "Date and time of the last namespace " "description": "Date and time of the last namespace "
"modification (READ-ONLY)", "modification",
"format": "date-time" "format": "date-time"
}, },
"visibility": { "visibility": {
@@ -512,8 +513,8 @@ schema_fixtures = {
}, },
"created_at": { "created_at": {
"type": "string", "type": "string",
"description": "Date and time of namespace creation " "readOnly": True,
"(READ-ONLY)", "description": "Date and time of namespace creation ",
"format": "date-time" "format": "date-time"
}, },
"namespace": { "namespace": {

View File

@@ -222,8 +222,8 @@ schema_fixtures = {
"properties": { "properties": {
"created_at": { "created_at": {
"type": "string", "type": "string",
"description": "Date and time of object creation " "readOnly": True,
"(READ-ONLY)", "description": "Date and time of object creation ",
"format": "date-time" "format": "date-time"
}, },
"description": { "description": {
@@ -246,8 +246,9 @@ schema_fixtures = {
}, },
"updated_at": { "updated_at": {
"type": "string", "type": "string",
"readOnly": True,
"description": "Date and time of the last object " "description": "Date and time of the last object "
"modification (READ-ONLY)", "modification",
"format": "date-time" "format": "date-time"
}, },
} }

View File

@@ -127,15 +127,16 @@ schema_fixtures = {
}, },
"created_at": { "created_at": {
"type": "string", "type": "string",
"readOnly": True,
"description": "Date and time of resource type " "description": "Date and time of resource type "
"association (READ-ONLY)", "association",
"format": "date-time" "format": "date-time"
}, },
"updated_at": { "updated_at": {
"type": "string", "type": "string",
"readOnly": True,
"description": "Date and time of the last resource " "description": "Date and time of the last resource "
"type association modification " "type association modification ",
"(READ-ONLY)",
"format": "date-time" "format": "date-time"
}, },
} }

View File

@@ -111,14 +111,15 @@ schema_fixtures = {
}, },
"created_at": { "created_at": {
"type": "string", "type": "string",
"description": ("Date and time of tag creation" "readOnly": True,
" (READ-ONLY)"), "description": ("Date and time of tag creation"),
"format": "date-time" "format": "date-time"
}, },
"updated_at": { "updated_at": {
"type": "string", "type": "string",
"readOnly": True,
"description": ("Date and time of the last tag" "description": ("Date and time of the last tag"
" modification (READ-ONLY)"), " modification"),
"format": "date-time" "format": "date-time"
}, },
'properties': {} 'properties': {}

View File

@@ -86,7 +86,8 @@ _BASE_SCHEMA = {
}, },
"file": { "file": {
"type": "string", "type": "string",
"description": "(READ-ONLY)" "readOnly": True,
"description": ("An image file url")
}, },
"owner": { "owner": {
"type": "string", "type": "string",
@@ -102,7 +103,8 @@ _BASE_SCHEMA = {
}, },
"size": { "size": {
"type": "integer", "type": "integer",
"description": "Size of image file in bytes (READ-ONLY)" "readOnly": True,
"description": "Size of image file in bytes"
}, },
"os_distro": { "os_distro": {
"type": "string", "type": "string",
@@ -111,7 +113,8 @@ _BASE_SCHEMA = {
}, },
"self": { "self": {
"type": "string", "type": "string",
"description": "(READ-ONLY)" "readOnly": True,
"description": ("An image self url")
}, },
"disk_format": { "disk_format": {
"enum": [ "enum": [
@@ -135,12 +138,14 @@ _BASE_SCHEMA = {
}, },
"direct_url": { "direct_url": {
"type": "string", "type": "string",
"readOnly": True,
"description": ("URL to access the image file kept in " "description": ("URL to access the image file kept in "
"external store (READ-ONLY)") "external store")
}, },
"schema": { "schema": {
"type": "string", "type": "string",
"description": "(READ-ONLY)" "readOnly": True,
"description": ("An image schema url")
}, },
"status": { "status": {
"enum": [ "enum": [
@@ -152,7 +157,8 @@ _BASE_SCHEMA = {
"pending_delete" "pending_delete"
], ],
"type": "string", "type": "string",
"description": "Status of the image (READ-ONLY)" "readOnly": True,
"description": "Status of the image"
}, },
"tags": { "tags": {
"items": { "items": {
@@ -181,8 +187,9 @@ _BASE_SCHEMA = {
}, },
"updated_at": { "updated_at": {
"type": "string", "type": "string",
"readOnly": True,
"description": ("Date and time of the last " "description": ("Date and time of the last "
"image modification (READ-ONLY)") "image modification")
}, },
"min_disk": { "min_disk": {
"type": "integer", "type": "integer",
@@ -191,7 +198,8 @@ _BASE_SCHEMA = {
}, },
"virtual_size": { "virtual_size": {
"type": "integer", "type": "integer",
"description": "Virtual size of image in bytes (READ-ONLY)" "readOnly": True,
"description": "Virtual size of image in bytes"
}, },
"instance_uuid": { "instance_uuid": {
"type": "string", "type": "string",
@@ -207,12 +215,14 @@ _BASE_SCHEMA = {
}, },
"checksum": { "checksum": {
"type": "string", "type": "string",
"description": "md5 hash of image contents. (READ-ONLY)", "readOnly": True,
"description": "md5 hash of image contents.",
"maxLength": 32 "maxLength": 32
}, },
"created_at": { "created_at": {
"type": "string", "type": "string",
"description": "Date and time of image registration (READ-ONLY)" "readOnly": True,
"description": "Date and time of image registration "
}, },
"protected": { "protected": {
"type": "boolean", "type": "boolean",