Skip to content

From Discord: Expressing Base64 Encoding and Headers in HttpApi Module #4229

Closed
@effect-bot

Description

@effect-bot

Summary

In the conversation, the user is attempting to express an API endpoint using the HttpApi module, which returns a PDF as a base64 string. The user provides an OpenAPI specification and shares their current TypeScript implementation using the HttpApi module. However, the current implementation lacks certain details, such as base64 encoding and response headers.

  1. Base64 Encoding:

    • To handle the base64 encoding, you can set a jsonSchema annotation on a Schema, marking the string as a base64 format. This is done by creating a Base64String schema with the appropriate JSON schema descriptor ("format": "base64").
  2. Response Headers:

    • There is no current method in the HttpApi module to define response headers directly within the TypeScript implementation shared in this conversation.
  3. Content Type Issue:

    • The specification of contentType: "application/pdf" seems to be ignored when using the HttpApiSchema.withEncoding.

The key takeaways are:

  • You can specify custom formats and JSON schema annotations in the HttpApi module using codecs in Effect TypeScript.
  • The current version of the HttpApi module may not support expressing response headers, and there could be limitations in specifying certain content types directly.

Discord thread

https://discord.com/channels/795981131316985866/1326480481637896242

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions