Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support callbacks #188

Open
2 of 3 tasks
Tracked by #79
nfroidure opened this issue Oct 17, 2024 · 0 comments
Open
2 of 3 tasks
Tracked by #79

support callbacks #188

nfroidure opened this issue Oct 17, 2024 · 0 comments
Assignees

Comments

@nfroidure
Copy link
Owner

nfroidure commented Oct 17, 2024

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 ).
@nfroidure nfroidure mentioned this issue Oct 17, 2024
9 tasks
@nfroidure nfroidure self-assigned this Oct 17, 2024
nfroidure added a commit that referenced this issue Feb 17, 2025
Allow to define callbacks and generate types for it. This is a first approach and could be improved
before the final version.

concerns #188
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant