hey-api / openapi-ts

🚀 The OpenAPI to TypeScript codegen. Generate clients, SDKs, validators, and more. Support: @mrlubos
https://heyapi.dev
Other
1.4k stars 106 forks source link

Webhooks not generated as services with OpenAPI 3.1 Specification #1252

Open markkkkas opened 2 weeks ago

markkkkas commented 2 weeks ago

Description

With OpenAPI Specification 3.1, webhooks are not generated as services, resulting in an empty file.

// services.gen.ts
// This file is auto-generated by @hey-api/openapi-ts

import { createClient, createConfig, type Options } from '@hey-api/client-axios';

export const client = createClient(createConfig());
// types.gen.ts
// This file is auto-generated by @hey-api/openapi-ts

export type Pet = {
    id: number;
    name: string;
    tag?: string;
};

Reproducible example or configuration

import { defineConfig } from '@hey-api/openapi-ts';

export default defineConfig({
    client: '@hey-api/client-axios',
    input: './webhook.yaml',
    output: './src/generated-client',
    schemas: false,
});

OpenAPI specification (optional)

openapi: 3.1.0
info:
  title: Webhook Example
  version: 1.0.0
  description: >
    Easy example of documentation with a single webhook,
    provided by OpenAPI Initiative.

webhooks:
  newPet:
    post:
      description: A new pet is born, let's come and discover it in Petstore.
      requestBody:
        description: Information about a new pet in the system
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Pet"
      responses:
        "200":
          description: Return a 200 status to indicate that the data was received successfully

components:
  schemas:
    Pet:
      required:
        - id
        - name
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
        tag:
          type: string

System information (optional)

@hey-api/client-axios: 0.2.7 @hey-api/openapi-ts": 0.53.5

mrlubos commented 2 weeks ago

Hi @markkkkas, yep, that needs to be (and will be) added https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/openApi/3.1.x/parser/index.ts#L204

mrlubos commented 2 weeks ago

@markkkkas can you provide more details about your use case? How are you using webhooks? Do you use or expect to use any of the third party plugins?