Skip to content
This repository has been archived by the owner on Jul 24, 2021. It is now read-only.

Commit

Permalink
modularize some schema definitions for reuse
Browse files Browse the repository at this point in the history
  • Loading branch information
karenetheridge committed Nov 24, 2020
1 parent a9b073a commit 820dc61
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 183 deletions.
5 changes: 1 addition & 4 deletions docs/json-schema/common.json
Expand Up @@ -76,9 +76,6 @@
"pattern" : "^\\S+$",
"type" : "string"
},
"device_setting_key" : {
"$ref" : "#/$defs/mojo_relaxed_placeholder"
},
"disk_serial_number" : {
"pattern" : "^\\S+$",
"type" : "string"
Expand Down Expand Up @@ -160,7 +157,7 @@
"pattern" : "^[\\w-]+$",
"type" : "string"
},
"user_setting_key" : {
"setting_key" : {
"$ref" : "#/$defs/mojo_relaxed_placeholder"
},
"uuid" : {
Expand Down
6 changes: 5 additions & 1 deletion docs/json-schema/query_params.json
Expand Up @@ -142,6 +142,10 @@
},
"type" : "object"
},
"GetBuild" : {
"$ref" : "#/$defs/WithDeviceRackData",
"unevaluatedProperties" : false
},
"GetBuilds" : {
"additionalProperties" : false,
"not" : {
Expand Down Expand Up @@ -190,7 +194,7 @@
}
},
"propertyNames" : {
"$ref" : "common.json#/$defs/device_setting_key"
"$ref" : "common.json#/$defs/setting_key"
},
"type" : "object"
},
Expand Down
123 changes: 17 additions & 106 deletions docs/json-schema/request.json
Expand Up @@ -18,34 +18,17 @@
"type" : "object"
},
"BuildAddUser" : {
"additionalProperties" : false,
"oneOf" : [
{
"required" : [
"user_id"
]
},
{
"required" : [
"email"
]
}
],
"$ref" : "#/$defs/UserIdOrEmail",
"properties" : {
"email" : {
"$ref" : "common.json#/$defs/email_address"
},
"role" : {
"$ref" : "common.json#/$defs/role"
},
"user_id" : {
"$ref" : "common.json#/$defs/uuid"
}
},
"required" : [
"role"
],
"type" : "object"
"type" : "object",
"unevaluatedProperties" : false
},
"BuildCreate" : {
"additionalProperties" : false,
Expand All @@ -64,28 +47,9 @@
"properties" : {
"admins" : {
"items" : {
"additionalProperties" : false,
"oneOf" : [
{
"required" : [
"user_id"
]
},
{
"required" : [
"email"
]
}
],
"properties" : {
"email" : {
"$ref" : "common.json#/$defs/email_address"
},
"user_id" : {
"$ref" : "common.json#/$defs/uuid"
}
},
"type" : "object"
"$ref" : "#/$defs/UserIdOrEmail",
"type" : "object",
"unevaluatedProperties" : false
},
"minItems" : 1,
"type" : "array",
Expand Down Expand Up @@ -421,7 +385,7 @@
},
"minProperties" : 1,
"propertyNames" : {
"$ref" : "common.json#/$defs/device_setting_key"
"$ref" : "common.json#/$defs/setting_key"
},
"type" : "object"
},
Expand Down Expand Up @@ -615,40 +579,23 @@
"type" : "object"
},
"Login" : {
"additionalProperties" : false,
"$ref" : "#/$defs/UserIdOrEmail",
"default" : {
"set_session" : false
},
"oneOf" : [
{
"required" : [
"user_id"
]
},
{
"required" : [
"email"
]
}
],
"properties" : {
"email" : {
"$ref" : "common.json#/$defs/email_address"
},
"password" : {
"$ref" : "common.json#/$defs/non_empty_string"
},
"set_session" : {
"type" : "boolean"
},
"user_id" : {
"$ref" : "common.json#/$defs/uuid"
}
},
"required" : [
"password"
],
"type" : "object"
"type" : "object",
"unevaluatedProperties" : false
},
"NewUser" : {
"additionalProperties" : false,
Expand Down Expand Up @@ -688,62 +635,26 @@
"type" : "null"
},
"OrganizationAddUser" : {
"additionalProperties" : false,
"oneOf" : [
{
"required" : [
"user_id"
]
},
{
"required" : [
"email"
]
}
],
"$ref" : "#/$defs/UserIdOrEmail",
"properties" : {
"email" : {
"$ref" : "common.json#/$defs/email_address"
},
"role" : {
"$ref" : "common.json#/$defs/role"
},
"user_id" : {
"$ref" : "common.json#/$defs/uuid"
}
},
"required" : [
"role"
],
"type" : "object"
"type" : "object",
"unevaluatedProperties" : false
},
"OrganizationCreate" : {
"additionalProperties" : false,
"properties" : {
"admins" : {
"items" : {
"additionalProperties" : false,
"oneOf" : [
{
"required" : [
"user_id"
]
},
{
"required" : [
"email"
]
}
],
"properties" : {
"email" : {
"$ref" : "common.json#/$defs/email_address"
},
"user_id" : {
"$ref" : "common.json#/$defs/uuid"
}
},
"type" : "object"
"$ref" : "#/$defs/UserIdOrEmail",
"type" : "object",
"unevaluatedProperties" : false
},
"minItems" : 1,
"type" : "array",
Expand Down Expand Up @@ -1141,7 +1052,7 @@
},
"minProperties" : 1,
"propertyNames" : {
"$ref" : "common.json#/$defs/user_setting_key"
"$ref" : "common.json#/$defs/setting_key"
},
"type" : "object"
}
Expand Down
4 changes: 2 additions & 2 deletions docs/json-schema/response.json
Expand Up @@ -1160,7 +1160,7 @@
"type" : "string"
},
"propertyNames" : {
"$ref" : "common.json#/$defs/device_setting_key"
"$ref" : "common.json#/$defs/setting_key"
},
"type" : "object"
},
Expand Down Expand Up @@ -2574,7 +2574,7 @@
"type" : "string"
},
"propertyNames" : {
"$ref" : "common.json#/$defs/user_setting_key"
"$ref" : "common.json#/$defs/setting_key"
},
"type" : "object"
},
Expand Down
4 changes: 1 addition & 3 deletions json-schema/common.yaml
Expand Up @@ -45,16 +45,14 @@ $defs:
type: string
pattern: ^\S+$
$ref: '#/$defs/mojo_relaxed_placeholder'
device_setting_key:
setting_key:
$ref: '#/$defs/mojo_relaxed_placeholder'
disk_serial_number:
type: string
pattern: ^\S+$
room_az:
type: string
pattern: ^[\w-]+$
user_setting_key:
$ref: '#/$defs/mojo_relaxed_placeholder'
role:
$comment: corresponds to role_enum in the database
enum:
Expand Down
5 changes: 4 additions & 1 deletion json-schema/query_params.yaml
Expand Up @@ -89,7 +89,7 @@ $defs:
type: string
format: uri
propertyNames:
$ref: common.yaml#/$defs/device_setting_key
$ref: common.yaml#/$defs/setting_key
additionalProperties:
type: string
GetValidationState:
Expand Down Expand Up @@ -130,6 +130,9 @@ $defs:
const: 0
completed:
const: 1
GetBuild:
$ref: '#/$defs/WithDeviceRackData'
unevaluatedProperties: false
WithDeviceRackData:
type: object
additionalProperties: true # used in non-terminal action: other parameters checked later
Expand Down

0 comments on commit 820dc61

Please sign in to comment.