@nocobase/plugin-api-doc 0.13.0-alpha.1
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.
- package/LICENSE +661 -0
- package/README.md +80 -0
- package/README.zh-CN.md +79 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/Document.d.ts +4 -0
- package/dist/client/index.d.ts +6 -0
- package/dist/client/index.js +48583 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +11 -0
- package/dist/locale/en-US.d.ts +2 -0
- package/dist/locale/en-US.js +5 -0
- package/dist/locale/index.d.ts +4 -0
- package/dist/locale/index.js +20 -0
- package/dist/locale/zh-CN.d.ts +6 -0
- package/dist/locale/zh-CN.js +9 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +11 -0
- package/dist/server/server.d.ts +8 -0
- package/dist/server/server.js +51 -0
- package/dist/server/swagger/base-swagger.d.ts +49 -0
- package/dist/server/swagger/base-swagger.js +54 -0
- package/dist/server/swagger/collections/components/field-type-map.d.ts +22 -0
- package/dist/server/swagger/collections/components/field-type-map.js +34 -0
- package/dist/server/swagger/collections/components/index.d.ts +24 -0
- package/dist/server/swagger/collections/components/index.js +18 -0
- package/dist/server/swagger/collections/components/parameters.d.ts +5 -0
- package/dist/server/swagger/collections/components/parameters.js +173 -0
- package/dist/server/swagger/collections/components/schemas.d.ts +23 -0
- package/dist/server/swagger/collections/components/schemas.js +91 -0
- package/dist/server/swagger/collections/index.d.ts +31 -0
- package/dist/server/swagger/collections/index.js +22 -0
- package/dist/server/swagger/collections/paths/associations/index.d.ts +6 -0
- package/dist/server/swagger/collections/paths/associations/index.js +32 -0
- package/dist/server/swagger/collections/paths/associations/multiple-association.d.ts +6 -0
- package/dist/server/swagger/collections/paths/associations/multiple-association.js +106 -0
- package/dist/server/swagger/collections/paths/associations/single-association.d.ts +5 -0
- package/dist/server/swagger/collections/paths/associations/single-association.js +88 -0
- package/dist/server/swagger/collections/paths/collection.d.ts +201 -0
- package/dist/server/swagger/collections/paths/collection.js +333 -0
- package/dist/server/swagger/collections/paths/index.d.ts +4 -0
- package/dist/server/swagger/collections/paths/index.js +30 -0
- package/dist/server/swagger/collections/tags/index.d.ts +6 -0
- package/dist/server/swagger/collections/tags/index.js +26 -0
- package/dist/server/swagger/constants.d.ts +10 -0
- package/dist/server/swagger/constants.js +14 -0
- package/dist/server/swagger/helpers.d.ts +171 -0
- package/dist/server/swagger/helpers.js +111 -0
- package/dist/server/swagger/index.d.ts +48 -0
- package/dist/server/swagger/index.js +221 -0
- package/dist/server/swagger/loader.d.ts +4 -0
- package/dist/server/swagger/loader.js +54 -0
- package/dist/server/swagger/merge.d.ts +1 -0
- package/dist/server/swagger/merge.js +13 -0
- package/dist/swagger.d.ts +43 -0
- package/dist/swagger.js +46 -0
- package/package.json +24 -0
- package/server.d.ts +3 -0
- package/server.js +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# api-doc
|
|
2
|
+
|
|
3
|
+
English | [中文](./README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Introduction
|
|
7
|
+
|
|
8
|
+
This plugin is based on `swagger` to write documentation.
|
|
9
|
+
|
|
10
|
+
## How to access the documentation
|
|
11
|
+
|
|
12
|
+
1. The access address in the plugin center is `{domain}/admin/settings/api-doc/documentation`
|
|
13
|
+
2. The access address outside the plugin center is `{domain}/api-documentation`
|
|
14
|
+
|
|
15
|
+
## How to write swagger documentation
|
|
16
|
+
|
|
17
|
+
> The method in the plugin is the same
|
|
18
|
+
|
|
19
|
+
1. `src/swagger.{ts,json}`
|
|
20
|
+
2. `src/swagger/index.{ts,json}`
|
|
21
|
+
|
|
22
|
+
The file paths above can all be traversed to write documentation. Just export your written documentation by default. An example is shown below:
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
export default {
|
|
26
|
+
info: {
|
|
27
|
+
title: 'NocoBase API - Api-doc plugin',
|
|
28
|
+
},
|
|
29
|
+
tags: [],
|
|
30
|
+
paths: {},
|
|
31
|
+
components: {
|
|
32
|
+
schemas: {}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Usually, you only need to write **info.title**, **tags**, **paths**, and **components**. Other information such as **server** and **info** are merged into our **base-swagger**.
|
|
38
|
+
|
|
39
|
+
Base swagger includes the following code:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
// base swagger
|
|
43
|
+
export default {
|
|
44
|
+
openapi: '3.0.3',
|
|
45
|
+
info: {
|
|
46
|
+
title: 'NocoBase API documentation',
|
|
47
|
+
description: '',
|
|
48
|
+
contact: {
|
|
49
|
+
url: 'https://github.com/nocobase/nocobase/issues',
|
|
50
|
+
},
|
|
51
|
+
license: {
|
|
52
|
+
name: 'Core packages are Apache 2.0 & Plugins packages are AGPL 3.0 licensed.',
|
|
53
|
+
url: 'https://github.com/nocobase/nocobase#license',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
externalDocs: {
|
|
57
|
+
description: 'Find out more about NocoBase',
|
|
58
|
+
url: 'https://docs.nocobase.com/',
|
|
59
|
+
},
|
|
60
|
+
components: {
|
|
61
|
+
securitySchemes: {
|
|
62
|
+
'api-key': {
|
|
63
|
+
type: 'http',
|
|
64
|
+
scheme: 'bearer',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
security: [
|
|
69
|
+
{
|
|
70
|
+
'api-key': [],
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
};
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
> Note that configurations that can only be obtained at runtime, such as the server and version fields, are not filled in the base-swagger.
|
|
77
|
+
|
|
78
|
+
You can also override these defaults. When writing the swagger documentation for your plugin, you should consider whether your plugin's documentation can be accessed independently.
|
|
79
|
+
|
|
80
|
+
For detailed swagger writing rules, please refer to the [official documentation](https://swagger.io/docs/specification/about/).
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# api-doc
|
|
2
|
+
|
|
3
|
+
[English](./README.md) | 中文
|
|
4
|
+
|
|
5
|
+
## 简介
|
|
6
|
+
|
|
7
|
+
该插件基于 `swagger` 编写文档。
|
|
8
|
+
|
|
9
|
+
## 如何访问文档
|
|
10
|
+
|
|
11
|
+
1. 在插件中心访问地址是 `{domain}/admin/settings/api-doc/documentation`
|
|
12
|
+
2. 在插件中心外访问地址是 `{domain}/api-documentation`
|
|
13
|
+
|
|
14
|
+
## 如何编写 swagger 文档
|
|
15
|
+
|
|
16
|
+
> 插件内方式一样
|
|
17
|
+
|
|
18
|
+
1. `src/swagger.{ts,json}`
|
|
19
|
+
2. `src/swagger/index.{ts,json}`
|
|
20
|
+
|
|
21
|
+
上面的文件路径均可遍写文档,只需最后将您编写的文档默认导出即可,例子如下:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
export default {
|
|
25
|
+
info: {
|
|
26
|
+
title: 'NocoBase API - Auth plugin',
|
|
27
|
+
},
|
|
28
|
+
tags: [],
|
|
29
|
+
paths: {},
|
|
30
|
+
components: {
|
|
31
|
+
schemas: {}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
通常你只需要编写 **info.title**, **tags**, **paths**, **components** 即可其他内容如 **server**, **info** 的其他信息都合并我们的 **base-swagger**.
|
|
37
|
+
|
|
38
|
+
base swagger 包含如下代码
|
|
39
|
+
```ts
|
|
40
|
+
// base swagger
|
|
41
|
+
export default {
|
|
42
|
+
openapi: '3.0.3',
|
|
43
|
+
info: {
|
|
44
|
+
title: 'NocoBase API documentation',
|
|
45
|
+
description: '',
|
|
46
|
+
contact: {
|
|
47
|
+
url: 'https://github.com/nocobase/nocobase/issues',
|
|
48
|
+
},
|
|
49
|
+
license: {
|
|
50
|
+
name: 'Core packages are Apache 2.0 & Plugins packages are AGPL 3.0 licensed.',
|
|
51
|
+
url: 'https://github.com/nocobase/nocobase#license',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
externalDocs: {
|
|
55
|
+
description: 'Find out more about NocoBase',
|
|
56
|
+
url: 'https://docs.nocobase.com/',
|
|
57
|
+
},
|
|
58
|
+
components: {
|
|
59
|
+
securitySchemes: {
|
|
60
|
+
'api-key': {
|
|
61
|
+
type: 'http',
|
|
62
|
+
scheme: 'bearer',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
security: [
|
|
67
|
+
{
|
|
68
|
+
'api-key': [],
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
> 注意:涉及到运行时才能获取的配置,并没有填写在 base-swagger 里,如 server, version 字段
|
|
76
|
+
|
|
77
|
+
这些默认的配置你同样也可以覆盖它,在你编写插件的 `swagger` 文档时,你需要视你的插件文档是独立的文档,可以被单独访问。
|
|
78
|
+
|
|
79
|
+
详细的 `swagger` 编写规则请参考[官方文档](https://swagger.io/docs/specification/about/)
|
package/client.d.ts
ADDED
package/client.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/client/index.js');
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Plugin } from '@nocobase/client';
|
|
2
|
+
export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<import("antd-style").SerializedStyles>;
|
|
3
|
+
export declare class APIDocumentationPlugin extends Plugin {
|
|
4
|
+
load(): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
export default APIDocumentationPlugin;
|