diff --git a/.codesandbox/ci.json b/.codesandbox/ci.json
index 8c33520f6..6d2c233c7 100644
--- a/.codesandbox/ci.json
+++ b/.codesandbox/ci.json
@@ -18,6 +18,7 @@
"/examples/advanced",
"/examples/faker",
"/examples/msw",
+ "/examples/python",
"/examples/msw-v2",
"/examples/react-query",
"/examples/react-query-v5",
diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts
index f7fcd0333..abf0ab7e3 100644
--- a/docs/.vitepress/config.ts
+++ b/docs/.vitepress/config.ts
@@ -346,6 +346,10 @@ const examplesSidebar = [
text: 'Templates new',
link: '/examples/client',
},
+ {
+ text: 'Python new',
+ link: '/examples/python',
+ },
]
const blogSidebar = [
diff --git a/docs/examples/python.md b/docs/examples/python.md
new file mode 100644
index 000000000..cd776c09f
--- /dev/null
+++ b/docs/examples/python.md
@@ -0,0 +1,18 @@
+---
+title: Python PetStore
+aside: false
+---
+
+
diff --git a/docs/plugins/react/components/editor.md b/docs/plugins/react/components/editor.md
index e793e1d51..11a002655 100644
--- a/docs/plugins/react/components/editor.md
+++ b/docs/plugins/react/components/editor.md
@@ -7,8 +7,6 @@ outline: deep
# Editor
-## Editor
-
::: code-group
```tsx [simple]
diff --git a/examples/client/src/gen/clients/axios/userService/createUser.kt b/examples/client/src/gen/clients/axios/userService/createUser.kt
deleted file mode 100644
index 394a9c5a5..000000000
--- a/examples/client/src/gen/clients/axios/userService/createUser.kt
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.example.blog
-
-import org.springframework.stereotype.Controller
-import org.springframework.ui.Model
-import org.springframework.ui.set
-import org.springframework.web.bind.annotation.GetMapping
-
-@Controller
-class HtmlController {
-
- @GetMapping("/user")
- fun createUser(model: Model): String {
- model["title"] = "Blog"
- return "blog"
- }
-}
\ No newline at end of file
diff --git a/examples/client/src/gen/clients/axios/userService/createUser.py b/examples/client/src/gen/clients/axios/userService/createUser.py
deleted file mode 100644
index c9fa2f5f5..000000000
--- a/examples/client/src/gen/clients/axios/userService/createUser.py
+++ /dev/null
@@ -1,5 +0,0 @@
-import requests
-
-response = requests.post("/user")
-
-print(response.status_code)
\ No newline at end of file
diff --git a/examples/client/src/gen/clients/axios/userService/createUsersWithListInput.kt b/examples/client/src/gen/clients/axios/userService/createUsersWithListInput.kt
deleted file mode 100644
index a30080359..000000000
--- a/examples/client/src/gen/clients/axios/userService/createUsersWithListInput.kt
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.example.blog
-
-import org.springframework.stereotype.Controller
-import org.springframework.ui.Model
-import org.springframework.ui.set
-import org.springframework.web.bind.annotation.GetMapping
-
-@Controller
-class HtmlController {
-
- @GetMapping("/user/createWithList")
- fun createUsersWithListInput(model: Model): String {
- model["title"] = "Blog"
- return "blog"
- }
-}
\ No newline at end of file
diff --git a/examples/client/src/gen/clients/axios/userService/createUsersWithListInput.py b/examples/client/src/gen/clients/axios/userService/createUsersWithListInput.py
deleted file mode 100644
index f0a4d5c89..000000000
--- a/examples/client/src/gen/clients/axios/userService/createUsersWithListInput.py
+++ /dev/null
@@ -1,5 +0,0 @@
-import requests
-
-response = requests.post("/user/createWithList")
-
-print(response.status_code)
\ No newline at end of file
diff --git a/examples/client/src/gen/clients/axios/userService/deleteUser.kt b/examples/client/src/gen/clients/axios/userService/deleteUser.kt
deleted file mode 100644
index 755cced51..000000000
--- a/examples/client/src/gen/clients/axios/userService/deleteUser.kt
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.example.blog
-
-import org.springframework.stereotype.Controller
-import org.springframework.ui.Model
-import org.springframework.ui.set
-import org.springframework.web.bind.annotation.GetMapping
-
-@Controller
-class HtmlController {
-
- @GetMapping("/user/:username")
- fun deleteUser(model: Model): String {
- model["title"] = "Blog"
- return "blog"
- }
-}
\ No newline at end of file
diff --git a/examples/client/src/gen/clients/axios/userService/deleteUser.py b/examples/client/src/gen/clients/axios/userService/deleteUser.py
deleted file mode 100644
index 7764f0ffa..000000000
--- a/examples/client/src/gen/clients/axios/userService/deleteUser.py
+++ /dev/null
@@ -1,5 +0,0 @@
-import requests
-
-response = requests.delete("/user/:username")
-
-print(response.status_code)
\ No newline at end of file
diff --git a/examples/client/src/gen/clients/axios/userService/getUserByName.kt b/examples/client/src/gen/clients/axios/userService/getUserByName.kt
deleted file mode 100644
index f09589e59..000000000
--- a/examples/client/src/gen/clients/axios/userService/getUserByName.kt
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.example.blog
-
-import org.springframework.stereotype.Controller
-import org.springframework.ui.Model
-import org.springframework.ui.set
-import org.springframework.web.bind.annotation.GetMapping
-
-@Controller
-class HtmlController {
-
- @GetMapping("/user/:username")
- fun getUserByName(model: Model): String {
- model["title"] = "Blog"
- return "blog"
- }
-}
\ No newline at end of file
diff --git a/examples/client/src/gen/clients/axios/userService/getUserByName.py b/examples/client/src/gen/clients/axios/userService/getUserByName.py
deleted file mode 100644
index 903330c98..000000000
--- a/examples/client/src/gen/clients/axios/userService/getUserByName.py
+++ /dev/null
@@ -1,5 +0,0 @@
-import requests
-
-response = requests.get("/user/:username")
-
-print(response.status_code)
\ No newline at end of file
diff --git a/examples/client/src/gen/clients/axios/userService/loginUser.kt b/examples/client/src/gen/clients/axios/userService/loginUser.kt
deleted file mode 100644
index 0089dd694..000000000
--- a/examples/client/src/gen/clients/axios/userService/loginUser.kt
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.example.blog
-
-import org.springframework.stereotype.Controller
-import org.springframework.ui.Model
-import org.springframework.ui.set
-import org.springframework.web.bind.annotation.GetMapping
-
-@Controller
-class HtmlController {
-
- @GetMapping("/user/login")
- fun loginUser(model: Model): String {
- model["title"] = "Blog"
- return "blog"
- }
-}
\ No newline at end of file
diff --git a/examples/client/src/gen/clients/axios/userService/loginUser.py b/examples/client/src/gen/clients/axios/userService/loginUser.py
deleted file mode 100644
index 01f6bcf36..000000000
--- a/examples/client/src/gen/clients/axios/userService/loginUser.py
+++ /dev/null
@@ -1,5 +0,0 @@
-import requests
-
-response = requests.get("/user/login")
-
-print(response.status_code)
\ No newline at end of file
diff --git a/examples/client/src/gen/clients/axios/userService/logoutUser.kt b/examples/client/src/gen/clients/axios/userService/logoutUser.kt
deleted file mode 100644
index 3d9c07e63..000000000
--- a/examples/client/src/gen/clients/axios/userService/logoutUser.kt
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.example.blog
-
-import org.springframework.stereotype.Controller
-import org.springframework.ui.Model
-import org.springframework.ui.set
-import org.springframework.web.bind.annotation.GetMapping
-
-@Controller
-class HtmlController {
-
- @GetMapping("/user/logout")
- fun logoutUser(model: Model): String {
- model["title"] = "Blog"
- return "blog"
- }
-}
\ No newline at end of file
diff --git a/examples/client/src/gen/clients/axios/userService/logoutUser.py b/examples/client/src/gen/clients/axios/userService/logoutUser.py
deleted file mode 100644
index a2a026f6a..000000000
--- a/examples/client/src/gen/clients/axios/userService/logoutUser.py
+++ /dev/null
@@ -1,5 +0,0 @@
-import requests
-
-response = requests.get("/user/logout")
-
-print(response.status_code)
\ No newline at end of file
diff --git a/examples/client/src/gen/clients/axios/userService/updateUser.kt b/examples/client/src/gen/clients/axios/userService/updateUser.kt
deleted file mode 100644
index 1a1c0f8f9..000000000
--- a/examples/client/src/gen/clients/axios/userService/updateUser.kt
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.example.blog
-
-import org.springframework.stereotype.Controller
-import org.springframework.ui.Model
-import org.springframework.ui.set
-import org.springframework.web.bind.annotation.GetMapping
-
-@Controller
-class HtmlController {
-
- @GetMapping("/user/:username")
- fun updateUser(model: Model): String {
- model["title"] = "Blog"
- return "blog"
- }
-}
\ No newline at end of file
diff --git a/examples/client/src/gen/clients/axios/userService/updateUser.py b/examples/client/src/gen/clients/axios/userService/updateUser.py
deleted file mode 100644
index 3fd3f3b0a..000000000
--- a/examples/client/src/gen/clients/axios/userService/updateUser.py
+++ /dev/null
@@ -1,5 +0,0 @@
-import requests
-
-response = requests.put("/user/:username")
-
-print(response.status_code)
\ No newline at end of file
diff --git a/examples/client/templates/CustomClientTemplate.tsx b/examples/client/templates/CustomClientTemplate.tsx
index 19a645f81..0beb579db 100644
--- a/examples/client/templates/CustomClientTemplate.tsx
+++ b/examples/client/templates/CustomClientTemplate.tsx
@@ -1,68 +1,17 @@
-import { File, Function, Editor } from '@kubb/react'
+import { File, Function } from '@kubb/react'
import { Client } from '@kubb/swagger-client/components'
import React from 'react'
-import { useOperationFile } from '@kubb/swagger/hooks'
export const templates = {
default: function({ name, generics, returnType, params, JSDoc, client }: React.ComponentProps) {
const clientParams = [client.path.template, client.withData ? 'data' : undefined, 'options'].filter(Boolean).join(', ')
- const filePython = useOperationFile({ extName: '.py' })
- const fileKotlin = useOperationFile({ extName: '.kt' })
-
return (
<>
-
-
-
- {`return axios.${client.method}(${clientParams})`}
-
-
-
-
-
- {`
-package com.example.blog
-
-import org.springframework.stereotype.Controller
-import org.springframework.ui.Model
-import org.springframework.ui.set
-import org.springframework.web.bind.annotation.GetMapping
-
-@Controller
-class HtmlController {
-
- @GetMapping("${client.path.URL}")
- fun ${name}(model: Model): String {
- model["title"] = "Blog"
- return "blog"
- }
-}
- `}
-
-
-
-
-
-
- import requests
-
-
- {`response = requests.${client.method}("${client.path.URL}")`}
-
-
- print(response.status_code)
-
-
-
+
+
+ {`return axios.${client.method}(${clientParams})`}
+
>
)
},
diff --git a/examples/client/templates/CustomClientTemplates.tsx b/examples/client/templates/CustomClientTemplates.tsx
deleted file mode 100644
index fa1cd260f..000000000
--- a/examples/client/templates/CustomClientTemplates.tsx
+++ /dev/null
@@ -1,23 +0,0 @@
-import { File, Function } from '@kubb/react'
-import { PluginOptions } from '@kubb/swagger-client'
-import { Client } from '@kubb/swagger-client/components'
-import React from 'react'
-
-function ClientTemplate({ name, generics, returnType, params, JSDoc, client }: React.ComponentProps) {
- const clientParams = [client.path.template, client.withData ? 'data' : undefined, 'options'].filter(Boolean).join(', ')
-
- return (
- <>
-
-
- {`return axios.${client.method}(${clientParams}`}
-
- >
- )
-}
-
-export const templates: PluginOptions['options']['templates'] = {
- client: {
- default: ClientTemplate,
- },
-}
diff --git a/examples/python/.prettierrc b/examples/python/.prettierrc
new file mode 100644
index 000000000..450c0351e
--- /dev/null
+++ b/examples/python/.prettierrc
@@ -0,0 +1,9 @@
+{
+ "tabWidth": 2,
+ "printWidth": 160,
+ "parser": "typescript",
+ "singleQuote": true,
+ "semi": false,
+ "bracketSameLine": false,
+ "endOfLine": "auto"
+}
diff --git a/examples/python/kubb.config.ts b/examples/python/kubb.config.ts
new file mode 100644
index 000000000..1b6f971bb
--- /dev/null
+++ b/examples/python/kubb.config.ts
@@ -0,0 +1,37 @@
+import { defineConfig } from '@kubb/core'
+
+import { templates } from './templates/CustomClientTemplate'
+
+export default defineConfig(async () => {
+ return {
+ root: '.',
+ input: {
+ // path: './test.json',
+ path: './petStore.yaml',
+ },
+ output: {
+ path: './src/gen',
+ clean: true,
+ },
+ hooks: {
+ // done: ['npx eslint --fix ./src/gen', 'prettier --write "**/*.{ts,tsx}"', 'pnpm typecheck'],
+ },
+ plugins: [
+ ['@kubb/swagger', { output: false, validate: true }],
+ [
+ '@kubb/swagger-client',
+ {
+ output: {
+ path: './',
+ exportType: false,
+ },
+ group: { type: 'tag', output: './{{tag}}Service' },
+ templates: {
+ client: templates,
+ operations: false,
+ },
+ },
+ ],
+ ],
+ }
+})
diff --git a/examples/python/package.json b/examples/python/package.json
new file mode 100644
index 000000000..a53cd27c3
--- /dev/null
+++ b/examples/python/package.json
@@ -0,0 +1,42 @@
+{
+ "name": "python-pet-store",
+ "version": "0.0.1",
+ "private": true,
+ "description": "Client PetStore example",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/kubb-project/kubb.git",
+ "directory": "packages/examples/python"
+ },
+ "license": "MIT",
+ "author": "Stijn Van Hulle =18",
+ "pnpm": ">=8.3.0"
+ }
+}
diff --git a/examples/python/petStore.yaml b/examples/python/petStore.yaml
new file mode 100644
index 000000000..47e49ced8
--- /dev/null
+++ b/examples/python/petStore.yaml
@@ -0,0 +1,969 @@
+openapi: 3.0.3
+info:
+ title: Swagger Petstore - OpenAPI 3.0
+ description: |-
+ This is a sample Pet Store Server based on the OpenAPI 3.0 specification. You can find out more about
+ Swagger at [https://swagger.io](https://swagger.io). In the third iteration of the pet store, we've switched to the design first approach!
+ You can now help us improve the API whether it's by making changes to the definition itself or to the code.
+ That way, with time, we can improve the API in general, and expose some of the new features in OAS3.
+
+ Some useful links:
+ - [The Pet Store repository](https://github.com/swagger-api/swagger-petstore)
+ - [The source API definition for the Pet Store](https://github.com/swagger-api/swagger-petstore/blob/master/src/main/resources/openapi.yaml)
+
+ termsOfService: http://swagger.io/terms/
+ contact:
+ email: apiteam@swagger.io
+ license:
+ name: Apache 2.0
+ url: http://www.apache.org/licenses/LICENSE-2.0.html
+ version: 1.0.11
+externalDocs:
+ description: Find out more about Swagger
+ url: http://swagger.io
+servers:
+ - url: https://petstore3.swagger.io/api/v3
+tags:
+ - name: pet
+ description: Everything about your Pets
+ externalDocs:
+ description: Find out more
+ url: http://swagger.io
+ - name: store
+ description: Access to Petstore orders
+ externalDocs:
+ description: Find out more about our store
+ url: http://swagger.io
+ - name: user
+ description: Operations about user
+paths:
+ /pets/{uuid}:
+ post:
+ summary: Create a pet
+ operationId: createPets
+ tags:
+ - pets
+ parameters:
+ - description: UUID
+ in: path
+ name: uuid
+ required: true
+ schema:
+ type: string
+ - description: Offset
+ in: query
+ name: offset
+ schema:
+ type: integer
+ - description: Header parameters
+ in: header
+ name: X-EXAMPLE
+ required: true
+ schema:
+ type: string
+ enum:
+ - ONE
+ - TWO
+ - THREE
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema:
+ type: object
+ required:
+ - "name"
+ - "tag"
+ properties:
+ name:
+ type: string
+ tag:
+ type: string
+ responses:
+ "201":
+ description: Null response
+ default:
+ description: unexpected error
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/responses/PetNotFound"
+ /pet:
+ put:
+ tags:
+ - pet
+ summary: Update an existing pet
+ description: Update an existing pet by Id
+ operationId: updatePet
+ requestBody:
+ description: Update an existent pet in the store
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/Pet"
+ application/xml:
+ schema:
+ $ref: "#/components/schemas/Pet"
+ application/x-www-form-urlencoded:
+ schema:
+ $ref: "#/components/schemas/Pet"
+ required: true
+ responses:
+ "200":
+ description: Successful operation
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/Pet"
+ application/xml:
+ schema:
+ $ref: "#/components/schemas/Pet"
+ "400":
+ description: Invalid ID supplied
+ "404":
+ description: Pet not found
+ "405":
+ description: Validation exception
+ security:
+ - petstore_auth:
+ - write:pets
+ - read:pets
+ post:
+ tags:
+ - pet
+ summary: Add a new pet to the store
+ description: Add a new pet to the store
+ operationId: addPet
+ requestBody:
+ description: Create a new pet in the store
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/AddPetRequest"
+ application/xml:
+ schema:
+ $ref: "#/components/schemas/Pet"
+ application/x-www-form-urlencoded:
+ schema:
+ $ref: "#/components/schemas/Pet"
+ required: true
+ responses:
+ "200":
+ description: Successful operation
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/Pet"
+ application/xml:
+ schema:
+ $ref: "#/components/schemas/Pet"
+ "405":
+ description: Invalid input
+ $ref: "#/components/responses/PetNotFound"
+ security:
+ - petstore_auth:
+ - write:pets
+ - read:pets
+ /pet/findByStatus:
+ get:
+ tags:
+ - pet
+ summary: Finds Pets by status
+ description: Multiple status values can be provided with comma separated strings
+ operationId: findPetsByStatus
+ parameters:
+ - name: status
+ in: query
+ description: Status values that need to be considered for filter
+ required: false
+ explode: true
+ schema:
+ type: string
+ default: available
+ enum:
+ - available
+ - pending
+ - sold
+ responses:
+ "200":
+ description: successful operation
+ content:
+ application/json:
+ schema:
+ type: array
+ items:
+ $ref: "#/components/schemas/Pet"
+ application/xml:
+ schema:
+ type: array
+ items:
+ $ref: "#/components/schemas/Pet"
+ "400":
+ description: Invalid status value
+ security:
+ - petstore_auth:
+ - write:pets
+ - read:pets
+ /pet/findByTags:
+ get:
+ tags:
+ - pet
+ summary: Finds Pets by tags
+ description: Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
+ operationId: findPetsByTags
+ parameters:
+ - name: tags
+ in: query
+ description: Tags to filter by
+ required: false
+ explode: true
+ schema:
+ type: array
+ items:
+ type: string
+ - $ref: "#/components/parameters/page"
+ - $ref: "#/components/parameters/pageSize"
+ - description: Header parameters
+ in: header
+ name: X-EXAMPLE
+ required: true
+ schema:
+ type: string
+ enum:
+ - ONE
+ - TWO
+ - THREE
+ responses:
+ "200":
+ description: successful operation
+ content:
+ application/json:
+ schema:
+ type: array
+ items:
+ $ref: "#/components/schemas/Pet"
+ application/xml:
+ schema:
+ type: array
+ items:
+ $ref: "#/components/schemas/Pet"
+ "400":
+ description: Invalid tag value
+ security:
+ - petstore_auth:
+ - write:pets
+ - read:pets
+ /pet/{petId}:
+ get:
+ tags:
+ - pet
+ summary: Find pet by ID
+ description: Returns a single pet
+ operationId: getPetById
+ parameters:
+ - name: petId
+ in: path
+ description: ID of pet to return
+ required: true
+ schema:
+ type: integer
+ format: int64
+ responses:
+ "200":
+ description: successful operation
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/Pet"
+ application/xml:
+ schema:
+ $ref: "#/components/schemas/Pet"
+ "400":
+ description: Invalid ID supplied
+ "404":
+ description: Pet not found
+ security:
+ - api_key: []
+ - petstore_auth:
+ - write:pets
+ - read:pets
+ post:
+ tags:
+ - pet
+ summary: Updates a pet in the store with form data
+ description: ""
+ operationId: updatePetWithForm
+ parameters:
+ - name: petId
+ in: path
+ description: ID of pet that needs to be updated
+ required: true
+ schema:
+ type: integer
+ format: int64
+ - name: name
+ in: query
+ description: Name of pet that needs to be updated
+ schema:
+ type: string
+ - name: status
+ in: query
+ description: Status of pet that needs to be updated
+ schema:
+ type: string
+ responses:
+ "405":
+ description: Invalid input
+ security:
+ - petstore_auth:
+ - write:pets
+ - read:pets
+ delete:
+ tags:
+ - pet
+ summary: Deletes a pet
+ description: delete a pet
+ operationId: deletePet
+ parameters:
+ - name: api_key
+ in: header
+ description: ""
+ required: false
+ schema:
+ type: string
+ - name: petId
+ in: path
+ description: Pet id to delete
+ required: true
+ schema:
+ type: integer
+ format: int64
+ responses:
+ "400":
+ description: Invalid pet value
+ security:
+ - petstore_auth:
+ - write:pets
+ - read:pets
+ /pet/{petId}/uploadImage:
+ post:
+ tags:
+ - pet
+ summary: uploads an image
+ description: ""
+ operationId: uploadFile
+ parameters:
+ - name: petId
+ in: path
+ description: ID of pet to update
+ required: true
+ schema:
+ type: integer
+ format: int64
+ - name: additionalMetadata
+ in: query
+ description: Additional Metadata
+ required: false
+ schema:
+ type: string
+ requestBody:
+ content:
+ application/octet-stream:
+ schema:
+ type: string
+ format: binary
+ responses:
+ "200":
+ description: successful operation
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/ApiResponse"
+ security:
+ - petstore_auth:
+ - write:pets
+ - read:pets
+ /store/inventory:
+ get:
+ tags:
+ - store
+ summary: Returns pet inventories by status
+ description: Returns a map of status codes to quantities
+ operationId: getInventory
+ responses:
+ "200":
+ description: successful operation
+ content:
+ application/json:
+ schema:
+ type: object
+ additionalProperties:
+ type: integer
+ format: int32
+ security:
+ - api_key: []
+ /store/order:
+ post:
+ tags:
+ - store
+ summary: Place an order for a pet
+ description: Place a new order in the store
+ operationId: placeOrder
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/Order"
+ application/xml:
+ schema:
+ $ref: "#/components/schemas/Order"
+ application/x-www-form-urlencoded:
+ schema:
+ $ref: "#/components/schemas/Order"
+ responses:
+ "200":
+ description: successful operation
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/Order"
+ "405":
+ description: Invalid input
+
+ patch:
+ tags:
+ - store
+ summary: Place an order for a pet with patch
+ description: Place a new order in the store with patch
+ operationId: placeOrderPatch
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/Order"
+ application/xml:
+ schema:
+ $ref: "#/components/schemas/Order"
+ application/x-www-form-urlencoded:
+ schema:
+ $ref: "#/components/schemas/Order"
+ responses:
+ "200":
+ description: successful operation
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/Order"
+ "405":
+ description: Invalid input
+ /store/order/{orderId}:
+ get:
+ tags:
+ - store
+ summary: Find purchase order by ID
+ description: For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions.
+ operationId: getOrderById
+ parameters:
+ - name: orderId
+ in: path
+ description: ID of order that needs to be fetched
+ required: true
+ schema:
+ type: integer
+ format: int64
+ responses:
+ "200":
+ description: successful operation
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/Order"
+ application/xml:
+ schema:
+ $ref: "#/components/schemas/Order"
+ "400":
+ description: Invalid ID supplied
+ "404":
+ description: Order not found
+ delete:
+ tags:
+ - store
+ summary: Delete purchase order by ID
+ description: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
+ operationId: deleteOrder
+ parameters:
+ - name: orderId
+ in: path
+ description: ID of the order that needs to be deleted
+ required: true
+ schema:
+ type: integer
+ format: int64
+ responses:
+ "400":
+ description: Invalid ID supplied
+ "404":
+ description: Order not found
+ /user:
+ post:
+ tags:
+ - user
+ summary: Create user
+ description: This can only be done by the logged in user.
+ operationId: createUser
+ requestBody:
+ description: Created user object
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/User"
+ application/xml:
+ schema:
+ $ref: "#/components/schemas/User"
+ application/x-www-form-urlencoded:
+ schema:
+ $ref: "#/components/schemas/User"
+ responses:
+ default:
+ description: successful operation
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/User"
+ application/xml:
+ schema:
+ $ref: "#/components/schemas/User"
+ /user/createWithList:
+ post:
+ tags:
+ - user
+ summary: Creates list of users with given input array
+ description: Creates list of users with given input array
+ operationId: createUsersWithListInput
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: array
+ items:
+ $ref: "#/components/schemas/User"
+ responses:
+ "200":
+ description: Successful operation
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/User"
+ application/xml:
+ schema:
+ $ref: "#/components/schemas/User"
+ default:
+ description: successful operation
+ /user/login:
+ get:
+ tags:
+ - user
+ summary: Logs user into the system
+ description: ""
+ operationId: loginUser
+ parameters:
+ - name: username
+ in: query
+ description: The user name for login
+ required: false
+ schema:
+ type: string
+ - name: password
+ in: query
+ description: The password for login in clear text
+ required: false
+ schema:
+ type: string
+ responses:
+ "200":
+ description: successful operation
+ headers:
+ X-Rate-Limit:
+ description: calls per hour allowed by the user
+ schema:
+ type: integer
+ format: int32
+ X-Expires-After:
+ description: date in UTC when token expires
+ schema:
+ type: string
+ format: date-time
+ content:
+ application/xml:
+ schema:
+ type: string
+ application/json:
+ schema:
+ type: string
+ "400":
+ description: Invalid username/password supplied
+ /user/logout:
+ get:
+ tags:
+ - user
+ summary: Logs out current logged in user session
+ description: ""
+ operationId: logoutUser
+ parameters: []
+ responses:
+ default:
+ description: successful operation
+ /user/{username}:
+ get:
+ tags:
+ - user
+ summary: Get user by user name
+ description: ""
+ operationId: getUserByName
+ parameters:
+ - name: username
+ in: path
+ description: "The name that needs to be fetched. Use user1 for testing. "
+ required: true
+ schema:
+ type: string
+ responses:
+ "200":
+ description: successful operation
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/User"
+ application/xml:
+ schema:
+ $ref: "#/components/schemas/User"
+ "400":
+ description: Invalid username supplied
+ "404":
+ description: User not found
+ put:
+ tags:
+ - user
+ summary: Update user
+ description: This can only be done by the logged in user.
+ operationId: updateUser
+ parameters:
+ - name: username
+ in: path
+ description: name that need to be deleted
+ required: true
+ schema:
+ type: string
+ requestBody:
+ description: Update an existent user in the store
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/User"
+ application/xml:
+ schema:
+ $ref: "#/components/schemas/User"
+ application/x-www-form-urlencoded:
+ schema:
+ $ref: "#/components/schemas/User"
+ responses:
+ default:
+ description: successful operation
+ delete:
+ tags:
+ - user
+ summary: Delete user
+ description: This can only be done by the logged in user.
+ operationId: deleteUser
+ parameters:
+ - name: username
+ in: path
+ description: The name that needs to be deleted
+ required: true
+ schema:
+ type: string
+ responses:
+ "400":
+ description: Invalid username supplied
+ "404":
+ description: User not found
+components:
+ schemas:
+ Order:
+ type: object
+ properties:
+ id:
+ type: integer
+ format: int64
+ example: 10
+ petId:
+ type: integer
+ format: int64
+ example: 198772
+ quantity:
+ type: integer
+ format: int32
+ example: 7
+ shipDate:
+ type: string
+ format: date-time
+ status:
+ type: string
+ description: Order Status
+ example: approved
+ enum:
+ - placed
+ - approved
+ - delivered
+ http_status:
+ type: number
+ description: HTTP Status
+ example: 200
+ enum:
+ - 200
+ - 400
+ - 500
+ x-enumNames:
+ - ok
+ - not_found
+ complete:
+ type: boolean
+ xml:
+ name: order
+ Customer:
+ type: object
+ properties:
+ id:
+ type: integer
+ format: int64
+ example: 100000
+ username:
+ type: string
+ example: fehguy
+ address:
+ type: array
+ xml:
+ name: addresses
+ wrapped: true
+ items:
+ $ref: "#/components/schemas/Address"
+ xml:
+ name: customer
+ Address:
+ type: object
+ properties:
+ street:
+ type: string
+ example: 437 Lytton
+ city:
+ type: string
+ example: Palo Alto
+ state:
+ type: string
+ example: CA
+ zip:
+ type: string
+ example: "94301"
+ xml:
+ name: address
+ Category:
+ type: object
+ properties:
+ id:
+ type: integer
+ format: int64
+ example: 1
+ name:
+ type: string
+ example: Dogs
+ xml:
+ name: category
+ User:
+ type: object
+ properties:
+ id:
+ type: integer
+ format: int64
+ example: 10
+ username:
+ type: string
+ example: theUser
+ firstName:
+ type: string
+ example: John
+ lastName:
+ type: string
+ example: James
+ email:
+ type: string
+ example: john@email.com
+ password:
+ type: string
+ example: "12345"
+ phone:
+ type: string
+ example: "12345"
+ userStatus:
+ type: integer
+ description: User Status
+ format: int32
+ example: 1
+ xml:
+ name: user
+ Tag:
+ type: object
+ properties:
+ id:
+ type: integer
+ format: int64
+ name:
+ type: string
+ xml:
+ name: tag
+
+ Pet:
+ required:
+ - name
+ - photoUrls
+ type: object
+ properties:
+ id:
+ type: integer
+ format: int64
+ example: 10
+ name:
+ type: string
+ example: doggie
+ category:
+ $ref: "#/components/schemas/Category"
+ photoUrls:
+ type: array
+ xml:
+ wrapped: true
+ items:
+ type: string
+ xml:
+ name: photoUrl
+ tags:
+ type: array
+ xml:
+ wrapped: true
+ items:
+ $ref: "#/components/schemas/Tag"
+ status:
+ type: string
+ description: pet status in the store
+ enum:
+ - available
+ - pending
+ - sold
+ xml:
+ name: pet
+ AddPetRequest:
+ required:
+ - name
+ - photoUrls
+ type: object
+ properties:
+ id:
+ type: integer
+ format: int64
+ example: 10
+ name:
+ type: string
+ example: doggie
+ category:
+ $ref: "#/components/schemas/Category"
+ photoUrls:
+ type: array
+ xml:
+ wrapped: true
+ items:
+ type: string
+ xml:
+ name: photoUrl
+ tags:
+ type: array
+ xml:
+ wrapped: true
+ items:
+ $ref: "#/components/schemas/Tag"
+ status:
+ type: string
+ description: pet status in the store
+ enum:
+ - available
+ - pending
+ - sold
+ xml:
+ name: pet
+ ApiResponse:
+ type: object
+ properties:
+ code:
+ type: integer
+ format: int32
+ type:
+ type: string
+ message:
+ type: string
+ xml:
+ name: "##default"
+ requestBodies:
+ Pet:
+ description: Pet object that needs to be added to the store
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/Pet"
+ application/xml:
+ schema:
+ $ref: "#/components/schemas/Pet"
+ UserArray:
+ description: List of user object
+ content:
+ application/json:
+ schema:
+ type: array
+ items:
+ $ref: "#/components/schemas/User"
+ securitySchemes:
+ petstore_auth:
+ type: oauth2
+ flows:
+ implicit:
+ authorizationUrl: https://petstore3.swagger.io/oauth/authorize
+ scopes:
+ write:pets: modify pets in your account
+ read:pets: read your pets
+ api_key:
+ type: apiKey
+ name: api_key
+ in: header
+ parameters:
+ page:
+ description: to request with required page number or pagination
+ in: query
+ name: page
+ required: false
+ schema:
+ type: string
+ pageSize:
+ description: to request with required page size
+ in: query
+ name: pageSize
+ required: false
+ schema:
+ type: string
+ responses:
+ PetNotFound:
+ content:
+ application/json:
+ schema:
+ properties:
+ code:
+ format: int32
+ type: integer
+ message:
+ type: string
+ description: Pet not found
diff --git a/examples/python/src/gen/petService/addPet.py b/examples/python/src/gen/petService/addPet.py
new file mode 100644
index 000000000..0ba7ed98a
--- /dev/null
+++ b/examples/python/src/gen/petService/addPet.py
@@ -0,0 +1,2 @@
+import requests
+response = requests.post("/pet")print(response.status_code)
\ No newline at end of file
diff --git a/examples/python/src/gen/petService/deletePet.py b/examples/python/src/gen/petService/deletePet.py
new file mode 100644
index 000000000..99b8720a8
--- /dev/null
+++ b/examples/python/src/gen/petService/deletePet.py
@@ -0,0 +1,2 @@
+import requests
+response = requests.delete("/pet/:petId")print(response.status_code)
\ No newline at end of file
diff --git a/examples/python/src/gen/petService/findPetsByStatus.py b/examples/python/src/gen/petService/findPetsByStatus.py
new file mode 100644
index 000000000..baba8ff27
--- /dev/null
+++ b/examples/python/src/gen/petService/findPetsByStatus.py
@@ -0,0 +1,2 @@
+import requests
+response = requests.get("/pet/findByStatus")print(response.status_code)
\ No newline at end of file
diff --git a/examples/python/src/gen/petService/findPetsByTags.py b/examples/python/src/gen/petService/findPetsByTags.py
new file mode 100644
index 000000000..e9f4f113e
--- /dev/null
+++ b/examples/python/src/gen/petService/findPetsByTags.py
@@ -0,0 +1,2 @@
+import requests
+response = requests.get("/pet/findByTags")print(response.status_code)
\ No newline at end of file
diff --git a/examples/python/src/gen/petService/getPetById.py b/examples/python/src/gen/petService/getPetById.py
new file mode 100644
index 000000000..27fe83686
--- /dev/null
+++ b/examples/python/src/gen/petService/getPetById.py
@@ -0,0 +1,2 @@
+import requests
+response = requests.get("/pet/:petId")print(response.status_code)
\ No newline at end of file
diff --git a/examples/python/src/gen/petService/updatePet.py b/examples/python/src/gen/petService/updatePet.py
new file mode 100644
index 000000000..4ee8296d4
--- /dev/null
+++ b/examples/python/src/gen/petService/updatePet.py
@@ -0,0 +1,2 @@
+import requests
+response = requests.put("/pet")print(response.status_code)
\ No newline at end of file
diff --git a/examples/python/src/gen/petService/updatePetWithForm.py b/examples/python/src/gen/petService/updatePetWithForm.py
new file mode 100644
index 000000000..8081989fa
--- /dev/null
+++ b/examples/python/src/gen/petService/updatePetWithForm.py
@@ -0,0 +1,2 @@
+import requests
+response = requests.post("/pet/:petId")print(response.status_code)
\ No newline at end of file
diff --git a/examples/python/src/gen/petService/uploadFile.py b/examples/python/src/gen/petService/uploadFile.py
new file mode 100644
index 000000000..122a3cc75
--- /dev/null
+++ b/examples/python/src/gen/petService/uploadFile.py
@@ -0,0 +1,2 @@
+import requests
+response = requests.post("/pet/:petId/uploadImage")print(response.status_code)
\ No newline at end of file
diff --git a/examples/python/src/gen/petsService/createPets.py b/examples/python/src/gen/petsService/createPets.py
new file mode 100644
index 000000000..0bfa61540
--- /dev/null
+++ b/examples/python/src/gen/petsService/createPets.py
@@ -0,0 +1,2 @@
+import requests
+response = requests.post("/pets/:uuid")print(response.status_code)
\ No newline at end of file
diff --git a/examples/python/src/gen/storeService/deleteOrder.py b/examples/python/src/gen/storeService/deleteOrder.py
new file mode 100644
index 000000000..34bdc4a9f
--- /dev/null
+++ b/examples/python/src/gen/storeService/deleteOrder.py
@@ -0,0 +1,2 @@
+import requests
+response = requests.delete("/store/order/:orderId")print(response.status_code)
\ No newline at end of file
diff --git a/examples/python/src/gen/storeService/getInventory.py b/examples/python/src/gen/storeService/getInventory.py
new file mode 100644
index 000000000..592b54981
--- /dev/null
+++ b/examples/python/src/gen/storeService/getInventory.py
@@ -0,0 +1,2 @@
+import requests
+response = requests.get("/store/inventory")print(response.status_code)
\ No newline at end of file
diff --git a/examples/python/src/gen/storeService/getOrderById.py b/examples/python/src/gen/storeService/getOrderById.py
new file mode 100644
index 000000000..cd55f3320
--- /dev/null
+++ b/examples/python/src/gen/storeService/getOrderById.py
@@ -0,0 +1,2 @@
+import requests
+response = requests.get("/store/order/:orderId")print(response.status_code)
\ No newline at end of file
diff --git a/examples/python/src/gen/storeService/placeOrder.py b/examples/python/src/gen/storeService/placeOrder.py
new file mode 100644
index 000000000..26b4450d0
--- /dev/null
+++ b/examples/python/src/gen/storeService/placeOrder.py
@@ -0,0 +1,2 @@
+import requests
+response = requests.post("/store/order")print(response.status_code)
\ No newline at end of file
diff --git a/examples/python/src/gen/storeService/placeOrderPatch.py b/examples/python/src/gen/storeService/placeOrderPatch.py
new file mode 100644
index 000000000..ccb5844fa
--- /dev/null
+++ b/examples/python/src/gen/storeService/placeOrderPatch.py
@@ -0,0 +1,2 @@
+import requests
+response = requests.patch("/store/order")print(response.status_code)
\ No newline at end of file
diff --git a/examples/python/src/gen/userService/createUser.py b/examples/python/src/gen/userService/createUser.py
new file mode 100644
index 000000000..84a50fc63
--- /dev/null
+++ b/examples/python/src/gen/userService/createUser.py
@@ -0,0 +1,2 @@
+import requests
+response = requests.post("/user")print(response.status_code)
\ No newline at end of file
diff --git a/examples/python/src/gen/userService/createUsersWithListInput.py b/examples/python/src/gen/userService/createUsersWithListInput.py
new file mode 100644
index 000000000..6d1b17666
--- /dev/null
+++ b/examples/python/src/gen/userService/createUsersWithListInput.py
@@ -0,0 +1,2 @@
+import requests
+response = requests.post("/user/createWithList")print(response.status_code)
\ No newline at end of file
diff --git a/examples/python/src/gen/userService/deleteUser.py b/examples/python/src/gen/userService/deleteUser.py
new file mode 100644
index 000000000..693a86fdd
--- /dev/null
+++ b/examples/python/src/gen/userService/deleteUser.py
@@ -0,0 +1,2 @@
+import requests
+response = requests.delete("/user/:username")print(response.status_code)
\ No newline at end of file
diff --git a/examples/python/src/gen/userService/getUserByName.py b/examples/python/src/gen/userService/getUserByName.py
new file mode 100644
index 000000000..e331e3c02
--- /dev/null
+++ b/examples/python/src/gen/userService/getUserByName.py
@@ -0,0 +1,2 @@
+import requests
+response = requests.get("/user/:username")print(response.status_code)
\ No newline at end of file
diff --git a/examples/python/src/gen/userService/loginUser.py b/examples/python/src/gen/userService/loginUser.py
new file mode 100644
index 000000000..1a08191bb
--- /dev/null
+++ b/examples/python/src/gen/userService/loginUser.py
@@ -0,0 +1,2 @@
+import requests
+response = requests.get("/user/login")print(response.status_code)
\ No newline at end of file
diff --git a/examples/python/src/gen/userService/logoutUser.py b/examples/python/src/gen/userService/logoutUser.py
new file mode 100644
index 000000000..b685a4354
--- /dev/null
+++ b/examples/python/src/gen/userService/logoutUser.py
@@ -0,0 +1,2 @@
+import requests
+response = requests.get("/user/logout")print(response.status_code)
\ No newline at end of file
diff --git a/examples/python/src/gen/userService/updateUser.py b/examples/python/src/gen/userService/updateUser.py
new file mode 100644
index 000000000..fd23ceaaa
--- /dev/null
+++ b/examples/python/src/gen/userService/updateUser.py
@@ -0,0 +1,2 @@
+import requests
+response = requests.put("/user/:username")print(response.status_code)
\ No newline at end of file
diff --git a/examples/python/src/index.ts b/examples/python/src/index.ts
new file mode 100644
index 000000000..e69de29bb
diff --git a/examples/python/templates/CustomClientTemplate.tsx b/examples/python/templates/CustomClientTemplate.tsx
new file mode 100644
index 000000000..b64a8d3b2
--- /dev/null
+++ b/examples/python/templates/CustomClientTemplate.tsx
@@ -0,0 +1,32 @@
+import { File, Editor } from '@kubb/react'
+import { Client } from '@kubb/swagger-client/components'
+import React from 'react'
+import { useOperationFile } from '@kubb/swagger/hooks'
+
+export const templates = {
+ default: function({ name, generics, returnType, params, JSDoc, client }: React.ComponentProps) {
+ const clientParams = [client.path.template, client.withData ? 'data' : undefined, 'options'].filter(Boolean).join(', ')
+
+ const filePython = useOperationFile({ extName: '.py' })
+
+ return (
+ <>
+
+
+
+
+ import requests
+
+ {`response = requests.${client.method}("${client.path.URL}")`}
+ print(response.status_code)
+
+
+
+ >
+ )
+ },
+} as const
diff --git a/examples/python/tsconfig.json b/examples/python/tsconfig.json
new file mode 100644
index 000000000..c1f835ec2
--- /dev/null
+++ b/examples/python/tsconfig.json
@@ -0,0 +1,28 @@
+{
+ "compilerOptions": {
+ "target": "ES2020",
+ /* If NOT transpiling with TypeScript: */
+ "module": "ES2020",
+ "moduleResolution": "Bundler",
+ "sourceMap": true,
+ "strictNullChecks": true,
+ "jsx": "react-jsx",
+ "outDir": "es",
+ "experimentalDecorators": true,
+ "skipLibCheck": true,
+ "baseUrl": ".",
+ "resolveJsonModule": true,
+ "esModuleInterop": true,
+ "allowJs": true,
+ "allowImportingTsExtensions": true,
+ "noEmit": true
+ },
+ "include": [
+ "./src/**/*"
+ ],
+ "exclude": [
+ "**/node_modules",
+ "**/types/**",
+ "**/mocks/**"
+ ]
+}
diff --git a/examples/python/tsup.config.ts b/examples/python/tsup.config.ts
new file mode 100644
index 000000000..d92bc6bce
--- /dev/null
+++ b/examples/python/tsup.config.ts
@@ -0,0 +1,12 @@
+import { defineConfig } from 'tsup'
+
+export default defineConfig({
+ entry: ['src/index.ts'],
+ treeshake: false,
+ sourcemap: false,
+ minify: false,
+ splitting: false,
+ clean: true,
+ dts: false,
+ format: ['cjs', 'esm'],
+})
diff --git a/packages/core/src/FileManager.ts b/packages/core/src/FileManager.ts
index e010c22dc..9dc15fa0c 100644
--- a/packages/core/src/FileManager.ts
+++ b/packages/core/src/FileManager.ts
@@ -436,12 +436,14 @@ function combineFiles(file: KubbFile.File): string {
// only use .js, .ts or .tsx files for ESM imports
+
if (file.language ? ['typescript', 'javascript'].includes(file.language) : !FileManager.isJavascript(file.baseName)) {
return file.source
}
const exports = file.exports ? combineExports(file.exports) : []
- const imports = file.imports ? combineImports(file.imports, exports, file.source) : []
+ // imports should be defined and source should contain code or we have imports without them being used
+ const imports = file.imports && file.source ? combineImports(file.imports, exports, file.source) : []
const importNodes = imports.filter(item => {
// isImportNotNeeded
diff --git a/packages/swagger-client/src/components/Client.tsx b/packages/swagger-client/src/components/Client.tsx
index 3ef5eb97e..59b671641 100644
--- a/packages/swagger-client/src/components/Client.tsx
+++ b/packages/swagger-client/src/components/Client.tsx
@@ -147,13 +147,14 @@ export function Client({
}
type FileProps = {
+ languages?: Array<'typescript' | 'text'>
/**
* This will make it possible to override the default behaviour.
*/
templates?: typeof defaultTemplates
}
-Client.File = function({ templates = defaultTemplates }: FileProps): KubbNode {
+Client.File = function({ languages = ['typescript'], templates = defaultTemplates }: FileProps): KubbNode {
const { options: { client: { importPath } } } = usePlugin()
const schemas = useSchemas()
const file = useOperationFile()
diff --git a/packages/swagger-client/src/components/Operations.tsx b/packages/swagger-client/src/components/Operations.tsx
index 1abbf70e3..23828332c 100644
--- a/packages/swagger-client/src/components/Operations.tsx
+++ b/packages/swagger-client/src/components/Operations.tsx
@@ -1,5 +1,5 @@
import { URLPath } from '@kubb/core/utils'
-import { File, usePlugin } from '@kubb/react'
+import { Editor, File, usePlugin } from '@kubb/react'
import { useFile } from '@kubb/react'
import { useOas } from '@kubb/swagger/hooks'
@@ -88,15 +88,24 @@ Operations.File = function({ name, paths, templates = defaultTemplates }: FilePr
const Template = templates.default
return (
-
- baseName={file.baseName}
- path={file.path}
- meta={file.meta}
- >
-
+ <>
+
+
+
+ baseName={file.baseName}
+ path={file.path}
+ meta={file.meta}
+ >
+
+
+
+
+
+
+
-
-
+
+ >
)
}
diff --git a/packages/swagger-faker/src/components/Mutation.tsx b/packages/swagger-faker/src/components/Mutation.tsx
index 02450d2c7..ef56f50ee 100644
--- a/packages/swagger-faker/src/components/Mutation.tsx
+++ b/packages/swagger-faker/src/components/Mutation.tsx
@@ -1,4 +1,4 @@
-import { File, usePlugin, usePluginManager } from '@kubb/react'
+import { Editor, File, usePlugin, usePluginManager } from '@kubb/react'
import { useOas, useOperationFile, useSchemas } from '@kubb/swagger/hooks'
import { FakerBuilder } from '../FakerBuilder.ts'
@@ -44,20 +44,22 @@ Mutation.File = function({}: FileProps): ReactNode {
const { source, imports } = builder.build()
return (
- <>
-
- baseName={file.baseName}
- path={file.path}
- meta={file.meta}
- >
-
- {imports.map((item, index) => {
- return
- })}
-
- {source}
-
-
- >
+
+
+
+ baseName={file.baseName}
+ path={file.path}
+ meta={file.meta}
+ >
+
+ {imports.map((item, index) => {
+ return
+ })}
+
+ {source}
+
+
+
+
)
}
diff --git a/packages/swagger-faker/src/components/Query.tsx b/packages/swagger-faker/src/components/Query.tsx
index ae7b5befd..9d127cdbb 100644
--- a/packages/swagger-faker/src/components/Query.tsx
+++ b/packages/swagger-faker/src/components/Query.tsx
@@ -1,4 +1,4 @@
-import { File, usePlugin, usePluginManager } from '@kubb/react'
+import { Editor, File, usePlugin, usePluginManager } from '@kubb/react'
import { useOas, useOperationFile, useSchemas } from '@kubb/swagger/hooks'
import { FakerBuilder } from '../FakerBuilder.ts'
@@ -43,20 +43,22 @@ Query.File = function({}: FileProps): ReactNode {
const { source, imports } = builder.build()
return (
- <>
-
- baseName={file.baseName}
- path={file.path}
- meta={file.meta}
- >
-
- {imports.map((item, index) => {
- return
- })}
-
- {source}
-
-
- >
+
+
+
+ baseName={file.baseName}
+ path={file.path}
+ meta={file.meta}
+ >
+
+ {imports.map((item, index) => {
+ return
+ })}
+
+ {source}
+
+
+
+
)
}
diff --git a/packages/swagger-msw/src/components/Handlers.tsx b/packages/swagger-msw/src/components/Handlers.tsx
index dc1218d14..971d46b4a 100644
--- a/packages/swagger-msw/src/components/Handlers.tsx
+++ b/packages/swagger-msw/src/components/Handlers.tsx
@@ -1,4 +1,4 @@
-import { File, usePlugin, usePluginManager } from '@kubb/react'
+import { Editor, File, usePlugin, usePluginManager } from '@kubb/react'
import { useFile } from '@kubb/react'
import type { KubbFile, ResolveNameParams, ResolvePathParams } from '@kubb/core'
@@ -123,16 +123,20 @@ Handlers.File = function({ name, paths, templates = defaultTemplates }: FileProp
const Template = templates.default
return (
-
- baseName={file.baseName}
- path={file.path}
- meta={file.meta}
- >
- {imports}
-
-
-
-
+
+
+
+ baseName={file.baseName}
+ path={file.path}
+ meta={file.meta}
+ >
+ {imports}
+
+
+
+
+
+
)
}
diff --git a/packages/swagger-msw/src/components/Mock.tsx b/packages/swagger-msw/src/components/Mock.tsx
index 5ee5c4804..262e12701 100644
--- a/packages/swagger-msw/src/components/Mock.tsx
+++ b/packages/swagger-msw/src/components/Mock.tsx
@@ -1,6 +1,6 @@
import { PackageManager } from '@kubb/core'
import { URLPath } from '@kubb/core/utils'
-import { File, useResolveName } from '@kubb/react'
+import { Editor, File, useResolveName } from '@kubb/react'
import { useOperation, useOperationFile, useOperationName, useSchemas } from '@kubb/swagger/hooks'
import { pluginKey as fakerPluginKey } from '@kubb/swagger-faker'
@@ -109,18 +109,22 @@ Mock.File = function({ templates = defaultTemplates }: FileProps): ReactNode {
const Template = templates.default
return (
-
- baseName={file.baseName}
- path={file.path}
- meta={file.meta}
- >
- {!isV2 && }
- {isV2 && }
- {fileFaker && responseName && }
-
-
-
-
+
+
+
+ baseName={file.baseName}
+ path={file.path}
+ meta={file.meta}
+ >
+ {!isV2 && }
+ {isV2 && }
+ {fileFaker && responseName && }
+
+
+
+
+
+
)
}
diff --git a/packages/swagger-swr/src/components/Mutation.tsx b/packages/swagger-swr/src/components/Mutation.tsx
index afe78a14b..4da96d398 100644
--- a/packages/swagger-swr/src/components/Mutation.tsx
+++ b/packages/swagger-swr/src/components/Mutation.tsx
@@ -1,6 +1,6 @@
import transformers from '@kubb/core/transformers'
import { FunctionParams, URLPath } from '@kubb/core/utils'
-import { File, Function, usePlugin } from '@kubb/react'
+import { Editor, File, Function, usePlugin } from '@kubb/react'
import { useOperation, useOperationFile, useOperationName, useSchemas } from '@kubb/swagger/hooks'
import { getASTParams, getComments } from '@kubb/swagger/utils'
import { pluginKey as swaggerTsPluginKey } from '@kubb/swagger-ts'
@@ -217,41 +217,43 @@ Mutation.File = function({ templates = defaultTemplates }: FileProps): ReactNode
}
return (
- <>
-
- baseName={file.baseName}
- path={file.path}
- meta={file.meta}
- >
-
-
-
-
- error.name) || [],
- ].filter(
- Boolean,
- )}
- root={file.path}
- path={fileType.path}
- isTypeOnly
- />
-
-
-
-
+
+
+ baseName={file.baseName}
+ path={file.path}
+ meta={file.meta}
+ >
+
+
+
+
+ error.name) || [],
+ ].filter(
+ Boolean,
+ )}
+ root={file.path}
+ path={fileType.path}
+ isTypeOnly
/>
-
-
- >
+
+
+
+
+
+
+
+
)
}
diff --git a/packages/swagger-swr/src/components/Query.tsx b/packages/swagger-swr/src/components/Query.tsx
index e13f57fd2..0971b48bd 100644
--- a/packages/swagger-swr/src/components/Query.tsx
+++ b/packages/swagger-swr/src/components/Query.tsx
@@ -1,5 +1,5 @@
import { FunctionParams, URLPath } from '@kubb/core/utils'
-import { File, Function, usePlugin, useResolveName } from '@kubb/react'
+import { Editor, File, Function, usePlugin, useResolveName } from '@kubb/react'
import { useOperation, useOperationFile, useOperationName, useSchemas } from '@kubb/swagger/hooks'
import { getASTParams, getComments } from '@kubb/swagger/utils'
import { pluginKey as swaggerTsPluginKey } from '@kubb/swagger-ts'
@@ -242,42 +242,44 @@ Query.File = function({ templates }: FileProps): ReactNode {
}
return (
- <>
-
- baseName={file.baseName}
- path={file.path}
- meta={file.meta}
- >
-
-
-
-
- error.name) || [],
- ].filter(
- Boolean,
- )}
- root={file.path}
- path={fileType.path}
- isTypeOnly
- />
-
-
-
-
+
+
+ baseName={file.baseName}
+ path={file.path}
+ meta={file.meta}
+ >
+
+
+
+
+ error.name) || [],
+ ].filter(
+ Boolean,
+ )}
+ root={file.path}
+ path={fileType.path}
+ isTypeOnly
/>
-
-
- >
+
+
+
+
+
+
+
+
)
}
diff --git a/packages/swagger-tanstack-query/src/components/Mutation.tsx b/packages/swagger-tanstack-query/src/components/Mutation.tsx
index 7e4dd26fb..cfdf66ccb 100644
--- a/packages/swagger-tanstack-query/src/components/Mutation.tsx
+++ b/packages/swagger-tanstack-query/src/components/Mutation.tsx
@@ -1,7 +1,7 @@
import { PackageManager } from '@kubb/core'
import transformers from '@kubb/core/transformers'
import { FunctionParams, URLPath } from '@kubb/core/utils'
-import { File, Function, usePlugin } from '@kubb/react'
+import { Editor, File, Function, usePlugin } from '@kubb/react'
import { useOperation, useOperationFile, useOperationName, useSchemas } from '@kubb/swagger/hooks'
import { getASTParams, getComments, isRequired } from '@kubb/swagger/utils'
import { pluginKey as swaggerTsPluginKey } from '@kubb/swagger-ts'
@@ -361,40 +361,44 @@ Mutation.File = function({ templates = defaultTemplates, imports = MutationImpor
}
return (
-
- baseName={file.baseName}
- path={file.path}
- meta={file.meta}
- >
-
-
- error.name) || [],
- ].filter(
- Boolean,
- )}
- root={file.path}
- path={fileType.path}
- isTypeOnly
- />
-
-
-
-
-
-
+
+
+
+ baseName={file.baseName}
+ path={file.path}
+ meta={file.meta}
+ >
+
+
+ error.name) || [],
+ ].filter(
+ Boolean,
+ )}
+ root={file.path}
+ path={fileType.path}
+ isTypeOnly
+ />
+
+
+
+
+
+
+
+
)
}
diff --git a/packages/swagger-tanstack-query/src/components/Query.tsx b/packages/swagger-tanstack-query/src/components/Query.tsx
index 3e70d0611..0725c088f 100644
--- a/packages/swagger-tanstack-query/src/components/Query.tsx
+++ b/packages/swagger-tanstack-query/src/components/Query.tsx
@@ -1,7 +1,7 @@
import { PackageManager } from '@kubb/core'
import transformers from '@kubb/core/transformers'
import { FunctionParams, URLPath } from '@kubb/core/utils'
-import { File, Function, usePlugin, useResolveName } from '@kubb/react'
+import { Editor, File, Function, usePlugin, useResolveName } from '@kubb/react'
import { useOperation, useOperationFile, useOperationName, useSchemas } from '@kubb/swagger/hooks'
import { getASTParams, getComments, getParams, isRequired } from '@kubb/swagger/utils'
import { pluginKey as swaggerTsPluginKey } from '@kubb/swagger-ts'
@@ -456,76 +456,80 @@ Query.File = function({ templates, imports = QueryImports.templates }: FileProps
}
return (
-
- baseName={file.baseName}
- path={file.path}
- meta={file.meta}
- >
- {parser === 'zod' && }
-
-
- error.name) || [],
- ].filter(
- Boolean,
- )}
- root={file.path}
- path={fileType.path}
- isTypeOnly
- />
-
-
- {!!infinite && }
- {!!suspense && isV5 && framework === 'react' && }
-
-
-
- {!!infinite && (
-
+
+
+ baseName={file.baseName}
+ path={file.path}
+ meta={file.meta}
+ >
+ {parser === 'zod' && }
+
+
+ error.name) || [],
+ ].filter(
+ Boolean,
+ )}
+ root={file.path}
+ path={fileType.path}
+ isTypeOnly
/>
- )}
- {!!suspense && isV5 && framework === 'react' && (
-
- )}
-
-
+
+
+ {!!infinite && }
+ {!!suspense && isV5 && framework === 'react' && }
+
+
+
+ {!!infinite && (
+
+ )}
+ {!!suspense && isV5 && framework === 'react' && (
+
+ )}
+
+
+
+
)
}
diff --git a/packages/swagger-ts/src/components/Mutation.tsx b/packages/swagger-ts/src/components/Mutation.tsx
index 82d05e57a..86f770141 100644
--- a/packages/swagger-ts/src/components/Mutation.tsx
+++ b/packages/swagger-ts/src/components/Mutation.tsx
@@ -1,7 +1,7 @@
import transformers from '@kubb/core/transformers'
import { print } from '@kubb/parser'
import * as factory from '@kubb/parser/factory'
-import { File, usePlugin, usePluginManager } from '@kubb/react'
+import { Editor, File, usePlugin, usePluginManager } from '@kubb/react'
import { useOas, useOperation, useOperationFile, useOperationName, useSchemas } from '@kubb/swagger/hooks'
import { TypeBuilder } from '../TypeBuilder.ts'
@@ -123,20 +123,22 @@ Mutation.File = function({ mode }: FileProps): ReactNode {
const { source, imports } = builder.build()
return (
- <>
-
- baseName={file.baseName}
- path={file.path}
- meta={file.meta}
- >
- {mode === 'directory' && imports.map((item, index) => {
- return
- })}
-
- {source}
- {printCombinedSchema(factoryName, operation, schemas)}
-
-
- >
+
+
+
+ baseName={file.baseName}
+ path={file.path}
+ meta={file.meta}
+ >
+ {mode === 'directory' && imports.map((item, index) => {
+ return
+ })}
+
+ {source}
+ {printCombinedSchema(factoryName, operation, schemas)}
+
+
+
+
)
}
diff --git a/packages/swagger-ts/src/components/Oas.tsx b/packages/swagger-ts/src/components/Oas.tsx
index 23db45797..40262c64d 100644
--- a/packages/swagger-ts/src/components/Oas.tsx
+++ b/packages/swagger-ts/src/components/Oas.tsx
@@ -1,4 +1,4 @@
-import { File, Type, usePlugin } from '@kubb/react'
+import { Editor, File, Type, usePlugin } from '@kubb/react'
import { useFile } from '@kubb/react'
import { useOas } from '@kubb/swagger/hooks'
@@ -68,16 +68,20 @@ Oas.File = function({ name, typeName, templates = defaultTemplates }: FileProps)
const Template = templates.default
return (
-
- baseName={file.baseName}
- path={file.path}
- meta={file.meta}
- >
-
-
-
-
-
+
+
+
+ baseName={file.baseName}
+ path={file.path}
+ meta={file.meta}
+ >
+
+
+
+
+
+
+
)
}
diff --git a/packages/swagger-ts/src/components/Query.tsx b/packages/swagger-ts/src/components/Query.tsx
index 059c2338d..ee427fb9a 100644
--- a/packages/swagger-ts/src/components/Query.tsx
+++ b/packages/swagger-ts/src/components/Query.tsx
@@ -1,7 +1,7 @@
import transformers from '@kubb/core/transformers'
import { print } from '@kubb/parser'
import * as factory from '@kubb/parser/factory'
-import { File, usePlugin, usePluginManager } from '@kubb/react'
+import { Editor, File, usePlugin, usePluginManager } from '@kubb/react'
import { useOas, useOperation, useOperationFile, useOperationName, useSchemas } from '@kubb/swagger/hooks'
import { TypeBuilder } from '../TypeBuilder.ts'
@@ -123,20 +123,22 @@ Query.File = function({ mode }: FileProps): ReactNode {
const { source, imports } = builder.build()
return (
- <>
-
- baseName={file.baseName}
- path={file.path}
- meta={file.meta}
- >
- {mode === 'directory' && imports.map((item, index) => {
- return
- })}
-
- {source}
- {printCombinedSchema(factoryName, operation, schemas)}
-
-
- >
+
+
+
+ baseName={file.baseName}
+ path={file.path}
+ meta={file.meta}
+ >
+ {mode === 'directory' && imports.map((item, index) => {
+ return
+ })}
+
+ {source}
+ {printCombinedSchema(factoryName, operation, schemas)}
+
+
+
+
)
}
diff --git a/packages/swagger-zod/src/components/Mutation.tsx b/packages/swagger-zod/src/components/Mutation.tsx
index a0576ae61..11f0fce76 100644
--- a/packages/swagger-zod/src/components/Mutation.tsx
+++ b/packages/swagger-zod/src/components/Mutation.tsx
@@ -1,4 +1,4 @@
-import { File, usePlugin, usePluginManager } from '@kubb/react'
+import { Editor, File, usePlugin, usePluginManager } from '@kubb/react'
import { useOas, useOperationFile, useSchemas } from '@kubb/swagger/hooks'
import { ZodBuilder } from '../ZodBuilder.ts'
@@ -46,20 +46,22 @@ Mutation.File = function({ mode }: FileProps): ReactNode {
const { source, imports } = builder.build()
return (
- <>
-
- baseName={file.baseName}
- path={file.path}
- meta={file.meta}
- >
-
- {mode === 'directory' && imports.map((item, index) => {
- return
- })}
-
- {source}
-
-
- >
+
+
+
+ baseName={file.baseName}
+ path={file.path}
+ meta={file.meta}
+ >
+
+ {mode === 'directory' && imports.map((item, index) => {
+ return
+ })}
+
+ {source}
+
+
+
+
)
}
diff --git a/packages/swagger-zod/src/components/Query.tsx b/packages/swagger-zod/src/components/Query.tsx
index 2ddab11cf..31688c8fd 100644
--- a/packages/swagger-zod/src/components/Query.tsx
+++ b/packages/swagger-zod/src/components/Query.tsx
@@ -1,4 +1,4 @@
-import { File, usePlugin, usePluginManager } from '@kubb/react'
+import { Editor, File, usePlugin, usePluginManager } from '@kubb/react'
import { useOas, useOperationFile, useSchemas } from '@kubb/swagger/hooks'
import { ZodBuilder } from '../ZodBuilder.ts'
@@ -45,20 +45,22 @@ Query.File = function({ mode }: FileProps): ReactNode {
const { source, imports } = builder.build()
return (
- <>
-
- baseName={file.baseName}
- path={file.path}
- meta={file.meta}
- >
-
- {mode === 'directory' && imports.map((item, index) => {
- return
- })}
-
- {source}
-
-
- >
+
+
+
+ baseName={file.baseName}
+ path={file.path}
+ meta={file.meta}
+ >
+
+ {mode === 'directory' && imports.map((item, index) => {
+ return
+ })}
+
+ {source}
+
+
+
+
)
}
diff --git a/packages/swagger-zodios/src/components/Definitions.tsx b/packages/swagger-zodios/src/components/Definitions.tsx
index b8ae52002..83e1697a1 100644
--- a/packages/swagger-zodios/src/components/Definitions.tsx
+++ b/packages/swagger-zodios/src/components/Definitions.tsx
@@ -1,6 +1,6 @@
import transformers from '@kubb/core/transformers'
import { URLPath } from '@kubb/core/utils'
-import { File, useFile, usePlugin } from '@kubb/react'
+import { Editor, File, useFile, usePlugin } from '@kubb/react'
import { usePluginManager } from '@kubb/react'
import { pluginKey as swaggerZodPluginKey } from '@kubb/swagger-zod'
@@ -327,17 +327,21 @@ Definitions.File = function({ name, baseURL, paths, templates = defaultTemplates
const Template = templates.default
return (
-
- baseName={file.baseName}
- path={file.path}
- meta={file.meta}
- >
-
- {imports}
-
-
-
-
+
+
+
+ baseName={file.baseName}
+ path={file.path}
+ meta={file.meta}
+ >
+
+ {imports}
+
+
+
+
+
+
)
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 5bf4af1b5..16948ea6a 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -432,6 +432,43 @@ importers:
specifier: ~5.2.2
version: 5.2.2
+ examples/python:
+ dependencies:
+ '@kubb/cli':
+ specifier: workspace:*
+ version: link:../../packages/cli
+ '@kubb/core':
+ specifier: workspace:*
+ version: link:../../packages/core
+ '@kubb/react':
+ specifier: workspace:*
+ version: link:../../packages/react
+ '@kubb/swagger':
+ specifier: workspace:*
+ version: link:../../packages/swagger
+ '@kubb/swagger-client':
+ specifier: workspace:*
+ version: link:../../packages/swagger-client
+ '@kubb/swagger-ts':
+ specifier: workspace:*
+ version: link:../../packages/swagger-ts
+ axios:
+ specifier: ^1.6.7
+ version: 1.6.7
+ devDependencies:
+ '@kubb/ts-config':
+ specifier: workspace:*
+ version: link:../../packages/config/ts-config
+ react:
+ specifier: ^18.2.0
+ version: 18.2.0
+ tsup:
+ specifier: ^8.0.2
+ version: 8.0.2(@microsoft/api-extractor@7.40.2)(ts-node@10.9.2)(typescript@5.3.3)
+ typescript:
+ specifier: ^5.3.3
+ version: 5.3.3
+
examples/react-query:
dependencies:
'@kubb/cli':