Skip to content

support callbacks #188

@nfroidure

Description

@nfroidure

See this callbacks example.

To do:

  • types generator support Generate types for callbacks schema2dts#39,
  • check this works fine with callbacks:
    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],
    }),
    {},
    ),
    },
    };
    }
    ,
  • think of the integration level: we could generate the API SDK in the watch function and add callback implementation utilities (see Allow to create a callbacks SDK openapi-ts-sdk-builder#17 ).

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions