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

feat(fetch): include error types in data type of fetch response #1776

Conversation

soartec-lab
Copy link
Member

Status

READY

Description

fix #1588
The data type of the fetch response now includes the error type.

Context

When you have multiple response types schema like a below:

paths:
  /pets:
    get:
      summary: List all pets
      operationId: listPets
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Pets'
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequest'

Before

So far, orval has only generated success type:

export type listPetsResponse = {
  data: Pets;
  status: number;
  headers: Headers;
};

After

From now on, it will generate a union that includes the error type

export type listPetsResponse = {
  data: Pets | BadRequest;
  status: number;
  headers: Headers;
};

Related PRs

none

Todos

  • Tests
  • Documentation
  • Changelog Entry (unreleased)

Steps to Test or Reproduce

you can check by sample apps

@soartec-lab soartec-lab added enhancement New feature or request fetch Fetch client related issue labels Dec 28, 2024
@soartec-lab soartec-lab added this to the 7.3.1 milestone Dec 28, 2024
@melloware melloware merged commit 17b1517 into orval-labs:master Dec 28, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fetch Fetch client related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fetch: generator does not seem to support multiple response types
2 participants