Skip to content

Commit a52a282

Browse files
author
AxT-Team Bot
committed
chore: enable NuGet release
0 parents  commit a52a282

File tree

869 files changed

+141147
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

869 files changed

+141147
-0
lines changed

.editorconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
root = true
2+
[*]
3+
charset = utf-8
4+
end_of_line = lf
5+
insert_final_newline = true
6+
trim_trailing_whitespace = true

.github/workflows/release.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: release
2+
on:
3+
push:
4+
tags: ['v*.*.*']
5+
jobs:
6+
publish:
7+
runs-on: ubuntu-latest
8+
permissions:
9+
contents: write
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: actions/setup-dotnet@v4
13+
with:
14+
dotnet-version: '8.0.x'
15+
- run: dotnet pack src --configuration Release --output out
16+
- name: Publish to NuGet
17+
run: dotnet nuget push out/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
18+
- uses: softprops/action-gh-release@v2
19+
with:
20+
files: out/*.nupkg
21+
generate_release_notes: true

.github/workflows/test.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: test
2+
on: [push, pull_request]
3+
jobs:
4+
test:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v4
8+
- uses: actions/setup-dotnet@v4
9+
with: { dotnet-version: '8.0.x' }
10+
- run: dotnet build -c Release

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.DS_Store
2+
.idea/
3+
.vscode/
4+
dist/
5+
build/
6+
coverage/

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# uapi-sdk-csharp
2+
3+
![Banner](./banner.png)
4+
5+
[![.NET](https://img.shields.io/badge/.NET-7+-512BD4?style=flat-square&logo=dotnet&logoColor=white)](https://dotnet.microsoft.com/)
6+
[![Docs](https://img.shields.io/badge/Docs-uapis.cn-2EAE5D?style=flat-square)](https://uapis.cn/)
7+
8+
> [!NOTE]
9+
> 所有接口的 C# 示例都可以在 [UApi](https://uapis.cn/docs/introduction) 的接口文档页面,向下滚动至 **快速启动** 区块后直接复制。
10+
11+
## 快速开始
12+
13+
```bash
14+
dotnet add package uapi-sdk-csharp
15+
```
16+
17+
```csharp
18+
using System;
19+
using System.Collections.Generic;
20+
using uapi;
21+
22+
var client = new Client("https://uapis.cn/api/v1");
23+
var result = await client.Social.getSocialQqUserinfoAsync(new Dictionary<string, object?> { ["qq"] = "10001" });
24+
Console.WriteLine(result);
25+
```
26+
27+
## 特性
28+
29+
现在你不再需要反反复复的查阅文档了。
30+
31+
只需在 IDE 中键入 `client.`,所有核心模块——如 `Social``Game``Image`——即刻同步展现。进一步输入即可直接定位到 `getSocialQqUserinfoAsync` 这样的具体方法,其名称与文档的 `operationId` 严格保持一致,确保了开发过程的直观与高效。
32+
33+
所有方法签名只接受真实且必需的参数。当你在构建请求时,IDE 会即时提示 `qq``username` 等键名,这彻底杜绝了在 `Dictionary<string, object?>` 中因键名拼写错误而导致的运行时错误。
34+
35+
针对 401、404、429 等标准 HTTP 响应,SDK 已将其统一映射为具名的异常类型。这些异常均附带 `Code``Status``Details` 等关键上下文信息,确保你在日志中能第一时间准确、快速地诊断问题。
36+
37+
`Client` 基于 `HttpClient`,构造函数会设置 BaseAddress 并自动追加 `Authorization` 头;如果你想引入代理、超时或重试策略,只需包装一个自定义的 `HttpClient` 传入即可。
38+
39+
如果你需要查看字段细节或内部逻辑,仓库中的 `./internal` 目录同步保留了由 `openapi-generator` 生成的完整结构体,随时可供参考。
40+
41+
## 错误模型概览
42+
43+
| HTTP 状态码 | SDK 错误类型 | 附加信息 |
44+
|-------------|----------------------------------------------|------------------------------------------------------------------------------------|
45+
| 401/403 | `UnauthorizedError` | `code``status` |
46+
| 404 | `NotFoundError` / `NoMatchError` | `code``status` |
47+
| 400 | `InvalidParameterError` / `InvalidParamsError` | `code``status``details` |
48+
| 429 | `ServiceBusyError` | `code``status``retry_after_seconds` |
49+
| 5xx | `InternalServerErrorError` / `ApiErrorError` | `code``status``details` |
50+
| 其他 4xx | `UapiError` | `code``status``details` |
51+
52+
## 其他 SDK
53+
54+
| 语言 | 仓库地址 |
55+
|-------------|--------------------------------------------------------------|
56+
| Go | https://github.com/AxT-Team/uapi-go-sdk |
57+
| Python | https://github.com/AxT-Team/uapi-python-sdk |
58+
| TypeScript| https://github.com/AxT-Team/uapi-typescript-sdk |
59+
| Browser (TypeScript/JavaScript)| https://github.com/AxT-Team/uapi-browser-sdk |
60+
| Java | https://github.com/AxT-Team/uapi-java-sdk |
61+
| PHP | https://github.com/AxT-Team/uapi-php-sdk |
62+
| C#(当前) | https://github.com/AxT-Team/uapi-csharp-sdk |
63+
| C++ | https://github.com/AxT-Team/uapi-cpp-sdk |
64+
| Rust | https://github.com/AxT-Team/uapi-rust-sdk |
65+
66+
## 文档
67+
68+
访问 [UApi文档首页](https://uapis.cn/docs/introduction) 并选择任意接口,向下滚动到 **快速启动** 区块即可看到最新的 C# 示例代码。

banner.png

2.23 MB
Loading

0 commit comments

Comments
 (0)