mirror of
https://github.com/cool-team-official/cool-admin-midway.git
synced 2025-12-10 16:12:50 +00:00
集成swagger
This commit is contained in:
parent
7369cbbd42
commit
4b3bcd7ea5
@ -6,6 +6,7 @@
|
||||
"dependencies": {
|
||||
"@cool-midway/core": "file:/Users/ap/Documents/src/admin/midway-packages/core",
|
||||
"@cool-midway/task": "file:/Users/ap/Documents/src/admin/midway-packages/task",
|
||||
"@cool-midway/rpc": "file:/Users/ap/Documents/src/admin/midway-packages/rpc",
|
||||
"@midwayjs/bootstrap": "^3.20.0",
|
||||
"@midwayjs/cache-manager": "^3.20.0",
|
||||
"@midwayjs/core": "^3.20.0",
|
||||
|
||||
202
pnpm-lock.yaml
generated
202
pnpm-lock.yaml
generated
@ -10,7 +10,10 @@ importers:
|
||||
dependencies:
|
||||
'@cool-midway/core':
|
||||
specifier: file:/Users/ap/Documents/src/admin/midway-packages/core
|
||||
version: file:../midway-packages/core
|
||||
version: file:../midway-packages/core(debug@4.4.0)
|
||||
'@cool-midway/rpc':
|
||||
specifier: file:/Users/ap/Documents/src/admin/midway-packages/rpc
|
||||
version: file:../midway-packages/rpc(debug@4.4.0)(encoding@0.1.13)
|
||||
'@cool-midway/task':
|
||||
specifier: file:/Users/ap/Documents/src/admin/midway-packages/task
|
||||
version: file:../midway-packages/task
|
||||
@ -58,7 +61,7 @@ importers:
|
||||
version: 0.5.16
|
||||
axios:
|
||||
specifier: ^1.7.9
|
||||
version: 1.7.9
|
||||
version: 1.7.9(debug@4.4.0)
|
||||
cron:
|
||||
specifier: ^3.5.0
|
||||
version: 3.5.0
|
||||
@ -332,9 +335,11 @@ packages:
|
||||
resolution: {directory: ../midway-packages/core, type: directory}
|
||||
hasBin: true
|
||||
|
||||
'@cool-midway/rpc@file:../midway-packages/rpc':
|
||||
resolution: {directory: ../midway-packages/rpc, type: directory}
|
||||
|
||||
'@cool-midway/task@file:../midway-packages/task':
|
||||
resolution: {directory: ../midway-packages/task, type: directory}
|
||||
hasBin: true
|
||||
|
||||
'@emnapi/runtime@1.3.1':
|
||||
resolution: {integrity: sha512-kEBmG8KyqtxJZv+ygbEim+KCGtIq1fC22Ms3S4ziXmYKm8uyoLX0MHONVKwp+9opg390VaKRNt4a7A9NwmpNhw==}
|
||||
@ -1115,6 +1120,10 @@ packages:
|
||||
argparse@2.0.1:
|
||||
resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==}
|
||||
|
||||
args@5.0.3:
|
||||
resolution: {integrity: sha512-h6k/zfFgusnv3i5TU08KQkVKuCPBtL/PWQbWkHUxvJrZ2nAyeaUupneemcrgn1xmqxPQsPIzwkUhOpoqPDRZuA==}
|
||||
engines: {node: '>= 6.0.0'}
|
||||
|
||||
array-differ@3.0.0:
|
||||
resolution: {integrity: sha512-THtfYS6KtME/yIAhKjZ2ul7XI96lQGHRputJQHO80LAWQnuGP4iCIN8vdMRboGbIEYBwU33q8Tch1os2+X0kMg==}
|
||||
engines: {node: '>=8'}
|
||||
@ -1323,6 +1332,10 @@ packages:
|
||||
resolution: {integrity: sha512-YrwaA0vEKazPBkn0ipTiMpSajYDSe+KjQfrjhcBMxJt/znbvlHd8Pw/Vamaz5EB4Wfhs3SUR3Z9mwRu/P3s3Yg==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
camelcase@5.0.0:
|
||||
resolution: {integrity: sha512-faqwZqnWxbxn+F1d399ygeamQNy3lPp/H9H6rNrqYh4FSVCtcY+3cub1MxA8o9mDd55mM8Aghuu/kuyYA6VTsA==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
camelcase@5.3.1:
|
||||
resolution: {integrity: sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==}
|
||||
engines: {node: '>=6'}
|
||||
@ -2010,6 +2023,9 @@ packages:
|
||||
fast-uri@3.0.5:
|
||||
resolution: {integrity: sha512-5JnBCWpFlMo0a3ciDy/JckMzzv1U9coZrIhedq+HXxxUfDTAiS0LA8OKVao4G9BxmCVck/jtA5r3KAtRWEyD8Q==}
|
||||
|
||||
fastest-validator@1.19.0:
|
||||
resolution: {integrity: sha512-wUfJBrXmccVz4kARAiWTkuqsC6EFeqbNxwfysCDk+maExBPP8KxyBwaWtayrWjKIaBIbaz+rqI2kel6ecayxcg==}
|
||||
|
||||
fastq@1.18.0:
|
||||
resolution: {integrity: sha512-QKHXPW0hD8g4UET03SdOdunzSouc9N4AuHdsX8XNcTsuz+yYFILVNIX4l9yHABMhiEI9Db0JTTIpu0wB+Y1QQw==}
|
||||
|
||||
@ -2444,6 +2460,10 @@ packages:
|
||||
resolution: {integrity: sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g==}
|
||||
engines: {node: '>= 12'}
|
||||
|
||||
ipaddr.js@2.2.0:
|
||||
resolution: {integrity: sha512-Ag3wB2o37wslZS19hZqorUnrnzSkpOVy+IiiDEiTqNubEYpYuHWIf6K4psgN2ZWKExS4xhVCrRVfb/wfW8fWJA==}
|
||||
engines: {node: '>= 10'}
|
||||
|
||||
is-arguments@1.2.0:
|
||||
resolution: {integrity: sha512-7bVbi0huj/wrIAOzb8U1aszg9kdi3KN/CyU19CTI7tAoZYEZoL9yCDXpbXN+uPsuWnP02cyug1gleqq+TU+YCA==}
|
||||
engines: {node: '>= 0.4'}
|
||||
@ -2836,6 +2856,10 @@ packages:
|
||||
resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
kleur@4.1.5:
|
||||
resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
koa-bodyparser@4.4.1:
|
||||
resolution: {integrity: sha512-kBH3IYPMb+iAXnrxIhXnW+gXV8OTzCu8VPDqvcDHW9SQrbkHmqPQtiZwrltNmSq6/lpipHnT7k7PsjlVD7kK0w==}
|
||||
engines: {node: '>=8.0.0'}
|
||||
@ -2867,6 +2891,10 @@ packages:
|
||||
resolution: {integrity: sha512-Y+CjUfLmIpoUCCRl0ub4smrYtGGr5AOa2AKOaWelGHOGz33X/Y/KizefGqbkwfz44+cnq/+9habclf8vOmu2LA==}
|
||||
engines: {node: '>=0.2.0'}
|
||||
|
||||
leven@2.1.0:
|
||||
resolution: {integrity: sha512-nvVPLpIHUxCUoRLrFqTgSxXJ614d8AgQoWl7zPe/2VadE8+1dpU3LBhowRuBAcuwruWtOdD8oYC9jDNJjXDPyA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
leven@3.1.0:
|
||||
resolution: {integrity: sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==}
|
||||
engines: {node: '>=6'}
|
||||
@ -3160,9 +3188,86 @@ packages:
|
||||
module-details-from-path@1.0.3:
|
||||
resolution: {integrity: sha512-ySViT69/76t8VhE1xXHK6Ch4NcDd26gx0MzKXLO+F7NOtnqH68d9zF94nT8ZWSxXh8ELOERsnJO/sWt1xZYw5A==}
|
||||
|
||||
moleculer@0.14.35:
|
||||
resolution: {integrity: sha512-KB4qs0zNTjE9z7Bl27FFLPaWkAsUFJajF2njozJeor1phFCAYP5S1JsWOSrnUBTtsH7SX4gTw8tGRdcgh1eyVQ==}
|
||||
engines: {node: '>= 10.x.x'}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
amqplib: ^0.7.0 || ^0.8.0 || ^0.9.0 || ^0.10.0
|
||||
avsc: ^5.0.0
|
||||
bunyan: ^1.0.0
|
||||
cbor-x: ^0.8.3 || ^0.9.0 || ^1.2.0
|
||||
dd-trace: ^0.33.0 || ^0.34.0 || ^0.35.0 || ^0.36.0 || >=1.0.0 <1.6.0
|
||||
debug: ^4.0.0
|
||||
etcd3: ^1.0.0
|
||||
ioredis: ^4.0.0 || ^5.0.0
|
||||
jaeger-client: ^3.0.0
|
||||
kafka-node: ^5.0.0
|
||||
log4js: ^6.0.0
|
||||
mqtt: ^4.0.0 || ^5.0.0
|
||||
msgpack5: ^5.0.0 || ^6.0.0
|
||||
nats: ^1.0.0 || ^2.0.0
|
||||
node-nats-streaming: ^0.0.51 || ^0.2.0 || ^0.3.0
|
||||
notepack.io: ^2.0.0 || ^3.0.0
|
||||
pino: ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0
|
||||
protobufjs: ^6.0.0 || ^7.0.0
|
||||
redlock: ^4.0.0
|
||||
rhea-promise: ^1.0.0 || ^2.0.0
|
||||
thrift: ^0.12.0 || ^0.16.0
|
||||
winston: ^3.0.0
|
||||
peerDependenciesMeta:
|
||||
amqplib:
|
||||
optional: true
|
||||
avsc:
|
||||
optional: true
|
||||
bunyan:
|
||||
optional: true
|
||||
cbor-x:
|
||||
optional: true
|
||||
dd-trace:
|
||||
optional: true
|
||||
debug:
|
||||
optional: true
|
||||
etcd3:
|
||||
optional: true
|
||||
ioredis:
|
||||
optional: true
|
||||
jaeger-client:
|
||||
optional: true
|
||||
kafka-node:
|
||||
optional: true
|
||||
log4js:
|
||||
optional: true
|
||||
mqtt:
|
||||
optional: true
|
||||
msgpack5:
|
||||
optional: true
|
||||
nats:
|
||||
optional: true
|
||||
node-nats-streaming:
|
||||
optional: true
|
||||
notepack.io:
|
||||
optional: true
|
||||
pino:
|
||||
optional: true
|
||||
protobufjs:
|
||||
optional: true
|
||||
redlock:
|
||||
optional: true
|
||||
rhea-promise:
|
||||
optional: true
|
||||
thrift:
|
||||
optional: true
|
||||
winston:
|
||||
optional: true
|
||||
|
||||
moment@2.30.1:
|
||||
resolution: {integrity: sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==}
|
||||
|
||||
mri@1.1.4:
|
||||
resolution: {integrity: sha512-6y7IjGPm8AzlvoUrwAaw1tLnUBudaS3752vcd8JtrpGGQn+rXIe63LFVHm/YMwtqAuh+LJPCFdlLYPWM1nYn6w==}
|
||||
engines: {node: '>=4'}
|
||||
|
||||
ms@2.1.3:
|
||||
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
|
||||
|
||||
@ -3706,6 +3811,10 @@ packages:
|
||||
resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==}
|
||||
engines: {node: '>=8.10.0'}
|
||||
|
||||
recursive-watch@1.1.4:
|
||||
resolution: {integrity: sha512-fWejAmdLi7B/jipBUjTLnqId+PK+573fbGNbdaNA/AiAnQAx6OYOLCGWRs0W5+PyM1rLzZSWK2f40QpHSR49PQ==}
|
||||
hasBin: true
|
||||
|
||||
redent@3.0.0:
|
||||
resolution: {integrity: sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==}
|
||||
engines: {node: '>=8'}
|
||||
@ -4270,6 +4379,9 @@ packages:
|
||||
peerDependencies:
|
||||
typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta'
|
||||
|
||||
ttl@1.3.1:
|
||||
resolution: {integrity: sha512-+bGy9iDAqg3WSfc2ZrprToSPJhZjqy7vUv9wupQzsiv+BVPVx1T2a6G4T0290SpQj+56Toaw9BiLO5j5Bd7QzA==}
|
||||
|
||||
tunnel-agent@0.6.0:
|
||||
resolution: {integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==}
|
||||
|
||||
@ -4811,12 +4923,12 @@ snapshots:
|
||||
dependencies:
|
||||
lockfile: 1.0.4
|
||||
|
||||
'@cool-midway/core@file:../midway-packages/core':
|
||||
'@cool-midway/core@file:../midway-packages/core(debug@4.4.0)':
|
||||
dependencies:
|
||||
'@cool-midway/cache-manager-fs-hash': 7.0.0
|
||||
'@midwayjs/cache': 3.14.0
|
||||
'@midwayjs/cache-manager': 3.20.0
|
||||
axios: 1.7.9
|
||||
axios: 1.7.9(debug@4.4.0)
|
||||
commander: 13.0.0
|
||||
download: 8.0.0
|
||||
glob: 11.0.1
|
||||
@ -4835,6 +4947,35 @@ snapshots:
|
||||
- supports-color
|
||||
- utf-8-validate
|
||||
|
||||
'@cool-midway/rpc@file:../midway-packages/rpc(debug@4.4.0)(encoding@0.1.13)':
|
||||
dependencies:
|
||||
ioredis: 5.4.2
|
||||
moleculer: 0.14.35(debug@4.4.0)(encoding@0.1.13)(ioredis@5.4.2)
|
||||
transitivePeerDependencies:
|
||||
- amqplib
|
||||
- avsc
|
||||
- bunyan
|
||||
- cbor-x
|
||||
- dd-trace
|
||||
- debug
|
||||
- encoding
|
||||
- etcd3
|
||||
- jaeger-client
|
||||
- kafka-node
|
||||
- log4js
|
||||
- mqtt
|
||||
- msgpack5
|
||||
- nats
|
||||
- node-nats-streaming
|
||||
- notepack.io
|
||||
- pino
|
||||
- protobufjs
|
||||
- redlock
|
||||
- rhea-promise
|
||||
- supports-color
|
||||
- thrift
|
||||
- winston
|
||||
|
||||
'@cool-midway/task@file:../midway-packages/task':
|
||||
dependencies:
|
||||
bullmq: 5.34.10
|
||||
@ -5789,6 +5930,13 @@ snapshots:
|
||||
|
||||
argparse@2.0.1: {}
|
||||
|
||||
args@5.0.3:
|
||||
dependencies:
|
||||
camelcase: 5.0.0
|
||||
chalk: 2.4.2
|
||||
leven: 2.1.0
|
||||
mri: 1.1.4
|
||||
|
||||
array-differ@3.0.0: {}
|
||||
|
||||
array-union@2.1.0: {}
|
||||
@ -5830,9 +5978,9 @@ snapshots:
|
||||
|
||||
aws-ssl-profiles@1.1.2: {}
|
||||
|
||||
axios@1.7.9:
|
||||
axios@1.7.9(debug@4.4.0):
|
||||
dependencies:
|
||||
follow-redirects: 1.15.9(debug@4.3.7)
|
||||
follow-redirects: 1.15.9(debug@4.4.0)
|
||||
form-data: 4.0.1
|
||||
proxy-from-env: 1.1.0
|
||||
transitivePeerDependencies:
|
||||
@ -6078,6 +6226,8 @@ snapshots:
|
||||
map-obj: 4.3.0
|
||||
quick-lru: 4.0.1
|
||||
|
||||
camelcase@5.0.0: {}
|
||||
|
||||
camelcase@5.3.1: {}
|
||||
|
||||
camelcase@6.3.0: {}
|
||||
@ -6765,6 +6915,8 @@ snapshots:
|
||||
|
||||
fast-uri@3.0.5: {}
|
||||
|
||||
fastest-validator@1.19.0: {}
|
||||
|
||||
fastq@1.18.0:
|
||||
dependencies:
|
||||
reusify: 1.0.4
|
||||
@ -6838,6 +6990,10 @@ snapshots:
|
||||
optionalDependencies:
|
||||
debug: 4.3.7
|
||||
|
||||
follow-redirects@1.15.9(debug@4.4.0):
|
||||
optionalDependencies:
|
||||
debug: 4.4.0
|
||||
|
||||
for-each@0.3.3:
|
||||
dependencies:
|
||||
is-callable: 1.2.7
|
||||
@ -7258,6 +7414,8 @@ snapshots:
|
||||
jsbn: 1.1.0
|
||||
sprintf-js: 1.1.3
|
||||
|
||||
ipaddr.js@2.2.0: {}
|
||||
|
||||
is-arguments@1.2.0:
|
||||
dependencies:
|
||||
call-bound: 1.0.3
|
||||
@ -7856,6 +8014,8 @@ snapshots:
|
||||
|
||||
kleur@3.0.3: {}
|
||||
|
||||
kleur@4.1.5: {}
|
||||
|
||||
koa-bodyparser@4.4.1:
|
||||
dependencies:
|
||||
co-body: 6.2.0
|
||||
@ -7917,6 +8077,8 @@ snapshots:
|
||||
|
||||
lazy@1.0.11: {}
|
||||
|
||||
leven@2.1.0: {}
|
||||
|
||||
leven@3.1.0: {}
|
||||
|
||||
levn@0.3.0:
|
||||
@ -8182,8 +8344,28 @@ snapshots:
|
||||
|
||||
module-details-from-path@1.0.3: {}
|
||||
|
||||
moleculer@0.14.35(debug@4.4.0)(encoding@0.1.13)(ioredis@5.4.2):
|
||||
dependencies:
|
||||
args: 5.0.3
|
||||
eventemitter2: 6.4.9
|
||||
fastest-validator: 1.19.0
|
||||
glob: 7.2.3
|
||||
ipaddr.js: 2.2.0
|
||||
kleur: 4.1.5
|
||||
lodash: 4.17.21
|
||||
lru-cache: 6.0.0
|
||||
node-fetch: 2.7.0(encoding@0.1.13)
|
||||
recursive-watch: 1.1.4
|
||||
optionalDependencies:
|
||||
debug: 4.4.0
|
||||
ioredis: 5.4.2
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
|
||||
moment@2.30.1: {}
|
||||
|
||||
mri@1.1.4: {}
|
||||
|
||||
ms@2.1.3: {}
|
||||
|
||||
msgpackr-extract@3.0.3:
|
||||
@ -8845,6 +9027,10 @@ snapshots:
|
||||
dependencies:
|
||||
picomatch: 2.3.1
|
||||
|
||||
recursive-watch@1.1.4:
|
||||
dependencies:
|
||||
ttl: 1.3.1
|
||||
|
||||
redent@3.0.0:
|
||||
dependencies:
|
||||
indent-string: 4.0.0
|
||||
@ -9443,6 +9629,8 @@ snapshots:
|
||||
tslib: 1.14.1
|
||||
typescript: 5.7.3
|
||||
|
||||
ttl@1.3.1: {}
|
||||
|
||||
tunnel-agent@0.6.0:
|
||||
dependencies:
|
||||
safe-buffer: 5.2.1
|
||||
|
||||
202
public/swagger/LICENSE
Normal file
202
public/swagger/LICENSE
Normal file
@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
2
public/swagger/NOTICE
Normal file
2
public/swagger/NOTICE
Normal file
@ -0,0 +1,2 @@
|
||||
swagger-ui
|
||||
Copyright 2020-2021 SmartBear Software Inc.
|
||||
22
public/swagger/README.md
Normal file
22
public/swagger/README.md
Normal file
@ -0,0 +1,22 @@
|
||||
# Swagger UI Dist
|
||||
[](http://badge.fury.io/js/swagger-ui-dist)
|
||||
|
||||
# API
|
||||
|
||||
This module, `swagger-ui-dist`, exposes Swagger-UI's entire dist folder as a dependency-free npm module.
|
||||
Use `swagger-ui` instead, if you'd like to have npm install dependencies for you.
|
||||
|
||||
`SwaggerUIBundle` and `SwaggerUIStandalonePreset` can be imported:
|
||||
```javascript
|
||||
import { SwaggerUIBundle, SwaggerUIStandalonePreset } from "swagger-ui-dist"
|
||||
```
|
||||
|
||||
To get an absolute path to this directory for static file serving, use the exported `getAbsoluteFSPath` method:
|
||||
|
||||
```javascript
|
||||
const swaggerUiAssetPath = require("swagger-ui-dist").getAbsoluteFSPath()
|
||||
|
||||
// then instantiate server that serves files from the swaggerUiAssetPath
|
||||
```
|
||||
|
||||
For anything else, check the [Swagger-UI](https://github.com/swagger-api/swagger-ui) repository.
|
||||
14
public/swagger/absolute-path.js
Normal file
14
public/swagger/absolute-path.js
Normal file
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* getAbsoluteFSPath
|
||||
* @return {string} When run in NodeJS env, returns the absolute path to the current directory
|
||||
* When run outside of NodeJS, will return an error message
|
||||
*/
|
||||
const getAbsoluteFSPath = function () {
|
||||
// detect whether we are running in a browser or nodejs
|
||||
if (typeof module !== "undefined" && module.exports) {
|
||||
return require("path").resolve(__dirname)
|
||||
}
|
||||
throw new Error('getAbsoluteFSPath can only be called within a Nodejs environment');
|
||||
}
|
||||
|
||||
module.exports = getAbsoluteFSPath
|
||||
BIN
public/swagger/favicon-16x16.png
Normal file
BIN
public/swagger/favicon-16x16.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 665 B |
BIN
public/swagger/favicon-32x32.png
Normal file
BIN
public/swagger/favicon-32x32.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 628 B |
16
public/swagger/index.css
Normal file
16
public/swagger/index.css
Normal file
@ -0,0 +1,16 @@
|
||||
html {
|
||||
box-sizing: border-box;
|
||||
overflow: -moz-scrollbars-vertical;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
*,
|
||||
*:before,
|
||||
*:after {
|
||||
box-sizing: inherit;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
background: #fafafa;
|
||||
}
|
||||
19
public/swagger/index.html
Normal file
19
public/swagger/index.html
Normal file
@ -0,0 +1,19 @@
|
||||
<!-- HTML for static distribution bundle build -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Swagger UI</title>
|
||||
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" />
|
||||
<link rel="stylesheet" type="text/css" href="index.css" />
|
||||
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
|
||||
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="swagger-ui"></div>
|
||||
<script src="./swagger-ui-bundle.js" charset="UTF-8"> </script>
|
||||
<script src="./swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
|
||||
<script src="./swagger-initializer.js" charset="UTF-8"> </script>
|
||||
</body>
|
||||
</html>
|
||||
17
public/swagger/index.js
Normal file
17
public/swagger/index.js
Normal file
@ -0,0 +1,17 @@
|
||||
try {
|
||||
module.exports.SwaggerUIBundle = require("./swagger-ui-bundle.js")
|
||||
module.exports.SwaggerUIStandalonePreset = require("./swagger-ui-standalone-preset.js")
|
||||
} catch(e) {
|
||||
// swallow the error if there's a problem loading the assets.
|
||||
// allows this module to support providing the assets for browserish contexts,
|
||||
// without exploding in a Node context.
|
||||
//
|
||||
// see https://github.com/swagger-api/swagger-ui/issues/3291#issuecomment-311195388
|
||||
// for more information.
|
||||
}
|
||||
|
||||
// `absolutePath` and `getAbsoluteFSPath` are both here because at one point,
|
||||
// we documented having one and actually implemented the other.
|
||||
// They were both retained so we don't break anyone's code.
|
||||
module.exports.absolutePath = require("./absolute-path.js")
|
||||
module.exports.getAbsoluteFSPath = require("./absolute-path.js")
|
||||
79
public/swagger/oauth2-redirect.html
Normal file
79
public/swagger/oauth2-redirect.html
Normal file
@ -0,0 +1,79 @@
|
||||
<!doctype html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<title>Swagger UI: OAuth2 Redirect</title>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
'use strict';
|
||||
function run () {
|
||||
var oauth2 = window.opener.swaggerUIRedirectOauth2;
|
||||
var sentState = oauth2.state;
|
||||
var redirectUrl = oauth2.redirectUrl;
|
||||
var isValid, qp, arr;
|
||||
|
||||
if (/code|token|error/.test(window.location.hash)) {
|
||||
qp = window.location.hash.substring(1).replace('?', '&');
|
||||
} else {
|
||||
qp = location.search.substring(1);
|
||||
}
|
||||
|
||||
arr = qp.split("&");
|
||||
arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';});
|
||||
qp = qp ? JSON.parse('{' + arr.join() + '}',
|
||||
function (key, value) {
|
||||
return key === "" ? value : decodeURIComponent(value);
|
||||
}
|
||||
) : {};
|
||||
|
||||
isValid = qp.state === sentState;
|
||||
|
||||
if ((
|
||||
oauth2.auth.schema.get("flow") === "accessCode" ||
|
||||
oauth2.auth.schema.get("flow") === "authorizationCode" ||
|
||||
oauth2.auth.schema.get("flow") === "authorization_code"
|
||||
) && !oauth2.auth.code) {
|
||||
if (!isValid) {
|
||||
oauth2.errCb({
|
||||
authId: oauth2.auth.name,
|
||||
source: "auth",
|
||||
level: "warning",
|
||||
message: "Authorization may be unsafe, passed state was changed in server. The passed state wasn't returned from auth server."
|
||||
});
|
||||
}
|
||||
|
||||
if (qp.code) {
|
||||
delete oauth2.state;
|
||||
oauth2.auth.code = qp.code;
|
||||
oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
|
||||
} else {
|
||||
let oauthErrorMsg;
|
||||
if (qp.error) {
|
||||
oauthErrorMsg = "["+qp.error+"]: " +
|
||||
(qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
|
||||
(qp.error_uri ? "More info: "+qp.error_uri : "");
|
||||
}
|
||||
|
||||
oauth2.errCb({
|
||||
authId: oauth2.auth.name,
|
||||
source: "auth",
|
||||
level: "error",
|
||||
message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server."
|
||||
});
|
||||
}
|
||||
} else {
|
||||
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
|
||||
}
|
||||
window.close();
|
||||
}
|
||||
|
||||
if (document.readyState !== 'loading') {
|
||||
run();
|
||||
} else {
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
run();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
18
public/swagger/package.json
Normal file
18
public/swagger/package.json
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "swagger-ui-dist",
|
||||
"version": "5.10.0",
|
||||
"main": "index.js",
|
||||
"repository": "git@github.com:swagger-api/swagger-ui.git",
|
||||
"contributors": [
|
||||
"(in alphabetical order)",
|
||||
"Anna Bodnia <anna.bodnia@gmail.com>",
|
||||
"Buu Nguyen <buunguyen@gmail.com>",
|
||||
"Josh Ponelat <jponelat@gmail.com>",
|
||||
"Kyle Shockey <kyleshockey1@gmail.com>",
|
||||
"Robert Barnwell <robert@robertismy.name>",
|
||||
"Sahar Jafari <shr.jafari@gmail.com>"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {},
|
||||
"devDependencies": {}
|
||||
}
|
||||
20
public/swagger/swagger-initializer.js
Normal file
20
public/swagger/swagger-initializer.js
Normal file
@ -0,0 +1,20 @@
|
||||
window.onload = function() {
|
||||
//<editor-fold desc="Changeable Configuration Block">
|
||||
|
||||
// the following lines will be replaced by docker/configurator, when it runs in a docker-container
|
||||
window.ui = SwaggerUIBundle({
|
||||
url: "/swagger/json",
|
||||
dom_id: '#swagger-ui',
|
||||
deepLinking: true,
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIStandalonePreset
|
||||
],
|
||||
plugins: [
|
||||
SwaggerUIBundle.plugins.DownloadUrl
|
||||
],
|
||||
layout: "StandaloneLayout"
|
||||
});
|
||||
|
||||
//</editor-fold>
|
||||
};
|
||||
3
public/swagger/swagger-ui-bundle.js
Normal file
3
public/swagger/swagger-ui-bundle.js
Normal file
File diff suppressed because one or more lines are too long
1
public/swagger/swagger-ui-bundle.js.map
Normal file
1
public/swagger/swagger-ui-bundle.js.map
Normal file
File diff suppressed because one or more lines are too long
3
public/swagger/swagger-ui-es-bundle-core.js
Normal file
3
public/swagger/swagger-ui-es-bundle-core.js
Normal file
File diff suppressed because one or more lines are too long
1
public/swagger/swagger-ui-es-bundle-core.js.map
Normal file
1
public/swagger/swagger-ui-es-bundle-core.js.map
Normal file
File diff suppressed because one or more lines are too long
3
public/swagger/swagger-ui-es-bundle.js
Normal file
3
public/swagger/swagger-ui-es-bundle.js
Normal file
File diff suppressed because one or more lines are too long
1
public/swagger/swagger-ui-es-bundle.js.map
Normal file
1
public/swagger/swagger-ui-es-bundle.js.map
Normal file
File diff suppressed because one or more lines are too long
3
public/swagger/swagger-ui-standalone-preset.js
Normal file
3
public/swagger/swagger-ui-standalone-preset.js
Normal file
File diff suppressed because one or more lines are too long
1
public/swagger/swagger-ui-standalone-preset.js.map
Normal file
1
public/swagger/swagger-ui-standalone-preset.js.map
Normal file
File diff suppressed because one or more lines are too long
3
public/swagger/swagger-ui.css
Normal file
3
public/swagger/swagger-ui.css
Normal file
File diff suppressed because one or more lines are too long
1
public/swagger/swagger-ui.css.map
Normal file
1
public/swagger/swagger-ui.css.map
Normal file
File diff suppressed because one or more lines are too long
2
public/swagger/swagger-ui.js
Normal file
2
public/swagger/swagger-ui.js
Normal file
File diff suppressed because one or more lines are too long
1
public/swagger/swagger-ui.js.map
Normal file
1
public/swagger/swagger-ui.js.map
Normal file
File diff suppressed because one or more lines are too long
@ -19,8 +19,6 @@ export default {
|
||||
logging: true,
|
||||
// 实体路径
|
||||
entities,
|
||||
// 时区
|
||||
timezone: '+08:00',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@ -19,7 +19,7 @@ import * as ProdConfig from './config/config.prod';
|
||||
import * as cool from '@cool-midway/core';
|
||||
import * as upload from '@midwayjs/upload';
|
||||
import * as task from '@cool-midway/task';
|
||||
import './modules/base/entity/base';
|
||||
// import * as rpc from '@cool-midway/rpc';
|
||||
|
||||
@Configuration({
|
||||
imports: [
|
||||
@ -39,6 +39,8 @@ import './modules/base/entity/base';
|
||||
upload,
|
||||
// cool-admin 官方组件 https://cool-js.com
|
||||
cool,
|
||||
// rpc 微服务 远程调用
|
||||
// rpc,
|
||||
// 任务与队列
|
||||
task,
|
||||
{
|
||||
|
||||
301
src/modules/swagger/builder.ts
Normal file
301
src/modules/swagger/builder.ts
Normal file
@ -0,0 +1,301 @@
|
||||
import { CoolEps } from '@cool-midway/core';
|
||||
import { Config, Inject, Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
/**
|
||||
* 构建文档
|
||||
*/
|
||||
@Provide()
|
||||
@Scope(ScopeEnum.Singleton)
|
||||
export class SwaggerBuilder {
|
||||
@Config('module.swagger.base')
|
||||
swaggerBase;
|
||||
|
||||
@Inject()
|
||||
eps: CoolEps;
|
||||
|
||||
json = {};
|
||||
|
||||
@Config('cool.eps')
|
||||
epsConfig: boolean;
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*/
|
||||
async init() {
|
||||
if (this.epsConfig) {
|
||||
await this.build();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建文档
|
||||
*/
|
||||
async build() {
|
||||
const epsData = {
|
||||
app: this.eps.app || [],
|
||||
admin: this.eps.admin || [],
|
||||
module: this.eps.module || {},
|
||||
};
|
||||
this.json = this.convertToSwagger(epsData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Epss转换为Swagger
|
||||
* @param dataJson
|
||||
* @returns
|
||||
*/
|
||||
convertToSwagger(dataJson) {
|
||||
const swagger = {
|
||||
...this.swaggerBase,
|
||||
paths: {},
|
||||
tags: Object.keys(dataJson.module)
|
||||
.filter(item => item != 'swagger')
|
||||
.map(moduleKey => {
|
||||
return {
|
||||
key: moduleKey,
|
||||
name: dataJson.module[moduleKey].name || '',
|
||||
description: dataJson.module[moduleKey].description || '',
|
||||
};
|
||||
}),
|
||||
};
|
||||
// 添加组件
|
||||
function addComponentSchemas(data) {
|
||||
if (_.isEmpty(data.name)) return;
|
||||
const schema = {
|
||||
type: 'object',
|
||||
properties: {},
|
||||
required: [],
|
||||
};
|
||||
|
||||
data.columns.forEach(column => {
|
||||
const swaggerType = mapTypeToSwagger(column.type);
|
||||
schema.properties[column.propertyName] = {
|
||||
type: swaggerType,
|
||||
description: column.comment,
|
||||
};
|
||||
|
||||
if (!column.nullable) {
|
||||
schema.required.push(column.propertyName);
|
||||
}
|
||||
});
|
||||
|
||||
swagger.components.schemas[data.name] = schema;
|
||||
return data.name;
|
||||
}
|
||||
// 转换类型
|
||||
function mapTypeToSwagger(type) {
|
||||
const typeMapping = {
|
||||
string: 'string',
|
||||
number: 'number',
|
||||
bigint: 'integer',
|
||||
datetime: 'string', // assuming datetime is formatted as ISO8601 string
|
||||
};
|
||||
return typeMapping[type] || 'string';
|
||||
}
|
||||
// 添加请求体
|
||||
function addRequest(path, schemas, data) {
|
||||
if (path == '/info' || path == '/list' || path == '/page') {
|
||||
if (path == '/info') {
|
||||
data.parameters = [
|
||||
{
|
||||
name: 'id',
|
||||
in: 'query',
|
||||
description: 'ID',
|
||||
required: true,
|
||||
schema: {
|
||||
type: 'integer',
|
||||
},
|
||||
},
|
||||
];
|
||||
} else {
|
||||
data.requestBody = {
|
||||
description: '动态请求体',
|
||||
required: true,
|
||||
content: {
|
||||
'application/json': {
|
||||
schema: {
|
||||
type: 'object',
|
||||
properties:
|
||||
path == '/page'
|
||||
? {
|
||||
page: {
|
||||
type: 'integer',
|
||||
description: '第几页',
|
||||
default: 1,
|
||||
},
|
||||
size: {
|
||||
type: 'integer',
|
||||
description: '每页大小',
|
||||
default: 20,
|
||||
},
|
||||
}
|
||||
: {},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
data.responses = {
|
||||
'200': {
|
||||
description: '成功响应',
|
||||
content: {
|
||||
'application/json': {
|
||||
schema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
code: {
|
||||
type: 'integer',
|
||||
description: '状态码',
|
||||
},
|
||||
message: {
|
||||
type: 'string',
|
||||
description: '响应消息',
|
||||
},
|
||||
data: {
|
||||
$ref: `#/components/schemas/${schemas}`,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
if (path == '/add' || path == '/update') {
|
||||
data.requestBody = {
|
||||
description: schemas,
|
||||
required: true,
|
||||
content: {
|
||||
'application/json': {
|
||||
schema: {
|
||||
$ref: `#/components/schemas/${schemas}`,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
data.responses = {
|
||||
'200': {
|
||||
description: '成功响应',
|
||||
content: {
|
||||
'application/json': {
|
||||
example: {
|
||||
code: 1000,
|
||||
message: 'success',
|
||||
data: {
|
||||
id: 6,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
if (path == '/delete') {
|
||||
data.requestBody = {
|
||||
description: schemas,
|
||||
required: true,
|
||||
content: {
|
||||
'application/json': {
|
||||
schema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
ids: {
|
||||
type: 'array',
|
||||
description: 'ID数组',
|
||||
items: {
|
||||
type: 'integer',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
data.responses = {
|
||||
'200': {
|
||||
description: '成功响应',
|
||||
content: {
|
||||
'application/json': {
|
||||
example: {
|
||||
code: 1000,
|
||||
message: 'success',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
// 处理每个模块下的API接口
|
||||
function processModuleApis(moduleApis, moduleName) {
|
||||
moduleApis.forEach(module => {
|
||||
const schemas = addComponentSchemas({
|
||||
name: module.name,
|
||||
columns: module.columns,
|
||||
});
|
||||
if (Array.isArray(module.api)) {
|
||||
module.api.forEach(api => {
|
||||
const fullPath = `${api.prefix == '/' ? '' : api.prefix}${
|
||||
api.path
|
||||
}`;
|
||||
const method = api.method.toLowerCase();
|
||||
|
||||
if (!swagger.paths[fullPath]) {
|
||||
swagger.paths[fullPath] = {};
|
||||
}
|
||||
|
||||
swagger.paths[fullPath][method] = {
|
||||
summary:
|
||||
`【${module.info.type.description || module.info.type.name}】` +
|
||||
api.summary || '',
|
||||
security: api.ignoreToken
|
||||
? []
|
||||
: [
|
||||
{
|
||||
ApiKeyAuth: [],
|
||||
},
|
||||
],
|
||||
tags: [moduleName || '其他'],
|
||||
responses: schemas
|
||||
? {
|
||||
'200': {
|
||||
description: 'Success response',
|
||||
content: {
|
||||
'application/json': {
|
||||
schema: {
|
||||
$ref: `#/components/schemas/${schemas}`,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
: {},
|
||||
};
|
||||
addRequest(api.path, schemas, swagger.paths[fullPath][method]);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 遍历app和admin中的所有模块
|
||||
Object.keys(dataJson.app).forEach(moduleKey => {
|
||||
if (Array.isArray(dataJson.app[moduleKey])) {
|
||||
processModuleApis(
|
||||
dataJson.app[moduleKey],
|
||||
dataJson.module[moduleKey]?.name
|
||||
);
|
||||
}
|
||||
});
|
||||
Object.keys(dataJson.admin).forEach(moduleKey => {
|
||||
if (Array.isArray(dataJson.admin[moduleKey])) {
|
||||
processModuleApis(
|
||||
dataJson.admin[moduleKey],
|
||||
dataJson.module[moduleKey]?.name
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
return swagger;
|
||||
}
|
||||
}
|
||||
50
src/modules/swagger/config.ts
Normal file
50
src/modules/swagger/config.ts
Normal file
@ -0,0 +1,50 @@
|
||||
import { ModuleConfig } from '@cool-midway/core';
|
||||
|
||||
/**
|
||||
* 模块配置
|
||||
*/
|
||||
export default ({ app }) => {
|
||||
return {
|
||||
// 模块名称
|
||||
name: 'Swagger',
|
||||
// 模块描述
|
||||
description: '处理和生成swagger文档',
|
||||
// 中间件,只对本模块有效
|
||||
middlewares: [],
|
||||
// 中间件,全局有效
|
||||
globalMiddlewares: [],
|
||||
// 模块加载顺序,默认为0,值越大越优先加载
|
||||
order: 0,
|
||||
// swagger基本配置
|
||||
base: {
|
||||
openapi: '3.1.0',
|
||||
info: {
|
||||
title: 'Cool Admin 在线API文档',
|
||||
version: '8.x',
|
||||
description: '本文档是由Cool Admin内部自动构建完成',
|
||||
contact: {
|
||||
name: '开发文档',
|
||||
url: 'https://cool-js.com',
|
||||
},
|
||||
},
|
||||
// 请求地址
|
||||
servers: [
|
||||
{
|
||||
url: `http://127.0.0.1:${app?.getConfig('koa.port') || 8001}`,
|
||||
description: '本地后台地址',
|
||||
},
|
||||
],
|
||||
paths: {},
|
||||
components: {
|
||||
schemas: {},
|
||||
securitySchemes: {
|
||||
Auth: {
|
||||
type: 'apiKey',
|
||||
name: 'Authorization',
|
||||
in: 'header',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
} as ModuleConfig;
|
||||
};
|
||||
35
src/modules/swagger/controller/index.ts
Normal file
35
src/modules/swagger/controller/index.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import { Config, Controller, Get, Inject } from '@midwayjs/core';
|
||||
import { Context } from '@midwayjs/koa';
|
||||
import { SwaggerBuilder } from '../builder';
|
||||
import { BaseController } from '@cool-midway/core';
|
||||
|
||||
/**
|
||||
* 欢迎界面
|
||||
*/
|
||||
@Controller('/swagger')
|
||||
export class SwaggerIndexController extends BaseController {
|
||||
@Inject()
|
||||
ctx: Context;
|
||||
|
||||
@Inject()
|
||||
swaggerBuilder: SwaggerBuilder;
|
||||
|
||||
@Config('cool.eps')
|
||||
epsConfig: boolean;
|
||||
|
||||
@Get('/', { summary: 'swagger界面' })
|
||||
public async index() {
|
||||
if (!this.epsConfig) {
|
||||
return this.fail('Eps未开启');
|
||||
}
|
||||
await this.ctx.render('swagger', {});
|
||||
}
|
||||
|
||||
@Get('/json', { summary: '获得Swagger JSON数据' })
|
||||
public async json() {
|
||||
if (!this.epsConfig) {
|
||||
return this.fail('Eps未开启');
|
||||
}
|
||||
return this.swaggerBuilder.json;
|
||||
}
|
||||
}
|
||||
28
src/modules/swagger/event/app.ts
Normal file
28
src/modules/swagger/event/app.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { CoolEvent, Event } from '@cool-midway/core';
|
||||
import { App, ILogger, Inject, Logger } from '@midwayjs/core';
|
||||
import { IMidwayKoaApplication } from '@midwayjs/koa';
|
||||
import { SwaggerBuilder } from '../builder';
|
||||
|
||||
/**
|
||||
* 修改jwt.secret
|
||||
*/
|
||||
@CoolEvent()
|
||||
export class SwaggerAppEvent {
|
||||
@Logger()
|
||||
coreLogger: ILogger;
|
||||
|
||||
@App()
|
||||
app: IMidwayKoaApplication;
|
||||
|
||||
@Inject()
|
||||
swaggerBuilder: SwaggerBuilder;
|
||||
|
||||
@Event('onServerReady')
|
||||
async onServerReady() {
|
||||
this.swaggerBuilder.init().then(() => {
|
||||
this.coreLogger.info(
|
||||
'\x1B[36m [cool:module:swagger] midwayjs cool module swagger build success\x1B[0m'
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user