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

Bug: RequestBody type omits application/json when application/json doesn't have schema property

Open tkow opened this issue 1 year ago • 0 comments

Steps To Reproduce

If oas file has lacked schema property about media type, RequestBody type omits application/json type. This cause build error because Param type generates reference to it. See followed by an example.

requestBody:
        description: The request body is currently not used.
        required: true
        content:
          application/json:
            example: '{}'

I thought it's loose schema definition, but OAS doesn't require it must be specified.

Run bun i && bun gen.ts && npx tsc --noEmit ./src/client.ts in https://github.com/tkow/cloudflare-ts-client.

スクリーンショット 2024-02-12 17 06 35

The current behavior

Params type generate requestBody refers to RequstBodyType,

requestBody: RequestBody$zone$cache$settings$start$cache$reserve$clear["application/json"]

but empty RequestBody type is generated.

export interface RequestBody$zone$cache$settings$start$cache$reserve$clear {
}

The expected behavior

It may be suitable that it generates

export interface RequestBody$zone$cache$settings$start$cache$reserve$clear {
  "application/json": any
}

tkow avatar Feb 12 '24 08:02 tkow