Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(enum): append index number on duplicate name #217

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fifty-glasses-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hey-api/openapi-ts": patch
---

fix(enum): append index number on duplicate name
19 changes: 10 additions & 9 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,23 @@
"es6": true,
"node": true
},
"plugins": ["simple-import-sort"],
"plugins": ["simple-import-sort", "sort-keys-fix"],
"rules": {
"@typescript-eslint/ban-ts-comment": 0,
"@typescript-eslint/ban-ts-ignore": 0,
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/explicit-module-boundary-types": 0,
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-inferrable-types": 0,
"@typescript-eslint/no-non-null-assertion": 0,
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-var-requires": "off",
"arrow-body-style": "error",
"import/order": "off",
"object-shorthand": "error",
"prettier/prettier": ["error"],
"simple-import-sort/exports": "error",
"simple-import-sort/imports": "error",
"sort-imports": "off"
"sort-imports": "off",
"sort-keys-fix/sort-keys-fix": "warn"
}
}
60 changes: 60 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.1.3",
"eslint-plugin-simple-import-sort": "12.0.0",
"eslint-plugin-sort-keys-fix": "1.1.2",
"express": "4.19.2",
"node-fetch": "3.3.2",
"npm-run-all2": "6.1.2",
Expand Down
16 changes: 8 additions & 8 deletions rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ import { defineConfig } from 'rollup';
*/
export function handlebarsPlugin(): Plugin {
return {
name: 'handlebars',
resolveId: (file: any, importer: any) => {
if (path.extname(file) === '.hbs') {
return path.resolve(path.dirname(importer), file);
}
return null;
},
load: (file: any) => {
if (path.extname(file) === '.hbs') {
const template = readFileSync(file, 'utf8').toString().trim();
Expand All @@ -41,9 +34,9 @@ export function handlebarsPlugin(): Plugin {
escapeDescription: true,
escapeNewline: true,
exactArray: true,
ifdef: true,
ifNotNullNotUndefined: true,
ifOperationDataOptional: true,
ifdef: true,
intersection: true,
modelUnionType: true,
nameOperationDataType: true,
Expand All @@ -60,6 +53,13 @@ export function handlebarsPlugin(): Plugin {
}
return null;
},
name: 'handlebars',
resolveId: (file: any, importer: any) => {
if (path.extname(file) === '.hbs') {
return path.resolve(path.dirname(importer), file);
}
return null;
},
};
}

Expand Down
2 changes: 1 addition & 1 deletion rollup.dts.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url)).
const external = [/^node:*/, ...Object.keys(pkg.dependencies), ...Object.keys(pkg.devDependencies)];

export default defineConfig({
external,
input: {
index: './temp/node/index.d.ts',
},
output: {
dir: './dist/node',
format: 'esm',
},
external,
plugins: [dts({ respectExternal: true })],
});
18 changes: 9 additions & 9 deletions src/openApi/common/parser/__tests__/getPattern.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { getPattern } from '../getPattern';

describe('getPattern', () => {
it.each([
{ pattern: undefined, expected: undefined },
{ pattern: '', expected: '' },
{ pattern: '^[a-zA-Z]', expected: '^[a-zA-Z]' },
{ pattern: '^\\w+$', expected: '^\\\\w+$' },
{ pattern: '^\\d{3}-\\d{2}-\\d{4}$', expected: '^\\\\d{3}-\\\\d{2}-\\\\d{4}$' },
{ pattern: '\\', expected: '\\\\' },
{ pattern: '\\/', expected: '\\\\/' },
{ pattern: '\\/\\/', expected: '\\\\/\\\\/' },
{ pattern: "'", expected: "\\'" },
{ expected: undefined, pattern: undefined },
{ expected: '', pattern: '' },
{ expected: '^[a-zA-Z]', pattern: '^[a-zA-Z]' },
{ expected: '^\\\\w+$', pattern: '^\\w+$' },
{ expected: '^\\\\d{3}-\\\\d{2}-\\\\d{4}$', pattern: '^\\d{3}-\\d{2}-\\d{4}$' },
{ expected: '\\\\', pattern: '\\' },
{ expected: '\\\\/', pattern: '\\/' },
{ expected: '\\\\/\\\\/', pattern: '\\/\\/' },
{ expected: "\\'", pattern: "'" },
])('getPattern($pattern) -> $expected', ({ pattern, expected }) => {
expect(getPattern(pattern)).toEqual(expected);
});
Expand Down
36 changes: 18 additions & 18 deletions src/openApi/common/parser/__tests__/getRef.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ describe('getRef (v2)', () => {
expect(
getRef(
{
swagger: '2.0',
info: {
title: 'dummy',
version: '1.0',
},
host: 'localhost:8080',
basePath: '/api',
schemes: ['http', 'https'],
paths: {},
definitions: {
Example: {
description: 'This is an Example model ',
type: 'integer',
},
},
host: 'localhost:8080',
info: {
title: 'dummy',
version: '1.0',
},
paths: {},
schemes: ['http', 'https'],
swagger: '2.0',
},
{
$ref: '#/definitions/Example',
Expand All @@ -39,25 +39,25 @@ describe('getRef (v3)', () => {
expect(
getRef(
{
openapi: '3.0',
components: {
schemas: {
Example: {
description: 'This is an Example model ',
type: 'integer',
},
},
},
info: {
title: 'dummy',
version: '1.0',
},
openapi: '3.0',
paths: {},
servers: [
{
url: 'https://localhost:8080/api',
},
],
components: {
schemas: {
Example: {
description: 'This is an Example model ',
type: 'integer',
},
},
},
},
{
$ref: '#/components/schemas/Example',
Expand All @@ -73,11 +73,11 @@ describe('getRef (v3)', () => {
expect(
getRef(
{
openapi: '3.0',
info: {
title: 'dummy',
version: '1.0',
},
openapi: '3.0',
paths: {
'/api/user/{id}': {
description: 'This is an Example path',
Expand Down
Loading
Loading