specove 0.1.0a1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- specove-0.1.0a1/LICENSE +21 -0
- specove-0.1.0a1/MANIFEST.in +6 -0
- specove-0.1.0a1/PKG-INFO +159 -0
- specove-0.1.0a1/README.md +114 -0
- specove-0.1.0a1/pyproject.toml +87 -0
- specove-0.1.0a1/setup.cfg +4 -0
- specove-0.1.0a1/src/specove/__init__.py +8 -0
- specove-0.1.0a1/src/specove/_version.py +4 -0
- specove-0.1.0a1/src/specove/assets/index.html +16 -0
- specove-0.1.0a1/src/specove/assets/init.js +42 -0
- specove-0.1.0a1/src/specove/assets/swagger-ui-LICENSE +202 -0
- specove-0.1.0a1/src/specove/assets/swagger-ui-NOTICE +2 -0
- specove-0.1.0a1/src/specove/assets/swagger-ui-bundle.js +2 -0
- specove-0.1.0a1/src/specove/assets/swagger-ui-bundle.js.LICENSE.txt +131 -0
- specove-0.1.0a1/src/specove/assets/swagger-ui-standalone-preset.js +2 -0
- specove-0.1.0a1/src/specove/assets/swagger-ui-standalone-preset.js.LICENSE.txt +45 -0
- specove-0.1.0a1/src/specove/assets/swagger-ui.css +3 -0
- specove-0.1.0a1/src/specove/assets/vendor.json +42 -0
- specove-0.1.0a1/src/specove/auth.py +99 -0
- specove-0.1.0a1/src/specove/core.py +312 -0
- specove-0.1.0a1/src/specove/fastapi.py +111 -0
- specove-0.1.0a1/src/specove/flask.py +97 -0
- specove-0.1.0a1/src/specove/py.typed +0 -0
- specove-0.1.0a1/src/specove.egg-info/PKG-INFO +159 -0
- specove-0.1.0a1/src/specove.egg-info/SOURCES.txt +32 -0
- specove-0.1.0a1/src/specove.egg-info/dependency_links.txt +1 -0
- specove-0.1.0a1/src/specove.egg-info/requires.txt +30 -0
- specove-0.1.0a1/src/specove.egg-info/top_level.txt +1 -0
- specove-0.1.0a1/test/check_artifacts.py +82 -0
- specove-0.1.0a1/test/check_browser.py +192 -0
- specove-0.1.0a1/test/check_sdist.py +64 -0
- specove-0.1.0a1/test/conftest.py +93 -0
- specove-0.1.0a1/test/test_core.py +255 -0
- specove-0.1.0a1/test/test_frameworks.py +124 -0
specove-0.1.0a1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 deepaint-ai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
specove-0.1.0a1/PKG-INFO
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: specove
|
|
3
|
+
Version: 0.1.0a1
|
|
4
|
+
Summary: 轻量、离线、多消费方与多版本的 OpenAPI 文档浏览组件
|
|
5
|
+
License: MIT License
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2026 deepaint-ai
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
|
|
27
|
+
Project-URL: Repository, https://github.com/deepaint-ai/specove
|
|
28
|
+
Keywords: openapi,swagger,flask,fastapi,offline,documentation
|
|
29
|
+
Classifier: Development Status :: 3 - Alpha
|
|
30
|
+
Classifier: Intended Audience :: Developers
|
|
31
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
32
|
+
Classifier: Operating System :: OS Independent
|
|
33
|
+
Classifier: Programming Language :: Python :: 3
|
|
34
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
37
|
+
Classifier: Topic :: Documentation
|
|
38
|
+
Requires-Python: >=3.7
|
|
39
|
+
Description-Content-Type: text/markdown
|
|
40
|
+
Provides-Extra: flask
|
|
41
|
+
Provides-Extra: fastapi
|
|
42
|
+
Provides-Extra: browser
|
|
43
|
+
Provides-Extra: dev
|
|
44
|
+
License-File: LICENSE
|
|
45
|
+
|
|
46
|
+
# Specove
|
|
47
|
+
|
|
48
|
+
轻量、离线的 OpenAPI 文档浏览组件。读取现有 catalog,按消费方、API 系列、文档版本和生命周期展示文档。页面由包内固定版本的 Swagger UI 渲染,不依赖 CDN,不要求使用者安装 Node.js。
|
|
49
|
+
|
|
50
|
+
当前版本:0.1.0a1(Alpha 预览版)。支持 Python 3.7 起、Flask 和 FastAPI;最低环境使用 Flask 2.2.5 / FastAPI 0.103.2 起的兼容版本,不代表最新框架支持 Python 3.7。
|
|
51
|
+
|
|
52
|
+
## 安装与接入
|
|
53
|
+
|
|
54
|
+
按使用框架选择对应的安装方式:
|
|
55
|
+
|
|
56
|
+
```console
|
|
57
|
+
python -m pip install "specove[flask]==0.1.0a1"
|
|
58
|
+
python -m pip install "specove[fastapi]==0.1.0a1"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
只使用哪个框架,就安装对应 extra。框架无关的核心没有第三方运行依赖。
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
from pathlib import Path
|
|
65
|
+
from flask import Flask
|
|
66
|
+
from specove.flask import register_docs
|
|
67
|
+
|
|
68
|
+
root = Path(__file__).resolve().parent
|
|
69
|
+
app = Flask(__name__)
|
|
70
|
+
viewer = register_docs(
|
|
71
|
+
app,
|
|
72
|
+
docs_dir=root / "docs/openapi",
|
|
73
|
+
project_root=root,
|
|
74
|
+
)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
FastAPI 使用同样的注册参数:
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
from pathlib import Path
|
|
81
|
+
from fastapi import FastAPI
|
|
82
|
+
from specove.fastapi import register_docs
|
|
83
|
+
|
|
84
|
+
root = Path(__file__).resolve().parent
|
|
85
|
+
app = FastAPI(docs_url=None, redoc_url=None, openapi_url=None)
|
|
86
|
+
viewer = register_docs(
|
|
87
|
+
app,
|
|
88
|
+
docs_dir=root / "docs/openapi",
|
|
89
|
+
project_root=root,
|
|
90
|
+
)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
访问 `/doc/`,HTTP Basic 用户名默认 `docs`。宿主自行决定是否在 development/testing 注册;Specove 不判断服务环境,不修改原有路由或业务鉴权。FastAPI 原生 /docs、/redoc、/openapi.json 由宿主决定是否关闭,Specove 不会替换它们。
|
|
94
|
+
|
|
95
|
+
## 文档目录
|
|
96
|
+
|
|
97
|
+
```text
|
|
98
|
+
docs/openapi/
|
|
99
|
+
├── catalog.json
|
|
100
|
+
├── .specove-password
|
|
101
|
+
└── service/v1.0.0/openapi.json
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
`catalog.json` 示例:
|
|
105
|
+
|
|
106
|
+
```json
|
|
107
|
+
{
|
|
108
|
+
"format_version": 1,
|
|
109
|
+
"api_version": "v1",
|
|
110
|
+
"documents": [
|
|
111
|
+
{
|
|
112
|
+
"consumer": "service",
|
|
113
|
+
"title": "内部服务",
|
|
114
|
+
"api_version": "v1",
|
|
115
|
+
"document_version": "v1.0.0",
|
|
116
|
+
"path": "docs/openapi/service/v1.0.0/openapi.json",
|
|
117
|
+
"lifecycle": "workspace-snapshot",
|
|
118
|
+
"operation_count": 1
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
path 相对于 project_root,必须解析到 docs_dir 内。只展示目录声明的条目,不扫描历史文件、不要求 all 目录;目录按注册时的快照展示,更新目录后需重建应用。OpenAPI JSON 在读取时重新校验。
|
|
125
|
+
|
|
126
|
+
首版展示 OpenAPI 3.0.x、3.1.x 自包含 JSON,仅支持 JSON Pointer 内部引用;拒绝外部引用和目录越界。不宣称完成完整 OpenAPI Schema 验证;契约生成和完整规范验证仍由服务构建流程负责。
|
|
127
|
+
|
|
128
|
+
## 访问保护
|
|
129
|
+
|
|
130
|
+
- 默认读取 `docs_dir/.specove-password`;不存在才原子生成,后续重启/多 worker 复用。
|
|
131
|
+
- `password="明确指定的密码"` 使用指定值,不接触旧文件;移除指定值后恢复使用旧文件。
|
|
132
|
+
- `allow_anonymous=True` 显式允许匿名,不创建密码文件;不能同时指定密码。
|
|
133
|
+
- 空白密码、损坏/不可读文件或无法保存均报错,不自动覆盖或开放匿名。
|
|
134
|
+
- 可用 `password_file=绝对路径` 覆盖存储位置,`url_prefix="/internal/doc"` 改变文档路由。
|
|
135
|
+
- 管理员可受控读取文件,或使用注册返回的 `viewer.password`;不要打印到普通日志、公开接口或错误页。文件保存可恢复的密码原文,必须按凭据保护。
|
|
136
|
+
- 首次创建依赖文件系统支持原子硬链接;不支持时明确报错,可显式配置密码,不退回竞态写入。
|
|
137
|
+
- 将 `**/.specove-password` 加入宿主 Git 忽略及文档交付排除规则;自定义密码文件名也要排除。Specove 不改写宿主仓库。
|
|
138
|
+
- Specove 不提供任意目录静态服务;宿主其它静态目录、反向代理也不得暴露密码文件。HTTP Basic 通过 HTTPS 使用。
|
|
139
|
+
|
|
140
|
+
页面、目录、JSON 和固定资源都受同一认证保护。默认关闭在线 API 调用和外部校验,浏览器只加载当前目录的本地资源。支持前缀与代理挂载;转发头的信任由宿主配置。
|
|
141
|
+
|
|
142
|
+
## 开发与发布
|
|
143
|
+
|
|
144
|
+
测试在 test/,全部缓存与临时产物在 tmp/。使用项目自身虚拟环境:
|
|
145
|
+
|
|
146
|
+
```console
|
|
147
|
+
python -m pip install ".[dev,flask,fastapi]"
|
|
148
|
+
python -m ruff format --check src test
|
|
149
|
+
python -m ruff check src test
|
|
150
|
+
python -m mypy
|
|
151
|
+
python -m pytest
|
|
152
|
+
python -m build
|
|
153
|
+
python test/check_artifacts.py
|
|
154
|
+
python -m twine check dist/*
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
发行包只包含必要的用户说明与许可,不包含 docs/ 下的开发设计、交接或发布过程文档;这些资料仅供源码仓库维护使用。
|
|
158
|
+
|
|
159
|
+
Specove 采用 MIT;固定版本 Swagger UI 保留独立 Apache-2.0 许可,来源和校验值随包记录。公开 PyPI 的源码和资源公开,即使 GitHub 仓库为私有。
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Specove
|
|
2
|
+
|
|
3
|
+
轻量、离线的 OpenAPI 文档浏览组件。读取现有 catalog,按消费方、API 系列、文档版本和生命周期展示文档。页面由包内固定版本的 Swagger UI 渲染,不依赖 CDN,不要求使用者安装 Node.js。
|
|
4
|
+
|
|
5
|
+
当前版本:0.1.0a1(Alpha 预览版)。支持 Python 3.7 起、Flask 和 FastAPI;最低环境使用 Flask 2.2.5 / FastAPI 0.103.2 起的兼容版本,不代表最新框架支持 Python 3.7。
|
|
6
|
+
|
|
7
|
+
## 安装与接入
|
|
8
|
+
|
|
9
|
+
按使用框架选择对应的安装方式:
|
|
10
|
+
|
|
11
|
+
```console
|
|
12
|
+
python -m pip install "specove[flask]==0.1.0a1"
|
|
13
|
+
python -m pip install "specove[fastapi]==0.1.0a1"
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
只使用哪个框架,就安装对应 extra。框架无关的核心没有第三方运行依赖。
|
|
17
|
+
|
|
18
|
+
```python
|
|
19
|
+
from pathlib import Path
|
|
20
|
+
from flask import Flask
|
|
21
|
+
from specove.flask import register_docs
|
|
22
|
+
|
|
23
|
+
root = Path(__file__).resolve().parent
|
|
24
|
+
app = Flask(__name__)
|
|
25
|
+
viewer = register_docs(
|
|
26
|
+
app,
|
|
27
|
+
docs_dir=root / "docs/openapi",
|
|
28
|
+
project_root=root,
|
|
29
|
+
)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
FastAPI 使用同样的注册参数:
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from pathlib import Path
|
|
36
|
+
from fastapi import FastAPI
|
|
37
|
+
from specove.fastapi import register_docs
|
|
38
|
+
|
|
39
|
+
root = Path(__file__).resolve().parent
|
|
40
|
+
app = FastAPI(docs_url=None, redoc_url=None, openapi_url=None)
|
|
41
|
+
viewer = register_docs(
|
|
42
|
+
app,
|
|
43
|
+
docs_dir=root / "docs/openapi",
|
|
44
|
+
project_root=root,
|
|
45
|
+
)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
访问 `/doc/`,HTTP Basic 用户名默认 `docs`。宿主自行决定是否在 development/testing 注册;Specove 不判断服务环境,不修改原有路由或业务鉴权。FastAPI 原生 /docs、/redoc、/openapi.json 由宿主决定是否关闭,Specove 不会替换它们。
|
|
49
|
+
|
|
50
|
+
## 文档目录
|
|
51
|
+
|
|
52
|
+
```text
|
|
53
|
+
docs/openapi/
|
|
54
|
+
├── catalog.json
|
|
55
|
+
├── .specove-password
|
|
56
|
+
└── service/v1.0.0/openapi.json
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
`catalog.json` 示例:
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"format_version": 1,
|
|
64
|
+
"api_version": "v1",
|
|
65
|
+
"documents": [
|
|
66
|
+
{
|
|
67
|
+
"consumer": "service",
|
|
68
|
+
"title": "内部服务",
|
|
69
|
+
"api_version": "v1",
|
|
70
|
+
"document_version": "v1.0.0",
|
|
71
|
+
"path": "docs/openapi/service/v1.0.0/openapi.json",
|
|
72
|
+
"lifecycle": "workspace-snapshot",
|
|
73
|
+
"operation_count": 1
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
path 相对于 project_root,必须解析到 docs_dir 内。只展示目录声明的条目,不扫描历史文件、不要求 all 目录;目录按注册时的快照展示,更新目录后需重建应用。OpenAPI JSON 在读取时重新校验。
|
|
80
|
+
|
|
81
|
+
首版展示 OpenAPI 3.0.x、3.1.x 自包含 JSON,仅支持 JSON Pointer 内部引用;拒绝外部引用和目录越界。不宣称完成完整 OpenAPI Schema 验证;契约生成和完整规范验证仍由服务构建流程负责。
|
|
82
|
+
|
|
83
|
+
## 访问保护
|
|
84
|
+
|
|
85
|
+
- 默认读取 `docs_dir/.specove-password`;不存在才原子生成,后续重启/多 worker 复用。
|
|
86
|
+
- `password="明确指定的密码"` 使用指定值,不接触旧文件;移除指定值后恢复使用旧文件。
|
|
87
|
+
- `allow_anonymous=True` 显式允许匿名,不创建密码文件;不能同时指定密码。
|
|
88
|
+
- 空白密码、损坏/不可读文件或无法保存均报错,不自动覆盖或开放匿名。
|
|
89
|
+
- 可用 `password_file=绝对路径` 覆盖存储位置,`url_prefix="/internal/doc"` 改变文档路由。
|
|
90
|
+
- 管理员可受控读取文件,或使用注册返回的 `viewer.password`;不要打印到普通日志、公开接口或错误页。文件保存可恢复的密码原文,必须按凭据保护。
|
|
91
|
+
- 首次创建依赖文件系统支持原子硬链接;不支持时明确报错,可显式配置密码,不退回竞态写入。
|
|
92
|
+
- 将 `**/.specove-password` 加入宿主 Git 忽略及文档交付排除规则;自定义密码文件名也要排除。Specove 不改写宿主仓库。
|
|
93
|
+
- Specove 不提供任意目录静态服务;宿主其它静态目录、反向代理也不得暴露密码文件。HTTP Basic 通过 HTTPS 使用。
|
|
94
|
+
|
|
95
|
+
页面、目录、JSON 和固定资源都受同一认证保护。默认关闭在线 API 调用和外部校验,浏览器只加载当前目录的本地资源。支持前缀与代理挂载;转发头的信任由宿主配置。
|
|
96
|
+
|
|
97
|
+
## 开发与发布
|
|
98
|
+
|
|
99
|
+
测试在 test/,全部缓存与临时产物在 tmp/。使用项目自身虚拟环境:
|
|
100
|
+
|
|
101
|
+
```console
|
|
102
|
+
python -m pip install ".[dev,flask,fastapi]"
|
|
103
|
+
python -m ruff format --check src test
|
|
104
|
+
python -m ruff check src test
|
|
105
|
+
python -m mypy
|
|
106
|
+
python -m pytest
|
|
107
|
+
python -m build
|
|
108
|
+
python test/check_artifacts.py
|
|
109
|
+
python -m twine check dist/*
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
发行包只包含必要的用户说明与许可,不包含 docs/ 下的开发设计、交接或发布过程文档;这些资料仅供源码仓库维护使用。
|
|
113
|
+
|
|
114
|
+
Specove 采用 MIT;固定版本 Swagger UI 保留独立 Apache-2.0 许可,来源和校验值随包记录。公开 PyPI 的源码和资源公开,即使 GitHub 仓库为私有。
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=67.8", "wheel>=0.42"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "specove"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "轻量、离线、多消费方与多版本的 OpenAPI 文档浏览组件"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.7"
|
|
11
|
+
license = {file = "LICENSE"}
|
|
12
|
+
dependencies = []
|
|
13
|
+
keywords = ["openapi", "swagger", "flask", "fastapi", "offline", "documentation"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
21
|
+
"Programming Language :: Python :: 3.7",
|
|
22
|
+
"Programming Language :: Python :: 3.13",
|
|
23
|
+
"Topic :: Documentation",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[project.urls]
|
|
27
|
+
Repository = "https://github.com/deepaint-ai/specove"
|
|
28
|
+
|
|
29
|
+
[project.optional-dependencies]
|
|
30
|
+
flask = ["Flask>=2.2.5,<4"]
|
|
31
|
+
fastapi = ["fastapi>=0.103.2,<1"]
|
|
32
|
+
browser = ["playwright>=1.48,<2; python_version >= '3.9'", "uvicorn>=0.22,<1; python_version >= '3.9'"]
|
|
33
|
+
dev = [
|
|
34
|
+
"setuptools>=67.8",
|
|
35
|
+
"wheel>=0.42",
|
|
36
|
+
"build==0.10.0; python_version < '3.8'",
|
|
37
|
+
"build>=1,<2; python_version >= '3.8'",
|
|
38
|
+
"mypy==1.4.1",
|
|
39
|
+
"pytest==7.4.4; python_version < '3.8'",
|
|
40
|
+
"pytest>=8,<10; python_version >= '3.8'",
|
|
41
|
+
"ruff==0.8.6",
|
|
42
|
+
"twine==4.0.2; python_version < '3.8'",
|
|
43
|
+
"twine>=6,<7; python_version >= '3.8'",
|
|
44
|
+
"httpx>=0.24,<0.25; python_version < '3.8'",
|
|
45
|
+
"httpx>=0.27,<1; python_version >= '3.8'",
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
[tool.setuptools.dynamic]
|
|
49
|
+
version = {attr = "specove._version.__version__"}
|
|
50
|
+
|
|
51
|
+
[tool.setuptools.packages.find]
|
|
52
|
+
where = ["src"]
|
|
53
|
+
|
|
54
|
+
[tool.setuptools.package-data]
|
|
55
|
+
specove = ["py.typed", "assets/*"]
|
|
56
|
+
|
|
57
|
+
[tool.setuptools]
|
|
58
|
+
license-files = ["LICENSE"]
|
|
59
|
+
|
|
60
|
+
[tool.pytest.ini_options]
|
|
61
|
+
testpaths = ["test"]
|
|
62
|
+
addopts = "-ra -p no:cacheprovider"
|
|
63
|
+
tmp_path_retention_count = 1
|
|
64
|
+
|
|
65
|
+
[tool.ruff]
|
|
66
|
+
target-version = "py37"
|
|
67
|
+
line-length = 88
|
|
68
|
+
cache-dir = "tmp/ruff-cache"
|
|
69
|
+
|
|
70
|
+
[tool.ruff.lint]
|
|
71
|
+
select = ["E", "W", "F", "I", "D"]
|
|
72
|
+
ignore = ["D400", "D415"]
|
|
73
|
+
|
|
74
|
+
[tool.ruff.lint.pydocstyle]
|
|
75
|
+
convention = "google"
|
|
76
|
+
|
|
77
|
+
[tool.ruff.lint.per-file-ignores]
|
|
78
|
+
"test/*.py" = ["D", "E402"]
|
|
79
|
+
|
|
80
|
+
[tool.mypy]
|
|
81
|
+
python_version = "3.7"
|
|
82
|
+
files = ["src/specove"]
|
|
83
|
+
check_untyped_defs = true
|
|
84
|
+
disallow_untyped_defs = true
|
|
85
|
+
no_implicit_optional = true
|
|
86
|
+
warn_unused_ignores = true
|
|
87
|
+
cache_dir = "tmp/mypy-cache"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<title>__SPECOVE_TITLE__</title>
|
|
7
|
+
<link rel="icon" href="data:,">
|
|
8
|
+
<link rel="stylesheet" href="assets/swagger-ui.css">
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<div id="swagger-ui" aria-label="接口文档"></div>
|
|
12
|
+
<script src="assets/swagger-ui-bundle.js"></script>
|
|
13
|
+
<script src="assets/swagger-ui-standalone-preset.js"></script>
|
|
14
|
+
<script src="assets/init.js"></script>
|
|
15
|
+
</body>
|
|
16
|
+
</html>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* Specove:只从受保护的本地目录加载文档,不允许查询参数覆盖配置。 */
|
|
2
|
+
"use strict";
|
|
3
|
+
(async function () {
|
|
4
|
+
const target = document.getElementById("swagger-ui");
|
|
5
|
+
try {
|
|
6
|
+
const response = await fetch("catalog.json", {
|
|
7
|
+
credentials: "same-origin",
|
|
8
|
+
cache: "no-store"
|
|
9
|
+
});
|
|
10
|
+
if (!response.ok) throw new Error("文档目录加载失败");
|
|
11
|
+
const catalog = await response.json();
|
|
12
|
+
const urls = catalog.documents.map(function (document) {
|
|
13
|
+
return { name: document.label, url: document.url };
|
|
14
|
+
});
|
|
15
|
+
const allowed = new Set(urls.map(function (entry) {
|
|
16
|
+
return new URL(entry.url, window.location.href).href;
|
|
17
|
+
}));
|
|
18
|
+
window.ui = SwaggerUIBundle({
|
|
19
|
+
dom_id: "#swagger-ui",
|
|
20
|
+
urls: urls,
|
|
21
|
+
presets: [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset],
|
|
22
|
+
layout: "StandaloneLayout",
|
|
23
|
+
filter: true,
|
|
24
|
+
deepLinking: true,
|
|
25
|
+
validatorUrl: null,
|
|
26
|
+
supportedSubmitMethods: [],
|
|
27
|
+
queryConfigEnabled: false,
|
|
28
|
+
persistAuthorization: false,
|
|
29
|
+
withCredentials: false,
|
|
30
|
+
requestInterceptor: function (request) {
|
|
31
|
+
if (!allowed.has(new URL(request.url, window.location.href).href) ||
|
|
32
|
+
(request.method || "GET").toUpperCase() !== "GET") {
|
|
33
|
+
throw new Error("只允许读取目录声明的本地文档");
|
|
34
|
+
}
|
|
35
|
+
request.credentials = "same-origin";
|
|
36
|
+
return request;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
} catch (error) {
|
|
40
|
+
target.textContent = "文档暂不可用,请联系服务维护者。";
|
|
41
|
+
}
|
|
42
|
+
})();
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|