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

Response types from openapi-fetch ignore null values #1637

Open
1 task done
gbbarroso opened this issue Apr 28, 2024 · 0 comments
Open
1 task done

Response types from openapi-fetch ignore null values #1637

gbbarroso opened this issue Apr 28, 2024 · 0 comments
Labels
bug Something isn't working openapi-fetch Relevant to the openapi-fetch library

Comments

@gbbarroso
Copy link

gbbarroso commented Apr 28, 2024

Description

Basically - types are getting a NonNullable<> somewhere and I believe they shouldn't

Reproduction
This was tested on version 0.9.3

type TestPaths = {
  '/v1/test': {
    /** @description Start a process flow */
    post: {
      /** @description Body */
      requestBody: {
        content: {
          'application/json': { test: boolean };
        };
      };
      responses: {
        /** @description Response */
        200: {
          content: {
            'application/json': { test: string | null };
          };
        };
      };
    };
  };
};

async function testFunction() {
  const client = createClient<TestPaths>({ baseUrl: '' });
  const result = await client
    .POST('/v1/test', { body: { test: true } })
    .then((x) => x.data);
  type Result = typeof result;
}

Expected result

Result should be { test: string | null }, not { test: string }

Checklist

@gbbarroso gbbarroso added bug Something isn't working openapi-fetch Relevant to the openapi-fetch library labels Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working openapi-fetch Relevant to the openapi-fetch library
Projects
None yet
Development

No branches or pull requests

1 participant