{
  "openapi": "3.1.0",
  "info": {
    "title": "OceanWay Core token read slice",
    "version": "0.1.0-draft"
  },
  "x-status": "local_identity_configured",
  "x-source-commit": "385d2dfd10d821b25c8a6766bd16eea248cb1652",
  "x-authentication": "Core access JWT and live database session required; full key retrieval requires allowed Origin, per-user rate limit and committed audit. Global cross-site handoff pending.",
  "paths": {
    "/api/token/": {
      "get": {
        "operationId": "GetAllTokens",
        "x-source-file": "controller/token.go",
        "responses": {
          "200": {
            "description": "Success or upstream-style business failure (inspect success).",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "const": "no-store"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ListSuccess"
                    },
                    {
                      "$ref": "#/components/schemas/Error"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Authentication/origin/internal error (AUTH_* middleware code or handler failure).",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/AuthError"
                    },
                    {
                      "$ref": "#/components/schemas/Error"
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Authentication/origin/internal error (AUTH_* middleware code or handler failure).",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/AuthError"
                    },
                    {
                      "$ref": "#/components/schemas/Error"
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Authentication/origin/internal error (AUTH_* middleware code or handler failure).",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/AuthError"
                    },
                    {
                      "$ref": "#/components/schemas/Error"
                    }
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "p",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Page; missing, malformed or nonpositive becomes 1."
          },
          {
            "name": "page_size",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Preferred size; zero or malformed falls back to ps then size. Negative becomes 10. Above 100 caps at 100."
          },
          {
            "name": "ps",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Legacy size alias."
          },
          {
            "name": "size",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Legacy token page size alias. Final default 10."
          }
        ]
      }
    },
    "/api/token/{id}": {
      "get": {
        "operationId": "GetToken",
        "x-source-file": "controller/token.go",
        "responses": {
          "200": {
            "description": "Success or upstream-style business failure (inspect success).",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "const": "no-store"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/DetailSuccess"
                    },
                    {
                      "$ref": "#/components/schemas/Error"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Authentication/origin/internal error (AUTH_* middleware code or handler failure).",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/AuthError"
                    },
                    {
                      "$ref": "#/components/schemas/Error"
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Authentication/origin/internal error (AUTH_* middleware code or handler failure).",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/AuthError"
                    },
                    {
                      "$ref": "#/components/schemas/Error"
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Authentication/origin/internal error (AUTH_* middleware code or handler failure).",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/AuthError"
                    },
                    {
                      "$ref": "#/components/schemas/Error"
                    }
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ]
      }
    },
    "/api/token/{id}/key": {
      "post": {
        "operationId": "GetTokenKey",
        "x-source-file": "controller/token.go",
        "responses": {
          "200": {
            "description": "Success or upstream-style business failure (inspect success).",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "const": "no-store"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/KeySuccess"
                    },
                    {
                      "$ref": "#/components/schemas/Error"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Authentication/origin/internal error (AUTH_* middleware code or handler failure).",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/AuthError"
                    },
                    {
                      "$ref": "#/components/schemas/Error"
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Authentication/origin/internal error (AUTH_* middleware code or handler failure).",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/AuthError"
                    },
                    {
                      "$ref": "#/components/schemas/Error"
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Authentication/origin/internal error (AUTH_* middleware code or handler failure).",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/AuthError"
                    },
                    {
                      "$ref": "#/components/schemas/Error"
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Per-user key retrieval limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthError"
                }
              }
            }
          },
          "503": {
            "description": "Required reveal audit not configured; fail closed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "MaskedToken": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "user_id": {
            "type": "integer"
          },
          "status": {
            "type": "integer"
          },
          "created_time": {
            "type": "integer"
          },
          "accessed_time": {
            "type": "integer"
          },
          "expired_time": {
            "type": "integer"
          },
          "remain_quota": {
            "type": "integer"
          },
          "used_quota": {
            "type": "integer"
          },
          "key": {
            "type": "string",
            "description": "Masked in list/detail. Full value only in explicit key retrieval response."
          },
          "name": {
            "type": "string"
          },
          "model_limits": {
            "type": "string"
          },
          "group": {
            "type": "string"
          },
          "unlimited_quota": {
            "type": "boolean"
          },
          "model_limits_enabled": {
            "type": "boolean"
          },
          "cross_group_retry": {
            "type": "boolean"
          },
          "allow_ips": {
            "type": [
              "string",
              "null"
            ]
          },
          "DeletedAt": {
            "type": [
              "string",
              "null"
            ],
            "description": "Upstream GORM field casing retained; active rows return null."
          },
          "auto_groups": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "id",
          "user_id",
          "status",
          "created_time",
          "accessed_time",
          "expired_time",
          "remain_quota",
          "used_quota",
          "key",
          "name",
          "model_limits",
          "group",
          "unlimited_quota",
          "model_limits_enabled",
          "cross_group_retry",
          "allow_ips",
          "DeletedAt",
          "auto_groups"
        ],
        "additionalProperties": false
      },
      "Page": {
        "type": "object",
        "properties": {
          "page": {
            "type": "integer",
            "minimum": 1
          },
          "page_size": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100
          },
          "total": {
            "type": "integer",
            "minimum": 0
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MaskedToken"
            }
          }
        },
        "required": [
          "page",
          "page_size",
          "total",
          "items"
        ],
        "additionalProperties": false
      },
      "FullKey": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string"
          }
        },
        "required": [
          "key"
        ],
        "additionalProperties": false
      },
      "Error": {
        "type": "object",
        "properties": {
          "success": {
            "const": false
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "success",
          "message"
        ],
        "additionalProperties": false
      },
      "ListSuccess": {
        "type": "object",
        "properties": {
          "success": {
            "const": true
          },
          "message": {
            "const": ""
          },
          "data": {
            "$ref": "#/components/schemas/Page"
          }
        },
        "required": [
          "success",
          "message",
          "data"
        ],
        "additionalProperties": false
      },
      "DetailSuccess": {
        "type": "object",
        "properties": {
          "success": {
            "const": true
          },
          "message": {
            "const": ""
          },
          "data": {
            "$ref": "#/components/schemas/MaskedToken"
          }
        },
        "required": [
          "success",
          "message",
          "data"
        ],
        "additionalProperties": false
      },
      "KeySuccess": {
        "type": "object",
        "properties": {
          "success": {
            "const": true
          },
          "message": {
            "const": ""
          },
          "data": {
            "$ref": "#/components/schemas/FullKey"
          }
        },
        "required": [
          "success",
          "message",
          "data"
        ],
        "additionalProperties": false
      },
      "AuthError": {
        "type": "object",
        "properties": {
          "success": {
            "const": false
          },
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "success",
          "code",
          "message"
        ],
        "additionalProperties": false
      }
    },
    "securitySchemes": {
      "Access": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
  },
  "security": [
    {
      "Access": []
    }
  ]
}
