Skip to content

Generated types make an attachment's disposition required, though the spec gives it a default #8

Description

@AminDhouib

What happens

In sendly-sdk@1.0.0, dist/index.d.ts types an attachment's disposition as required:

attachments?: {
    filename: string
    content: string
    contentType?: string
    disposition: "attachment" | "inline"   // <- not optional
}[]

So this does not compile:

await sendly.emails.send({
    to: 'someone@example.com',
    from: 'us@example.com',
    subject: 'Report',
    body: '<p>Attached.</p>',
    attachments: [{ filename: 'report.pdf', content: base64 }],
})
// Property 'disposition' is missing in type '{ filename: string; content: string; }'

Why it is wrong

The OpenAPI schema declares default: "attachment" for that property, and it is not in the schema's required list. The API supplies the value; TypeScript should not force the caller to.

This is the usual openapi-typescript behaviour for a property carrying a default — the generator treats the default as a guarantee about the response shape and emits it as required on the request shape too. It is a generator artifact, not an intentional API constraint.

Suggested fix

The curated alias layer already solves exactly this elsewhere — PartialKeys<> is applied to CampaignV1Create.type and ListSubscribe.allowResubscribe. Extending it to the attachment item's disposition is a one-line change and needs no regeneration:

export type SendEmailV1Attachment = PartialKeys<
    NonNullable<components['schemas']['SendEmailV1']['attachments']>[number],
    'disposition'
>

It may be worth auditing the rest of the generated surface for other properties that carry a spec default and came out required for the same reason.

Context

Found while migrating a production app onto Sendly (transactional email, three services). Verified against the published sendly-sdk@1.0.0 tarball and https://api.sendly.now/api/openapi.json on 2026-09-03.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions