Skip to content

Commit

Permalink
Merge branch 'main' into feat/784
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnvanhulle committed Jan 21, 2024
2 parents 066b3b2 + bf1e521 commit 71f4eec
Show file tree
Hide file tree
Showing 173 changed files with 874 additions and 778 deletions.
6 changes: 6 additions & 0 deletions .changeset/perfect-trees-juggle.md
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`
5 changes: 5 additions & 0 deletions .changeset/polite-bikes-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@kubb/swagger": patch
---

Do not create barrel files with `getGroupedByTagFiles`
5 changes: 5 additions & 0 deletions .changeset/rude-clocks-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@kubb/swagger-ts": patch
---

Remove use of namespace
3 changes: 2 additions & 1 deletion docs/plugins/swagger-zod/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ export default defineConfig({
})
```

:::

### typed

Use TypeScript(`@kubb/swagger-ts`) to add type annotation.
Expand Down Expand Up @@ -400,7 +402,6 @@ export default defineConfig({
})
```

:::

:::

Expand Down
6 changes: 3 additions & 3 deletions examples/advanced/petStore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ components:
example: 1
xml:
name: user
Tag:
tag.Tag:
type: object
properties:
id:
Expand Down Expand Up @@ -851,7 +851,7 @@ components:
xml:
wrapped: true
items:
$ref: "#/components/schemas/Tag"
$ref: "#/components/schemas/tag.Tag"
status:
type: string
description: pet status in the store
Expand Down Expand Up @@ -889,7 +889,7 @@ components:
xml:
wrapped: true
items:
$ref: "#/components/schemas/Tag"
$ref: "#/components/schemas/tag.Tag"
status:
type: string
description: pet status in the store
Expand Down
4 changes: 2 additions & 2 deletions examples/advanced/src/gen/mocks/createAddPetRequest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createCategory } from './createCategory'
import { createTag } from './createTag'
import { createTagTag } from './tag/createTag'
import { faker } from '@faker-js/faker'
import type { AddPetRequest } from '../models/ts/AddPetRequest'

Expand All @@ -9,7 +9,7 @@ export function createAddPetRequest(): NonNullable<AddPetRequest> {
'name': faker.string.alpha(),
'category': createCategory(),
'photoUrls': faker.helpers.arrayElements([faker.string.alpha()]) as any,
'tags': faker.helpers.arrayElements([createTag()]) as any,
'tags': faker.helpers.arrayElements([createTagTag()]) as any,
'status': faker.helpers.arrayElement<any>([`available`, `pending`, `sold`]),
}
}
4 changes: 2 additions & 2 deletions examples/advanced/src/gen/mocks/createPet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createCategory } from './createCategory'
import { createTag } from './createTag'
import { createTagTag } from './tag/createTag'
import { faker } from '@faker-js/faker'
import type { Pet } from '../models/ts/Pet'

Expand All @@ -9,7 +9,7 @@ export function createPet(): NonNullable<Pet> {
'name': faker.string.alpha(),
'category': createCategory(),
'photoUrls': faker.helpers.arrayElements([faker.string.alpha()]) as any,
'tags': faker.helpers.arrayElements([createTag()]) as any,
'tags': faker.helpers.arrayElements([createTagTag()]) as any,
'status': faker.helpers.arrayElement<any>([`available`, `pending`, `sold`]),
}
}
2 changes: 1 addition & 1 deletion examples/advanced/src/gen/mocks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ export * from './createCustomer'
export * from './createOrder'
export * from './createPet'
export * from './createPetNotFound'
export * from './createTag'
export * from './createUser'
export * from './createUserArray'
export * from './tag/index'
export * as petsMocks from './petsController/index'
export * as petMocks from './petController/index'
export * as userMocks from './userController/index'
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() }
}
1 change: 1 addition & 0 deletions examples/advanced/src/gen/mocks/tag/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './createTag'
4 changes: 2 additions & 2 deletions examples/advanced/src/gen/models/ts/AddPetRequest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Category } from './Category'
import type { Tag } from './Tag'
import type { TagTag } from './tag/Tag'

export const AddPetRequestStatus = {
'available': 'available',
Expand All @@ -26,7 +26,7 @@ export type AddPetRequest = {
/**
* @type array | undefined
*/
tags?: Tag[]
tags?: TagTag[]
/**
* @description pet status in the store
* @type string | undefined
Expand Down
4 changes: 2 additions & 2 deletions examples/advanced/src/gen/models/ts/Pet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Category } from './Category'
import type { Tag } from './Tag'
import type { TagTag } from './tag/Tag'

export const PetStatus = {
'available': 'available',
Expand All @@ -26,7 +26,7 @@ export type Pet = {
/**
* @type array | undefined
*/
tags?: Tag[]
tags?: TagTag[]
/**
* @description pet status in the store
* @type string | undefined
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced/src/gen/models/ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export * from './petController/index.js'
export * from './PetNotFound.js'
export * from './petsController/index.js'
export * from './storeController/index.js'
export * from './Tag.js'
export * from './tag/index.js'
export * from './User.js'
export * from './UserArray.js'
export * from './userController/index.js'
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export type FindPetsByStatusQueryParams = {
* @description successful operation
*/
export type FindPetsByStatusQueryResponse = Pet[]
export namespace FindPetsByStatusQuery {
export type Response = FindPetsByStatusQueryResponse
export type QueryParams = FindPetsByStatusQueryParams
export type Errors = FindPetsByStatus400
export type FindPetsByStatusQuery = {
Response: FindPetsByStatusQueryResponse
QueryParams: FindPetsByStatusQueryParams
Errors: FindPetsByStatus400
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ export type FindPetsByTagsQueryParams = {
* @description successful operation
*/
export type FindPetsByTagsQueryResponse = Pet[]
export namespace FindPetsByTagsQuery {
export type Response = FindPetsByTagsQueryResponse
export type QueryParams = FindPetsByTagsQueryParams
export type HeaderParams = FindPetsByTagsHeaderParams
export type Errors = FindPetsByTags400
export type FindPetsByTagsQuery = {
Response: FindPetsByTagsQueryResponse
QueryParams: FindPetsByTagsQueryParams
HeaderParams: FindPetsByTagsHeaderParams
Errors: FindPetsByTags400
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export type GetPetByIdPathParams = {
* @description successful operation
*/
export type GetPetByIdQueryResponse = Omit<NonNullable<Pet>, 'name'>
export namespace GetPetByIdQuery {
export type Response = GetPetByIdQueryResponse
export type PathParams = GetPetByIdPathParams
export type Errors = GetPetById400 | GetPetById404
export type GetPetByIdQuery = {
Response: GetPetByIdQueryResponse
PathParams: GetPetByIdPathParams
Errors: GetPetById400 | GetPetById404
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
export type GetInventoryQueryResponse = {
[key: string]: number
}
export namespace GetInventoryQuery {
export type Response = GetInventoryQueryResponse
export type GetInventoryQuery = {
Response: GetInventoryQueryResponse
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export type GetOrderByIdPathParams = {
* @description successful operation
*/
export type GetOrderByIdQueryResponse = Order
export namespace GetOrderByIdQuery {
export type Response = GetOrderByIdQueryResponse
export type PathParams = GetOrderByIdPathParams
export type Errors = GetOrderById400 | GetOrderById404
export type GetOrderByIdQuery = {
Response: GetOrderByIdQueryResponse
PathParams: GetOrderByIdPathParams
Errors: GetOrderById400 | GetOrderById404
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type Tag = {
export type TagTag = {
/**
* @type integer | undefined int64
*/
Expand Down
1 change: 1 addition & 0 deletions examples/advanced/src/gen/models/ts/tag/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Tag.js'
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export type GetUserByNamePathParams = {
* @description successful operation
*/
export type GetUserByNameQueryResponse = User
export namespace GetUserByNameQuery {
export type Response = GetUserByNameQueryResponse
export type PathParams = GetUserByNamePathParams
export type Errors = GetUserByName400 | GetUserByName404
export type GetUserByNameQuery = {
Response: GetUserByNameQueryResponse
PathParams: GetUserByNamePathParams
Errors: GetUserByName400 | GetUserByName404
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export type LoginUserQueryParams = {
* @description successful operation
*/
export type LoginUserQueryResponse = string
export namespace LoginUserQuery {
export type Response = LoginUserQueryResponse
export type QueryParams = LoginUserQueryParams
export type Errors = LoginUser400
export type LoginUserQuery = {
Response: LoginUserQueryResponse
QueryParams: LoginUserQueryParams
Errors: LoginUser400
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
export type LogoutUserError = any | null

export type LogoutUserQueryResponse = any | null
export namespace LogoutUserQuery {
export type Response = LogoutUserQueryResponse
export type Errors = LogoutUserError
export type LogoutUserQuery = {
Response: LogoutUserQueryResponse
Errors: LogoutUserError
}
2 changes: 1 addition & 1 deletion examples/advanced/src/gen/schemas/AddPetRequest.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"type": "object",
"properties": { "id": { "type": "integer", "format": "int64" }, "name": { "type": "string" } },
"xml": { "name": "tag" },
"x-readme-ref-name": "Tag"
"x-readme-ref-name": "tag.Tag"
}
},
"status": { "type": "string", "description": "pet status in the store", "enum": ["available", "pending", "sold"] }
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced/src/gen/schemas/Pet.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"type": "object",
"properties": { "id": { "type": "integer", "format": "int64" }, "name": { "type": "string" } },
"xml": { "name": "tag" },
"x-readme-ref-name": "Tag"
"x-readme-ref-name": "tag.Tag"
}
},
"status": { "type": "string", "description": "pet status in the store", "enum": ["available", "pending", "sold"] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"type": "object",
"properties": { "id": { "type": "integer", "format": "int64" }, "name": { "type": "string" } },
"xml": { "name": "tag" },
"x-readme-ref-name": "Tag"
"x-readme-ref-name": "tag.Tag"
}
2 changes: 1 addition & 1 deletion examples/advanced/src/gen/schemas2/AddPetRequest.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"type": "object",
"properties": { "id": { "type": "integer", "format": "int64" }, "name": { "type": "string" } },
"xml": { "name": "tag" },
"x-readme-ref-name": "Tag"
"x-readme-ref-name": "tag.Tag"
}
},
"status": { "type": "string", "description": "pet status in the store", "enum": ["available", "pending", "sold"] }
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced/src/gen/schemas2/Pet.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"type": "object",
"properties": { "id": { "type": "integer", "format": "int64" }, "name": { "type": "string" } },
"xml": { "name": "tag" },
"x-readme-ref-name": "Tag"
"x-readme-ref-name": "tag.Tag"
}
},
"status": { "type": "string", "description": "pet status in the store", "enum": ["available", "pending", "sold"] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"type": "object",
"properties": { "id": { "type": "integer", "format": "int64" }, "name": { "type": "string" } },
"xml": { "name": "tag" },
"x-readme-ref-name": "Tag"
"x-readme-ref-name": "tag.Tag"
}
4 changes: 2 additions & 2 deletions examples/advanced/src/gen/zod/addPetRequestSchema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { categorySchema } from './categorySchema'
import { tagSchema } from './tagSchema'
import { tagTagSchema } from './tag/tagSchema'
import { z } from 'zod'
import type { AddPetRequest } from '../models/ts/AddPetRequest'

Expand All @@ -8,6 +8,6 @@ export const addPetRequestSchema: z.ZodType<AddPetRequest> = z.object({
'name': z.string(),
'category': z.lazy(() => categorySchema).optional(),
'photoUrls': z.array(z.string()),
'tags': z.array(z.lazy(() => tagSchema)).optional(),
'tags': z.array(z.lazy(() => tagTagSchema)).optional(),
'status': z.enum([`available`, `pending`, `sold`]).describe(`pet status in the store`).optional(),
})
2 changes: 1 addition & 1 deletion examples/advanced/src/gen/zod/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export * as petSchemas from './petController/index'
export * from './petNotFoundSchema'
export * from './petSchema'
export * as petsSchemas from './petsController/index'
export * from './tagSchema'
export * from './tag/index'
export * from './userArraySchema'
export * as userSchemas from './userController/index'
export * from './userSchema'
4 changes: 2 additions & 2 deletions examples/advanced/src/gen/zod/petSchema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { categorySchema } from './categorySchema'
import { tagSchema } from './tagSchema'
import { tagTagSchema } from './tag/tagSchema'
import { z } from 'zod'
import type { Pet } from '../models/ts/Pet'

Expand All @@ -8,6 +8,6 @@ export const petSchema: z.ZodType<Pet> = z.object({
'name': z.string(),
'category': z.lazy(() => categorySchema).optional(),
'photoUrls': z.array(z.string()),
'tags': z.array(z.lazy(() => tagSchema)).optional(),
'tags': z.array(z.lazy(() => tagTagSchema)).optional(),
'status': z.enum([`available`, `pending`, `sold`]).describe(`pet status in the store`).optional(),
})
1 change: 1 addition & 0 deletions examples/advanced/src/gen/zod/tag/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './tagSchema'
4 changes: 4 additions & 0 deletions examples/advanced/src/gen/zod/tag/tagSchema.ts
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() })
4 changes: 0 additions & 4 deletions examples/advanced/src/gen/zod/tagSchema.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export type FindPetsByStatusQueryParams = {
* @description successful operation
*/
export type FindPetsByStatusQueryResponse = Pet[]
export namespace FindPetsByStatusQuery {
export type Response = FindPetsByStatusQueryResponse
export type QueryParams = FindPetsByStatusQueryParams
export type Errors = FindPetsByStatus400
export type FindPetsByStatusQuery = {
Response: FindPetsByStatusQueryResponse
QueryParams: FindPetsByStatusQueryParams
Errors: FindPetsByStatus400
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ export type FindPetsByTagsQueryParams = {
* @description successful operation
*/
export type FindPetsByTagsQueryResponse = Pet[]
export namespace FindPetsByTagsQuery {
export type Response = FindPetsByTagsQueryResponse
export type QueryParams = FindPetsByTagsQueryParams
export type HeaderParams = FindPetsByTagsHeaderParams
export type Errors = FindPetsByTags400
export type FindPetsByTagsQuery = {
Response: FindPetsByTagsQueryResponse
QueryParams: FindPetsByTagsQueryParams
HeaderParams: FindPetsByTagsHeaderParams
Errors: FindPetsByTags400
}
Loading

0 comments on commit 71f4eec

Please sign in to comment.