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

Orval Generating a Specific File for Union Types #1959

Open
tarcisioandrade opened this issue Mar 3, 2025 · 3 comments
Open

Orval Generating a Specific File for Union Types #1959

tarcisioandrade opened this issue Mar 3, 2025 · 3 comments
Labels
question Further information is requested

Comments

@tarcisioandrade
Copy link

tarcisioandrade commented Mar 3, 2025

When we have a union types the orval creates a file and a specific type for it, instead of putting it inline.

Example:

AddressDto in Backend

Image

AddressDto generated by orval

Image

Image

Image

An AddressDtoStreat file was created instead of placed inline string | null.

Is there any setting that changes this behavior?

Version
"orval": "7.4.0"

@melloware melloware added the question Further information is requested label Mar 3, 2025
@AllieJonsson
Copy link
Contributor

How does the OpenAPI specification look like? Is there a lot of oneOf in the spec?

type: object
oneOf:
  - string
  - null

since this is not something that happens when the specification is something like

type: string
nullable: true

@tarcisioandrade
Copy link
Author

How does the OpenAPI specification look like? Is there a lot of oneOf in the spec?

type: object
oneOf:

  • string
  • null
    since this is not something that happens when the specification is something like

type: string
nullable: true

Yes, my OpenAPI generates using oneOf.

Image

So to solve this, I just have to prevent him from using oneOf, correct?

@AllieJonsson
Copy link
Contributor

Yes, currently that is the only solution. If you cant change the actual spec, you could do some fiddeling in the input.transformer config setting to turn your

{
  "oneOf": [
    {
      "type": "null"
    },
    {
      "type": xxx
    }
  ]
}

Into

{
  "type": xxx,
  "nullable": true
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants