Skip to content

Commit

Permalink
feat: 关键字字典调整
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudcome committed Jan 3, 2025
1 parent e233e98 commit fa7dfff
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/printer/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,21 @@ export const KEYWORD_VARS = [
'namespace',
'async',
'await',
// 上下文关键字
'any',
'boolean',
'constructor',
'declare',
'get',
'module',
'require',
'number',
'set',
'string',
'symbol',
'type',
'from',
'of',
// // 上下文关键字
// 'any',
// 'boolean',
// 'constructor',
// 'declare',
// 'get',
// 'module',
// 'require',
// 'number',
// 'set',
// 'string',
// 'symbol',
// 'type',
// 'from',
// 'of',
];

export const AXIOS_IMPORT_NAME = 'axios';
Expand Down
48 changes: 48 additions & 0 deletions test/printer/arg.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,3 +367,51 @@ it('n*path + n*query + n*header', () => {
}"
`);
});

it('path name unique', () => {
const printer = new Printer({
openapi: '3.1.0',
info: {
title: 'test',
version: '1.0.0',
},
paths: {
'/pets/{type}': {
get: {
operationId: 'getPet',
parameters: [
{
in: 'path',
name: 'type',
schema: {
type: 'string',
},
},
],
},
},
},
});

expect(
printer.print({
hideImports: true,
hideHeaders: true,
hideFooters: true,
hideInfo: true,
hideHelpers: true,
}),
).toMatchInlineSnapshot(`
"/**
* @param type request path "type"
* @param [config] request config
*/
export async function getPet(type:string,config?:AxiosRequestConfig): AxiosPromise<unknown> {
return axios({
method: "get",
url: \`/pets/\${type}\`,
...config
});
}"
`);
});

0 comments on commit fa7dfff

Please sign in to comment.