Skip to content

support webhooks #187

@nfroidure

Description

@nfroidure

See this webhooks example.

To do:

  • types generator support Generate types for Webhooks schema2dts#38,
  • check this works fine with webhooks:
    export function cleanupOpenAPI(
    api: OpenAPIV3_1.Document,
    ): OpenAPIV3_1.Document {
    const seenRefs = [
    ...new Set(
    collectRefs(
    api as unknown as JsonObject,
    api.paths as unknown as JsonValue,
    ),
    ),
    ];
    return {
    ...api,
    components: {
    ...(Object.keys(api?.components || {}) as ComponentType[]).reduce(
    (cleanedComponents, componentType) => ({
    ...cleanedComponents,
    [componentType]: COMPONENTS_TYPES.includes(componentType)
    ? Object.keys(api?.components?.[componentType] || {})
    .filter((key) =>
    seenRefs.includes(`#/components/${componentType}/${key}`),
    )
    .reduce(
    (cleanedComponents, key) => ({
    ...cleanedComponents,
    [key]: api.components?.[componentType]?.[key],
    }),
    {},
    )
    : api.components?.[componentType],
    }),
    {},
    ),
    },
    };
    }
    (especially when an endpoint uses webhooks schemas, how to know it from the schema (if possible)),
  • think of the integration level: we could generate the API SDK in the watch function and add webhook implementation utilities (see Allow to create a webhooks SDK openapi-ts-sdk-builder#16 ).

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions