openapi-typescript icon indicating copy to clipboard operation
openapi-typescript copied to clipboard

Response types from openapi-fetch ignore null values

Open gbbarroso opened this issue 10 months ago • 0 comments

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 avatar Apr 28 '24 05:04 gbbarroso