Skip to content

Instantly share code, notes, and snippets.

@adfinlay
Created April 24, 2018 10:30
Show Gist options
  • Save adfinlay/e797691536644f72d8b6e4668074e8ac to your computer and use it in GitHub Desktop.
Save adfinlay/e797691536644f72d8b6e4668074e8ac to your computer and use it in GitHub Desktop.
swagger.json
{
"openapi" : "3.0.0",
"info" : {
"description" : "Test API for retrieving information",
"version" : "1.0.0",
"title" : "Test API"
},
"paths" : {
"/articles" : {
"get" : {
"tags" : [ "Articles" ],
"summary" : "Retrieve a list of articles",
"operationId" : "listArticles",
"parameters" : [ {
"in" : "query",
"name" : "limit",
"description" : "specify the maximum number of articles to return",
"required" : true,
"schema" : {
"type" : "integer",
"format" : "int32",
"minimum" : 0,
"maximum" : 50
}
} ],
"responses" : {
"200" : {
"description" : "List of articles",
"content" : {
"application/json" : {
"schema" : {
"type" : "array",
"items" : {
"$ref" : "#/components/schemas/BasicArticle"
}
}
}
}
}
}
}
},
"/articles/{uuid}" : {
"get" : {
"tags" : [ "Articles" ],
"parameters" : [ {
"name" : "uuid",
"in" : "path",
"description" : "Article UUID",
"required" : true,
"schema" : {
"type" : "string",
"format" : "uuid"
}
} ],
"summary" : "Retrieve a specific article",
"operationId" : "getArticle",
"responses" : {
"200" : {
"description" : "Details of article",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Article"
}
}
}
},
"404" : {
"$ref" : "#/components/responses/NotFound"
}
}
}
}
},
"components" : {
"responses" : {
"NotFound" : {
"description" : "The specified resource was not found",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Error"
}
}
}
}
},
"schemas" : {
"Error" : {
"type" : "object",
"properties" : {
"code" : {
"type" : "integer"
},
"error" : {
"type" : "string"
}
}
},
"Content" : {
"allOf" : [ {
"type" : "object",
"properties" : {
"id" : {
"type" : "integer"
},
"title" : {
"type" : "string"
},
"url" : {
"type" : "string",
"format" : "uri",
"description" : "Link to the content on the website"
},
"thumbnail" : {
"type" : "string",
"format" : "uri",
"description" : "Link to the thumbnail image for the content"
},
"author" : {
"$ref" : "#/components/schemas/User"
},
"datetime" : {
"type" : "string",
"format" : "date-time",
"description" : "Date/time of content publication"
},
"content_type" : {
"type" : "string",
"description" : "Content type for use in e.g. content reporting"
},
"vote_points" : {
"type" : "integer",
"description" : "Number of points the content has earned through user votes"
}
}
} ]
},
"BasicArticle" : {
"example" : {
"$ref" : "#/components/examples/BasicArticle"
},
"allOf" : [ {
"$ref" : "#/components/schemas/Content"
}, {
"type" : "object",
"properties" : {
"summary" : {
"type" : "string",
"format" : "html",
"description" : "Article summary"
}
}
} ]
},
"Article" : {
"example" : {
"$ref" : "#/components/examples/Article"
},
"allOf" : [ {
"$ref" : "#/components/schemas/Content"
}, {
"$ref" : "#/components/schemas/BasicArticle"
}, {
"type" : "object",
"properties" : {
"content" : {
"type" : "string",
"format" : "html",
"description" : "Article content (HTML)"
}
}
} ]
},
"User" : {
"example" : {
"$ref" : "#/components/examples/User"
},
"properties" : {
"id" : {
"type" : "integer"
},
"uuid" : {
"type" : "string",
"format" : "uuid"
},
"username" : {
"type" : "string"
},
"avatar" : {
"type" : "string",
"format" : "uri"
}
},
"type" : "object"
}
},
"examples" : {
"BasicArticle" : {
"id" : 42,
"title" : "Best Article Ever",
"url" : "https://www.example.com/article/42",
"author" : {
"$ref" : "#/components/examples/User"
},
"datetime" : "2018-04-01 18:42:01Z",
"content_type" : "Article",
"vote_points" : 42,
"summary" : "This is the article summary"
},
"Article" : {
"id" : 42,
"title" : "Best Article Ever",
"url" : "https://www.example.com/article/42",
"author" : {
"$ref" : "#/components/examples/User"
},
"datetime" : "2018-04-01 18:42:01Z",
"content_type" : "Article",
"vote_points" : 42,
"content" : "<p>This is the article content</p>"
},
"User" : {
"id" : 42,
"uuid" : "88b6a469-d0dc-448f-8aec-28621e5f205d",
"username" : "user_1",
"avatar" : "http://www.fillmurray.com/100/100"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment