mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 17:01:00 +03:00
Feature: interactive swagger-ui auto-generated API docs from express (#1812)
* Add interactive swagger-ui auto-generated API docs from express * Update README.md * Update index.ts //@ts-ignore * Fix eslint no-console error * Add swagger paths * Add all end points * Update swagger.yml * update swagger yml file * update swagger config --------- Co-authored-by: Henry <hzj94@hotmail.com>
This commit is contained in:
committed by
GitHub
parent
0f58d31493
commit
e8f5f07735
@@ -1,11 +1,11 @@
|
||||
import { Request } from 'express'
|
||||
import { ChatFlow } from '../../src/database/entities/ChatFlow'
|
||||
import { utilValidateKey } from '../../src/utils/validateKey'
|
||||
import { validateChatflowAPIKey } from '../../src/utils/validateKey'
|
||||
import { compareKeys, getAPIKeys } from '../../src/utils/apiKey'
|
||||
|
||||
jest.mock('../../src/utils/apiKey')
|
||||
|
||||
describe('utilValidateKey', () => {
|
||||
describe('validateChatflowAPIKey', () => {
|
||||
let req: Partial<Request>
|
||||
let chatflow: ChatFlow
|
||||
|
||||
@@ -19,13 +19,13 @@ describe('utilValidateKey', () => {
|
||||
})
|
||||
|
||||
it('should return true if chatflow.apikeyid is not set', async () => {
|
||||
const result = await utilValidateKey(req as Request, chatflow)
|
||||
const result = await validateChatflowAPIKey(req as Request, chatflow)
|
||||
expect(result).toBe(true)
|
||||
})
|
||||
|
||||
it('should return false if chatflow.apikeyid is set but authorization header is missing', async () => {
|
||||
chatflow.apikeyid = 'some-api-key-id'
|
||||
const result = await utilValidateKey(req as Request, chatflow)
|
||||
const result = await validateChatflowAPIKey(req as Request, chatflow)
|
||||
expect(result).toBe(false)
|
||||
})
|
||||
|
||||
@@ -35,7 +35,7 @@ describe('utilValidateKey', () => {
|
||||
;(getAPIKeys as jest.Mock).mockResolvedValue([{ id: 'some-api-key-id', apiSecret: 'expected-secret-key' }])
|
||||
;(compareKeys as jest.Mock).mockImplementation((expected, supplied) => expected === supplied)
|
||||
|
||||
const result = await utilValidateKey(req as Request, chatflow)
|
||||
const result = await validateChatflowAPIKey(req as Request, chatflow)
|
||||
expect(result).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user