Skip to content

Instantly share code, notes, and snippets.

@raedatoui
Created May 4, 2012 21:26
Show Gist options
  • Save raedatoui/2597831 to your computer and use it in GitHub Desktop.
Save raedatoui/2597831 to your computer and use it in GitHub Desktop.
Swagger nested resources
//resources.json
{
"apiVersion": "0.1",
"apis": [
{
"description": "Operations about projects",
"path": "/project.{format}"
},
{
"description": "Operations about tickets",
"path": "/ticket.{format}"
}
],
"basePath": "http://localhost:3000",
"swaggerVersion": "1.0"
}
//project.json
{
"apiVersion": "0.1",
"apis": [
{
"description": "Operations about projects",
"operations": [
{
"errorResponses": [
{
"code": 400,
"reason": "Invalid ID supplied"
},
{
"code": 404,
"reason": "Project not found"
}
],
"httpMethod": "GET",
"nickname": "getProjectById",
"notes": "Returns a project when ID > 0.",
"parameters": [
{
"allowMultiple": false,
"allowableValues": {
"max": 10.0,
"min": 1.0,
"valueType": "RANGE"
},
"dataType": "string",
"description": "ID of project that needs to be fetched",
"name": "projectId",
"paramType": "path",
"required": true
}
],
"responseClass": "project",
"summary": "Find project by ID"
}
],
"path": "/projects/{projectId}"
},
],
"basePath": "http://localhost:3000",
"models": {
},
"resourcePath": "/projects",
"swaggerVersion": "1.0"
}
//ticket.json
{
"apiVersion": "0.1",
"apis": [
{
"description": "Operations about tickets",
"operations": [
{
"errorResponses": [
{
"code": 400,
"reason": "Invalid ID supplied"
},
{
"code": 404,
"reason": "Ticket not found"
}
],
"httpMethod": "GET",
"nickname": "getTicketById",
"notes": "Returns a project when ID > 0.",
"parameters": [
{
"allowMultiple": false,
"allowableValues": {
"max": 10.0,
"min": 1.0,
"valueType": "RANGE"
},
"dataType": "string",
"description": "ID of project that needs to be fetched",
"name": "projectId",
"paramType": "path",
"required": true
},
{
"allowMultiple": false,
"allowableValues": {
"max": 10.0,
"min": 1.0,
"valueType": "RANGE"
},
"dataType": "string",
"description": "ID of ticket that needs to be fetched",
"name": "ticketId",
"paramType": "path",
"required": true
}
],
"responseClass": "ticket",
"summary": "Find project by ID"
}
],
"path": "/projects/{projectId}/tickets/{ticketId}"
}
],
"basePath": "http://localhost:3000/",
"models": {
},
"resourcePath": "/tickets",
"swaggerVersion": "1.0"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment