Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incorrect type generated when combining oneOf with properties #713

Closed
tannera-cargill opened this issue Jun 23, 2024 · 1 comment · Fixed by #745
Closed

incorrect type generated when combining oneOf with properties #713

tannera-cargill opened this issue Jun 23, 2024 · 1 comment · Fixed by #745
Labels
bug 🔥 Something isn't working

Comments

@tannera-cargill
Copy link

Description

This library is incorrectly generating TypeScript types for OpenAPI schemas that combine oneOf with properties. The generated type only includes the oneOf union, ignoring the additional properties defined in the schema.

OpenAPI specification (optional)

{
  "CompositionWithOneOfWithRefAndPropertiesFlat": {
    "type": "object",
    "oneOf": [
      {
        "$ref": "#/components/parameters/SimpleParameter"
      },
      {
        "$ref": "#/components/schemas/NonAsciiStringæøåÆØÅöôêÊ字符串"
      }
    ],
    "required": [
      "baz",
      "qux"
    ],
    "properties": {
      "baz": {
        "type": "integer",
        "format": "uint16",
        "minimum": 0.0,
        "nullable": true
      },
      "qux": {
        "type": "integer",
        "format": "uint8",
        "minimum": 0.0
      }
    }
  }
}

Expected behavior
The generated TypeScript type should be an intersection of the oneOf union and an object type with the additional properties. Something like:

export type CompositionWithOneOfWithRefAndPropertiesFlat = 
  (ParameterSimpleParameter | NonAsciiStringæøåÆØÅöôêÊ字符串) 
  & {
    baz?: number;
    qux: number;
  };

Actual behavior

export type CompositionWithOneOfWithRefAndPropertiesFlat = ParameterSimpleParameter | NonAsciiStringæøåÆØÅöôêÊ字符串;

Configuration

No response

System information (optional)

No response

@tannera-cargill tannera-cargill added the bug 🔥 Something isn't working label Jun 23, 2024
@mrlubos
Copy link
Contributor

mrlubos commented Jun 23, 2024

Thanks for reporting @tannera-cargill

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🔥 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants