generated from stijnvanhulle/template
-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correct import when refs are using . syntax(creating subfolders) (#796)
* fix: remove use of ts namespace * chore: update examples * fix: A schema name with `pet.Pets` will be moved inside of the folder `src/gen/pet/pets/ts` instead of `src/gen/petPets.ts` * chore: update examples * chore: fix examples * chore: fix plugin zod
- Loading branch information
1 parent
3e46f03
commit bf1e521
Showing
42 changed files
with
181 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@kubb/swagger-ts": patch | ||
"@kubb/core": patch | ||
--- | ||
|
||
A schema name with `pet.Pets` will be moved inside of the folder `src/gen/pet/pets/ts` instead of `src/gen/petPets.ts` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
examples/advanced/src/gen/mocks/createTag.ts → ...s/advanced/src/gen/mocks/tag/createTag.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { faker } from '@faker-js/faker' | ||
import type { Tag } from '../models/ts/Tag' | ||
import type { TagTag } from '../../models/ts/tag/Tag' | ||
|
||
export function createTag(): NonNullable<Tag> { | ||
export function createTagTag(): NonNullable<TagTag> { | ||
return { 'id': faker.number.float({}), 'name': faker.string.alpha() } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './createTag' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/advanced/src/gen/models/ts/Tag.ts → ...les/advanced/src/gen/models/ts/tag/Tag.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export type Tag = { | ||
export type TagTag = { | ||
/** | ||
* @type integer | undefined int64 | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './Tag.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './tagSchema' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { z } from 'zod' | ||
import type { TagTag } from '../../models/ts/tag/Tag' | ||
|
||
export const tagTagSchema: z.ZodType<TagTag> = z.object({ 'id': z.number().optional(), 'name': z.string().optional() }) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { camelCase, pascalCase, pathCase } from './casing.ts' | ||
|
||
describe('casing', () => { | ||
test('camelCase', () => { | ||
expect(camelCase('pet pet')).toBe('petPet') | ||
expect(camelCase('pet.Pet', { isFile: true })).toBe('pet/pet') | ||
expect(camelCase('create tag.tag', { isFile: true })).toBe('createTag/tag') | ||
expect(camelCase('tag.tag', { isFile: true, prefix: 'create' })).toBe('tag/createTag') | ||
expect(camelCase('tag.tag', { isFile: true, suffix: 'schema' })).toBe('tag/tagSchema') | ||
}) | ||
test('pascalCase', () => { | ||
expect(pascalCase('pet pet')).toBe('PetPet') | ||
expect(pascalCase('pet.Pet', { isFile: true })).toBe('pet/Pet') | ||
expect(pascalCase('create tag.tag', { isFile: true })).toBe('createTag/Tag') | ||
expect(pascalCase('tag.tag', { isFile: true, prefix: 'create' })).toBe('tag/CreateTag') | ||
expect(pascalCase('tag.tag', { isFile: true, suffix: 'schema' })).toBe('tag/TagSchema') | ||
}) | ||
|
||
test('pathCase', () => { | ||
expect(pathCase('pet pet')).toBe('petpet') | ||
expect(pathCase('pet.Pet', { isFile: true })).toBe('pet/pet') | ||
expect(pathCase('create tag.tag', { isFile: true })).toBe('createTag/tag') | ||
expect(pathCase('tag.tag', { isFile: true, prefix: 'create' })).toBe('tag/createtag') | ||
expect(pathCase('tag.tag', { isFile: true, suffix: 'schema' })).toBe('tag/tagschema') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,37 @@ | ||
import { camelCase as changeCaseCamel, pascalCase as changePascalCase } from 'change-case' | ||
import { camelCase as changeCamelCase, pascalCase as changePascalCase, pathCase as changePathCase } from 'change-case' | ||
|
||
export function camelCase(text: string): string { | ||
return changeCaseCamel(text, { delimiter: '', mergeAmbiguousCharacters: true }) | ||
type Options = { | ||
/** | ||
* When set it will replace all `.` with `/`. | ||
*/ | ||
isFile?: boolean | ||
prefix?: string | ||
suffix?: string | ||
} | ||
|
||
export function pascalCase(text: string): string { | ||
return changePascalCase(text, { delimiter: '', mergeAmbiguousCharacters: true }) | ||
export function camelCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string { | ||
if (isFile) { | ||
const splitArray = text.split('.') | ||
return splitArray.map((item, i) => i === splitArray.length - 1 ? camelCase(item, { prefix, suffix }) : camelCase(item)).join('/') | ||
} | ||
|
||
return changeCamelCase(`${prefix} ${text} ${suffix}`, { delimiter: '', mergeAmbiguousCharacters: true }) | ||
} | ||
|
||
export function pascalCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string { | ||
if (isFile) { | ||
const splitArray = text.split('.') | ||
return splitArray.map((item, i) => i === splitArray.length - 1 ? pascalCase(item, { prefix, suffix }) : camelCase(item)).join('/') | ||
} | ||
|
||
return changePascalCase(`${prefix} ${text} ${suffix}`, { delimiter: '', mergeAmbiguousCharacters: true }) | ||
} | ||
|
||
export function pathCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string { | ||
if (isFile) { | ||
const splitArray = text.split('.') | ||
return splitArray.map((item, i) => i === splitArray.length - 1 ? pathCase(item, { prefix, suffix }) : camelCase(item)).join('/') | ||
} | ||
|
||
return changePathCase(`${prefix} ${text} ${suffix}`, { delimiter: '' }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
bf1e521
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
kubb – ./
kubb-git-main-kubb.vercel.app
www.kubb.dev
kubb-kubb.vercel.app
kubb.dev