Skip to content

Commit

Permalink
Add nested json schema example
Browse files Browse the repository at this point in the history
  • Loading branch information
vdespa committed Dec 28, 2019
1 parent abe53da commit 73c462f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# The short X.Y version
version = u''
# The full version, including alpha/beta/rc tags
release = u'Version 1.5.0 - December 2019'
release = u'Version 1.5.1 - December 2019'


# -- General configuration ---------------------------------------------------
Expand Down
33 changes: 31 additions & 2 deletions docs/schema-validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,47 @@ Possible types are:
Object has required property
----------------------------

This is the JSON response: ::
Given this JSON response: ::

{
"code": "FX002"
}

This is the JSON schema with a property named code of type String that is mandatory: ::
This is the JSON schema with a property named "code" of type String that is mandatory: ::

const schema = {
"type": "object",
"properties": {
"code": { "type": "string" }
},
"required": ["code"]
};

Nested objects
--------------

Given this JSON response: ::

{
"code": "2",
"error": {
"message": "Not permitted."
}
}

This is the JSON schema with the an nested object named "error" that has a property named "message" that is a string. ::

const schema = {
"type": "object",
"properties": {
"code": { "type": "string" },
"error": {
"type": "object",
"properties": {
"message": { type: "string" }
},
"required": ["message"]
}
},
"required": ["code", "error"]
};

0 comments on commit 73c462f

Please sign in to comment.