{
  "openapi": "3.1.1",
  "info": {
    "title": "List79 client API",
    "description": "For your own interface, from the browser. Send your product's public key as \"X-List79-Key: pk_…\" and, to vote, suggest or comment, a user token your server signs with the widget secret as \"Authorization: Bearer …\". The JavaScript package @list79/client wraps it.",
    "version": "v1"
  },
  "servers": [
    {
      "url": "https://list79.com"
    }
  ],
  "paths": {
    "/client/v1/me": {
      "get": {
        "tags": [
          "Client"
        ],
        "summary": "The product, and the signed-in user if a valid user token came with the call.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MeOutput"
                }
              }
            }
          }
        }
      }
    },
    "/client/v1/requests": {
      "get": {
        "tags": [
          "Client"
        ],
        "summary": "Requests, with paging. filter: popular (open, most-voted first; the default), new, planned (planned and in progress), shipped, or mine (suggested or voted for by the user).",
        "parameters": [
          {
            "name": "filter",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 0
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientRequestList"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Client"
        ],
        "summary": "Suggest a request as the signed-in user. Their vote is added.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SuggestInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientRequest"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/client/v1/requests/{number}": {
      "get": {
        "tags": [
          "Client"
        ],
        "summary": "One request. A merged request has mergedInto set; show that one instead.",
        "parameters": [
          {
            "name": "number",
            "in": "path",
            "required": true,
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientRequest"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          }
        }
      }
    },
    "/client/v1/requests/{number}/vote": {
      "post": {
        "tags": [
          "Client"
        ],
        "summary": "Vote as the signed-in user. Voting twice is harmless; a vote on a merged request goes to the request it was merged into.",
        "parameters": [
          {
            "name": "number",
            "in": "path",
            "required": true,
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientVote"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          }
        }
      },
      "delete": {
        "tags": [
          "Client"
        ],
        "summary": "Take the signed-in user's vote back.",
        "parameters": [
          {
            "name": "number",
            "in": "path",
            "required": true,
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientVote"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          }
        }
      }
    },
    "/client/v1/requests/{number}/comments": {
      "get": {
        "tags": [
          "Client"
        ],
        "summary": "A request's public comments, oldest first.",
        "parameters": [
          {
            "name": "number",
            "in": "path",
            "required": true,
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ClientComment"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          }
        }
      },
      "post": {
        "tags": [
          "Client"
        ],
        "summary": "Comment as the signed-in user.",
        "parameters": [
          {
            "name": "number",
            "in": "path",
            "required": true,
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CommentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientComment"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ClientComment": {
        "required": [
          "id",
          "body",
          "authorName",
          "team",
          "mine",
          "createdAt"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "body": {
            "type": "string"
          },
          "authorName": {
            "type": [
              "null",
              "string"
            ]
          },
          "team": {
            "type": "boolean"
          },
          "mine": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ClientProduct": {
        "required": [
          "name",
          "language",
          "portalUrl",
          "names"
        ],
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "language": {
            "type": [
              "null",
              "string"
            ]
          },
          "portalUrl": {
            "type": [
              "null",
              "string"
            ]
          },
          "names": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          }
        }
      },
      "ClientRequest": {
        "required": [
          "number",
          "title",
          "body",
          "status",
          "votes",
          "voted",
          "mine",
          "comments",
          "authorName",
          "reason",
          "mergedInto",
          "createdAt",
          "updatedAt"
        ],
        "type": "object",
        "properties": {
          "number": {
            "type": "integer",
            "format": "int32"
          },
          "title": {
            "type": "string"
          },
          "body": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/RequestStatus"
          },
          "votes": {
            "type": "integer",
            "format": "int32"
          },
          "voted": {
            "type": "boolean"
          },
          "mine": {
            "type": "boolean"
          },
          "comments": {
            "type": "integer",
            "format": "int32"
          },
          "authorName": {
            "type": [
              "null",
              "string"
            ]
          },
          "reason": {
            "type": [
              "null",
              "string"
            ]
          },
          "mergedInto": {
            "type": [
              "null",
              "integer"
            ],
            "format": "int32"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ClientRequestList": {
        "required": [
          "items",
          "total",
          "offset",
          "limit"
        ],
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientRequest"
            }
          },
          "total": {
            "type": "integer",
            "format": "int32"
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          }
        }
      },
      "ClientUser": {
        "required": [
          "id",
          "name",
          "language"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": [
              "null",
              "string"
            ]
          },
          "language": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "ClientVote": {
        "required": [
          "number",
          "votes",
          "voted"
        ],
        "type": "object",
        "properties": {
          "number": {
            "type": "integer",
            "format": "int32"
          },
          "votes": {
            "type": "integer",
            "format": "int32"
          },
          "voted": {
            "type": "boolean"
          }
        }
      },
      "CommentInput": {
        "required": [
          "body"
        ],
        "type": "object",
        "properties": {
          "body": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "HttpValidationProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": [
              "null",
              "string"
            ]
          },
          "title": {
            "type": [
              "null",
              "string"
            ]
          },
          "status": {
            "type": [
              "null",
              "integer"
            ],
            "format": "int32"
          },
          "detail": {
            "type": [
              "null",
              "string"
            ]
          },
          "instance": {
            "type": [
              "null",
              "string"
            ]
          },
          "errors": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      },
      "MeOutput": {
        "required": [
          "product",
          "user"
        ],
        "type": "object",
        "properties": {
          "product": {
            "$ref": "#/components/schemas/ClientProduct"
          },
          "user": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/ClientUser"
              }
            ]
          }
        }
      },
      "RequestStatus": {
        "enum": [
          "new",
          "underReview",
          "planned",
          "inProgress",
          "shipped",
          "declined",
          "merged"
        ]
      },
      "SuggestInput": {
        "required": [
          "title",
          "body"
        ],
        "type": "object",
        "properties": {
          "title": {
            "type": [
              "null",
              "string"
            ]
          },
          "body": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      }
    },
    "securitySchemes": {
      "publicKey": {
        "type": "apiKey",
        "description": "Your product's public key (pk_… or pk_test_…). Safe in browser code.",
        "name": "X-List79-Key",
        "in": "header"
      },
      "userToken": {
        "type": "http",
        "description": "The signed-in user: an HS256 JWT your server signs with the widget secret (sub, exp; optional email, name, locale). Needed to vote, suggest and comment.",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
  },
  "security": [
    {
      "publicKey": [ ],
      "userToken": [ ]
    },
    {
      "publicKey": [ ]
    }
  ],
  "tags": [
    {
      "name": "Client"
    }
  ]
}