Skip to content

Instantly share code, notes, and snippets.

@panSarin
Last active May 12, 2016 13:34
Show Gist options
  • Save panSarin/6a7efcdd503a315d21fcf38213d560cc to your computer and use it in GitHub Desktop.
Save panSarin/6a7efcdd503a315d21fcf38213d560cc to your computer and use it in GitHub Desktop.
nested schema validation example
{
"swagger": "2.0",
"info": { "version": "0.0.0.0.1", "title": "Users API endpoints"},
"paths": {
"/user_settings": {
"get": {
"description": "User settings",
"parameters": [
{
"in": "query",
"name": "auth_token",
"description": "user token",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "Successful response",
"schema": {
"$ref": "#/definitions/user_settings_response"
}
}
}
}
}
},
"definitions": {
"user_settings_response": {
"description": "User settings",
"type": "object",
"properties": {
"id": {"type": "string", "example": "567bc35c5605f67f41000026"},
"ios_landing_page": {"type": "string", "example": "Hello"},
"units": {
"type": "array",
"items": { "$ref": "#/definitions/unit" }
}
}
},
"unit": {
"type": "object",
"required": ["facility", "test"],
"properties": {
"id": {"type": "string", "example": "567bc35c5605f67f41000026"},
"facility": {"type": "string", "example": "Common Facility"},
"_id": {"type": "string", "example": "567bc35c5605f67f41000026"},
"name": {"type": "string", "example": "1A"}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment