转换文本命名风格

POST/case/convert
公开访问curl

支持 camelCase、snake_case、kebab-case、PascalCase、CONSTANT_CASE 与 URL Slug。 访问类别:匿名 API,可携带 Token 使用独立额度

请求参数

_formatquery
响应格式为 json 或 text;_format=svg 返回 JSON。plain 是 text 的别名。未识别的值继续按 Accept 协商。
string · 可选:json、text
_colorquery
控制 text 响应的 ANSI 颜色。0、false、off、no 关闭;省略或其他值保留。
string · 可选:0、false、off、no

请求体

application/json
text必填
string · 最长:65536 字符
style必填
string · 可选:camel、snake、kebab、pascal、constant、slug

响应

application/json

{
  "type": "object",
  "properties": {
    "text": {
      "type": "string"
    }
  },
  "required": [
    "text"
  ]
}

响应示例

成功响应

curl -sS --json '{"style":"snake","text":"accessToken"}' https://oit.sh/case/convert
HTTP 200
content-type: application/json
content-encoding: gzip
cache-control: no-store

{
  "text": "access_token"
}

错误示例

curl -sS --json '{}' https://oit.sh/case/convert
HTTP 400
content-type: application/json
content-encoding: gzip
cache-control: no-store

{
  "error": {
    "code": "INVALID_INPUT",
    "message": "参数无效",
    "issues": [
      {
        "location": "body",
        "field": "text",
        "code": "invalid_type",
        "message": "需要 字符串 类型"
      },
      {
        "location": "body",
        "field": "style",
        "code": "invalid_value",
        "message": "允许值:camel、snake、kebab、pascal、constant、slug"
      }
    ]
  }
}

curl 访问示例

curl、wget、HTTPie 默认得到 text/plain。示例展示纯文本输出。

命令与输出

curl -sS --json '{"style":"snake","text":"accessToken"}' 'https://oit.sh/case/convert?_color=0&_format=text'
HTTP 200
content-type: text/plain; charset=utf-8
content-encoding: gzip
cache-control: no-store

text: access_token

在线调试

必填
必填
Ctrl / ⌘ + Enter
curl -X POST 'https://oit.sh/case/convert' \
  -H 'Content-Type: application/json' \
  --data-raw '{"text":"accessToken","style":"snake"}'

响应

等待请求

等待发送请求