astahmer / typed-openapi

Generate a headless Typescript API client from an OpenAPI spec
https://typed-openapi-web.vercel.app/
195 stars 24 forks source link

Response of content type '*/*' does not resolve properly #52

Open njbair opened 1 month ago

njbair commented 1 month ago

Given the minimal example YAML below, note how the generated schema includes response: unknown. After some testing, I determined this only happens when the content type is '*/*'. If I change it to application/json, it works fine.

openapi: 3.0.3
info:
  title: Test API Spec
  version: 1.0.0
components:
  schemas:
    Response:
      properties:
        id:
          type: integer
        name:
          type: string
      type: object
paths:
  /test:
    get:
      operationId: getTest
      responses:
        '200':
          content:
            '*/*':
              schema:
                items:
                  $ref: '#/components/schemas/Response'
                type: array
servers:
  - url: https://api.example.com

...this produces a response of type unknown:

  export type get_GetTest = {
    method: "GET";
    path: "/test";
    requestFormat: "json";
    parameters: never;
    response: unknown;
  };

Originally posted by @njbair in https://github.com/astahmer/typed-openapi/issues/51#issuecomment-2341454776