Closed Fearghal-Des closed 1 week ago
kubb
2.18.20
Windows
@tanstack-query
MSW
React
Vue
"@tanstack/react-query": "^5.49.2", "react": "^18.3.1",
Specify an open api specification with a union of const types. Here is an example:
"kind": { "default": "open", "anyOf": [ { "const": "open", "type": "string" }, { "const": "invite_only", "type": "string" }, { "const": "request_to_join", "type": "string" }, { "const": "invite_only_hidden", "type": "string" } ] },
After running kubb generate the type definition is outputted like:
kind : (string | string | string | string)
The code was ran with the following kubb config:
import { defineConfig } from '@kubb/core' import { pluginOas } from '@kubb/plugin-oas' import { pluginTanstackQuery } from '@kubb/swagger-tanstack-query' import { pluginTs } from '@kubb/swagger-ts' import { pluginZod } from '@kubb/swagger-zod' export default defineConfig({ input: { path: './documentation.json', }, output: { path: './src/lib', }, plugins: [ pluginTs(), pluginOas(), pluginZod(), pluginTanstackQuery({ output: { path: './hooks', }, group: { type: 'tag', output: './hooks/{{tag}}Hooks' }, framework: 'react', dataReturnType: 'full', mutate: { variablesType: 'hook', methods: [ 'post', 'put', 'delete' ], }, infinite: { queryParam: 'next_page', initialPageParam: 0, cursorParam: 'nextCursor', }, query: { methods: [ 'get' ], importPath: "@tanstack/react-query" }, suspense: {}, parser: 'zod', }), ], })
Every time
Expected behaviour is for the type of kind to be declared like:
kind : "open" | "invite_only" | "request_to_join" | "invite_only_hidden"
An example of a relevant section of the OpenAPI file is here:
The OpenAPI specification was auto generated using the ElysiaJS Swagger plugin.
Be aware that const is only a feature in OpenAPI 3.1.x so if your version is not set to 3.1.0 or higher it will just return 'string'.
const
What version of
kubb
is running?2.18.20
What platform is your computer?
Windows
What version of external packages are you using(
@tanstack-query
,MSW
,React
,Vue
, ...)"@tanstack/react-query": "^5.49.2", "react": "^18.3.1",
What steps can reproduce the bug?
Specify an open api specification with a union of const types. Here is an example:
After running kubb generate the type definition is outputted like:
The code was ran with the following kubb config:
How often does this bug happen?
Every time
What is the expected behavior?
Expected behaviour is for the type of kind to be declared like:
Swagger/OpenAPI file?
An example of a relevant section of the OpenAPI file is here:
Additional information
The OpenAPI specification was auto generated using the ElysiaJS Swagger plugin.