8000 Generated discriminator types do not have discriminator set to the mapping string · Issue #1736 · kubb-labs/kubb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Generated discriminator types do not have discriminator set to the mapping string #1736
Open
@xeoneux

Description

@xeoneux

What version of kubb is running?

3.10.12

What kind of platform do you use?

MacOS

Your kubb.config.ts config file?

The same one as e2e/kubb.config.js

Swagger/OpenAPI file?

The same one as e2e/schemas/discriminator.yaml

What version of external packages are you using(@tanstack-query, MSW, React, Vue, ...)

-

What steps can reproduce the bug?

The generated types, EnumerationValueSpecificationDto, RangeValueSpecificationDto, RegexValueSpecificationDto and SliderValueSpecificationDto all have property type as string.

For example

export type EnumerationValueSpecificationDto = {
  /**
   * @minLength 1
   * @type string
   */
  readonly type: string
  /**
   * @type array
   */
  enumeration: string[]
}

How often does this bug happen?

Every time

What is the expected behaviour?

Instead, their type should be the specific string provided in their discriminator (just like Cat or Dog)
It should be type: 'enum' for EnumerationValueSpecificationDto and type: 'range' for RangeValueSpecificationDto and so on...

So that when EnumerationValueSpecificationDto is without the parent context, this should fail

let enum: EnumerationValueSpecificationDto;
enum.type = 'range'; // !!! Should be a type error, but isn't

It is fine for Cat or Dog

export type Cat = {
  /**
   * @type string, uuid
   */
  id: string
  /**
   * @type string
   */
  type: 'Cat'
  /**
   * @type boolean | undefined
   */
  meow?: boolean
}

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0