Files
TimiServerAPI/scripts/export-openapi.ps1
T
Timi aefc0ad205 feat(openapi): integrate springdoc and API integration guide
- add springdoc-openapi and expose /v3/api-docs, /v3/api-docs.yaml and Swagger UI
- keep API docs responses unwrapped by replacing the global return handler
- add Chinese @Tag/@Operation/@Parameter docs for file and async task controllers
- add docs/api-integration.md and local export scripts for AI agent consumption
- ignore local OpenAPI snapshots and force LF for shell scripts
2026-11-25 01:23:30 +08:00

51 lines
1.3 KiB
PowerShell

<#
.SYNOPSIS
导出本地 OpenAPI 文档。
.DESCRIPTION
从本地已启动的服务获取 /v3/api-docs.yaml(或 JSON),写入 docs 目录。
生成的文件已被 .gitignore 忽略,不会提交。
.PARAMETER BaseUrl
服务地址,默认 http://localhost:18092。
.PARAMETER OutFile
输出文件路径,默认 docs/openapi.local.yaml。
扩展名为 .json 时导出 JSON,否则导出 YAML。
.EXAMPLE
.\scripts\export-openapi.ps1
.EXAMPLE
.\scripts\export-openapi.ps1 -BaseUrl http://192.168.1.10:18092 -OutFile docs/openapi.local.json
#>
param(
[string]$BaseUrl = "http://localhost:18092",
[string]$OutFile
)
$ErrorActionPreference = "Stop"
if ([string]::IsNullOrWhiteSpace($OutFile)) {
$OutFile = Join-Path (Split-Path -Parent $PSScriptRoot) "docs\openapi.local.yaml"
}
$BaseUrl = $BaseUrl.TrimEnd("/")
$OutFile = [System.IO.Path]::GetFullPath($OutFile)
$OutDir = Split-Path -Parent $OutFile
if (-not (Test-Path -LiteralPath $OutDir)) {
New-Item -ItemType Directory -Path $OutDir -Force | Out-Null
}
if ([System.IO.Path]::GetExtension($OutFile) -ieq ".json") {
$ApiPath = "/v3/api-docs"
} else {
$ApiPath = "/v3/api-docs.yaml"
}
$Url = "$BaseUrl$ApiPath"
Write-Host "Fetching $Url"
Invoke-WebRequest -Uri $Url -OutFile $OutFile -UseBasicParsing
Write-Host "OpenAPI exported to $OutFile"