Closed
Description
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.
-
Base64 Encoding:
- To handle the base64 encoding, you can set a
jsonSchema
annotation on aSchema
, marking the string as a base64 format. This is done by creating aBase64String
schema with the appropriate JSON schema descriptor ("format": "base64"
).
- To handle the base64 encoding, you can set a
-
Response Headers:
- There is no current method in the HttpApi module to define response headers directly within the TypeScript implementation shared in this conversation.
-
Content Type Issue:
- The specification of
contentType: "application/pdf"
seems to be ignored when using theHttpApiSchema.withEncoding
.
- The specification of
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