Skip to content

Instantly share code, notes, and snippets.

@hawkz
Created April 10, 2021 15:18
Show Gist options
  • Save hawkz/78511c463b638942996bad80ada2324b to your computer and use it in GitHub Desktop.
Save hawkz/78511c463b638942996bad80ada2324b to your computer and use it in GitHub Desktop.
{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"title": "Shared Service Layer - Search",
"description": "The api for the Search Project"
},
"paths": {
"/search/v1/location": {
"post": {
"summary" : "Add a new location to the search index",
"operationId": "addLocationToSearchIndex",
"consumes": [ "application/json" ],
"produces": [ "application/json" ],
"security" : [
{
"apiKeyAuth" : []
}
],
"parameters": [
],
"requestBody" : {
"required" : true,
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Place"
}
}
}
},
"responses": {
"201": {
"$ref" : "#/components/responses/201"
},
"400": {
"$ref" : "#/components/responses/400"
},
"500": {
"$ref" : "#/components/responses/500"
}
}
},
"get": {
"summary" : "Retrieve a location from the search index",
"operationId": "getLocationFromSearchIndex",
"consumes": [ "application/json" ],
"produces": [ "application/json" ],
"parameters": [
{
"in" : "query",
"name" : "searchType",
"description" : "The type of geo search you want to perform: radial for \"as the crow flies\", and city for searches in that city only",
"schema" : {
"type" : "string",
"enum" : ["radial","city"]
},
"required" : true
},
{
"in" : "query",
"name" : "postcode",
"description" : "The postcode to search from",
"schema" : {
"type" : "string",
"minLength" : 4,
"maxLength" : 10
},
"required" : true
},
{
"in" : "query",
"name" : "results",
"description" : "Number of results per page",
"schema" : {
"type" : "number",
"format": "integer",
"minimum" : 0,
"maxLength" : 1000,
"default" : 10
},
"required" : false
},
{
"in" : "query",
"name" : "page",
"description" : "The page of results to return",
"schema" : {
"type" : "number",
"format": "integer",
"minimum" : 0,
"maxLength" : 1000,
"default" : 0
},
"required" : false
}
],
"responses": {
"200": {
"$ref" : "#/components/responses/200"
},
"400": {
"$ref" : "#/components/responses/400"
},
"500": {
"$ref" : "#/components/responses/500"
}
}
}
},
"/search/v1/location/{id}": {
"put": {
"summary" : "Update a location in the search index",
"operationId": "updateLocationInSearchIndex",
"consumes": [ "application/json" ],
"produces": [ "application/json" ],
"security" : [
{
"apiKeyAuth" : []
}
],
"parameters": [
{
"name" : "id",
"in" : "path",
"required" : true,
"schema" : {
"type" : "string",
"example" : "100-100-1"
}
}
],
"requestBody" : {
"required" : true,
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Place"
}
}
}
},
"responses": {
"200": {
"$ref" : "#/components/responses/200"
},
"400": {
"$ref" : "#/components/responses/400"
},
"500": {
"$ref" : "#/components/responses/500"
}
}
},
"delete": {
"summary" : "Delete a location in the search index",
"operationId": "deleteLocationInSearchIndex",
"consumes": [ "application/json" ],
"produces": [ "application/json" ],
"security" : [
{
"apiKeyAuth" : []
}
],
"parameters": [
{
"name" : "id",
"in" : "path",
"required" : true,
"schema" : {
"type" : "string",
"example" : "100-100-1"
}
}
],
"responses": {
"200": {
"$ref" : "#/components/responses/200"
},
"400": {
"$ref" : "#/components/responses/400"
},
"500": {
"$ref" : "#/components/responses/500"
}
}
}
},
"/search/v1/article": {
"post": {
"summary" : "Add a new article to the search index",
"operationId": "addArticleToSearchIndex",
"consumes": [ "application/json" ],
"produces": [ "application/json" ],
"security" : [
{
"apiKeyAuth" : []
}
],
"parameters": [
],
"requestBody" : {
"required" : true,
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Article"
}
}
}
},
"responses": {
"201": {
"$ref" : "#/components/responses/201"
},
"400": {
"$ref" : "#/components/responses/400"
},
"500": {
"$ref" : "#/components/responses/500"
}
}
},
"get": {
"summary" : "Retrieve an article from the search index",
"operationId": "getArticleFromSearchIndex",
"consumes": [ "application/json" ],
"produces": [ "application/json" ],
"parameters": [
{
"in" : "query",
"name" : "query",
"description" : "Full text search of the article",
"schema" : {
"type" : "string"
},
"required" : true
},
{
"in" : "query",
"name" : "results",
"description" : "Number of results per page",
"schema" : {
"type" : "number",
"format": "integer",
"minimum" : 0,
"maxLength" : 1000,
"default" : 10
},
"required" : false
},
{
"in" : "query",
"name" : "page",
"description" : "The page of results to return",
"schema" : {
"type" : "number",
"format": "integer",
"minimum" : 0,
"maxLength" : 1000,
"default" : 0
},
"required" : false
}
],
"responses": {
"200": {
"$ref" : "#/components/responses/200"
},
"400": {
"$ref" : "#/components/responses/400"
},
"500": {
"$ref" : "#/components/responses/500"
}
}
}
},
"/search/v1/article/{id}": {
"put": {
"summary" : "Update an article in the search index",
"operationId": "updateArticleInSearchIndex",
"consumes": [ "application/json" ],
"produces": [ "application/json" ],
"security" : [
{
"apiKeyAuth" : []
}
],
"parameters": [
{
"name" : "id",
"in" : "path",
"required" : true,
"schema" : {
"type" : "string",
"example" : "100-100-1"
}
}
],
"requestBody" : {
"required" : true,
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Article"
}
}
}
},
"responses": {
"200": {
"$ref" : "#/components/responses/200"
},
"400": {
"$ref" : "#/components/responses/400"
},
"500": {
"$ref" : "#/components/responses/500"
}
}
},
"delete": {
"summary" : "Delete an article in the search index",
"operationId": "deleteArticleInSearchIndex",
"consumes": [ "application/json" ],
"produces": [ "application/json" ],
"security" : [
{
"apiKeyAuth" : []
}
],
"parameters": [
{
"name" : "id",
"in" : "path",
"required" : true,
"schema" : {
"type" : "string",
"example" : "100-100-1"
}
}
],
"responses": {
"200": {
"$ref" : "#/components/responses/200"
},
"400": {
"$ref" : "#/components/responses/400"
},
"500": {
"$ref" : "#/components/responses/500"
}
}
}
}
},
"components": {
"securitySchemes" : {
"bearerAuth" : {
"type" : "http",
"scheme" : "bearer",
"bearerFormat" : "jwt",
"in" : "header",
"description" : "Bearer: <TOKEN>"
},
"apiKeyAuth" : {
"type" : "apiKey",
"in" : "header",
"name" : "X-API-Key"
}
},
"responses" : {
"200" : {
"description": "Success",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/GenericResponseObject"
}
}
}
},
"201" : {
"description": "Created",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/GenericResponseObject"
}
}
}
},
"400": {
"description": "Client error",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/GenericResponseObject"
}
}
}
},
"500": {
"description": "Server error",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/GenericResponseObject"
}
}
}
}
},
"schemas" : {
"Place" : {
"type" : "object",
"properties" : {
"@context" : {
"type" : "string",
"const" : "https://schema.org",
"example": "https://schema.org"
},
"@type" : {
"type" : "string",
"const" : "Place",
"example": "Place"
},
"identifier" : {
"type" : "string",
"example": "500-100-1",
"description" : "The ID of the object that can be used to update it in the search index"
},
"address" : {
"type" : "object",
"properties" : {
"@type" : {
"type" : "string",
"const" : "PostalAddress",
"example": "PostalAddress"
},
"streetAddress" : {
"type" : "string",
"example": "Great Russell Street"
},
"addressRegion" : {
"type" : "string",
"example": "London"
},
"addressLocality" : {
"type" : "string",
"example": "London"
},
"addressCountry" : {
"type" : "string",
"example": "UK"
},
"latitude" : {
"type" : "number",
"format": "double",
"example": 51.5428548,
"minimum" : -90,
"maximum" : 90
},
"longitude" : {
"type" : "number",
"format": "double",
"example": -0.1625090986157582,
"minimum" : -180,
"maximum" : 180
}
},
"required" : ["@type","streetAddress","addressRegion","addressCountry","addressLocality","latitude","longitude"]
},
"description" : {
"type" : "string",
"example": "Description of location"
},
"photo" : {
"type" : "object",
"properties" : {
"@type" : {
"type" : "string",
"const" : "ImageObject",
"example": "ImageObject"
},
"contentUrl" : {
"type" : "string",
"format" : "uri",
"example": "https://myimage.com/image.png"
},
"description" : {
"type" : "string",
"example": "Description for image"
}
},
"required" : ["@type","contentUrl","description"]
},
"url" : {
"type" : "string",
"format" : "uri",
"example": "https://my-location.com"
},
"maximumAttendeeCapacity" : {
"type" : "integer",
"format" : "int32",
"example": "20",
"minimum" : 0
},
"aggregateRating" : {
"$ref" : "#/components/schemas/AggregateRating"
},
"openingHoursSpecification" : {
"type" : "array",
"items" : {
"type" : "object",
"properties" : {
"@type" : {
"type" : "string",
"const" : "OpeningHoursSpecification",
"example": "OpeningHoursSpecification"
},
"opens" : {
"type" : "string",
"example": "09:00:00"
},
"closes" : {
"type" : "string",
"example": "17:00:00"
},
"dayOfWeek" : {
"type" : "string",
"example": "https://schema.org/Saturday",
"enum" : [
"https://schema.org/Monday",
"https://schema.org/Tuesday",
"https://schema.org/Wednesday",
"https://schema.org/Thursday",
"https://schema.org/Friday",
"https://schema.org/Saturday",
"https://schema.org/Sunday"
]
}
},
"required" : ["@type","opens","closes","dayOfWeek"]
}
}
},
"required" : ["@context","address","@type"]
},
"Article" : {
"type" : "object",
"properties" : {
"@context" : {
"type" : "string",
"const" : "https://schema.org",
"example": "https://schema.org"
},
"@type" : {
"type" : "string",
"const" : "Article",
"example": "Article"
},
"identifier" : {
"type" : "string",
"example": "500-100-1",
"description" : "The ID of the object that can be used to update it in the search index"
},
"author" : {
"type" : "string",
"example": "Author"
},
"abstract" : {
"type" : "string",
"example": "Abstract"
},
"articleBody" : {
"type" : "string",
"example": "Full body for text search"
},
"publisher" : {
"type" : "string",
"example": "Publisher"
},
"aggregateRating" : {
"$ref" : "#/components/schemas/AggregateRating"
},
"datePublished" : {
"type" : "string",
"format" : "date",
"example": "2009-05-08"
},
"thumbnailUrl" : {
"type" : "string",
"format" : "uri",
"example": "http://image.com/image.png"
},
"keywords" : {
"type" : "array",
"items" : {
"type" : "string",
"example": "keyword 1"
}
},
"hasPart" : {
"type" : "array",
"items" : {
"$ref" : "#/components/schemas/CreativeWork"
}
}
},
"required" : ["@context","@type","articleBody"]
},
"AggregateRating" : {
"type" : "object",
"properties" : {
"@type" : {
"type" : "string",
"const" : "AggregateRating",
"example": "AggregateRating"
},
"ratingValue" : {
"type" : "number",
"format" : "double",
"example": 4.5,
"minium" : 0
},
"reviewCount" : {
"type" : "integer",
"format" : "int32",
"example": 250,
"minium" : 0
}
},
"required" : ["@type","ratingValue"]
},
"MediaObject" : {
"properties" : {
"@type" : {
"type" : "string",
"const" : "MediaObject",
"example": "MediaObject"
},
"encodingFormat" : {
"type" : "string",
"examples": ["video/mp4","audio/mpeg","application/pdf","image/png"],
"description" : "MIME type"
},
"contentUrl" : {
"type" : "string",
"format" : "uri",
"example": "https://video.com/video.mp4"
},
"thumbnail" : {
"type" : "string",
"format" : "uri",
"example": "https://video.com/thumbnail.png"
}
},
"required" : ["@type","encodingFormat", "contentUrl"]
},
"CreativeWork" : {
"type" : "object",
"properties" : {
"@type" : {
"type" : "string",
"const" : "CreativeWork",
"example": "CreativeWork"
},
"encoding" : {
"$ref" : "#/components/schemas/MediaObject"
}
},
"required" : ["@type", "encoding"]
},
"GenericResponseObject" : {
"type" : "object",
"properties" : {
"version" : {
"type" : "string",
"example" : "1.0.0"
},
"links" : {
"description" : "Key value HAL links",
"example" : "{\"self\" : \"https://\"}",
"type" : "object",
"properties" : {
},
"required" : ["key", "value"],
"nullable": true
},
"meta" : {
"type" : "object",
"properties" : {
"error" : {
"type" : "object",
"properties" : {
"status_code" : {
"type" : "integer",
"example" : 200,
"minimum" : 100,
"maximum" : 1000
},
"error_type" : {
"type" : "string",
"example" : "[ERROR200]"
},
"error_message" : {
"type" : "string",
"example" : "Incorrect data"
}
},
"required" : ["status_code", "error_type","error_message"],
"nullable": true
},
"pagination" : {
"type" : "object",
"properties" : {
"per_page" : {
"type" : "integer",
"example" : 10,
"minimum" : 0,
"description" : "Number of results per page"
},
"total_pages" : {
"type" : "integer",
"example" : 10,
"minimum" : 0,
"description" : "Total number of pages of data"
},
"total_entries" : {
"type" : "integer",
"example" : 10,
"minimum" : 0,
"description" : "Total number of data objects available for this query"
},
"first_page" : {
"type" : "string",
"example" : "https://api.page.com/page/2?per_page=10",
"description" : "The API endpoint to call to get the first page set"
},
"last_page" : {
"type" : "string",
"example" : "https://api.page.com/page/10?per_page=10",
"description" : "The API endpoint to call to get the last page set"
},
"next_page" : {
"type" : "string",
"example" : "https://api.page.com/page/3?per_page=10",
"description" : "The API endpoint to call to get the next page set"
},
"prev_page" : {
"type" : "string",
"example" : "https://api.page.com/page/1?per_page=10",
"description" : "The API endpoint to call to get the previous page set"
}
},
"required" : ["per_page", "total_pages","total_entries","first_page", "last_page","next_page","prev_page"],
"nullable": true
}
},
"required" : ["error","pagination"]
},
"data" : {
"type" : "array",
"description" : "Always an array - even for single results",
"items" : {
"oneOf" : [
{"$ref" : "#/components/schemas/Place"},
{"$ref" : "#/components/schemas/Article"}
],
"discriminator" : {
"propertyName" : "@type"
}
}
}
},
"required" : ["version","links", "meta", "data"]
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment