Skip to content

Commit

Permalink
feat(mock): support all openapi method
Browse files Browse the repository at this point in the history
  • Loading branch information
liangskyli committed May 13, 2023
1 parent f651857 commit a490bf8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
14 changes: 12 additions & 2 deletions packages/mock/src/http/mock/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,18 @@ import multer from 'multer';
import { join } from 'path';
import { pathToRegexp } from 'path-to-regexp';

const VALID_METHODS = ['get', 'post', 'put', 'patch', 'delete'];
const BODY_PARSED_METHODS = ['post', 'put', 'patch', 'delete'];
// support all openapi method
const VALID_METHODS = [
'get',
'put',
'post',
'delete',
'options',
'head',
'patch',
'trace',
];
const BODY_PARSED_METHODS = VALID_METHODS.filter((item) => item !== 'get');

const debug = createDebug('mock:utils');

Expand Down
2 changes: 1 addition & 1 deletion packages/mock/test/mock.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { IOpts } from '../src/http/server/server';
const config: IOpts = {
mockDir: path.join(__dirname, '/'),
//mockDir: path.join(__dirname, '/gen-mock'),
//mockDir: path.join(__dirname, '../../http-mock-gen/test/gen-mock/'),
//mockDir: path.join(__dirname, '../../http-mock-gen/test/all-gen-dirs/gen-mock/'),
port: 8002,
socketConfig: {
enable: true,
Expand Down
4 changes: 2 additions & 2 deletions packages/mock/test/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ mockServer({
});
//mockServer({port: 9001 });
//mockServer({hostname: '127.0.0.1',port: 9001 });
//console.log(path.join(__dirname, '../../http-mock-gen/test/gen-mock/'));
//console.log(path.join(__dirname, '../../http-mock-gen/test/all-gen-dirs/gen-mock/'));
/*mockServer({
port: 7010,
mockDir: path.join(__dirname, '../../http-mock-gen/test/gen-mock/'),
mockDir: path.join(__dirname, '../../http-mock-gen/test/all-gen-dirs/gen-mock/'),
});*/

0 comments on commit a490bf8

Please sign in to comment.