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

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

Closed
effect-bot opened this issue Jan 10, 2025 · 2 comments
Closed
Labels
enhancement New feature or request platform

Comments

@effect-bot
Copy link

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

@gcanti
Copy link
Contributor

gcanti commented Jan 11, 2025

The Content Type Issue is addressed in #4226

@gcanti gcanti added the enhancement New feature or request label Jan 11, 2025
@gcanti
Copy link
Contributor

gcanti commented Jan 15, 2025

Closing because response headers are tracked by #4045

@gcanti gcanti closed this as completed Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request platform
Projects
None yet
Development

No branches or pull requests

2 participants